CrossbowProjectile::onCollision - who shot me?
by Mike Stoddart · in Torque Game Engine · 05/19/2002 (7:58 pm) · 5 replies
I'm trying to implement basic team functionality, and mostly thanks to a resource on this site, I've managed that.
Next I want to implement friendly fire so that when you shoot someone, damage will only be inflicted if the person is not on your team.
I've added a variable called "team" into %client.
Inside CrossbowProjectile::onCollision, I need to know who fired the shot that hit this player, but how can I do that?
To test this, I would expect to shoot myself, and if friendly fire is on, I shouldn't get damaged.
Any suggestions greatly appreciated.
Thanks
Next I want to implement friendly fire so that when you shoot someone, damage will only be inflicted if the person is not on your team.
I've added a variable called "team" into %client.
Inside CrossbowProjectile::onCollision, I need to know who fired the shot that hit this player, but how can I do that?
To test this, I would expect to shoot myself, and if friendly fire is on, I shouldn't get damaged.
Any suggestions greatly appreciated.
Thanks
#2
05/19/2002 (9:29 pm)
In onFire() in rw/server/scripts/crossbow.cs, it looks like the code sets a "client" variable in the projectile object. Perhaps in the onCollision function, you could look for this client object and compare its team field.
#3
05/20/2002 (2:22 am)
in the onCollision(%this,%obj,%col,...), the target is %col and the guy that fired the projectile is %obj.client.player
#4
05/20/2002 (4:35 pm)
Thanks folks; I thought I had it earlier but I was wrong, hence the edited post.
#5
function Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
{
}
%obj.client is the target player that was hit
%sourceObject.client is the player that fired the shot
Thanks!!!
05/20/2002 (8:15 pm)
I got it working. In player.cs:function Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
{
}
%obj.client is the target player that was hit
%sourceObject.client is the player that fired the shot
Thanks!!!
Torque Owner Mike Stoddart