ID:2819579
 
Problem description:

Hi Guys, I'm using forum_accounts sidescroller library for my game. I'm trying to make a double jump feature and wondering if anyone has managed to do this? I don't want to start messing around with the library and possibly breaking it.

I did try key_repeat() but I believe it's something something to do with the pathing and can_jump() procedures.

First off, make a variable for how many jumps you want; I'll go with var/jumps_remaining = 2, and also a var/jumps_max = 2

in movement.dm, you will find this

        can_jump()
if(on_ladder)
return 0

// If the mob is following a path, we limit how frequently
// they can jump (from the same tile). The reason we do this
// is because if they get stuck (the pathing isn't perfect!)
// they might jump repeatedly. With no delay it looks silly.
if(path || destination)
if(__last_jump_loc == loc)
if(__jump_delay > 0)
__jump_delay -= 1
return 0

return on_ground


replace the last line with return jumps_remaining

in the proc for set_flags, you will see this:

        set_flags()
on_ground = 0
on_ceiling = 0
on_left = 0
on_right = 0

// we make use of built-in procs but we also have to check for ramps
for(var/atom/a in obounds(src, 0, -1, 0, -pheight + 1))
if(!can_bump(a)) continue

if(a.pleft != a.pright)
if(py == a.height(px,py,pwidth,pheight))
on_ground |= (1 | a.flags | a.flags_top)
else
if(py == a.py + a.pheight)
on_ground |= (1 | a.flags | a.flags_top)


tack on jumps_remaining = jumps_max at the end, right below where it sets the on_ground flag.

then, in the jump proc, make it so jumps_remaining--