#--------------------------------# # This script offers "movement" in the form of hopping or wiggling! # Assign state ids to JUMPSTATE or STUCKSTATE # Use your action (Space) button to hop around # You can place in the event to make them hop! # Additional credit to Galv as this was based on his Jump System. #--------------------------------# ($imported ||= {})["Galvs_Jump_Ability"] = true module Galv_Jump JUMPSTATE = [12,14] STUCKSTATE = [13] JUMP_SE = "Audio/SE/015-Jump01.ogg" STUCK_SE= "Audio/SE/032-Switch01.ogg" end module RPG class Event::Page def event_hop? @list.each {|cmd| if cmd.code == 108 && res = cmd.parameters[0].match("") return true end } return false end end end class Game_Battler def has_stuck? return true if @states.any? {|i| Galv_Jump::STUCKSTATE.include?(i)} return false end def has_hop? return true if @states.any? {|i| Galv_Jump::JUMPSTATE.include?(i)} return false end end class Game_Party def update_state_stepper Audio.se_play(Galv_Jump::STUCK_SE) actors[0].remove_states_auto check_map_slip_damage if rand(3) == 0 $game_player.make_encounter_count if rand(3) == 0 end end ################################ class Game_Character def move_down(turn_enabled = true) if turn_enabled turn_down end if passable?(@x, @y, 2) turn_down if hop_state? or stuck_state? do_jump else @y += 1 increase_steps end else # Impassable check_event_trigger_touch(@x, @y+1) # Touch event is triggered? end end def move_left(turn_enabled = true) if turn_enabled turn_left end if passable?(@x, @y, 4) # Passable turn_left if hop_state? or stuck_state? do_jump else @x -= 1 increase_steps end else # Impassable check_event_trigger_touch(@x-1, @y) # Touch event is triggered? end end def move_right(turn_enabled = true) if turn_enabled turn_right end if passable?(@x, @y,6) # Passable turn_right if hop_state? or stuck_state? do_jump else @x += 1 increase_steps end else # Impassable check_event_trigger_touch(@x+1, @y) # Touch event is triggered? end end def move_up(turn_enabled = true) if turn_enabled turn_up end if passable?(@x, @y,8 ) # Passable turn_up if hop_state? or stuck_state? do_jump else @y -= 1 increase_steps end else # Impassable check_event_trigger_touch(@x, @y-1) # Touch event is triggered? end end def randstep rand(2) == 0 ? @pattern = 1 : @pattern = 3 end def canpass?(x,y) return true end def check_distance distance = 1 @jump_x = 0 @jump_y = 0 ch = [] @can_jump = true bob = @direction case bob when 2 @jump_y = 1 distance.times { |i| ch << @jump_y - i if canpass?(@x, @y + @jump_y - i) } @jump_y = ch.max if !ch.empty? when 4 @jump_x = -1 distance.times { |i| ch << @jump_x + i if canpass?(@x + @jump_x + i, @y) } @jump_x = ch.min if !ch.empty? when 6 @jump_x = 1 distance.times { |i| ch << @jump_x - i if canpass?(@x + @jump_x - i, @y) } @jump_x = ch.max if !ch.empty? when 8 @jump_y = -1 distance.times { |i| ch << @jump_y + i if canpass?(@x, @y + @jump_y + i) } @jump_y = ch.min if !ch.empty? end if ch.empty? @jump_y = 0 @jump_x = 0 @can_jump = false end end end class Game_Player < Game_Character def stuck_state? return false if $game_party.actors.empty? return true if $game_party.actors[0].has_stuck? return false end def hop_state? return false if $game_party.actors.empty? return true if $game_party.actors[0].has_hop? return false end def update # Remember whether or not moving in local variables last_moving = moving? # If moving, event running, move route forcing, and message window # display are all not occurring if !jumping? @alway_on_top = false unless moving? or $game_system.map_interpreter.running? or @move_route_forcing or $game_temp.message_window_showing if stuck_state? i = false i = true if Input.trigger?(2) or Input.trigger?(4) or Input.trigger?(6) or Input.trigger?(8) if i == true randstep $game_party.update_state_stepper end elsif hop_state? @direction = Input.dir4 if Input.dir4 > 0 if Input.trigger?(Input::C) @direction = Input.dir4 if Input.dir4 > 0 do_jump if !$game_system.map_interpreter.running? && !jumping? end else case Input.dir4 when 2 move_down when 4 move_left when 6 move_right when 8 move_up end end end end # Remember coordinates in local variables last_real_x = @real_x last_real_y = @real_y super # If character moves down and is positioned lower than the center # of the screen if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y # Scroll map down $game_map.scroll_down(@real_y - last_real_y) end # If character moves left and is positioned more let on-screen than # center if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X # Scroll map left $game_map.scroll_left(last_real_x - @real_x) end # If character moves right and is positioned more right on-screen than # center if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X # Scroll map right $game_map.scroll_right(@real_x - last_real_x) end # If character moves up and is positioned higher than the center # of the screen if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y # Scroll map up $game_map.scroll_up(last_real_y - @real_y) end # If not moving unless moving? # If player was moving last time if last_moving # Event determinant is via touch of same position event result = check_event_trigger_here([1,2]) # If event which started does not exist if result == false # Disregard if debug mode is ON and ctrl key was pressed unless $DEBUG and Input.press?(Input::CTRL) # Encounter countdown if @encounter_count > 0 @encounter_count -= 1 end end end end # If C button was pressed if Input.trigger?(Input::C) # Same position and front event determinant check_event_trigger_here([0]) check_event_trigger_there([0,1,2]) end end end def do_jump check_distance bob = @direction @can_jump = false unless passable?(@x,@y,bob) if @can_jump $game_party.actors[0].remove_states_auto increase_steps Audio.se_play(Galv_Jump::JUMP_SE) if hop_state? jump(@jump_x, @jump_y)# if hop_state? randstep check_event_trigger_touch(@x + @jump_x, @y + @jump_y) end end def jump(x_plus, y_plus) @alway_on_top = true super end end class Game_Event < Game_Character def hop_state? return true if @page and @page.event_hop? return false end def stuck_state? return false end def do_jump check_distance @can_jump = false unless passable?(@x,@y,@direction) jump(@jump_x, @jump_y) if @can_jump randstep end def erase @erased = true @alway_on_top = true refresh end end