Advertisement
Kakakadafi

GamePad Extender Patch

Oct 29th, 2017
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 18.48 KB | None | 0 0
  1. #===============================================================================
  2. # This patch overwrite some methods from these scripts:
  3. # 1. XAS
  4. # 2. Dash & Backdash Skill
  5. #
  6. # Put this patch below "GamePad Extender" script.
  7. #===============================================================================
  8.  
  9. #===============================================================================
  10. # ■ XAS ACTION
  11. #===============================================================================
  12. module XAS_ACTION
  13.   #--------------------------------------------------------------------------
  14.   # ● Can Shoot
  15.   #--------------------------------------------------------------------------    
  16.   def can_shoot?(skill)
  17.       if self.battler == nil and self.tool_id > 0
  18.          @battler = self.action.user.battler
  19.       end  
  20.       return false if self.battler == nil
  21.       return false if skill == nil
  22.       return true if ignore_can_shoot?(skill)
  23.       enough_cost = true
  24.       return false if tools_on_map?(skill.id)      
  25.       if self.battler.state_mute  
  26.          seal_effect
  27.          return false
  28.       end  
  29.       if self.battler.cast_action[4].between?(1,self.battler.cast_action[1] -1)
  30.          return false
  31.       end
  32.       return false if check_cast_action?(skill)
  33.       return false if check_auto_target_select?(skill)
  34.       unless enough_skill_cost?(skill)
  35.          if $game_options
  36.             volume = 100 * $game_options.master_volume
  37.             volume *= $game_options.se_volume
  38.          else
  39.             volume = 100
  40.          end
  41.          Audio.se_play("Audio/SE/" + XAS_SOUND::ACTION_COST , volume.to_i, 100)
  42.          return false
  43.       end
  44.       return true
  45.   end
  46. end
  47.  
  48. #===============================================================================
  49. # ■ Game Player
  50. #===============================================================================
  51. class Game_Player < Game_Character
  52.   #--------------------------------------------------------------------------
  53.   # ● check_treasure_here  
  54.   #--------------------------------------------------------------------------                
  55.   def check_treasure_here  
  56.      for event in $game_map.events_xy(@x, @y)
  57.          if event.treasure != nil
  58.             name_pop = true
  59.             case event.treasure[0]            
  60.             when 1
  61.                   item = $data_items[event.treasure[1]]
  62.                   if can_execute_field_item_effect?(item)
  63.                      name_pop = false
  64.                   else  
  65.                      $game_party.gain_item(item, 1)
  66.                   end
  67.                   $game_map.need_refresh = true
  68.             when 2  
  69.                   item = $data_weapons[event.treasure[1]]
  70.                   $game_party.gain_item($data_weapons[event.treasure[1]], 1,false)
  71.             when 3
  72.                   item = $data_armors[event.treasure[1]]
  73.                   $game_party.gain_item(item, 1,false)
  74.             end
  75.              if $game_options
  76.                 volume = 100 * $game_options.master_volume
  77.                 volume *= $game_options.se_volume
  78.              else
  79.                 volume = 100
  80.              end
  81.             Audio.se_play("Audio/SE/" + XAS_SOUND::ITEM_DROP , volume.to_i, 100)  
  82.             event.erase
  83.             if item != nil
  84.                 if item.note =~ /<Drop Animation = (\d+)>/
  85.                    self.animation_id = $1.to_i
  86.                 end
  87.                 if XAS_DAMAGE_POP::DAMAGE_ITEM_POP and name_pop
  88.                    self.battler.damage = item.name.to_s
  89.                    self.battler.damage_pop = true
  90.                    self.battler.damage_type = "Item"
  91.                 end                      
  92.             end
  93.           end            
  94.      end  
  95.  end
  96.  
  97.   #--------------------------------------------------------------------------
  98.   # ● Check Actor Level
  99.   #--------------------------------------------------------------------------          
  100.   def check_actor_level
  101.       return if $game_party.in_battle
  102.       return if self.battler == nil
  103.       return if self.battler.old_level == self.battler.level
  104.       reset_old_level(false)
  105.       if self.battler.level > 1
  106.          if $game_options
  107.             volume = 100 * $game_options.master_volume
  108.             volume *= $game_options.se_volume
  109.          else
  110.             volume = 100
  111.          end
  112.          Audio.se_play("Audio/SE/" + XAS_SOUND::LEVEL_UP , volume.to_i, 100)
  113.          if XAS_WORD::ENABLE_WORD
  114.             $game_player.battler.damage = XAS_WORD::LEVEL_UP
  115.             $game_player.battler.damage_pop = true
  116.          end
  117.       end
  118.       $game_player.need_refresh = true
  119.   end
  120.  
  121.   #--------------------------------------------------------------------------
  122.   # ● Throw Event
  123.   #--------------------------------------------------------------------------  
  124.   def throw_event
  125.       for event in $game_map.events.values
  126.           if event.throw_active and not jumping?
  127.              $game_temp.can_throw = true
  128.              event.throw_action(event.throw)
  129.              return if $game_temp.can_throw == false
  130.              $game_temp.pickup_lock_time = event.jump_count
  131.              $game_temp.throw_position[0] = event.x
  132.              $game_temp.throw_position[1] = event.y
  133.              event.throw_active = false
  134.              $game_temp.pickup_lock = false    
  135.              if $game_options
  136.                 volume = 100 * $game_options.master_volume
  137.                 volume *= $game_options.se_volume
  138.              else
  139.                 volume = 100
  140.              end
  141.              Audio.se_play("Audio/SE/" + THROW_SE, volume.to_i, 100)
  142.              action_id = MOG_PICK_THROW::THROW_ACTION_ID
  143.              $game_player.shoot(action_id) unless (event.tool_id > 0 and event.action.first_impact_time > 0)
  144.           end        
  145.       end    
  146.       if event == nil or event.erased or event.dead?
  147.          $game_map.reset_pickup
  148.       end      
  149.   end
  150.  
  151.   #--------------------------------------------------------------------------
  152.   # ● Check Event Pickup
  153.   #--------------------------------------------------------------------------
  154.   def check_event_pickup(triggers)
  155.       front_x = $game_map.x_with_direction(@x, @direction)
  156.       front_y = $game_map.y_with_direction(@y, @direction)
  157.       for event in $game_map.events_xy(front_x, front_y)
  158.           if event.throw > 0 and not (jumping? or event.dead?)
  159.              event.throw_active = true
  160.              $game_temp.pickup_lock = true
  161.              event.jump(0,0)
  162.              $game_temp.pickup_lock_time = event.jump_count
  163.              event.x = @x
  164.              event.y = @y
  165.              if $game_options
  166.                 volume = 100 * $game_options.master_volume
  167.                 volume *= $game_options.se_volume
  168.              else
  169.                 volume = 100
  170.              end
  171.              Audio.se_play("Audio/SE/" + PICK_UP_SE, volume.to_i, 100)
  172.              @dash_active = false
  173.              @shield = false
  174.              reset_cast_temp
  175.           end
  176.       end
  177.   end
  178.  
  179.   #--------------------------------------------------------------------------
  180.   # * Update Dash Command
  181.   #--------------------------------------------------------------------------            
  182.   alias old_update_dash_button_2 update_dash_button
  183.   def update_dash_button
  184.     if @rush_cooldown > 0
  185.       @rush_cooldown -= 1
  186.     end
  187.     if rush_accessories_equipped? && !$game_map.interpreter.running?
  188.       # YIN
  189.       if @wait_cast_time && @wait_cast_time <= 0
  190.         if @stored_action
  191.           @rush_btn_released = true
  192.           @rush_cooldown = Kadafi::RushCooldown
  193.           self.battler.cast_action = @stored_action
  194.           self.shoot(self.battler.cast_action[0])
  195.           @stored_action = nil
  196.           @wait_cast_time = nil
  197.           return
  198.         end
  199.       end
  200.       if Input.press?(Kadafi::RushButton) && @rush_cooldown == 0
  201.         if @wait_cast_time && @wait_cast_time > 0
  202.           @wait_cast_time -= 1
  203.         end
  204.         # Check if the character is currently casting a skill
  205.         # and if it is, store it.
  206.         if self.battler.cast_action[0] != 0
  207.           @wait_cast_time = (self.battler.cast_action[4] - self.battler.cast_action[1]).abs
  208.           @stored_action = self.battler.cast_action.clone
  209.           self.battler.cast_action[0] = 0
  210.           self.battler.cast_action[1] = 0
  211.           self.battler.cast_action[2] = 0
  212.           self.battler.cast_action[3] = 0
  213.           self.battler.cast_action[4] = 0
  214.         end
  215.         @rush_btn_released = false
  216.         @rush_delay += 1
  217.         if @rush_delay > Kadafi::RushDelay
  218.           if !@rush_se_played
  219.             @dash_stance = VE_DEFAULT_RUSH_SUFIX
  220.              if $game_options
  221.                 volume = Kadafi::RushSEVolume * $game_options.master_volume
  222.                 volume *= $game_options.se_volume
  223.              else
  224.                 volume = Kadafi::RushSEVolume
  225.              end
  226.             Audio.se_play("Audio/SE/" + Kadafi::RushSE, volume.to_i, 100) rescue nil
  227.             @rush_se_played = true
  228.           end
  229.         end
  230.       else
  231.         if !@rush_btn_released
  232.           @rush_btn_released = true
  233.           @rush_cooldown = Kadafi::RushCooldown
  234.           if @stored_action
  235.             self.battler.cast_action = @stored_action
  236.             self.shoot(self.battler.cast_action[0])
  237.             @stored_action = nil
  238.             @wait_cast_time = nil
  239.           end
  240.         end
  241.         @dash_stance = VE_DEFAULT_DASH_SUFIX
  242.         @rush_se_played = false
  243.         @rush_delay = 0
  244.       end
  245.     end
  246.     old_update_dash_button_2
  247.   end
  248.  
  249.   # Update input for backdash
  250.   def update_backdash_button # And front dash!
  251.     backdash_distance = 2 # Also used as frontdash distance
  252.     if @backdash_cooldown # Also used as frontdash cooldown
  253.       @backdash_cooldown -= 1
  254.       return if @backdash_cooldown > 0
  255.     end
  256.     if Input.trigger?(PadConfig.dash)
  257.       if backstep_accessories_equipped?
  258.         @backdash_cooldown = 27
  259.         # YIN
  260.         pose_suffix = Kadafi::DashBackSuffix
  261.         make_pose(pose_suffix, @backdash_cooldown - 12)
  262.         image_only_on_dash(true)
  263.          if $game_options
  264.             volume = 80 * $game_options.master_volume
  265.             volume *= $game_options.se_volume
  266.          else
  267.             volume = 80
  268.          end
  269.         Audio.se_play('Audio/ME/dash', volume.to_i, 150)
  270.         d = 10 - direction
  271.         a = 0
  272.         if @diagonal_direction != 0
  273.           backdash_distance = (backdash_distance * OrangeMovement::Tile_Sections/Math.sqrt(2)).to_i/OrangeMovement::Tile_Sections
  274.         end
  275.         backdash_distance.times do
  276.           OrangeMovement::Tile_Sections.times do
  277.             if @diagonal_direction != 0
  278.               case @diagonal_direction
  279.                 when 1
  280.                   if (diagonal_passable?(@x+a, @y-a, 6, 8) && diagonal_passable?(@x+(a*2), @y-(a*2), 6, 8))
  281.                     a += (my_step_size * 2)
  282.                   elsif diagonal_passable?(@x+a, @y-a, 6, 8)
  283.                     a += my_step_size
  284.                   end
  285.                 when 3
  286.                   if (diagonal_passable?(@x-a, @y-a, 4, 8) && diagonal_passable?(@x-(a*2), @y-(a*2), 4, 8))
  287.                     a += (my_step_size * 2)
  288.                   elsif diagonal_passable?(@x-a, @y-a, 4, 8)
  289.                     a += my_step_size
  290.                   end
  291.                 when 7
  292.                   if (diagonal_passable?(@x+a, @y+a, 6, 2) && diagonal_passable?(@x+(a*2), @y+(a*2), 6, 2))
  293.                     a += (my_step_size * 2)
  294.                   elsif diagonal_passable?(@x+a, @y+a, 6, 2)
  295.                     a += my_step_size
  296.                   end
  297.                 when 9
  298.                   if (diagonal_passable?(@x-a, @y+a, 4, 2) && diagonal_passable?(@x-(a*2), @y+(a*2), 4, 2))
  299.                     a += (my_step_size * 2)
  300.                   elsif diagonal_passable?(@x-a, @y+a, 4, 2)
  301.                     a += my_step_size
  302.                   end
  303.               end
  304.             else
  305.               case @direction
  306.                 when 2; a += my_step_size if passable?(@x, @y-a, d)
  307.                 when 4; a += my_step_size if passable?(@x+a, @y, d)
  308.                 when 6; a += my_step_size if passable?(@x-a, @y, d)
  309.                 when 8; a += my_step_size if passable?(@x, @y+a, d)
  310.               end
  311.             end  
  312.           end
  313.         end
  314.         if @diagonal_direction != 0
  315.           case @diagonal_direction
  316.             when 1
  317.               @x += a
  318.               @y -= a
  319.             when 3
  320.               @x -= a
  321.               @y -= a
  322.             when 7
  323.               @x += a
  324.               @y += a
  325.             when 9      
  326.               @x -= a
  327.               @y += a
  328.           end
  329.         else
  330.           case @direction
  331.             when 2
  332.               @x += 0
  333.               @y -= a
  334.             when 8
  335.               @x += 0
  336.               @y += a
  337.             when 4
  338.               @x += a
  339.               @y += 0
  340.             when 6
  341.               @x -= a
  342.               @y += 0
  343.           end
  344.         end              
  345.         @jump_peak = 3 + a.abs - @move_speed
  346.   #~       p @jump_peak
  347.         @jump_count = @jump_peak * 3.9
  348.         @stop_count = 0
  349.         straighten
  350.        
  351.       # Front Dash
  352.       elsif forwardstep_accessories_equipped?
  353.         @backdash_cooldown = 27
  354.         # YIN
  355.         pose_suffix = Kadafi::DashForwardSuffix
  356.         make_pose(pose_suffix, @backdash_cooldown - 12)
  357.         image_only_on_dash(true)
  358.          if $game_options
  359.             volume = 80 * $game_options.master_volume
  360.             volume *= $game_options.se_volume
  361.          else
  362.             volume = 80
  363.          end
  364.         Audio.se_play('Audio/ME/dash', volume.to_i, 150)
  365.         d = direction
  366.         a = 0
  367.         if @diagonal_direction != 0
  368.           backdash_distance = (backdash_distance * OrangeMovement::Tile_Sections/Math.sqrt(2)).to_i/OrangeMovement::Tile_Sections
  369.         end
  370.         backdash_distance.times do
  371.           OrangeMovement::Tile_Sections.times do
  372.             if @diagonal_direction != 0
  373.               case @diagonal_direction
  374.                 when 1
  375.                   if (diagonal_passable?(@x-a, @y+a, 4, 2) && diagonal_passable?(@x-(a*2), @y+(a*2), 4, 2))
  376.                     a += (my_step_size * 2)
  377.                   elsif diagonal_passable?(@x-a, @y+a, 4, 2)
  378. #~                   if diagonal_passable?(@x-a, @y+a, 6, 8)
  379.                     a += my_step_size
  380.                   end
  381.                 when 3
  382.                   if (diagonal_passable?(@x+a, @y+a, 6, 2) && diagonal_passable?(@x+(a*2), @y+(a*2), 6, 2))
  383.                     a += (my_step_size * 2)
  384.                   elsif diagonal_passable?(@x+a, @y+a, 6, 2)
  385. #~                   if diagonal_passable?(@x+a, @y+a, 4, 8)
  386.                     a += my_step_size
  387.                   end
  388.                 when 7
  389.                   if (diagonal_passable?(@x-a, @y-a, 4, 8) && diagonal_passable?(@x-(a*2), @y-(a*2), 4, 8))
  390.                     a += (my_step_size * 2)
  391.                   elsif diagonal_passable?(@x-a, @y-a, 4, 8)
  392. #~                   if diagonal_passable?(@x-a, @y-a, 6, 2)
  393.                     a += my_step_size
  394.                   end
  395.                 when 9
  396.                   if (diagonal_passable?(@x+a, @y-a, 6, 8) && diagonal_passable?(@x+(a*2), @y-(a*2), 6, 8))
  397.                     a += (my_step_size * 2)
  398.                   elsif diagonal_passable?(@x+a, @y-a, 6, 8)
  399. #~                   if diagonal_passable?(@x+a, @y-a, 4, 2)
  400.                     a += my_step_size
  401.                   end
  402.               end
  403.             else
  404.               case @direction
  405.                 when 2; a += my_step_size if passable?(@x, @y+a, d)
  406.                 when 4; a += my_step_size if passable?(@x-a, @y, d)
  407.                 when 6; a += my_step_size if passable?(@x+a, @y, d)
  408.                 when 8; a += my_step_size if passable?(@x, @y-a, d)
  409.               end
  410.             end  
  411.           end
  412.         end
  413.         if @diagonal_direction != 0
  414.           case @diagonal_direction
  415.             when 1
  416.               @x -= a
  417.               @y += a
  418.             when 3
  419.               @x += a
  420.               @y += a
  421.             when 7
  422.               @x -= a
  423.               @y -= a
  424.             when 9      
  425.               @x += a
  426.               @y -= a
  427.           end
  428.         else
  429.           case @direction
  430.             when 2
  431.               @x += 0
  432.               @y += a
  433.             when 8
  434.               @x += 0
  435.               @y -= a
  436.             when 4
  437.               @x -= a
  438.               @y += 0
  439.             when 6
  440.               @x += a
  441.               @y += 0
  442.           end
  443.         end              
  444.         @jump_peak = 3 + a.abs - @move_speed
  445.         @jump_count = @jump_peak * 3.9
  446.         @stop_count = 0
  447.         straighten
  448.       end
  449.     end
  450.   end
  451. end  
  452.  
  453. #==============================================================================
  454. # ■ Game_Character
  455. #==============================================================================
  456. class Game_Character < Game_CharacterBase
  457.   #--------------------------------------------------------------------------
  458.   # ● Update CT Wait
  459.   #--------------------------------------------------------------------------                    
  460.   def update_ct_wait
  461.       if self.battler.ct == self.battler.ct_max and self.battler.ct_wait == true
  462.          self.battler.ct_wait = false
  463.          if $game_temp.ct_sound_time >= XAS_CT_SYSTEM::CT_FULL_SE_ENABLE_TIME
  464.             se = XAS_CT_SYSTEM::CT_FULL_SE
  465.             if se != nil
  466.                  if $game_options
  467.                     volume = 70 * $game_options.master_volume
  468.                     volume *= $game_options.se_volume
  469.                  else
  470.                     volume = 70
  471.                  end
  472.                Audio.se_play("Audio/SE/" + se , volume.to_i, 100)
  473.             end  
  474.          end
  475.          $game_temp.ct_sound_time = 0
  476.       end
  477.       return if self.battler.ct_wait  
  478.       if self.battler.ct < self.battler.ct_max
  479.          if self.battler.shield or self.dash_active
  480.             if self.battler.ct == 0
  481.                self.battler.ct_wait = true
  482.                self.battler.shield = false
  483.                self.dash_active = false
  484.                se = XAS_CT_SYSTEM::CT_WAIT_SE
  485.                if se != nil
  486.                      if $game_options
  487.                         volume = 100 * $game_options.master_volume
  488.                         volume *= $game_options.se_volume
  489.                      else
  490.                         volume = 100
  491.                      end
  492.                   Audio.se_play("Audio/SE/" + se , volume.to_i, 100)
  493.                end  
  494.             end  
  495.             return
  496.          end
  497.          self.battler.ct_wait = true
  498.       end  
  499.   end  
  500. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement