Heartbreak61

「SIMPLE STUPID」 Jump! ver.0.60

May 11th, 2013
743
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.45 KB | None | 0 0
  1. #==============================================================================
  2. # ■ 「SIMPLE STUPID」 Jump! ver.0.60
  3. # by HBK61
  4. # Requires: N/A
  5. # Rewrites method:  N/A
  6. # Aliases method:
  7. #   Game_Player#initialize
  8. #   Scene_Map#update_scene
  9. #              
  10. #==============================================================================
  11. # CHANGELOG
  12. # - ver0.60  2013.05.12   Started the script & finished
  13. #==============================================================================
  14. # INTRODUCTION
  15. # - Simply stupidly add jump effect on map with button press.
  16. #==============================================================================
  17. # INSTRUCTION
  18. # - Set the properties below
  19. #==============================================================================
  20.  
  21. module HBK
  22.   module JUMP
  23. #==============================================================================
  24. # CONFIGURATION
  25.     Jump_Distance = 3 # jump distance
  26.     Jump_Button = :X # button to do jumping
  27.     Jump_Delay = 0 # jump delay before another jump in seconds
  28.     Jump_Switch = 0 # set this switch to enable/disable jump
  29. # END of CONFIGURATION
  30. #==============================================================================
  31.   end
  32. end
  33.  
  34. class Game_Player
  35.   alias hbk_ssjs_initialize initialize
  36.   def initialize
  37.     hbk_ssjs_initialize
  38.     @jump_delay = 0
  39.   end
  40.  
  41.   def button_jump
  42.   if $game_switches[HBK::JUMP::Jump_Switch] || HBK::JUMP::Jump_Switch == 0
  43.     return unless normal_walk?
  44.     return if @jump_delay > 0
  45.     @jump_delay = (HBK::JUMP::Jump_Delay * Graphics.frame_rate).to_i
  46.     i = HBK::JUMP::Jump_Distance
  47.     while i > 1
  48.       return if jumping?
  49.       if @direction == 2
  50.         xtgt = @x
  51.         ytgt = @y + i
  52.       elsif @direction == 4
  53.         xtgt = @x - i
  54.         ytgt = @y
  55.       elsif @direction == 8
  56.         xtgt = @x
  57.         ytgt = @y - i
  58.       elsif @direction == 6
  59.         xtgt = @x + i
  60.         ytgt = @y
  61.       end
  62.       ev = true
  63.       $game_map.events.each_key{|e|
  64.         if $game_map.events[e].x == xtgt && $game_map.events[e].y == ytgt && $game_map.events[e].normal_priority?
  65.           ev = false
  66.         end
  67.       }
  68.       if map_passable?(xtgt, ytgt, @direction) && ev
  69.         case @direction
  70.         when 2
  71.           jump(0,i)
  72.         when 4
  73.           jump(-i,0)
  74.         when 8
  75.           jump(0,-i)
  76.         when 6
  77.           jump(i,0)
  78.         end
  79.         @followers.each{|f| f.button_jump}
  80.         return
  81.       end
  82.       i -= 1
  83.     end
  84.   end
  85.   end
  86.  
  87.   attr_accessor :jump_delay, :button_jumping
  88. end
  89.  
  90. class Game_Follower
  91.   def button_jump
  92.     sx = dxffj($game_player.x)
  93.     sy = dyffj($game_player.y)
  94.     jump(sx,sy)
  95.   end
  96.  
  97.   def dxffj(x)
  98.     result = x - @x
  99.     if $game_map.loop_horizontal? && result.abs > $game_map.width / 2
  100.       if result < 0
  101.         result += $game_map.width
  102.       else
  103.         result -= $game_map.width
  104.       end
  105.     end
  106.     result
  107.   end
  108.  
  109.   def dyffj(y)
  110.     result = y - @y
  111.     if $game_map.loop_vertical? && result.abs > $game_map.height / 2
  112.       if result < 0
  113.         result += $game_map.height
  114.       else
  115.         result -= $game_map.height
  116.       end
  117.     end
  118.     result
  119.   end
  120. end
  121.  
  122. class Scene_Map
  123.   alias hbk_ssjs_update_scene update_scene
  124.   def update_scene
  125.     hbk_ssjs_update_scene
  126.     unless scene_changing?
  127.       $game_player.button_jump if Input.press?(HBK::JUMP::Jump_Button)
  128.       $game_player.jump_delay -= 1 if $game_player.jump_delay > 0
  129.     end
  130.   end  
  131. end
Advertisement
Add Comment
Please, Sign In to add comment