Skip to content

Commit

Permalink
Allow toggling Explodes to not work during buildup/being sold
Browse files Browse the repository at this point in the history
  • Loading branch information
Starkku committed Mar 29, 2024
1 parent 5e1960f commit 5143aa1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
6 changes: 5 additions & 1 deletion docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -565,14 +565,18 @@ In `rulesmd.ini`:
Storage.TiberiumIndex=-1 ; integer, [Tiberiums] list index
```

### Exploding unit passenger killing customization
### Exploding object customizations

- By default `Explodes=true` TechnoTypes have all of their passengers killed when they are destroyed. This behaviour can now be disabled by setting `Explodes.KillPassengers=false`.
- BuildingTypes with `Explodes=true` can by default explode even when they are still being built or sold. This can be disabled by setting `Explodes.DuringBuildup` to false. This causes them to behave as if `Explodes` was set to false while being built up or sold.

In `rulesmd.ini`:
```ini
[SOMETECHNO] ; TechnoType
Explodes.KillPassengers=true ; boolean

[SOMEBUILDING] ; BuildingType
Explodes.DuringBuildup=true ; boolean
```

### IronCurtain effects on organics customization
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ New:
- Recreate the weed-charging of SWs like the TS Chemical Missile (by ZivDero)
- Allow to change the speed of gas particles (by ZivDero)
- Allow upgrade animations to use `Powered` & `PoweredLight/Effect/Special` keys (by Starkku)
- Toggle for `Explodes=true` BuildingTypes to not explode during buildup or being sold (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
10 changes: 8 additions & 2 deletions src/Ext/Techno/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,20 @@ DEFINE_HOOK(0x701DFF, TechnoClass_ReceiveDamage_FlyingStrings, 0x7)
return 0;
}

DEFINE_HOOK(0x70265F, TechnoClass_ReceiveDamage_Explodes, 0x6)
DEFINE_HOOK(0x702603, TechnoClass_ReceiveDamage_Explodes, 0x6)
{
enum { SkipKillingPassengers = 0x702669 };
enum { SkipExploding = 0x702672, SkipKillingPassengers = 0x702669 };

GET(TechnoClass*, pThis, ESI);

const auto pTypeExt = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType());

if (pThis->WhatAmI() == AbstractType::Building)
{
if (!pTypeExt->Explodes_DuringBuildup && (pThis->CurrentMission == Mission::Construction || pThis->CurrentMission == Mission::Selling))
return SkipExploding;
}

if (!pTypeExt->Explodes_KillPassengers)
return SkipKillingPassengers;

Expand Down
3 changes: 2 additions & 1 deletion src/Ext/TechnoType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->IronCurtain_KillWarhead.Read(exINI, pSection, "IronCurtain.KillWarhead");

this->Explodes_KillPassengers.Read(exINI, pSection, "Explodes.KillPassengers");
this->Explodes_DuringBuildup.Read(exINI, pSection, "Explodes.DuringBuildup");
this->DeployFireWeapon.Read(exINI, pSection, "DeployFireWeapon");
this->TargetZoneScanType.Read(exINI, pSection, "TargetZoneScanType");

Expand Down Expand Up @@ -532,7 +533,6 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
.Process(this->SelfHealGainType)
.Process(this->Passengers_SyncOwner)
.Process(this->Passengers_SyncOwner_RevertOnExit)
.Process(this->Explodes_KillPassengers)

.Process(this->PronePrimaryFireFLH)
.Process(this->ProneSecondaryFireFLH)
Expand All @@ -548,6 +548,7 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
.Process(this->IronCurtain_KillWarhead)

.Process(this->Explodes_KillPassengers)
.Process(this->Explodes_DuringBuildup)
.Process(this->DeployFireWeapon)
.Process(this->TargetZoneScanType)

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 @@ -149,6 +149,7 @@ class TechnoTypeExt
Nullable<IronCurtainEffect> IronCurtain_Effect;
Nullable<WarheadTypeClass*> IronCurtain_KillWarhead;
Valueable<bool> Explodes_KillPassengers;
Valueable<bool> Explodes_DuringBuildup;
Nullable<int> DeployFireWeapon;
Valueable<TargetZoneScanType> TargetZoneScanType;

Expand Down Expand Up @@ -331,6 +332,7 @@ class TechnoTypeExt
, IronCurtain_KillWarhead {}

, Explodes_KillPassengers { true }
, Explodes_DuringBuildup { true }
, DeployFireWeapon {}
, TargetZoneScanType { TargetZoneScanType::Same }

Expand Down

0 comments on commit 5143aa1

Please sign in to comment.