Log player location every second (mutator) UT2004

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Alison

New Member
Jan 25, 2005
9
0
0
Hello

Im am trying to Log the location of every player, every second. Im doing this as part of an art project (read: shes an artist), so I apologise for my complete lack of programming knowledge.

Heres what I have so far (by foraging and guessing)...

Code:
class playerlocation extends mutator;

var() int counter;

event PreBeginPlay()
{
counter=0;
}

function ModifyPlayer(Pawn Other)
{

counter=counter+1;
Log( "spawn = " $ counter);
Log(Other.Location.X);
Log(Other.Location.Y);
Log(Other.Location.Z);

Super.ModifyPlayer(Other);

}


defaultproperties
{
FriendlyName="Spawn Points"
Description="please tell me whither I spawn"
}

This code works fine and tells me the location the player spawns and which overall spawn it is. This however is only part of what I want.
I found this code earlier on the forums...

Code:
class myDeathmatch extends xDeathmatch;

defaultproperties
{
defaultplayercontrollerclass=class'mypackage.myPlayerController'
}

Code:
class myPlayerController extends xPlayer;

exec function GetLocation()
{
log("My location is: "$Location);
}

defaultproperties
{
}

Which is good, but the location needs to be logged every second, using I assume a timer function like this one?

Code:
event PreBeginPlay()
{
    SetTimer(1.0,true);
}

function Timer()
{
}

My question is this, how can all these elements be combined to make a lovely fat log file of locations?
My problem at the moment I think lies with the timer, I simply cant get it to work with or in another function. Indeed judging by what ucc make keeps telling me functions cant go inside other functions. Im also trying to keep this as a mutator should I?

Any help with any of this would be appreciated, I have of course been trying to figure this out by myself and by using the wiki and many other "beginner to unrealscript" type sites, but well... I think my head has reached its code limit.

thanks
 

RegularX

Master of Dagoth Lies
Feb 2, 2000
1,215
0
0
Chicago, IL
In your mutator PreBeginPlay, have a SetTimer Function. Set the timer function to go into a function that will work against the level's Controller list and log the location of each pawn, if the pawn != none.

You can look at MutRegen for an example of mutators which operate against all the controllers on a timed basis. Basically instead of healing them, you'd be logging their pawn's location.

And I'd assume you want the pawn's location, not the controller's. The pawn is the actual representation of the player on the map.
 

Alison

New Member
Jan 25, 2005
9
0
0
thanks very much! I look at mutregen, messed around a bit and now it works!

Code:
class Watcher extends mutator;

var() int counter;

event PreBeginPlay()
{
    counter=0;
    SetTimer(1.0,true);
}

function ModifyPlayer(Pawn Other)
{
    
    counter=counter+1;
    Log( "spawn = " $ counter);
	Log("spawnxloc =" $Other.Location.X);
	Log("spawnyloc =" $Other.Location.Y);
	Log("spawnzloc =" $Other.Location.Z);

    Super.ModifyPlayer(Other);

}

function Timer()
{
    local Controller C;

    for (C = Level.ControllerList; C != None; C = C.NextController)
    {
	Log("movingxloc = " $C.Pawn.Location.X);
	Log("movingyloc = " $C.Pawn.Location.Y);
	Log("movingzloc = " $C.Pawn.Location.Z);
    }
}

defaultproperties
{
     FriendlyName="Watcher"
     Description="log spawn number and location. Log location of player every sec too."
}

thanks again :)
 

RegularX

Master of Dagoth Lies
Feb 2, 2000
1,215
0
0
Chicago, IL
Glad to help.

As an additional suggestion, I'd update Timer to be like this:

Code:
for (C = Level.ControllerList; C != None; C = C.NextController)
    {
	if(C.Pawn != None) {
          Log("movingxloc = " $C.Pawn.Location.X);
	  Log("movingyloc = " $C.Pawn.Location.Y);
	  Log("movingzloc = " $C.Pawn.Location.Z);
          }
    }

Controllers who have recently killed pawns or in other waiting positions will throw accessed nones otherwise, and by the looks of it - you'll have a big enough log file as it is.

Mind if I ask what kind of art project?
 

Alison

New Member
Jan 25, 2005
9
0
0
great timer update thanks :)
(I was wondering why I was getting warnings in the log file)

The art project thing is about generative worlds, and also about how people interact with their environment.

The idea is Im gonna take all the player position data and feed it in to another code churny program, to produce a 3D model of the level that was being played. Though obviously my one is going to look very different, only the parts of the map that have been active will be drawn so you'll get a level designed by the actions of the players on the original. If you get me... so any space that hasnt been used wont exist.

Its a bit wierd, but Im hoping its gonna look quite good in the end.