Advertisement
Guest User

Untitled

a guest
Jan 31st, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. static event OnLoadedSavedGameToStrategy()
  2. {
  3.     local XComGameState NewGameState;
  4.     local XComGameStateHistory History;
  5.     local XComGameState_HeadquartersXCom XComHQ;
  6.     local X2ItemTemplateManager ItemTemplateMgr;
  7.     local X2ItemTemplate ItemTemplate;
  8.     local XComGameState_Item NewItemState;
  9.  
  10.     History = `XCOMHISTORY;
  11.     NewGameState = class'XComGameStateContext_ChangeContainer'.static.CreateChangeState("Add Items");
  12.     XComHQ = XComGameState_HeadquartersXCom(History.GetSingleGameStateObjectForClass(class'XComGameState_HeadquartersXCom'));
  13.     XComHQ = XComGameState_HeadquartersXCom(NewGameState.CreateStateObject(class'XComGameState_HeadquartersXCom', XComHQ.ObjectID));
  14.     NewGameState.AddStateObject(XComHQ);
  15.  
  16.     ItemTemplateMgr = class'X2ItemTemplateManager'.static.GetItemTemplateManager();
  17.  
  18.     //  find the template for weapon squad upgrade in engineering
  19.     ItemTemplate = ItemTemplateMgr.FindItemTemplate('SparkRifle_MG_Schematic'); //  <<== EDIT THIS TEMPLATE NAME
  20.  
  21.     if(ItemTemplate != none)
  22.     {
  23.         if (XComHQ.HasItem(ItemTemplate))   //  check if that squad upgrade has been purchased
  24.         {                                   //  if yes
  25.        
  26.             //  find the template for the weapon that is supposed to be added by this weapon squad upgrade
  27.             ItemTemplate = ItemTemplateMgr.FindItemTemplate('IRI_MEC_Chaingun');        //  <<== EDIT THIS TEMPLATE NAME
  28.    
  29.             if(ItemTemplate != none)
  30.             {
  31.                 if (!XComHQ.HasItem(ItemTemplate))  //  if HQ inventory doesn't contain the weapon already, add it
  32.                 {
  33.                     NewItemState = ItemTemplate.CreateInstanceFromTemplate(NewGameState);
  34.                     NewGameState.AddStateObject(NewItemState);
  35.                     XComHQ.AddItemToHQInventory(NewItemState);
  36.                     History.AddGameStateToHistory(NewGameState);
  37.                 }
  38.                 else // if the weapon is already in the HQ inventory, do nothing
  39.                 {
  40.                     History.CleanupPendingGameState(NewGameState);
  41.                 }
  42.             }
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement