ID:1128399
 
(See the best response by Jemai1.)
Code:
client
East()
if (mob.icon_state == "MAIN" || mob.icon_state == "BATTLE")
..()
West()
if (mob.icon_state == "MAIN" || mob.icon_state == "BATTLE")
..()

mob
key_down(k)
if (k == "east")
quickturneast()
else if (k == "west")
quickturnwest()
else if (k == "south")
crouch()
else if (k == "a")
actiona()
else if (k == "s")
actions()
else if (k == "d")
actiond()
else if (k == "/")
battle()

key_up(k)
if (k == "south")
stand()

key_repeat(k)
if (k == "east")
client.East()
else if (k == "west")
client.West()

mob
verb
crouch()
set hidden = 1
set instant = 1
if (icon_state == "BATTLE" || icon_state == "MAIN")
bound_height=90
icon_state="CROUCH"

stand()
set hidden = 1
set instant = 1
if (battle)
if (icon_state == "CROUCH")
bound_height=104
icon_state = "BATTLE"
else if (!battle)
if (icon_state == "CROUCH")
bound_height=104
icon_state = "MAIN"

quickturneast()
set hidden = 1
set instant = 1
if (icon_state == "MAIN" || icon_state == "BATTLE" || icon_state == "CROUCH")
if (dir == WEST)
dir = EAST
else if (dir == EAST)
client.East()

quickturnwest()
set hidden = 1
set instant = 1
if (icon_state == "MAIN" || icon_state == "BATTLE" || icon_state == "CROUCH")
if (dir == EAST)
dir = WEST
else if (dir == WEST)
client.West()

battle()
set hidden = 1
set instant = 1
if (battle)
if (icon_state != "BATTLE")
return
battle=0
icon_state = "MAIN"
else if (!battle)
if (icon_state != "MAIN")
return
battle=1
icon_state = "BATTLE"

actiona()
set hidden = 1
set instant = 1
if (icon_state == "BATTLE" && A == "Punch")
var/Attack/A
icon_state = "HIGH PUNCH"
if (dir == EAST)
A = new /Attack/PUNCH/HIGHPUNCH/EAST(src.loc)
else if (dir == WEST)
A = new /Attack/PUNCH/HIGHPUNCH/WEST(src.loc)
A.Attack(src)
sleep(2)
if (client && client.keys["south"] == 1)
bound_height=90
icon_state = "CROUCH"
else
icon_state = "BATTLE"
else if (icon_state == "CROUCH" && A == "Punch")
var/Attack/A
icon_state = "LOW PUNCH"
if (dir == EAST)
A = new /Attack/PUNCH/LOWPUNCH/EAST(src.loc)
else if (dir == WEST)
A = new /Attack/PUNCH/LOWPUNCH/WEST(src.loc)
A.Attack(src)
sleep(2)
if (client && client.keys["south"] == 1)
icon_state = "CROUCH"
else
bound_height=104
icon_state = "BATTLE"

actions()
set hidden = 1
set instant = 1
var/Attack/A
if (icon_state == "BATTLE" && S == "Kick")
icon_state = "HIGH KICK"
if (dir == EAST)
A = new /Attack/KICK/HIGHKICK/EAST(src.loc)
else if (dir == EAST)
A = new /Attack/KICK/HIGHKICK/WEST(src.loc)
A.Attack(src)
sleep(3)
if (client && client.keys["south"] == 1)
bound_height = 90
icon_state = "CROUCH"
else
icon_state = "BATTLE"
else if (icon_state == "CROUCH" && S == "Kick")
icon_state = "LOW KICK"
if (dir == EAST)
A = new /Attack/KICK/LOWKICK/EAST(src.loc)
else if (dir == WEST)
A = new /Attack/KICK/LOWKICK/WEST(src.loc)
A.Attack(src)
sleep(3)
if (client && client.keys["south"] == 1)
icon_state = "CROUCH"
else
bound_height = 104
icon_state = "BATTLE"

actiond()
set hidden = 1
set instant = 1
if (D == "Jump")
if (icon_state == "MAIN" || icon_state == "BATTLE")
if (!actions.Find("Jumping"))
actions.Add("Jumping")
if (dir == EAST)
icon_state = "JUMPEAST"
else if (dir == WEST)
icon_state = "JUMPWEST"
if (client && client.keys["east"] == 1)
var/a = 2
do
sleep(1)
step(src,NORTHEAST,16)
a--
while (a)
else if (client && client.keys["west"] == 1)
var/a = 2
do
sleep(1)
step(src,NORTHWEST,16)
a--
while (a)
else
var/a = 2
do
sleep(1)
step(src,NORTH,16)
a--
while (a)
actions.Remove("Jumping")
actions.Add("Falling")
NormalFall()
proc
NormalFall()
while (actions.Find("Falling"))
sleep(1)
if (client && client.keys["south"] == 1 && client.keys["east"] == 1)
if (!icon_state == "JUMP EAST")
icon_state = "JUMP EAST"
step(src,SOUTHEAST,16)
else if (client && client.keys["east"] == 1)
if (!icon_state == "JUMP EAST")
icon_state = "JUMP EAST"
step(src,SOUTHEAST,8)
else if (client && client.keys["south"] == 1 && client.keys["west"] == 1)
if (!icon_state == "JUMP WEST")
icon_state = "JUMP WEST"
step(src,SOUTHWEST,16)
else if (client && client.keys["west"] == 1)
if (!icon_state == "JUMP WEST")
icon_state = "JUMP WEST"
step(src,SOUTHWEST,8)
else if (client && client.keys["south"] == 1)
step(src,SOUTH,16)
else
step(src,SOUTH,8)

Attack
parent_type = /obj/
icon_state = ""
icon = 'MHuman.dmi'
density = 1

proc
Attack(mob/O)
..()
PUNCH
Attack(mob/O)
for (var/mob/A in obounds(src,0))
if (A != O)
O.Punch1(A)
break
del src

bound_height = 16
bound_width = 24
HIGHPUNCH
bound_y = 67
EAST
bound_x = 85

WEST
bound_x = 18
LOWPUNCH
bound_y = 53
EAST
bound_x = 85

WEST
bound_x = 18


Problem description:
(this is run with Forum_Accounts Keyboard library.)
When I run the following code the NormalFall proc sometimes gets stuck running. It should stop after the mob touches down on the ground. Any ideas where I went wrong?
You never remove Falling from actions. Do so when you get the ground.
I forgot to include the code below sorry

obj/ground
proc/Land(mob/O)
if (O.actions.Find("Falling"))
if (O.icon_state == "JUMPEAST" || O.icon_state == "JUMPWEST")
O.actions.Remove("Falling")
sleep(5)
if (O.icon_state == "JUMP EAST")
O.dir = EAST
else if (O.icon_state == "JUMP WEST")
O.dir = WEST
if (O.dir == NORTHWEST)
O.dir = WEST
else if (O.dir == SOUTHWEST)
O.dir = WEST
else if (O.dir == NORTHEAST)
O.dir = EAST
else if (O.dir == SOUTHEAST)
O.dir = EAST
if (O.battle)
O.icon_state = "BATTLE"
else if (!O.battle)
O.icon_state = "MAIN"

Cross(mob/O)
if (O.actions.Find("Falling"))
Land(O)
..()
road
density = 1
icon = 'Map Tiles.dmi'
icon_state = "Road"
It could be that you are calling actiond multiple times. Therefore, your actions var is filled with multiple "Falling". Cross will only get called once so if you have 5 "Falling", you'll still have 4.

Solution: Check if you already have "Falling" in your actions var. If there is, don't add anymore.
I added in a check, however it is still repeating the loop after touch down.
so I ran it a few more times to look for any changes and realized that the loop is stopping however the dir isnt changing to east or west. So it looks like the change did fix it.
then the next time it will continue looping as normal.
(edit: by normal I mean the loop doesnt end.)
Best response
Well, first thing to do is to fix your Land proc. You should remove "Falling" regardless of the icon_state.

Secondly, Cross requires a return value. 1 to allow overlap and 0 to deny.
    Cross(mob/O)
if (istype(O) && O.actions.Find("Falling"))
Land(O)
return ..()


To fix further problems, you can add debug messages to trace the source of your troubles.
proc/proc1()
world << "proc1 does this"
// do stuff
world << "proc1 calls proc2"
proc2()

proc/proc2()
world << "proc1 does that"
// do stuff


PS: Your icon states are inconsistent. You are using "JUMP EAST" and "JUMPEAST"
I have already used debugging messages. That is how I found out it was not occurring everytime I jumped.
I made a bit of code to remove any number action "Falling" that get added to see if that would remove the problem.
obj/ground
proc/Land(mob/O)
if (O.actions.Find("Falling"))
for (var/a in O.actions)
if (a == "Falling")
O.actions.Remove("Falling")
//same as before

This seems to have fixed it. Somehow it was getting added way to many times.
Oh and thanks, I didnt notice the typo on the icon_state.
(edit: I need to stop writing this stuff when Im so tired... I wrote have the code without the space. lol)