Jump to content

PSA: Where to find the definitions of Firaxis' UnrealScript macros


Kvalyr

Recommended Posts

UnrealScript's syntax has a nasty amount of boilerplate involved, especially when doing things like calling static functions:

class'SomeClassWithAVerboseNameToAvoidConfusion'.static.SomeVerboselyNamedFunction(args);

Firaxis make heavy use of preprocessor macros in their code to make it easier to do things like fetch the game's presentation layer, screenstack or game state; or create a new template.
`PRES
`SCREENSTACK

`XCOMGAME
`CREATE_X2ABILITY_TEMPLATE
etc.

 

Macros are normally defined with file-level scope only, but global macros can be defined by placing them in a 'Globals.uci' file at the root of a project.

Firaxis' macros for XCOM2 can be found here:

XCOM 2 SDK\Development\Src\Core\Globals.uci

Seeing those might make it a little easier to decipher what Firaxis' code is doing in places where macro use is heavy.

 

Example from Globals.uci:

`define XWORLDINFO class'Engine'.static.GetCurrentWorldInfo()
`define XCOMGAME XComGameInfo(class'Engine'.static.GetCurrentWorldInfo().Game)
`define REPLAY XComTacticalGRI(class'WorldInfo'.static.GetWorldInfo().GRI).ReplayMgr
`define TUTORIAL XComTutorialMgr(XComTacticalGRI(class'WorldInfo'.static.GetWorldInfo().GRI).ReplayMgr)
`define XCOMHISTORY class'XComGameStateHistory'.static.GetGameStateHistory()
`define XCOMHQ class'UIUtilities_Strategy'.static.GetXComHQ()
`define XCOMNETMANAGER class'XComGameStateNetworkManager'.static.GetGameStateNetworkManager()
`define XCOMVISUALIZATIONMGR XComGameReplicationInfo(class'Engine'.static.GetCurrentWorldInfo().GRI).VisualizationMgr
`define XENGINE XComEngine(class'Engine'.static.GetEngine())
`define XCOMGRI XComGameReplicationInfo(class'Engine'.static.GetCurrentWorldInfo().GRI)
`define TACTICALGRI XComTacticalGRI(`XCOMGRI)
`define SOUNDMGR XComGameReplicationInfo(class'Engine'.static.GetCurrentWorldInfo().GRI).GetSoundManager()
`define XTACTICALSOUNDMGR XComTacticalSoundManager(`SOUNDMGR)
`define XSTRATEGYSOUNDMGR XComStrategySoundManager(`SOUNDMGR)
`define XWORLD class'XComWorldData'.static.GetWorldData()
`define PRES XComPresentationLayer(XComPlayerController(class'WorldInfo'.static.GetWorldInfo().GetALocalPlayerController()).Pres)
`define PRESBASE (XComPlayerController(class'WorldInfo'.static.GetWorldInfo().GetALocalPlayerController()).Pres)
`define TOOLTIPMGR XComPlayerController(class'WorldInfo'.static.GetWorldInfo().GetALocalPlayerController()).Pres.m_kTooltipMgr
`define SCREENSTACK XComPlayerController(class'WorldInfo'.static.GetWorldInfo().GetALocalPlayerController()).Pres.ScreenStack
`define CONTENT XComContentManager(class'Engine'.static.GetEngine().GetContentManager())
`define MAPS XComMapManager(class'Engine'.static.GetEngine().GetMapManager())
`define XPROFILESETTINGS XComOnlineProfileSettings(class'Engine'.static.GetEngine().GetProfileSettings())
`define ONLINEEVENTMGR XComOnlineEventMgr(class'Engine'.static.GetEngine().OnlineEventManager)
`define AUTOSAVEMGR XComGameReplicationInfo(class'Engine'.static.GetCurrentWorldInfo().GRI).GetAutosaveMgr()
`define XEXPAND class'XComLocalizer'.static
`define XMCP class'XComMCP'.static
`define XEXPANDCONTEXT XComEngine(class'Engine'.static.GetEngine()).LocalizeContext
`define XANIMNAME(a) XComGameReplicationInfo(class'Engine'.static.GetCurrentWorldInfo().GRI).AnimMapping[`a]
`define XEVENTMGR class'X2EventManager'.static.GetEventManager()
`define SPAWNMGR class'XComAISpawnManager'.static.GetSpawnManager()
`define TRIGGERXP(EventName,XpEarn,XpGrant,GameState) class'X2EventManager'.static.GetEventManager().TriggerEvent(`EventName,class'XpEventData'.static.NewXpEventData(`XpEarn,`XpGrant),,`GameState)

Link to comment
Share on other sites

  • 2 weeks later...
  • Recently Browsing   0 members

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