Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------------------------------------------------------------------------
- // FILE: XComDownloadableContentInfo_TacticalReloadNew2.uc
- //
- // Use the X2DownloadableContentInfo class to specify unique mod behavior when the
- // player creates a new campaign or loads a saved game.
- //
- //---------------------------------------------------------------------------------------
- // Copyright (c) 2016 Firaxis Games, Inc. All rights reserved.
- //---------------------------------------------------------------------------------------
- class X2DownloadableContentInfo_TacticalReloadNew2 extends X2DownloadableContentInfo config(TacticalReloadNew2);
- // Config variables
- var config bool SWAP_DEMOLITION;
- var config bool CROSS_${1}< ${3} >
- /// This method is run if the player loads a saved game inside the stragy layer
- static event OnLoadedSavedGameToStrategy()
- {
- `LOG("OnLoadedSavedGame is activated", true, 'TacticalReloadNew2');
- if(default.SWAP_DEMOLITION == true)
- {
- `LOG("SWAP_DEMOLITION is being called in OnLoadedSavedGame", true, 'TacticalReloadNew2');
- SwapDemolition();
- }
- }
- /// Called when the player starts a new campaign while this mod is installed
- static event InstallNewCampaign(XComGameState StartState)
- {
- if(default.SWAP_DEMOLITION == true)
- {
- PatchSoldierClassTemplates();
- `LOG("PatchSoldierCclassTemplates has been run!", true, 'TacticalReloadNew2');
- }
- }
- /// Run after all the templates have been created
- static event OnPostTemplatesCreated()
- {
- `LOG("All templates have been created.", true, 'TacticalReloadNew2');
- if(default.SWAP_DEMOLITION == true)
- {
- PatchSoldierClassTemplates();
- `LOG("PatchSoldierCclassTemplates has been run!", true, 'TacticalReloadNew2');
- }
- }
- /// Function to patch the SoldierClassTemplates (from the base game's X2SoldierClassTemplateManager(.uc) class) and replace Demolition with TacticalReload
- static function PatchSoldierClassTemplates()
- {
- local X2SoldierClassTemplateManager Manager;
- local X2SoldierClassTemplate SoldierClassTemplate;
- local int i;
- Manager = class'X2SoldierClassTemplateManager'.static.GetSoldierClassTemplateManager();
- SoldierClassTemplate = Manager.FindSoldierClassTemplate('Grenadier');
- // Requires unprotecting X2SoldierClassTemplate -> SoldierRanks class
- // Loop through the AbilitySlots of the Sergeant rank in reverse order
- if (SoldierClassTemplate != none && SoldierClassTemplate.SoldierRanks.Length > 0)
- {
- // Check if the current AbilitySlot has the Demolition ability
- for (i = SoldierClassTemplate.SoldierRanks[2].AbilitySlots.Length - 1; i >= 0; i--)
- {
- // Replace the Demolition ability with TacticalReload and end the loop
- if (SoldierClassTemplate.SoldierRanks[2].AbilitySlots[i].AbilityType.AbilityName == 'Demolition')
- {
- SoldierClassTemplate.SoldierRanks[2].AbilitySlots[i].AbilityType.AbilityName = 'TacticalReload';
- break;
- }
- }
- }
- }
- // Set values to ones defined in the config (config values are defined in X2Effect_TacticalReloadDamage.uc)
- /*
- static function bool AbilityTagExpandHandler(string InString, out string OutString)
- {
- local name TagText;
- TagText = name(InString);
- switch (TagText)
- {
- // Bonus damage
- case 'BONUSDMGCV':
- OutString = string(class'X2Effect_TacticalReloadNew2'.default.TR_BONUS_DAMAGE_CV);
- return true;
- case 'BONUSDMGMG':
- OutString = string(class'X2Effect_TacticalReloadNew2'.default.TR_BONUS_DAMAGE_MG);
- return true;
- case 'BONUSDMGBM':
- OutString = string(class'X2Effect_TacticalReloadNew2'.default.TR_BONUS_DAMAGE_BM);
- return true;
- // Bonus aim
- case 'BONUSAIMCV':
- OutString = string(class'X2Effect_TacticalReloadNew2'.default.TR_BONUS_AIM_CV);
- return true;
- case 'BONUSAIMMG':
- OutString = string(class'X2Effect_TacticalReloadNew2'.default.TR_BONUS_AIM_MG);
- return true;
- case 'BONUSAIMBM':
- OutString = string(class'X2Effect_TacticalReloadNew2'.default.TR_BONUS_AIM_BM);
- return true;
- // Bonus crit chance
- case 'BONUSCRITCV':
- OutString = string(class'X2Effect_TacticalReloadNew2'.default.TR_BONUS_CRIT_CV);
- return true;
- case 'BONUSCRITMG':
- OutString = string(class'X2Effect_TacticalReloadNew2'.default.TR_BONUS_CRIT_MG);
- return true;
- case 'BONUSCRITBM':
- OutString = string(class'X2Effect_TacticalReloadNew2'.default.TR_BONUS_CRIT_BM);
- return true;
- //End
- default:
- return false;
- }
- }*/
- // Function to swap Demolition with TacticalReload
- static function SwapDemolition()
- {
- local XComGameStateHistory History;
- local XComGameState_Unit UnitState;
- local XComGameState_HeadquartersXCom XComHQ;
- local StateObjectReference UnitRef;
- local XComGameState NewGameState;
- History = `XCOMHISTORY;
- XComHQ = `XCOMHQ;
- `LOG("SwapDemolition() function is called", true, 'TacticalReloadNew2');
- NewGameState = class'XComGameStateContext_ChangeContainer'.static.CreateChangeState("Adding UnitState");
- foreach XComHQ.Crew(UnitRef)
- {
- UnitState = XComGameState_Unit(History.GetGameStateForObjectID(UnitRef.ObjectID));
- if (UnitState != none && UnitState.GetSoldierClassTemplateName() == 'Grenadier')
- {
- if (UnitState.AbilityTree[2].Abilities[0].AbilityName == 'Demolition')
- {
- `LOG("Demolition found", true, 'TacticalReloadNew2');
- UnitState = XComGameState_Unit(NewGameState.ModifyStateObject(class'XComGameState_Unit', UnitState.ObjectID));
- UnitState.AbilityTree[2].Abilities[0].AbilityName = 'TacticalReload';
- }
- }
- }
- foreach XComHQ.DeadCrew(UnitRef)
- {
- UnitState = XComGameState_Unit(History.GetGameStateForObjectID(UnitRef.ObjectID));
- if (UnitState != none && UnitState.GetSoldierClassTemplateName() == 'Grenadier')
- {
- if (UnitState.AbilityTree[2].Abilities[0].AbilityName == 'TacticalReload')
- {
- `LOG("Demolition found", true, 'TacticalReloadNew2');
- UnitState = XComGameState_Unit(NewGameState.ModifyStateObject(class'XComGameState_Unit', UnitState.ObjectID));
- UnitState.AbilityTree[2].Abilities[0].AbilityName = 'TacticalReloadr';
- }
- }
- }
- if(NewGameState != none)
- {
- `LOG("NewGameState is being submitted", true, 'TacticalReloadNew2');
- History.AddGameStateToHistory(NewGameState);
- }
- }
Advertisement
Advertisement