Advertisement
Guest User

Untitled

a guest
May 3rd, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class ABetterBarracks_Effect_Repeater_Critdamage_Override extends X2Effect_Persistent;
  2.  
  3. var int BonusCritDmg;
  4.  
  5. function int GetAttackingDamageModifier(XComGameState_Effect EffectState, XComGameState_Unit Attacker, Damageable TargetDamageable, XComGameState_Ability AbilityState, const out EffectAppliedData AppliedData, const int CurrentDamage, optional XComGameState NewGameState)
  6. {
  7.     local X2WeaponTemplate WeaponTemplate;
  8.     local X2AbilityToHitCalc_StandardAim StandardHit;
  9.     local X2Effect_ApplyWeaponDamage WeaponDamageEffect;
  10.     local XComGameState_Item WeaponState;
  11.     local XComGameStateHistory    History;
  12.     local array<X2WeaponUpgradeTemplate> InstalledUpgradeTemplateNames;
  13.     local int i;
  14.    
  15.     History = `XCOMHISTORY;
  16.     WeaponState = XComGameState_Item(History.GetGameStateForObjectID(AbilityState.GetSourceWeapon().ObjectID));
  17.  
  18.     if (class'XComGameStateContext_Ability'.static.IsHitResultHit(AppliedData.AbilityResultContext.HitResult))
  19.     {
  20.         WeaponDamageEffect = X2Effect_ApplyWeaponDamage(class'X2Effect'.static.GetX2Effect(AppliedData.EffectRef));
  21.         if (WeaponDamageEffect != none)
  22.         {          
  23.             if (WeaponDamageEffect.bIgnoreBaseDamage)
  24.             {  
  25.                 return 0;      
  26.             }
  27.         }
  28.         WeaponState = XComGameState_Item(History.GetGameStateForObjectID(AbilityState.GetSourceWeapon().ObjectID));
  29.         if (WeaponState == none)
  30.         {
  31.             return 0;
  32.         }
  33.         else
  34.         {        
  35.             //    Grab Templates for all Upgrades on the weapon
  36.             InstalledUpgradeTemplateNames = WeaponState.GetMyWeaponUpgradeTemplates();
  37.             //    cycle through all of them
  38.             for (i=0; i < InstalledUpgradeTemplateNames.Length; i++)
  39.             {
  40.                 //    check if the Upgrade is the Repeater
  41.                 if (InstalledUpgradeTemplateNames[i].DataName == 'FreeKillUpgrade_Bsc' || InstalledUpgradeTemplateNames[i].DataName == 'FreeKillUpgrade_Adv' || InstalledUpgradeTemplateNames[i].DataName == 'FreeKillUpgrade_Sup')
  42.                 {
  43.                     //    exit the cycle
  44.                     break;
  45.                 }
  46.             }
  47.             //    after the cycle finishes working, check if it cycled through all templates
  48.             if (i == InstalledUpgradeTemplateNames.Length)
  49.             {
  50.                 //    if it did, means the source weapon for the firing ability
  51.                 //    isn't the one the Repeater is attached to.
  52.                 return 0;
  53.             }
  54.  
  55.         }
  56.         StandardHit = X2AbilityToHitCalc_StandardAim(AbilityState.GetMyTemplate().AbilityToHitCalc);
  57.         if(StandardHit != none && StandardHit.bIndirectFire)
  58.         {
  59.             return 0;
  60.         }      
  61.         if(AbilityState.SourceWeapon == EffectState.ApplyEffectParameters.ItemStateObjectRef)
  62.         {
  63.             if (AppliedData.AbilityResultContext.HitResult == eHit_Crit)
  64.             {
  65.                 return BonusCritDmg;
  66.             }          
  67.         }
  68.     }
  69.     return 0;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement