Guest User

Untitled

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