ID:2457187
 
(See the best response by Kaiochao.)


Problem description:
I'm trying to make an attack move, so how can I make a random choice to move, so I have a punch with the left hand and the right in separate frames, what should I do in a code to select such a frame?
For example, when the Attack is pressed one of these frames will be randomly chosen and played

sorry for my bad English


Best response
If you have the left hand punch and right hand punch as separate icon states in the icon, you can use pick() to pick one randomly. Just pass all the possible icon states to it and it will return one of them randomly.
mob/enemy/bolsonaro
new()
spawn(10)
while(10)
for(var/mob/M in oview(1))
M.hp-=150
new/obj/pow(M.loc)//pooww animate
sleep(5)
spawn(10)
while(1)
walk(src,pick(NORTH,SOUTH,EAST,WEST,WEST,SOUTHWEST))
sleep(2)
..()
In response to Klogaum
Klogaum wrote:
mob/enemy/bolsonaro
new()
spawn(10)
while(10)
for(var/mob/M in oview(1))
M.hp-=150
new/obj/pow(M.loc)//pooww animate
sleep(5)
spawn(10)
while(1)
walk(src,pick(NORTH,SOUTH,EAST,WEST,WEST,SOUTHWEST))
sleep(2)
..()

He's asking how to pick a random attack animation, not how to move randomly.