ID:169574
 
Can someone please give me an example of an AI code...example: how to make a monster keep attacking until its healthm goes below a certain point. Can someone please help??

Thank you,
Billy Bob
mob/enemy/proc/aiattack()
spawn while(1)
if(src:hp<10)
return 0
else
attack()
In response to CIB
I still don't understand... Where would I put it in the code? A little more detail please... Thanks for responding though...

Billy Bob
In response to Billybobjoe
o.O don't you even know how to make them attack?
mob/enemy/proc/attack()
spawn while(1)
for(var/mob/PC/P in oview(src,5)
step_to(src,P,1)
for(var/mob/PC/P in oview(src,1)
P.damage(src:atk)
sleep(5)
sleep(5)
I recommend checking out: HR monster, I've heard it's got quite a nice example on that. :)
In response to Hell Ramen
Hell Ramen wrote:
I recommend checking out: HR monster, I've heard it's got quite a nice example on that. :)

Yea, looking is always better than asking, since many things have already been made and as most will tell you: "There's no point in re-inventing the wheel."

RD
In response to CIB
Urgh, no use colons. Why use a colon when a period would work much better? things like "src:atk" should probably be "src.atk".

And put your code into DM tags, like so:
Code
Code
Code

http://developer.byond.com/hub/ITGMaster/EnemyAI

Simple, and usefull. Learn from it.
In response to Artekia
? i thought collons and points are(except in procs) the same. :S what does it bring to use a . instead?