Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ABetterBarracks_Effect_Repeater_Critdamage_Override extends X2Effect_Persistent;
- var int BonusCritDmg;
- function int GetAttackingDamageModifier(XComGameState_Effect EffectState, XComGameState_Unit Attacker, Damageable TargetDamageable, XComGameState_Ability AbilityState, const out EffectAppliedData AppliedData, const int CurrentDamage, optional XComGameState NewGameState)
- {
- local X2WeaponTemplate WeaponTemplate;
- local X2AbilityToHitCalc_StandardAim StandardHit;
- local X2Effect_ApplyWeaponDamage WeaponDamageEffect;
- local XComGameState_Item WeaponState;
- local XComGameStateHistory History;
- local array<X2WeaponUpgradeTemplate> InstalledUpgradeTemplateNames;
- local int i;
- History = `XCOMHISTORY;
- WeaponState = XComGameState_Item(History.GetGameStateForObjectID(AbilityState.GetSourceWeapon().ObjectID));
- if (class'XComGameStateContext_Ability'.static.IsHitResultHit(AppliedData.AbilityResultContext.HitResult))
- {
- WeaponDamageEffect = X2Effect_ApplyWeaponDamage(class'X2Effect'.static.GetX2Effect(AppliedData.EffectRef));
- if (WeaponDamageEffect != none)
- {
- if (WeaponDamageEffect.bIgnoreBaseDamage)
- {
- return 0;
- }
- }
- WeaponState = XComGameState_Item(History.GetGameStateForObjectID(AbilityState.GetSourceWeapon().ObjectID));
- if (WeaponState == none)
- {
- return 0;
- }
- else
- {
- // Grab Templates for all Upgrades on the weapon
- InstalledUpgradeTemplateNames = WeaponState.GetMyWeaponUpgradeTemplates();
- // cycle through all of them
- for (i=0; i < InstalledUpgradeTemplateNames.Length; i++)
- {
- // check if the Upgrade is the Repeater
- if (InstalledUpgradeTemplateNames[i].DataName == 'FreeKillUpgrade_Bsc' || InstalledUpgradeTemplateNames[i].DataName == 'FreeKillUpgrade_Adv' || InstalledUpgradeTemplateNames[i].DataName == 'FreeKillUpgrade_Sup')
- {
- // exit the cycle
- break;
- }
- }
- // after the cycle finishes working, check if it cycled through all templates
- if (i == InstalledUpgradeTemplateNames.Length)
- {
- // if it did, means the source weapon for the firing ability
- // isn't the one the Repeater is attached to.
- return 0;
- }
- }
- StandardHit = X2AbilityToHitCalc_StandardAim(AbilityState.GetMyTemplate().AbilityToHitCalc);
- if(StandardHit != none && StandardHit.bIndirectFire)
- {
- return 0;
- }
- if(AbilityState.SourceWeapon == EffectState.ApplyEffectParameters.ItemStateObjectRef)
- {
- if (AppliedData.AbilityResultContext.HitResult == eHit_Crit)
- {
- return BonusCritDmg;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement