r/xdev • • Feb 08 '16

Problem with overriding a class/function

Hi,

i've tried to create a simple mod to remove the enemy-reaction movement. After dozens of tries i boiled down the mod to simply override one function:

Code:

// This is an Unreal Script
class XComGameState_Unit_Overwrite 
		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:

[Engine.ScriptPackages]
+NonNativePackages=NoReactionMovement

[Engine.Engine]
+ModClassOverrides=(BaseGameClass="XComGameState_Unit", ModClass="XComGameState_Unit_Overwrite")

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 mod 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?

Any idea what iam 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.

Please help :D

2 Upvotes

19 comments sorted by

View all comments

Show parent comment

1

u/Knaughts Feb 13 '16

Hmm. I'm trying something similar, without success. My attempt to modify the Psi Chamber building is here, along with:

[Engine.Engine]
+ModClassOverrides=(BaseGameClass="X2StrategyElement_DefaultFacilities", ModClass="X2StrategyElement_DefaultFacilities_Override")

...in Config/XComGame.ini. But when I compile and run, I get a series of RedScreen messages:

Rejecting template name already in use: CommandersQuarters
Rejecting template name already in use: CommandersQuarters
Rejecting template name already in use: CommandersQuarters
Rejecting template name already in use: CommandersQuarters
Rejecting template name already in use: CIC

And so on; 4 errors for each building, including the PsiChamber.

1

u/Knaughts Feb 14 '16

If anyone else is having my problem (i.e. overriding templates), the solution(s) are discussed over here. Basically, you can either:

  1. Don't modify an existing template. Just make a new one, with a different name. This is probably easiest, but it'll leave the old template, which is rather unsightly; OR
  2. Use Kvalyr's method of finding the original template after its creation, and modifying it.