Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[VX] 'Jump implementation' script v1.0

'Jump implementation' script v1.0
(I decided it's a fair name)


What's this?
This is something I haven't seen yet around, (probably I just missed all the relevant search results) this enables a jump function for your game.

Details
  • Jumps 2 tiles long (if can't, jumps only 1 tile)
  • Doesn't allow to jump over characters (events with priority 'Same as Characters')
  • Compatible with Trickster's caterpillar script modified by Diedrupo (sorry, I've found it on another site, so I can't give you a link)
  • You can define a switch which must be turned ON to let you jump (default Switch 001).
  • Jumps by pressing the controller's X button (by default A on you keyboard).
  • Now you can't jump with a vehicle.
  • You can define a sound to play when jumping
  • Two control behaviour: jump continuously when pressing X or jump once when pressed (something beta)
  • Now the character jumps zero tile if can't jump anywhere.
  • Now the poisoned characters get damage equal to the jump length.
  • While jumping, a stepping part of the walk animation is shown to look better.
By request all these can be modified to be configurable.

Script
Code:
#==============================================================================
# ** Game_Player jump modifications
#------------------------------------------------------------------------------
# Blabla this script enables you to jump with the X controller button (def. A)
#==============================================================================

class Game_Player
  
  JUMPSWITCH = 1       # This switch indicates the possibility of jumping
  CATERPILLAR = false  # Set this true, if you're using the caterpillar script
  JUMPSOUND = "Audio\\SE\\Jump2"   # You can define a sound played when jumping
                               # Leave empty to play nothing
  BUTTON_BEHAVIOUR = 2 # 1 for countinous jump when pressed, 2 for jump once
                       # per button press
  
  @jumpbutton = false
                       
  alias_method :ducktor_jump_movable?, :movable?
  def movable?
    return false if jumping?
    ducktor_jump_movable?
  end
  
  alias_method :ducktor_jump_move_by_input, :move_by_input
  def move_by_input
    ducktor_jump_move_by_input
    if Input.press?(Input::X) and (not $game_switches[JUMPSWITCH]) and movable? and (not in_vehicle?)
      return if @jumpbutton and (BUTTON_BEHAVIOUR == 2)
      case @direction
      when 2
        if passable?(@x,@y+2)
          unless collide_with_characters?(@x,@y+1)
            $game_party.update_move(5, 0, 2) if CATERPILLAR
            @y += 2
            distance = 2
            @jump_peak = 10 + distance - @move_speed
            @jump_count = @jump_peak * 2
            @stop_count = 0
            straighten
            $game_party.on_player_walk
            Audio.se_play(JUMPSOUND) if (JUMPSOUND.size != 0)
          else
            distance = 0
            @jump_peak = 10 + distance - @move_speed
            @jump_count = @jump_peak * 2
            @stop_count = 0
            straighten
            $game_party.on_player_walk
            Audio.se_play(JUMPSOUND) if (JUMPSOUND.size != 0)
          end
        elsif passable?(@x,@y+1)
          $game_party.update_move(5, 0, 1) if CATERPILLAR
          @y += 1
          distance = 1
          @jump_peak = 10 + distance - @move_speed
          @jump_count = @jump_peak * 2
          @stop_count = 0
          straighten
          $game_party.on_player_walk
          Audio.se_play(JUMPSOUND) if (JUMPSOUND.size != 0)
        else
          distance = 0
          @jump_peak = 10 + distance - @move_speed
          @jump_count = @jump_peak * 2
          @stop_count = 0
          straighten
          $game_party.on_player_walk
          Audio.se_play(JUMPSOUND) if (JUMPSOUND.size != 0)
        end
      when 4
        if passable?(@x-2,@y)
          unless collide_with_characters?(@x-1,@y)
            $game_party.update_move(5, -2, 0) if CATERPILLAR
            @x -= 2
            distance = 2
            @jump_peak = 10 + distance - @move_speed
            @jump_count = @jump_peak * 2
            @stop_count = 0
            straighten
            $game_party.on_player_walk
            $game_party.on_player_walk
            Audio.se_play(JUMPSOUND) if (JUMPSOUND.size != 0)
          else
            distance = 0
            @jump_peak = 10 + distance - @move_speed
            @jump_count = @jump_peak * 2
            @stop_count = 0
            straighten
            Audio.se_play(JUMPSOUND) if (JUMPSOUND.size != 0)
          end
        elsif passable?(@x-1,@y)
          $game_party.update_move(5, -1, 0) if CATERPILLAR
          @x -= 1
          distance = 1
          @jump_peak = 10 + distance - @move_speed
          @jump_count = @jump_peak * 2
          @stop_count = 0
          straighten
          $game_party.on_player_walk
          Audio.se_play(JUMPSOUND) if (JUMPSOUND.size != 0)
        else
          distance = 0
          @jump_peak = 10 + distance - @move_speed
          @jump_count = @jump_peak * 2
          @stop_count = 0
          straighten
          Audio.se_play(JUMPSOUND) if (JUMPSOUND.size != 0)
        end
      when 6
        if passable?(@x+2,@y)
          unless collide_with_characters?(@x+1,@y)
            $game_party.update_move(5, 2, 0) if CATERPILLAR
            @x += 2
            distance = 2
            @jump_peak = 10 + distance - @move_speed
            @jump_count = @jump_peak * 2
            @stop_count = 0
            straighten
            $game_party.on_player_walk
            $game_party.on_player_walk
            Audio.se_play(JUMPSOUND) if (JUMPSOUND.size != 0)
          else
            distance = 0
            @jump_peak = 10 + distance - @move_speed
            @jump_count = @jump_peak * 2
            @stop_count = 0
            straighten
            Audio.se_play(JUMPSOUND) if (JUMPSOUND.size != 0)
          end
        elsif passable?(@x+1,@y)
          $game_party.update_move(5, 1, 0) if CATERPILLAR
          @x += 1
          distance = 1
          @jump_peak = 10 + distance - @move_speed
          @jump_count = @jump_peak * 2
          @stop_count = 0
          straighten
          $game_party.on_player_walk
          Audio.se_play(JUMPSOUND) if (JUMPSOUND.size != 0)
        else
          distance = 0
          @jump_peak = 10 + distance - @move_speed
          @jump_count = @jump_peak * 2
          @stop_count = 0
          straighten
          Audio.se_play(JUMPSOUND) if (JUMPSOUND.size != 0)
        end
      when 8
        if passable?(@x,@y-2)
          unless collide_with_characters?(@x,@y-1)
            $game_party.update_move(5, 0, -2) if CATERPILLAR
            @y -= 2
            distance = 2
            @jump_peak = 10 + distance - @move_speed
            @jump_count = @jump_peak * 2
            @stop_count = 0
            straighten
            $game_party.on_player_walk
            $game_party.on_player_walk
            Audio.se_play(JUMPSOUND) if (JUMPSOUND.size != 0)
          else
            distance = 0
            @jump_peak = 10 + distance - @move_speed
            @jump_count = @jump_peak * 2
            @stop_count = 0
            straighten
            Audio.se_play(JUMPSOUND) if (JUMPSOUND.size != 0)
          end
        elsif passable?(@x,@y-1)
          $game_party.update_move(5, 0, -1) if CATERPILLAR
          @y -= 1
          distance = 1
          @jump_peak = 10 + distance - @move_speed
          @jump_count = @jump_peak * 2
          @stop_count = 0
          straighten
          $game_party.on_player_walk
          Audio.se_play(JUMPSOUND) if (JUMPSOUND.size != 0)
        else
          distance = 0
          @jump_peak = 10 + distance - @move_speed
          @jump_count = @jump_peak * 2
          @stop_count = 0
          straighten
          Audio.se_play(JUMPSOUND) if (JUMPSOUND.size != 0)
        end
      end
    end
    @jumpbutton = jumping? ? Input.press?(Input::X) : false
  end
end

class Game_Character
  alias_method :ducktor_jump_update_jump, :update_jump
  #--------------------------------------------------------------------------
  # * Update While Jumping
  #--------------------------------------------------------------------------
  def update_jump
    ducktor_jump_update_jump
    @anime_count = 20
  end  
end

Other
This script shall not affect the built-in jump function of Game_Character. The script modifies the move_by_input function, and does not even call the jump function, checks passability in place, so if you make your character jump by defining a move route, it still may jump out of the map, or onto inpassable tiles!
If you're familiar with scripts, you can reverse the switch check, so you can jump, if it is OFF.

Other other
I'm really interested in your opinions, because it is my first RM script ever, and I'm still in search of directions. Also please tell me, if such a script already can be found on this board. :tongue:
And the general sorry for bad english. Demo coming soon, if you wish. Thanks!

Ducktor
 
I tried to do this with events but more complicated event systems don't seem to work in VX. :P I wonder if it's compatible with Near's 8 directional movement. Hmm.
  -KRoP
 
If you put my script below the 8dir script, it shall work. But if it does not, I can take a look at the reason and combine the two, if you provide a link to a thread where I can find it.
 
Doing this by events still requires scripting if you want your hero keep on the map, and avoid stepping onto impassable tiles. First I wanted to create it with events, but I run into the problem, that the hero jumps on impassable tiles as well. By events as I know there's no passability check at all. Scripting is a must... :( But is even simpler. ;)
 

418er

Member

Thanx for this script it really helped my game alot!
The only thing missing is sfx when the player jumps.
 
There is NO built-in jump in VX. I scanned trough the whole script to find one, and I just didn't find any. You must have played a game which also implemented jumping by events or script.

Also we have to notice, if we use a move route by events to implement jump, we see that our hero jumps everywhere. I mean onto tiles that cannot be passed, and onto tiles that doesn't even exist (outside of map).

Woratana (I think) had once a jump restriction script on a forum (I'm not sure where) and it fixed that glitch well. But I wanted to create something, that does not allow you to jump over character level events, and if you can't jump two tiles long, than just jump 1 tile (like in Mystic Quest Legend, if you know the game). There were awesome puzzles with elevations, you had to push blocks, and go one level upper and than jump over the blocks. I want to create similar in my game, and in a demo I post here. But it's complicated, because of the impossibility of jumping over character level events.

The default move_by_input (or similar) checks only the four directions. The 8 direction movement scripts replace this part with a check for 8 directions, and the jump check comes after it. That's why it must be compatible with 8dir mov scripts.
 
Is there any way to make it so the player doesn't keep jumping just by holding down the key, and rather a single jump every time the key is pressed?
  -KRoP
 
Script updated, see details in the details section.

@KRoP: I've tried to script your request, try modifying the BUTTON_BEHAVIOUR constant to 2, and see if you are satisfied with the result. I'm not sure if it's 100%, because it is not  :tongue:
The problem is, that if you keep pressing the jump button, it jumps one, and if you move a tile, it jumps again. But I think this is not a general player behaviour.  :wink:
 
Thanks, I've tried to recreate Final Fantasy: Mystic Quest's jump (also known as Mystic Quest Legend). First I played that game in German. I understood nothing :lol: But it has an awesome gameplay. Super Nintendo has the best RPG games.  :smile:
 
Hey ducktor my question was can you make this script 2 player compatable?
edit: if you can, can you give me the link to the caterpillar script that it works with or where to find it cause I can't find it (I'm new here (i'm a newb)).
 

Taylor

Sponsor

This could be very useful, but would it be possible to make it only possible to jump when facing certain tiles? In Golden Sun you could only jump when facing a one tile gap, however here you can jump wherever you want.
 
Sorry if this is necroposting, but I tried turning off the switch to make jumping capable. I set it to switch 94 and when I turn the switch off, I can still jump. I want to make it to where I can't jump on the world map.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top