Jump to content

Recommended Posts

Simple Jump System v1.1

Author: Maloke

 

Introduction:

This is my first script, a simple jump system.

 

Features:

Allow the main hero to jump a block space;

Configurable jump sound;

Configurable switch to activate the "jump ability";

Configurable button, default is A;

Very compatible;

 

Screenshot:

LBdGd.png

 

Script:

#--------------------------------------------------------------#
# SIMPLE JUMP SYSTEM
#--------------------------------------------------------------#
# Give you the ability to jump over some objetcs and holes,
# avoiding on walk over events conditions, etc.
#--------------------------------------------------------------#
# Author.......: Maloke
# Version......: 1.5
# Launch.......: 01/13/2013
# Last Update..: 01/16/2013
#--------------------------------------------------------------#
# [?] Instructions:
#
# 1. Make a switch to activate it
#
# 2. Hold the direction you want to jump, then press the button 
# A of your keyboard, or the custom key (if you have configured)
#--------------------------------------------------------------#
# Special thanks to Galv
#--------------------------------------------------------------#

module MK_SJS
#--------------------------------------------------------------#
# [%] Settings
#--------------------------------------------------------------#
  JUMP_SWITCH = 1      #If this is on the jump works
  JUMP_SOUND = "Jump1"  #Play this SE if you jump
  JUMP_DELAY = 30      #Frame delay between jumps
  JUMP_TRIGGER = :X    #Set a custom bustom for jump
#--------------------------------------------------------------#
end
#--------------------------------------------------------------#
# [!] Code
#--------------------------------------------------------------#
# Warning: I do not recomend editting below this if you don't
# know what you are doing.
#--------------------------------------------------------------#
class Game_Player < Game_Character
#--------------------------------------------------------------#
# * Alias methods
#--------------------------------------------------------------#
  alias mk_update update
  alias mk_move_by_input move_by_input
  alias mk_init initialize
#--------------------------------------------------------------#
# * Defines the delay between jumps
#--------------------------------------------------------------# 
  def initialize
    mk_init
    @jump_delay = MK_SJS::JUMP_DELAY
  end
#--------------------------------------------------------------#
# * Will check the jump_priority [Bug Fix]
#--------------------------------------------------------------#
  def update
    mk_update
    jump_priority
  end
#--------------------------------------------------------------#
# * Verify if the Switch is on then verify if the delay is
# still charging after this, is ready for jump, and when you
# do it jump and reset the delay
#--------------------------------------------------------------#
  def move_by_input
    mk_move_by_input
    if $game_switches[MK_SJS::JUMP_SWITCH] == true
    if @jump_delay == MK_SJS::JUMP_DELAY
      if Input.trigger?(MK_SJS::JUMP_TRIGGER)
        jump_extra if do_jump
        @jump_delay = 0
      end
    else
      @jump_delay += 1
    end
    end
  end
#--------------------------------------------------------------#
# * Check every passability possible [Bug Fix]
#--------------------------------------------------------------#  
  def check_map_passability(mkx, mky)
    if map_passable?(mkx, mky, 2) or map_passable?(mkx, mky, 4) or map_passable?(mkx, mky, 6) or map_passable?(mkx, mky, 8)
      return true
    else
      return false
    end
  end
#--------------------------------------------------------------#
# * 2 -> Your hero will be over everthing
# 1 -> Your hero is normal
#--------------------------------------------------------------#
  def jump_priority
    if jumping?
      @priority_type = 2
    else
      @priority_type = 1
    end
  end
#--------------------------------------------------------------#
# * Check if there are any tile of 2 height in your way 
#--------------------------------------------------------------#
  def check_layered(mk_cl_x, mk_cl_y)
    mk_tile_check = "[0, 0, "+$game_map.tile_id(mk_cl_x, mk_cl_y, 0x00).to_s+"]"
    mk_layered_check = $game_map.layered_tiles(mk_cl_x, mk_cl_y).to_s
    else if mk_tile_check == mk_layered_check
      return true
    else
      return false
    end
  end
#--------------------------------------------------------------#
# * Make you followers jump with you, and play the SE
#--------------------------------------------------------------#  
  def jump_extra
    @followers.each {|member| member.jump(@x - member.x, @y - member.y)}
    Audio.se_play('Audio/SE/'+MK_SJS::JUMP_SOUND+'.ogg',50,150)
  end
#--------------------------------------------------------------#
# * Do the jump only if everything is all right
#--------------------------------------------------------------#
  def do_jump
    case @direction
    when 2
      if !collide_with_events?(@x, @y+2) && check_map_passability(@x, @y+2)
        if normal_walk? && check_layered(@x, @y)
          jump( 0, 2)
        end
      end
    when 4
      if !collide_with_events?(@x-2, @y) && check_map_passability(@x-2, @y)
        if normal_walk? && check_layered(@x-1, @y-1)
          jump(-2, 0)
        end
      end
    when 6
      if !collide_with_events?(@x+2, @y) && check_map_passability(@x+2, @y)
        if normal_walk? && check_layered(@x+1, @y-1)
          jump( 2, 0)
        end
      end
    when 8
      if !collide_with_events?(@x, @y-2) && check_map_passability(@x, @y-2)
        if normal_walk? && check_layered(@x, @y-2)
          jump( 0,-2)
        end
      end
    end
  end
#--------------------------------------------------------------#
# * End of Class
#--------------------------------------------------------------# 
end
#--------------------------------------------------------------#
# * Script End
#--------------------------------------------------------------#
Credits:

Maloke

 

Author Notes:

Please report bugs

 

Update Notes:

  • Party Members now repeat the jump
  • Now you can configure a delay between jumps

    [Revision] Cleaned the jump audio code

    [bUG Fixed] Jumping action looking like under event

Edited by Maloke

Share this post


Link to post
Share on other sites

Pretty good for a first script!

Reporting some bugs:

 

1. You can jump onto "same as characters" level events from 2 tiles away.

2. You can jump horizontally through internal walls of a house

3. You can jump onto "wall-top" tiles from above or below it (as you can normally walk on these) from 2 tiles away and also from the sides if the walltop extends horizontally.

4. Jumping over "same as character" level events vertically looks like the player goes under the event.

5. You can jump vertically through tree tiles and other similarly designed tiles (as only their base is unpassable) and jumping horizontally past them cuts the player's head off behind the "above character" part of the tree.

6. you've made the default button "S", not "A" (not a bug, but thought I'd mention it)

 

On an unrelated note (not saying this because of the above) I don't think "minimal bugs" is a feature. No bugs should be the norm :)

Share this post


Link to post
Share on other sites
1. You can jump onto "same as characters" level events from 2 tiles away.

2. You can jump horizontally through internal walls of a house

3. You can jump onto "wall-top" tiles from above or below it (as you can normally walk on these) from 2 tiles away and also from the sides if the walltop extends horizontally.

4. Jumping over "same as character" level events vertically looks like the player goes under the event.

5. You can jump vertically through tree tiles and other similarly designed tiles (as only their base is unpassable) and jumping horizontally past them cuts the player's head off behind the "above character" part of the tree.

6. you've made the default button "S", not "A" (not a bug, but thought I'd mention it)

1. Studying the problem

2. Studying the problem

3. Studying the problem

4. Fixed

5. Partially Fixed

6. Fixed

 

I'm a real noob yet, but i'm trying harder to make better scripts.

Thanks for your report.

Share this post


Link to post
Share on other sites

I am not scripter, Keep up the good scripting.

I will try the script and reply to you tommorow.

 

Maybe you could make a fall note tag? like when you touch a terrain tagged tile (for example 5 or any thing you chose), you fall and a common event is activated :)

Share this post


Link to post
Share on other sites

Galv, take a look, I rewrote the whole code and tried to fix some bugs you commented before.

 

Now you can not jump over a tree, or something with similar design.

But i couldn't fix the wall jump problem yet, but i'm working on it.

Edited by Maloke

Share this post


Link to post
Share on other sites

That nearly works, though you can't jump horizontally behind those type of tiles and can jump over the tree horizontally but not vertically.

 

My idea for that was to check regions so they can be used to block where the player shouldn't jump (like the tree lower tree tile). Checking terrain tags would work, too.

 

I had the same idea for point 4 as you, although jumping while behind a tree would make the player appear above it during the jump. I didn't think of a good way to solve that, though, so mine still does it (I'm learning to script as well).

Share this post


Link to post
Share on other sites

Might want to do some more tests, I think you broke a couple of things :P

Check your down jump direction there's a mistake with an Input.press? and no argument.

Also I noticed the player's priority stays above everything

Share this post


Link to post
Share on other sites

I love the idea, but the script doesn't really work perfectly because you can jump into areas you wouldn't be able to walk into for a lot of reasons.

 

Edit: looks like a lot of the problems I was having are fixable by adding many, many "same priority" empty events in places I dont want the player to be able to jump.

 

Interesting...

 

Also does anyone know a way to confine jumping to the space bar, :SPACE didnt work for me.

Edited by Dymdez

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×