Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Phobos.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<PropertyGroup>
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<PlatformToolset>v145</PlatformToolset>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
Expand Down
7 changes: 2 additions & 5 deletions Phobos.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,6 @@
<ClCompile Include="src\Interop\BulletExt.cpp" />
<ClCompile Include="src\Interop\EventExt.cpp" />
<ClCompile Include="src\Interop\TechnoExt.cpp" />
<ClCompile Include="src\Interop\ScenarioExt.cpp" />
<ClCompile Include="src\Interop\Version.cpp" />
<!-- src\Locomotion -->
<ClCompile Include="src\Locomotion\TestLocomotionClass.cpp" />
<!-- src\Misc -->
Expand Down Expand Up @@ -247,6 +245,7 @@
<!-- src\New\Entity -->
<ClCompile Include="src\New\Entity\Ares\RadarJammerClass.cpp" />
<ClCompile Include="src\New\Entity\AttachEffectClass.cpp" />
<ClCompile Include="src\New\Entity\VectorState.cpp" />
<ClCompile Include="src\New\Entity\BannerClass.cpp" />
<ClCompile Include="src\New\Entity\LaserTrailClass.cpp" />
<ClCompile Include="src\New\Entity\ShieldClass.cpp" />
Expand Down Expand Up @@ -357,8 +356,6 @@
<ClInclude Include="src\Interop\BulletExt.h" />
<ClInclude Include="src\Interop\EventExt.h" />
<ClInclude Include="src\Interop\TechnoExt.h" />
<ClInclude Include="src\Interop\ScenarioExt.h" />
<ClInclude Include="src\Interop\Version.h" />
<!-- src\Locomotion -->
<ClInclude Include="src\Locomotion\TestLocomotionClass.h" />
<!-- src\Misc -->
Expand Down Expand Up @@ -418,4 +415,4 @@
<ClInclude Include="src\Utilities\Template.h" />
<ClInclude Include="src\Utilities\TemplateDef.h" />
</ItemGroup>
</Project>
</Project>
51 changes: 49 additions & 2 deletions src/Ext/Bullet/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#include <Ext/WeaponType/Body.h>
#include <Ext/Cell/Body.h>
#include <Ext/EBolt/Body.h>
#include <Ext/Techno/Body.h>
#include <New/Entity/LaserTrailClass.h>
#include <New/Entity/VectorState.h>

BulletExt::ExtContainer BulletExt::ExtMap;

Expand Down Expand Up @@ -487,8 +489,48 @@ void BulletExt::ExtData::Serialize(T& Stm)
.Process(this->ParabombFallRate)
.Process(this->IsInstantDetonation)
.Process(this->FirepowerMult)

.Process(this->Trajectory) // Keep this shit at last
.Process(this->VectorType)
.Process(this->Vector.Initialized)
.Process(this->Vector.CurrentFrame)
.Process(this->Vector.DisabledTimer)
.Process(this->Vector.CurrentSpeed)
.Process(this->Vector.CurrentAngle)
.Process(this->Vector.CurrentCircleRadius)
.Process(this->Vector.CurrentCircleSpeed)
.Process(this->Vector.CurrentCircleAngle)
.Process(this->Vector.InitialOriginPos)
.Process(this->Vector.InitialLocation)
.Process(this->Vector.PrevCirclePos)
.Process(this->Vector.ArcHeight)
.Process(this->Vector.ArcRotation)
.Process(this->Vector.TargetOffset)
.Process(this->Vector.NormalRotF)
.Process(this->Vector.NormalRotL)
.Process(this->Vector.NormalRotH)
.Process(this->Vector.NormalStepF)
.Process(this->Vector.NormalStepL)
.Process(this->Vector.NormalStepH)
.Process(this->Vector.MovementFrames)
.Process(this->Vector.FacingRad)
.Process(this->Vector.TiltRad)
.Process(this->Vector.OriginOffset)
.Process(this->Vector.PrevCircleCenter)
.Process(this->Vector.OriginElapsed)
.Process(this->Vector.OriginSpeed)
.Process(this->Vector.OriginAngle)
.Process(this->Vector.OriginTargetOffset)
.Process(this->Vector.OriginCircleRadiusRuntime)
.Process(this->Vector.OriginCircleSpeedRuntime)
.Process(this->Vector.OriginCircleAngleRuntime)
.Process(this->Vector.OriginNormalRotFRuntime)
.Process(this->Vector.OriginNormalRotLRuntime)
.Process(this->Vector.OriginNormalRotHRuntime)
.Process(this->Vector.OriginNormalStepF)
.Process(this->Vector.OriginNormalStepL)
.Process(this->Vector.OriginNormalStepH)
.Process(this->Vector.OriginFacing)
.Process(this->Vector.OriginTilt)
.Process(this->Trajectory)
;
}

Expand All @@ -511,6 +553,11 @@ BulletExt::ExtContainer::ExtContainer() : Container("BulletClass") { }

BulletExt::ExtContainer::~ExtContainer() = default;

void BulletExt::ExtData::VectorAI()
{
VectorAI_Run(this->OwnerObject(), this->VectorType, this->Vector, this->OwnerObject() ? static_cast<BulletClass*>(this->OwnerObject())->Owner : nullptr, true);
}

// =============================
// container hooks

Expand Down
9 changes: 9 additions & 0 deletions src/Ext/Bullet/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <Ext/BulletType/Body.h>
#include <Ext/TechnoType/Body.h>
#include <New/Entity/LaserTrailClass.h>
#include <New/Type/AttachEffectTypeClass.h>
#include <New/Entity/VectorState.h>

struct RadialFireStruct
{
Expand Down Expand Up @@ -38,6 +40,11 @@ class BulletExt

TrajectoryPointer Trajectory;

AttachEffectTypeClass* VectorType;
VectorState Vector;

void VectorAI();

ExtData(BulletClass* OwnerObject) : Extension<BulletClass>(OwnerObject)
, TypeExtData { nullptr }
, FirerHouse { nullptr }
Expand All @@ -47,6 +54,8 @@ class BulletExt
, DetonateOnInterception { true }
, LaserTrails {}
, Trajectory { nullptr }
, VectorType { nullptr }
, Vector {}
, SnappedToTarget { false }
, DamageNumberOffset { INT32_MIN }
, ParabombFallRate { 0 }
Expand Down
26 changes: 23 additions & 3 deletions src/Ext/Bullet/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ DEFINE_HOOK(0x466556, BulletClass_Init, 0x6)
{
pExt->FirerHouse = pThis->Owner->Owner;
pExt->FirepowerMult = TechnoExt::GetCurrentFirepowerMultiplier(pThis->Owner);

// Init Vector from firing techno's AE types
auto const pTechnoExt = TechnoExt::ExtMap.Find(pThis->Owner);
for (auto const& ae : pTechnoExt->AttachedEffects)
{
auto const pAEType = ae->GetType();
if (!pAEType) continue;
if (pAEType->HasVector() && pAEType->Vector_AffectBullets)
{
pExt->VectorType = pAEType;
break;
}
}
}

auto const pType = pThis->Type;
Expand Down Expand Up @@ -44,6 +57,14 @@ DEFINE_HOOK(0x4666F7, BulletClass_AI, 0x6)
BulletAITemp::ExtData = pBulletExt;
BulletAITemp::TypeExtData = pBulletTypeExt;

if (pBulletExt->VectorType)
{
if (pBulletExt->Vector.CurrentFrame >= pBulletExt->VectorType->Duration)
pBulletExt->VectorType = nullptr;
else
pBulletExt->VectorAI();
}

if (pBulletExt->InterceptedStatus & InterceptedStatus::Targeted)
{
if (const auto pTarget = abstract_cast<BulletClass*>(pThis->Target))
Expand Down Expand Up @@ -81,9 +102,8 @@ DEFINE_HOOK(0x4666F7, BulletClass_AI, 0x6)
}
}

//Because the laser trails will be drawn before the calculation of changing the velocity direction in each frame.
//This will cause the laser trails to be drawn in the wrong position too early, resulting in a visual appearance resembling a "bouncing".
//Let trajectories draw their own laser trails after the Trajectory's OnAI() to avoid predicting incorrect positions or pass through targets.
// VectorAI moved to BulletClass_AI_Trailer for correct engine-movement-final override

if (!pBulletExt->Trajectory && pBulletExt->LaserTrails.size())
{
const CoordStruct location = pThis->GetCoords();
Expand Down
14 changes: 14 additions & 0 deletions src/Ext/Techno/Body.Update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1944,6 +1944,20 @@ void TechnoExt::ExtData::UpdateAttachEffects()
}
}

// Next AE chain
if (hasExpired && !pType->Next.empty())
{
auto const pInvoker = attachEffect->GetInvoker();
auto const pInvokerHouse = attachEffect->InvokerHouse;
for (auto pNextType : pType->Next)
{
if (pNextType)
AttachEffectClass::CreateAndAttach(pNextType, pThis, pThis->GetTechnoType(), this->AttachedEffects,
pInvokerHouse ? pInvokerHouse : pThis->Owner, pInvoker ? pInvoker : pThis, attachEffect->Source, AEAttachParams{});
}
altered = true;
}

if (shouldDiscard && attachEffect->ResetIfRecreatable())
{
++it;
Expand Down
59 changes: 59 additions & 0 deletions src/New/Entity/AttachEffectClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ AttachEffectClass::AttachEffectClass()
, NeedsRecalculateStat { false }
, LastDiscardCheckFrame { -1 }
, LastDiscardCheckValue { false }
, Vector { }
{
this->HasInitialized = false;
AttachEffectClass::Array.emplace_back(this);
Expand Down Expand Up @@ -257,6 +258,7 @@ void AttachEffectClass::AI()
this->CloakCheck();
this->OnlineCheck();
this->AnimCheck();
this->VectorAI();
}

void AttachEffectClass::AI_Temporal()
Expand Down Expand Up @@ -1059,6 +1061,23 @@ void AttachEffectClass::TransferAttachedEffects(TechnoClass* pSource, TechnoClas

#pragma endregion

CoordStruct AttachEffectClass::GetFLHAbsoluteCoords(CoordStruct origin, CoordStruct flh, DirStruct facing)
{
double rad = facing.GetRadian<32>();
double cosR = std::cos(rad);
double sinR = std::sin(rad);
return { origin.X + static_cast<int>(flh.X * cosR + flh.Y * sinR),
origin.Y + static_cast<int>(flh.X * sinR - flh.Y * cosR),
origin.Z + flh.Z };
}

void AttachEffectClass::VectorAI()
{
if (!this->Type->Vector_AffectTechno)
return;
VectorAI_Run(this->Techno, this->Type, this->Vector, this->Invoker, false);
}

// =============================
// load / save

Expand Down Expand Up @@ -1092,6 +1111,46 @@ bool AttachEffectClass::Serialize(T& Stm)
.Process(this->LastActiveStat)
.Process(this->LaserTrail)
.Process(this->NeedsRecalculateStat)
.Process(this->Vector.Initialized)
.Process(this->Vector.CurrentFrame)
.Process(this->Vector.DisabledTimer)
.Process(this->Vector.CurrentSpeed)
.Process(this->Vector.CurrentAngle)
.Process(this->Vector.CurrentCircleRadius)
.Process(this->Vector.CurrentCircleSpeed)
.Process(this->Vector.CurrentCircleAngle)
.Process(this->Vector.InitialOriginPos)
.Process(this->Vector.InitialLocation)
.Process(this->Vector.PrevCirclePos)
.Process(this->Vector.ArcHeight)
.Process(this->Vector.ArcRotation)
.Process(this->Vector.TargetOffset)
.Process(this->Vector.NormalRotF)
.Process(this->Vector.NormalRotL)
.Process(this->Vector.NormalRotH)
.Process(this->Vector.NormalStepF)
.Process(this->Vector.NormalStepL)
.Process(this->Vector.NormalStepH)
.Process(this->Vector.MovementFrames)
.Process(this->Vector.FacingRad)
.Process(this->Vector.TiltRad)
.Process(this->Vector.OriginOffset)
.Process(this->Vector.PrevCircleCenter)
.Process(this->Vector.OriginElapsed)
.Process(this->Vector.OriginSpeed)
.Process(this->Vector.OriginAngle)
.Process(this->Vector.OriginTargetOffset)
.Process(this->Vector.OriginCircleRadiusRuntime)
.Process(this->Vector.OriginCircleSpeedRuntime)
.Process(this->Vector.OriginCircleAngleRuntime)
.Process(this->Vector.OriginNormalRotFRuntime)
.Process(this->Vector.OriginNormalRotLRuntime)
.Process(this->Vector.OriginNormalRotHRuntime)
.Process(this->Vector.OriginNormalStepF)
.Process(this->Vector.OriginNormalStepL)
.Process(this->Vector.OriginNormalStepH)
.Process(this->Vector.OriginFacing)
.Process(this->Vector.OriginTilt)
.Success();
}

Expand Down
15 changes: 12 additions & 3 deletions src/New/Entity/AttachEffectClass.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <New/Type/AttachEffectTypeClass.h>
#include <New/Entity/VectorState.h>

class LaserTrailClass;

Expand All @@ -22,6 +23,7 @@ class AttachEffectClass
void CreateAnim();
void UpdateCumulativeAnim();
void TransferCumulativeAnim(AttachEffectClass* pSource);
void VectorAI();

bool CanShowAnim() const
{
Expand Down Expand Up @@ -58,15 +60,16 @@ class AttachEffectClass
static int Detach(TechnoClass* pTarget, AEAttachInfoTypeClass const& attachEffectInfo);
static int DetachByGroups(TechnoClass* pTarget, AEAttachInfoTypeClass const& attachEffectInfo);
static void TransferAttachedEffects(TechnoClass* pSource, TechnoClass* pTarget);
static CoordStruct GetFLHAbsoluteCoords(CoordStruct origin, CoordStruct flh, DirStruct facing);

static AttachEffectClass* CreateAndAttach(AttachEffectTypeClass* pType, TechnoClass* pTarget, TechnoTypeClass* pTargetType, std::vector<std::unique_ptr<AttachEffectClass>>& targetAEs, HouseClass* pInvokerHouse, TechnoClass* pInvoker,
AbstractClass* pSource, AEAttachParams const& attachInfo, bool checkCumulative = true);

private:
void OnlineCheck();
void CloakCheck();
void AnimCheck();

static AttachEffectClass* CreateAndAttach(AttachEffectTypeClass* pType, TechnoClass* pTarget, TechnoTypeClass* pTargetType, std::vector<std::unique_ptr<AttachEffectClass>>& targetAEs, HouseClass* pInvokerHouse, TechnoClass* pInvoker,
AbstractClass* pSource, AEAttachParams const& attachInfo, bool checkCumulative = true);

static int DetachTypes(TechnoClass* pTarget, AEAttachInfoTypeClass const& attachEffectInfo, std::vector<AttachEffectTypeClass*> const& types);
static int RemoveAllOfType(AttachEffectTypeClass* pType, TechnoClass* pTarget, int minCount, int maxCount);

Expand All @@ -81,9 +84,13 @@ class AttachEffectClass
int RecreationDelay;
AttachEffectTypeClass* Type;
TechnoClass* Techno;

public:
HouseClass* InvokerHouse;
TechnoClass* Invoker;
AbstractClass* Source;

private:
AnimClass* Animation;
bool IsAnimHidden;
bool IsInTunnel;
Expand All @@ -101,6 +108,8 @@ class AttachEffectClass
bool HasCumulativeAnim;
bool ShouldBeDiscarded;
bool NeedsRecalculateStat;

VectorState Vector;
};

// Container for TechnoClass-specific AttachEffect fields.
Expand Down
Loading
Loading