Skip to content

Commit 856cebd

Browse files
authored
Merge pull request #1548 from furudee/1547-boomboom
Use env dmg of weapon when hitting tilefrac actors and add event
2 parents f4da22d + 48cd2a9 commit 856cebd

1 file changed

Lines changed: 71 additions & 3 deletions

File tree

X2WOTCCommunityHighlander/Src/XComGame/Classes/X2Ability.uc

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,11 @@ static function GenerateDamageEvents(XComGameState NewGameState, XComGameStateCo
147147
local int PhysicalImpulseAmount;
148148
local name DamageTypeTemplateName;
149149
local PrimitiveComponent HitComponent;
150-
150+
151+
// Variables for Issue #1547
152+
local XComGameState_Item SourceAmmoStateObject, LoadedAmmoStateObject;
153+
local int DamageAmount;
154+
151155
//If this damage effect has an associated position, it does world damage
152156
if(AbilityContext.ResultContext.ProjectileHitLocations.Length > 0)
153157
{
@@ -176,6 +180,32 @@ static function GenerateDamageEvents(XComGameState NewGameState, XComGameStateCo
176180
DamageTypeTemplateName = 'Explosion';
177181
}
178182

183+
/// HL-Docs: ref:Bugfixes; issue:1547
184+
/// Use the environment damage value of the weapon with projectile events instead of a flat value, that resulted in low damage weapons destroying walls
185+
// Start Issue #1547
186+
if (SourceItemStateObject != none)
187+
{
188+
SourceAmmoStateObject = AbilityStateObject.GetSourceAmmo();
189+
190+
if (SourceAmmoStateObject != none)
191+
{
192+
DamageAmount += SourceAmmoStateObject.GetItemEnvironmentDamage();
193+
}
194+
else if (SourceItemStateObject.HasLoadedAmmo())
195+
{
196+
LoadedAmmoStateObject = XComGameState_Item(History.GetGameStateForObjectID(SourceItemStateObject.LoadedAmmo.ObjectID));
197+
if (LoadedAmmoStateObject != None)
198+
{
199+
DamageAmount += LoadedAmmoStateObject.GetItemEnvironmentDamage();
200+
}
201+
}
202+
203+
DamageAmount += SourceItemStateObject.GetItemEnvironmentDamage();
204+
}
205+
206+
TriggerModifyProjectileEnvironmentDamageEvent(DamageAmount, NewGameState, AbilityStateObject);
207+
// End Issue #1547
208+
179209
//The touch list includes a start and end point. Do not apply travelling damage to these points
180210
for(Index = 1; Index < AbilityContext.InputContext.ProjectileEvents.Length; ++Index)
181211
{
@@ -193,10 +223,9 @@ static function GenerateDamageEvents(XComGameState NewGameState, XComGameStateCo
193223
DamageEvent.bRadialDamage = AbilityRadius > 0;
194224

195225
HitComponent = AbilityContext.InputContext.ProjectileEvents[Index].TraceInfo.HitComponent;
196-
197226
if (HitComponent != none && XComTileFracLevelActor(HitComponent.Owner) != none )
198227
{
199-
DamageEvent.DamageAmount = 20;
228+
DamageEvent.DamageAmount = DamageAmount; // Issue #1547 - originally 20
200229
DamageEvent.bAffectFragileOnly = false;
201230
DamageEvent.DamageDirection = AbilityContext.InputContext.ProjectileTouchEnd - AbilityContext.InputContext.ProjectileTouchStart;
202231
}
@@ -223,6 +252,45 @@ static function GenerateDamageEvents(XComGameState NewGameState, XComGameStateCo
223252
}
224253
}
225254

255+
// Start Issue #1547
256+
/// HL-Docs: feature:ModifyProjectileEnvironmentDamage; issue:1547; tags:tactical
257+
/// This event allows to modify the environmental damage a projectile event will deal to `XComTileFracLevelActor` actors, which are walls/floors that will fracture in chunks
258+
///
259+
/// If `OverrideDamage` is true, damage will be overridden by `DamageAmount`, if `OverrideDamage` is false, then `DamageAmount` will be added to the damage
260+
///
261+
///```event
262+
///EventID: ModifyProjectileEnvironmentDamage,
263+
///EventData: [inout bool OverrideDamage, inout int DamageAmount, in XComGameState_Ability AbilityStateObject],
264+
///EventSource: none,
265+
///NewGameState: yes
266+
///```
267+
static private function TriggerModifyProjectileEnvironmentDamageEvent(out int DamageAmount, XComGameState NewGameState, XComGameState_Ability AbilityStateObject)
268+
{
269+
local XComLWTuple Tuple;
270+
271+
Tuple = new class'XComLWTuple';
272+
Tuple.Id = 'ModifyProjectileEnvironmentDamage';
273+
Tuple.Data.Add(3);
274+
Tuple.Data[0].kind = XComLWTVBool;
275+
Tuple.Data[0].b = false; // override? (true) or add? (false)
276+
Tuple.Data[1].kind = XComLWTVInt;
277+
Tuple.Data[1].i = 0; // override/bonus environment damage
278+
Tuple.Data[2].kind = XComLWTVObject;
279+
Tuple.Data[2].o = AbilityStateObject; // ability being used
280+
281+
`XEVENTMGR.TriggerEvent('ModifyProjectileEnvironmentDamage', Tuple, none, NewGameState);
282+
283+
if(Tuple.Data[0].b)
284+
{
285+
DamageAmount = Tuple.Data[1].i;
286+
}
287+
else
288+
{
289+
DamageAmount += Tuple.Data[1].i;
290+
}
291+
}
292+
// End Issue #1547
293+
226294
//Used by charging melee attacks to perform a move and an attack.
227295
static function XComGameState TypicalMoveEndAbility_BuildGameState(XComGameStateContext Context)
228296
{

0 commit comments

Comments
 (0)