From 319adb063b1722230831f6b7dcb2fbf2822e6d65 Mon Sep 17 00:00:00 2001 From: chaserli <914137150@qq.com> Date: Sun, 15 Jan 2023 14:02:03 +0800 Subject: [PATCH] IC/BerserkColor --- src/Ext/Techno/Hooks.cpp | 47 ++++++++++++++++++++++++++++++++++ src/Ext/TechnoType/Body.cpp | 6 +++++ src/Ext/TechnoType/Body.h | 3 ++- src/Ext/Unit/Hooks.Jumpjet.cpp | 18 +++++++++++++ src/Ext/WeaponType/Body.cpp | 2 ++ src/Ext/WeaponType/Body.h | 2 ++ src/Ext/WeaponType/Hooks.cpp | 22 +++++++++++++++- src/Phobos.cpp | 9 ++++--- 8 files changed, 103 insertions(+), 6 deletions(-) diff --git a/src/Ext/Techno/Hooks.cpp b/src/Ext/Techno/Hooks.cpp index 3a16126ca8..df3bf3fe33 100644 --- a/src/Ext/Techno/Hooks.cpp +++ b/src/Ext/Techno/Hooks.cpp @@ -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; +} diff --git a/src/Ext/TechnoType/Body.cpp b/src/Ext/TechnoType/Body.cpp index 5f4c8a26ab..f0d143cdf7 100644 --- a/src/Ext/TechnoType/Body.cpp +++ b/src/Ext/TechnoType/Body.cpp @@ -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(add) + this->BerserkColor.Read(exINI, pSection, YRSTR(0x83A194)); + this->IronCurtainColor.Read(exINI, pSection, YRSTR(0x83A1A4)); +#undef YRSTR } template @@ -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) diff --git a/src/Ext/TechnoType/Body.h b/src/Ext/TechnoType/Body.h index ee403dfb25..986fde3e33 100644 --- a/src/Ext/TechnoType/Body.h +++ b/src/Ext/TechnoType/Body.h @@ -136,7 +136,8 @@ class TechnoTypeExt Nullable IronCurtain_KillWarhead; Valueable Explodes_KillPassengers; Nullable DeployFireWeapon; - + Nullable BerserkColor {}; + Nullable IronCurtainColor {}; struct LaserTrailDataEntry { ValueableIdx idxType; diff --git a/src/Ext/Unit/Hooks.Jumpjet.cpp b/src/Ext/Unit/Hooks.Jumpjet.cpp index 4ce35395e9..38f7761752 100644 --- a/src/Ext/Unit/Hooks.Jumpjet.cpp +++ b/src/Ext/Unit/Hooks.Jumpjet.cpp @@ -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(iloco)->State) < JumpjetLocomotionClass::State::Crashing) + return 0x54DCE8; + return 0; +} + +DEFINE_HOOK(0x54DD3D, JJLoco_DrawMatrix_Axis, 0x5) +{ + GET(ILocomotion*, iloco, ESI); + auto state = static_cast(iloco)->State; + if (state && state < JumpjetLocomotionClass::State::Descending) + return 0x54DE88; + return 0; +} diff --git a/src/Ext/WeaponType/Body.cpp b/src/Ext/WeaponType/Body.cpp index 9961cbab68..4877de0019 100644 --- a/src/Ext/WeaponType/Body.cpp +++ b/src/Ext/WeaponType/Body.cpp @@ -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 @@ -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) ; }; diff --git a/src/Ext/WeaponType/Body.h b/src/Ext/WeaponType/Body.h index ea64e7b092..b0753976f8 100644 --- a/src/Ext/WeaponType/Body.h +++ b/src/Ext/WeaponType/Body.h @@ -31,6 +31,7 @@ class WeaponTypeExt Nullable FeedbackWeapon; Valueable Laser_IsSingleColor; Nullable> ROF_RandomDelay; + Valueable RockerPitch; ExtData(WeaponTypeClass* OwnerObject) : Extension(OwnerObject) , DiskLaser_Radius { DiskLaserClass::Radius } @@ -47,6 +48,7 @@ class WeaponTypeExt , FeedbackWeapon {} , Laser_IsSingleColor { false } , ROF_RandomDelay {} + , RockerPitch { 0 } { } virtual ~ExtData() = default; diff --git a/src/Ext/WeaponType/Hooks.cpp b/src/Ext/WeaponType/Hooks.cpp index cc95192dc5..461965ed65 100644 --- a/src/Ext/WeaponType/Hooks.cpp +++ b/src/Ext/WeaponType/Hooks.cpp @@ -1,5 +1,5 @@ #include "Body.h" - +#include #include DEFINE_HOOK(0x772A0A, WeaponTypeClass_SetSpeed_ApplyGravity, 0x6) @@ -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; +} diff --git a/src/Phobos.cpp b/src/Phobos.cpp index 79cd054bdf..91141aab05 100644 --- a/src/Phobos.cpp +++ b/src/Phobos.cpp @@ -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 @@ -287,6 +287,7 @@ DEFINE_HOOK(0x66E9DF, RulesClass_Process_Phobos, 0x8) } #ifndef IS_RELEASE_VER + DEFINE_HOOK(0x4F4583, GScreenClass_DrawText, 0x6) { #ifndef STR_GIT_COMMIT @@ -294,7 +295,7 @@ DEFINE_HOOK(0x4F4583, GScreenClass_DrawText, 0x6) #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, @@ -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; }