Skip to content

Commit 8552728

Browse files
committed
AE FeedbackWeapon
1 parent 14f124f commit 8552728

File tree

7 files changed

+34
-2
lines changed

7 files changed

+34
-2
lines changed

docs/New-or-Enhanced-Logics.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ This page describes all the engine features that are either new and introduced b
4141
- `ExtraWarheads.DetonationChances` can be used to customize the chance of each extra Warhead detonation occuring. Value from position matching the position from `ExtraWarheads` is used if found, or last listed value if not found. If list is empty, every extra Warhead detonation is guaranteed to occur.
4242
- `ExtraWarheads.FullDetonation` can be used to customize whether or not each individual Warhead is detonated fully (as part of a dummy weapon) or simply deals area damage and applies Phobos' Warhead effects. Value from position matching the position from `ExtraWarheads` is used if found, or last listed value if not found. If list is empty, defaults to true.
4343
- Note that the listed Warheads must be listed in `[Warheads]` for them to work.
44+
- `FeedbackWeapon` can specify an auxiliary weapon to be fired on the firer itself when a weapon is fired.
45+
- `FireInTransport` setting of the feedback weapon is respected to determine if it can be fired when the original weapon is fired from inside `OpenTopped=true` transport. If feedback weapon is fired, it is fired on the transport. `OpenToppedDamageMultiplier` is not applied on feedback weapons.
4446
- `Tint.Color` & `Tint.Intensity` can be used to set a color tint effect and additive lighting increase/decrease on the object the effect is attached to, respectively.
4547
- `Tint.VisibleToHouses` can be used to control which houses can see the tint effect.
4648
- `FirepowerMultiplier`, `ArmorMultiplier`, `SpeedMultiplier` and `ROFMultiplier` can be used to modify the object's firepower, armor strength, movement speed and weapon reload rate, respectively.
@@ -121,6 +123,7 @@ ExtraWarheads= ; List of WarheadTypes
121123
ExtraWarheads.DamageOverrides= ; List of integers
122124
ExtraWarheads.DetonationChances= ; List of floating-point values (percentage or absolute)
123125
ExtraWarheads.FullDetonation= ; List of booleans
126+
FeedbackWeapon= ; WeaponType
124127
Tint.Color= ; integer - R,G,B
125128
Tint.Intensity= ; floating point value
126129
Tint.VisibleToHouses=all ; List of Affected House Enumeration (none|owner/self|allies/ally|team|enemies/enemy|all)

src/Ext/Techno/Body.Update.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,6 +1171,7 @@ void TechnoExt::ExtData::RecalculateStatMultipliers()
11711171
bool hasRestrictedArmorMultipliers = false;
11721172
bool hasCritModifiers = false;
11731173
bool hasExtraWarheads = false;
1174+
bool hasFeedbackWeapon = false;
11741175

11751176
for (const auto& attachEffect : this->AttachedEffects)
11761177
{
@@ -1193,6 +1194,7 @@ void TechnoExt::ExtData::RecalculateStatMultipliers()
11931194
hasRestrictedArmorMultipliers |= (type->ArmorMultiplier != 1.0 && (type->ArmorMultiplier_AllowWarheads.size() > 0 || type->ArmorMultiplier_DisallowWarheads.size() > 0));
11941195
hasCritModifiers |= (type->Crit_Multiplier != 1.0 || type->Crit_ExtraChance != 0.0);
11951196
hasExtraWarheads |= type->ExtraWarheads.size() > 0;
1197+
hasFeedbackWeapon |= type->FeedbackWeapon != nullptr;
11961198
}
11971199

11981200
this->AE.FirepowerMultiplier = firepower;
@@ -1210,6 +1212,7 @@ void TechnoExt::ExtData::RecalculateStatMultipliers()
12101212
this->AE.HasRestrictedArmorMultipliers = hasRestrictedArmorMultipliers;
12111213
this->AE.HasCritModifiers = hasCritModifiers;
12121214
this->AE.HasExtraWarheads = hasExtraWarheads;
1215+
this->AE.HasFeedbackWeapon = hasFeedbackWeapon;
12131216

12141217
if (forceDecloak && pThis->CloakState == CloakState::Cloaked)
12151218
pThis->Uncloak(true);

src/Ext/Techno/Hooks.Firing.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,22 @@ DEFINE_HOOK(0x6FF43F, TechnoClass_FireAt_FeedbackWeapon, 0x6)
586586
}
587587
}
588588

589+
auto const pExt = TechnoExt::ExtMap.Find(pThis);
590+
591+
if (pExt->AE.HasFeedbackWeapon)
592+
{
593+
for (auto const& pAE : pExt->AttachedEffects)
594+
{
595+
if (auto const pWeaponFeedback = pAE->GetType()->FeedbackWeapon)
596+
{
597+
if (pThis->InOpenToppedTransport && !pWeaponFeedback->FireInTransport)
598+
return 0;
599+
600+
WeaponTypeExt::DetonateAt(pWeaponFeedback, pThis, pThis);
601+
}
602+
}
603+
}
604+
589605
return 0;
590606
}
591607

src/New/Entity/AttachEffectClass.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <AnimClass.h>
55
#include <BuildingClass.h>
6+
#include <MapClass.h>
67

78
#include <Ext/Anim/Body.h>
89
#include <Ext/Techno/Body.h>
@@ -57,7 +58,7 @@ AttachEffectClass::AttachEffectClass(AttachEffectTypeClass* pType, TechnoClass*
5758
pArmor = pShieldData->GetArmorType();
5859
}
5960

60-
this->Duration = Math::max(static_cast<int>(this->Duration * GeneralUtils::GetWarheadVersusArmor(this->Type->Duration_ApplyVersus_Warhead, pArmor)), 0);
61+
this->Duration = Math::max(MapClass::GetTotalDamage(this->Duration, this->Type->Duration_ApplyVersus_Warhead, pArmor, 0), 0);
6162
}
6263

6364
if (this->Type->Duration_ApplyFirepowerMult && this->Duration > 0 && pInvoker)
@@ -413,7 +414,7 @@ void AttachEffectClass::RefreshDuration(int durationOverride)
413414
pArmor = pShieldData->GetArmorType();
414415
}
415416

416-
this->Duration = Math::max(static_cast<int>(this->Duration * GeneralUtils::GetWarheadVersusArmor(this->Type->Duration_ApplyVersus_Warhead, pArmor)), 0);
417+
this->Duration = Math::max(MapClass::GetTotalDamage(this->Duration, this->Type->Duration_ApplyVersus_Warhead, pArmor, 0), 0);
417418
}
418419

419420
if (this->Type->Duration_ApplyFirepowerMult && this->Duration > 0 && this->Invoker)

src/New/Entity/AttachEffectClass.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ struct AttachEffectTechnoProperties
9898
bool HasRestrictedArmorMultipliers;
9999
bool HasCritModifiers;
100100
bool HasExtraWarheads;
101+
bool HasFeedbackWeapon;
101102

102103
AttachEffectTechnoProperties() :
103104
FirepowerMultiplier { 1.0 }
@@ -113,5 +114,8 @@ struct AttachEffectTechnoProperties
113114
, ReflectDamage { false }
114115
, HasOnFireDiscardables { false }
115116
, HasRestrictedArmorMultipliers { false }
117+
, HasCritModifiers { false }
118+
, HasExtraWarheads { false }
119+
, HasFeedbackWeapon { false }
116120
{ }
117121
};

src/New/Type/AttachEffectTypeClass.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ void AttachEffectTypeClass::LoadFromINI(CCINIClass* pINI)
129129
this->ExtraWarheads_DetonationChances.Read(exINI, pSection, "ExtraWarheads.DetonationChances");
130130
this->ExtraWarheads_FullDetonation.Read(exINI, pSection, "ExtraWarheads.FullDetonation");
131131

132+
this->FeedbackWeapon.Read<true>(exINI, pSection, "FeedbackWeapon");
133+
132134
this->Tint_Color.Read(exINI, pSection, "Tint.Color");
133135
this->Tint_Intensity.Read(exINI, pSection, "Tint.Intensity");
134136
this->Tint_VisibleToHouses.Read(exINI, pSection, "Tint.VisibleToHouses");
@@ -207,6 +209,7 @@ void AttachEffectTypeClass::Serialize(T& Stm)
207209
.Process(this->ExtraWarheads_DamageOverrides)
208210
.Process(this->ExtraWarheads_DetonationChances)
209211
.Process(this->ExtraWarheads_FullDetonation)
212+
.Process(this->FeedbackWeapon)
210213
.Process(this->Tint_Color)
211214
.Process(this->Tint_Intensity)
212215
.Process(this->Tint_VisibleToHouses)

src/New/Type/AttachEffectTypeClass.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class AttachEffectTypeClass final : public Enumerable<AttachEffectTypeClass>
7070
ValueableVector<int> ExtraWarheads_DamageOverrides;
7171
ValueableVector<double> ExtraWarheads_DetonationChances;
7272
ValueableVector<bool> ExtraWarheads_FullDetonation;
73+
Valueable<WeaponTypeClass*> FeedbackWeapon;
7374
Nullable<ColorStruct> Tint_Color;
7475
Valueable<double> Tint_Intensity;
7576
Valueable<AffectedHouse> Tint_VisibleToHouses;
@@ -135,6 +136,7 @@ class AttachEffectTypeClass final : public Enumerable<AttachEffectTypeClass>
135136
, ExtraWarheads_DamageOverrides {}
136137
, ExtraWarheads_DetonationChances {}
137138
, ExtraWarheads_FullDetonation {}
139+
, FeedbackWeapon {}
138140
, Tint_Color {}
139141
, Tint_Intensity { 0.0 }
140142
, Tint_VisibleToHouses { AffectedHouse::All }

0 commit comments

Comments
 (0)