Author Topic: Bot StopFollowPlayer Event  (Read 218 times)

What I want to do, is have a bot that kind of acts like Barney in Half-Life 1. You can tell the bot to follow you, and tell the bot to stop. So far, I have the bot following the player with the FollowPlayer event, but I can't figure out how to make the bot stop AND still be able to shoot. The only way I figured out to make the bot stop following, is to set SetBotPowered to off. However, that just turns the bot completely off.

Basically, what I want is an event that does the opposite of the FollowPlayer event.

looks like it uses
Code: [Select]
%bot.hFollowType
%bot.hKeepFollowing
%bot.hFollowingNoDamage

and in the looping following code
Code: [Select]
if(%obj.hFollowingNoDamage == 0 && %obj.hFollowType != 1 && %obj.hFollowType != 2)
return;

so i suspect can just set all 3 values to 0 and hope it stops following?
Code: [Select]
function AIPlayer::stopFollowPlayer(%bot)
{
%bot.hFollowType = 0;
%bot.hKeepFollowing = 0;
%bot.hFollowingNoDamage = 0;
}

registerOutputEvent(Bot, "StopFollowPlayer", 1);

will test if i did the event syntax correctly in a bit, hopefully that works though if you put it in a server.cs in a folder in addons alongside a description.txt

Code: [Select]
function AIPlayer::stopFollowPlayer(%bot)
{
%bot.hFollowType = 0;
%bot.hKeepFollowing = 0;
%bot.hFollowingNoDamage = 0;
}

registerOutputEvent(Bot, "StopFollowPlayer", 1);
I ended up doing this, and it appears to only work when the bot is focused and kills another bot. I think you're on the right track though.

I have a different question:
could it be possible to make a script that does that the bots won't be too close to the player they follow?

for stopping bots, i'm guessing the bot is being told to follow the player somehow then, instead of the loop being needed
in which case i guess could have a dummy bot/player and tell the bot to follow that instead for a bit, or follow itself?

I have a different question:
could it be possible to make a script that does that the bots won't be too close to the player they follow?
should be possible, even if not simple/straightforward/easy