Skip to content

Commit 7355c24

Browse files
committed
RealLaunch
1 parent 8552728 commit 7355c24

File tree

8 files changed

+74
-4
lines changed

8 files changed

+74
-4
lines changed

docs/New-or-Enhanced-Logics.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ This page describes all the engine features that are either new and introduced b
5757
- `Crit.AllowWarheads` can be used to list only Warheads that can benefit from this critical hit chance multiplier and `Crit.DisallowWarheads` weapons that are not allowed to, respectively.
5858
- `RevengeWeapon` can be used to temporarily grant the specified weapon as a [revenge weapon](#revenge-weapon) for the attached object.
5959
- `RevengeWeapon.AffectsHouses` customizes which houses can trigger the revenge weapon.
60+
- If `RevengeWeapon.RealLaunch` set to true, the weapon will be fired through a real projectile from the TechnoType to the killer.
6061
- `ReflectDamage` can be set to true to have any positive damage dealt to the object the effect is attached to be reflected back to the attacker. `ReflectDamage.Warhead` determines which Warhead is used to deal the damage, defaults to `[CombatDamage] -> C4Warhead`. If `ReflectDamage.Warhead.Detonate` is set to true, the Warhead is fully detonated instead of used to simply deal damage. `ReflectDamage.Chance` determines the chance of reflection. `ReflectDamage.Multiplier` is a multiplier to the damage received and then reflected back, while `ReflectDamage.Override` directly overrides the damage. Already reflected damage cannot be further reflected back.
6162
- Warheads can prevent reflect damage from occuring by setting `SuppressReflectDamage` to true. `SuppressReflectDamage.Types` can control which AttachEffectTypes' reflect damage is suppressed, if none are listed then all of them are suppressed. `SuppressReflectDamage.Groups` does the same thing but for all AttachEffectTypes in the listed groups.
6263
- `DisableWeapons` can be used to disable ability to fire any and all weapons.
@@ -146,6 +147,7 @@ Crit.AllowWarheads= ; List of WarheadTypes
146147
Crit.DisallowWarheads= ; List of WarheadTypes
147148
RevengeWeapon= ; WeaponType
148149
RevengeWeapon.AffectsHouses=all ; List of Affected House Enumeration (none|owner/self|allies/ally|team|enemies/enemy|all)
150+
RevengeWeapon.RealLaunch=false ; boolean
149151
ReflectDamage=false ; boolean
150152
ReflectDamage.Warhead= ; WarheadType
151153
ReflectDamage.Warhead.Detonate=false ; WarheadType
@@ -1681,6 +1683,7 @@ RecountBurst= ; boolean
16811683

16821684
- Similar to `DeathWeapon` in that it is fired after a TechnoType is killed, but with the difference that it will be fired on whoever dealt the damage that killed the TechnoType. If TechnoType died of sources other than direct damage dealt by another TechnoType, `RevengeWeapon` will not be fired.
16831685
- `RevengeWeapon.AffectsHouses` can be used to filter which houses the damage that killed the TechnoType is allowed to come from to fire the weapon.
1686+
- If `RevengeWeapon.RealLaunch` set to true, the weapon will be fired through a real projectile from the TechnoType to the killer.
16841687
- It is possible to grant revenge weapons through [attached effects](#attached-effects) as well.
16851688
- If a Warhead has `SuppressRevengeWeapons` set to true, it will not trigger revenge weapons. `SuppressRevengeWeapons.Types` can be used to list WeaponTypes affected by this, if none are listed all WeaponTypes are affected.
16861689

@@ -1689,6 +1692,7 @@ In `rulesmd.ini`:
16891692
[SOMETECHNO] ; TechnoType
16901693
RevengeWeapon= ; WeaponType
16911694
RevengeWeapon.AffectsHouses=all ; List of Affected House Enumeration (none|owner/self|allies/ally|team|enemies/enemy|all)
1695+
RevengeWeapon.RealLaunch=false ; boolean
16921696

16931697
[SOMEWARHEAD] ; WarheadType
16941698
SuppressRevengeWeapons=false ; boolean
@@ -2022,7 +2026,7 @@ While this feature can provide better performance than a large `CellSpread` valu
20222026
### Fire weapon when Warhead kills something
20232027

20242028
- `KillWeapon` will be fired at the target TechnoType's location once it's killed by this Warhead.
2025-
- `KillWeapon.OnFirer` will be fired at the attacker's location once the target TechnoType is killed by this Warhead. If the source of this Warhead is not another TechnoType, `KillWeapon.OnFirer` will not be fired.
2029+
- `KillWeapon.OnFirer` will be fired at the attacker's location once the target TechnoType is killed by this Warhead. If the source of this Warhead is not another TechnoType, `KillWeapon.OnFirer` will not be fired. If `KillWeapon.OnFirer.RealLaunch` set to true, the weapon will be fired through a real projectile from the TechnoType to the killer.
20262030
- `KillWeapon.AffectsHouses` / `KillWeapon.OnFirer.AffectsHouses` and `KillWeapon.Affects` / `KillWeapon.OnFirer.Affects` can be used to filter which houses targets can belong to and which types of targets are be considered valid for `KillWeapon` and `KillWeapon.OnFirer` respectively.
20272031
- If the source of this Warhead is not another TechnoType, `KillWeapon` will be fired regardless of the target's house or type.
20282032
- If a TechnoType has `SuppressKillWeapons` set to true, it will not trigger `KillWeapon` or `KillWeapon.OnFirer` upon being killed. `SuppressKillWeapons.Types` can be used to list WeaponTypes affected by this, if none are listed all WeaponTypes are affected.
@@ -2036,6 +2040,7 @@ KillWeapon.AffectsHouses=all ; List of Affected House Enumeration (none
20362040
KillWeapon.OnFirer.AffectsHouses=all ; List of Affected House Enumeration (none|owner/self|allies/ally|team|enemies/enemy|all)
20372041
KillWeapon.Affects=all ; List of Affected Target Enumeration (none|aircraft|buildings|infantry|units|all)
20382042
KillWeapon.OnFirer.Affects=all ; List of Affected Target Enumeration (none|aircraft|buildings|infantry|units|all)
2043+
KillWeapon.OnFirer.RealLaunch=false ; boolean
20392044

20402045
[SOMETECHNO] ; TechnoType
20412046
SuppressKillWeapons=false ; boolean

src/Ext/Techno/WeaponHelpers.cpp

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#include "Body.h"
22

33
#include <OverlayTypeClass.h>
4+
#include <BulletClass.h>
45

6+
#include <Ext/Bullet/Body.h>
57
#include <Ext/WeaponType/Body.h>
68
#include <Ext/WarheadType/Body.h>
79
#include <Utilities/EnumFunctions.h>
@@ -219,7 +221,24 @@ void TechnoExt::ApplyKillWeapon(TechnoClass* pThis, TechnoClass* pSource, Warhea
219221
&& EnumFunctions::IsTechnoEligible(pThis, pWHExt->KillWeapon_OnFirer_Affects))
220222
{
221223
if (!pTypeExt->SuppressKillWeapons || (hasFilters && !pTypeExt->SuppressKillWeapons_Types.Contains(pWHExt->KillWeapon_OnFirer)))
222-
WeaponTypeExt::DetonateAt(pWHExt->KillWeapon_OnFirer, pSource, pSource);
224+
{
225+
if (pWHExt->KillWeapon_OnFirer_RealLaunch)
226+
{
227+
auto const pWeapon = pWHExt->KillWeapon_OnFirer;
228+
229+
if (BulletClass* pBullet = pWeapon->Projectile->CreateBullet(pSource, pSource,
230+
pWeapon->Damage, pWeapon->Warhead, pWeapon->Speed, pWeapon->Bright))
231+
{
232+
pBullet->WeaponType = pWeapon;
233+
pBullet->MoveTo(pSource->Location, BulletVelocity::Empty);
234+
BulletExt::ExtMap.Find(pBullet)->FirerHouse = pSource->Owner;
235+
}
236+
}
237+
else
238+
{
239+
WeaponTypeExt::DetonateAt(pWHExt->KillWeapon_OnFirer, pSource, pSource);
240+
}
241+
}
223242
}
224243
}
225244

@@ -233,7 +252,24 @@ void TechnoExt::ApplyRevengeWeapon(TechnoClass* pThis, TechnoClass* pSource, War
233252
if (pTypeExt->RevengeWeapon && EnumFunctions::CanTargetHouse(pTypeExt->RevengeWeapon_AffectsHouses, pThis->Owner, pSource->Owner))
234253
{
235254
if (!pWHExt->SuppressRevengeWeapons || (hasFilters && !pWHExt->SuppressRevengeWeapons_Types.Contains(pTypeExt->RevengeWeapon)))
236-
WeaponTypeExt::DetonateAt(pTypeExt->RevengeWeapon, pSource, pThis);
255+
{
256+
if (pTypeExt->RevengeWeapon_RealLaunch)
257+
{
258+
auto const pWeapon = pTypeExt->RevengeWeapon;
259+
260+
if (BulletClass* pBullet = pWeapon->Projectile->CreateBullet(pSource, pThis,
261+
pWeapon->Damage, pWeapon->Warhead, pWeapon->Speed, pWeapon->Bright))
262+
{
263+
pBullet->WeaponType = pWeapon;
264+
pBullet->MoveTo(pSource->Location, BulletVelocity::Empty);
265+
BulletExt::ExtMap.Find(pBullet)->FirerHouse = pThis->Owner;
266+
}
267+
}
268+
else
269+
{
270+
WeaponTypeExt::DetonateAt(pTypeExt->RevengeWeapon, pSource, pThis);
271+
}
272+
}
237273
}
238274

239275
for (auto& attachEffect : pExt->AttachedEffects)
@@ -250,7 +286,24 @@ void TechnoExt::ApplyRevengeWeapon(TechnoClass* pThis, TechnoClass* pSource, War
250286
continue;
251287

252288
if (EnumFunctions::CanTargetHouse(pType->RevengeWeapon_AffectsHouses, pThis->Owner, pSource->Owner))
253-
WeaponTypeExt::DetonateAt(pType->RevengeWeapon, pSource, pThis);
289+
{
290+
if (pType->RevengeWeapon_RealLaunch)
291+
{
292+
auto const pWeapon = pType->RevengeWeapon;
293+
294+
if (BulletClass* pBullet = pWeapon->Projectile->CreateBullet(pSource, pThis,
295+
pWeapon->Damage, pWeapon->Warhead, pWeapon->Speed, pWeapon->Bright))
296+
{
297+
pBullet->WeaponType = pWeapon;
298+
pBullet->MoveTo(pSource->Location, BulletVelocity::Empty);
299+
BulletExt::ExtMap.Find(pBullet)->FirerHouse = pThis->Owner;
300+
}
301+
}
302+
else
303+
{
304+
WeaponTypeExt::DetonateAt(pType->RevengeWeapon, pSource, pThis);
305+
}
306+
}
254307
}
255308
}
256309

src/Ext/TechnoType/Body.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
469469

470470
this->RevengeWeapon.Read<true>(exINI, pSection, "RevengeWeapon");
471471
this->RevengeWeapon_AffectsHouses.Read(exINI, pSection, "RevengeWeapon.AffectsHouses");
472+
this->RevengeWeapon_RealLaunch.Read(exINI, pSection, "RevengeWeapon.RealLaunch");
472473

473474
this->RecountBurst.Read(exINI, pSection, "RecountBurst");
474475

@@ -934,6 +935,7 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
934935

935936
.Process(this->RevengeWeapon)
936937
.Process(this->RevengeWeapon_AffectsHouses)
938+
.Process(this->RevengeWeapon_RealLaunch)
937939

938940
.Process(this->AttachEffects)
939941

src/Ext/TechnoType/Body.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ class TechnoTypeExt
242242

243243
Valueable<WeaponTypeClass*> RevengeWeapon;
244244
Valueable<AffectedHouse> RevengeWeapon_AffectsHouses;
245+
Valueable<bool> RevengeWeapon_RealLaunch;
245246

246247
AEAttachInfoTypeClass AttachEffects;
247248

@@ -559,6 +560,7 @@ class TechnoTypeExt
559560

560561
, RevengeWeapon {}
561562
, RevengeWeapon_AffectsHouses { AffectedHouse::All }
563+
, RevengeWeapon_RealLaunch { false }
562564

563565
, AttachEffects {}
564566

src/Ext/WarheadType/Body.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ void WarheadTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
290290
this->KillWeapon_OnFirer_AffectsHouses.Read(exINI, pSection, "KillWeapon.OnFirer.AffectsHouses");
291291
this->KillWeapon_Affects.Read(exINI, pSection, "KillWeapon.Affects");
292292
this->KillWeapon_OnFirer_Affects.Read(exINI, pSection, "KillWeapon.OnFirer.Affects");
293+
this->KillWeapon_OnFirer_RealLaunch.Read(exINI, pSection, "KillWeapon.OnFirer.RealLaunch");
293294

294295
this->ElectricAssaultLevel.Read(exINI, pSection, "ElectricAssaultLevel");
295296

@@ -543,6 +544,7 @@ void WarheadTypeExt::ExtData::Serialize(T& Stm)
543544
.Process(this->KillWeapon_OnFirer_AffectsHouses)
544545
.Process(this->KillWeapon_Affects)
545546
.Process(this->KillWeapon_OnFirer_Affects)
547+
.Process(this->KillWeapon_OnFirer_RealLaunch)
546548

547549
.Process(this->ElectricAssaultLevel)
548550

src/Ext/WarheadType/Body.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ class WarheadTypeExt
172172
Valueable<AffectedHouse> KillWeapon_OnFirer_AffectsHouses;
173173
Valueable<AffectedTarget> KillWeapon_Affects;
174174
Valueable<AffectedTarget> KillWeapon_OnFirer_Affects;
175+
Valueable<bool> KillWeapon_OnFirer_RealLaunch;
175176

176177
Valueable<int> ElectricAssaultLevel;
177178

@@ -376,6 +377,7 @@ class WarheadTypeExt
376377
, KillWeapon_OnFirer_AffectsHouses { AffectedHouse::All }
377378
, KillWeapon_Affects { AffectedTarget::All }
378379
, KillWeapon_OnFirer_Affects { AffectedTarget::All }
380+
, KillWeapon_OnFirer_RealLaunch { false }
379381
{ }
380382

381383
void ApplyConvert(HouseClass* pHouse, TechnoClass* pTarget);

src/New/Type/AttachEffectTypeClass.cpp

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

159159
this->RevengeWeapon.Read<true>(exINI, pSection, "RevengeWeapon");
160160
this->RevengeWeapon_AffectsHouses.Read(exINI, pSection, "RevengeWeapon.AffectsHouses");
161+
this->RevengeWeapon_RealLaunch.Read(exINI, pSection, "RevengeWeapon.RealLaunch");
161162

162163
this->ReflectDamage.Read(exINI, pSection, "ReflectDamage");
163164
this->ReflectDamage_Warhead.Read(exINI, pSection, "ReflectDamage.Warhead");
@@ -232,6 +233,7 @@ void AttachEffectTypeClass::Serialize(T& Stm)
232233
.Process(this->Crit_DisallowWarheads)
233234
.Process(this->RevengeWeapon)
234235
.Process(this->RevengeWeapon_AffectsHouses)
236+
.Process(this->RevengeWeapon_RealLaunch)
235237
.Process(this->ReflectDamage)
236238
.Process(this->ReflectDamage_Warhead)
237239
.Process(this->ReflectDamage_Warhead_Detonate)

src/New/Type/AttachEffectTypeClass.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class AttachEffectTypeClass final : public Enumerable<AttachEffectTypeClass>
9393
ValueableVector<WarheadTypeClass*> Crit_DisallowWarheads;
9494
Valueable<WeaponTypeClass*> RevengeWeapon;
9595
Valueable<AffectedHouse> RevengeWeapon_AffectsHouses;
96+
Valueable<bool> RevengeWeapon_RealLaunch;
9697
Valueable<bool> ReflectDamage;
9798
Nullable<WarheadTypeClass*> ReflectDamage_Warhead;
9899
Valueable<bool> ReflectDamage_Warhead_Detonate;
@@ -159,6 +160,7 @@ class AttachEffectTypeClass final : public Enumerable<AttachEffectTypeClass>
159160
, Crit_DisallowWarheads {}
160161
, RevengeWeapon {}
161162
, RevengeWeapon_AffectsHouses { AffectedHouse::All }
163+
, RevengeWeapon_RealLaunch { false }
162164
, ReflectDamage { false }
163165
, ReflectDamage_Warhead {}
164166
, ReflectDamage_Warhead_Detonate { false }

0 commit comments

Comments
 (0)