Question about class overrides

For technical discussions and help
Post Reply
Kulin
Posts: 2
Joined: Tue Feb 09, 2016 8:25 am

Question about class overrides

Post by Kulin »

Hi,

i hope its ok that i bother you with questions about this example. But at the moment it seems like nobody is able to help me in the 2k and reddit modding forums. I think modders new to xcom 2 have just not enough experience to answer this kind of question so i hope you guys can help me. :shock:

What i try to achieve is to change the scamper behavior. I would like to let all units on the map scamper once in the direction of the player(but don't automatically attack, just taking cover). They should react like a normal military unit that gets the radio call "enemy is attacking from the south". Then they should not get any more free movements(because this brings too much randomness in to the matches and removes tactics like diversionary tactics combined flank attacks completely from the game.

I tried to make this changes in the Class XComGameState_Unit by overriding the function UnitAGainsKnowledgeOfUnitB and boiled the code down to make it as easily readable as possible:

Code: Select all

// This is an Unreal Script
class XComGameState_Unit_Override extends XComGameState_Unit dependson(XComCoverInterface);

static function UnitAGainsKnowledgeOfUnitB(XComGameState_Unit UnitA, XComGameState_Unit UnitB, XComGameState AlertInstigatingGameState, EAlertCause AlertCause, bool bUnitAIsMidMove)
{
    `RedScreen("Override Successfull");
}
It also has this Ini-Entry:

Code: Select all

    [Engine.ScriptPackages]
    +NonNativePackages=NoReactionMovement
    
    [Engine.Engine]
    +ModClassOverrides=(BaseGameClass="XComGameState_Unit", ModClass="XComGameState_Unit_Override")
However: the red screen is never shown. And also if i copy the content of the original function it is never called.

I've uploaded the project here
https://www.dropbox.com/s/qiiu4czu2k...ement.zip?dl=0

Is it because the function is static? Or is it never called at all? Another modder gave me the tip that they probably call static function directly over the class name. For example "XComGameState_Unit.UnitAGainsKnowledgeOfUnitB(...)" and bypass all overrides by doing it.

That's why i searched for another function and found CanScamper in XComGameState_AIGroup. But again it does not want to work:

Code: Select all

// This is an Unreal Script
class XComGameState_AIGroup_Override
        extends XComGameState_AIGroup
        dependson(XComAISpawnManager, XComGameState_AIUnitData);

private function bool CanScamper(XComGameState_Unit UnitStateObject)
{
    return false;
}
Any idea what I'm doing wrong? It shows no errors on compilation or something. Tried it for hours in various ways but i have no clue what could be wrong.

Would be nice if someone with a clue could give me a hint. :)

Thanks!
Amineri

Re: Question about class overrides

Post by Amineri »

Sadly, gamestate classes are amongst the classes that cannot be overridden in this manner.

Because gamestates aren't always created at run-time, but get serialized into savefile as well. When I spoke with Firaxis about this, they indicated that they'd considering allowing overrides in this case, but that there were too many cases that could cause serious errors.
Kulin
Posts: 2
Joined: Tue Feb 09, 2016 8:25 am

Re: Question about class overrides

Post by Kulin »

Amineri wrote:Sadly, gamestate classes are amongst the classes that cannot be overridden in this manner.

Because gamestates aren't always created at run-time, but get serialized into savefile as well. When I spoke with Firaxis about this, they indicated that they'd considering allowing overrides in this case, but that there were too many cases that could cause serious errors.
Hi,

thanks for your answer. At least i know it was no problem on my side. That explains a lot. Guess i have to look for another anchor-point then. :)

Do you know if there is already list of classes that are not allowed to override?

And best of Luck with your own game! ;)
Post Reply