Author Topic: Registering an input event without a client feild?  (Read 635 times)

Basically I want a global event to trigger an input event for all bricks...
Code: [Select]
registerInputEvent("fxDTSBrick", "onNewDay", "Self fxDTSBrick");

function fxDTSBrick::onNewDay(%obj,%c)
{
   $InputTarget_["Self"]   = %obj;
   %obj.processInputEvent("onNewDay",%c);
}
This defines the event.
And this triggers it as a part of a function...
Code: [Select]
for(%cs=0;%cs<clientgroup.getcount();%cs++)
{
%client = clientgroup.getobject(%cs);
if(isObject(%client))
{
%brickgroup = %client.brickgroup;
if(isObject(%brickgroup))
{
for(%bs=0;%bs<%brickgroup.getcount();%bs++)
{
%brick = %brickgroup.getobject(%bs);
if(isObject(%brick))
%brick.onNewDay(clientgroup.getobject(0));
}
}
}
}
But as you see, I use %brick.onNewDay(clientgroup.getobject(0)); just putting in a random client to get around it, this seems to have no effect as the input event has no client output, but I feel it is bad practice, is there anyway around a client field or will this work?

I used to create a AIConnection lasting for the duration of the input event function and slightly after the .processInputEvent, and it seems to work nicely.

So how would I do that, anyhow.

Code: [Select]
%cl = new AIConnection() {
    name = "";
    bl_id = -1;
};

...

Code: [Select]
%cl.delete();
// or
%cl.schedule(..., delete);

GameMode_ZAPT/scripts/function.cs

Code: [Select]
registerInputEvent("fxDTSBrick", "onZombieSpawned", "Self fxDTSBrick" TAB "Bot Player" TAB "MiniGame MiniGame"TAB "OwnerPlayer Player" TAB "OwnerClient GameConnection");

Code: [Select]
function fxDTSBrick::onZombieSpawned(%this, %obj)
{
$InputTarget_["Self"] = %this;

if(zombieBot(%obj))
{
$InputTarget_["Bot"] = %obj;
}
else
{
$InputTarget_["Bot"] = -1;
}

$InputTarget_["MiniGame"] = getMiniGameFromObject(%this);

if(isObject(%this.getGroup().client))
{
if(isObject(%this.getGroup().client.player))
{
$InputTarget_["OwnerPlayer"] = %this.getGroup().client.player;
}

$InputTarget_["OwnerClient"] = %this.getGroup().client;
}
else
{
$InputTarget_["OwnerPlayer"] = -1;
$InputTarget_["OwnerClient"] = -1;
}

%this.processInputEvent("onZombieSpawned", %obj);
}