Jump to content

adding custom characters to barracks


eggroll666

Recommended Posts

so i created a custom character but i'm having difficulties adding him into the game whether it be a fresh game or pre-existing save.

this is what i'm using to try to load him in.

 

 

 

 

//---------------------------------------------------------------------------------------
// FILE: XComDownloadableContentInfo_MyXCOM2Mod.uc
//
// Use the X2DownloadableContentInfo class to specify unique mod behavior when the
// player creates a new campaign or loads a saved game.
//
//---------------------------------------------------------------------------------------
// Copyright © 2016 Firaxis Games, Inc. All rights reserved.
//---------------------------------------------------------------------------------------
class X2DownloadableContentInfo_MyXCOM2Mod extends X2DownloadableContentInfo;
static event OnLoadedSavedGame()
{
local XComGameStateHistory History;
local XComGameState NewGameState;
local XComGameState_HeadquartersXCom OldXComHQState;
local XComGameState_HeadquartersXCom NewXComHQState;
local XComGameState_Unit ItemState;
local X2CharacterTemplateManager ItemMgr;
local X2CharacterTemplate ItemTemplate;
local CharacterPoolManager CharMgr;
//In this method, we demonstrate functionality that will add ExampleWeapon to the player's inventory when loading a saved
//game. This allows players to enjoy the content of the mod in campaigns that were started without the mod installed.
ItemMgr = class'X2CharacterTemplateManager'.static.GetCharacterTemplateManager();
History = `XCOMHISTORY;
//Create a pending game state change
NewGameState = class'XComGameStateContext_ChangeContainer'.static.CreateChangeState("Adding CoconutMonkey");
//Get the previous XCom HQ state - we'll need it's ID to create a new state for it
OldXComHQState = XComGameState_HeadquartersXCom(History.GetSingleGameStateObjectForClass(class'XComGameState_HeadquartersXCom'));
//Make the new XCom HQ state. This starts out as just a copy of the previous state.
NewXComHQState = XComGameState_HeadquartersXCom(NewGameState.CreateStateObject(class'XComGameState_HeadquartersXCom', OldXComHQState.ObjectID));
//Make the changes to the HQ state. Here we add items to the HQ's inventory
ItemTemplate = ItemMgr.FindCharacterTemplate('CoconutMonkey');
//Instantiate a new item state object using the template.
ItemState = ItemTemplate.CreateInstanceFromTemplate(NewGameState);
NewGameState.AddStateObject(ItemState);
//Add the newly created item to the HQ inventory
ItemState.SetSkillLevel(5);
NewGameState.AddStateObject(ItemState);
NewXComHQState.AddToCrew(NewGameState, ItemState);
ItemState.SetHQLocation(eSoldierLoc_Barracks);
NewXComHQState.HandlePowerOrStaffingChange(NewGameState);
//Commit the new HQ state object to the state change that we built
NewGameState.AddStateObject(NewXComHQState);
//Commit the state change into the history.
History.AddGameStateToHistory(NewGameState);
}
/// <summary>
/// Called when the player starts a new campaign while this DLC / Mod is installed
/// </summary>
static event InstallNewCampaign(XComGameState StartState)
{
//Don't need to do anything - the weapon should be picked up and placed into the HQ inventory when starting a new campaign.
}
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...