Jump to content
Days_of_Ruin

Player Jump via Button Press

Recommended Posts

Hello friends!

 

I come to you bearing a humble request.

Of which I cannot accomplish on my own.

 

I am looking for someone with a healthy knowledge of scripting to see if they might convert an already working RPGVX script to VXA.

 

The script in question is a Player Jump script allowing the player to jump anywhere on the map at the push of a button instead of eventing a single instance.

 

My game, which I had previously been working on in VX, desperately needs this script to continue onto fulfilment.

 

Here is the script from VX.

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

#

# Jump Input

#

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

# Author: SuperOverlord

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

# Features:

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

# o Set an input for jumping on map.

# o Jump further if dashing.

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

# Instructions:

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

# o Place below materials, above main.

# o Change values as desired in configuration below.

# o To disallow jumping any of the following can be done:

# - Have the switch from config set to 'off'.

# - Include '[NOJUMP]' in a map name for no jumping on that map.

# - Include 'NOJUMP' in an event name for no jumping through that event.

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

# Script Calls

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

# o To change the distance a jump takes the player.

#

# $game_player.jump_distance = n

# ~ n is the new jump distance

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

# Compatibility

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

# Put below any scripts that redefine move_by_input.

# Should be compatible with 8 direction scripts, though untested.

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

 

module SOV

module JumpInput

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

# Configuration

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

# Input used for jumping.

INPUT = Input::X

# Id of switch required on to allow jumping by input.

SWITCH_ID = 101

# Jump distance (Can be changed in game with a script call)

INT_JUMP_DIS = 0

# How far extra a jump takes the player if they're dashing.

DASH_JUMP_DIS = 3

# Sound effect played when the player jumps. [filename, volume, pitch]

SE = ["Blow2",25,150]

# Should the player jump on the spot if no further is possible

JUMP_ON_SPOT = true

# Time in frames to block the player from jumping

JUMP_COOLDOWN = 30

# An array of tile ids the player can't jump through.

NO_JUMP_TILES = []

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

# End Configuration ~Fall rate: -9.8m/sec~

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

end

end

 

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

# Import

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

$imported = {} if $imported == nil

$imported['JumpInput'] = true

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

 

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

# ** Sound

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

 

module Sound

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

# * Play SE

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

def self.play_jump

a,b,c = *SOV::JumpInput::SE

Audio.se_play("Audio/SE/#{a}", b, c)

end

end

 

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

# ** Game_Map

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

 

class Game_Map

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

# * Get the map name

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

def name

if @name == nil

data = load_data("Data/MapInfos.rvdata")

@name = data[@map_id].name

end

return @name

end

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

# * Can the player jump in this map. (Doesn't effect jumping via events)

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

def no_jump_by_input?

if @no_jump == nil

@no_jump = name.upcase.include?('[N0JUMP]')

end

return @no_jump

end

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

# * Can the tile at x,y be jumped over?

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

def jump_passable?(x,y)

# Check valid tile id

for i in 0..2

return false if SOV::JumpInput::NO_JUMP_TILES.include?( data[x,y,i] )

end

# Check valid events

for event in events_xy(x,y)

return false if event.name.upcase.include?('NOJUMP')

end

return true

end

end

 

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

# ** Game_Event

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

 

class Game_Event

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

# * Get events name

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

def name

@event.name

end

end

 

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

# ** Game_Player

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

 

class Game_Player

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

# Alias List

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

alias sov_ji_move_by_input move_by_input

alias sov_ji_initialize initialize

alias sov_ji_update update

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

# Public Instance Variables

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

attr_accessor :jump_distance

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

# * Initialize

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

def initialize

sov_ji_initialize

@jump_distance = SOV::JumpInput::INT_JUMP_DIS

@jump_cooldown = 0

end

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

# * Update

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

def update

@jump_cooldown -= 1 if @jump_cooldown > 0 and not jumping?

sov_ji_update

end

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

# * Move by input

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

def move_by_input

sov_ji_move_by_input

jump_by_input

end

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

# * Determine how far a jump would would move the player

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

def calc_jump_xy

# Find dx and dy depending on direction

case @direction%3

when 0 # 3,6,9

dy = @direction == 3 ? -1 : ( @direction == 9 ? 1 : 0 )

dx = 1

when 1 # 1,4,7

dy = @direction == 1 ? -1 : ( @direction == 7 ? 1 : 0 )

dx = -1

when 2 # 2,8

dy = @direction == 8 ? -1 : ( @direction == 2 ? 1 : 0 )

dx = 0

end

# Add one to distance if dashing

dis = @jump_distance

dis += SOV::JumpInput::DASH_JUMP_DIS if dash? and moving?

# Find furthest jump can be

max_x = dx * dis + @x

max_y = dy * dis + @y

# Find furthest passable tile

while not passable?(max_x, max_y)

max_x -= dx unless max_x == @x

max_y -= dy unless max_y == @y

return 0, 0 if max_x == @x and max_y == @y

end

# Find how far jump can make it to furthest passable tile

count_x = last_pass_x = @x

count_y = last_pass_y = @y

while count_x != max_x or count_y != max_y

# Next tile can be jumped into

if $game_map.jump_passable?(count_x+dx, count_y+dy)

# Increase counters

count_x += dx unless count_x == max_x

count_y += dy unless count_y == max_y

else

# Return last passable tile

return last_pass_x-@x, last_pass_y-@y

end

# Current tile is passable

if passable?(count_x, count_y)

last_pass_x,last_pass_y = count_x, count_y

end

end

return count_x-@x, count_y-@y

end

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

# * Jump by input

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

def jump_by_input

if Input.trigger?(SOV::JumpInput::INPUT) and not $game_player.in_vehicle?

return unless $game_switches[sOV::JumpInput::SWITCH_ID]

return if $game_map.no_jump_by_input?

return if @jump_cooldown > 0

x_plus, y_plus = calc_jump_xy

return if not SOV::JumpInput::JUMP_ON_SPOT and x_plus == 0 and y_plus == 0

Sound.play_jump

@jump_cooldown = SOV::JumpInput::JUMP_COOLDOWN

jump(x_plus, y_plus)

end

end

end

 

I, as well as SuperOverlord i'm sure, would be incredibly thankful if this were converted for VXA.

Share this post


Link to post
Share on other sites

You may want to take the time to just learn how to do this yourself if all you want to do is have the player jump when you press a button, that would be a good script to practice/start learning how to script with.

Share this post


Link to post
Share on other sites

Wilkituska: Victor's script is nice, but also pretty restrictive. See his notes:

 

# IMPORTANT: This mechanic was developed for single player porpouse only.

# It WILL NOT WORK WITH THE FOLLOWERS. Disable the followers visibility on

# where jumping is allowed. I will not make this system works with followers,

# simply don't ask anything about it.

 

So if there's another quickie script for jumping, I'd support that too (although there probably already is one posted somewhere).

 

By the way, to original poster: Have you tried using the VX script in Ace? Not every VX script has to be converted to Ace, some also work with both. When I just tested it in my project, the input to jump didn't work, but the script produced no errors, so there's probably only the actual jump method that needs some tweaking.

Edited by Caveras

Share this post


Link to post
Share on other sites

Try this guys... Victor probably didn't allow followers because it's a fair amount of extra work to get it to look nice when you have followers on.

 

# Allows jumping by input...
# ** module INPUT

module JUMP
 module Settings
  DashJumpSize = 3
  JumpSize = 2
  Key = :X # the game key that can be pressed to jump. Not necessarily the
			  # same as the keyboard key
 end # End - Settings
end # End - JUMP

# ** Game_Player

class Game_Player < Game_Character

 # alias method move_by_input
 alias jump_settings_move_by_input_alias_method_49271 move_by_input
 def move_by_input
jump_settings_move_by_input_alias_method_49271
try_jump if Input.trigger?(JUMP::Settings::Key)
 end # End - move_by_input

 def try_jump

#print "inside try_jump \n"

jump_x, jump_y = 0,0
case @direction
when 2
  jump_y = get_jump_size
when 4
  jump_x = -get_jump_size
when 6
  jump_x = get_jump_size
when 8
  jump_y = -get_jump_size
end
jump(jump_x, jump_y) if map_passable?(jump_x+@x, jump_y+@y, @direction)
 end # End - try_jump

 def get_jump_size
val = dash? ? JUMP::Settings::DashJumpSize : JUMP::Settings::JumpSize
#print "jump size = #{val}\n"
#val
 end

end # End - Game_Player

Edited by eshra

Share this post


Link to post
Share on other sites

In eshra's script, between

def try_jump
and
jump_x, jump_y = 0,0
, add this in a new line:
return unless $game_map.map_id == id_of_the_map_you_want_this_to_work_in

If you want it to work in multiple maps, but not in every one, use this instead:

return unless array_of_map_ids_it_works_in.include?($game_map.map_id)

You can make your array like this:

[ID1, ID2, ID3]
with ID1 etc. obviously exchanged for the respective ID's.

Share this post


Link to post
Share on other sites

Thanks all.

I've been much too busy with college and my job to work on my game much, but lately i've had huge amounts of spare time which i've devoted strictly to finishing this project.

I've decided to use Galv's Jump script for my game, but I greatly appreciate the help from you all.

Some screens and a demo should be up by april. I'd love some feedback and criticism.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×