Advertisement
DeleteMetaInf

X2Effect_TacticalReloadDamage.uc

Apr 15th, 2023
1,730
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class X2Effect_TacticalReloadDamage extends X2Effect_Persistent config (TacticalReloadNew2);
  2. var localized string FriendlyName;
  3.  
  4. var float fDamageMultiplier;
  5.  
  6. var config int BONUS_DAMAGE_DEFAULT;
  7. var config int BONUS_AIM_DEFAULT;
  8. var config int BONUS_CRIT_DEFAULT;
  9.  
  10. var config int BONUS_DAMAGE_CV;
  11. var config int BONUS_DAMAGE_MG;
  12. var config int BONUS_DAMAGE_BM;
  13.  
  14. var config int BONUS_AIM_CV;
  15. var config int BONUS_AIM_MG;
  16. var config int BONUS_AIM_BM;
  17.  
  18. var config int BONUS_CRIT_CV;
  19. var config int BONUS_CRIT_MG;
  20. var config int BONUS_CRIT_BM;
  21.  
  22. function int GetAttackingDamageModifier(XComGameState_Effect EffectState, XComGameState_Unit Attacker, Damageable TargetDamageable, XComGameState_Ability AbilityState, const out EffectAppliedData AppliedData, const int CurrentDamage, optional XComGameState NewGameState)
  23. {
  24.     local XComGameState_Item    ItemState;
  25.     //local X2AbilityTemplate   AbilityTemplate;
  26.     local XComGameState_Player  Player;
  27.    
  28.     ItemState = AbilityState.GetSourceWeapon();
  29.     //AbilityTemplate = AbilityState.GetMyTemplate();
  30.  
  31.     //  Check that Ability that activated GetAttackingDamageModifier comes from the same weapon as the ability that applied this effect.
  32.     if (ItemState != none && ItemState.ObjectID == AppliedData.ItemStateObjectRef.ObjectID)
  33.     {
  34.         //  If this effect is used not just for damage preview, but for actual damage calculation, then remove it, so that damage increase is applied only once.
  35.         if (NewGameState != none)
  36.         {
  37.             Player = XComGameState_Player(`XCOMHISTORY.GetGameStateForObjectID(EffectState.ApplyEffectParameters.PlayerStateObjectRef.ObjectID));
  38.             if (Player != none)
  39.             {
  40.                 `XEVENTMGR.TriggerEvent('TacticalReloadExpended', Player, Attacker, NewGameState);
  41.             }
  42.         }
  43.         return CurrentDamage * fDamageMultiplier;
  44.  
  45.         /*
  46.         if (ItemState != none && AbilityState.GetMyTemplateName() == 'TacticalReload') // Change to work with all weapons later
  47.         {
  48.             if (ItemState != none && ItemState.GetWeaponTech() == 'conventional')
  49.             {
  50.                 return default.BONUS_DAMAGE_CV;
  51.             }
  52.             else if (ItemState != none && ItemState.GetWeaponTech() == 'magnetic')
  53.             {
  54.                 return default.BONUS_DAMAGE_MG;
  55.             }
  56.             else if (ItemState != none && ItemState.GetWeaponTech() == 'beam')
  57.             {
  58.                 return default.BONUS_DAMAGE_BM;
  59.             }
  60.             else if (ItemState != none)
  61.             {
  62.                 return default.BONUS_DAMAGE_DEFAULT;
  63.             }
  64.         }
  65.  
  66.         */
  67.     }
  68.     else return 0;
  69. }
  70.  
  71. function bool IsEffectCurrentlyRelevant(XComGameState_Effect EffectGameState, XComGameState_Unit TargetUnit)
  72. {
  73.     return EffectGameState.iTurnsRemaining > 0;
  74. }
  75.  
  76. static function EventListenerReturn OnPlayerTurnTickedWrapper(Object EventData, Object EventSource, XComGameState GameState, Name Event, Object CallbackData)
  77. {
  78.     local XComGameState_Effect EffectGameState;
  79.     local XComGameState_Unit   TargetUnit;
  80.  
  81.     EffectGameState = XComGameState_Effect(CallbackData);
  82.     TargetUnit = XComGameState_Unit(EventSource);
  83.  
  84.     //  If this event was triggered by a unit this effect was applied to
  85.     if (EffectGameState != none && TargetUnit != none && EffectGameState.ApplyEffectParameters.TargetStateObjectRef.ObjectID == TargetUnit.ObjectID)
  86.     {      
  87.         //  Then "tick" the effect. Since the effect has 1 turn duration, that's effectively the same as removing it.
  88.         //  Straight up removing the effect doesn't work, because that for some reason doesn't handle removing perk content PFX
  89.         return EffectGameState.OnPlayerTurnTicked(EventData, EventSource, GameState, Event, CallbackData);
  90.     }
  91.     return ELR_NoInterrupt;
  92. }
  93.  
  94. static function PowerUpVisualization(XComGameState VisualizeGameState, out VisualizationActionMetadata ActionMetadata, const name EffectApplyResult)
  95. {
  96.     //local X2Action_PlayAnimation  PlayAnimation;
  97.     local X2Action_PlayEffect       EffectAction;
  98.  
  99.     if (EffectApplyResult != 'AA_Success') return;
  100.    
  101.     //PlayAnimation = X2Action_PlayAnimation(class'X2Action_PlayAnimation'.static.AddToVisualizationTree(ActionMetadata, VisualizeGameState.GetContext(), false, ActionMetadata.LastActionAdded));
  102.     //PlayAnimation.Params.AnimName = 'HL_PowerUp';
  103.  
  104.     EffectAction = X2Action_PlayEffect(class'X2Action_PlayEffect'.static.AddToVisualizationTree(ActionMetadata, VisualizeGameState.GetContext(), false, ActionMetadata.LastActionAdded));
  105.     EffectAction.EffectName = "TacticalReload_Persistent_Effect_Name";
  106.     EffectAction.AttachToUnit = true;
  107.     //EffectAction.AttachToSocketsArrayName = 'BoneSocketActor';
  108.     EffectAction.AttachToSocketName = 'R_Hand';
  109. }
  110.  
  111. function GetToHitModifiers(XComGameState_Effect EffectState, XComGameState_Unit Attacker, XComGameState_Unit Target, XComGameState_Ability AbilityState, class<X2AbilityToHitCalc> ToHitType, bool bMelee, bool bFlanking, bool bIndirectFire, out array<ShotModifierInfo> ShotModifiers)
  112. {
  113.     local ShotModifierInfo ModInfo;
  114.     local XComGameState_Item SourceWeapon;
  115.  
  116.     SourceWeapon = AbilityState.GetSourceWeapon();
  117.    
  118.     if (SourceWeapon != none && AbilityState.GetMyTemplateName() == 'TacticalReload') // Change to work with all weapons later
  119.     {
  120.         if (SourceWeapon != none && SourceWeapon.GetWeaponTech() == 'conventional')
  121.         {
  122.             ModInfo.ModType = eHit_Crit;
  123.             ModInfo.Reason = FriendlyName;
  124.             ModInfo.Value = default.BONUS_CRIT_CV;
  125.  
  126.             ShotModifiers.AddItem(ModInfo);
  127.  
  128.             ModInfo.ModType = eHit_Success;
  129.             ModInfo.Reason = FriendlyName;
  130.             ModInfo.Value = default.BONUS_AIM_CV;
  131.  
  132.             ShotModifiers.AddItem(ModInfo);
  133.         }
  134.         else if (SourceWeapon != none && SourceWeapon.GetWeaponTech() == 'magnetic')
  135.         {
  136.             ModInfo.ModType = eHit_Crit;
  137.             ModInfo.Reason = FriendlyName;
  138.             ModInfo.Value = default.BONUS_CRIT_MG;
  139.  
  140.             ShotModifiers.AddItem(ModInfo);
  141.  
  142.             ModInfo.ModType = eHit_Success;
  143.             ModInfo.Reason = FriendlyName;
  144.             ModInfo.Value = default.BONUS_AIM_MG;
  145.  
  146.             ShotModifiers.AddItem(ModInfo);
  147.         }
  148.         else if (SourceWeapon != none && SourceWeapon.GetWeaponTech() == 'beam')
  149.         {
  150.             ModInfo.ModType = eHit_Crit;
  151.             ModInfo.Reason = FriendlyName;
  152.             ModInfo.Value = default.BONUS_CRIT_BM;
  153.  
  154.             ShotModifiers.AddItem(ModInfo);
  155.  
  156.             ModInfo.ModType = eHit_Success;
  157.             ModInfo.Reason = FriendlyName;
  158.             ModInfo.Value = default.BONUS_AIM_BM;
  159.  
  160.             ShotModifiers.AddItem(ModInfo);
  161.         }
  162.         else if (SourceWeapon != none)
  163.         {
  164.             ModInfo.ModType = eHit_Crit;
  165.             ModInfo.Reason = FriendlyName;
  166.             ModInfo.Value = default.BONUS_CRIT_DEFAULT;
  167.  
  168.             ShotModifiers.AddItem(ModInfo);
  169.  
  170.             ModInfo.ModType = eHit_Success;
  171.             ModInfo.Reason = FriendlyName;
  172.             ModInfo.Value = default.BONUS_AIM_DEFAULT;
  173.  
  174.             ShotModifiers.AddItem(ModInfo);
  175.         }
  176.     }
  177. }
  178.  
  179. defaultproperties
  180. {
  181.     bDisplayInSpecialDamageMessageUI = true
  182.     //EffectName = "TacticalReloadEffect"
  183.     //VisualizationFn = PowerUpVisualization
  184. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement