Attack Proc:
proc/enemyattack()
var/obj/monster/O
if(src.wild==1)
while(src)
if(O in view(src))
if(O.name in src.killlist)
walk_to(src,O,1,5)
if(O in oview(1))
step_towards(src,O)
else
sleep(10)
walk_rand(src,15)
break
else
for(O in view(src))
break
sleep(5)
spawn(2) enemyattack()
Damage proc:
proc/damage(obj/O)
var/damage = (rand(src.minatk,src.maxatk)) - O.def
O.hp -= damage
O.killlist += src.name
Problem description:
First-this is based from an AI Demo
The first code is the Enemyattack proc, which so far only makes the enemy walk randomly, even though they have been attacked. They're supposed to walk around when there isn't any objs near them that are listed in their kill list, but they just continue to walk. Im thinking the reason to this is because the O.name is not being added to the src.killlist or something like that, but thats what I don't get because the name is being added to the killlist in the damage proc.
Help would be appreciated.
You can see where the loop starts with the Enemy being attacked first, and the progression from there. The only way this will work for all attacks is if you add the "<font face=courier new>src.Attacking()</font>" proc is placed somewhere within EVERY ability that(For lack of a better phrase) "Pulls Aggro" on the Enemy. This is helpful too because you can have certain "debuffs" that you can place on an Enemy, but they wont attack you for it.
If you have any questions, just post them here, I'll try my best to answer them. and I'm sorry if this little Demo doesn't work, it's just to provide proof-of-concept. If you want, i can try to develop something for you. I have to make one of my own in my game anyways, so I'll do my best to help.
Danke Schoen, und Auf Weidersehen!
-Danbriggs
PS: If it doesn't work, and you know why, please tell me so that i may clean up this little snippet. It was done off the top of my head and without being tested.
PSS: If you're wanting to know how to make an "Aggro" system like in WoW, that simply attacks the player with the highest threat against the Enemy, please tell me. I'm developing one at the moment, and i plan to make it a Library. I'll make sure that it remains as simple as possible so newer coders can understand it and implement it into their projects. Thanks.