Skip to content

Commit 7d4a3d0

Browse files
committed
AE duration affected by firepower multipliers
1 parent 7bc8752 commit 7d4a3d0

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

docs/New-or-Enhanced-Logics.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This page describes all the engine features that are either new and introduced b
77
### Attached Effects
88

99
- Similar (but not identical) to [Ares' AttachEffect](https://ares-developers.github.io/Ares-docs/new/attacheffect.html), but with some differences and new features. The largest difference is that here attached effects are explicitly defined types.
10-
- `Duration` determines how long the effect lasts for. It can be overriden by `DurationOverrides` on TechnoTypes and Warheads.
10+
- `Duration` determines how long the effect lasts for. It can be overriden by `DurationOverrides` on TechnoTypes and Warheads. If `Duration.ApplyFirepowerMult` set to true, the duration will multiply the invoker's firepower multipliers.
1111
- `Cumulative`, if set to true, allows the same type of effect to be applied on same object multiple times, up to `Cumulative.MaxCount` number or with no limit if `Cumulative.MaxCount` is a negative number. If the target already has `Cumulative.MaxCount` number of the same effect applied on it, trying to attach another will refresh duration of the attached instance with shortest remaining duration.
1212
- `Powered` controls whether or not the effect is rendered inactive if the object it is attached to is deactivated (`PoweredUnit` or affected by EMP) or on low power. What happens to animation is controlled by `Animation.OfflineAction`.
1313
- `DiscardOn` accepts a list of values corresponding to conditions where the attached effect should be discarded. Defaults to `none`, meaning it is never discarded.
@@ -82,6 +82,7 @@ In `rulesmd.ini`:
8282

8383
[SOMEATTACHEFFECT] ; AttachEffectType
8484
Duration=0 ; integer - game frames or negative value for indefinite duration
85+
Duration.ApplyFirepowerMult=false ; boolean
8586
Cumulative=false ; boolean
8687
Cumulative.MaxCount=-1 ; integer
8788
Powered=false ; boolean

src/New/Entity/AttachEffectClass.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ AttachEffectClass::AttachEffectClass(AttachEffectTypeClass* pType, TechnoClass*
4444
if (this->InitialDelay <= 0)
4545
this->HasInitialized = true;
4646

47-
Duration = this->DurationOverride != 0 ? this->DurationOverride : this->Type->Duration;
47+
this->Duration = this->DurationOverride != 0 ? this->DurationOverride : this->Type->Duration;
48+
49+
if (this->Type->Duration_ApplyFirepowerMult && pInvoker)
50+
this->Duration = static_cast<int>(this->Duration * pInvoker->FirepowerMultiplier * TechnoExt::ExtMap.Find(pInvoker)->AE.FirepowerMultiplier);
4851

4952
AttachEffectClass::Array.emplace_back(this);
5053
}
@@ -382,6 +385,9 @@ void AttachEffectClass::RefreshDuration(int durationOverride)
382385
else
383386
this->Duration = this->DurationOverride ? this->DurationOverride : this->Type->Duration;
384387

388+
if (this->Type->Duration_ApplyFirepowerMult && this->Invoker)
389+
this->Duration = static_cast<int>(this->Duration * this->Invoker->FirepowerMultiplier * TechnoExt::ExtMap.Find(this->Invoker)->AE.FirepowerMultiplier);
390+
385391
if (this->Type->Animation_ResetOnReapply)
386392
{
387393
this->KillAnim();

src/New/Type/AttachEffectTypeClass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ void AttachEffectTypeClass::LoadFromINI(CCINIClass* pINI)
9696
INI_EX exINI(pINI);
9797

9898
this->Duration.Read(exINI, pSection, "Duration");
99+
this->Duration_ApplyFirepowerMult.Read(exINI, pSection, "Duration.ApplyFirepowerMult");
99100
this->Cumulative.Read(exINI, pSection, "Cumulative");
100101
this->Cumulative_MaxCount.Read(exINI, pSection, "Cumulative.MaxCount");
101102
this->Powered.Read(exINI, pSection, "Powered");
@@ -166,6 +167,7 @@ void AttachEffectTypeClass::Serialize(T& Stm)
166167
{
167168
Stm
168169
.Process(this->Duration)
170+
.Process(this->Duration_ApplyFirepowerMult)
169171
.Process(this->Cumulative)
170172
.Process(this->Cumulative_MaxCount)
171173
.Process(this->Powered)

src/New/Type/AttachEffectTypeClass.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class AttachEffectTypeClass final : public Enumerable<AttachEffectTypeClass>
4141

4242
public:
4343
Valueable<int> Duration;
44+
Valueable<bool> Duration_ApplyFirepowerMult;
4445
Valueable<bool> Cumulative;
4546
Valueable<int> Cumulative_MaxCount;
4647
Valueable<bool> Powered;
@@ -95,6 +96,7 @@ class AttachEffectTypeClass final : public Enumerable<AttachEffectTypeClass>
9596

9697
AttachEffectTypeClass(const char* const pTitle) : Enumerable<AttachEffectTypeClass>(pTitle)
9798
, Duration { 0 }
99+
, Duration_ApplyFirepowerMult { false }
98100
, Cumulative { false }
99101
, Cumulative_MaxCount { -1 }
100102
, Powered { false }

0 commit comments

Comments
 (0)