Drakten

Untitled

Jun 14th, 2020
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.21 KB | None | 0 0
  1. #####################################################################################################################
  2. ABILITY:
  3. #####################################################################################################################
  4. class X2Ability_MeleeAttachments extends XMBAbility config(MeleeAttachments);
  5.  
  6. var config int GUARD_SHIELD;
  7. var config int GUARD_ACTIVATIONS_PER_MISSION;
  8. var config array<name> AllowedWeaponCategories;
  9.  
  10. static function array<X2DataTemplate> CreateTemplates()
  11. {
  12. local array<X2DataTemplate> Templates;
  13.  
  14. Templates.AddItem(BscGuardDAb());
  15.  
  16. return Templates;
  17. }
  18.  
  19. static function X2AbilityTemplate BscGuardDAb()
  20. {
  21. local X2AbilityTemplate Template;
  22. local X2Effect_PersistentStatChange Effect;
  23. local X2Condition_UnitType UnitTypeCondition;
  24. local X2Condition_UnitValue ValueCondition;
  25. local X2Effect_IncrementUnitValue IncrementEffect;
  26. local X2AbilityTrigger_EventListener EventListenerWpn;
  27.  
  28. `CREATE_X2ABILITY_TEMPLATE(Template, 'BscGuardDAb');
  29.  
  30. Template.AbilitySourceName = 'eAbilitySource_Item';
  31. Template.eAbilityIconBehaviorHUD = eAbilityIconBehavior_NeverShow;
  32. Template.IconImage = "img:///UILibrary_XPACK_Common.PerkIcons.UIPerk_ReflectShot";
  33.  
  34. Template.AbilityToHitCalc = default.DeadEye;
  35. Template.AbilityTargetStyle = default.SelfTarget;
  36.  
  37. //trying an event listener so that the ability only fires on kills due to the weapon with the attachment
  38.  
  39. EventListenerWpn = new class'X2AbilityTrigger_EventListener';
  40. EventListenerWpn.ListenerData.EventID = 'KillMail';
  41. EventListenerWpn.ListenerData.Deferral = ELD_OnStateSubmitted;
  42. EventListenerWpn.ListenerData.Filter = eFilter_None;
  43. EventListenerWpn.ListenerData.EventFn = DraktenMeleeListener;
  44. Template.AbilityTriggers.AddItem(EventListenerWpn);
  45.  
  46. // Using shield to debug for now because easy visualization
  47. Effect = new class'X2Effect_PersistentStatChange';
  48. Effect.EffectName = 'BscGuardDAb';
  49. Effect.AddPersistentStatChange(eStat_ShieldHP, default.GUARD_SHIELD);
  50. Effect.DuplicateResponse = eDupe_Allow;
  51. Effect.BuildPersistentEffect(1, true, true, false);
  52.  
  53. // Does not trigger when killing Lost
  54. UnitTypeCondition = new class'X2Condition_UnitType';
  55. UnitTypeCondition.ExcludeTypes.AddItem('TheLost');
  56. AddTriggerTargetCondition(Template, UnitTypeCondition);
  57.  
  58. // Limit activations
  59. ValueCondition = new class'X2Condition_UnitValue';
  60. ValueCondition.AddCheckValue('Guard_Activations', default.GUARD_ACTIVATIONS_PER_MISSION, eCheck_LessThan);
  61. Template.AbilityTargetConditions.AddItem(ValueCondition);
  62.  
  63. // Create an effect that will increment the unit value
  64. IncrementEffect = new class'X2Effect_IncrementUnitValue';
  65. IncrementEffect.UnitName = 'Guard_Activations';
  66. IncrementEffect.NewValueToSet = 1;
  67. IncrementEffect.CleanupType = eCleanup_BeginTactical;
  68. Template.AddTargetEffect(IncrementEffect);
  69.  
  70. // Trigger abilities don't appear as passives. Add a passive ability icon.
  71. AddIconPassive(Template);
  72.  
  73. // Show a flyover when activated
  74. Template.bShowActivation = true;
  75.  
  76. return Template;
  77. }
  78.  
  79. static function EventListenerReturn DraktenMeleeListener(Object EventData, Object EventSource, XComGameState GameState, Name EventID, Object CallbackData)
  80. {
  81. local XComGameStateContext_Ability AbilityContext;
  82. local XComGameState_Ability AbilityState;
  83. local XComGameState_Item SourceWeapon;
  84. local array<name> AttachedWeaponUpgrades;
  85.  
  86. AbilityContext = XComGameStateContext_Ability(GameState.GetContext());
  87. AbilityState = XComGameState_Ability(CallbackData);
  88. SourceWeapon = XComGameState_Item(`XCOMHISTORY.GetGameStateForObjectID(AbilityContext.InputContext.ItemObject.ObjectID));
  89. AttachedWeaponUpgrades = SourceWeapon.GetMyWeaponUpgradeTemplateNames();
  90.  
  91. if (AbilityState.OwnerStateObject.ObjectID == AbilityContext.InputContext.SourceObject.ObjectID)
  92. {
  93. if (AttachedWeaponUpgrades.Find('Guard_D_Bsc') != INDEX_NONE)
  94. {
  95. if (SourceWeapon != None && default.AllowedWeaponCategories.Find(SourceWeapon.GetWeaponCategory()) != INDEX_NONE)
  96. {
  97. AbilityState.AbilityTriggerAgainstSingleTarget(AbilityContext.InputContext.SourceObject, false);
  98. }
  99. }
  100. }
  101. return ELR_NoInterrupt;
  102. }
  103. ##################################################################################################################
  104. config file:
  105. ##################################################################################################################
  106. [MeleeAttachments.X2Ability_MeleeAttachments]
  107. +GUARD_SHIELD = 5
  108. +GUARD_ACTIVATIONS_PER_MISSION = 10
  109. +AllowedWeaponCategories=sword
  110.  
  111. #####################################################################################################################
  112. x2ITEM
  113. #####################################################################################################################
  114. class X2Item_MeleeAttachments extends X2Item;
  115.  
  116. static function array<X2DataTemplate> CreateTemplates()
  117. {
  118. local array<X2DataTemplate> Items;
  119. Items.AddItem(CreateBasicGuard_D());
  120.  
  121. return Items;
  122. }
  123.  
  124. static function X2DataTemplate CreateBasicGuard_D()
  125. {
  126. local X2WeaponUpgradeTemplate Template;
  127.  
  128. `CREATE_X2TEMPLATE(class'X2WeaponUpgradeTemplate', Template, 'Guard_D_Bsc');
  129. Template.BonusAbilities.AddItem('BscGuardDAb');
  130.  
  131. return Template;
  132. }
Add Comment
Please, Sign In to add comment