Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 Trigger;
- // 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);
- // Create a triggered ability that activates whenever the unit gets a kill
- Template = SelfTargetTrigger('BscGuardDAb', "img:///UILibrary_XPACK_Common.PerkIcons.UIPerk_ReflectShot", false, Effect, 'KillMail');
- //trying an event listener so that the ability only fires on kills due to the weapon with the attachment
- Trigger = new class'X2AbilityTrigger_EventListener';
- Trigger.ListenerData.EventID = 'AbilityActivated';
- Trigger.ListenerData.Deferral = ELD_OnStateSubmitted;
- Trigger.ListenerData.Filter = eFilter_None;
- Trigger.ListenerData.EventFn = DraktenMeleeListener;
- Template.AbilityTriggers.AddItem(Trigger);
- // 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;
- }
Add Comment
Please, Sign In to add comment