Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #####################################################################################################################
- ABILITY:
- #####################################################################################################################
- class X2Ability_MeleeAttachments extends XMBAbility config(MeleeAttachments);
- var config int GUARD_SHIELD;
- var config int GUARD_ACTIVATIONS_PER_MISSION;
- var config array<name> AllowedWeaponCategories;
- static function array<X2DataTemplate> CreateTemplates()
- {
- local array<X2DataTemplate> Templates;
- Templates.AddItem(BscGuardDAb());
- return Templates;
- }
- static function X2AbilityTemplate BscGuardDAb()
- {
- local X2AbilityTemplate Template;
- local X2Effect_PersistentStatChange Effect;
- local X2Condition_UnitType UnitTypeCondition;
- local X2Condition_UnitValue ValueCondition;
- local X2Effect_IncrementUnitValue IncrementEffect;
- local X2AbilityTrigger_EventListener EventListenerWpn;
- `CREATE_X2ABILITY_TEMPLATE(Template, 'BscGuardDAb');
- Template.AbilitySourceName = 'eAbilitySource_Item';
- Template.eAbilityIconBehaviorHUD = eAbilityIconBehavior_NeverShow;
- Template.IconImage = "img:///UILibrary_XPACK_Common.PerkIcons.UIPerk_ReflectShot";
- Template.AbilityToHitCalc = default.DeadEye;
- Template.AbilityTargetStyle = default.SelfTarget;
- //trying an event listener so that the ability only fires on kills due to the weapon with the attachment
- EventListenerWpn = new class'X2AbilityTrigger_EventListener';
- EventListenerWpn.ListenerData.EventID = 'KillMail';
- EventListenerWpn.ListenerData.Deferral = ELD_OnStateSubmitted;
- EventListenerWpn.ListenerData.Filter = eFilter_None;
- EventListenerWpn.ListenerData.EventFn = DraktenMeleeListener;
- Template.AbilityTriggers.AddItem(EventListenerWpn);
- // Using shield to debug for now because easy visualization
- Effect = new class'X2Effect_PersistentStatChange';
- Effect.EffectName = 'BscGuardDAb';
- Effect.AddPersistentStatChange(eStat_ShieldHP, default.GUARD_SHIELD);
- Effect.DuplicateResponse = eDupe_Allow;
- Effect.BuildPersistentEffect(1, true, true, false);
- // Does not trigger when killing Lost
- UnitTypeCondition = new class'X2Condition_UnitType';
- UnitTypeCondition.ExcludeTypes.AddItem('TheLost');
- AddTriggerTargetCondition(Template, UnitTypeCondition);
- // Limit activations
- ValueCondition = new class'X2Condition_UnitValue';
- ValueCondition.AddCheckValue('Guard_Activations', default.GUARD_ACTIVATIONS_PER_MISSION, eCheck_LessThan);
- Template.AbilityTargetConditions.AddItem(ValueCondition);
- // Create an effect that will increment the unit value
- IncrementEffect = new class'X2Effect_IncrementUnitValue';
- IncrementEffect.UnitName = 'Guard_Activations';
- IncrementEffect.NewValueToSet = 1;
- IncrementEffect.CleanupType = eCleanup_BeginTactical;
- Template.AddTargetEffect(IncrementEffect);
- // Trigger abilities don't appear as passives. Add a passive ability icon.
- AddIconPassive(Template);
- // Show a flyover when activated
- Template.bShowActivation = true;
- return Template;
- }
- static function EventListenerReturn DraktenMeleeListener(Object EventData, Object EventSource, XComGameState GameState, Name EventID, Object CallbackData)
- {
- local XComGameStateContext_Ability AbilityContext;
- local XComGameState_Ability AbilityState;
- local XComGameState_Item SourceWeapon;
- local array<name> AttachedWeaponUpgrades;
- AbilityContext = XComGameStateContext_Ability(GameState.GetContext());
- AbilityState = XComGameState_Ability(CallbackData);
- SourceWeapon = XComGameState_Item(`XCOMHISTORY.GetGameStateForObjectID(AbilityContext.InputContext.ItemObject.ObjectID));
- AttachedWeaponUpgrades = SourceWeapon.GetMyWeaponUpgradeTemplateNames();
- if (AbilityState.OwnerStateObject.ObjectID == AbilityContext.InputContext.SourceObject.ObjectID)
- {
- if (AttachedWeaponUpgrades.Find('Guard_D_Bsc') != INDEX_NONE)
- {
- if (SourceWeapon != None && default.AllowedWeaponCategories.Find(SourceWeapon.GetWeaponCategory()) != INDEX_NONE)
- {
- AbilityState.AbilityTriggerAgainstSingleTarget(AbilityContext.InputContext.SourceObject, false);
- }
- }
- }
- return ELR_NoInterrupt;
- }
- ##################################################################################################################
- config file:
- ##################################################################################################################
- [MeleeAttachments.X2Ability_MeleeAttachments]
- +GUARD_SHIELD = 5
- +GUARD_ACTIVATIONS_PER_MISSION = 10
- +AllowedWeaponCategories=sword
- #####################################################################################################################
- x2ITEM
- #####################################################################################################################
- class X2Item_MeleeAttachments extends X2Item;
- static function array<X2DataTemplate> CreateTemplates()
- {
- local array<X2DataTemplate> Items;
- Items.AddItem(CreateBasicGuard_D());
- return Items;
- }
- static function X2DataTemplate CreateBasicGuard_D()
- {
- local X2WeaponUpgradeTemplate Template;
- `CREATE_X2TEMPLATE(class'X2WeaponUpgradeTemplate', Template, 'Guard_D_Bsc');
- Template.BonusAbilities.AddItem('BscGuardDAb');
- return Template;
- }
Add Comment
Please, Sign In to add comment