Skip to content

Commit 084fcb6

Browse files
committed
omit negative duration for ApplyFirepowerMult
add ApplyArmorMultOnTarget
1 parent 7d4a3d0 commit 084fcb6

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

docs/New-or-Enhanced-Logics.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ 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. If `Duration.ApplyFirepowerMult` set to true, the duration will multiply the invoker's firepower multipliers.
10+
- `Duration` determines how long the effect lasts for. It can be overriden by `DurationOverrides` on TechnoTypes and Warheads.
11+
- If `Duration.ApplyFirepowerMult` set to true, the duration will multiply the invoker's firepower multipliers if it's not negative. Can't reduce duration to below 0 by a negative firepower multiplier.
12+
- If `Duration.ApplyArmorMultOnTarget` set to true, the duration will divide the target's armor multipliers if it's not negative. This'll also include `ArmorMultiplier` from its own and ignore `ArmorMultiplier.Allow/DisallowWarheads`. Can't reduce duration to below 0 by a negative armor multiplier.
1113
- `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.
1214
- `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`.
1315
- `DiscardOn` accepts a list of values corresponding to conditions where the attached effect should be discarded. Defaults to `none`, meaning it is never discarded.
@@ -83,6 +85,7 @@ In `rulesmd.ini`:
8385
[SOMEATTACHEFFECT] ; AttachEffectType
8486
Duration=0 ; integer - game frames or negative value for indefinite duration
8587
Duration.ApplyFirepowerMult=false ; boolean
88+
Duration.ApplyArmorMultOnTarget=false ; boolean
8689
Cumulative=false ; boolean
8790
Cumulative.MaxCount=-1 ; integer
8891
Powered=false ; boolean

src/New/Entity/AttachEffectClass.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@ AttachEffectClass::AttachEffectClass(AttachEffectTypeClass* pType, TechnoClass*
4646

4747
this->Duration = this->DurationOverride != 0 ? this->DurationOverride : this->Type->Duration;
4848

49-
if (this->Type->Duration_ApplyFirepowerMult && pInvoker)
50-
this->Duration = static_cast<int>(this->Duration * pInvoker->FirepowerMultiplier * TechnoExt::ExtMap.Find(pInvoker)->AE.FirepowerMultiplier);
49+
if (this->Type->Duration_ApplyFirepowerMult && this->Duration > 0 && pInvoker)
50+
this->Duration = Math::max(static_cast<int>(this->Duration * pInvoker->FirepowerMultiplier * TechnoExt::ExtMap.Find(pInvoker)->AE.FirepowerMultiplier), 0);
51+
52+
if (this->Type->Duration_ApplyArmorMultOnTarget && this->Duration > 0) // count its own ArmorMultiplier as well
53+
this->Duration = Math::max(static_cast<int>(this->Duration / pTechno->ArmorMultiplier / TechnoExt::ExtMap.Find(pTechno)->AE.ArmorMultiplier / this->Type->ArmorMultiplier), 0);
5154

5255
AttachEffectClass::Array.emplace_back(this);
5356
}
@@ -385,8 +388,11 @@ void AttachEffectClass::RefreshDuration(int durationOverride)
385388
else
386389
this->Duration = this->DurationOverride ? this->DurationOverride : this->Type->Duration;
387390

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);
391+
if (this->Type->Duration_ApplyFirepowerMult && this->Duration > 0 && this->Invoker)
392+
this->Duration = Math::max(static_cast<int>(this->Duration * this->Invoker->FirepowerMultiplier * TechnoExt::ExtMap.Find(this->Invoker)->AE.FirepowerMultiplier), 0);
393+
394+
if (this->Type->Duration_ApplyArmorMultOnTarget && this->Duration > 0) // no need to count its own effect again
395+
this->Duration = Math::max(static_cast<int>(this->Duration / this->Techno->ArmorMultiplier / TechnoExt::ExtMap.Find(this->Techno)->AE.ArmorMultiplier), 0);
390396

391397
if (this->Type->Animation_ResetOnReapply)
392398
{

src/New/Type/AttachEffectTypeClass.cpp

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

9898
this->Duration.Read(exINI, pSection, "Duration");
9999
this->Duration_ApplyFirepowerMult.Read(exINI, pSection, "Duration.ApplyFirepowerMult");
100+
this->Duration_ApplyArmorMultOnTarget.Read(exINI, pSection, "Duration.ApplyArmorMultOnTarget");
100101
this->Cumulative.Read(exINI, pSection, "Cumulative");
101102
this->Cumulative_MaxCount.Read(exINI, pSection, "Cumulative.MaxCount");
102103
this->Powered.Read(exINI, pSection, "Powered");
@@ -168,6 +169,7 @@ void AttachEffectTypeClass::Serialize(T& Stm)
168169
Stm
169170
.Process(this->Duration)
170171
.Process(this->Duration_ApplyFirepowerMult)
172+
.Process(this->Duration_ApplyArmorMultOnTarget)
171173
.Process(this->Cumulative)
172174
.Process(this->Cumulative_MaxCount)
173175
.Process(this->Powered)

src/New/Type/AttachEffectTypeClass.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class AttachEffectTypeClass final : public Enumerable<AttachEffectTypeClass>
4242
public:
4343
Valueable<int> Duration;
4444
Valueable<bool> Duration_ApplyFirepowerMult;
45+
Valueable<bool> Duration_ApplyArmorMultOnTarget;
4546
Valueable<bool> Cumulative;
4647
Valueable<int> Cumulative_MaxCount;
4748
Valueable<bool> Powered;
@@ -97,6 +98,7 @@ class AttachEffectTypeClass final : public Enumerable<AttachEffectTypeClass>
9798
AttachEffectTypeClass(const char* const pTitle) : Enumerable<AttachEffectTypeClass>(pTitle)
9899
, Duration { 0 }
99100
, Duration_ApplyFirepowerMult { false }
101+
, Duration_ApplyArmorMultOnTarget { false }
100102
, Cumulative { false }
101103
, Cumulative_MaxCount { -1 }
102104
, Powered { false }

0 commit comments

Comments
 (0)