From e34222a0723d6045f86831ac87d828ec2bf4563c Mon Sep 17 00:00:00 2001 From: Netsu_Negi <71598172+NetsuNegi@users.noreply.github.com> Date: Tue, 4 Jul 2023 08:04:29 +0800 Subject: [PATCH 01/10] first commit --- src/Ext/Rules/Body.cpp | 7 +++++ src/Ext/Rules/Body.h | 7 +++++ src/Ext/Techno/Hooks.cpp | 57 +++++++++++++++++++++++++++++++++++++ src/Ext/TechnoType/Body.cpp | 8 ++++++ src/Ext/TechnoType/Body.h | 8 ++++++ 5 files changed, 87 insertions(+) diff --git a/src/Ext/Rules/Body.cpp b/src/Ext/Rules/Body.cpp index bbab5ddf46..ca8f1d83b0 100644 --- a/src/Ext/Rules/Body.cpp +++ b/src/Ext/Rules/Body.cpp @@ -112,6 +112,10 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI) this->ROF_RandomDelay.Read(exINI, GameStrings::CombatDamage, "ROF.RandomDelay"); + this->CloakAnim.Read(exINI, GameStrings::AudioVisual, "CloakAnim"); + this->DecloakAnim.Read(exINI, GameStrings::AudioVisual, "DecloakAnim"); + this->Cloak_KickOutParasite.Read(exINI, GameStrings::CombatDamage, "Cloak.KickOutParasite"); + this->DisplayIncome.Read(exINI, GameStrings::AudioVisual, "DisplayIncome"); this->DisplayIncome_Houses.Read(exINI, GameStrings::AudioVisual, "DisplayIncome.Houses"); this->DisplayIncome_AllowAI.Read(exINI, GameStrings::AudioVisual, "DisplayIncome.AllowAI"); @@ -229,6 +233,9 @@ void RulesExt::ExtData::Serialize(T& Stm) .Process(this->CrateOnlyOnLand) .Process(this->RadialIndicatorVisibility) .Process(this->DrawTurretShadow) + .Process(this->CloakAnim) + .Process(this->DecloakAnim) + .Process(this->Cloak_KickOutParasite) ; } diff --git a/src/Ext/Rules/Body.h b/src/Ext/Rules/Body.h index 2b38f4fb28..c105d7777d 100644 --- a/src/Ext/Rules/Body.h +++ b/src/Ext/Rules/Body.h @@ -81,6 +81,10 @@ class RulesExt Valueable RadialIndicatorVisibility; Valueable DrawTurretShadow; + Valueable CloakAnim; + Valueable DecloakAnim; + Valueable Cloak_KickOutParasite; + ExtData(RulesClass* OwnerObject) : Extension(OwnerObject) , Storage_TiberiumIndex { -1 } , InfantryGainSelfHealCap {} @@ -126,6 +130,9 @@ class RulesExt , CrateOnlyOnLand { false } , RadialIndicatorVisibility { AffectedHouse::Allies } , DrawTurretShadow { false } + , CloakAnim { nullptr } + , DecloakAnim { nullptr } + , Cloak_KickOutParasite { true } { } virtual ~ExtData() = default; diff --git a/src/Ext/Techno/Hooks.cpp b/src/Ext/Techno/Hooks.cpp index e8f7b1facd..f1b1d82a8a 100644 --- a/src/Ext/Techno/Hooks.cpp +++ b/src/Ext/Techno/Hooks.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include DEFINE_HOOK(0x6F9E50, TechnoClass_AI, 0x5) @@ -471,3 +472,59 @@ DEFINE_HOOK(0x4CD4E1, FlyLocomotionClass_Update_LayerUpdate, 0x6) return 0; } + +DEFINE_HOOK(0x7037F7, TechnoClass_Cloak_CloakAnim, 0x5) +{ + GET(TechnoClass* const, pThis, ESI); + + if (const auto pAnimType = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType())->CloakAnim.Get(RulesExt::Global()->CloakAnim)) + { + if (const auto pAnim = GameCreate(pAnimType, pThis->GetCoords())) + AnimExt::SetAnimOwnerHouseKind(pAnim, pThis->Owner, nullptr, false); + } + + return 0; +} + +DEFINE_HOOK(0x70374F, TechnoClass_Uncloak_DecloakAnim, 0x5) +{ + TechnoClass* const pThis = reinterpret_cast(R->ESI() - 0x9C); + + if (const auto pAnimType = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType())->DecloakAnim.Get(RulesExt::Global()->DecloakAnim)) + { + if (const auto pAnim = GameCreate(pAnimType, pThis->GetCoords())) + AnimExt::SetAnimOwnerHouseKind(pAnim, pThis->Owner, nullptr, false); + } + + return 0; +} + +DEFINE_HOOK(0x4D9992, FootClass_PointerGotInvalid_Parasite, 0x7) +{ + enum { SkipGameCode = 0x4D99D3 }; + + GET(FootClass*, pThis, ESI); + GET(AbstractClass*, pAbstract, EDI); + GET(FootClass*, pParasiteOwner, EAX); + GET(bool, bRemoved, EBX); + + if (pParasiteOwner == pAbstract && (!pParasiteOwner->Health || !Make_Global(0xA8ED5C))) + { + pThis->ParasiteEatingMe = nullptr; + return SkipGameCode; + } + + if (!bRemoved) + { + const auto pTypeExt = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType()); + bRemoved = pTypeExt->Cloak_KickOutParasite.Get(RulesExt::Global()->Cloak_KickOutParasite); + } + + if (pParasiteOwner && pParasiteOwner->Health > 0) + pParasiteOwner->ParasiteImUsing->PointerExpired(pAbstract, bRemoved); + + if (pThis == pAbstract && bRemoved) + pThis->ParasiteEatingMe = nullptr; + + return SkipGameCode; +} diff --git a/src/Ext/TechnoType/Body.cpp b/src/Ext/TechnoType/Body.cpp index 505f71cee7..ea59cf43d2 100644 --- a/src/Ext/TechnoType/Body.cpp +++ b/src/Ext/TechnoType/Body.cpp @@ -246,6 +246,10 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI) this->CrushOverlayExtraForwardTilt.Read(exINI, pSection, "CrushOverlayExtraForwardTilt"); this->CrushSlowdownMultiplier.Read(exINI, pSection, "CrushSlowdownMultiplier"); + this->CloakAnim.Read(exINI, pSection, "CloakAnim"); + this->DecloakAnim.Read(exINI, pSection, "DecloakAnim"); + this->Cloak_KickOutParasite.Read(exINI, pSection, "Cloak.KickOutParasite"); + // Ares 0.2 this->RadarJamRadius.Read(exINI, pSection, "RadarJamRadius"); @@ -513,6 +517,10 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm) .Process(this->CrushForwardTiltPerFrame) .Process(this->CrushOverlayExtraForwardTilt) .Process(this->CrushSlowdownMultiplier) + + .Process(this->CloakAnim) + .Process(this->DecloakAnim) + .Process(this->Cloak_KickOutParasite) ; } void TechnoTypeExt::ExtData::LoadFromStream(PhobosStreamReader& Stm) diff --git a/src/Ext/TechnoType/Body.h b/src/Ext/TechnoType/Body.h index 5e357d5e05..59b978bf05 100644 --- a/src/Ext/TechnoType/Body.h +++ b/src/Ext/TechnoType/Body.h @@ -175,6 +175,10 @@ class TechnoTypeExt std::vector> DeployedWeaponBurstFLHs; std::vector> EliteDeployedWeaponBurstFLHs; + Nullable CloakAnim; + Nullable DecloakAnim; + Nullable Cloak_KickOutParasite; + ExtData(TechnoTypeClass* OwnerObject) : Extension(OwnerObject) , HealthBar_Hide { false } , UIDescription {} @@ -302,6 +306,10 @@ class TechnoTypeExt , CrushSlowdownMultiplier { 0.2 } , CrushForwardTiltPerFrame {} , CrushOverlayExtraForwardTilt { 0.02 } + + , CloakAnim {} + , DecloakAnim {} + , Cloak_KickOutParasite {} { } virtual ~ExtData() = default; From 523806495da0349d35bc3d88061f3721bc4b6686 Mon Sep 17 00:00:00 2001 From: Netsu_Negi <71598172+NetsuNegi@users.noreply.github.com> Date: Sun, 9 Jul 2023 08:38:03 +0800 Subject: [PATCH 02/10] fix --- CREDITS.md | 4 +++- docs/New-or-Enhanced-Logics.md | 19 +++++++++++++++++++ docs/Whats-New.md | 1 + src/Ext/Techno/Hooks.cpp | 32 +++++++++++++++++++------------- 4 files changed, 42 insertions(+), 14 deletions(-) diff --git a/CREDITS.md b/CREDITS.md index 4b0a3922ee..be0ba41771 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -261,7 +261,9 @@ This page lists all the individual contributions to the project by their author. - **FlyStar** - Campaign load screen PCX support - New condition for automatic self-destruction logic when TechnoTypes exist/don't exist -- **NetsuNegi** - Forbidding parallel AI queues by type +- **NetsuNegi** + - Forbidding parallel AI queues by type + - Cloak Enhancement - **Apollo** - Translucent SHP drawing patches - **ststl** - Customizable ShowTimer priority of superweapons diff --git a/docs/New-or-Enhanced-Logics.md b/docs/New-or-Enhanced-Logics.md index 4747a8abfa..c41119a1af 100644 --- a/docs/New-or-Enhanced-Logics.md +++ b/docs/New-or-Enhanced-Logics.md @@ -928,6 +928,25 @@ EVA.Sold= ; EVA entry SellSound= ; sound entry ``` +### Cloak Enhancement + +- When unit start cloak or stop cloaking, an animation can play on his location + - You can also set whether cloak units kick out parasites + +In `rulesmd.ini`: +```ini +[SOMETECHNO] +CloakAnim= ; Animation +DecloakAnim= ; Animation +Cloak.KickOutParasite= ; boolean + +[AudioVisual] +CloakAnim= ; Animation +DecloakAnim= ; Animation + +[CombatDamage] +Cloak.KickOutParasite=true ; boolean + ## Terrain ### Destroy animation & sound diff --git a/docs/Whats-New.md b/docs/Whats-New.md index b51eb52d14..ce534c32dd 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -317,6 +317,7 @@ New: - Example custom locomotor that circles around the target (by Kerbiter, CCHyper, with help from Otamaa; based on earlier experiment by CnCVK) - Vehicle voxel turret shadows & body multi-section shadows (by TwinkleStar) - Crushing tilt and slowdown customization (by Starkku) +- Cloak Enhancement (by NetsuNegi) Vanilla fixes: - Allow AI to repair structures built from base nodes/trigger action 125/SW delivery in single player missions (by Trsdy) diff --git a/src/Ext/Techno/Hooks.cpp b/src/Ext/Techno/Hooks.cpp index f1b1d82a8a..6b14d3bd51 100644 --- a/src/Ext/Techno/Hooks.cpp +++ b/src/Ext/Techno/Hooks.cpp @@ -477,23 +477,29 @@ DEFINE_HOOK(0x7037F7, TechnoClass_Cloak_CloakAnim, 0x5) { GET(TechnoClass* const, pThis, ESI); - if (const auto pAnimType = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType())->CloakAnim.Get(RulesExt::Global()->CloakAnim)) + if (const auto pTypeExt = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType())) { - if (const auto pAnim = GameCreate(pAnimType, pThis->GetCoords())) - AnimExt::SetAnimOwnerHouseKind(pAnim, pThis->Owner, nullptr, false); + if (const auto pAnimType = pTypeExt->CloakAnim.Get(RulesExt::Global()->CloakAnim)) + { + if (const auto pAnim = GameCreate(pAnimType, pThis->GetCoords())) + AnimExt::SetAnimOwnerHouseKind(pAnim, pThis->Owner, nullptr, false); + } } return 0; } -DEFINE_HOOK(0x70374F, TechnoClass_Uncloak_DecloakAnim, 0x5) +DEFINE_HOOK(0x703736, TechnoClass_Uncloak_DecloakAnim, 0x6) { - TechnoClass* const pThis = reinterpret_cast(R->ESI() - 0x9C); + GET(TechnoClass* const, pThis, ESI); - if (const auto pAnimType = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType())->DecloakAnim.Get(RulesExt::Global()->DecloakAnim)) + if (const auto pTypeExt = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType())) { - if (const auto pAnim = GameCreate(pAnimType, pThis->GetCoords())) - AnimExt::SetAnimOwnerHouseKind(pAnim, pThis->Owner, nullptr, false); + if (const auto pAnimType = pTypeExt->DecloakAnim.Get(RulesExt::Global()->DecloakAnim)) + { + if (const auto pAnim = GameCreate(pAnimType, pThis->GetCoords())) + AnimExt::SetAnimOwnerHouseKind(pAnim, pThis->Owner, nullptr, false); + } } return 0; @@ -506,7 +512,7 @@ DEFINE_HOOK(0x4D9992, FootClass_PointerGotInvalid_Parasite, 0x7) GET(FootClass*, pThis, ESI); GET(AbstractClass*, pAbstract, EDI); GET(FootClass*, pParasiteOwner, EAX); - GET(bool, bRemoved, EBX); + GET(bool, removed, EBX); if (pParasiteOwner == pAbstract && (!pParasiteOwner->Health || !Make_Global(0xA8ED5C))) { @@ -514,16 +520,16 @@ DEFINE_HOOK(0x4D9992, FootClass_PointerGotInvalid_Parasite, 0x7) return SkipGameCode; } - if (!bRemoved) + if (!removed) { const auto pTypeExt = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType()); - bRemoved = pTypeExt->Cloak_KickOutParasite.Get(RulesExt::Global()->Cloak_KickOutParasite); + removed = pTypeExt->Cloak_KickOutParasite.Get(RulesExt::Global()->Cloak_KickOutParasite); } if (pParasiteOwner && pParasiteOwner->Health > 0) - pParasiteOwner->ParasiteImUsing->PointerExpired(pAbstract, bRemoved); + pParasiteOwner->ParasiteImUsing->PointerExpired(pAbstract, removed); - if (pThis == pAbstract && bRemoved) + if (pThis == pAbstract && removed) pThis->ParasiteEatingMe = nullptr; return SkipGameCode; From b26ec2b139f6db2e91a38db62bb374f41bd1f3f5 Mon Sep 17 00:00:00 2001 From: Netsu_Negi <71598172+NetsuNegi@users.noreply.github.com> Date: Sun, 9 Jul 2023 08:47:30 +0800 Subject: [PATCH 03/10] fix docs --- docs/New-or-Enhanced-Logics.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/New-or-Enhanced-Logics.md b/docs/New-or-Enhanced-Logics.md index c41119a1af..8575801c34 100644 --- a/docs/New-or-Enhanced-Logics.md +++ b/docs/New-or-Enhanced-Logics.md @@ -946,6 +946,7 @@ DecloakAnim= ; Animation [CombatDamage] Cloak.KickOutParasite=true ; boolean +``` ## Terrain From d57057683ec2e1d5e1d59b0a0fc156cf42a85e60 Mon Sep 17 00:00:00 2001 From: Netsu_Negi <71598172+NetsuNegi@users.noreply.github.com> Date: Sun, 9 Jul 2023 20:28:00 +0800 Subject: [PATCH 04/10] Update New-or-Enhanced-Logics.md --- docs/New-or-Enhanced-Logics.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/New-or-Enhanced-Logics.md b/docs/New-or-Enhanced-Logics.md index 06f36c3479..7eb6943004 100644 --- a/docs/New-or-Enhanced-Logics.md +++ b/docs/New-or-Enhanced-Logics.md @@ -936,16 +936,16 @@ SellSound= ; sound entry In `rulesmd.ini`: ```ini [SOMETECHNO] -CloakAnim= ; Animation -DecloakAnim= ; Animation +CloakAnim= ; Animation +DecloakAnim= ; Animation Cloak.KickOutParasite= ; boolean [AudioVisual] -CloakAnim= ; Animation -DecloakAnim= ; Animation +CloakAnim= ; Animation +DecloakAnim= ; Animation [CombatDamage] -Cloak.KickOutParasite=true ; boolean +Cloak.KickOutParasite=true ; boolean ``` ## Terrain From 8e3502d252b16268e87ca850b11bd294f5c6e39d Mon Sep 17 00:00:00 2001 From: Netsu_Negi <71598172+NetsuNegi@users.noreply.github.com> Date: Mon, 17 Jul 2023 14:18:30 +0800 Subject: [PATCH 05/10] editor config fix --- src/Ext/Rules/Body.cpp | 2 +- src/Ext/Rules/Body.h | 6 +++--- src/Ext/TechnoType/Body.cpp | 8 ++++---- src/Ext/TechnoType/Body.h | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Ext/Rules/Body.cpp b/src/Ext/Rules/Body.cpp index a6927d6719..e3991c3664 100644 --- a/src/Ext/Rules/Body.cpp +++ b/src/Ext/Rules/Body.cpp @@ -255,7 +255,7 @@ void RulesExt::ExtData::Serialize(T& Stm) .Process(this->Infantry_DefaultDigitalDisplayTypes) .Process(this->Vehicles_DefaultDigitalDisplayTypes) .Process(this->Aircraft_DefaultDigitalDisplayTypes) - .Process(this->CloakAnim) + .Process(this->CloakAnim) .Process(this->DecloakAnim) .Process(this->Cloak_KickOutParasite) ; diff --git a/src/Ext/Rules/Body.h b/src/Ext/Rules/Body.h index ac57e82c1b..01e23b17bf 100644 --- a/src/Ext/Rules/Body.h +++ b/src/Ext/Rules/Body.h @@ -93,8 +93,8 @@ class RulesExt ValueableVector Infantry_DefaultDigitalDisplayTypes; ValueableVector Vehicles_DefaultDigitalDisplayTypes; ValueableVector Aircraft_DefaultDigitalDisplayTypes; - - Valueable CloakAnim; + + Valueable CloakAnim; Valueable DecloakAnim; Valueable Cloak_KickOutParasite; @@ -153,7 +153,7 @@ class RulesExt , Infantry_DefaultDigitalDisplayTypes {} , Vehicles_DefaultDigitalDisplayTypes {} , Aircraft_DefaultDigitalDisplayTypes {} - , CloakAnim { nullptr } + , CloakAnim { nullptr } , DecloakAnim { nullptr } , Cloak_KickOutParasite { true } { } diff --git a/src/Ext/TechnoType/Body.cpp b/src/Ext/TechnoType/Body.cpp index 745d45b483..e120b84dd4 100644 --- a/src/Ext/TechnoType/Body.cpp +++ b/src/Ext/TechnoType/Body.cpp @@ -252,8 +252,8 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI) this->EmptyAmmoPip.Read(exINI, pSection, "EmptyAmmoPip"); this->PipWrapAmmoPip.Read(exINI, pSection, "PipWrapAmmoPip"); this->AmmoPipSize.Read(exINI, pSection, "AmmoPipSize"); - - this->CloakAnim.Read(exINI, pSection, "CloakAnim"); + + this->CloakAnim.Read(exINI, pSection, "CloakAnim"); this->DecloakAnim.Read(exINI, pSection, "DecloakAnim"); this->Cloak_KickOutParasite.Read(exINI, pSection, "Cloak.KickOutParasite"); @@ -533,8 +533,8 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm) .Process(this->EmptyAmmoPip) .Process(this->PipWrapAmmoPip) .Process(this->AmmoPipSize) - - .Process(this->CloakAnim) + + .Process(this->CloakAnim) .Process(this->DecloakAnim) .Process(this->Cloak_KickOutParasite) ; diff --git a/src/Ext/TechnoType/Body.h b/src/Ext/TechnoType/Body.h index d232f5d2de..456ba719a1 100644 --- a/src/Ext/TechnoType/Body.h +++ b/src/Ext/TechnoType/Body.h @@ -326,8 +326,8 @@ class TechnoTypeExt , EmptyAmmoPip { -1 } , PipWrapAmmoPip { 14 } , AmmoPipSize {} - - , CloakAnim {} + + , CloakAnim {} , DecloakAnim {} , Cloak_KickOutParasite {} { } From 57effc9516defa983b125fa8321a06d5194e1fae Mon Sep 17 00:00:00 2001 From: Netsu_Negi <71598172+NetsuNegi@users.noreply.github.com> Date: Mon, 17 Jul 2023 14:28:41 +0800 Subject: [PATCH 06/10] fix --- src/Ext/Rules/Body.cpp | 2 +- src/Ext/Rules/Body.h | 2 +- src/Ext/TechnoType/Body.cpp | 4 ++-- src/Ext/TechnoType/Body.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Ext/Rules/Body.cpp b/src/Ext/Rules/Body.cpp index e3991c3664..402bf86857 100644 --- a/src/Ext/Rules/Body.cpp +++ b/src/Ext/Rules/Body.cpp @@ -255,7 +255,7 @@ void RulesExt::ExtData::Serialize(T& Stm) .Process(this->Infantry_DefaultDigitalDisplayTypes) .Process(this->Vehicles_DefaultDigitalDisplayTypes) .Process(this->Aircraft_DefaultDigitalDisplayTypes) - .Process(this->CloakAnim) + .Process(this->CloakAnim) .Process(this->DecloakAnim) .Process(this->Cloak_KickOutParasite) ; diff --git a/src/Ext/Rules/Body.h b/src/Ext/Rules/Body.h index 01e23b17bf..16c1b26c41 100644 --- a/src/Ext/Rules/Body.h +++ b/src/Ext/Rules/Body.h @@ -93,7 +93,7 @@ class RulesExt ValueableVector Infantry_DefaultDigitalDisplayTypes; ValueableVector Vehicles_DefaultDigitalDisplayTypes; ValueableVector Aircraft_DefaultDigitalDisplayTypes; - + Valueable CloakAnim; Valueable DecloakAnim; Valueable Cloak_KickOutParasite; diff --git a/src/Ext/TechnoType/Body.cpp b/src/Ext/TechnoType/Body.cpp index e120b84dd4..3fba468754 100644 --- a/src/Ext/TechnoType/Body.cpp +++ b/src/Ext/TechnoType/Body.cpp @@ -252,7 +252,7 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI) this->EmptyAmmoPip.Read(exINI, pSection, "EmptyAmmoPip"); this->PipWrapAmmoPip.Read(exINI, pSection, "PipWrapAmmoPip"); this->AmmoPipSize.Read(exINI, pSection, "AmmoPipSize"); - + this->CloakAnim.Read(exINI, pSection, "CloakAnim"); this->DecloakAnim.Read(exINI, pSection, "DecloakAnim"); this->Cloak_KickOutParasite.Read(exINI, pSection, "Cloak.KickOutParasite"); @@ -533,7 +533,7 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm) .Process(this->EmptyAmmoPip) .Process(this->PipWrapAmmoPip) .Process(this->AmmoPipSize) - + .Process(this->CloakAnim) .Process(this->DecloakAnim) .Process(this->Cloak_KickOutParasite) diff --git a/src/Ext/TechnoType/Body.h b/src/Ext/TechnoType/Body.h index 456ba719a1..b81a172388 100644 --- a/src/Ext/TechnoType/Body.h +++ b/src/Ext/TechnoType/Body.h @@ -326,7 +326,7 @@ class TechnoTypeExt , EmptyAmmoPip { -1 } , PipWrapAmmoPip { 14 } , AmmoPipSize {} - + , CloakAnim {} , DecloakAnim {} , Cloak_KickOutParasite {} From dbe5519cb4786f2792dc41c113e61881cabd6667 Mon Sep 17 00:00:00 2001 From: Coronia <2217891145@qq.com> Date: Tue, 25 Aug 2026 12:53:00 +0800 Subject: [PATCH 07/10] use anim list --- docs/New-or-Enhanced-Logics.md | 16 ++++++++-------- src/Ext/Rules/Body.cpp | 10 +++++----- src/Ext/Rules/Body.h | 10 +++++----- src/Ext/Techno/Hooks.cpp | 24 ++++-------------------- src/Ext/TechnoType/Body.cpp | 8 ++++---- src/Ext/TechnoType/Body.h | 10 +++++----- 6 files changed, 31 insertions(+), 47 deletions(-) diff --git a/docs/New-or-Enhanced-Logics.md b/docs/New-or-Enhanced-Logics.md index 5ede610356..a1d19ef4d7 100644 --- a/docs/New-or-Enhanced-Logics.md +++ b/docs/New-or-Enhanced-Logics.md @@ -2555,17 +2555,17 @@ Ammo.DeployUnlockMaximumAmount=-1 ; integer In `rulesmd.ini`: ```ini -[SOMETECHNO] -CloakAnim= ; Animation -DecloakAnim= ; Animation -Cloak.KickOutParasite= ; boolean +[General] +Cloak.KickOutParasite=true ; boolean [AudioVisual] -CloakAnim= ; Animation -DecloakAnim= ; Animation +CloakAnims= ; List of Animation +DecloakAnims= ; List of Animation -[CombatDamage] -Cloak.KickOutParasite=true ; boolean +[SOMETECHNO] +CloakAnims= ; List of Animation, default to [AudioVisual] -> CloakAnims +DecloakAnims= ; List of Animation, default to [AudioVisual] -> DecloakAnims +Cloak.KickOutParasite= ; boolean, default to [General] -> Cloak.KickOutParasite ``` ### Custom hover vehicles shutdown drowning death diff --git a/src/Ext/Rules/Body.cpp b/src/Ext/Rules/Body.cpp index 46575a28b6..bc86659c57 100644 --- a/src/Ext/Rules/Body.cpp +++ b/src/Ext/Rules/Body.cpp @@ -260,9 +260,9 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI) this->ROF_RandomDelay.Read(exINI, GameStrings::CombatDamage, "ROF.RandomDelay"); - this->CloakAnim.Read(exINI, GameStrings::AudioVisual, "CloakAnim"); - this->DecloakAnim.Read(exINI, GameStrings::AudioVisual, "DecloakAnim"); - this->Cloak_KickOutParasite.Read(exINI, GameStrings::CombatDamage, "Cloak.KickOutParasite"); + this->CloakAnims.Read(exINI, GameStrings::AudioVisual, "CloakAnims"); + this->DecloakAnims.Read(exINI, GameStrings::AudioVisual, "DecloakAnims"); + this->Cloak_KickOutParasite.Read(exINI, GameStrings::General, "Cloak.KickOutParasite"); this->DisplayIncome.Read(exINI, GameStrings::AudioVisual, "DisplayIncome"); this->DisplayIncome_Delay.Read(exINI, GameStrings::AudioVisual, "DisplayIncome.Delay"); @@ -1113,8 +1113,8 @@ void RulesExt::ExtData::Serialize(T& Stm) .Process(this->KeepAlive_Buildings) .Process(this->KeepAlive_Defenses) .Process(this->AutoTarget_InsignificantWhenMindControlled) - .Process(this->CloakAnim) - .Process(this->DecloakAnim) + .Process(this->CloakAnims) + .Process(this->DecloakAnims) .Process(this->Cloak_KickOutParasite) ; } diff --git a/src/Ext/Rules/Body.h b/src/Ext/Rules/Body.h index a3520788f2..4715be8ae7 100644 --- a/src/Ext/Rules/Body.h +++ b/src/Ext/Rules/Body.h @@ -546,8 +546,8 @@ class RulesExt Valueable KeepAlive_Defenses; Valueable AutoTarget_InsignificantWhenMindControlled; - Valueable CloakAnim; - Valueable DecloakAnim; + ValueableVector CloakAnims; + ValueableVector DecloakAnims; Valueable Cloak_KickOutParasite; ExtData(RulesClass* OwnerObject) : Extension(OwnerObject) @@ -1033,9 +1033,9 @@ class RulesExt , AutoTarget_InsignificantWhenMindControlled { true } - , CloakAnim{ nullptr } - , DecloakAnim{ nullptr } - , Cloak_KickOutParasite{ true } + , CloakAnims {} + , DecloakAnims {} + , Cloak_KickOutParasite { true } { } virtual ~ExtData() = default; diff --git a/src/Ext/Techno/Hooks.cpp b/src/Ext/Techno/Hooks.cpp index 2709f2c220..1a177031d1 100644 --- a/src/Ext/Techno/Hooks.cpp +++ b/src/Ext/Techno/Hooks.cpp @@ -1374,16 +1374,8 @@ DEFINE_HOOK(0x7037F7, TechnoClass_Cloak_CloakAnim, 0x5) GET(TechnoClass* const, pThis, ESI); const auto pTypeExt = TechnoExt::Fetch(pThis)->TypeExtData; - - if (const auto pAnimType = pTypeExt->CloakAnim.Get(RulesExt::Global()->CloakAnim)) - { - if (const auto pAnim = GameCreate(pAnimType, pThis->GetCoords())) - { - AnimExt::SetAnimOwnerHouseKind(pAnim, pThis->Owner, nullptr, false); - AnimExt::Fetch(pAnim)->SetInvoker(pThis); - } - } - + const auto& cloakAnims = !pTypeExt->CloakAnims.empty() ? pTypeExt->CloakAnims : RulesExt::Global()->CloakAnims; + AnimExt::CreateRandomAnim(cloakAnims, pThis->GetCenterCoords(), pThis, pThis->Owner, true, true); return 0; } @@ -1392,16 +1384,8 @@ DEFINE_HOOK(0x703736, TechnoClass_Uncloak_DecloakAnim, 0x6) GET(TechnoClass* const, pThis, ESI); const auto pTypeExt = TechnoExt::Fetch(pThis)->TypeExtData; - - if (const auto pAnimType = pTypeExt->DecloakAnim.Get(RulesExt::Global()->DecloakAnim)) - { - if (const auto pAnim = GameCreate(pAnimType, pThis->GetCoords())) - { - AnimExt::SetAnimOwnerHouseKind(pAnim, pThis->Owner, nullptr, false); - AnimExt::Fetch(pAnim)->SetInvoker(pThis); - } - } - + const auto& decloakAnims = !pTypeExt->DecloakAnims.empty() ? pTypeExt->DecloakAnims : RulesExt::Global()->DecloakAnims; + AnimExt::CreateRandomAnim(decloakAnims, pThis->GetCenterCoords(), pThis, pThis->Owner, true, true); return 0; } diff --git a/src/Ext/TechnoType/Body.cpp b/src/Ext/TechnoType/Body.cpp index 46116224af..c694fce575 100644 --- a/src/Ext/TechnoType/Body.cpp +++ b/src/Ext/TechnoType/Body.cpp @@ -1184,8 +1184,8 @@ void TechnoTypeExt::LoadFromINIFile(CCINIClass* const pINI) if (this->Convert_Health_AbovePercent > this->Convert_Health_BelowPercent) Debug::Log("[Developer warning][%s] Convert.Health.AbovePercent is greater than Convert.Health.BelowPercent, resulting in no conversion.\n", pSection); - this->CloakAnim.Read(exINI, pSection, "CloakAnim"); - this->DecloakAnim.Read(exINI, pSection, "DecloakAnim"); + this->CloakAnims.Read(exINI, pSection, "CloakAnims"); + this->DecloakAnims.Read(exINI, pSection, "DecloakAnims"); this->Cloak_KickOutParasite.Read(exINI, pSection, "Cloak.KickOutParasite"); // Ares 0.2 @@ -1810,8 +1810,8 @@ void TechnoTypeExt::Serialize(T& Stm) .Process(this->Convert_Health_BelowPercent) .Process(this->Convert_Health) - .Process(this->CloakAnim) - .Process(this->DecloakAnim) + .Process(this->CloakAnims) + .Process(this->DecloakAnims) .Process(this->Cloak_KickOutParasite) // Ares 0.2 diff --git a/src/Ext/TechnoType/Body.h b/src/Ext/TechnoType/Body.h index 5fe6ba8b86..202ccd638c 100644 --- a/src/Ext/TechnoType/Body.h +++ b/src/Ext/TechnoType/Body.h @@ -429,8 +429,8 @@ class TechnoTypeExt : public ObjectTypeExt Valueable Convert_Health_BelowPercent; Nullable Convert_Health; - Nullable CloakAnim; - Nullable DecloakAnim; + ValueableVector CloakAnims; + ValueableVector DecloakAnims; Nullable Cloak_KickOutParasite; // Ares 0.2 @@ -834,9 +834,9 @@ class TechnoTypeExt : public ObjectTypeExt , Convert_Health_BelowPercent { -1.0 } , Convert_Health {} - , CloakAnim{} - , DecloakAnim{} - , Cloak_KickOutParasite{} + , CloakAnims {} + , DecloakAnims {} + , Cloak_KickOutParasite {} // Ares 0.2 , RadarJamRadius { 0 } From 4dd59080a1ec1874c27ab28f23fcd6448f4ad636 Mon Sep 17 00:00:00 2001 From: Coronia <2217891145@qq.com> Date: Tue, 25 Aug 2026 13:16:45 +0800 Subject: [PATCH 08/10] don't set OwnerObject --- src/Ext/Techno/Hooks.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Ext/Techno/Hooks.cpp b/src/Ext/Techno/Hooks.cpp index 1a177031d1..9777db1299 100644 --- a/src/Ext/Techno/Hooks.cpp +++ b/src/Ext/Techno/Hooks.cpp @@ -1375,7 +1375,7 @@ DEFINE_HOOK(0x7037F7, TechnoClass_Cloak_CloakAnim, 0x5) const auto pTypeExt = TechnoExt::Fetch(pThis)->TypeExtData; const auto& cloakAnims = !pTypeExt->CloakAnims.empty() ? pTypeExt->CloakAnims : RulesExt::Global()->CloakAnims; - AnimExt::CreateRandomAnim(cloakAnims, pThis->GetCenterCoords(), pThis, pThis->Owner, true, true); + AnimExt::CreateRandomAnim(cloakAnims, pThis->GetCenterCoords(), pThis, pThis->Owner, true); return 0; } @@ -1385,7 +1385,7 @@ DEFINE_HOOK(0x703736, TechnoClass_Uncloak_DecloakAnim, 0x6) const auto pTypeExt = TechnoExt::Fetch(pThis)->TypeExtData; const auto& decloakAnims = !pTypeExt->DecloakAnims.empty() ? pTypeExt->DecloakAnims : RulesExt::Global()->DecloakAnims; - AnimExt::CreateRandomAnim(decloakAnims, pThis->GetCenterCoords(), pThis, pThis->Owner, true, true); + AnimExt::CreateRandomAnim(decloakAnims, pThis->GetCenterCoords(), pThis, pThis->Owner, true); return 0; } From f29a15a999a54718a4a10e8cb5262e337b2e950c Mon Sep 17 00:00:00 2001 From: NetsuNegi39 Date: Wed, 26 Aug 2026 10:23:22 +0800 Subject: [PATCH 09/10] update --- docs/New-or-Enhanced-Logics.md | 2 +- src/Ext/Rules/Body.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/New-or-Enhanced-Logics.md b/docs/New-or-Enhanced-Logics.md index a1d19ef4d7..c8d98a9d54 100644 --- a/docs/New-or-Enhanced-Logics.md +++ b/docs/New-or-Enhanced-Logics.md @@ -2556,7 +2556,7 @@ Ammo.DeployUnlockMaximumAmount=-1 ; integer In `rulesmd.ini`: ```ini [General] -Cloak.KickOutParasite=true ; boolean +Cloak.KickOutParasite=false ; boolean [AudioVisual] CloakAnims= ; List of Animation diff --git a/src/Ext/Rules/Body.h b/src/Ext/Rules/Body.h index 4715be8ae7..993f1ca9a7 100644 --- a/src/Ext/Rules/Body.h +++ b/src/Ext/Rules/Body.h @@ -1035,7 +1035,7 @@ class RulesExt , CloakAnims {} , DecloakAnims {} - , Cloak_KickOutParasite { true } + , Cloak_KickOutParasite { false } { } virtual ~ExtData() = default; From 73d75ad6d3c8e8b1d83fc695e906e546a9d5f3f3 Mon Sep 17 00:00:00 2001 From: NetsuNegi39 Date: Thu, 27 Aug 2026 15:24:07 +0800 Subject: [PATCH 10/10] chinese docs --- docs/locale/zh_CN/LC_MESSAGES/CREDITS.po | 3 +++ .../locale/zh_CN/LC_MESSAGES/New-or-Enhanced-Logics.po | 10 ++++++++++ docs/locale/zh_CN/LC_MESSAGES/Whats-New.po | 3 +++ 3 files changed, 16 insertions(+) diff --git a/docs/locale/zh_CN/LC_MESSAGES/CREDITS.po b/docs/locale/zh_CN/LC_MESSAGES/CREDITS.po index ecc8839068..6611745d88 100644 --- a/docs/locale/zh_CN/LC_MESSAGES/CREDITS.po +++ b/docs/locale/zh_CN/LC_MESSAGES/CREDITS.po @@ -1892,6 +1892,9 @@ msgstr "修复了短时间内叠加大量辐射场会因为频繁的光照更新 msgid "Customize ivan bomb visibility" msgstr "自定义伊文炸弹可见性" +msgid "Cloak Enhancement" +msgstr "隐形增强" + msgid "**Apollo** - Translucent SHP drawing patches" msgstr "**Apollo** - 半透明 SHP 绘制补丁" diff --git a/docs/locale/zh_CN/LC_MESSAGES/New-or-Enhanced-Logics.po b/docs/locale/zh_CN/LC_MESSAGES/New-or-Enhanced-Logics.po index 89d6b506fb..0f36da697c 100644 --- a/docs/locale/zh_CN/LC_MESSAGES/New-or-Enhanced-Logics.po +++ b/docs/locale/zh_CN/LC_MESSAGES/New-or-Enhanced-Logics.po @@ -5363,6 +5363,16 @@ msgstr "" "`Ammo.DeployUnlockMinimumAmount` & `Ammo.DeployUnlockMaximumAmount` " "分别设定载具启用部署功能所需的最低与最高弹药量阈值,负值表示禁用检查。" +msgid "Cloak Enhancement" +msgstr "隐形增强" + +msgid "When unit start cloak or stop cloaking, " +"an animation can play on his location" +msgstr "当单位开始或停止隐形时,可以在其位置播放动画" + +msgid "You can also set whether cloak units kick out parasites" +msgstr "您也可以设置隐形单位是否踢出寄生者" + msgid "Custom hover vehicles shutdown drowning death" msgstr "自定义悬浮载具溺死" diff --git a/docs/locale/zh_CN/LC_MESSAGES/Whats-New.po b/docs/locale/zh_CN/LC_MESSAGES/Whats-New.po index e77af149c6..4d9e44e4fd 100644 --- a/docs/locale/zh_CN/LC_MESSAGES/Whats-New.po +++ b/docs/locale/zh_CN/LC_MESSAGES/Whats-New.po @@ -857,6 +857,9 @@ msgid "" msgstr "" "[修改弹药弹头](New-or-Enhanced-Logics.md#modify-ammo-on-impact)(by FS-21)" +msgid "Cloak Enhancement (by NetsuNegi)" +msgstr "隐形增强(by NetsuNegi)" + msgid "Vanilla fixes:" msgstr "原版问题修复:"