Author Topic: Making a Hole Bot only target specific teams  (Read 1856 times)

I'm trying to make a Cop bot that will attack people on a specific criminal team when he sees them, but is otherwise neutral. I've dug through the Bot_Hole code but still can't figure out how to do this. Does anyone know how?

Idk why the hell you'd dig through the code when it's a simple event function that exists already for bots, it's called setTeam.

Idk why the hell you'd dig through the code when it's a simple event function that exists already for bots, it's called setTeam.
Read carefully.

Read carefully.
From what I read, you can handle this perfectly with setTeam.

From what I read, you can handle this perfectly with setTeam.
If you just change the bot's team, it will attack everyone that is not on it's team. What I'm trying to achieve is a bot that will target and attack people on a specific team if it sees them, but is neutral to everyone that is NOT on that team.

If you just change the bot's team, it will attack everyone that is not on it's team. What I'm trying to achieve is a bot that will target and attack people on a specific team if it sees them, but is neutral to everyone that is NOT on that team.
You could prob do this with VCE then and BotSight or BotNewTarget events then and just keep the cop on a neutral team.

probably can take a peek at the code and see if its easy enough to make

In case anyone else ever needs to do this, I found a way how.
Just set the bot's hType (team) to Neutral, then add the following code to the bot's loop:
Code: [Select]
function ExampleHoleBot::onBotLoop(%this, %obj)
{
    //hReturnCloseBlockhead code, with a couple of tweaks.
    %type = $TypeMasks::PlayerObjectType;
    %pos = %obj.getPosition();
    %scale = getWord(%obj.getScale(),0);
    %radius = brickToRadius( %obj.hSearchRadius )*%scale;

    initContainerRadiusSearch(%pos,%radius,%type);
    while((%target = containerSearchNext()) != 0)
    {
        %target = %target.getID();

// take into consideration LOS
if( %target != %obj && !%target.isCloaked && hLOSCheck( %obj, %target ) )
{
            if(%target.hType $= "TeamToAttack") //Check the target's team to make sure it's the specific team that needs to be attacked. Not put into the above line for readability.
            {
               // remember to check FOV before continuing
       if( %obj.hSearchFOV )
       {
           if( %obj.hFOVCheck( %target ) )
                   {
                        %obj.hFollowPlayer( %target, 1, 0 ); //Makes the bot attack the target if it's team matches.
                   }
        }
            }
        }
        else
        {
            if(%target.hType $= "TeamToAttack")
            {
                %obj.hFollowPlayer( %target, 1, 0 );
            }
        }
    }
}
Thanks to both of you for the help.
« Last Edit: June 05, 2021, 02:43:43 PM by RobbinsonBlock »