I can make my monsters wander randomly, and chase players (very unintelligently) and run away. But there are a few things I am unsure of.
I want several Orc monsters to stay near their camp. I surrounded their camp with an area that only allows clients passed. But now, if a player walks within 6 squares of an Orc, the Orc runs to the wall of area, and then just stands there. How can I tell the Orc to ignore anything unless it is within its own area?
Also, if a monster's path is blocked by an obstacle, they won't take a route around. How can I get them to realise they can't go forward, and go around instead?
Here is my current code;
proc//core procs for the system
ai_random_wander()//random wander if no mobs are in range to attack
if(src.key)//if the source is human
return//don't call the rest
else
walk_rand(src,7)//walk randomly with 7 lag
src.ai_run_away()//checks for run away
spawn(10)//delay for one tick
ai_random_wander()//wander some more
ai_run_away()//used for checking to see if it should run or attack
if(src.client)
return
else
for(var/mob/chars/M in oview(4,src))//loops over all mobs within 4 tiles of the monster
if(M.client)//if the mob is human
if(get_dist(src,M) <= 5 && src.HP < src.HP/3)//if the player is close, and the monster is weaker
walk_away(src,M,5,6)//run away
else
src.ai_walk_to()//calls the walk_to (for attacking) proc
else
continue//if it's a monster keep looping
ai_walk_to()
if(src.client)
return 0
else
for(var/mob/chars/M in oview(5,src))
if(M.client)
if(get_dist(src,M) <= 5)//within 5 tiles
walk_to(src,M,1,6)//walk to the player
if(get_dist(src,M) <= 1)
Attackproc()
break//stops the loop
else
continue
Thank you.
~Ease~