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 Bug Fix

Gust

Member

VX Jump Bug Fix
By: Gustavo Bicalho

Introduction

Well, a friend of mine just noticed that if you try to jump onto a impassable place on VX, it lets you do that. At the other RPG Makers the impossible jump waits untill it can be completed (may be never) or is ignored (if the ignore option is selected at the move event command), just like a normal move.
This little code makes VX jumps work like jumps from the older versions.

Script

Code:
#==============================================================================

# VX Jump Bug Fix

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

# Author: Gustavo Bicalho

#==============================================================================

 

class Game_Character

  JUMP_IN_PLACE_IF_IMPOSSIBLE = false

  alias :gus_jumpfix_jump :jump

  def jump(x_plus, y_plus)

    if !passable?(@x+x_plus, @y+y_plus)

      return gus_jumpfix_jump(0,0) if (JUMP_IN_PLACE_IF_IMPOSSIBLE)

      @move_failed = true

      return

    end

    gus_jumpfix_jump(x_plus, y_plus)

  end

end

 

Instructions

Paste the code anywhere above Main and below Game_Character.
The constant JUMP_IN_PLACE_IF_IMPOSSIBLE allows a behavior modification: when you set it to true, if the jump is impossible the player will just jump in place. This is not the behavior you would expect at the older RM's, but I think it may be useful XD

Terms and Conditions

Use it as you wish, credits would be appreciated.
 
I personally think you shouldn't use a constant variable to do that.
Let's say someone has a jump system where he doesn't want to jump on impassable tiles, but wants to be able to do so in scripted events.
In this case, you're screwed because your variable is hard coded.

I think you should add this in Game_System as public variable (attr_accessor) so people can change this option on the fly.

Take care!
-Dargor
 
There's always a way to change a Constant value but only if it's an Array or Hash... that means JUMP_IN_PLACE_IF_IMPOSSIBLE = false should be transformed into an Array like this JUMP_IN_PLACE_IF_IMPOSSIBLE = [false]. Now every time you need to change it on the fly, you'll need to call like this way... JUMP_IN_PLACE_IF_IMPOSSIBLE[0] = false or true. It'd work best if included in a module not a class... but the module could be mixed in the class...
 
You are right. But changing constants is simply bad. Ruby constants are supposed to remain constant for the duration of the program. The Ruby interpreter does not actually enforce the constancy of constants, but it does issue a warning if a program changes the value of a constant. I'm not sure if it does this in RPG Maker but whatever, it's bad.

To be cleaner, you should add this at the top of your script

Code:
class Game_System

    attr_accessor :jump_in_place

    alias :game_system_jump_initialize :initialize

    def initialize

      game_system_jump_initialize

      @jump_in_place = false

    end

  end

end

Then replace this line:
return gus_jumpfix_jump(0,0) if (JUMP_IN_PLACE_IF_IMPOSSIBLE)

with this one:
return gus_jumpfix_jump(0,0) if $game_system.jump_in_place

You don't need to put this between parentheses.

Then, at any time in the game, you could call a script like this:
$game_system.jump_in_place = true/false

Also, by adding this variable to Game_System, it will be saved along with all other game data.
 
You are right. But changing constants is simply bad. Ruby constants are supposed to remain constant for the duration of the program. The Ruby interpreter does not actually enforce the constancy of constants, but it does issue a warning if a program changes the value of a constant. I'm not sure if it does this in RPG Maker but whatever, it's bad.
Normally you'll be right, but the method I explained above doesn't even show a warning either in IRB or in RM.

I agree with you that it should be saved in the saved game data file, but you can even do that with constants and a ternary condition.

I just wanted to show you there are always several ways to achieve the same purpose (and normally RM ways aren't the best).
 

Gust

Member

Actually, I thought about putting that setting in some global data variable like Dargor did. Or I could have a used a Switch.
But, remember, the main purpose of the script is to achieve the same behavior of the previous RPG Makers, and the "jump in place" thing is just an "extra". With that in mind, I left the option it in a constant for simplicity. Anyone who wants to change the behavior during the game can change the code to use a switch or something like that with little effort.

Anyway, thanks for the comments!
 

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