RustyDios

OPTC Ability Costs Array

Jan 25th, 2021 (edited)
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.93 KB | None | 0 0
  1. static event OnPostTemplatesCreated()
  2. {
  3.     local X2AbilityTemplateManager              AllAbilities;       //holder for all abilities
  4.  
  5.     //KAREN !! Get all the (template) managers !!
  6.     AllAbilities            = class'X2AbilityTemplateManager'.static.GetAbilityTemplateManager();
  7.  
  8.     if (default.b_SomeConfigValueForControl)
  9.     {
  10.         //values here can be pulled from config if needed, default.iAP
  11.         ChangeCosts(AllAbilities.FindAbilityTemplate('AbilityName'), iAP, bFree, bTurn, iChrg, iCool);
  12.     }
  13. }
  14.  
  15. //function to obliterate and rebuild an abilities costs array
  16. static function ChangeCosts(X2AbilityTemplate Template, int AP, bool bFree, bool bEndsTurn, iNumCharges, iCooldown)
  17. {
  18.     local X2AbilityCost_ActionPoints    APCost;
  19.     local X2AbilityCooldown             Cooldown;
  20.     local X2AbilityCharges              Charges;
  21.     local X2AbilityCost_Charges         ChargeCost;
  22.  
  23.     if (Template != none)
  24.     {
  25.         //reset
  26.         Template.AbilityCosts.Length = 0;
  27.         Template.AbilityCooldown = none;
  28.         Template.AbilityCharges = none;
  29.  
  30.         //create and add new AP costs
  31.         APCost = new class'X2AbilityCost_ActionPoints';
  32.             APCost.iNumPoints = AP;
  33.             APCost.bFreeCost = bFree;               //free cost evaluates AP required
  34.             APCost.bConsumeAllPoints = bEndsTurn;
  35.         Template.AbilityCosts.AddItem(APCost);
  36.  
  37.         //create and add new charges cost if needed
  38.         if (iNumCharges > 0)
  39.         {
  40.             ChargeCost = new class'X2AbilityCost_Charges';
  41.             ChargeCost.NumCharges = 1;
  42.             Template.AbilityCosts.AddItem(ChargeCost);
  43.  
  44.             Charges = new class'X2AbilityCharges';
  45.             Charges.InitialCharges = iNumCharges;
  46.             Template.AbilityCharges = Charges
  47.         }
  48.  
  49.         //create and add new cooldown if needed
  50.         if (iCooldown > 0)
  51.         {
  52.             Cooldown = new class'X2AbilityCooldown';
  53.             Cooldown.iNumTurns = iCooldown;         //a 1 turn cooldown can be used to avoid same-turn spamming of free abilities
  54.             Template.AbilityCooldown = Cooldown;
  55.         }
  56.  
  57.         `LOG("ChangeCosts was completed for" @Template.LocFriendlyName, default.b_SomeConfigValueForControl, 'ModJam');
  58.     }
  59.  
  60. }
Add Comment
Please, Sign In to add comment