I search for solutions in this order: Past Code, Unreal Source, Wiki, BUF, groups.yahoo, google, screaming at monitor. – RegularX

User:00zX/Using The Unreal Engine 3 Preprocessor

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search

Including Macro Files

class YourPawn extends UTPawn

Example Macro File

When compiling with the -debug command line switch, the debug macro will then be defined and will switch our blank spaces to config/exec respectively.

 `define dconf
 `define dexec
 `define dconf config
 `define dexec exec

Copy the above template into a blank text document and call the file YourMacroFile.uci

Example of usage

If we want to add a variable thats configurable only when the macro `DevBuild is defined.

class YourPawn extends UTPawn
var `{dconf} bool	bCanDodge;
function bool Dodge(eDoubleClickDir DoubleClickMove)
		return Super.Dodge(DoubleClickMove);
		return false;



Example of usage

If we want to add a variable that already exists but is not config editable. (PostBeginPlay)

class YourPawn extends UTPawn
var `{dconf} float	newGroundSpeed;
function PossessedBy(Controller C, bool bVehicleTransition)
	Super.PossessedBy(C, bVehicleTransition);
	GroundSpeed = newGroundSpeed;

Useful Macros

 * 2005-2011 Daniel Batten (aka 00zX or MonsOlympus)
	/*`define redef(OldDef, NewDef) `undefine `{OldDef} `define `{OldDef} `{NewDef}*/
	/* Globals */
	`define sWorld_Info class'WorldInfo'.static.GetWorldInfo()
	`define sGame_RepInfo `{sWorldInfo}.GRI
	`define sGravity `{sWorldInfo}.WorldGravityZ
	`define sEngine class'Engine'.static
	/** Timers - checks the timers to see if they are active before setting or clearing them. */
	`define CheckClearTimer(name) if(IsTimerActive(nameof(`name))){ClearTimer(nameof(`name));}
	`define CheckSetTimer(time, loop, name) if(!IsTimerActive(nameof(`name))){SetTimer(`time, `loop, nameof(`name));}
	`define ResetTimer(time, loop, name) SetTimer(`time, `loop, nameof(`name))
	/** Variables and Defaults */
	`define SetToDefault(Obj, Var) `{Obj}.`{Var} = `{Obj}.Default.`{Var}
	`define SetVar(Obj, Var) `{Obj}.`{Var} = `{Var}
           //Usage: `SetVar(`P, MaxMultiJump) ~ where `P is UTPawn(Pawn) cast.
           //Outputs: UTPawn(Pawn).MaxMultiJump = MaxMultiJump; ~ Where UT Prefix can be a macro also.
	`define CheckRet(Obj) if(`Obj == none) return
	/** Save/Load Object */
	`define SaveObj(Obj, FileName, Bool, Ver) `sEngine().BasicSaveObject(`{Obj}, `{FileName}, `{Bool}, `{Ver})
	`define LoadObj(Obj, FileName, Bool, Ver) `sEngine().BasicSaveObject(`{Obj}, `{FileName}, `{Bool}, `{Ver})
	/** MetaTags */
	`define mUI(min, max) <UIMin=`min | UIMax=`max>
	`define mClamp(min, max) <ClampMin=`min | ClampMax=`max>
	`define mUIClamp(min, max) <UIMin=`min | UIMax=`max | ClampMin=`min | ClampMax=`max>
	/* Debugging */
	`define LogName 'Debug'
	`define LogdLine() `logd("------------------------------------------------------",,`{LogName});
	`define LogFunc(Name) `log(Self$"."$class.name$"."$GetFuncName()$"()",,`Name);
	`define LogdFunc() `logd(Self$"."$class.name$"."$GetFuncName()$"()",,`{LogName});
	`define LogF(string) `logd(GetFuncName()$"(): "$`{string},,`{LogName});
	/* Pawn */
	`define ColHeight CylinderComponent.CollisionHeight
	`define ColRadius CylinderComponent.CollisionRadius
	`define DefColHeight CylinderComponent.Default.CollisionHeight
	`define DefColRadius CylinderComponent.Default.CollisionRadius