Skip to content

Commit 3986217

Browse files
Customize the landing animation of technos that have Locomotor=Fly (#2259)
In vanilla, if a techno has `Locomotor=Fly` and `IsDropship=true`, it plays the `[DROPLAND]` animation when landing; if `IsDropship=false` but it is an aircraft with `Carryall=true`, it will play the `[CARYLAND]` animation when landing. Now you can customize this logic. In `rulesmd.ini`: ```ini [AudioVisual] DefaultLandingAnim= ; AnimationType DefaultLandingAnim.Dropship=DROPLAND ; AnimationType DefaultLandingAnim.Carryall=CARYLAND ; AnimationType [SOMETECHNO] ; TechnoType LandingAnim= ; AnimationType, defaults to the global default (<custom animation>, DROPLAND, or CARYLAND) based on unit's IsDropship/Carryall flags ``` --- <img width="438" height="234" alt="LandingAnim" src="https://github.com/user-attachments/assets/ee9d5d16-ac32-4dba-81f8-262388ec2536" /> *RING1, PDFXLOC and a custom animation created by ppap11404*
1 parent 8898bd6 commit 3986217

8 files changed

Lines changed: 92 additions & 0 deletions

File tree

CREDITS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,7 @@ This page lists all the individual contributions to the project by their author.
685685
- Allow customizing whether the creation of shrapnel weapon is controlled by the new target check on the warhead of the parent weapon
686686
- Customize `Tiled` drawing interval and centering
687687
- Customize whether technos with `Locomotor=Fly` wobble
688+
- Customize the landing animation of technos that have `Locomotor=Fly`
688689
- **Ollerus**:
689690
- Build limit group enhancement
690691
- Customizable rocker amplitude

docs/Fixed-or-Improved-Logics.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,6 +1749,21 @@ FallingDownDamage.Water= ; integer / percentage
17491749
FallingDownDamage.AllowEMP=true ; boolean
17501750
```
17511751

1752+
### Customize the landing animation of technos that have `Locomotor=Fly`
1753+
1754+
- In vanilla, if a techno has `Locomotor=Fly` and `IsDropship=true`, it plays the `[DROPLAND]` animation when landing; if `IsDropship=false` but it is an aircraft with `Carryall=true`, it will play the `[CARYLAND]` animation when landing. Now you can customize this logic.
1755+
1756+
In `rulesmd.ini`:
1757+
```ini
1758+
[AudioVisual]
1759+
DefaultLandingAnim= ; AnimationType
1760+
DefaultLandingAnim.Dropship=DROPLAND ; AnimationType
1761+
DefaultLandingAnim.Carryall=CARYLAND ; AnimationType
1762+
1763+
[SOMETECHNO] ; TechnoType
1764+
LandingAnim= ; AnimationType, defaults to the global default (none, DROPLAND, or CARYLAND) based on unit's IsDropship/Carryall flags
1765+
```
1766+
17521767
### Customize whether technos with `Locomotor=Fly` wobble
17531768

17541769
- In vanilla, if technos use `Locomotor=Fly` and do not have `IsDropship=true`, they will have a hardcoded wobble effect. However, using `IsDropship=true` also introduces a series of hardcoded behaviors associated with it. Now, you can customize whether to disable this behavior, and it can also be used to enable this behavior for technos with `IsDropship=true`.

docs/Whats-New.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,7 @@ HideShakeEffects=false ; boolean
592592
- [Animation transparency customization settings](New-or-Enhanced-Logics.md#customizable-animation-transparency-settings) (by Starkku)
593593
- [Customize `Tiled` drawing interval and centering](Fixed-or-Improved-Logics.md#customize-the-drawing-interval-for-tiled) (by Noble_Fish)
594594
- [Customize whether technos with `Locomotor=Fly` wobble](Fixed-or-Improved-Logics.md#customize-whether-technos-with-locomotor-fly-wobble) (by Noble_Fish)
595+
- [Customize the landing animation of technos that have `Locomotor=Fly`](Fixed-or-Improved-Logics.md#customize-the-landing-animation-of-technos-that-have-locomotor-fly) (by Noble_Fish)
595596
596597
#### Vanilla fixes:
597598
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)

src/Ext/Rules/Body.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,10 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
428428

429429
this->FlyNoWobbles.Read(exINI, GameStrings::AudioVisual, "FlyNoWobbles");
430430

431+
this->DefaultLandingAnim.Read(exINI, GameStrings::AudioVisual, "DefaultLandingAnim");
432+
this->DefaultLandingAnim_Dropship.Read(exINI, GameStrings::AudioVisual, "DefaultLandingAnim.Dropship");
433+
this->DefaultLandingAnim_Carryall.Read(exINI, GameStrings::AudioVisual, "DefaultLandingAnim.Carryall");
434+
431435
this->TeamDelays_DynamicType.Read(exINI, GameStrings::General, "TeamDelays.DynamicType");
432436

433437
char tempBuffer[40];
@@ -775,6 +779,9 @@ void RulesExt::ExtData::Serialize(T& Stm)
775779
.Process(this->RemoveMindControl_Silent)
776780
.Process(this->MindControl_Permanent_ReplaceSilent)
777781
.Process(this->FlyNoWobbles)
782+
.Process(this->DefaultLandingAnim)
783+
.Process(this->DefaultLandingAnim_Dropship)
784+
.Process(this->DefaultLandingAnim_Carryall)
778785
.Process(this->TeamDelays_DynamicType)
779786
.Process(this->TeamDelays_Count)
780787
;

src/Ext/Rules/Body.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,10 @@ class RulesExt
365365
Valueable<bool> MindControl_Permanent_ReplaceSilent;
366366
Nullable<bool> FlyNoWobbles;
367367

368+
Valueable<AnimTypeClass*> DefaultLandingAnim;
369+
Nullable<AnimTypeClass*> DefaultLandingAnim_Dropship;
370+
Nullable<AnimTypeClass*> DefaultLandingAnim_Carryall;
371+
368372
Valueable<DynamicTeamDelayType> TeamDelays_DynamicType;
369373
Valueable<Vector3D<int>> TeamDelays_Count[8];
370374

@@ -672,6 +676,10 @@ class RulesExt
672676

673677
, FlyNoWobbles {}
674678

679+
, DefaultLandingAnim { nullptr }
680+
, DefaultLandingAnim_Dropship {}
681+
, DefaultLandingAnim_Carryall {}
682+
675683
, TeamDelays_DynamicType { DynamicTeamDelayType::StartingPoint }
676684
, TeamDelays_Count {}
677685
{ }

src/Ext/Techno/Hooks.cpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2065,6 +2065,58 @@ DEFINE_HOOK(0x70AFEF, TechnoClass_UpdateSight_DynamicSight2, 0x6)
20652065

20662066
#pragma endregion
20672067

2068+
static AnimTypeClass* GetLandingAnim(TechnoClass* pTechno)
2069+
{
2070+
auto const pType = pTechno->GetTechnoType();
2071+
auto const pTypeExt = TechnoTypeExt::ExtMap.Find(pType);
2072+
2073+
if (pTypeExt->LandingAnim.isset())
2074+
return pTypeExt->LandingAnim.Get();
2075+
2076+
if (pType->IsDropship)
2077+
{
2078+
if (RulesExt::Global()->DefaultLandingAnim_Dropship.isset())
2079+
return RulesExt::Global()->DefaultLandingAnim_Dropship.Get();
2080+
return AnimTypeClass::Find("DROPLAND");
2081+
}
2082+
2083+
auto const pAircraft = abstract_cast<AircraftClass*, true>(pTechno);
2084+
if (pAircraft && pAircraft->Type->Carryall)
2085+
{
2086+
if (RulesExt::Global()->DefaultLandingAnim_Carryall.isset())
2087+
return RulesExt::Global()->DefaultLandingAnim_Carryall.Get();
2088+
return AnimTypeClass::Find("CARYLAND");
2089+
}
2090+
2091+
return RulesExt::Global()->DefaultLandingAnim;
2092+
}
2093+
2094+
DEFINE_HOOK(0x4CEB59, FlyLocomotionClass_ProcessLanding_ForceDropship, 0x6)
2095+
{
2096+
GET(FlyLocomotionClass*, pLoco, ESI);
2097+
auto const pType = pLoco->LinkedTo->GetTechnoType();
2098+
bool force = TechnoTypeExt::ExtMap.Find(pType)->LandingAnim.isset() || RulesExt::Global()->DefaultLandingAnim != nullptr;
2099+
2100+
R->CL(force || pType->IsDropship);
2101+
return 0x4CEB5F;
2102+
}
2103+
2104+
DEFINE_HOOK(0x4CEB7E, FlyLocomotionClass_ProcessLanding_DropshipAnim, 0x5)
2105+
{
2106+
GET(FlyLocomotionClass*, pLoco, ESI);
2107+
auto const pAnim = GetLandingAnim(pLoco->LinkedTo);
2108+
R->EAX(pAnim ? pAnim->ArrayIndex : -1);
2109+
return 0x4CEB88;
2110+
}
2111+
2112+
DEFINE_HOOK(0x4CEC31, FlyLocomotionClass_ProcessLanding_CarryallAnim, 0x5)
2113+
{
2114+
GET(FlyLocomotionClass*, pLoco, ESI);
2115+
auto const pAnim = GetLandingAnim(pLoco->LinkedTo);
2116+
R->EAX(pAnim ? pAnim->ArrayIndex : -1);
2117+
return 0x4CEC3B;
2118+
}
2119+
20682120
DEFINE_HOOK(0x4CF8B1, FlyLocomotionClass_Draw_Point_NoWobbles, 0x6)
20692121
{
20702122
enum { Continue = 0x4CF8B7 };

src/Ext/TechnoType/Body.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,6 +1201,8 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
12011201

12021202
this->FlyNoWobbles.Read(exINI, pSection, "FlyNoWobbles");
12031203

1204+
this->LandingAnim.Read(exINI, pSection, "LandingAnim");
1205+
12041206
// Ares 0.2
12051207
this->RadarJamRadius.Read(exINI, pSection, "RadarJamRadius");
12061208

@@ -1945,6 +1947,8 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
19451947
.Process(this->Parasite_AllowWaterExit)
19461948

19471949
.Process(this->FlyNoWobbles)
1950+
1951+
.Process(this->LandingAnim)
19481952
;
19491953
}
19501954
void TechnoTypeExt::ExtData::LoadFromStream(PhobosStreamReader& Stm)

src/Ext/TechnoType/Body.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,8 @@ class TechnoTypeExt
514514

515515
Nullable<bool> FlyNoWobbles;
516516

517+
Nullable<AnimTypeClass*> LandingAnim;
518+
517519
ExtData(TechnoTypeClass* OwnerObject) : Extension<TechnoTypeClass>(OwnerObject)
518520
, HealthBar_Hide { false }
519521
, HealthBar_HidePips { false }
@@ -980,6 +982,8 @@ class TechnoTypeExt
980982
, Parasite_AllowWaterExit {}
981983

982984
, FlyNoWobbles {}
985+
986+
, LandingAnim {}
983987
{ }
984988

985989
virtual ~ExtData() = default;

0 commit comments

Comments
 (0)