Skip to content

Commit

Permalink
Add ForceShield.KeptOnDeploy
Browse files Browse the repository at this point in the history
  • Loading branch information
Starkku committed May 19, 2024
1 parent 26c9f41 commit 8ef800d
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 14 deletions.
16 changes: 9 additions & 7 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -836,22 +836,24 @@ DeployingAnim.ReverseForUndeploy=true ; boolean
DeployingAnim.UseUnitDrawer=true ; boolean
```

### Preserve Iron Curtain status on type conversion
### Preserve Iron Curtain / Force Shield status on type conversion

![image](_static/images/preserve-ic.gif)
*Bugfix in action*

- Iron Curtain status is now preserved by default when converting between TechnoTypes via `DeploysInto`/`UndeploysInto`.
- This behavior can be turned off per-TechnoType and global basis.
- `IronCurtain.Modifier` is re-applied upon type conversion.
- Iron Curtain status is now preserved by default when converting between TechnoTypes via `DeploysInto`/`UndeploysInto`. Force Shield status preservation is turned off by default.
- This behavior can be turned on/off per-TechnoType and on global basis.
- `IronCurtain.Modifier` / `ForceShield.Modifier` (whichever is applicable) is re-applied upon type conversion.

In `rulesmd.ini`:
```ini
[CombatDamage]
IronCurtain.KeptOnDeploy=yes ; boolean
IronCurtain.KeptOnDeploy=true ; boolean
ForceShield.KeptOnDeploy=false ; boolean

[SOMETECHNO] ; VehicleType with DeploysInto or BuildingType with UndeploysInto
IronCurtain.KeptOnDeploy= ; boolean, default to [CombatDamage]->IronCurtain.KeptOnDeploy
[SOMETECHNO] ; VehicleType with DeploysInto or BuildingType with UndeploysInto
IronCurtain.KeptOnDeploy= ; boolean, default to [CombatDamage]->IronCurtain.KeptOnDeploy
ForceShield.KeptOnDeploy= ; boolean, default to [CombatDamage]->ForceShield.KeptOnDeploy
```

### Stationary vehicles
Expand Down
3 changes: 2 additions & 1 deletion docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ You can use the migration utility (can be found on [Phobos supplementaries repo]

### From vanilla

- `[CrateRules]` -> `FreeMCV` now controls whether or not player is forced to receive unit from `[General]` -> `BaseUnit` from goodie crate if they own no buildings or any existing `BaseUnit` vehicles and own more than `[CrateRules]` -> `FreeMCV.CreditsThreshold` (defaults to 1500) credits.- Iron Curtain status is now preserved by default when converting between TechnoTypes via `DeploysInto`/`UndeploysInto`. This behavior can be turned off per-TechnoType and global basis using `[SOMETECHNOTYPE]/[CombatDamage]->IronCurtain.KeptOnDeploy=no`.
- `[CrateRules]` -> `FreeMCV` now controls whether or not player is forced to receive unit from `[General]` -> `BaseUnit` from goodie crate if they own no buildings or any existing `BaseUnit` vehicles and own more than `[CrateRules]` -> `FreeMCV.CreditsThreshold` (defaults to 1500) credits.
- Translucent RLE SHPs will now be drawn using a more precise and performant algorithm that has no green tint and banding. Can be disabled with `rulesmd.ini->[General]->FixTransparencyBlitters=no`.
- Iron Curtain status is now preserved by default when converting between TechnoTypes via `DeploysInto`/`UndeploysInto`. This behavior can be turned off per-TechnoType and global basis using `[SOMETECHNOTYPE]/[CombatDamage]->IronCurtain.KeptOnDeploy=no`.
- - The obsolete `[General] WarpIn` has been enabled for the default anim type when technos are warping in. If you want to restore the vanilla behavior, use the same anim type as `WarpOut`.
Expand Down Expand Up @@ -403,6 +403,7 @@ New:
- Custom tint on TechnoTypes (by Starkku)
- Revenge weapon (by Starkku)
- AttachEffect types with new features like custom tint and weapon range modifier (by Starkku)
- `ForceShield.KeptOnDeploy` to complement `IronCurtain.KeptOnDeploy` (by Starkku)
Vanilla fixes:
- Allow AI to repair structures built from base nodes/trigger action 125/SW delivery in single player missions (by Trsdy)
Expand Down
2 changes: 2 additions & 0 deletions src/Ext/Rules/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
this->ForbidParallelAIQueues_Vehicle.Read(exINI, "GlobalControls", "ForbidParallelAIQueues.Vehicle");

this->IronCurtain_KeptOnDeploy.Read(exINI, GameStrings::CombatDamage, "IronCurtain.KeptOnDeploy");
this->ForceShield_KeptOnDeploy.Read(exINI, GameStrings::CombatDamage, "ForceShield.KeptOnDeploy");
this->IronCurtain_EffectOnOrganics.Read(exINI, GameStrings::CombatDamage, "IronCurtain.EffectOnOrganics");
this->IronCurtain_KillOrganicsWarhead.Read(exINI, GameStrings::CombatDamage, "IronCurtain.KillOrganicsWarhead");

Expand Down Expand Up @@ -283,6 +284,7 @@ void RulesExt::ExtData::Serialize(T& Stm)
.Process(this->IronCurtain_EffectOnOrganics)
.Process(this->IronCurtain_KillOrganicsWarhead)
.Process(this->IronCurtain_KeptOnDeploy)
.Process(this->ForceShield_KeptOnDeploy)
.Process(this->ROF_RandomDelay)
.Process(this->ToolTip_Background_Color)
.Process(this->ToolTip_Background_Opacity)
Expand Down
2 changes: 2 additions & 0 deletions src/Ext/Rules/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class RulesExt
Valueable<AffectedHouse> DisplayIncome_Houses;

Valueable<bool> IronCurtain_KeptOnDeploy;
Valueable<bool> ForceShield_KeptOnDeploy;
Valueable<IronCurtainEffect> IronCurtain_EffectOnOrganics;
Nullable<WarheadTypeClass*> IronCurtain_KillOrganicsWarhead;

Expand Down Expand Up @@ -177,6 +178,7 @@ class RulesExt
, ForbidParallelAIQueues_Navy { false }
, ForbidParallelAIQueues_Vehicle { false }
, IronCurtain_KeptOnDeploy { true }
, ForceShield_KeptOnDeploy { false }
, IronCurtain_EffectOnOrganics { IronCurtainEffect::Kill }
, IronCurtain_KillOrganicsWarhead { }
, ROF_RandomDelay { { 0 ,2 } }
Expand Down
12 changes: 9 additions & 3 deletions src/Ext/Techno/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,21 @@ bool TechnoExt::HasAvailableDock(TechnoClass* pThis)
return false;
}

void TechnoExt::SyncIronCurtainStatus(TechnoClass* pFrom, TechnoClass* pTo)
// Syncs Iron Curtain or Force Shield timer to another techno.
void TechnoExt::SyncInvulnerability(TechnoClass* pFrom, TechnoClass* pTo)
{
if (pFrom->IsIronCurtained() && !pFrom->ForceShielded)
if (pFrom->IsIronCurtained())
{
const auto pTypeExt = TechnoTypeExt::ExtMap.Find(pFrom->GetTechnoType());
if (pTypeExt->IronCurtain_KeptOnDeploy.Get(RulesExt::Global()->IronCurtain_KeptOnDeploy))
bool isForceShielded = pFrom->ForceShielded;
bool allowSyncing = !isForceShielded ? pTypeExt->IronCurtain_KeptOnDeploy.Get(RulesExt::Global()->IronCurtain_KeptOnDeploy) :
pTypeExt->ForceShield_KeptOnDeploy.Get(RulesExt::Global()->ForceShield_KeptOnDeploy);

if (allowSyncing)
{
pTo->IronCurtain(pFrom->IronCurtainTimer.GetTimeLeft(), pFrom->Owner, false);
pTo->IronTintStage = pFrom->IronTintStage;
pTo->ForceShielded = isForceShielded;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Ext/Techno/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class TechnoExt
static void DrawSelfHealPips(TechnoClass* pThis, Point2D* pLocation, RectangleStruct* pBounds);
static void DrawInsignia(TechnoClass* pThis, Point2D* pLocation, RectangleStruct* pBounds);
static void ApplyGainedSelfHeal(TechnoClass* pThis);
static void SyncIronCurtainStatus(TechnoClass* pFrom, TechnoClass* pTo);
static void SyncInvulnerability(TechnoClass* pFrom, TechnoClass* pTo);
static CoordStruct PassengerKickOutLocation(TechnoClass* pThis, FootClass* pPassenger, int maxAttempts);
static bool AllowedTargetByZone(TechnoClass* pThis, TechnoClass* pTarget, TargetZoneScanType zoneScanType, WeaponTypeClass* pWeapon = nullptr, bool useZone = false, int zone = -1);
static void UpdateAttachedAnimLayers(TechnoClass* pThis);
Expand Down
4 changes: 2 additions & 2 deletions src/Ext/Techno/Hooks.DeploysInto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ DEFINE_HOOK(0x739956, UnitClass_Deploy_Transfer, 0x6)

TechnoExt::TransferMindControlOnDeploy(pUnit, pStructure);
ShieldClass::SyncShieldToAnother(pUnit, pStructure);
TechnoExt::SyncIronCurtainStatus(pUnit, pStructure);
TechnoExt::SyncInvulnerability(pUnit, pStructure);
AttachEffectClass::TransferAttachedEffects(pUnit, pStructure);

return 0;
Expand All @@ -88,7 +88,7 @@ DEFINE_HOOK(0x44A03C, BuildingClass_Mi_Selling_Transfer, 0x6)

TechnoExt::TransferMindControlOnDeploy(pStructure, pUnit);
ShieldClass::SyncShieldToAnother(pStructure, pUnit);
TechnoExt::SyncIronCurtainStatus(pStructure, pUnit);
TechnoExt::SyncInvulnerability(pStructure, pUnit);
AttachEffectClass::TransferAttachedEffects(pStructure, pUnit);

pUnit->QueueMission(Mission::Hunt, true);
Expand Down
2 changes: 2 additions & 0 deletions src/Ext/TechnoType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->Passengers_SyncOwner_RevertOnExit.Read(exINI, pSection, "Passengers.SyncOwner.RevertOnExit");

this->IronCurtain_KeptOnDeploy.Read(exINI, pSection, "IronCurtain.KeptOnDeploy");
this->ForceShield_KeptOnDeploy.Read(exINI, pSection, "ForceShield.KeptOnDeploy");
this->IronCurtain_Effect.Read(exINI, pSection, "IronCurtain.Effect");
this->IronCurtain_KillWarhead.Read(exINI, pSection, "IronCurtain.KillWarhead");

Expand Down Expand Up @@ -579,6 +580,7 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
.Process(this->EliteDeployedWeaponBurstFLHs)

.Process(this->IronCurtain_KeptOnDeploy)
.Process(this->ForceShield_KeptOnDeploy)
.Process(this->IronCurtain_Effect)
.Process(this->IronCurtain_KillWarhead)

Expand Down
2 changes: 2 additions & 0 deletions src/Ext/TechnoType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class TechnoTypeExt
Valueable<bool> Passengers_SyncOwner_RevertOnExit;

Nullable<bool> IronCurtain_KeptOnDeploy;
Nullable<bool> ForceShield_KeptOnDeploy;
Nullable<IronCurtainEffect> IronCurtain_Effect;
Nullable<WarheadTypeClass*> IronCurtain_KillWarhead;
Valueable<bool> Explodes_KillPassengers;
Expand Down Expand Up @@ -352,6 +353,7 @@ class TechnoTypeExt
, DeployedSecondaryFireFLH {}

, IronCurtain_KeptOnDeploy {}
, ForceShield_KeptOnDeploy {}
, IronCurtain_Effect {}
, IronCurtain_KillWarhead {}

Expand Down

0 comments on commit 8ef800d

Please sign in to comment.