When running Team Deathmatch, I'm trying to make a simple way of having a brick as 'capturable' by teams which then triggers events. However, I'm running into some obscure problem I cannot figure out...
function TDMPointTriggerData::onTickTrigger(%this,%trigger)
{
%brick = %trigger.spawnBrick;
//... code cut out
if(%brick.tdmCaptureNum[%atkTeam] == 0)
{
if(%brick.tdmIsCaptured)
return;
%brick.setTeamAllied(%defTeam+1,%defClient);
}
else if(%brick.tdmCaptureNum[%atkTeam] == 100)
{
if(%brick.tdmIsCaptured)
return;
echo("-> POINT CAPTURED: " @ %atkclient SPC "(" @ %atkclient.name @ ")");
$cl = %atkclient;
%brick.setTeamAllied(%atkTeam+1,%atkClient);
}
else if(%brick.tdmIsCaptured)
{
%brick.tdmIsCaptured = 0;
%colAv = vectorScale(vectorAdd(%atkCol,%defCol),0.5) SPC 1;
%brick.setColor(getClosestPaintColor(%colAv));
}
}
This code works fine, and teams can capture the control points by standing on a brick created with it. The code echoes this when on Team 1 I capture a Team 2 control point:
-> POINT CAPTURED: 7316 (Space Guy)
... which indicates that everything is fine. $cl is saved for debugging, as is below. It then calls %brick.setTeamAllied with that same variable (%atkClient, here 7316)...
registerOutputEvent(fxDTSBrick,"setTeamAllied","list NONE 0 PLAYER 7 1 1 2 2 3 3 4 4 5 5 6 6",1);
function fxDTSBrick::setTeamAllied(%this,%team,%client)
{
echo("-> SET TEAM ALLIED: " @ %client SPC "(" @ %client.name @ ")");
echo("-> SAVED CLIENT = " @ $cl SPC "(" @ $cl.name @ ")");
//... code cut out
}
Immediately, at the start of the function, I echo the same variables that I just showed. But what I get...
-> SET TEAM ALLIED: ()
-> SAVED CLIENT = 7316 (Space Guy)
%client has disappeared, even though it should be the same as %atkclient I passed to the function. $cl still shows up as the correct value. What happened to it? Is it to do with the registerOutputEvent call? (I've set 'append client' to 1 which is used when I call it as an event, but that shouldn't affect it here)