Advertisement
Guest User

Untitled

a guest
Mar 13th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. //  this code will trigger when the game finishes creating ability, item and character templates.
  3. static event OnPostTemplatesCreated()
  4. {
  5.     //  this is the list of local variables used in is code.
  6.     local X2AbilityTemplate             Template;
  7.     local X2AbilityTemplateManager      AbilityManager;
  8.     local X2AbilityCost_ActionPoints    ActionPointCost;
  9.     local X2AbilityCooldown             Cooldown;
  10.     local X2AbilityCost_Ammo            AmmoCost;
  11.  
  12.     //  grab ability manager, which we will use to find ability templates by name.
  13.     AbilityManager = class'X2AbilityTemplateManager'.static.GetAbilityTemplateManager();
  14.    
  15.     //  find an ability template by name and record it into the "Template" variable.
  16.     Template = AbilityManager.FindAbilityTemplate('Shadow');
  17.    
  18.     //  if the ability template was successfully found, we can start making changes to it.
  19.     if(Template != none)
  20.     {
  21.         //  this how to remove ALL costs from the ability, such as charges, ammo, cooldown and action points.
  22.         Template.AbilityCosts.Length = 0;  
  23.        
  24.         //  this is how you add a simple 1 action ability cost.
  25.         ActionPointCost = new class'X2AbilityCost_ActionPoints';
  26.         ActionPointCost.iNumPoints = 1;
  27.         Template.AbilityCosts.AddItem(ActionPointCost);
  28.        
  29.         //  this is how you add "turn ending action" cost to an ability.
  30.         //  i.e. this ability will consume all soldier's action points after being used.
  31.         ActionPointCost = new class'X2AbilityCost_ActionPoints';
  32.         ActionPointCost.iNumPoints = 1;
  33.         ActionPointCost.bConsumeAllPoints = true;
  34.         Template.AbilityCosts.AddItem(ActionPointCost);
  35.        
  36.         //  this is how you add a "free action" ability cost to the ability.
  37.         //  even "free" abilities need to have the "free action" ability cost,
  38.         //  so that they can't be used after the soldier "finished turn", i.e. spent all their action points
  39.         ActionPointCost =  new class'X2AbilityCost_ActionPoints';
  40.         ActionPointCost.iNumPoints = 1;
  41.         ActionPointCost.bFreeCost = true;
  42.         Template.AbilityCosts.AddItem(ActionPointCost);
  43.        
  44.         //  note: don't give one ability more than one Action Point Cost.
  45.         //  It probably won't break anything if you do, but there's no reason to do it, I just list all three here as an example.
  46.         //  if you want to "hide" a piece of code from the game, you can comment it out like this:
  47.         //  Template.AbilityCosts.Length = 0;  
  48.  
  49.        
  50.         //  this is how you add a cooldown to an ability
  51.         Cooldown = new class'X2AbilityCooldown';
  52.         Cooldown.iNumTurns = 2;
  53.         Template.AbilityCooldown = Cooldown;
  54.        
  55.        
  56.         //  this is how you add an ammo cost to an ability, if it involves shooting, like Banish / Annihilation.
  57.         AmmoCost = new class'X2AbilityCost_Ammo';
  58.         AmmoCost.iAmmo = 1;
  59.         Template.AbilityCosts.AddItem(AmmoCost);
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement