Drakten

Untitled

Jun 14th, 2020
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  1. static function X2AbilityTemplate BscGuardDAb()
  2. {
  3. local X2AbilityTemplate Template;
  4. local X2Effect_PersistentStatChange Effect;
  5. local X2Condition_UnitType UnitTypeCondition;
  6. local X2Condition_UnitValue ValueCondition;
  7. local X2Effect_IncrementUnitValue IncrementEffect;
  8. local X2AbilityTrigger_EventListener Trigger;
  9.  
  10.  
  11.  
  12. // Using shield to debug for now because easy visualization
  13. Effect = new class'X2Effect_PersistentStatChange';
  14. Effect.EffectName = 'BscGuardDAb';
  15. Effect.AddPersistentStatChange(eStat_ShieldHP, default.GUARD_SHIELD);
  16. Effect.DuplicateResponse = eDupe_Allow;
  17. Effect.BuildPersistentEffect(1, true, true, false);
  18.  
  19. // Create a triggered ability that activates whenever the unit gets a kill
  20. Template = SelfTargetTrigger('BscGuardDAb', "img:///UILibrary_XPACK_Common.PerkIcons.UIPerk_ReflectShot", false, Effect, 'KillMail');
  21.  
  22. //trying an event listener so that the ability only fires on kills due to the weapon with the attachment
  23.  
  24. Trigger = new class'X2AbilityTrigger_EventListener';
  25. Trigger.ListenerData.EventID = 'AbilityActivated';
  26. Trigger.ListenerData.Deferral = ELD_OnStateSubmitted;
  27. Trigger.ListenerData.Filter = eFilter_None;
  28. Trigger.ListenerData.EventFn = DraktenMeleeListener;
  29. Template.AbilityTriggers.AddItem(Trigger);
  30.  
  31. // Does not trigger when killing Lost
  32. UnitTypeCondition = new class'X2Condition_UnitType';
  33. UnitTypeCondition.ExcludeTypes.AddItem('TheLost');
  34. AddTriggerTargetCondition(Template, UnitTypeCondition);
  35.  
  36. // Limit activations
  37. ValueCondition = new class'X2Condition_UnitValue';
  38. ValueCondition.AddCheckValue('Guard_Activations', default.GUARD_ACTIVATIONS_PER_MISSION, eCheck_LessThan);
  39. Template.AbilityTargetConditions.AddItem(ValueCondition);
  40.  
  41. // Create an effect that will increment the unit value
  42. IncrementEffect = new class'X2Effect_IncrementUnitValue';
  43. IncrementEffect.UnitName = 'Guard_Activations';
  44. IncrementEffect.NewValueToSet = 1;
  45. IncrementEffect.CleanupType = eCleanup_BeginTactical;
  46. Template.AddTargetEffect(IncrementEffect);
  47.  
  48. // Trigger abilities don't appear as passives. Add a passive ability icon.
  49. AddIconPassive(Template);
  50.  
  51. // Show a flyover when activated
  52. Template.bShowActivation = true;
  53.  
  54. return Template;
  55. }
  56.  
  57. static function EventListenerReturn DraktenMeleeListener(Object EventData, Object EventSource, XComGameState GameState, Name EventID, Object CallbackData)
  58. {
  59. local XComGameStateContext_Ability AbilityContext;
  60. local XComGameState_Ability AbilityState;
  61. local XComGameState_Item SourceWeapon;
  62. local array<name> AttachedWeaponUpgrades;
  63.  
  64. AbilityContext = XComGameStateContext_Ability(GameState.GetContext());
  65. AbilityState = XComGameState_Ability(CallbackData);
  66. SourceWeapon = XComGameState_Item(`XCOMHISTORY.GetGameStateForObjectID(AbilityContext.InputContext.ItemObject.ObjectID));
  67. AttachedWeaponUpgrades = SourceWeapon.GetMyWeaponUpgradeTemplateNames();
  68.  
  69. if (AbilityState.OwnerStateObject.ObjectID == AbilityContext.InputContext.SourceObject.ObjectID)
  70. {
  71. if (AttachedWeaponUpgrades.Find('Guard_D_Bsc') != INDEX_NONE)
  72. {
  73. if (SourceWeapon != None && default.AllowedWeaponCategories.Find(SourceWeapon.GetWeaponCategory()) != INDEX_NONE)
  74. {
  75. AbilityState.AbilityTriggerAgainstSingleTarget(AbilityContext.InputContext.SourceObject, false);
  76. }
  77. }
  78. }
  79. return ELR_NoInterrupt;
  80. }
Add Comment
Please, Sign In to add comment