PDA

View Full Version : hud mutator


_U][B_StoneRain
18th Nov 2001, 08:38 PM
class myMutator extends Mutator;

var bool isInitialized;

function PostBeginPlay()
{
if ( isInitialized ) return;
isInitialized = True;
RegisterHUDMutator();
}
Function Tick (float Deltatime)
{
Super.Tick(DeltaTime);
if (!bHudMutator) RegisterHUDMutator();
}
simulated event PostRender ( canvas C)
{
..... C.DrawText("....."); .... // do the drawing here
C.Reset();
if ( NextMutator != None )
{
NextMutator.PostRender ( C );
}
}

what is wrong with this code ? locally on my pc it works fine but it doesn't run on our server. simply no effect at all. adding the mutator to the serverpackages only resultet in having to download it. may this be an issue with UTPure ?

another problem is that the mutator does not work in combination with other mutators that change the hud. if i select several mutators only the first in the list changes the hud.

even this version from the tutorials shows the same effects:


smartT.uc
-------------
class smartT expands Mutator;
function PreBeginPlay()
{
spawn(class'smartT.THUDNotify');
}


THUDNotify.uc
------------------
class THUDNotify expands SpawnNotify;
simulated event Actor SpawnNotification( Actor A )
{
if ( HUD(A).HUDMutator == none )
{
HUD(A).HUDMutator = spawn(class'smartT.THUD',A);
}
else
{
HUD(A).HUDMutator.AddMutator(spawn(class'smartT.THUD',A));
}
return A;
}

defaultproperties
{
ActorClass=class'Engine.HUD'
}


THUD.uc
-----------
class THUD extends Mutator;
var bool isInitialized;
function PostBeginPlay()
{
if ( isInitialized ) return;
isInitialized = True;
RegisterHUDMutator();
}
Function Tick (float Deltatime)
{
Super.Tick(DeltaTime);
if (!bHudMutator) RegisterHUDMutator();
}
simulated function PostRender ( canvas C)
{
C.Draw.........
C.Reset();
if ( NextMutator != None )
{
NextMutator.PostRender ( C );
}
}

Mychaeel
18th Nov 2001, 08:58 PM
Add the following default properties to your mutator class:
bAlwaysRelevant=true
bAlwaysTick=true
RemoteRole=ROLE_SimulatedProxy
Make your mutator's Tick function simulated, and you can also scratch the whole SpawnNotify hack.

usaar33
18th Nov 2001, 09:35 PM
check out my tuty on linked lists for the proper way to have a HUD mutator in netplay.

_U][B_StoneRain
18th Nov 2001, 09:55 PM
the mutator runs and the Sender.ClientMessage("...") in the mutate function works, but still no change in the hud. and one hud mutator still overrides all other hud mutators.

when do I have to add a line at serverpackages ?
afaik simulated means that the functions are called on all clients. which functions must be simulated, only Tick & PostBeginPlay & functions like that or all functions I implemented in the mutator ?

/edit 02:58/
on my way :)

Mychaeel
18th Nov 2001, 10:08 PM
All functions you want to run on the client too.

If you omit the ServerPackages entry, the HUD won't show up on clients. For the attached sample, that would be:ServerPackages=MyHUDMutator

_U][B_StoneRain
18th Nov 2001, 10:39 PM
BIG TNX to you all, now it works :)

I read all tuties on hud mutators but didn't expect the best infos in a tuty about linked lists. I put the whole spawn notify crap in the trashcan, someone should update the hud tuties and replace the code examples with the code from Mychaeel's zip

@Mychaeel
oh je, nachher um 8:00 klingelt wieder der Wecker, aber jetzt kann ich endlich beruhigt schlafen gehen :P