Jump to content

new console commands?


CaveRat

Recommended Posts

Anyone knows if it's possible to create new exec functions (aka console commands)? I've tried extending various cheatmanager classes but nothing works. If i define a new exec function, I can see it in autocomplete list when typing in the console, but I always get "command not recognized" when I hit enter.

Edited by CaveRat
Link to comment
Share on other sites

I have been able to do that, and it works for me. I copied the function levelupbarracks in the hq cheat manager, and renamed it to levelupaliens. I must admit that I gave this mod privately to another modder here, and he reported just what you did, that he got "command not recognized". It does work for me, but there may be some bit I am missing to tell others.

Link to comment
Share on other sites

  • 1 month later...

I thought I'd post an update on this with my findings in case someone might find it useful. So far I have found two ways of making custom console commands work (not counting Highlander mod)

 

1.

 

First you need to decide which part of the game you need commands to work in (Tactical, Strategy). The game loads different GameInfo objects, each with their own PlayerController > CheatManager objects. Commands (exec functions) are defined in those CheatManager classes, and the hierarchy is as follows:

 

CheatManager

>XcomCheatManager

>XcomShellCheatManager (works in Main Menu)

>XcomHeadquartersCheatManager (Strategy)

>XcomTacticalCheatManager (Tactical)

 

So, if for example you want to make commands that work during Tactical play, first you need to do is create a class

that extends XcomTacticalCheatManager:

/*
*  Commands for Tactical Game
*/

class CustomTacticalCheatManager extends XcomTacticalCheatManager;

// test function
exec function TestCustomCommand()
{
	OutputMsg("Hello World"); // prints text to console window
}

Once you have that, all you need to do is define a ModClassOverride in the XcomEgine.ini

[Engine.Engine] 
+ModClassOverrides=(BaseGameClass="XcomTacticalCheatManager", ModClass="CustomTacticalCheatManager")

This is what I was originally missing, and why my commands failed to work. This method will work fine but as with all class overrides, you need to keep track of your XcomEngine.ini. If you want to use different CheatManager classes with different mods, this might become problematic. There is another way of doing it.

 

2. Set CheatManager at run time.

 

You still need your custom class, but you can call following function sometime during Tactical game:

/* 
* Sets up CheatManager in Tactical section
*/
function SetupTacticalCheatManager()
{
	local XcomTacticalController TPC;

	TPC = XcomTacticalController(class'WorldInfo'.GetWorldInfo().GetALocalPlayerController());
	if (TPC != none)
	{
		TPC.CheatManager = new(TPC) class'CustomTacticalCheatManager';
	}
}

Basically, it just grabs XcomTacticalPlayerController and instantiates new CheatManager class. I have run this via a UIScreenListener which is set to listen to UITacticalHUD, and it worked. No class overrides needed.

Link to comment
Share on other sites

For #1, please note XComTacticalCheatManager is "native core". When you attempt to extend it and write a ModOverride line, the game will not accept it. So for #1 you must make a highlander mod. I did not completely understand #2, but it may have the same problem.

 

I was able to extend XComHeadquartersCheatManager to add commands without any highlanders. I mentioned above that one other modder had some trouble using this. Since then both he, and another player who reported the problem, could solve the problem with the magic "remove and rebuild ini files" trick. So, for strategy level commands, there is a known solution. For tactical level, non-highlander, please confirm if you have made this work.

Link to comment
Share on other sites

For #1, please note XComTacticalCheatManager is "native core". When you attempt to extend it and write a ModOverride line, the game will not accept it. So for #1 you must make a highlander mod. I did not completely understand #2, but it may have the same problem.

 

Uh, I've tested the above without experiencing any problems.

 

Some native classes cannot be overridden - true, but CheatManager is "newed" via PlayerController script.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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