Advertisement
Kakakadafi

backdash & frontdash

Aug 4th, 2017
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.44 KB | None | 0 0
  1. #==============================================================================
  2. # Configuration
  3. #==============================================================================
  4. module Kadafi
  5.   #--------------------------------------------------------------------------
  6.   # * Custom Accessories IDs to be Checked
  7.   #--------------------------------------------------------------------------
  8.   BackStep_CustomAccessoriesIDs = [] # [id, id, id, ... ]
  9.   ForwardStep_CustomAccessoriesIDs = [] # [id, id, id, ... ]
  10.   DashBackSuffix = "[bds]"
  11.   DashForwardSuffix = "[bds]"
  12. end
  13. #==============================================================================
  14. # Don't edit below this line unless you know what to do.
  15. #==============================================================================
  16.  
  17. class Game_Player < Game_Character
  18.  
  19.   def update_action_command
  20.     update_check_battler_equipment if can_check_battler_equipment?
  21.     update_backdash_button
  22.     update_dash_button
  23.     update_auto_target_shoot
  24.     update_combo_time
  25.     update_action_1_button
  26.     update_action_2_button
  27.     update_skill_button
  28.     update_item_button
  29.     update_change_leader_button
  30.     update_charge_button
  31.   end
  32.  
  33.   def update_backdash_button
  34.     backdash_distance = 2
  35.     if @backdash_cooldown
  36.       @backdash_cooldown -= 1
  37.       return if @backdash_cooldown > 0
  38.     end
  39.     if Input.trigger?(:L) && backstep_accessories_equipped?
  40.         @backdash_cooldown = 27
  41.         # YIN
  42.         pose_suffix = Kadafi::DashBackSuffix
  43.         make_pose(pose_suffix, @backdash_cooldown - 12)
  44.         image_only_on_dash(true)
  45.         Audio.se_play('Audio/ME/dash', 80, 150)
  46.         d = 10 - direction
  47.         a = 0
  48.         if @diagonal_direction != 0
  49.           backdash_distance = (backdash_distance * OrangeMovement::Tile_Sections/Math.sqrt(2)).to_i/OrangeMovement::Tile_Sections
  50.         end
  51.         backdash_distance.times do
  52.           OrangeMovement::Tile_Sections.times do
  53.             if @diagonal_direction != 0
  54.               case @diagonal_direction
  55.                 when 1
  56.                   if (diagonal_passable?(@x+a, @y-a, 6, 8) && diagonal_passable?(@x+(a*2), @y-(a*2), 6, 8))
  57.                     a += (my_step_size * 2)
  58.                   elsif diagonal_passable?(@x+a, @y-a, 6, 8)
  59.                     a += my_step_size
  60.                   end
  61.                 when 3
  62.                   if (diagonal_passable?(@x-a, @y-a, 4, 8) && diagonal_passable?(@x-(a*2), @y-(a*2), 4, 8))
  63.                     a += (my_step_size * 2)
  64.                   elsif diagonal_passable?(@x-a, @y-a, 4, 8)
  65.                     a += my_step_size
  66.                   end
  67.                 when 7
  68.                   if (diagonal_passable?(@x+a, @y+a, 6, 2) && diagonal_passable?(@x+(a*2), @y+(a*2), 6, 2))
  69.                     a += (my_step_size * 2)
  70.                   elsif diagonal_passable?(@x+a, @y+a, 6, 2)
  71.                     a += my_step_size
  72.                   end
  73.                 when 9
  74.                   if (diagonal_passable?(@x-a, @y+a, 4, 2) && diagonal_passable?(@x-(a*2), @y+(a*2), 4, 2))
  75.                     a += (my_step_size * 2)
  76.                   elsif diagonal_passable?(@x-a, @y+a, 4, 2)
  77.                     a += my_step_size
  78.                   end
  79.               end
  80.             else
  81.               case @direction
  82.                 when 2; a += my_step_size if passable?(@x, @y-a, d)
  83.                 when 4; a += my_step_size if passable?(@x+a, @y, d)
  84.                 when 6; a += my_step_size if passable?(@x-a, @y, d)
  85.                 when 8; a += my_step_size if passable?(@x, @y+a, d)
  86.               end
  87.             end  
  88.           end
  89.         end
  90.         if @diagonal_direction != 0
  91.           case @diagonal_direction
  92.             when 1
  93.               @x += a
  94.               @y -= a
  95.             when 3
  96.               @x -= a
  97.               @y -= a
  98.             when 7
  99.               @x += a
  100.               @y += a
  101.             when 9      
  102.               @x -= a
  103.               @y += a
  104.           end
  105.         else
  106.           case @direction
  107.             when 2
  108.               @x += 0
  109.               @y -= a
  110.             when 8
  111.               @x += 0
  112.               @y += a
  113.             when 4
  114.               @x += a
  115.               @y += 0
  116.             when 6
  117.               @x -= a
  118.               @y += 0
  119.           end
  120.         end              
  121.         @jump_peak = 3 + a.abs - @move_speed
  122.   #~       p @jump_peak
  123.         @jump_count = @jump_peak * 3.9
  124.         @stop_count = 0
  125.         straighten
  126.     end  
  127.   end
  128.    
  129.   #--------------------------------------------------------------------------
  130.   # * Determine if Custom Accessories Is Equipped
  131.   #--------------------------------------------------------------------------    
  132.   def backstep_accessories_equipped?
  133.     item = self.battler.equips[4]
  134.     if item
  135.       return Kadafi::BackStep_CustomAccessoriesIDs.include?(item.id)
  136.     else
  137.       return false
  138.     end
  139.   end
  140.    
  141.   def forwardstep_accessories_equipped?
  142.     item = self.battler.equips[4]
  143.     if item
  144.       return Kadafi::ForwardStep_CustomAccessoriesIDs.include?(item.id)
  145.     else
  146.       return false
  147.     end
  148.   end
  149.  
  150.   def update_jump
  151.     @jump_count -= 1
  152.     @real_x = (@real_x * @jump_count + @x) / (@jump_count + 1.0)
  153.     @real_y = (@real_y * @jump_count + @y) / (@jump_count + 1.0)
  154.     update_bush_depth
  155.     if @jump_count == 0
  156.       @real_x = @x = $game_map.round_x(@x)
  157.       @real_y = @y = $game_map.round_y(@y)
  158.       image_only_on_dash(true)
  159.     end
  160.   end
  161.  
  162. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement