Author Topic: Preventing AIPlayers from attack your feet  (Read 1027 times)

When you use %bot.setAimObject(%player); It makes them aim at your feet, is there a way to make them aim at your body?
« Last Edit: November 06, 2007, 03:22:04 PM by MrPickle »

You have to add to the Z of where the bot is aiming, not sure how you would do that with aimobject.

Yeah, That's what I needed help with. I don't want to use aim location because that'd require schedules which'd result in lag when their's several bots.

Unless Badspot knows a way, I don't think it's possible.  The aiming is controlled with engine code.


However, if you make some sort of script object to manage the schedules of all the bots, it shouldn't be too bad.  You would add each bot created to the script object.  Then, have the script object run a method every 500 milliseconds that updates the aim / move objects for each bot in the list.  You can drastically reduce lag this way.

Could you please demonstrate?

Something like this should work.  Note the method at the bottom where you'll need to add your own code to update each bot.

Code: [Select]
new ScriptObject(botManager)
{
     numBots = 0;
};

function botManager::add(%this,%obj)
{
     //%obj == object ID of the AIPlayer
     %this.numBots++;
     %this.bot[%this.numBots] = %obj;
}

function botManager::remove(%this,%obj)
{
     //%obj = object ID of the AIPlayer
     %bots = 0;

     for(%i = 1;%i <= %this.numBots;%i++)
     {
          %test = %this.getObject[%i];

          if(%test != %obj)
          {
               %bot[%bots++] = %test;
          }
     }

     for(%j = 1;%j <= %bots;%j++)
     {
          %this.bot[%j] = %bot[%j];
     }

     %this.numBots--;
}

function botManager::getCount(%this)
{
     return %this.numBots;
}

function botManager::getObject(%this,%num)
{
     return %this.bot[%num];
}

function botManager::updateBots(%this)
{
     for(%i = 1;%i <= %this.numBots;%i++)
     {
          %bot = %this.getObject(%i);
          //Your code to update each bot here
     }
}
« Last Edit: November 07, 2007, 12:55:48 PM by Trader »


No problem.  Script objects are very much your friend.  I LOVE them.

First time I've seen them ^^

Just make sure that you add a check when your bots are deleted to remove them from the botManager.