Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,7 @@ This page lists all the individual contributions to the project by their author.
- Customize the step limit of the credits indicator
- Disable the credits indicator smooth transition
- Add `selling`, `undeploying` and `harvesting` conditions to `DiscardOn`
- Add a definition flag for whether AutoDeath can trigger in Limbo state
- **Ollerus**:
- Build limit group enhancement
- Customizable rocker amplitude
Expand Down
2 changes: 2 additions & 0 deletions docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -1978,12 +1978,14 @@ Both `InitialStrength` and `InitialStrength.Cloning` never surpass the type's `S
- `vanish`: The object will be directly removed from the game peacefully instead of actually getting killed.
- `sell`: If the object is a **building** with buildup, it will be sold instead of destroyed.
- If this option is not set, the self-destruction logic will not be enabled. `AutoDeath.VanishAnimation` can be set to animation to play at object's location if `vanish` behaviour is chosen. If more than one animation is listed, a random one is selected.
- `AutoDeath.AllowLimboed` can be used to define whether AutoDeath is triggered when the unit is in limbo state, such as when it is a passenger.
- This logic also supports buildings delivered by [LimboDelivery](#limbodelivery). However in this case, all `AutoDeath.Behavior` values produce identical result where the building is simply deleted.

In `rulesmd.ini`:
```ini
[SOMETECHNO] ; TechnoType
AutoDeath.Behavior= ; enumeration (kill | vanish | sell), default not set
AutoDeath.AllowLimboed=true ; boolean
AutoDeath.VanishAnimation= ; List of AnimationTypes
AutoDeath.OnAmmoDepletion=false ; boolean
AutoDeath.OnOwnerChange=false ; boolean
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ HideShakeEffects=false ; boolean
- [Customize the step limit of the credits indicator](User-Interface.md#customize-the-step-limit-of-the-credits-indicator) (by Noble_Fish)
- [Disable the credits indicator smooth transition](User-Interface.md#disable-the-credits-indicator-smooth-transition) (by Noble_Fish)
- Add `selling`, `undeploying` and `harvesting` conditions to `DiscardOn` (by Noble_Fish)
- Add a definition flag for whether AutoDeath can trigger in Limbo state (by Noble_Fish)

#### Vanilla fixes:
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)
Expand Down
32 changes: 18 additions & 14 deletions src/Ext/House/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,24 +217,28 @@ DEFINE_HOOK(0x7015C9, TechnoClass_Captured_UpdateTracking, 0x6)

if (pTypeExt->AutoDeath_Behavior.isset())
{
const bool humanToComputer = pTypeExt->AutoDeath_OnOwnerChange_HumanToComputer.Get(pTypeExt->AutoDeath_OnOwnerChange);
const bool computerToHuman = pTypeExt->AutoDeath_OnOwnerChange_ComputerToHuman.Get(pTypeExt->AutoDeath_OnOwnerChange);

if (humanToComputer && computerToHuman)
{
TechnoExt::KillSelf(pThis, pTypeExt->AutoDeath_Behavior, pTypeExt->AutoDeath_VanishAnimation, !pThis->IsInLogic && pThis->IsAlive);
return 0;
}
else if (humanToComputer || computerToHuman)
const bool isInLimbo = !pThis->IsInLogic && pThis->IsAlive;
if (!(isInLimbo && !pTypeExt->AutoDeath_AllowLimboed))
{
const bool I_am_human = pThis->Owner->IsControlledByHuman();
const bool humanToComputer = pTypeExt->AutoDeath_OnOwnerChange_HumanToComputer.Get(pTypeExt->AutoDeath_OnOwnerChange);
const bool computerToHuman = pTypeExt->AutoDeath_OnOwnerChange_ComputerToHuman.Get(pTypeExt->AutoDeath_OnOwnerChange);

if (I_am_human != pNewOwner->IsControlledByHuman())
if (humanToComputer && computerToHuman)
{
if ((I_am_human && humanToComputer) || (!I_am_human && computerToHuman))
TechnoExt::KillSelf(pThis, pTypeExt->AutoDeath_Behavior, pTypeExt->AutoDeath_VanishAnimation, isInLimbo);
return 0x701881;
}
else if (humanToComputer || computerToHuman)
{
const bool I_am_human = pThis->Owner->IsControlledByHuman();

if (I_am_human != pNewOwner->IsControlledByHuman())
{
TechnoExt::KillSelf(pThis, pTypeExt->AutoDeath_Behavior, pTypeExt->AutoDeath_VanishAnimation, !pThis->IsInLogic && pThis->IsAlive);
return 0;
if ((I_am_human && humanToComputer) || (!I_am_human && computerToHuman))
{
TechnoExt::KillSelf(pThis, pTypeExt->AutoDeath_Behavior, pTypeExt->AutoDeath_VanishAnimation, isInLimbo);
return 0x701881;
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/Ext/Techno/Body.Update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ bool TechnoExt::ExtData::CheckDeathConditions(bool isInLimbo)
if (!pTypeExt->AutoDeath_Behavior.isset())
return false;

if (isInLimbo && !pTypeExt->AutoDeath_AllowLimboed)
return false;

auto const pThis = this->OwnerObject();

// Self-destruction must be enabled
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 @@ -792,6 +792,7 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->Ammo_DeployUnlockMaximumAmount.Read(exINI, pSection, "Ammo.DeployUnlockMaximumAmount");

this->AutoDeath_Behavior.Read(exINI, pSection, "AutoDeath.Behavior");
this->AutoDeath_AllowLimboed.Read(exINI, pSection, "AutoDeath.AllowLimboed");
this->AutoDeath_VanishAnimation.Read(exINI, pSection, "AutoDeath.VanishAnimation");
this->AutoDeath_OnAmmoDepletion.Read(exINI, pSection, "AutoDeath.OnAmmoDepletion");
this->AutoDeath_OnOwnerChange.Read(exINI, pSection, "AutoDeath.OnOwnerChange");
Expand Down Expand Up @@ -1552,6 +1553,7 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
.Process(this->Ammo_DeployUnlockMaximumAmount)

.Process(this->AutoDeath_Behavior)
.Process(this->AutoDeath_AllowLimboed)
.Process(this->AutoDeath_VanishAnimation)
.Process(this->AutoDeath_OnAmmoDepletion)
.Process(this->AutoDeath_OnOwnerChange)
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 @@ -91,6 +91,7 @@ class TechnoTypeExt
Valueable<int> Ammo_DeployUnlockMaximumAmount;

Nullable<AutoDeathBehavior> AutoDeath_Behavior;
Valueable<bool> AutoDeath_AllowLimboed;
ValueableVector<AnimTypeClass*> AutoDeath_VanishAnimation;
Valueable<bool> AutoDeath_OnAmmoDepletion;
Valueable<bool> AutoDeath_OnOwnerChange;
Expand Down Expand Up @@ -647,6 +648,7 @@ class TechnoTypeExt
, Ammo_DeployUnlockMaximumAmount { -1 }

, AutoDeath_Behavior { }
, AutoDeath_AllowLimboed { true }
, AutoDeath_VanishAnimation {}
, AutoDeath_OnAmmoDepletion { false }
, AutoDeath_OnOwnerChange { false }
Expand Down
Loading