Advertisement
LiTTleDRAgo

[RGSS] DRG - XAS Jump Attack

Nov 3rd, 2013
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.63 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  2. # DRG - XAS Jump Attack
  3. # Version: 1.00
  4. # Author : LiTTleDRAgo
  5. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  6. #
  7. #  Introduction :
  8. #  - If you press C + direction player's facing, player will do a jump forward
  9. #    and attack
  10. #  - If you press C + other direction, player will step 2 tiles away to that
  11. #    direction
  12. #
  13. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  14.  
  15. ($imported ||= {})[:drg_xas_jump_attack] = 1.00
  16.  
  17. $xrxs_xas                   || raise("This script needs XAS 3.91 to work")
  18. $imported[:drg_core_engine] || raise("This script needs Drago Core Engine")
  19.  
  20. #==============================================================================
  21. # ** Game_Player
  22. #------------------------------------------------------------------------------
  23. #  This class handles the player. Its functions include event starting
  24. #  determinants and map scrolling. Refer to "$game_player" for the one
  25. #  instance of this class.
  26. #==============================================================================
  27. class Game_Player
  28.   #--------------------------------------------------------------------------
  29.   # ● Public Instance_Variables
  30.   #--------------------------------------------------------------------------
  31.   attr_sec_accessor :jump_attack_range,  1  # Attack jump 1 tiles
  32.   attr_sec_accessor :jump_step_range,    2  # Step jump 2 tiles
  33.   #--------------------------------------------------------------------------
  34.   # ● Alias Listing
  35.   #--------------------------------------------------------------------------
  36.   alias_sec_method :update_command_jump_attack,  :update_command
  37.   alias_sec_method :update_movement_jump_attack, :update_movement
  38.   #--------------------------------------------------------------------------
  39.   # ● Update Command
  40.   #--------------------------------------------------------------------------
  41.   def update_command(*args)
  42.     if Input.press?(XAS_COMMAND::ATTACK_ACTION1)
  43.       dir = Input.dir4
  44.       if dir == @direction
  45.         unless @jump_attack == 1
  46.           @jump_attack = 1
  47.           jump_to_direction(dir, jump_attack_range) && active_attack
  48.         end
  49.         return
  50.       elsif dir > 0  
  51.         unless @jump_attack == 2
  52.           fix = @direction_fix
  53.           (@jump_attack = 2) && (@direction_fix = true)
  54.           jump_to_direction(dir, jump_step_range) && @direction_fix = fix
  55.         end
  56.         return
  57.       end
  58.     end
  59.     @jump_attack = nil
  60.     update_command_jump_attack(*args)    
  61.   end    
  62.   #--------------------------------------------------------------------------
  63.   # ● Jump to Direction
  64.   #--------------------------------------------------------------------------
  65.   def jump_to_direction(dir, jump_range = 2)# Jump 2 tiles away
  66.     jumping? or (p = jump_range).times do
  67.       unless jumping?
  68.         case dir
  69.         when 6 then throw_event?(jump_range,0,p)  && jump(jump_range,0)
  70.         when 4 then throw_event?(-jump_range,0,p) && jump(-jump_range,0)
  71.         when 2 then throw_event?(0,jump_range,p)  && jump(0,jump_range)
  72.         when 8 then throw_event?(0,-jump_range,p) && jump(0,-jump_range)
  73.         end
  74.         jump_range == 1 && jump(0,0)
  75.         (jump_range -= 1) && (p -= 1)
  76.       end        
  77.     end
  78.     true
  79.   end
  80.   #--------------------------------------------------------------------------
  81.   # ● Movement Update
  82.   #--------------------------------------------------------------------------
  83.   def update_movement
  84.     update_movement_jump_attack unless Input.press?(XAS_COMMAND::ATTACK_ACTION1)
  85.   end
  86. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement