Skip to content

Commit 816d992

Browse files
committed
Add FireOnce weapon infantry sequence reset toggle
1 parent 3b0b9cc commit 816d992

File tree

8 files changed

+54
-0
lines changed

8 files changed

+54
-0
lines changed

docs/Fixed-or-Improved-Logics.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,16 @@ In `rulesmd.ini`
13351335
KickOutPassengers=true ; boolean
13361336
```
13371337

1338+
### Disable FireOnce resetting infantry sequence
1339+
1340+
- It is now possible to disable `FireOnce=true` weapon resetting infantry sequences after firing via `FireOnce.ResetSequence`. Target will be forgotten like before, the firing sequence will simply continue playing after firing if there are any frames left.
1341+
1342+
In `rulesmd.ini`
1343+
```ini
1344+
[SOMEWEAPON]
1345+
FireOnce.ResetSequence=true ; boolean
1346+
```
1347+
13381348
### Single-color lasers
13391349

13401350
![image](_static/images/issinglecolor.gif)

docs/Whats-New.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ New:
450450
- Forbidding parallel AI queues for specific TechnoTypes (by Starkku)
451451
- Nonprovocative Warheads (by Starkku)
452452
- Option to restore `PowerSurplus` setting for AI (by Starkku)
453+
- `FireOnce` infantry sequence reset toggle (by Starkku)
453454
454455
Vanilla fixes:
455456
- Allow AI to repair structures built from base nodes/trigger action 125/SW delivery in single player missions (by Trsdy)

src/Ext/Techno/Body.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ void TechnoExt::ExtData::Serialize(T& Stm)
489489
.Process(this->IsBurrowed)
490490
.Process(this->HasBeenPlacedOnMap)
491491
.Process(this->DeployFireTimer)
492+
.Process(this->SkipTargetChangeResetSequence)
492493
.Process(this->ForceFullRearmDelay)
493494
.Process(this->CanCloakDuringRearm)
494495
.Process(this->WHAnimRemainingCreationInterval)

src/Ext/Techno/Body.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class TechnoExt
4242
bool IsBurrowed;
4343
bool HasBeenPlacedOnMap; // Set to true on first Unlimbo() call.
4444
CDTimerClass DeployFireTimer;
45+
bool SkipTargetChangeResetSequence;
4546
bool ForceFullRearmDelay;
4647
bool CanCloakDuringRearm; // Current rearm timer was started by DecloakToFire=no weapon.
4748
int WHAnimRemainingCreationInterval;
@@ -75,6 +76,7 @@ class TechnoExt
7576
, IsBurrowed { false }
7677
, HasBeenPlacedOnMap { false }
7778
, DeployFireTimer {}
79+
, SkipTargetChangeResetSequence { false }
7880
, ForceFullRearmDelay { false }
7981
, CanCloakDuringRearm { false }
8082
, WHAnimRemainingCreationInterval { 0 }

src/Ext/Techno/Hooks.Firing.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,22 @@ DEFINE_HOOK(0x6FF43F, TechnoClass_FireAt_FeedbackWeapon, 0x6)
509509
return 0;
510510
}
511511

512+
DEFINE_HOOK(0x6FF905, TechnoClass_FireAt_FireOnce, 0x6)
513+
{
514+
GET(TechnoClass*, pThis, ESI);
515+
516+
if (auto const pInf = abstract_cast<InfantryClass*>(pThis))
517+
{
518+
GET(WeaponTypeClass*, pWeapon, EBX);
519+
auto const pWeaponExt = WeaponTypeExt::ExtMap.Find(pWeapon);
520+
521+
if (!pWeaponExt->FireOnce_ResetSequence)
522+
TechnoExt::ExtMap.Find(pInf)->SkipTargetChangeResetSequence = true;
523+
}
524+
525+
return 0;
526+
}
527+
512528
DEFINE_HOOK(0x6FF660, TechnoClass_FireAt_Interceptor, 0x6)
513529
{
514530
GET(TechnoClass* const, pSource, ESI);

src/Ext/Techno/Hooks.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,3 +599,23 @@ DEFINE_HOOK(0x6F9FA9, TechnoClass_AI_PromoteAnim, 0x6)
599599
// TunnelLocomotionClass_IsToHaveShadow, skip shadow on all but idle.
600600
// TODO: Investigate if it is possible to fix the shadows not tilting on the burrowing etc. states.
601601
DEFINE_JUMP(LJMP, 0x72A070, 0x72A07F);
602+
603+
604+
DEFINE_HOOK(0x51B20E, InfantryClass_AssignTarget_FireOnce, 0x6)
605+
{
606+
enum { SkipGameCode = 0x51B255 };
607+
608+
GET(InfantryClass*, pThis, ESI);
609+
GET(AbstractClass*, pTarget, EBX);
610+
611+
auto const pExt = TechnoExt::ExtMap.Find(pThis);
612+
613+
if (!pTarget && pExt->SkipTargetChangeResetSequence)
614+
{
615+
pThis->IsFiring = false;
616+
pExt->SkipTargetChangeResetSequence = false;
617+
return SkipGameCode;
618+
}
619+
620+
return 0;
621+
}

src/Ext/WeaponType/Body.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ void WeaponTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
9595
this->Laser_IsSingleColor.Read(exINI, pSection, "IsSingleColor");
9696
this->ROF_RandomDelay.Read(exINI, pSection, "ROF.RandomDelay");
9797
this->OmniFire_TurnToTarget.Read(exINI, pSection, "OmniFire.TurnToTarget");
98+
this->FireOnce_ResetSequence.Read(exINI, pSection, "FireOnce.ResetSequence");
9899
this->ExtraWarheads.Read(exINI, pSection, "ExtraWarheads");
99100
this->ExtraWarheads_DamageOverrides.Read(exINI, pSection, "ExtraWarheads.DamageOverrides");
100101
this->ExtraWarheads_DetonationChances.Read(exINI, pSection, "ExtraWarheads.DetonationChances");
@@ -137,6 +138,7 @@ void WeaponTypeExt::ExtData::Serialize(T& Stm)
137138
.Process(this->Laser_IsSingleColor)
138139
.Process(this->ROF_RandomDelay)
139140
.Process(this->OmniFire_TurnToTarget)
141+
.Process(this->FireOnce_ResetSequence)
140142
.Process(this->ExtraWarheads)
141143
.Process(this->ExtraWarheads_DamageOverrides)
142144
.Process(this->ExtraWarheads_DetonationChances)

src/Ext/WeaponType/Body.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class WeaponTypeExt
4040
Valueable<bool> Laser_IsSingleColor;
4141
Nullable<PartialVector2D<int>> ROF_RandomDelay;
4242
Valueable<bool> OmniFire_TurnToTarget;
43+
Valueable<bool> FireOnce_ResetSequence;
4344
ValueableVector<WarheadTypeClass*> ExtraWarheads;
4445
ValueableVector<int> ExtraWarheads_DamageOverrides;
4546
ValueableVector<double> ExtraWarheads_DetonationChances;
@@ -78,6 +79,7 @@ class WeaponTypeExt
7879
, Laser_IsSingleColor { false }
7980
, ROF_RandomDelay {}
8081
, OmniFire_TurnToTarget { false }
82+
, FireOnce_ResetSequence { true }
8183
, ExtraWarheads {}
8284
, ExtraWarheads_DamageOverrides {}
8385
, ExtraWarheads_DetonationChances {}

0 commit comments

Comments
 (0)