hey MauveBib thanks heaps for the help. Your not wrong about it being trickier than i thought.
so far ive got a function like this (ripped from The Ai Cafe tutorials already one step ahead in that sense)
// ------------------------------------------------
void() SearchForItems =
// ------------------------------------------------
{
local entity item;
item = findradius(self.origin, 1500);
while(item)
{
if ( (item.classname == "NormalFruit") || (item.classname == "PoisonFruit") )
{
self.goalentity = item;
}
item = item.chain;
}
};
which works fine the ai walks towards the entity while it exists.
I also took your advice and converted the bot_look_for_enemy function to look like this
// ------------------------------------------------
void() SearchForPlayer =
// ------------------------------------------------
{
local entity found, foe;
// bots aren't clients, so we have to check fo them manually
// we just see if any of the bots in the entity list are visible
if (self.enemy)
return;
found = world;
foe = find(world, classname, "player");
while(foe)
{
if (visible(foe) && foe != self && foe.health > 0)
found = foe;
foe = find(foe, classname, "player");
}
if (found != world)
{
self.enemy = found;
self.goalentity = found;
}
};
which works fine also the Ai move towards the player.
But i cant firgure out how i would check if SearchForItem finds nothing so it can then call SearchForPlayer.
Ive tried a few different things but im kinda stumped again.
basicaly just trying to tell the Ai no matter what if there is an entity with the classname "NormalFruit" or "PoisonFruit" to always target it, if there are no items present with that classname target the player
Any help is greatly appreciated.