scripting help with galv's jump ability

squarer00t

Villager
Member
Joined
Jul 2, 2015
Messages
13
Reaction score
0
First Language
italian
Primarily Uses
Hi!

I hope this is the correct section

I'm using Galv's Jump Ability script. Basically it works so that, by pressing a button, the character jumps in the direction they're currently facing. However I was wondering if it's possibly to change it so that you can only jump in a direction if you're holding the jump button /and/ the correct arrow key at the same time. Does that make sense?

I tried doing that with a common event instead of a script



but I'd have no clue how to make certain tiles unjumpable, plus the character can jump off screen. I'm... still not the best at eventing. Like at all.

Thank you!

Here's the original script:



#------------------------------------------------------------------------------#

#  Galv's Jump Ability

#------------------------------------------------------------------------------#

#  For: RPGMAKER VX ACE

#  Version 1.6

#------------------------------------------------------------------------------#

#  2013-06-02 - Version 1.6 - fixed a bug with region block jumping

#  2013-03-14 - Version 1.5 - fixed priority bug when jumping behind things

#                           - cleaned up code a bit

#  2013-01-15 - Version 1.4 - added follower jumping

#  2013-01-11 - Version 1.3 - added ability to make event pages block jumping

#  2012-12-05 - Version 1.2 - fixed some more bugs

#  2012-11-30 - Version 1.1 - fixed jumping in vehicles bug

#  2012-11-29 - Version 1.0 - release

#------------------------------------------------------------------------------#

#  This script allows the player to jump with the press of a button. The player

#  will jump as far as their max distance will take them without landing on a

#  blocked tile. Use regions to block players jumping completely to prevent the

#  player from doing things like jumping between rooms.

#------------------------------------------------------------------------------#

#  INSTRUCTIONS:

#  Put script under Materials and above Main

#  Read options and settings below.

#------------------------------------------------------------------------------#

 

#------------------------------------------------------------------------------#

#  COMMENT FOR EVENT (Must be first event command)

#------------------------------------------------------------------------------#

#

#  <block>

#

#  add this comment as the first event command of a page to make it unable to

#  be jumped over. Change the page to a new event page without the comment when

#  you want it to be jumpable.

 

#------------------------------------------------------------------------------#

#  NOTETAG FOR ACTORS, ARMORS, WEAPONS

#------------------------------------------------------------------------------#

#

#  <jump_bonus: x>        # Adds that many tiles to jump distance

#

#------------------------------------------------------------------------------#

#  Only the jump bonus for the party leader and his/her equips are calculated

#------------------------------------------------------------------------------#

#  SCRIPT CALL:

#  You can change an actor's jump bonus (that was set with the notetag) during

#  the game with a script call:

#

#  jump_bonus(actor_id,jump_bonus)

#

#  EXAMPLE:

#  jump_bonus(3,2)         # Changes actor 3's jump bonus to 2

#------------------------------------------------------------------------------#

 

($imported ||= {})["Galvs_Jump_Ability"] = true

module Galv_Jump

   

#------------------------------------------------------------------------------#

#  SCRIPT SETUP OPTIONS

#------------------------------------------------------------------------------#

   

  DISABLE_SWITCH = 1         # Cannot jump when this switch is ON

   

  BUTTON = :X                # Button to press to jump. :X is "a" key.

   

  DEFAULT_DISTANCE = 2       # Distance player can jump with no bonuses

  SPRINT_BONUS = 1           # Distance increased with a running jump

   

  JUMP_SE = ["Jump2", 50, 120]

   

  MAX_JUMP_BONUS = 3         # The maximum bonus you can get from equips/actors

   

  NO_JUMP_REGIONS = [1,2,3]  # Region ID's that the player cannot jump over

 

#------------------------------------------------------------------------------#

#  END SCRIPT SETUP OPTIONS

#------------------------------------------------------------------------------#

 

end

 

class RPG::BaseItem

  def jump_bonus

    if @jump_bonus.nil?

      if @note =~ /<jump_bonus: (.*)>/i

        @jump_bonus = $1.to_i

      else

        @jump_bonus = 0

      end

    end

    @jump_bonus

  end

end # RPG::BaseItem

 

 

class Game_Player < Game_Character

  attr_accessor :priority_type

   

  alias galv_jump_player_initialize initialize

  def initialize

    galv_jump_player_initialize

    @jump_equip_bonus = 0

  end

 

  alias galv_jump_player_refresh refresh

  def refresh

    get_jump_equip_bonus

    galv_jump_player_refresh

  end

   

  def get_jump_equip_bonus

    bonus = 0 + $game_party.leader.jump_bonus

    $game_party.leader.equips.each { |eq| bonus += eq.jump_bonus if !eq.nil?}

    @jump_equip_bonus = [bonus,Galv_Jump::MAX_JUMP_BONUS].min

  end

   

  alias galv_jump_move_by_input move_by_input

  def move_by_input

    return if jumping?

    @priority_type = 1 if !jumping?

    galv_jump_move_by_input

    if !$game_switches[Galv_Jump::DISABLE_SWITCH] && Input.trigger?(Galv_Jump::BUTTON)

      do_jump if !$game_map.interpreter.running? && !jumping? && normal_walk?

    end

  end

   

  def do_jump

    get_bonuses

    @distance = Galv_Jump::DEFAULT_DISTANCE + @jump_bonus

    check_region

    check_distance

    if @can_jump

      RPG::SE.new(Galv_Jump::JUMP_SE[0], Galv_Jump::JUMP_SE[1], Galv_Jump::JUMP_SE[2]).play

      jump(@jump_x, @jump_y)

      @followers.each { |f| f.jump(@x - f.x, @y - f.y) }

    end

  end

   

  def get_bonuses

    @jump_bonus = 0 + @jump_equip_bonus

    @jump_bonus += Galv_Jump::SPRINT_BONUS if dash? && moving?

  end

   

  def check_region

    @max_x = 0

    @max_y = 0

    case @direction

    when 2

      @max_y = @distance

      (@distance+1).times { |i| return @max_y = i if stopper?(@x, @y+i+1) }

    when 4

      @max_x = -@distance

      (@distance+1).times { |i| return @max_x = -i if stopper?(@x-i-1, @y) }

    when 6

      @max_x = @distance

      (@distance+1).times { |i| return @max_x = i if stopper?(@x+i+1, @y) }

    when 8

      @max_y = -@distance

      (@distance+1).times { |i| return @max_y = -i if stopper?(@x, @y-i-1) }

    end

  end

   

  def stopper?(x,y)

    Galv_Jump::NO_JUMP_REGIONS.include?($game_map.region_id(x,y)) ||

      !$game_map.stopper_event?(x,y)

  end

   

  def canpass?(x,y)

    map_passable?(x, y, @direction) &&

    $game_map.blocking_event?(x,y) ||

    Galv_Jump::NO_JUMP_REGIONS.include?($game_map.region_id(x,y))

  end

   

  def check_distance

    @jump_x = 0

    @jump_y = 0

    ch = []

    @can_jump = true

 

    case @direction

    when 2

      @jump_y = @distance

      @distance.times { |i| ch << @jump_y - i if canpass?(@x, @y + @jump_y - i) }

      ch.delete_if {|x| x > @max_y }

      @jump_y = ch.max if !ch.empty?

    when 4

      @jump_x = -@distance

      @distance.times { |i| ch << @jump_x + i if canpass?(@x + @jump_x + i, @y) }

      ch.delete_if {|x| x < @max_x }

      @jump_x = ch.min if !ch.empty?

    when 6

      @jump_x = @distance

      @distance.times { |i| ch << @jump_x - i if canpass?(@x + @jump_x - i, @y) }

      ch.delete_if {|x| x > @max_x }

      @jump_x = ch.max if !ch.empty?

    when 8

      @jump_y = -@distance

      @distance.times { |i| ch << @jump_y + i if canpass?(@x, @y + @jump_y + i) }

      ch.delete_if {|x| x < @max_y }

      @jump_y = ch.min if !ch.empty?

    end

    if ch.empty?

      @jump_y = 0

      @jump_x = 0

      @can_jump = false

    end

  end

   

  def jump(x_plus, y_plus)

    @priority_type = 1.5

    super

  end

end # Game_Player < Game_Character

 

 

class Game_Map

  def blocking_event?(x,y)

    events_xy(x,y).each { |e| return false if e.priority_type == 1 }

     return true

   end

 

  def stopper_event?(x,y)

    events_xy(x,y).each { |e|

      next if e.list.nil?

      return false if e.list[0].code == 108 && e.list[0].parameters[0] == "<block>"

    }

     return true

   end

end # Game_Map

 

 

class Game_Actor < Game_Battler

  attr_accessor :jump_bonus

   

  alias galv_jump_actor_initialize initialize

  def initialize(actor_id)

    galv_jump_actor_initialize(actor_id)

    @jump_bonus = $data_actors[actor_id].jump_bonus

  end

end # Game_Actor < Game_Battler

 

 

class Scene_Menu < Scene_MenuBase

  def return_scene

    $game_player.refresh

    super

  end

end # Scene_Menu < Scene_MenuBase

 

class Game_Interpreter

  def jump_bonus(actor,bonus)

    $game_actors[actor].jump_bonus = bonus

    $game_player.refresh

  end

end # Game_Interpreter

 

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
184
First Language
Meowish
Primarily Uses
That's because the default jump in the rgss3 engine never check if the landing position is valid or not.

You will either need to add a small script to change that or simply add this to your condition branch check.

$game_map.passable?($game_player.x+jump, $game_player.y+jump, $game_player.direction)where jump = the number you use for jumping -1

passable? is a method to check if it's passable from Tile A to destination Tile based on X direction.

So you are not calculating on the landing tile but a tile before the landing tile on direction X. In this case, direction X is the current player direction.

There might be a smarter way around this, but i can't think of any at the moment.

You might be able to find some useful information here too:

http://forums.rpgmakerweb.com/index.php?/topic/3452-direction-based-line-of-sight-events/
 

squarer00t

Villager
Member
Joined
Jul 2, 2015
Messages
13
Reaction score
0
First Language
italian
Primarily Uses
Thanks for the help!

I tried adding that to my conditional branch, but nothing changed unfortunately. :<

I feel bad asking, as I would do this myself if i could- but I don't know anything about scripting and scripting language. Would it be possible to add a condition to the conditional branch that checks whether the tile before the landing tile on direction x has a certain region ID? So that you wouldnt be able to jump over tiles with that particular region ID... such as walls... and the borders of the map, I suppose.

Is it doable? I... uh. attempted. To write that myself ...

($game_player.x+1, $game_player.y+1, $game_player.direction)= $game_map.region_id = 1

but I have no clue how to do that and this nonsense garbage mess came out ahaha  :(

--

EDIT::

Nevermind, I think I managed to do that with events! 
 
Last edited by a moderator:

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
184
First Language
Meowish
Primarily Uses
You don't have to use any region ID block for that, since the passable check itself should be enough to check if the tile is passable or not.

Adding a region ID block will still have to make use of the passable method if doing it via script.

http://forums.rpgmakerweb.com/index.php?/topic/45980-terrain-tagregion-passage-block-via-switch/

And it still have no effect on the default jump method since it doesn't check for passability by itself.

So in the end you will still be using the passable check. You should be able to do it via eventing with the way i said in the last post.

If you want to block the passage using dummy events (which can cause lag if you have a bunch of them), you can simply use the collision check instead:

$game_player.collide_with_characters?(x, y)where x and y is your landing point.

And oh, if you want the whole party to move with the player (followers jumping).

You can try my party controller script too!

http://forums.rpgmakerweb.com/index.php?/topic/45165-party-movement-controller/
 

squarer00t

Villager
Member
Joined
Jul 2, 2015
Messages
13
Reaction score
0
First Language
italian
Primarily Uses
Nevermind, I edited this part of the script

 if !$game_switches[Galv_Jump::DISABLE_SWITCH] && Input.trigger?(Galv_Jump::BUTTON)      do_jump if !$game_map.interpreter.running? && !jumping? && normal_walk?

as 

if !$game_switches[Galv_Jump::DISABLE_SWITCH] && Input.trigger?(Galv_Jump::BUTTON)      do_jump if !$game_map.interpreter.running? && !jumping? && Input.dir4 == 6 or Input.dir4 == 2 or Input.dir4 == 8 or Input.dir4 == 4

and by sheer luck it worked perfectly. I had no idea what I was doing but... well! Okay good I guess pff :>

Again, thanks for the help tho! And your party controller script sounds super cool, I'll remember to use it in the future!
 
Last edited by a moderator:

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
184
First Language
Meowish
Primarily Uses
and by sheer luck it worked perfectly. I had no idea what I was doing but... well! Okay good I guess pff :>
Simply use Input.dir4 should work if you want an input by direction check, it's either that 4 numbers anyway, so you don't have to put that up 4 times in the script.

Again, thanks for the help tho! And your party controller script sounds super cool, I'll remember to use it in the future!
You're welcome and glad you like the script!
 

squarer00t

Villager
Member
Joined
Jul 2, 2015
Messages
13
Reaction score
0
First Language
italian
Primarily Uses
Oh! Really? Ahaha okay!! Sorry I... literally had no clue what I was doing  ;)  I'll change right away
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,051
Messages
1,018,549
Members
137,837
Latest member
Dabi
Top