Who shot the bot
by Howard Dortch · in Torque Game Engine · 08/22/2004 (3:23 pm) · 8 replies
This function gets called when I shoot a bot:
function Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
I have tried to get who shot the bot so the bot can select a client as a target but can't tell how to get it from this. Anyone know which parameter will give me who shot the bot?
function Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
I have tried to get who shot the bot so the bot can select a client as a target but can't tell how to get it from this. Anyone know which parameter will give me who shot the bot?
#2
Take the mp5 for instance:
function mp5Projectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
I can't tell from this who fired the bullit. Then in this function radius damage is called
radiusDamage
(%obj, VectorAdd(%pos, VectorScale(%normal, 0.01)),
%this.damageRadius,%this.radiusDamage,"Radius",40);
Still can't tell who fired the bullit. and radius damage calls Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
Here the %sourceObject is the bullit no?
At least I think this is how it works.
08/23/2004 (4:39 am)
Actually I'm workin from the bot backwards So the bot wants to know who shot it so it can return fire or chase.Take the mp5 for instance:
function mp5Projectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
I can't tell from this who fired the bullit. Then in this function radius damage is called
radiusDamage
(%obj, VectorAdd(%pos, VectorScale(%normal, 0.01)),
%this.damageRadius,%this.radiusDamage,"Radius",40);
Still can't tell who fired the bullit. and radius damage calls Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
Here the %sourceObject is the bullit no?
At least I think this is how it works.
#3
I might have the syntax a bit off but I think you see the Idea
08/23/2004 (4:45 am)
Something along the lines of function mp5Projectile::onCollision(%this,%obj,%col,%fade,%pos,%normal){
if(%col.isAiControlled())
%col.BotReturnFire(%obj.sourceObj); //or %obj.client
}
function AIPlayer::BotReturnFire(%this, %bot, %enemy){
$bot.setAiming(%enemy);
}I might have the syntax a bit off but I think you see the Idea
#4
08/23/2004 (4:51 am)
Make sure you have the sourceSlot set on the projectile. When you fire the projectile you can set a var on it telling who fired it. If %sourceObject is the projectile, then you can get that var from it. If you are not sure what %sourceObject is, just do an echo on it in the console.
#5
I think rather than having to put code in every weapon that it probably should be called from player since player code is used for bots as well.
@Ward I'm able to track it through to player but dont know how to determine if it's a human(me) or a bot. Anthony has the idea for a quick test but I can't make that part work.
08/23/2004 (7:34 am)
@anthony isAIControlled fails as unknown no matter what I call it with.I think rather than having to put code in every weapon that it probably should be called from player since player code is used for bots as well.
@Ward I'm able to track it through to player but dont know how to determine if it's a human(me) or a bot. Anthony has the idea for a quick test but I can't make that part work.
#6
if (%col.getclassName() $= "player" for human
if (%col.getclassName() $= "aiplayer" for a bot
08/23/2004 (8:42 am)
Howard tryif (%col.getclassName() $= "player" for human
if (%col.getclassName() $= "aiplayer" for a bot
#7
08/24/2004 (4:02 am)
When in doubt use %obj.dump() to find what can be used
#8
The projectile structure has a member called sourceObject as the player that shot the bullit so when fired, the bullit knows who fired it.
in this function:
function Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
sourceObject is the bullit and since the bullit struct has a member sourceObject as the shooter ( good god that's not confusing ) I can do this in the Armor::damage
if(%obj.getClassName() $= "AIPlayer")
{
%obj.BotReturnFire(%sourceObject.sourceObject);
}
now the bot can get the position of who shot the bot...../sigh
I put the call to bot return fire here instead of doing it for each weapon this way no matter what weapon was fired at the bot it will return fire. So I'm not sure what other damage the bot can take in game that would mess this up.
Thanks all for your help and can we keep this going a bit more for input?
08/24/2004 (5:53 am)
Well I solved the problem and probably caused other problems so one of you wizzards please tell me what I screwed up doing this. The projectile structure has a member called sourceObject as the player that shot the bullit so when fired, the bullit knows who fired it.
in this function:
function Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
sourceObject is the bullit and since the bullit struct has a member sourceObject as the shooter ( good god that's not confusing ) I can do this in the Armor::damage
if(%obj.getClassName() $= "AIPlayer")
{
%obj.BotReturnFire(%sourceObject.sourceObject);
}
now the bot can get the position of who shot the bot...../sigh
I put the call to bot return fire here instead of doing it for each weapon this way no matter what weapon was fired at the bot it will return fire. So I'm not sure what other damage the bot can take in game that would mess this up.
Thanks all for your help and can we keep this going a bit more for input?
Associate Anthony Rosenbaum
So when the particle's onCollision is called the appropraite player, the one who fired the shot, can recieve points or punishment in this matter.