Skip to content

Commit d0a94e4

Browse files
authored
Customize whether the animation with Crater=yes would destroy tiberium (#1702)
### Customize whether `Crater=yes` animation would destroy tiberium - In vanilla, the anim with `Crater=yes` is hardcoded to destroy the tiberium in its cell. Now you can disable this behavior by setting the following tags to `false`. In `rulesmd.ini`: ```ini [General] AnimCraterDestroyTiberium=true ; boolean ``` In `artmd.ini`: ```ini [SOMEANIM] ; AnimationType Crater.DestroyTiberium= ; boolean, default to [General]->AnimCraterDestroyTiberium ```
1 parent 38f5ef2 commit d0a94e4

File tree

8 files changed

+40
-6
lines changed

8 files changed

+40
-6
lines changed

CREDITS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ This page lists all the individual contributions to the project by their author.
525525
- Allow miners do area guard
526526
- Make harvesters do addtional scan after unload
527527
- Customize the scatter caused by aircraft attack mission
528+
- Customize whether `Crater=yes` animation would destroy tiberium
528529
- **tyuah8**:
529530
- Drive/Jumpjet/Ship/Teleport locomotor did not power on when it is un-piggybacked bugfix
530531
- Destroyed unit leaves sensors bugfix

docs/Fixed-or-Improved-Logics.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,22 @@ SplashAnims.PickRandom=false ; boolean
361361
ExtraShadow=true ; boolean
362362
```
363363

364+
### Customize whether `Crater=yes` animation would destroy tiberium
365+
366+
- In vanilla, the anim with `Crater=yes` is hardcoded to destroy the tiberium in its cell. Now you can disable this behavior by setting the following tags to `false`.
367+
368+
In `rulesmd.ini`:
369+
```ini
370+
[General]
371+
AnimCraterDestroyTiberium=true ; boolean
372+
```
373+
374+
In `artmd.ini`:
375+
```ini
376+
[SOMEANIM] ; AnimationType
377+
Crater.DestroyTiberium= ; boolean, default to [General]->AnimCraterDestroyTiberium
378+
```
379+
364380
### Fire animations spawned by Scorch & Flamer
365381

366382
- Tiberian Sun allowed `Scorch=true` and `Flamer=true` animations to spawn fire animations from `[AudioVisual] -> SmallFire` & `LargeFire`. This behaviour has been reimplemented and is fully customizable.

docs/Whats-New.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,8 @@ New:
385385
- Customize the scatter caused by aircraft attack mission (by TaranDahl)
386386
- [Customizable garrison and bunker properties](Fixed-or-Improved-Logics.md#customizable-garrison-and-bunker-properties) (by Otamaa)
387387
- [Disable DamageSound for buildings](Fixed-or-Improved-Logics.md#disable-damagesound) (by Otamaa)
388-
- [Power plant damage factor](New-or-Enhanced-Logics.md#power-plant-damage-factor) (by Otamaa and Ollerus)
388+
- [Power plant damage factor](Fixed-or-Improved-Logics#power-plant-damage-factor) (by Otamaa and Ollerus)
389+
- Customize whether `Crater=yes` animation would destroy tiberium (by TaranDahl)
389390
390391
Vanilla fixes:
391392
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)

src/Ext/Anim/Hooks.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ DEFINE_HOOK(0x423B95, AnimClass_AI_HideIfNoOre_Threshold, 0x8)
2525

2626
if (pType->HideIfNoOre)
2727
{
28-
auto nThreshold = abs(AnimTypeExt::ExtMap.Find(pThis->Type)->HideIfNoOre_Threshold.Get());
28+
const int nThreshold = abs(AnimTypeExt::ExtMap.Find(pThis->Type)->HideIfNoOre_Threshold.Get());
2929
pThis->Invisible = pThis->GetCell()->GetContainedTiberiumValue() <= nThreshold;
3030
}
3131

@@ -42,8 +42,8 @@ DEFINE_HOOK(0x42453E, AnimClass_AI_Damage, 0x6)
4242

4343
GET(AnimClass*, pThis, ESI);
4444

45-
auto const pTypeExt = AnimTypeExt::ExtMap.Find(pThis->Type);
46-
int delay = pTypeExt->Damage_Delay.Get();
45+
const auto pTypeExt = AnimTypeExt::ExtMap.Find(pThis->Type);
46+
const int delay = pTypeExt->Damage_Delay.Get();
4747
int damageMultiplier = 1;
4848
double damage = 0;
4949
int appliedDamage = 0;
@@ -483,4 +483,10 @@ DEFINE_HOOK(0x425060, AnimClass_Expire_ScorchFlamer, 0x6)
483483

484484
#pragma endregion
485485

486+
DEFINE_HOOK(0x4250E1, AnimClass_Middle_CraterDestroyTiberium, 0x6)
487+
{
488+
enum { SkipDestroyTiberium = 0x4250EC };
489+
GET(AnimTypeClass*, pType, EDX);
490+
return AnimTypeExt::ExtMap.Find(pType)->Crater_DestroyTiberium.Get(RulesExt::Global()->AnimCraterDestroyTiberium) ? 0 : SkipDestroyTiberium;
491+
}
486492

src/Ext/AnimType/Body.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ void AnimTypeExt::ProcessDestroyAnims(UnitClass* pThis, TechnoClass* pKiller)
1717
if (!pThis)
1818
return;
1919

20-
HouseClass* pInvoker = pKiller ? pKiller->Owner : nullptr;
21-
2220
if (pThis->Type->DestroyAnim.Count > 0)
2321
{
2422
auto const facing = pThis->PrimaryFacing.Current().GetDir();
@@ -49,6 +47,7 @@ void AnimTypeExt::ProcessDestroyAnims(UnitClass* pThis, TechnoClass* pKiller)
4947
if (pAnimType)
5048
{
5149
auto const pAnim = GameCreate<AnimClass>(pAnimType, pThis->Location);
50+
auto const pInvoker = pKiller ? pKiller->Owner : nullptr;
5251

5352
//auto VictimOwner = pThis->IsMindControlled() && pThis->GetOriginalOwner()
5453
// ? pThis->GetOriginalOwner() : pThis->Owner;
@@ -119,6 +118,7 @@ void AnimTypeExt::ExtData::LoadFromINIFile(CCINIClass* pINI)
119118
this->LargeFireAnims.Read(exINI, pID, "LargeFireAnims");
120119
this->LargeFireChances.Read(exINI, pID, "LargeFireChances");
121120
this->LargeFireDistances.Read(exINI, pID, "LargeFireDistances");
121+
this->Crater_DestroyTiberium.Read(exINI, pID, "Crater.DestroyTiberium");
122122

123123
// Parasitic types
124124
Nullable<TechnoTypeClass*> createUnit;
@@ -176,6 +176,7 @@ void AnimTypeExt::ExtData::Serialize(T& Stm)
176176
.Process(this->LargeFireAnims)
177177
.Process(this->LargeFireChances)
178178
.Process(this->LargeFireDistances)
179+
.Process(this->Crater_DestroyTiberium)
179180
;
180181
}
181182

src/Ext/AnimType/Body.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class AnimTypeExt
5454
ValueableVector<AnimTypeClass*> LargeFireAnims;
5555
ValueableVector<double> LargeFireChances;
5656
ValueableVector<double> LargeFireDistances;
57+
Nullable<bool> Crater_DestroyTiberium;
5758

5859
ExtData(AnimTypeClass* OwnerObject) : Extension<AnimTypeClass>(OwnerObject)
5960
, Palette { CustomPalette::PaletteMode::Temperate }
@@ -91,6 +92,7 @@ class AnimTypeExt
9192
, LargeFireAnims {}
9293
, LargeFireChances {}
9394
, LargeFireDistances {}
95+
, Crater_DestroyTiberium {}
9496
{ }
9597

9698
virtual ~ExtData() = default;

src/Ext/Rules/Body.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
272272

273273
this->HarvesterScanAfterUnload.Read(exINI, GameStrings::General, "HarvesterScanAfterUnload");
274274

275+
this->AnimCraterDestroyTiberium.Read(exINI, GameStrings::General, "AnimCraterDestroyTiberium");
276+
275277
// Section AITargetTypes
276278
int itemsCount = pINI->GetKeyCount("AITargetTypes");
277279
for (int i = 0; i < itemsCount; ++i)
@@ -498,6 +500,7 @@ void RulesExt::ExtData::Serialize(T& Stm)
498500
.Process(this->ProneSpeed_NoCrawls)
499501
.Process(this->DamagedSpeed)
500502
.Process(this->HarvesterScanAfterUnload)
503+
.Process(this->AnimCraterDestroyTiberium)
501504
;
502505
}
503506

src/Ext/Rules/Body.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ class RulesExt
225225

226226
Valueable<bool> HarvesterScanAfterUnload;
227227

228+
Valueable<bool> AnimCraterDestroyTiberium;
229+
228230
ExtData(RulesClass* OwnerObject) : Extension<RulesClass>(OwnerObject)
229231
, Storage_TiberiumIndex { -1 }
230232
, HarvesterDumpAmount { 0.0f }
@@ -395,6 +397,8 @@ class RulesExt
395397
, DamagedSpeed { 0.75 }
396398

397399
, HarvesterScanAfterUnload { false }
400+
401+
, AnimCraterDestroyTiberium { true }
398402
{ }
399403

400404
virtual ~ExtData() = default;

0 commit comments

Comments
 (0)