Undo client::setownedobject()

bugs_
04-07-2007, 10:08 PM
So I got sidetracked on some deployable turret stuff. In zadmin and fstat
these lines are present but commented out in the deploy turret code:

// Client::setOwnedObject(%c lient, %turret);
// Client::setOwnedObject(%c lient, %player);

In normal zadmin the turret wouldn't be associated with the deployer and
the server logs the turret kills to killerId 0 in Client::onKilled()

if (!%killerId)
{
//turret
%damageType = $EnergyDamageType;
messageAll(0, strcat(%victimName, " dies."), $DeathMessageMask);
%playerId.scoreDeaths++ ;
}

So the kill isn't awarded to anyone and even the death is apparently not
tallied. I added the "%playerId.scoreDeaths++ ;" line to keep track of
this.

If you uncomment those Client::setOwnedObject lines you start getting some
nicer turret kill messages and the scoring can give the turret kill points
to the deployer.

My problem is disassociating the turret from the deployer when the deployer
drops or changes teams. I have tried a couple of things to get this to
happen and I have run out of ideas.

Does anyone know of a scripting way to undo the client::setownedobject() or
is it necessary to code an unsetownedobject() mem.dll function?

Amadeus
04-08-2007, 06:40 AM
Keep a list of the turrets that a player deployed?

Lemon
04-08-2007, 10:41 AM
The object owner code is commented out in default base scripts as well btw. I have a couple of ideas that I'll work through today.

I'm starting here...

echo("MSG: "@Client::getname(%client) @" deployed a Remote Turret("@%turret@") at "@$los::position);

EDIT:
false start...


//if (!%killerId)
if (%damagetype==2)
{
//turret
//%damageType = $EnergyDamageType;
%checkturret=%killerId.ow nsturrets;
if (Client::getteam(%killerI d)==Client::getteam(%play erid) || Client::getteam(%killerid )==-1 || %checkturret!=true)
{
//Client::AdjustScore(%play erId, "TurretDeath"); // lose a point for an 'unowned' turret death?
messageAll(0, strcat("A turret kills "@%victimName@"."));
}
else
{
messageAll(0, strcat(Client::GetName(%k illerId)@ " kills "@%victimname@" with a turret."));
Client::AdjustScore(%kill erId, "TurretKill");
Client::AdjustScore(%play erId, "TurretDeath");
}
}



// Remote turrets - kill points to player that deploy them
Client::setOwnedObject(%c lient, %turret);
Client::setOwnedObject(%c lient, %player);
%client.ownsturrets=true;

on disconnect
%clientId.ownsturrets=fal se;


code.ratings.cs

//$Stats::Rating["Turret"] = 0;
$Stats::Rating["TurretKill"] = 1;
$Stats::Rating["TurretDeath"] = -1;

Plasmatic
04-08-2007, 08:02 PM
I wrangled with this for a while allready. Projectiles are tagged with the client ID when fired, based on the firing objects controling client. When the client switches teams this causes problems with turrets, when the player dies, this creates problems with spawning peolectile code (based on player object)

Following the script, it looks like they had planned on changing it somewhere down the line, look at player::ondamage for example. The function uses %shooterObject, but the game passes a client id to it.

The best workaround I've found is creating new damage types for the turrets, and do an additional check to see which team the client is on. If they're on a same team, and team damage is off eliminate the tk message, if tk is on, and the turret is auto fire only change the death message, etc..

Lemon
04-10-2007, 06:37 PM
Funnily enough my first thought was "Ask Plasmatic" but I figured you'd see the thread and I was bored enough to give it a shot. Fun stuff.

Plasmatic
04-11-2007, 05:44 AM
I do have a forum for this stuff.. ;) Annihilation.info :: Index (http://www.annihilation.info)

ManyLith
04-11-2007, 09:21 AM
Good Site Plas..needs a Nice Banner and some more downloads though lol

Plasmatic
04-14-2007, 03:32 PM
Thanks, and yes, I know. I need a few good banners.