Kain Nobel
Member
This topic has been resolved, thank you everybody who helped. I will be re-posting the script in the Submitted Scripts forum within the next 48 hours but for now you can find it in my last post. Have fun and enjoy! :D
def jump_up(n = 1)
while n > 0
if passable?(@x, @y + (n-1), @direction)
jump(0, -n)
break
end
n -= 1
end
end
#-------------------------------------------------------------------------
# * Name : Can Jump?
# Info : Returns if Can Jump
# Author : SephirothSpawn
# Call Info : Integer Amounts, X & Y Plus
#-------------------------------------------------------------------------
def can_jump?(x_plus, y_plus)
new_x = @x + x_plus
new_y = @y + y_plus
return (x_plus == 0 and y_plus == 0) || passable?(new_x, new_y, 0)
end
def jump_up(x_plus, y_plus)
while !can_jump?(x_plus, y_plus)
break if x_plus == 0 && y_plus == 0
# subtract/add your x_plus and y_plus but also considering angles. if you need help, let me know.
end
jump(x_plus, y_plus)
end
#==============================================================================
# ** Game_Player jump modifications
#------------------------------------------------------------------------------
# Blabla this script enables you to jump with the X controller button (def. A)
#==============================================================================
class Game_Player < Game_Character
JUMPSWITCH = 1 # This switch indicates the possibility of jumping
CATERPILLAR = false # Set this true, if you're using the caterpillar script
JUMPSOUND = "Audio\\SE\\Jump1" # 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 $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
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
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 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
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
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
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
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
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
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
 #-----------------------------------------------------------------------------
 # * Jump Up
 #-----------------------------------------------------------------------------
 def jump_up(n = 1)
  unless jump_dist.nil?
   jump_sound
   jump(0, jump_dist.last)#(-n, 0)
  end
 end
 #-----------------------------------------------------------------------------
 # * Jump Dist Modifier
 #-----------------------------------------------------------------------------
 def jump_dist
  @spaces = []
  case @direction
  when 2 # Down
   for i in 0...(-Jump::Distance)
    if passable?(self.x, self.y - i, 2)
     @spaces.push(i)
     return @spaces
    end
   end
  when 4 # Left
   for i in 0...(-Jump::Distance)
    if passable?(self.x + i, self.y, 4)
     @spaces.push(i)
     return @spaces
    end
   end
  when 6 # Right
   for i in 0...(-Jump::Distance)
    if passable?(self.x - i, self.y, 6)
     @spaces.push(i)
     return @spaces
    end
   end
  when 8 # Up
   for i in 0...(-Jump::Distance)
    if passable?(self.x, self.y + i, 8)
     @spaces.push(i)
     return @spaces
    end
   end
  end
 end
end
#===============================================================================
# ** Jump
#-------------------------------------------------------------------------------
#Â Â Determines jump speed and wether or not player is allowed to 'jump' on map.
#===============================================================================
module Jump
 Enabled   = true
 Debug    = false
 XcludeMaps = [3]
 Distance  = 3
 SE     = "015-Jump01"#, 80, 90]
 LandSE   = ["016-Jump02", 80, 100]
 Button   = Input::ALT
end
################################################################################
#===============================================================================
# ** Game_Map
#-------------------------------------------------------------------------------
#Â Added a method which will determine if jump is disabled on this map.
#===============================================================================
class Game_Map
 #-----------------------------------------------------------------------------
 # * Disable Dash?
 #-----------------------------------------------------------------------------
 def disable_jump?
  return Jump::XcludeMaps.include?(@map_id)
 end
end
################################################################################
#===============================================================================
# ** Game_Character
#-------------------------------------------------------------------------------
#Â Â This class has been appended with easy jump commands.
#===============================================================================
class Game_Character
 #-----------------------------------------------------------------------------
 # * Alias Methods
 #-----------------------------------------------------------------------------
 alias_method :kn_jumpscript_game_character_initialize, :initialize
 alias_method :kn_jumpscript_game_character_jump,    :jump
 #-----------------------------------------------------------------------------
 # * Initialize (*Aliased*)
 #-----------------------------------------------------------------------------
 def initialize
  kn_jumpscript_game_character_initialize
  @spaces = []
  @jump_se = Jump::SE
  @land_se = Jump::LandSE
 end
 #-----------------------------------------------------------------------------
 # * Jump (*Aliased*)
 #-----------------------------------------------------------------------------
 def jump(x_plus, y_plus)
  jump_x, jump_y = self.x + x_plus, self.y + y_plus
  kn_jumpscript_game_character_jump(x_plus, y_plus)
  if self.x == jump_x && self.y == jump_y && !@land_se.nil?
   land_sound
  end
 end
 #-----------------------------------------------------------------------------
 # * Jump Up
 #-----------------------------------------------------------------------------
 def jump_up
  unless jump_dist.nil?
   jump_sound
   jump(0, jump_dist.last)#(-n, 0)
  end
 end
 #-----------------------------------------------------------------------------
 # * Jump Down
 #-----------------------------------------------------------------------------
 def jump_down
  unless jump_dist.nil?
   jump_sound
   jump(0, -jump_dist.last)
  end
 end
 #-----------------------------------------------------------------------------
 # * Jump Left
 #-----------------------------------------------------------------------------
 def jump_left
  unless jump_dist.nil?
   jump_sound
   jump(jump_dist.last, 0)#(-n, 0)
  end
 end
 #-----------------------------------------------------------------------------
 # * Jump Right
 #-----------------------------------------------------------------------------
 def jump_right
  unless jump_dist.nil?
   jump_sound
   jump(-jump_dist.last, 0)#(n, 0)
  end
 end
 #-----------------------------------------------------------------------------
 # * Jump Sound
 #-----------------------------------------------------------------------------
 def jump_sound
  unless @jump_se.nil?
   if @jump_se.is_a?(Array)
    return Audio.se_play("Audio/SE/"+@jump_se[0],@jump_se[1],@jump_se[2])
   elsif @jump_se.is_a?(String)
    return Audio.se_play("Audio/SE/" + @jump_se, 100, 100)
   end
  end
 end
 #-----------------------------------------------------------------------------
 # * Jump Sound
 #-----------------------------------------------------------------------------
 def land_sound
  unless @jump_se.nil?
   if @land_se.is_a?(Array)
    return Audio.se_play("Audio/SE/"+@land_se[0],@land_se[1],@land_se[2])
   elsif @land_se.is_a?(String)
    return Audio.se_play("Audio/SE/" + @land_se, 100, 100)
   end
  end
 end
 #-----------------------------------------------------------------------------
 # * Jump Args
 #-----------------------------------------------------------------------------
 def jump_args
  case @direction
  when 2 # Facing Down
   return self.y > $game_map.height - Jump::Distance
  when 4 # Facing Left
   return self.x < Jump::Distance
  when 6
   return self.x > $game_map.width - Jump::Distance
  when 8 # Facing Up
   return self.y < Jump::Distance
  end
 end
 #-----------------------------------------------------------------------------
 # * Jump Dist Modifier
 #-----------------------------------------------------------------------------
 def jump_dist
  @spaces = []
  case @direction
  when 2 # Down
   for i in 0...(-Jump::Distance)
    if passable?(self.x, self.y - i, 2)
     @spaces.push(i)
     return @spaces
    end
   end
  when 4 # Left
   for i in 0...(-Jump::Distance)
    if passable?(self.x + i, self.y, 4)
     @spaces.push(i)
     return @spaces
    end
   end
  when 6 # Right
   for i in 0...(-Jump::Distance)
    if passable?(self.x - i, self.y, 6)
     @spaces.push(i)
     return @spaces
    end
   end
  when 8 # Up
   for i in 0...(-Jump::Distance)
    if passable?(self.x, self.y + i, 8)
     @spaces.push(i)
     return @spaces
    end
   end
  end
 end
end
#===============================================================================
# ** Scene_Map
#-------------------------------------------------------------------------------
#Â Â This scene has been enhanced to allow the player to jump when a certain
# button is pressed.
#===============================================================================
class Scene_Map
 #-----------------------------------------------------------------------------
 # * Alias Listing
 #-----------------------------------------------------------------------------
 alias_method :kn_jumpscript_scene_map_update,    :update
 #-----------------------------------------------------------------------------
 # * Update Method (*Aliased*)
 #-----------------------------------------------------------------------------
 def update
  kn_jumpscript_scene_map_update
  if Jump::Enabled
   jump_command
  end
 end
 #-----------------------------------------------------------------------------
 # * Jump Command
 #-----------------------------------------------------------------------------
 def jump_command
  if Input.press?(Jump::Button)
   unless $game_player.jumping? or $game_player.move_route_forcing or
   $game_player.jump_args or $game_temp.message_window_showing or
   $game_system.map_interpreter.running?
    case $game_player.direction
    when 2 ; $game_player.jump_down
    when 4 ; $game_player.jump_left
    when 6 ; $game_player.jump_right
    when 8 ; $game_player.jump_up
    end
   end
  end
 end
end
################################################################################
def jump_dist
@spaces = []
case @direction
when 2 # Down
for i in 0...(-Jump::Distance)
if passable?(self.x, self.y - i, 2)
@spaces.push(i)
return @spaces
end
end
#...
jump(0, jump_dist.last) # Would be a jump_down, -jump_dist.last would be up
def jump_dist
@spaces = []
case @direction
when 2 # Down
for i in 0...(-Jump::Distance)
if passable?(self.x, self.y - i, 2)
@spaces.push(i)
return @spaces
end
end
#===============================================================================
# ** Jump
#-------------------------------------------------------------------------------
# Written by : Kain Nobel
# Version : 0.5
# Last Update : 07/15/2008
# Created On : 07/14/2008
#-------------------------------------------------------------------------------
# * Special thanks to David A Black @ ruby-forum.com for simplifying jump_dist.
################################################################################
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
# ~** CUSTOMIZABLE CONSTANTS - BEGIN **~ #
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
################################################################################
module Jump
Enabled = true
Debug = false
XcludeMaps = [3]
Distance = 4
SE = "015-Jump01"#, 80, 90]
LandSE = ["016-Jump02", 80, 100]
Button = Input::ALT
end
################################################################################
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
# ~** CUSTOMIZABLE CONSTANTS - END **~ #
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
################################################################################
#===============================================================================
# ** Game_Map
#-------------------------------------------------------------------------------
# Added a method which will determine if jump is disabled on this map.
#===============================================================================
class Game_Map
#-----------------------------------------------------------------------------
# * Disable Dash?
#-----------------------------------------------------------------------------
def disable_jump?
return Jump::XcludeMaps.include?(@map_id)
end
end
################################################################################
#===============================================================================
# ** Game_Character
#-------------------------------------------------------------------------------
# This class has been appended with easy jump commands.
#===============================================================================
class Game_Character
attr_reader :spaces
#-----------------------------------------------------------------------------
# * Alias Methods
#-----------------------------------------------------------------------------
alias_method :kn_jumpscript_game_character_initialize, :initialize
alias_method :kn_jumpscript_game_character_jump, :jump
#-----------------------------------------------------------------------------
# * Initialize (*Aliased*)
#-----------------------------------------------------------------------------
def initialize
kn_jumpscript_game_character_initialize
@spaces = []
@jump_se = Jump::SE
@land_se = Jump::LandSE
end
#-----------------------------------------------------------------------------
# * Jump (*Aliased*)
#-----------------------------------------------------------------------------
def jump(x_plus, y_plus)
jump_x, jump_y = self.x + x_plus, self.y + y_plus
kn_jumpscript_game_character_jump(x_plus, y_plus)
if self.x == jump_x && self.y == jump_y && !@land_se.nil?
land_sound
end
end
#-----------------------------------------------------------------------------
# * Jump Up
#-----------------------------------------------------------------------------
def jump_up
unless jump_dist[-1].nil? or jump_dist[-1] == 0
jump_sound
jump(0, -jump_dist.last)
end
end
#-----------------------------------------------------------------------------
# * Jump Down
#-----------------------------------------------------------------------------
def jump_down
unless jump_dist[-1].nil? or jump_dist[-1] == 0
jump_sound
jump(0, jump_dist.last)
end
end
#-----------------------------------------------------------------------------
# * Jump Left
#-----------------------------------------------------------------------------
def jump_left
unless jump_dist[-1].nil? or jump_dist[-1] == 0
jump_sound
jump(-jump_dist.last, 0)
end
end
#-----------------------------------------------------------------------------
# * Jump Right
#-----------------------------------------------------------------------------
def jump_right
unless jump_dist[-1].nil? or jump_dist[-1] == 0
jump_sound
jump(jump_dist.last, 0)
end
end
#-----------------------------------------------------------------------------
# * Jump Sound
#-----------------------------------------------------------------------------
def jump_sound
unless @jump_se.nil?
if @jump_se.is_a?(Array)
return Audio.se_play("Audio/SE/"+@jump_se[0],@jump_se[1],@jump_se[2])
elsif @jump_se.is_a?(String)
return Audio.se_play("Audio/SE/" + @jump_se, 100, 100)
end
end
end
#-----------------------------------------------------------------------------
# * Jump Sound
#-----------------------------------------------------------------------------
def land_sound
unless @jump_se.nil?
if @land_se.is_a?(Array)
return Audio.se_play("Audio/SE/"+@land_se[0],@land_se[1],@land_se[2])
elsif @land_se.is_a?(String)
return Audio.se_play("Audio/SE/" + @land_se, 100, 100)
end
end
end
#-----------------------------------------------------------------------------
# * Jump Args
#-----------------------------------------------------------------------------
def jump_args
case @direction
when 2 # Facing Down
return self.y > $game_map.height - Jump::Distance
when 4 # Facing Left
return self.x < Jump::Distance
when 6
return self.x > $game_map.width - Jump::Distance
when 8 # Facing Up
return self.y < Jump::Distance
end
end
#-----------------------------------------------------------------------------
# * Jump Dist Modifier
#-----------------------------------------------------------------------------
def jump_dist
spaces = []
0.upto(Jump::Distance-1) do |i|
pass = case @direction
when 2 then passable?(self.x, self.y + i, 2)
when 4 then passable?(self.x - i, self.y, 4)
when 6 then passable?(self.x + i, self.y, 6)
when 8 then passable?(self.x, self.y - i, 8)
end
if pass
spaces[i] = (i+1)
end
end
return spaces
end
end
#===============================================================================
# ** Scene_Map
#-------------------------------------------------------------------------------
# This scene has been enhanced to allow the player to jump when a certain
# button is pressed.
#===============================================================================
class Scene_Map
#-----------------------------------------------------------------------------
# * Alias Listing
#-----------------------------------------------------------------------------
alias_method :kn_jumpscript_scene_map_update, :update
#-----------------------------------------------------------------------------
# * Update Method (*Aliased*)
#-----------------------------------------------------------------------------
def update
kn_jumpscript_scene_map_update
if Jump::Enabled
jump_command
end
end
#-----------------------------------------------------------------------------
# * Jump Command
#-----------------------------------------------------------------------------
def jump_command
if Input.press?(Jump::Button)
unless $game_player.jumping? or $game_player.move_route_forcing or
$game_player.jump_args or $game_temp.message_window_showing or
$game_system.map_interpreter.running?
case $game_player.direction
when 2 ; $game_player.jump_down
when 4 ; $game_player.jump_left
when 6 ; $game_player.jump_right
when 8 ; $game_player.jump_up
end
end
end
end
end
################################################################################