Skip to content

Commit

Permalink
IC/BerserkColor
Browse files Browse the repository at this point in the history
  • Loading branch information
chaserli committed Jan 15, 2023
1 parent 59f7a67 commit 319adb0
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 6 deletions.
47 changes: 47 additions & 0 deletions src/Ext/Techno/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,3 +693,50 @@ DEFINE_HOOK(0x4DEAEE, FootClass_IronCurtain_Organics, 0x6)
}

DEFINE_JUMP(VTABLE, 0x7EB1AC, 0x4DEAE0); // Redirect InfantryClass::IronCurtain to FootClass::IronCurtain

DEFINE_HOOK(0x518FBC, InfantryClass_Draw_If, 0x6)
{
GET(InfantryClass*, pThis, EBP);

R->AL(pThis->Berzerk || pThis->IsIronCurtained());

return 0x518FC2;
}

DEFINE_HOOK(0x518FDA, InfantryClass_Draw_BerserkColor, 0x6)
{
GET(RulesClass*, pRules, ECX);
GET(InfantryClass*, pThis, EBP);

auto typeExt = TechnoTypeExt::ExtMap.Find(pThis->Type);

R->EAX(pThis->IsIronCurtained()?typeExt->IronCurtainColor.Get(pRules->IronCurtainColor)
: typeExt->BerserkColor.Get(pRules->BerserkColor));

return 0x518FE0;
}


DEFINE_HOOK(0x73BFBF, UnitClass_Draw_ICcolor, 0x6)
{
GET(RulesClass*, pRules, ESI);
GET(UnitClass*, pThis, EBP);

auto typeExt = TechnoTypeExt::ExtMap.Find(pThis->Type);

R->EAX(typeExt->IronCurtainColor.Get(pRules->IronCurtainColor));

return 0x73BFC5;
}

DEFINE_HOOK(0x73C097, UnitClass_Draw_BerserkColor, 0x6)
{
GET(RulesClass*, pRules, EDI);
GET(UnitClass*, pThis, EBP);

auto typeExt = TechnoTypeExt::ExtMap.Find(pThis->Type);

R->EAX(typeExt->BerserkColor.Get(pRules->BerserkColor));

return 0x73C09D;
}
6 changes: 6 additions & 0 deletions src/Ext/TechnoType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->ProneSecondaryFireFLH.Read(exArtINI, pArtSection, "ProneSecondaryFireFLH");
this->DeployedPrimaryFireFLH.Read(exArtINI, pArtSection, "DeployedPrimaryFireFLH");
this->DeployedSecondaryFireFLH.Read(exArtINI, pArtSection, "DeployedSecondaryFireFLH");
#define YRSTR(add) reinterpret_cast<const char*>(add)
this->BerserkColor.Read(exINI, pSection, YRSTR(0x83A194));
this->IronCurtainColor.Read(exINI, pSection, YRSTR(0x83A1A4));
#undef YRSTR
}

template <typename T>
Expand Down Expand Up @@ -400,6 +404,8 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
.Process(this->EliteDeployedWeaponBurstFLHs)

.Process(this->IronCurtain_KeptOnDeploy)
.Process(this->BerserkColor)
.Process(this->IronCurtainColor)
.Process(this->IronCurtain_Effect)
.Process(this->IronCurtain_KillWarhead)

Expand Down
3 changes: 2 additions & 1 deletion src/Ext/TechnoType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ class TechnoTypeExt
Nullable<WarheadTypeClass*> IronCurtain_KillWarhead;
Valueable<bool> Explodes_KillPassengers;
Nullable<int> DeployFireWeapon;

Nullable<int> BerserkColor {};
Nullable<int> IronCurtainColor {};
struct LaserTrailDataEntry
{
ValueableIdx<LaserTrailTypeClass> idxType;
Expand Down
18 changes: 18 additions & 0 deletions src/Ext/Unit/Hooks.Jumpjet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,21 @@ DEFINE_HOOK(0x54CB0E, JumpjetLocomotionClass_State5_CrashSpin, 0x7)
}

//TODO : Issue #690 #655

DEFINE_HOOK(0x54DCCF, JJLoco_DrawMatrix_TiltCrashJj, 0x5)
{
GET(ILocomotion*, iloco, ESI);

if ((static_cast<JumpjetLocomotionClass*>(iloco)->State) < JumpjetLocomotionClass::State::Crashing)
return 0x54DCE8;
return 0;
}

DEFINE_HOOK(0x54DD3D, JJLoco_DrawMatrix_Axis, 0x5)
{
GET(ILocomotion*, iloco, ESI);
auto state = static_cast<JumpjetLocomotionClass*>(iloco)->State;
if (state && state < JumpjetLocomotionClass::State::Descending)
return 0x54DE88;
return 0;
}
2 changes: 2 additions & 0 deletions src/Ext/WeaponType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ void WeaponTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->FeedbackWeapon.Read(exINI, pSection, "FeedbackWeapon", true);
this->Laser_IsSingleColor.Read(exINI, pSection, "IsSingleColor");
this->ROF_RandomDelay.Read(exINI, pSection, "ROF.RandomDelay");
this->RockerPitch.Read(exINI, pSection, "RockerPitch");
}

template <typename T>
Expand All @@ -58,6 +59,7 @@ void WeaponTypeExt::ExtData::Serialize(T& Stm)
.Process(this->AreaFire_Target)
.Process(this->FeedbackWeapon)
.Process(this->Laser_IsSingleColor)
.Process(this->RockerPitch)
.Process(this->ROF_RandomDelay)
;
};
Expand Down
2 changes: 2 additions & 0 deletions src/Ext/WeaponType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class WeaponTypeExt
Nullable<WeaponTypeClass*> FeedbackWeapon;
Valueable<bool> Laser_IsSingleColor;
Nullable<PartialVector2D<int>> ROF_RandomDelay;
Valueable<float> RockerPitch;

ExtData(WeaponTypeClass* OwnerObject) : Extension<WeaponTypeClass>(OwnerObject)
, DiskLaser_Radius { DiskLaserClass::Radius }
Expand All @@ -47,6 +48,7 @@ class WeaponTypeExt
, FeedbackWeapon {}
, Laser_IsSingleColor { false }
, ROF_RandomDelay {}
, RockerPitch { 0 }
{ }

virtual ~ExtData() = default;
Expand Down
22 changes: 21 additions & 1 deletion src/Ext/WeaponType/Hooks.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Body.h"

#include <UnitClass.h>
#include <Ext/BulletType/Body.h>

DEFINE_HOOK(0x772A0A, WeaponTypeClass_SetSpeed_ApplyGravity, 0x6)
Expand All @@ -22,3 +22,23 @@ DEFINE_HOOK(0x773087, WeaponTypeClass_GetSpeed_ApplyGravity, 0x6)
return 0x7730A3;
}

DEFINE_HOOK(0x7413DD, UnitClass_Fire_RockerPitch, 0x6)
{
GET(UnitClass* const, pThis, ESI);
if (!pThis->IsVoxel()) return 0;

GET(BulletClass* const, pTraj, EDI);
if (auto const wpnExt = WeaponTypeExt::ExtMap.Find(pTraj->WeaponType))
{
const float pitch = wpnExt->RockerPitch.Get();
if (CLOSE_ENOUGH(pitch,0.002))
return 0;

const double theta = pThis->GetRealFacing().GetRadian<32>() - pThis->PrimaryFacing.Current().GetRadian<32>();

pThis->RockingForwardsPerFrame += (float)(-pitch * Math::cos(theta));
pThis->RockingSidewaysPerFrame += (float)(pitch * Math::sin(theta));
}

return 0;
}
9 changes: 5 additions & 4 deletions src/Phobos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const char* Phobos::AppIconPath = nullptr;
bool Phobos::Debug_DisplayDamageNumbers = false;

#ifdef STR_GIT_COMMIT
const wchar_t* Phobos::VersionDescription = L"Phobos nightly build (" STR_GIT_COMMIT L" @ " STR_GIT_BRANCH L"). DO NOT SHIP IN MODS!";
const wchar_t* Phobos::VersionDescription = L"Trsdy build @ " STR_GIT_COMMIT L" in case of emergency";
#elif !defined(IS_RELEASE_VER)
const wchar_t* Phobos::VersionDescription = L"Phobos development build #" _STR(BUILD_NUMBER) L". Please test the build before shipping.";
#else
Expand Down Expand Up @@ -287,14 +287,15 @@ DEFINE_HOOK(0x66E9DF, RulesClass_Process_Phobos, 0x8)
}

#ifndef IS_RELEASE_VER

DEFINE_HOOK(0x4F4583, GScreenClass_DrawText, 0x6)
{
#ifndef STR_GIT_COMMIT
if (!HideWarning)
#endif // !STR_GIT_COMMIT
{
auto wanted = Drawing::GetTextDimensions(Phobos::VersionDescription, { 0,0 }, 0, 2, 0);

ColorStruct bgd { 0,0,0 };
RectangleStruct rect = {
DSurface::Composite->GetWidth() - wanted.Width - 10,
0,
Expand All @@ -304,8 +305,8 @@ DEFINE_HOOK(0x4F4583, GScreenClass_DrawText, 0x6)

Point2D location { rect.X + 5,5 };

DSurface::Composite->FillRect(&rect, COLOR_BLACK);
DSurface::Composite->DrawText(Phobos::VersionDescription, &location, COLOR_RED);
DSurface::Composite->FillRectTrans(&rect, &bgd, 25);
DSurface::Composite->DrawText(Phobos::VersionDescription, &location, 0x8108);
}
return 0;
}
Expand Down

0 comments on commit 319adb0

Please sign in to comment.