Advertisement
Drakten

Untitled

Aug 11th, 2020
1,436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. static function X2AbilityTemplate BscSiphonUpgradeHUD()
  2. {
  3.     local X2AbilityTemplate                 Template;
  4.     local X2AbilityCost_Charges             ChargeCost;
  5.     local X2AbilityCharges                  Charges;
  6.     local X2AbilityCooldown                 Cooldown;
  7.     local X2Effect_Persistent               DummyEffect;
  8.     local X2Condition_UnitEffects           EffectsCondition;
  9.    
  10.     `CREATE_X2ABILITY_TEMPLATE(Template, 'BasicSiphonShield');
  11.  
  12.     //HUD and icon stuff
  13.     Template.Hostility = eHostility_Neutral;
  14.     Template.AbilitySourceName = 'eAbilitySource_Item';
  15.     Template.IconImage = "img:///ShieldUps.HUD.siphon";
  16.     Template.eAbilityIconBehaviorHUD = eAbilityIconBehavior_AlwaysShow;
  17.     Template.ShotHUDPriority = 1900;
  18.     Template.AbilityConfirmSound = "TacticalUI_ActivateAbility";
  19.  
  20.     Template.AbilityToHitCalc = default.DeadEye;
  21.     Template.AbilityTargetStyle = default.SelfTarget;
  22.     Template.AbilityTriggers.AddItem(default.PlayerInputTrigger);
  23.     Template.AbilityCosts.AddItem(default.FreeActionCost);
  24.  
  25.     ChargeCost = new class'X2AbilityCost_Charges';
  26.     ChargeCost.NumCharges = 1;
  27.     Template.AbilityCosts.AddItem(ChargeCost);
  28.  
  29.     Charges = new class'X2AbilityCharges';
  30.     Charges.InitialCharges = default.BSC_SIPH_USES;
  31.     Template.AbilityCharges = Charges;
  32.  
  33.     Cooldown = new class'X2AbilityCooldown';
  34.     Cooldown.iNumTurns = default.BSC_SIPH_CD;
  35.     Template.AbilityCooldown = Cooldown;
  36.  
  37.     Template.AbilityShooterConditions.AddItem(default.LivingShooterProperty);
  38.  
  39.     //BuildPersistentEffect(int _iNumTurns, optional bool _bInfiniteDuration=false, optional bool _bRemoveWhenSourceDies=true, optional bool _bIgnorePlayerCheckOnTick=false, optional GameRuleStateChange _WatchRule=eGameRule_TacticalGameStart )
  40.     DummyEffect = new class'X2Effect_Persistent';
  41.     DummyEffect.EffectName = 'BscSiphonDummyEffect';
  42.     DummyEffect.BuildPersistentEffect(1,,,, eGameRule_PlayerTurnEnd);
  43.     DummyEffect.SetDisplayInfo(ePerkBuff_Passive, Template.LocFriendlyName, Template.LocLongDescription, Template.IconImage, false,,Template.AbilitySourceName);
  44.     Template.AddTargetEffect(DummyEffect);
  45.  
  46.     EffectsCondition = new class'X2Condition_UnitEffects';
  47.     EffectsCondition.AddExcludeEffect('BscSiphonDummyEffect', 'AA_MissingRequiredEffect');
  48.     Template.AbilityTargetConditions.AddItem(EffectsCondition);
  49.  
  50.     Template.AdditionalAbilities.AddItem('BscSiphonUpgradeActual');
  51.  
  52.     Template.bShowActivation = true;
  53.     Template.BuildNewGameStateFn = TypicalAbility_BuildGameState;
  54.     Template.BuildVisualizationFn = TypicalAbility_BuildVisualization;
  55.  
  56.     return Template;
  57. }
  58.  
  59. static function X2AbilityTemplate BscSiphonUpgradeActual()
  60. {
  61.     local X2AbilityTemplate                 Template;
  62.     local X2Effect_PersistentStatChange     ShieldedEffect;
  63.     local X2AbilityMultiTarget_Radius       MultiTarget;
  64.     local X2AbilityTrigger_EventListener    EventListener;
  65.     local X2Condition_UnitProperty          FriendCondition;
  66.     local X2Condition_UnitEffects           EffectsCondition;
  67.     local X2Effect_RemoveEffects            RemoveEffects;
  68.  
  69.     `CREATE_X2ABILITY_TEMPLATE(Template, 'BscSiphonUpgradeActual');
  70.  
  71.     Template.Hostility = eHostility_Neutral;
  72.     Template.AbilitySourceName = 'eAbilitySource_Item';
  73.     Template.IconImage = "img:///ShieldUps.HUD.siphon";
  74.     Template.eAbilityIconBehaviorHUD = eAbilityIconBehavior_NeverShow;
  75.     Template.ShotHUDPriority = 1900;
  76.    
  77.     Template.AbilityToHitCalc = default.DeadEye;
  78.     Template.AbilityTargetStyle = default.SelfTarget;
  79.    
  80.     Template.AbilityShooterConditions.AddItem(default.LivingShooterProperty);
  81.     EffectsCondition = new class'X2Condition_UnitEffects';
  82.     EffectsCondition.AddRequireEffect('BscSiphonDummyEffect', 'AA_MissingRequiredEffect');
  83.     Template.AbilityShooterConditions.AddItem(EffectsCondition);
  84.    
  85.     EventListener = new class'X2AbilityTrigger_EventListener';
  86.     EventListener.ListenerData.EventID = 'KillMail';
  87.     EventListener.ListenerData.Deferral = ELD_OnStateSubmitted;
  88.     EventListener.ListenerData.Filter = eFilter_None;
  89.     EventListener.ListenerData.EventFn = SiphonListener;
  90.     EventListener.ListenerData.Priority = 40;
  91.     Template.AbilityTriggers.AddItem(EventListener);
  92.  
  93.     FriendCondition = new class'X2Condition_UnitProperty';
  94.     FriendCondition.ExcludeDead = true;
  95.     FriendCondition.ExcludeFriendlyToSource = false;
  96.     FriendCondition.ExcludeHostileToSource = true;
  97.     FriendCondition.ExcludeCivilian = true;
  98.     FriendCondition.FailOnNonUnits = true;
  99.     Template.AbilityMultiTargetConditions.AddItem(FriendCondition);
  100.  
  101.     MultiTarget = new class'X2AbilityMultiTarget_Radius';
  102.     MultiTarget.fTargetRadius = default.BSC_SIPH_RADIUS;
  103.     MultiTarget.bIgnoreBlockingCover = true;
  104.     Template.AbilityMultiTargetStyle = MultiTarget;
  105.  
  106.     ShieldedEffect = CreateShieldedEffect(Template.LocFriendlyName, Template.GetMyLongDescription(), default.BSC_SIPH_SHIELD);
  107.     Template.AddShooterEffect(ShieldedEffect);
  108.     Template.AddMultiTargetEffect(ShieldedEffect);
  109.  
  110.     RemoveEffects = new class'X2Effect_RemoveEffects';
  111.     RemoveEffects.EffectNamesToRemove.AddItem('BscSiphonDummyEffect');
  112.     Template.AddTargetEffect(RemoveEffects);
  113.  
  114.     Template.BuildNewGameStateFn = TypicalAbility_BuildGameState;
  115.     Template.BuildVisualizationFn = class'X2Ability_AdventShieldBearer'.static.Shielded_BuildVisualization;
  116.     Template.CinescriptCameraType = "AdvShieldBearer_EnergyShieldArmor";
  117.  
  118.     Template.SuperConcealmentLoss = class'X2AbilityTemplateManager'.default.SuperConcealmentStandardShotLoss;
  119.     Template.ChosenActivationIncreasePerUse = class'X2AbilityTemplateManager'.default.StandardShotChosenActivationIncreasePerUse;
  120.     Template.LostSpawnIncreasePerUse = class'X2AbilityTemplateManager'.default.MeleeLostSpawnIncreasePerUse;
  121.    
  122.     return Template;
  123. }
  124.  
  125. //killmail  EventManager.TriggerEvent('KillMail', self, Killer, NewGameState);
  126. static function EventListenerReturn SiphonListener(Object EventData, Object EventSource, XComGameState GameState, Name EventID, Object CallbackData)
  127. {  
  128.     local XComGameStateContext_Ability      AbilityContext;
  129.     local XComGameState_Ability             AbilityState;
  130.     local XComGameState_Item                SourceWeapon;
  131.     local array<name>                       AttachedWeaponUpgrades;
  132.     local XComGameState_Unit                KilledUnit;
  133.     //local bool                                correctkiller;
  134.     //local bool                                correctupgrade;
  135.    
  136.  
  137.     AbilityContext = XComGameStateContext_Ability(GameState.GetContext())
  138.     AbilityState = XComGameState_Ability(CallbackData);
  139.     SourceWeapon = XComGameState_Item(`XCOMHISTORY.GetGameStateForObjectID(AbilityContext.InputContext.ItemObject.ObjectID));
  140.     AttachedWeaponUpgrades = SourceWeapon.GetMyWeaponUpgradeTemplateNames();
  141.     KilledUnit = XComGameState_Unit(EventData);
  142.     /*
  143.     correctkiller = (AbilityState.OwnerStateObject.ObjectID == AbilityContext.InputContext.SourceObject.ObjectID);
  144.     `LOG("is the killer the only one: " $ correctkiller);
  145.     correctupgrade = (AttachedWeaponUpgrades.Find('DraktenSiphon_Bsc') != INDEX_NONE);
  146.     `LOG("is the upgrade installed: " $ correctupgrade);
  147.     */
  148.     if (KilledUnit.GetTeam() != eTeam_TheLost) //won't fire on Lost kills
  149.     {
  150.         if (AbilityState.OwnerStateObject == AbilityContext.InputContext.SourceObject) //making sure the ability only fires when the killer kills
  151.         {
  152.             if (AttachedWeaponUpgrades.Find('DraktenSiphon_Bsc') != INDEX_NONE || AttachedWeaponUpgrades.Find('DraktenSiphon_Adv') != INDEX_NONE || AttachedWeaponUpgrades.Find('DraktenSiphon_Sup') != INDEX_NONE) // making sure the correct attachments are installed
  153.            
  154.                 {
  155.                     AbilityState.AbilityTriggerAgainstSingleTarget(AbilityContext.InputContext.SourceObject, false); //if all conditions pass, ability fires
  156.                 }
  157.            
  158.         }
  159.     }
  160.     return ELR_NoInterrupt;
  161. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement