example of attack list for a mob.
list/attacks = list(/mob/proc/attack,/mob/proc/splash,/mob/proc/splash)
Code:
combat system.
mob/proc/combat(mob/M)
if(M.hp <= 0)
src.death(M)
return
var/turn = pick(M.attacks)
spawn() call(M,turn)(src)
Problem description:
Basically I want the monsters in this mud to randomly choose their attacks. And every single attack, including attack are a proc. IE mob/proc/attack() and mob/proc/splash().
What I was going for is every mob has the attacks they can use in their attacks list. And then in the combat proc, it would randomly choose one of those attacks in the list and then calls it.
Won't work though. Compiles just fine and the game runs perfect, except that all the mobs ever do is call attack() and nothing else.
Edit:
Would:
spawn() call(M, pick(M.attacks))(src)
work the same way or would that be incorrect?
Edit 2:
With some suggestions from Jon88 I changed the lists to like this:
list/attacks = list("attack","splash")
And it works just fine, except for some reason it simply picks attack every single time. It has yet out of like a few 100 cycles to pick anything then attack.
pick() shouldn't do that, you probably were just lucky.