Advertisement
RustyDios

BluescreensToDeck

Nov 23rd, 2020 (edited)
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.73 KB | None | 0 0
  1. ////////////////////////////////////////////////////////////
  2. //  x2dlcinfo
  3. ///////////////////////////////////////////////////////////
  4.  
  5. var config bool bRAT_BLUESCREENTODECK;
  6. var config bool bEnableLogging;
  7.  
  8. // Called on load into a save game strategy layer
  9. static event OnLoadedSavedGameToStrategy()
  10. {
  11.     PutBluescreensInDeck();
  12. }                  
  13.  
  14. static event OnPostTemplatesCreated()
  15. {
  16.     local X2StrategyElementTemplateManager      AllStratElems;      //holder for all strat elements
  17.     AllStratElems           = class'X2StrategyElementTemplateManager'.static.GetStrategyElementTemplateManager();
  18.    
  19.     PatchBluescreenTech(AllStratElems);
  20. }
  21.  
  22.     /////////////////////////////////////////////////////////////////
  23.     // Makes Bluescreen rounds into the experimental deck
  24.     /////////////////////////////////////////////////////////////////
  25.  
  26. //On Load Save Game
  27. static function PutBluescreensInDeck()
  28. {
  29.     local X2ItemTemplateManager     ItemMgr;
  30.  
  31.     //Karen, call the manager !!
  32.     ItemMgr = class'X2ItemTemplateManager'.static.GetItemTemplateManager();
  33.  
  34.     RemoveFromDecks(ItemMgr.FindItemTemplate('BluescreenRounds'));
  35.     RemoveFromDecks(ItemMgr.FindItemTemplate('EMPGrenade'));
  36.    
  37.     //if tech done place them in the deck
  38.     if (default.bRAT_BLUESCREENTODECK && HasCompletedTechByTemplateName('Bluescreen'))
  39.     {
  40.         AddToDecks(ItemMgr.FindItemTemplate('BluescreenRounds'),'ExperimentalAmmoRewards');
  41.         AddToDecks(ItemMgr.FindItemTemplate('EMPGrenade'),      'ExperimentalGrenadeRewards');
  42.     }
  43. }
  44.  
  45. static function bool HasCompletedTechByTemplateName(name TemplateName)
  46. {
  47.     local XComGameState_Tech TechState;
  48.     local int i;
  49.  
  50.     for (i = 0 ; i < `XCOMHQ.TechsResearched.length ; i++)
  51.     {
  52.         TechState = XComGameState_Tech(`XCOMHISTORY.GetGameStateForObjectID(`XCOMHQ.TechsResearched[i].ObjectID));
  53.  
  54.         //Outdated savegames may contain completed techs that have since been removed. Don't bother checking them.
  55.         if (TechState.GetMyTemplate() == None)              continue;
  56.  
  57.         //if tech name matches our query
  58.         if (TechState.GetMyTemplateName() == TemplateName)  return true;
  59.     }
  60.  
  61.     //for no matches found
  62.     return false;
  63. }
  64.  
  65. static function RemoveFromDecks (X2ItemTemplate Template)
  66. {
  67.     if (Template != none)
  68.     {
  69.         Template.CanBeBuilt = true;
  70.         Template.RewardDecks.length = 0;
  71.         `LOG("Patched :: "@Template.GetItemFriendlyName() @" :: Moved OUT of Experimental deck",default.bEnableLogging,'WOTC_RAT');
  72.     }
  73. }
  74.  
  75. static function AddToDecks (X2ItemTemplate Template, name RewardDeckName)
  76. {
  77.     if (Template != none)
  78.     {
  79.         if (!IsDLCInstalled('WOTC_PGOverhaul'))
  80.         {
  81.             Template.CanBeBuilt = false;
  82.         }
  83.  
  84.         Template.RewardDecks.AddItem(RewardDeckName);
  85.  
  86.         `LOG("Patched :: "@Template.GetItemFriendlyName() @" :: Moved IN to Experimental Deck",default.bEnableLogging,'WOTC_RAT');
  87.     }
  88. }
  89.  
  90. //OPTC Patch of Tech
  91. static function PatchBluescreenTech(X2StrategyElementTemplateManager StratMgr)
  92. {
  93.     local X2TechTemplate                        TechTemplate;
  94.     local X2StrategyElementTemplate             Template;
  95.  
  96.     Template = StratMgr.FindStrategyElementTemplate('Bluescreen');
  97.     if (default.bRAT_BLUESCREENTODECK && X2TechTemplate(Template) != none)
  98.     {
  99.         TechTemplate = X2TechTemplate(Template);
  100.         TechTemplate.ResearchCompletedFn = PutBluescreensInDeckReward;
  101.  
  102.         `LOG("Patched :: Bluescreen Template to flip deck items",default.bEnableLogging,'WOTC_RAT');
  103.     }
  104. }
  105.  
  106. static function PutBluescreensInDeckReward(XComGameState NewGameState, XComGameState_Tech TechState)
  107. {
  108.     local X2ItemTemplateManager     ItemMgr;
  109.  
  110.     //Karen, call the manager !!
  111.     ItemMgr = class'X2ItemTemplateManager'.static.GetItemTemplateManager();
  112.  
  113.     // place them in the deck
  114.     if (default.bRAT_BLUESCREENTODECK)
  115.     {
  116.         AddToDecks(ItemMgr.FindItemTemplate('BluescreenRounds'),'ExperimentalAmmoRewards');
  117.         AddToDecks(ItemMgr.FindItemTemplate('EMPGrenade'),      'ExperimentalGrenadeRewards');
  118.     }
  119. }
  120.     //////////////////////////////////////////////////////////////////////////////////////////
  121.     // CHECK FOR DLC/MODS
  122.     //////////////////////////////////////////////////////////////////////////////////////////
  123.  
  124. static function bool IsDLCInstalled(name DLCName)
  125. {
  126.     local XComOnlineEventMgr        EventMgr;
  127.     local int                        i;
  128.  
  129.     // Return true if no DLC required
  130.     if (DLCName == '')
  131.     {
  132.         return true;
  133.     }
  134.  
  135.     // Access Online Event Manager
  136.     EventMgr = `ONLINEEVENTMGR;
  137.  
  138.     // Return true if required DLC is installed
  139.     for (i = 0; i < EventMgr.GetNumDLC(); ++i)
  140.     {
  141.         if (EventMgr.GetDLCNames(i) == DLCName)
  142.         {
  143.             return true;
  144.         }
  145.     }
  146.  
  147.     return false;
  148. }
  149.  
  150. ////////////////////////////////////////////////////////////
  151. //  PGOv2 config
  152. ///////////////////////////////////////////////////////////
  153. [WOTC_PGOverhaul.X2Helpers_PGOverhaulExperimentalItems]
  154. ; ===== adds the individual unlock techs =====
  155. +arrUnlockExperimentalItem=(ItemName="BluescreenRounds",    TechName="BluescreenRounds_UnlockTech", TechImage="img:///UILibrary_StrategyImages.ResearchTech.TECH_Experimental_Ammo")
  156. +arrUnlockExperimentalItem=(ItemName="EMPGrenade",          TechName="EMPGrenade_UnlockTech",       TechImage="img:///UILibrary_StrategyImages.ResearchTech.TECH_Experimental_Grenade")
  157.  
  158. ////////////////////////////////////////////////////////////
  159. //  Localisaztion xcomgame.int
  160. ///////////////////////////////////////////////////////////
  161. ;***************************************
  162. ;New PGOv2 Unlocks
  163. ;***************************************
  164.  
  165. [BluescreenRounds_UnlockTech X2TechTemplate]
  166. DisplayName="Experimental Ammo: Bluescreen Rounds"
  167. Summary="Iridar WOULD Kill me if this goes public. HotBlooded Bluescreens round to deck works with PGOv2"
  168.  
  169. [EMPGrenade_UnlockTech X2TechTemplate]
  170. DisplayName="Experimental Grenade: EMP"
  171. Summary="Iridar WOULD Kill me if this goes public. HotBlooded Bluescreens grenades to deck works with PGOv2"
  172.  
  173.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement