[4.5.x] Implementing Jumping in Brawler Mod

vanderblade

Active member
This is a complicated process, so I'm hoping we can solve it as a community.

Caveat: I'm trying my best to learn here, so I apologize for all my (perhaps obvious) errors and mistakes.

Here's what needs to happen logically for a simple jump kick.

Press an input (let's say the A button, but could be whatever) to:
1) change the player action state to a jump animation;
2) while in this state, move the player up and either left or right depending on the direction player is facing, and then back down to their previous x horizontal position to maintain illusion they've jumping up and over before coming back down to the starting x position;
3) make player invincible during this action state (best practice to avoid interruption);
4) create game object for a kicking leg that hurts monsters when colliding with their hit box.

I've been trying to write a script and right now can press A to change the player action state to a jump animation. Big whoop, right?

But I'm having issues working through the logic of moving the player up and in the direction they are facing, implementing the invincible flag (not native to the brawler mod), and thinking through how to spawn a kick game object that would damage the monster).

There's also the issue that I'll have to go back and, I believe, update all the move scripts to check if the player isJumping so you can't suddenly start walking while in the middle of a jump kick.

Here's what I have so far. And yes, I know that this would, if it worked, only send the player up and to the right while in their jumping animation. But it's a start. As it stands, the player goes into their jumping action state but does not move at all.

Code:
;;an attempt at a faux jumping script for brawler module
 
    TXA
    STA temp ;; assumes the object that we want is in x.
GetActionStep temp
    CMP #$03 ;; is it already jumping?
    BNE +notJumping
        ;; wait until we're back to idle to jump again.
        RTS
    +notJumping
    CMP #$07 ;; is it hurt?
    BNE +canJump
        ;; wait until we're back to idle to jump
        RTS
    +canJump
        
        TXA
        STA temp ;; assumes the object we want to move is in x.
        ChangeActionStep temp, #$03 ;; assumes that "jump" is in action 3
        ;arg0 = what object?
        ;arg1 = what behavior?
        
        StartMoving temp, #UPRIGHT
        
        RTS
 

vanderblade

Active member
Okay. Had to figure this out by myself, so it's a little jank. But I did find a solution.

Step 1: Make a jump animation and assign it to unused player action state. Use another unused state for a jump kick animation state.

Step 2: Use the invulnerability flag to make player invincible while in jump state and jump kick state.

Step 3: Make an input script that changes player to that jump state. Assign it to any button or combination of buttons you want.

Here was the tricky part. As an asm idiot, I tried to make a script that would change to the jump state and then change to the jump kick state and also move the created player weapon (the foot) travel with the player, all in one script. Maybe that is possible. If so, let me know! But I couldn't get it to work. So I went about a different method.

Step 4: Create a new timer end action to do the rest of the jump kick after the initial jump. I went into the timerend script and used one of the unused slots. This timer end action kicks in at end of timed jump state. It then changes player to jump kick action state. I then move my player downright or down left, depending on which way the player was facing when they jump kicked. I also included the code to create the player weapon (jump kick foot) here.

Step 5: Whatever object you assigned to the player jump kick foot object (I'm using object 8, or #$08), make sure to set a speed to it. We want it to move with the player, after all. Then I created a new monster AI script that moves either down left or down right, depending on what action state the foot object is in when created. If in state 00 (the right state), it moves downright. If in action state 01 (the left state), it moves downleft. Note, in the creation code above, I have separate action states create a left and right version of the jump kick foot. This will match player weapon (foot) movement with the player character movement, creating the illusion of a single object.

Step 6: Assign new monster AI to the left and right states in the jump kick foot object. Done.

The end result: https://drive.google.com/file/d/1xRRvOE6Ph2BiGHDMhPeq8ym1WQty3emh/view?usp=sharing

One HUGE caveat: Unless you want to break the jump kick action mid-way through, you'll also want to go through all your action and movement scripts and add a check to see if the player is in the jump or jump kick state. If so, don't allow other movements/actions.

I would break this down further and show screenshots, but right now, I'm afraid this is a backwards-ass way of accomplishing a jump kick. And I don't want to give people a bad tutorial in detail. If somebody posts a better method, I'd be happy to adopt it.

However, if you want to do this and have questions, let me know.
 

AllDarnDavey

Active member
BrawlerWJump.gif

I tried to add jump to the brawler module myself.
That's why my ByteOff2020 entry is so short and simple, I spent almost my entire ByteOff time trying to add jump to the brawler module, got pretty far too. But despite how the gif above looks, it was still riddled with issues so I spent the last few days of ByteOff cobbling together a different game demo to submit instead.

The brawler module's physics script has gravity stripped out completely, so I had to add that back in. But that made the script no longer fit into memory, so I had to strip all the enemy proximity stuff out, which broke all enemy AI (I planned on redoing that outside the physics script later, but never got that far).

GroundLayer.PNG

My technique was to create an Object_Layer variable which gets set by tile scripts as you walk over them. You can see the walkable part of the collision above starting at 08 then increasing as you go down. Gravity was disabled while walking, but turned on when jumping and falling. Physics was updated to fall until you collided with a tile greater than or equal to your Object_layer variable.

There was a lot of small issue that kept popping up with my approach, I had to add checks while walking or idle to see if you had walked off an edge and were no longer on solid ground -- getting solid tiles to block you from moving unless jumping, etc. I never did get it all ironed out. I may one day, pick up where I left off and try again.

I don't know if any of this is helpful for your approach to this problem, but I thought you'd be interested in seeing how I tried to solve it.
 

vanderblade

Active member
Very cool stuff, Davey. I don't have the skill to do actual physics/gravity. I just cheesed it. I move my character up during the jump state, and then either down right or down left, depending on player orientation, during the kick portion of the animation.

I'm just finishing a demo of my brawler and taking a break. Maybe when I get back there will be a user-made mod to do the basic stuff, but as you indicated, once you start messing with the base module, you kind of have to start rearranging everything. It's a nightmare for novice users.

Also, how do you post gifs in the forums?
 

AllDarnDavey

Active member
Very cool stuff, Davey. I don't have the skill to do actual physics/gravity. I just cheesed it. I move my character up during the jump state, and then either down right or down left, depending on player orientation, during the kick portion of the animation.
Yeah, just making it look like a "jump" is much easier, and if it works for your game, then it's the right call. I didn't actually code physics in my example (I'm not that good a programmer), I just copy & pasted the physics from the platform module, but even then it's not exactly plug and play.
Also, how do you post gifs in the forums?
Just hit the "Attach files" button, upload the gif, then "insert" it into your post. The same way you post pics, but it also supports animated gifs. I use LICEcap to quickly capture gifs offscreen. I find quick animations are super helpful, they get your point across much better than just words, and they're eye catching, so people are more likely to read the post and not just glaze over it.
 
Top Bottom