Author Topic: I need help with damaging bots in a minigame  (Read 2867 times)

So I have this code to make bots that can either spawn with a sword, or a bow, and they'll attack the nearest player. But for some reason, they can't damage me in a minigame, and I can't damage them back.

Code: [Select]
package hax
{
function getMiniGameFromObject(%obj)
{
if(isObject(%obj.miniGame))
return %obj.miniGame;
return Parent::getMiniGameFromObject(%obj);
}
};

activatePackage("hax");

function newAlien()
{
%bot = new AIPlayer()
{
datablock = "playerStandardArmor";
position = pickSpawnPoint();
miniGame = findLocalClient().miniGame;
ShootBool = 0;
};
%random = getRandom(1,2);
switch(%random)
{
case 1:
%bot.mountImage(bowImage,0);
case 2:
%bot.mountImage(swordImage,0);
}
%bot.alienTick();
%bot.shootTick();
}

function AIPlayer::alienTick(%bot)
{
//Find closest
initContainerRadiusSearch(%bot.getPosition(), 500, $TypeMasks::PlayerObjectType);
while (%obj = containerSearchNext()) {
if (%obj == %bot || %obj.getClassName() $= "AIPlayer" || %obj.client.miniGame != %bot.miniGame)
continue;
%target = %obj;
%bot.setAimObject(%target);
%bot.setMoveObject(%target);

break;
}
%bot.schedule(100,0,alienTick);
}

I don't know how to fix this, pls help
« Last Edit: June 06, 2014, 03:02:46 PM by PurpleMetro »

Shouldn't you remove the "return" from return Parent::getMiniGameFromObject(%obj);?

I'm not really sure but I've never seen parenting done that way

Shouldn't you remove the "return" from return Parent::getMiniGameFromObject(%obj);?

I'm not really sure but I've never seen parenting done that way

Port lended me the code for the package. I don't know he just told me I needed to add the bot to the minigame.
Did remove, but no signs of a difference

Also I figured out how to kill the bots now. I had to enable "Include all player's bricks" in the minigame options. But I still can't kill the bots, so that's a problem.

And when someone dies, they just stay in place attacking, as if they're still there. why are bots so hard to code :(

Pretty sure the aiplayer needs to have a client defined (aiconnection) with minigame defined on that
At least this is what I remember doing, and it worked

If you're using Slayer, just call %minigame.addBotToGame().