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

Legacy:BigHeadRules

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
UT2003 :: Actor >> Info >> GameRules >> BigHeadRules (Package: UnrealGame)

The BigHeadRules class affects the size of the Pawn's head after they have made a kill or died.

Properties[edit]

BigHeadMutator 
The MutBigHead object associated with this GameRules actor, which is used to GetHeadScaleFor after a controlled Pawn has successfully killed another Pawn.

Functions[edit]

ScoreKill ( Controller Killer, Controller Killed ) 
Alters the size of the Killer's head, based on Deaths vs Score, after any kill is made.

Source Code Walkthrough[edit]

This might be useful to further demonstrate custom GameRules scripting.

class BigHeadRules extends GameRules;
 
var MutBigHead BigHeadMutator;
 
function ScoreKill(Controller Killer, Controller Killed)
{
	if ( (Killer != None) && (Killer.Pawn != None) )
		Killer.Pawn.SetHeadScale(BigHeadMutator.GetHeadScaleFor(Killer.Pawn));
 
	if ( NextGameRules != None )
		NextGameRules.ScoreKill(Killer,Killed);
}
 
defaultproperties
{
}

First lets look after the action, at the use of the variable NextGameRules. NextGameRules is the next GameRules in the linked list of GameRules. If you neglect to add these two lines of code in a GameRules function, any GameRules loaded after this GameRules will not have a chance to augment play.

This simply states that if the Killer exists and that the Killer happens to be a Pawn, then in fact increase the size of the head on the Killer's Pawn. The size factor is determined by the function GetHeadScaleFor inside MutBigHead.

function float GetHeadScaleFor(Pawn P)
{
	local float NewScale;
 
	if ( abs(P.PlayerReplicationInfo.Deaths) < 1 )
		NewScale = P.PlayerReplicationInfo.Score + 1;
	else
		NewScale = (P.PlayerReplicationInfo.Score+1)/(P.PlayerReplicationInfo.Deaths+1);
	return FClamp(NewScale, 0.5, 4.0);	
}

Related Topics[edit]

Discussion[edit]

Burtlo: Thought I would use the subclasses as a great oppurtunity to show how GameRules work.

SuperApe: Fine idea. I've also used the code for this and MutVampire to learn about GameRules and Mutator classes. Nice and concice. :)