Game Development Community

My dead bad guys still shoot at me! help

by Jesse P · in Technical Issues · 11/17/2007 (4:21 pm) · 8 replies

I used the aiGuard.cs script from Ken Finney's Advanced 3d Game Programming book to place an AI bad guy in my game, it works but the problem is that when the player kills the bad guy his dead body still shoots at the player. I'm not much of a coder and have been banging my head on my desk over this for a couple of days now. Any suggestions? Thanks

#1
11/20/2007 (6:43 pm)
I have one suggestion: In the AIGuard::onDeath function (or what ever it is), find the last two schedule functions, then delete them and replace them with the scheduled functions. Confused? It will delete the dead guard right away, but deleted objects can't shoot! ;)
#2
11/20/2007 (11:15 pm)
Hey thanks, didn't try that but what I did to solve the problem was when the guard dies I set the attention, agression, etc. all to zero by just adding a few lines such as %obj.attention = 0;

Now I've gotta figure out the next problem and that's the fact that my guards really suck, they keep loosing me and then just sitting there and not shooting at me. They've been doing that since the beginning before I fixed the shooting after death problem. hmm, what I need to do is recruit someone who knows AI to help me on this project pro-bono
#3
11/21/2007 (5:39 am)
Jesse, there are 2 really good resources here dealing with aiGuards. Do a search for AIGuard and Killer Kork. I know the aiguard and aipatrol resources work great. (they are companion resources). I haven't tried Killer Kork, but eather one would be good places to look to see how to fix your code.
#4
11/21/2007 (11:29 am)
Thanks I'll check em' out. I heard the Killer Kork hits on performance though and I need something real light. I'll take a look at it though to see what may be wrong. Thanks
#5
11/22/2007 (6:35 am)
Deassert his trigger finger trigger when he dies.
#6
12/24/2007 (2:34 am)
Hi I oso have the same problem..my bot still shoot after i die or when the bot dies. My bot uses the player death animation. My code is that when a player is within the range of the bot, the bot will shoot at me. For the bot shooting i use
%this.setImageTrigger(0,true);
.

So when the bot dies i do not know where to put
%this.setImageTrigger(0,false);
. Any help?
#7
12/24/2007 (1:52 pm)
Thanks, I had fixed it by setting his attention level and aggression level to 0 when he dies
#8
01/03/2008 (7:21 pm)
@rushh

Add this to your AIPlayer.cs (or AIGuard.cs)

function AIPlayer::onDisabled(%this,%obj,%state)
{
// The player object sets the "disabled" state when damage exceeds
// it's maxDamage value. This is method is invoked by ShapeBase
// state mangement code.

// If we want to deal with the damage information that actually
// caused this death, then we would have to move this code into
// the script "damage" method.
%obj.playDeathCry();
%obj.playDeathAnimation();
%obj.setRepairRate(0);
%obj.setRechargeRate(0);
%obj.clearDamageDt();
%obj.schedule(50000, "startFade", 5000, 0, true);
%obj.schedule(100000, "delete");
%obj.setImageTrigger(0,false);
%obj.attentionlevel = 0;

return;
}

If you are using the AIGuard, then you would have to change the top to

function AIGuard::onDisabled(%this,%obj,%state)

This should stop the bot from shooting you when it's dead.