-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow overriding weapon base damage for purposes of flyovers #1275
Allow overriding weapon base damage for purposes of flyovers #1275
Conversation
I think the displayed damage type on the flyover for applied damage should match the damage type actually applied to the target. The trick is that an ability can apply damage of several types at the same time, which are gathered from different sources in X2Effect_ApplyWeaponDamage. The This functions a bit differently for X2Effect_ApplyWeaponDamage. Normally it has the I assume the rule of "effect won't be applied if the target is immune to a damage type listed in For example, let's take an X2Effect_ApplyWeaponDamage that is set up to apply weapon damage, attached to a sword, and also its own And even if the target is immune to both, the effect will still be applied, the target just won't take any damage. Unless, of course, either of these damage types is manually added to effect's DamageTypes array. To summarize, an X2Effect_AWD can potentially apply damage of multiple types, and has its own logic for gathering the damage types. Then the question is: which of the damage types should be displayed in flyover? Well let's think about what the flyover can actually display, which is either generic damage or psionic damage. So I think the task boils down to checking whether the effect is applying psionic damage or not. If yes, then display the psionic flyover. If not, then we don't care what other damage types are, the flyover will be the same either way. All that said, to determine whether the effect applies psionic damage or not, we have to repeat the effect's process of gathering the damage type either way. One huge huge caveat is that a custom X2Effect_ApplyWeaponDamage can have completely arbitrary logic for gathering applied damage types, so we can't reliably make a universal solution by copying vanilla logic from X2Effect_AWD. What we can do is check what damage types have actually been applied to the unit. Visualization happens after the effect has already been applied by state code, so we can examine the struct native DamageResult
{
var int DamageAmount, MitigationAmount, ShieldHP, Shred;
var bool bImmuneToAllDamage; // if ALL of the damage being dealt was 0'd out due to immunity, it will be tracked here
var bool bFreeKill; // free kill weapon upgrade forced death of the unit
var name FreeKillAbilityName;
var EffectAppliedData SourceEffect;
var XComGameStateContext Context;
var array<DamageModifierInfo> SpecialDamageFactors;
var array<name> DamageTypes;
}; Of particular interest are Therefore, the task is:
I think this is the optimal solution that covers all bases, but discussion is welcome. |
Seems reasonable to me - I'll try to tackle this over the next few days :) |
09ecbdf
to
d42c4b4
Compare
Hey, so I've been looking into this a bit - basically, X2Action_ApplyWeaponDamageToUnit already does something pretty similar to what you're suggesting here - see below:
Basically, the bit inside the 'else/if' which runs for damage types which either tick, or come from the world, does almost exactly what you're suggesting - checks that for each instance of damage on the unit, if it matches the context of the thing activating it, get the originating X2Effect, takes the first element of the damagetypes array associated with that effect and assigns the damagetypename (which decides what type of flyover is used) based on that. The difficulty is that if we re-arrange it to adjust the behaviour such that it gets the damage type from the X2Effect and use that preferentially for the flyover, then abilities like rend (where the damage type on the effect is 'melee' but the damage type on the weapon is 'psi') will display incorrectly. So really, there probably needs to be some kind of flag within X2Effect its-self saying 'ignore base weapon damage for flyovers' - then when grabbing the X2Effects associated with the damage, if that flag isn't set, we skip assigning the damagetypename there and let it fall back to the weapon template instead. Does that make any sense? |
d42c4b4
to
ada510d
Compare
Fixes #1274