X2CommunityCore / X2CommunityHighlander

MIT License
7 stars 3 forks source link

Environmental explosions ignore all effects #200

Open bountygiver opened 7 years ago

bountygiver commented 7 years ago

Environmental explosions currently just damage the affected unit for a set amount, ignoring all effects except armor and shields. This is due to damage reductions/immunities are only checked in X2Effect_ApplyWeaponDamage but not in XCOmGameState_Unit.TakeDamage, causing units with fortress to still take damage from exploding cars/gas canisters.

Fix: Instead of calling TakeDamage() directly, apply a X2Effect_ApplyWeaponDamage effect instead, dynamically generate an x2effect right before dealing damage should be OK as without references from template managers it should be garbage collected, otherwise extend the effect with a new effect that takes in the destructible source. The code is in Explode() function of XComGameState_DestructionSphere

code to apply effects without triggering ability can be found in EverVigilantTurnEndListener in XComGameState_Ability

bountygiver commented 7 years ago

OK I had the idea of using game state override of making this a separate mod, end up scraping it because of privatewrite variables, so basically this can only be done in highlander

robojumper commented 7 years ago

Are you sure the source is XComGameState_DestructionSphere? The unit damage should be triggered by XComDestructibleActor_Action_RadialDamage, which is native code unfortunately.

XComGameState_DestructionSphere seems like a leftover thing where units could trigger explosions by using an ability (see X2TargetingMethod_ExplosiveDeviceDetonate, 'ExplosiveDeviceDetonate').

A simple Script Trace should clear that up.

bountygiver commented 7 years ago

the thing is XComDestructibleActor_Action_RadialDamage is not really called by anything really, there's just a visualization code and 2 more places which called it is silence destruction which also sets the damage to 0. While XComGameState_DestructionSphere does have proper activation code from XComDestructionSphere which is a proper placable (which means it can be added by maps not just scripts), and it is also still actively used by explodeit cheat code

bountygiver commented 7 years ago

I will run a test with my scrapped mod project to trace which one is the actual one called