Typecasting Mutator?

Discussions about Coding and Scripting
Post Reply
User avatar
ANUBITEK
Adept
Posts: 261
Joined: Sun Dec 28, 2014 1:10 am
Location: Anubitek

Typecasting Mutator?

Post by ANUBITEK »

I'm working on an event in a PlayerPawn code that, when "UpdateStats()" is called, should tell the current level mutator to run a function "StatsActivated()". Problem is that I'm running into an error when I attempt to typecast the mutator class. I'm fairly certain I'm typecasting incorrectly though, so how would I do this correctly?

Code: Select all

Error: C:\GOG Games\Unreal Gold\RPG_Game_dev\Classes\RPG_PlatformPawn.uc(150) : Error, Unrecognized member 'StatsActivated' in class 'Class'
Error: C:\GOG Games\Unreal Gold\RPG_Game_dev\Classes\RPG_PlatformPawn.uc(150) : Error, '(': Expression has no effect
Error: C:\GOG Games\Unreal Gold\RPG_Game_dev\Classes\RPG_PlatformPawn.uc(150) : Error, Missing ';' before ')'

Code: Select all

var bool bNeedsStatsSaved;
var class<RPG_GameMutator> CustomMut;

event UpdateStats()
{
	CustomMut = class'RPG_GameMutator';
	if ( bNeedsStatsSaved == true && Level.Game.MutatorClass == class'RPG_GameMutator' )
		CustomMut.StatsActivated();
		bNeedsStatsSaved = false;
}
EDIT:
I would assume that the following quote might have something to do with this, but I don't quite understand what I'm reading:
Unfortunatly it does not work. I tried it out myself, you cant typecast (metacast / reference typecast) actor references to object references or vice versa OR (like in the example) object reference to object reference, because Objects don't exist in a map, they exist in a raw UnrealEngine environment. You can only reference to an object of that class by using the "new" command creating a new object instance of that class. Checking if a class (typecasted or not) is NOT none is save, because it's indeed none, but won't get you anything after "if (expression != none)". Always use new command or the dynamicloadobject function for these.
<<| http://uncodex.ut-files.com/ |>>

Code reference for UGold, UT99, Unreal2, UT2k3, UT3
Additional Beyond Unreal Wiki Links
wiki.beyondunreal.com/Legacy:Console_Bar
wiki.beyondunreal.com/Exec_commands#Load
wiki.beyondunreal.com/Legacy:Exec_Directive#Loading_Other_Packages
wiki.beyondunreal.com/Legacy:Config_Vars_And_.Ini_Files
wiki.beyondunreal.com/Legacy:INT_File
User avatar
Wormbo
Adept
Posts: 258
Joined: Sat Aug 24, 2013 6:04 pm
Contact:

Re: Typecasting Mutator?

Post by Wormbo »

Yopu don't have a mutator there, but a class with instructions on how to construct a mutator. That class only has access to default values and static functions for such a mutator's properties, so you need to tell the compiler that you want to access those default properties or static functions, not the class instance's properties and functions.

(Unreal Wiki is currently up again, so I'm linking that.)
Post Reply