Advertisement
Kakakadafi

[Overwrite] -> CT System

Jan 16th, 2018
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 16.77 KB | None | 0 0
  1. #==============================================================================
  2. # ■ +++ MOG - XAS CT SYSTEM (v1.0) +++
  3. #==============================================================================
  4. # By Moghunter
  5. # http://www.atelier-rgss.com
  6. #==============================================================================
  7. # Toggles the system Combat Time in XAS.
  8. #===============================================================================
  9. # To modify the CT system in the characters during the game, use the
  10. # commands below.
  11. #
  12. # actor = $game_party.members[X1]
  13. # actor.ct_max = X2
  14. # actor.ct_speed = X3
  15. #
  16. # X1 - ID the character.
  17. # X2 - A maximum amount of CT.
  18. # X3 - Speed ​​load the CT.
  19. #
  20. #===============================================================================
  21. module XAS_CT_SYSTEM
  22.   #General position of hud.
  23.   CT_POSITION = [49,75]
  24.   # Meter position.
  25.   CT_GAUGE_POSITION = [6, 23]
  26.   #Shares of skills should wait until the meter get full.
  27.   CT_ACTION_WAIT_FULL_GAUGE = false
  28.   # Enable cost of shell.
  29.   CT_COST_SHIELD = false
  30.   #Enable cost of running.
  31.   CT_COST_DASH = false
  32.   # Definition sound when the meter get full.
  33.   CT_FULL_SE = "nothing"
  34.   # Minimum to activate the sound meter full.
  35.   CT_FULL_SE_ENABLE_TIME = 90
  36.   # Definition sound when the meter reaches zero.
  37.   CT_WAIT_SE = "nothing"
  38.   # Animation speed meter.
  39.   CT_METER_FLOW_SPEED = 0
  40.   # Initial setting of the CT for each character.
  41.   # ACTOR_INITIAL_CT  = {A=>[B,C]}
  42.   # A = Actor ID
  43.   # B = CT Max
  44.   # C = CT speed  
  45.   ACTOR_INITIAL_CT = {
  46.   1=>[100,0.9]
  47.   }
  48. end  
  49.  
  50. #===============================================================================
  51. # ■ Game Temp
  52. #===============================================================================
  53. class Game_Temp
  54.  
  55.   attr_accessor :ct_sound_time
  56.  
  57.   #--------------------------------------------------------------------------
  58.   # ● Initialize
  59.   #--------------------------------------------------------------------------        
  60.   alias xas_ct_initialize initialize
  61.   def initialize
  62.       @ct_sound_time = 0
  63.       xas_ct_initialize
  64.   end
  65.  
  66. end  
  67.  
  68.  
  69. #===============================================================================
  70. # ■ Game System
  71. #===============================================================================
  72. class Game_System
  73.  
  74.   attr_accessor :ct_system
  75.  
  76.   #--------------------------------------------------------------------------
  77.   # ● Initialize
  78.   #--------------------------------------------------------------------------        
  79.   alias xas_ct_initialize initialize
  80.   def initialize
  81.       @ct_system = true
  82.       xas_ct_initialize
  83.   end
  84.  
  85. end  
  86.  
  87.  
  88. #===============================================================================
  89. # ■ Game Actor
  90. #===============================================================================
  91. class Game_Actor < Game_Battler
  92.  
  93.   attr_accessor :ct
  94.   attr_accessor :ct_max
  95.   attr_accessor :ct_speed
  96.   attr_accessor :ct_wait
  97.  
  98.   #--------------------------------------------------------------------------
  99.   # ● Iinitialize
  100.   #--------------------------------------------------------------------------      
  101.   alias xas_ct_initialize initialize
  102.   def initialize(actor_id)
  103.       xas_ct_initialize(actor_id)
  104.       @ct_max = 100
  105.       @ct = @ct_max
  106.       @ct_speed = 1
  107.       @ct_wait = false
  108.       setup_initial_ct(actor_id)      
  109.   end  
  110.  
  111.   #--------------------------------------------------------------------------
  112.   # ● Setup Initial CT
  113.   #--------------------------------------------------------------------------        
  114.   def setup_initial_ct(actor_id)
  115.       ct_par = XAS_CT_SYSTEM::ACTOR_INITIAL_CT[actor_id]
  116.       if ct_par != nil
  117.          @ct_max = ct_par[0]
  118.          @ct_speed = ct_par[1]
  119.          @ct = @ct_max
  120.       end  
  121.   end
  122.  
  123.   #--------------------------------------------------------------------------
  124.   # ● CT
  125.   #--------------------------------------------------------------------------        
  126.   def ct
  127.       n = [[@ct, 0].max, @ct_max].min
  128.       return n    
  129.   end  
  130.  
  131.   #--------------------------------------------------------------------------
  132.   # ● CT Max
  133.   #--------------------------------------------------------------------------        
  134.   def ct_max
  135.       n = [[@ct_max, 1].max, 9999].min
  136.       return n    
  137.   end
  138.  
  139.   #--------------------------------------------------------------------------
  140.   # ● CT Speed
  141.   #--------------------------------------------------------------------------        
  142.   def ct_speed
  143.       n_speed = @ct_speed * @ct_max / 100
  144.       n = [[n_speed, 0].max, @ct_max].min
  145.       return n    
  146.   end  
  147.  
  148. end
  149.  
  150. #==============================================================================
  151. # ■ Game_Character
  152. #==============================================================================
  153. class Game_Character < Game_CharacterBase
  154.  
  155.   #--------------------------------------------------------------------------
  156.   # ● CT SPEED
  157.   #--------------------------------------------------------------------------            
  158.   alias xas_ct_update_battler update_battler
  159.   def update_battler
  160.       update_ct if can_update_ct?
  161.       xas_ct_update_battler
  162.   end  
  163.  
  164.   #--------------------------------------------------------------------------
  165.   # ● Can Update CT
  166.   #--------------------------------------------------------------------------              
  167.   def can_update_ct?
  168.       return false if self.battler.is_a?(Game_Enemy)        
  169.       return true
  170.   end  
  171.  
  172.   #--------------------------------------------------------------------------
  173.   # ● Update CT
  174.   #--------------------------------------------------------------------------              
  175.   def update_ct
  176.       if $game_system.ct_system == false
  177.          self.battler.ct = self.battler.ct_max
  178.          self.battler.ct_wait = false
  179.          return
  180.       end  
  181.       $game_temp.ct_sound_time += 1 if self.battler.ct < self.battler.ct_max
  182.       execute_ct_effect
  183.       update_ct_wait
  184.   end  
  185.  
  186.   #--------------------------------------------------------------------------
  187.   # ● Update CT
  188.   #--------------------------------------------------------------------------                
  189.   def execute_ct_effect      
  190.       if ct_cost?
  191.          self.battler.ct -= 1
  192.       else
  193.          self.battler.ct += self.battler.ct_speed
  194.       end
  195.   end  
  196.    
  197.   #--------------------------------------------------------------------------
  198.   # ● CT Cost
  199.   #--------------------------------------------------------------------------                  
  200.   def ct_cost?
  201.       return true if self.battler.shield and XAS_CT_SYSTEM::CT_COST_SHIELD
  202.       return true if @dash_active and XAS_CT_SYSTEM::CT_COST_DASH
  203.       return false
  204.   end
  205.  
  206.   #--------------------------------------------------------------------------
  207.   # ● Update CT Wait
  208.   #--------------------------------------------------------------------------                    
  209.   def update_ct_wait
  210.       if self.battler.ct == self.battler.ct_max and self.battler.ct_wait == true
  211.          self.battler.ct_wait = false
  212.          if $game_temp.ct_sound_time >= XAS_CT_SYSTEM::CT_FULL_SE_ENABLE_TIME
  213.             se = XAS_CT_SYSTEM::CT_FULL_SE
  214.             if se != nil
  215.                Audio.se_play("Audio/SE/" + se , 70, 100)
  216.             end  
  217.          end
  218.          $game_temp.ct_sound_time = 0
  219.       end
  220.       return if self.battler.ct_wait  
  221.       if self.battler.ct < self.battler.ct_max
  222.          if self.battler.shield or self.dash_active
  223.             if self.battler.ct == 0
  224.                self.battler.ct_wait = true
  225.                self.battler.shield = false
  226.                self.dash_active = false
  227.                se = XAS_CT_SYSTEM::CT_WAIT_SE
  228.                if se != nil
  229.                   Audio.se_play("Audio/SE/" + se , 100, 100)
  230.                end  
  231.             end  
  232.             return
  233.          end
  234.          self.battler.ct_wait = true
  235.       end  
  236.   end  
  237. end  
  238.  
  239. #==============================================================================
  240. # ■ Game_Player
  241. #==============================================================================
  242. class Game_Player < Game_Character
  243.  
  244.   #--------------------------------------------------------------------------
  245.   # ● Can Update Command?
  246.   #--------------------------------------------------------------------------      
  247.   alias ct_can_use_command can_use_command?
  248.   def can_use_command?
  249.       if XAS_CT_SYSTEM::CT_ACTION_WAIT_FULL_GAUGE
  250.          return false if self.battler.ct_wait
  251.       end  
  252.       ct_can_use_command
  253.   end  
  254.  
  255.   #--------------------------------------------------------------------------
  256.   # ● Can Update Command?
  257.   #--------------------------------------------------------------------------        
  258.   alias xas_ct_can_use_shield_command can_use_shield_command?
  259.   def can_use_shield_command?
  260.       if self.battler.ct < 0.1 * self.battler.ct_max
  261.       @use_shield_command = false
  262.       return false
  263.  
  264.      end
  265.       xas_ct_can_use_shield_command
  266.   end
  267.  
  268.   #--------------------------------------------------------------------------
  269.   # ● Can Update Command?
  270.   #--------------------------------------------------------------------------        
  271.   alias xas_ct_can_dash can_dash?
  272.  def can_dash?
  273.        if self.battler.ct < 0.1 * self.battler.ct_max
  274.  
  275.             @dash_active = false
  276.  
  277.              return false
  278.  
  279.      end
  280.       xas_ct_can_dash
  281.   end  
  282.  
  283. end  
  284.  
  285. #===============================================================================
  286. # ■  XAS_ACTION
  287. #===============================================================================
  288. module XAS_ACTION
  289.    
  290.   #--------------------------------------------------------------------------
  291.   # ● enough_skill_cost?
  292.   #--------------------------------------------------------------------------          
  293.   alias xas_ct_enough_skill_cost enough_skill_cost?
  294.   def enough_skill_cost?(skill)
  295.       return false unless check_ct_cost?(skill)
  296.       xas_ct_enough_skill_cost(skill)
  297.   end  
  298.  
  299.   #--------------------------------------------------------------------------
  300.   # ● Check CT Cost?
  301.   #--------------------------------------------------------------------------  
  302.   def check_ct_cost?(skill)
  303.       return true if $game_system.ct_system == false
  304.       return true if self.battler.is_a?(Game_Enemy)
  305.       if skill.note =~ /<CT Cost = (\d+)>/
  306.          ct_cost = $1.to_i
  307.          if ct_cost != nil
  308.             return false if self.battler.ct < ct_cost
  309.             self.battler.ct -= ct_cost
  310.          end
  311.       end  
  312.       return true  
  313.   end
  314.      
  315. end  
  316.  
  317. #==============================================================================
  318. # ■ Action_Meter_Sprite
  319. #==============================================================================
  320. class CT_Sprite
  321.   include XAS_CT_SYSTEM
  322.  
  323.   #--------------------------------------------------------------------------
  324.   # * initialize
  325.   #--------------------------------------------------------------------------
  326.   def initialize
  327.       @actor = $game_party.members[0]
  328.       return if @actor == nil
  329.       @hide_sprite = MOG_ULTIMA_HUD::REMOVE_PARTS[@actor.id].include?(:stamina)
  330.       update_meter_type
  331.       create_layout
  332.       create_meter    
  333.   end
  334.  
  335.   #--------------------------------------------------------------------------
  336.   # ● Create Layout
  337.   #--------------------------------------------------------------------------    
  338.   def create_layout
  339.     @layout_sprite = Sprite.new
  340.     @layout_sprite.bitmap = Cache.system("XAS_CT_Layout")
  341.     @layout_sprite.z = 150
  342.     @layout_sprite.x = CT_POSITION[0]
  343.     @layout_sprite.y = CT_POSITION[1]
  344.   end  
  345.  
  346.   #--------------------------------------------------------------------------
  347.   # ● Create Meter
  348.   #--------------------------------------------------------------------------  
  349.   def create_meter
  350.       @meter_flow = 0
  351.       @meter_image = Cache.system("XAS_CT_Meter")
  352.       @meter_height = @meter_image.height / 5
  353.       @meter_range = @meter_image.width / 3
  354.       @meter_sprite = Sprite.new
  355.       @meter_sprite.bitmap = Bitmap.new(@meter_image.width,@meter_image.height)
  356.       @meter_sprite.z = 150
  357.       @meter_sprite.x =  CT_POSITION[0] + CT_GAUGE_POSITION[0]
  358.       @meter_sprite.y =  CT_POSITION[1] + CT_GAUGE_POSITION[1]
  359.       update_meter_flow
  360.   end  
  361.  
  362.   #--------------------------------------------------------------------------
  363.   # ● Dispose
  364.   #--------------------------------------------------------------------------
  365.   def dispose
  366.       return if @actor == nil
  367.       @meter_sprite.bitmap.dispose
  368.       @meter_sprite.dispose
  369.       @meter_image.dispose
  370.       @layout_sprite.bitmap.dispose
  371.       @layout_sprite.dispose
  372.   end
  373.  
  374.   #--------------------------------------------------------------------------
  375.   # ● update
  376.   #--------------------------------------------------------------------------
  377.   def update
  378.       return if @actor == nil
  379.       update_meter_type
  380.       update_meter_flow
  381.       update_visible
  382.   end
  383.  
  384.   #--------------------------------------------------------------------------
  385.   # ● Update Visible
  386.   #--------------------------------------------------------------------------      
  387.   def update_visible
  388.       vis = $game_system.enable_hud
  389.       vis = false if $game_system.ct_system == false
  390.       vis = false if @hide_sprite
  391.       @meter_sprite.visible = vis
  392.       @layout_sprite.visible = vis
  393.   end
  394.  
  395.   #--------------------------------------------------------------------------
  396.   # ● Refresh CT Meter
  397.   #--------------------------------------------------------------------------  
  398.   def refresh
  399.       dispose
  400.       initialize
  401.   end
  402.  
  403.   #--------------------------------------------------------------------------
  404.   # * update
  405.   #--------------------------------------------------------------------------  
  406.   def update_meter_type
  407.       if @actor.cast_action[4] > 0
  408.          @ct_now = @actor.cast_action[4]
  409.          @ct_max = @actor.cast_action[1]
  410.          @ct_type = 3
  411.       elsif @actor.x_charge_action[2] > 15  
  412.          @ct_now = @actor.x_charge_action[2]
  413.          @ct_max = @actor.x_charge_action[1]
  414.          @ct_type = 3
  415.       else
  416.          @ct_now = @actor.ct
  417.          @ct_max = @actor.ct_max
  418.          @ct_type = 1
  419.          unless @actor.ct_wait  
  420.             if $game_player.dash_active or @actor.shield
  421.                @ct_type = 2
  422.             end  
  423.          end
  424.       end
  425.       @ct_max = [[@ct_max, 1].max, @ct_max].min
  426.       @ct_now = [[@ct_now, 0].max, @ct_max].min
  427.       if @ct_type == 3 and @ct_now == @ct_max
  428.          @ct_type = rand(3)        
  429.       else
  430.          @ct_type = 0 if @ct_now == @ct_max
  431.       end
  432.   end
  433.  
  434.   #--------------------------------------------------------------------------
  435.   # *  meter_flow_update
  436.   #--------------------------------------------------------------------------
  437.   def update_meter_flow      
  438.       @meter_sprite.bitmap.clear      
  439.       meter_src_rect = Rect.new(0, @meter_height * 4, @meter_image.width / 3, @meter_height)
  440.       @meter_sprite.bitmap.blt(0,0, @meter_image, meter_src_rect)      
  441.       @meter_width = @meter_range  * @ct_now / @ct_max        
  442.       meter_src_rect = Rect.new(@meter_flow,@ct_type * @meter_height , @meter_width, @meter_height)
  443.       @meter_sprite.bitmap.blt(0,0, @meter_image, meter_src_rect)
  444.       @meter_flow += CT_METER_FLOW_SPEED  
  445.       if @meter_flow >= @meter_image.width - @meter_range
  446.          @meter_flow = 0  
  447.       end
  448.   end            
  449. end
  450.  
  451. #==============================================================================
  452. # ■ Spriteset_Map
  453. #==============================================================================
  454. class Spriteset_Map
  455.   #--------------------------------------------------------------------------
  456.   # ● initialize  
  457.   #--------------------------------------------------------------------------
  458.   alias xas_ct_initialize initialize
  459.   def initialize  
  460.       @ct = CT_Sprite.new
  461.       xas_ct_initialize
  462.   end
  463.  
  464.   #--------------------------------------------------------------------------
  465.   # ● dispose
  466.   #--------------------------------------------------------------------------
  467.   alias xas_ct_dispose dispose
  468.   def dispose    
  469.       @ct.dispose
  470.       xas_ct_dispose
  471.   end
  472.  
  473.   #--------------------------------------------------------------------------
  474.   # ● update  
  475.   #--------------------------------------------------------------------------
  476.   alias xas_ct_update update
  477.   def update  
  478.       @ct.update
  479.       xas_ct_update
  480.   end
  481.    
  482.   #--------------------------------------------------------------------------
  483.   # ● Refresh Hud
  484.   #--------------------------------------------------------------------------  
  485.   alias xas_ct_refresh_hud refresh_hud
  486.   def refresh_hud
  487.       xas_ct_refresh_hud
  488.       @ct.refresh
  489.   end        
  490.  
  491. end
  492.  
  493. $mog_rgss3_xas_ct_system = true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement