Typecasting game type?

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

Typecasting game type?

Post by ANUBITEK »

I need to grab the game type I have in my level (in this case, class'RPG_Game') but I do not know how to do this. I am trying to check a gametype specific variable, which is in RPG_Game, called "bDirectionaSprites". How can I access this variable for a sanity check in the following function?

Code: Select all

function SpawnSpriteAnimation( SpriteAnimation sAnimation, optional name Tag, optional bool bDirectionalSprites )
{
	local RPG_Game GameMode;
	
	if ( Level.Game != none && Level.Game == class'RPG_Game')
	{
		sAnimation = new( None, 'AnimationObj') class'SpriteAnimation';
		sAnimation.bDirectionalSprites = Level.Game.bDirectionalSprites;
		sAnimation.Tag = Tag;
	}
}
OffTopic
Also here is some Saint Pepsi, enjoy~
_hI0qMtdfng
<<| 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
Barbie
Godlike
Posts: 2792
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Typecasting game type?

Post by Barbie »

Code: Select all

sAnimation.bDirectionalSprites = RPG_Game(Level.Game).bDirectionalSprites;
:?:
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
ANUBITEK
Adept
Posts: 261
Joined: Sun Dec 28, 2014 1:10 am
Location: Anubitek

Re: Typecasting game type?

Post by ANUBITEK »

Oh shit, I was doing this backward. I was inserting Level.Game(RPG_Game). Another way I found out how to do this was to put a variable in the actor I was working on, then have a my game mode do a postbeginplay search for all spriteanimationmanagers, then assign the game type itself to the variable sitting in the actor I am working on:

Code: Select all

	ForEach AllActors (class'SpriteAnimationManager', AnimManager)
	{
		AnimManager.GameMode = self;
		if ( AnimManager.bHasSpriteActor != true )
		{
			AnimManager.SpawnSpriteAnimation( sAnimation, AnimManager.tag, self.bDirectionalSprites );
		}
	}
<<| 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
Post Reply