Advertisement
mrbubble

Guts Effect

Jul 11th, 2012
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 33.85 KB | None | 0 0
  1. #==============================================================================
  2. # ++ Guts Effect ++                                             v1.3 (7/12/12)
  3. #==============================================================================
  4. # Script by:
  5. #     Mr. Bubble ( http://mrbubblewand.wordpress.com/ )
  6. # Thanks:
  7. #     Yanfly, script and design references
  8. #--------------------------------------------------------------------------
  9. # Those who have played games from the Breath of Fire console-RPG series
  10. # may be familiar with the uncommon "Guts" gameplay mechanic. Guts is a
  11. # hidden parameter that provides a chance to automatically revive
  12. # immediately after being incapacitated.
  13. #
  14. # This script provides minimal developer options for modifying the
  15. # actual Guts stat in-game. For the most part, I expect people to just
  16. # use the <gain guts: n> tag and 'add_actor_guts' script call. But if
  17. # there is another way you'd like Guts to be modified, feel free
  18. # to suggest it.
  19. #
  20. # Please report any odd behavior involving triggered guts effects
  21. # in-battle.
  22. #--------------------------------------------------------------------------
  23. #   ++ Changelog ++
  24. #--------------------------------------------------------------------------
  25. # v1.3 : Fixed F8 crash with YEA Battle Engine. (7/12/2012)
  26. # v1.2 : Fixed a typo which caused an error. (7/12/2012)
  27. # v1.1 : 'Attack Times+' issues should be fixed now.
  28. #      : New option added in customization module.
  29. #      : Guts checks are now also done at the end of turn. (7/11/2012)
  30. # v1.0 : Initial release. (7/11/2012)
  31. #--------------------------------------------------------------------------
  32. #   ++ Installation ++
  33. #--------------------------------------------------------------------------
  34. # Install this script in the Materials section in your project's
  35. # script editor.
  36. #
  37. # Install this script below any scripts that modify the default
  38. # battle system in you script editor.
  39. #==============================================================================
  40. #   ++ Guts Notetags ++
  41. #==============================================================================
  42. # Note: Some tags are given shorter tags for typing convenience. You only
  43. #       need to use one <tag> from a given group for a notebox.
  44. #
  45. # The following Notetags are for Classes, Weapons, Armors, Enemies,
  46. # and States:
  47. #
  48. # <guts: +n>
  49. # <guts: -n>
  50. #   This tag lets classes, weapons, armors, and states modify guts parameter
  51. #   where n is a negative or positive value. This only affects battlers if
  52. #   they have the item equipped, state inflicted, etc. It will not permanently
  53. #   affect battler base guts similar to regular stats.
  54. #--------------------------------------------------------------------------
  55. # The following Notetags are for Skills and Items only:
  56. #
  57. # <grow guts: +n>
  58. # <grow guts: -n>
  59. #   This tag is only for items and skills. This will allow the item to
  60. #   permanently modify the target's guts parameter where n is a negative
  61. #   or positive value. To avoid potential gameplay oddities, this effect
  62. #   will not work on enemies.
  63. #--------------------------------------------------------------------------
  64. # The following Notetags are for Actors and Enemies only:
  65. #
  66. # <custom guts>
  67. # setting
  68. # setting
  69. # </custom guts>
  70. #   This tag allows you to define custom initial values for actor and
  71. #   enemy guts-related parameters. You can add as many settings between
  72. #   the <custom guts> tags as you like. Any settings that are omitted
  73. #   will use the default values as defined in the customization module
  74. #   in this script. The following settings are available:
  75. #  
  76. #     base: n
  77. #       This setting defines the base guts value for the actor or enemy
  78. #       at the start of the game where n is a positive number value.
  79. #      
  80. #     text: message
  81. #     text: key
  82. #       This setting defines the battler's personal in-battle guts text
  83. #       where message is a string of characters. %s can be used within
  84. #       the messages, but it is not required. %s is automatically
  85. #       replaced by the battler's name.    
  86. #
  87. #       'text: key' is an alternative to 'text: message'. This setting
  88. #       defines the battler's personal in-battle guts text where key is
  89. #       the name of a key defined in PRESET_GUTS_MESSAGES which is found
  90. #       in the customization module of this script.
  91. #      
  92. #     reduce: -n
  93. #       This setting defines the amount of guts the battler will
  94. #       permanently lose when guts is triggered where n should be a
  95. #       negative number value. n can be positive, but it is not
  96. #       recommended.
  97. #      
  98. #     animation id: id
  99. #     ani id: id
  100. #       This setting defines the database animation used on the battler
  101. #       when guts is triggered where id is the animation ID number
  102. #       found in your database.
  103. #
  104. #     hp recovery: n%
  105. #     hp: n%
  106. #       This setting defines the amount of HP the battler recovers when
  107. #       guts is triggered where n is the percentage rate recovered
  108. #       based on MAX HP. If set to 0%, the battler will regain at least
  109. #       1 HP.
  110. #
  111. # Here are some examples of custom guts tags:
  112. #
  113. #   <custom guts>
  114. #   base: 10
  115. #   text: %s: I won't lose!
  116. #   reduce: -40
  117. #   ani id: 39
  118. #   </custom guts>
  119. #
  120. # Since "hp recovery" is omitted from this example tag, it will instead
  121. # use the default value as defined in the customization module of
  122. # this script.
  123. #
  124. #   <custom guts>
  125. #   base: 20
  126. #   text: preset3
  127. #   </custom guts>
  128. #
  129. # This tag is an example of how you can use pre-defined guts messages
  130. # for the 'text' setting.
  131. #
  132. # If an actor is added to the party with the "Change Party Member" event
  133. # command and the "Initialize" box is checked, the actor's guts-related
  134. # parameters will reset to what is defined in this tag along with
  135. # any other default values.
  136. #==============================================================================
  137. #   ++ Guts Script Calls ++
  138. #==============================================================================
  139. # The following script calls are meant to be used in "Script..."
  140. # event commands found under Tab 3 when adding a new event command.
  141. #
  142. # add_actor_guts(actor_id, value)
  143. #   This script call permanently modifies an actor's guts parameter where
  144. #   actor_id is an actor ID number from your database. value can be negative
  145. #   or positive. Actor guts values cannot exceed the maximum defined guts
  146. #   value or drop below 0.
  147. #--------------------------------------------------------------------------
  148. #   ++ Compatibility ++
  149. #--------------------------------------------------------------------------
  150. # This script has built-in compatibility the following scripts:
  151. #
  152. #     -Auto-Life Effect
  153. #     -YEA Battle Engine
  154. #
  155. # This script aliases the following default VXA methods:
  156. #
  157. #     BattleManager#judge_win_loss
  158. #
  159. #     Game_BattlerBase#initialize
  160. #
  161. #     Game_Battler#die
  162. #     Game_Battler#on_battle_end
  163. #     Game_Battler#on_battle_start
  164. #     Game_Battler#item_apply
  165. #
  166. #     Scene_Battle#process_action
  167. #     Scene_Battle#process_action_end
  168. #     Scene_Battle#turn_end
  169. #
  170. #     Game_Interpreter#command_129
  171. #    
  172. # There are no default method overwrites.
  173. #
  174. # Requests for compatibility with other scripts are welcome.
  175. #--------------------------------------------------------------------------
  176. #      Compatibility Notes
  177. #--------------------------------------------------------------------------
  178. # If 'Auto-Life Effects' and 'Guts Effects' are installed in the same
  179. # project, auto-life effects will always take precdence over guts
  180. # effects.
  181. #--------------------------------------------------------------------------
  182. #   ++ Terms and Conditions ++
  183. #--------------------------------------------------------------------------
  184. # Please do not repost this script elsewhere without permission.
  185. # Free for non-commercial use. For commercial use, contact me first.
  186. #
  187. # Newest versions of this script can be found at
  188. #                                           http://mrbubblewand.wordpress.com/
  189. #==============================================================================
  190.  
  191. $imported = {} if $imported.nil?
  192. $imported["BubsGuts"] = true
  193.  
  194. #==========================================================================
  195. # ++ START OF USER CUSTOMIZATION MODULE ++
  196. #==========================================================================
  197. module Bubs
  198.   #==========================================================================
  199.   # ++ Guts Settings
  200.   #==========================================================================
  201.   module Guts
  202.   #--------------------------------------------------------------------------
  203.   #   Guts Parameter Vocab
  204.   #--------------------------------------------------------------------------
  205.   GUTS_VOCAB   = "Guts" # Guts full name
  206.   GUTS_VOCAB_A = "GUT"  # Guts abbreviation
  207.  
  208.   #--------------------------------------------------------------------------
  209.   #   Disable Guts Switch ID Setting     !! IMPORTANT SETTING !!
  210.   #--------------------------------------------------------------------------
  211.   # This setting defines the switch ID number used to determine if revival
  212.   # by guts is allowed in battle. This is useful for evented battles and
  213.   # such. If the ID is set to 0, no game switches will be used.
  214.   #
  215.   # If the switch is ON, revival by guts is disabled.
  216.   # If the switch is OFF, revival by guts is allowed.
  217.   DISABLE_GUTS_SWITCH_ID = 0
  218.  
  219.   #--------------------------------------------------------------------------
  220.   #   Check Guts Triggers After Each Action
  221.   #--------------------------------------------------------------------------
  222.   # true  : Guts checks can be done after each complete action.
  223.   # false : Guts checks are done only at the end of turn.
  224.   CHECK_AFTER_EACH_ACTION = true
  225.  
  226.   #--------------------------------------------------------------------------
  227.   #   Maximum Guts Value
  228.   #--------------------------------------------------------------------------
  229.   # This setting defines the maximum amount of guts an actor or enemy
  230.   # can absolutely obtain.
  231.   GUTS_MAX = 255
  232.  
  233.   #--------------------------------------------------------------------------
  234.   #   Guts Chance Formula
  235.   #--------------------------------------------------------------------------
  236.   # This setting determines the formula used when determining the chance
  237.   # for guts to trigger. Available methods include, but is not limited to:
  238.   #
  239.   # guts : The battler's personal guts value.
  240.   # guts_max : The maximum possible guts value as defined by GUTS_MAX.
  241.   #
  242.   # The value this formula produces should be between 0.0 and 1.0.
  243.   GUTS_CHANCE_FORMULA = "guts / guts_max"
  244.  
  245.   #--------------------------------------------------------------------------
  246.   #   Guts Effect Text
  247.   #--------------------------------------------------------------------------
  248.   # This setting defines the text that is displayed in the battle log when
  249.   # a battler successfully triggers guts. This text is displayed before the
  250.   # actor's/enemy's personal message.
  251.   #
  252.   # %s is automatically replaced by the actor or enemy name (but is not
  253.   # required).
  254.   GUTS_EFFECT_TEXT = "%s recovers with willpower."
  255.  
  256.   #--------------------------------------------------------------------------
  257.   #   Guts Sound Effect Settings
  258.   #--------------------------------------------------------------------------
  259.   # This sound effect plays when the general guts text is displayed.
  260.   #                 "filename", Volume, Pitch
  261.   GUTS_EFFECT_SE = ["Recovery",     80,  100]
  262.   #--------------------------------------------------------------------------
  263.   #   Guts Personal Text Sound Effect Settings
  264.   #--------------------------------------------------------------------------
  265.   # This sound effect plays when the actor's/enemy's personal text is
  266.   # displayed.
  267.   #                       "filename", Volume, Pitch
  268.   PERSONAL_GUTS_TEXT_SE = [    "Miss",    100,  130]
  269.  
  270. #==========================================================================
  271. #   Guts Default Settings
  272. #==========================================================================
  273. # The default settings within the hash below will be used if a
  274. # <custom guts> tag is not found in the actor's or enemy's notebox.
  275.   GUTS_DEFAULTS = {
  276.   #--------------------------------------------------------------------------
  277.   #   Default Base Guts Values
  278.   #--------------------------------------------------------------------------
  279.   # These settings define the base guts value for actors and enemies
  280.   # at the start of the game
  281.     :actor_guts_base => 5.0,  # Actor Base Guts
  282.     :enemy_guts_base => 0.0,  # Enemy Base Guts
  283.    
  284.   #--------------------------------------------------------------------------
  285.   #   Default Guts Reduction on Trigger (Actors only)
  286.   #--------------------------------------------------------------------------
  287.   # When an actor successfully triggers guts, you can reduce the actor's
  288.   # guts stat permanently by a set amount. This will only reduce the actor's
  289.   # guts stat. This will not affect equipment, states, etc. on the actor.
  290.   # This will not reduce an actor's guts stat to below 0.
  291.     :guts_reduce => -32,
  292.    
  293.   #--------------------------------------------------------------------------
  294.   #   Default Personal Guts Text on Trigger
  295.   #--------------------------------------------------------------------------
  296.   # This setting defines the default personal message used when guts is
  297.   # triggered. If the string is empty, a personal quote will not
  298.   # be displayed.
  299.   #
  300.   # %s is automatically replaced by the actor's name.
  301.     :actor_guts_text => "%s: I won't lose!",  # Actor Text
  302.     :enemy_guts_text => "",                   # Enemy Text
  303.    
  304.   #--------------------------------------------------------------------------
  305.   #   Default Guts HP Recovery
  306.   #--------------------------------------------------------------------------
  307.     :hp_rate => 1.0, # HP Recovery Rate, 0.0 ~ 100.0 (%)
  308.   #--------------------------------------------------------------------------
  309.   #   Default Guts Animation ID
  310.   #--------------------------------------------------------------------------
  311.     :guts_ani => 42, # Animation ID number
  312.    
  313.   } # <-- Do not delete.
  314.  
  315.   #--------------------------------------------------------------------------
  316.   #   Pre-set Guts Messages
  317.   #--------------------------------------------------------------------------
  318.   # This setting allows you to create custom pre-set text messages for use in
  319.   # <custom guts> notetags. The standard format for a pre-set in this hash
  320.   # is:
  321.   #
  322.   #       :key => "string",
  323.   #
  324.   # :key can be any kind of name as long as it is preceeded by a colon (:)
  325.   #
  326.   # %s will automatically be replaced by the battler's name (but is not
  327.   # required).
  328.   PRESET_GUTS_MESSAGES = {
  329.     :preset1 => "%s: Heh, guess I slipped...",
  330.     :preset2 => "%s: OK, now I'm angry!",
  331.     :preset3 => "%s: Don't count me out yet!",
  332.     :preset4 => "%s: Hey! That hurt!",
  333.     :preset5 => "%s: Wheeeeeeeeep!",
  334.     :preset6 => "%s: Was that supposed to hurt?",
  335.     :nothing => "",
  336.   # You can create more presets within this hash.
  337.    
  338.   } # <-- Do not delete.
  339.   end # module Guts
  340. end # module Bubs
  341.  
  342. #==========================================================================
  343. # ++ END OF USER CUSTOMIZATION MODULE ++
  344. #==========================================================================
  345.  
  346.  
  347.  
  348. #==============================================================================
  349. # ++ Vocab
  350. #==============================================================================
  351. module Vocab
  352.   GutsEffectText = Bubs::Guts::GUTS_EFFECT_TEXT
  353.  
  354.   def self.guts; Bubs::Guts::GUTS_VOCAB; end
  355.   def self.guts_a; Bubs::Guts::GUTS_VOCAB_A; end
  356. end # module Vocab
  357.  
  358. #==============================================================================
  359. # ++ Sound
  360. #==============================================================================
  361. module Sound
  362.   # General Guts Text SE
  363.   def self.play_guts_effect
  364.     Audio.se_play("/Audio/SE/" + Bubs::Guts::GUTS_EFFECT_SE[0],
  365.                   Bubs::Guts::GUTS_EFFECT_SE[1],
  366.                   Bubs::Guts::GUTS_EFFECT_SE[2])
  367.   end
  368.   # Battler Guts Text SE
  369.   def self.play_guts_text
  370.     Audio.se_play("/Audio/SE/" + Bubs::Guts::PERSONAL_GUTS_TEXT_SE[0],
  371.                   Bubs::Guts::PERSONAL_GUTS_TEXT_SE[1],
  372.                   Bubs::Guts::PERSONAL_GUTS_TEXT_SE[2])
  373.   end
  374. end # module Sound
  375.  
  376.  
  377. #==========================================================================
  378. # ++ Bubs::Regexp
  379. #==========================================================================
  380. module Bubs
  381.   module Regexp
  382.     module BaseItem
  383.       GUTS_START = /<CUSTOM\s*GUTS>/i
  384.       GUTS_END   = /<\/CUSTOM\s*GUTS>/i
  385.      
  386.       GUTS_PLUS = /<(?:GAIN)?[\s_]?GUTS:\s*([-+]?\d+\.?\d*)>/i
  387.     end # module BaseItem
  388.   end # module Regexp
  389. end # module Bubs
  390.  
  391.  
  392. #==========================================================================
  393. # ++ DataManager
  394. #==========================================================================
  395. module DataManager
  396.   #--------------------------------------------------------------------------
  397.   # alias : load_database
  398.   #--------------------------------------------------------------------------
  399.   class << self; alias load_database_bubs_guts load_database; end
  400.   def self.load_database
  401.     load_database_bubs_guts # alias
  402.     load_notetags_bubs_guts
  403.   end
  404.  
  405.   #--------------------------------------------------------------------------
  406.   # new method : load_notetags_bubs_guts
  407.   #--------------------------------------------------------------------------
  408.   def self.load_notetags_bubs_guts
  409.     groups = [$data_actors, $data_classes, $data_items, $data_skills,
  410.       $data_weapons, $data_armors, $data_enemies, $data_states]
  411.     for group in groups
  412.       for obj in group
  413.         next if obj.nil?
  414.         obj.load_notetags_bubs_guts
  415.       end # for obj
  416.     end # for group
  417.   end # def
  418.  
  419. end # module DataManager
  420.  
  421.  
  422. #==========================================================================
  423. # ++ BattleManager
  424. #==========================================================================
  425. module BattleManager
  426.   class << self; alias judge_win_loss_bubs_guts judge_win_loss; end
  427.   #--------------------------------------------------------------------------
  428.   # alias : judge_win_loss
  429.   #--------------------------------------------------------------------------
  430.   def self.judge_win_loss
  431.     if @phase
  432.       return process_abort   if aborting?
  433.       return false           if gutsable_members
  434.     end
  435.     judge_win_loss_bubs_guts # alias
  436.   end
  437.  
  438.   #--------------------------------------------------------------------------
  439.   # new method : gutsable_members
  440.   #--------------------------------------------------------------------------
  441.   def self.gutsable_members
  442.     $game_party.battle_members.each do |actor|
  443.       return true if actor.gutsable
  444.     end
  445.    
  446.     $game_troop.members.each do |enemy|
  447.       return true if enemy.gutsable
  448.     end
  449.    
  450.     return false
  451.   end
  452.  
  453. end # module BattleManager
  454.  
  455.  
  456. #==========================================================================
  457. # ++ RPG::BaseItem
  458. #==========================================================================
  459. # A superclass of actor, class, skill, item, weapon, armor, enemy, and state.
  460. class RPG::BaseItem
  461.   #--------------------------------------------------------------------------
  462.   # public instance variables
  463.   #--------------------------------------------------------------------------
  464.   attr_accessor :guts_param
  465.   attr_accessor :guts_text
  466.   attr_accessor :guts_reduce
  467.   attr_accessor :guts_animation
  468.   attr_accessor :guts_hp_recovery_rate
  469.  
  470.   #--------------------------------------------------------------------------
  471.   # common cache : load_notetags_bubs_guts
  472.   #--------------------------------------------------------------------------
  473.   def load_notetags_bubs_guts
  474.     @guts_param = 0.0
  475.    
  476.     self.note.split(/[\r\n]+/).each { |line|
  477.       case line
  478.      
  479.       when Bubs::Regexp::BaseItem::GUTS_PLUS
  480.         @guts_param = $1.to_f
  481.        
  482.       end # case
  483.     } # self
  484.    
  485.     load_battler_notetags_bubs_guts if self.is_a?(RPG::Actor) || self.is_a?(RPG::Enemy)
  486.   end
  487.  
  488.   #--------------------------------------------------------------------------
  489.   # common cache : load_battler_notetags_bubs_guts
  490.   #--------------------------------------------------------------------------
  491.   def load_battler_notetags_bubs_guts
  492.     @guts_text             = ""
  493.     @guts_reduce           = Bubs::Guts::GUTS_DEFAULTS[:guts_reduce]
  494.     @guts_animation        = Bubs::Guts::GUTS_DEFAULTS[:guts_ani]
  495.     @guts_hp_recovery_rate = Bubs::Guts::GUTS_DEFAULTS[:hp_rate]
  496.    
  497.     guts_tag = false
  498.    
  499.     if self.is_a?(RPG::Actor)
  500.       @guts_param          = Bubs::Guts::GUTS_DEFAULTS[:actor_guts_base]
  501.       @guts_text           = Bubs::Guts::GUTS_DEFAULTS[:actor_guts_text]
  502.     elsif self.is_a?(RPG::Enemy)
  503.       @guts_param          = Bubs::Guts::GUTS_DEFAULTS[:enemy_guts_base]
  504.       @guts_text           = Bubs::Guts::GUTS_DEFAULTS[:enemy_guts_text]
  505.     end
  506.    
  507.     self.note.split(/[\r\n]+/).each { |line|
  508.       case line
  509.  
  510.       when Bubs::Regexp::BaseItem::GUTS_START
  511.         guts_tag = true
  512.        
  513.       when Bubs::Regexp::BaseItem::GUTS_END
  514.         guts_tag = false
  515.      
  516.       else
  517.         next unless guts_tag
  518.         case line
  519.        
  520.         when /BASE:\s*[+]?(\d+)/i
  521.           @guts_param = $1.to_f
  522.          
  523.         when /TEXT:\s*(.*)\s*/i
  524.           if Bubs::Guts::PRESET_GUTS_MESSAGES[$1.to_sym]
  525.             @guts_text = Bubs::Guts::PRESET_GUTS_MESSAGES[$1.to_sym]
  526.           else
  527.             @guts_text = $1
  528.           end
  529.         when /REDUCE:\s*([-+]?\d+\.?\d*)/i
  530.           @guts_reduce = $1.to_f
  531.          
  532.         when /(?:ANIMATION|ANI)\s*id:\s*(\d+)/i
  533.           @guts_animation = $1.to_i
  534.          
  535.         when /HP\s*(?:RECOVERY)?:\s*([+]?\d+\.?\d*)[%]?/i
  536.           @guts_hp_recovery_rate = $1.to_f
  537.          
  538.         end # case
  539.       end # case
  540.     } # self.note.split
  541.   end # def
  542. end # RPG::BaseItem
  543.  
  544.  
  545. #==============================================================================
  546. # ++ Window_BattleLog
  547. #==============================================================================
  548. class Window_BattleLog < Window_Selectable
  549.   #--------------------------------------------------------------------------
  550.   # new method : display_guts_effect_text
  551.   #--------------------------------------------------------------------------
  552.   def display_guts_effect_text(target)
  553.     Sound.play_guts_effect
  554.     add_text(sprintf(Vocab::GutsEffectText, target.name))
  555.   end
  556.  
  557.   #--------------------------------------------------------------------------
  558.   # new method : display_guts_text
  559.   #--------------------------------------------------------------------------
  560.   def display_guts_text(target)
  561.     Sound.play_guts_text
  562.     add_text(sprintf(target.personal_guts_text, target.name))
  563.     wait
  564.   end # def display_guts_text
  565. end # class Window_BattleLog
  566.  
  567.  
  568. #==========================================================================
  569. # ++ Game_BattlerBase
  570. #==========================================================================
  571. class Game_BattlerBase
  572.   #--------------------------------------------------------------------------
  573.   # public instance variables
  574.   #--------------------------------------------------------------------------
  575.   attr_accessor :gutsable       # guts check flag
  576.   #--------------------------------------------------------------------------
  577.   # alias : initialize
  578.   #--------------------------------------------------------------------------
  579.   alias initialize_bubs_guts initialize
  580.   def initialize
  581.     @gutsable = false
  582.  
  583.     initialize_bubs_guts # alias    
  584.   end
  585.  
  586.   #--------------------------------------------------------------------------
  587.   # new method : gut
  588.   #--------------------------------------------------------------------------
  589.   def gut
  590.     n = 0.0
  591.     if actor?
  592.       n += self.actor.guts_param
  593.       n += self.class.guts_param
  594.       for equip in equips
  595.         next if equip.nil?
  596.         n += equip.guts_param
  597.       end
  598.     else
  599.       n += self.enemy.guts_param
  600.     end
  601.     for state in states
  602.       next if state.nil?
  603.       n += state.guts_param
  604.     end
  605.     # determine min/max guts value
  606.     n = [n, 0].max
  607.     n = [n, guts_max].min
  608.    
  609.     return n
  610.   end # def gut
  611.   alias guts gut
  612.  
  613.   #--------------------------------------------------------------------------
  614.   # new method : gut_max
  615.   #--------------------------------------------------------------------------
  616.   def gut_max
  617.     Bubs::Guts::GUTS_MAX.to_f
  618.   end # def gut_max
  619.   alias guts_max gut_max
  620.  
  621.   #--------------------------------------------------------------------------
  622.   # new method : add_guts
  623.   #--------------------------------------------------------------------------
  624.   def add_guts(user, item)
  625.     return
  626.   end
  627. end # class Game_BattlerBase
  628.  
  629.  
  630. #==============================================================================
  631. # ++ Game_Battler
  632. #==============================================================================
  633. class Game_Battler < Game_BattlerBase
  634.  
  635.   #--------------------------------------------------------------------------
  636.   # alias : die
  637.   #--------------------------------------------------------------------------
  638.   alias die_bubs_guts die
  639.   def die
  640.     @gutsable = true
  641.    
  642.     die_bubs_guts # alias
  643.   end # def die
  644.  
  645.   #--------------------------------------------------------------------------
  646.   # alias : on_battle_end
  647.   #--------------------------------------------------------------------------
  648.   alias on_battle_end_bubs_guts on_battle_end
  649.   def on_battle_end
  650.     @gutsable = false
  651.    
  652.     on_battle_end_bubs_guts # alias
  653.   end # def on_battle_end
  654.  
  655.   #--------------------------------------------------------------------------
  656.   # alias : on_battle_start
  657.   #--------------------------------------------------------------------------
  658.   alias on_battle_start_bubs_guts on_battle_start
  659.   def on_battle_start
  660.     @gutsable = false
  661.    
  662.     on_battle_start_bubs_guts # alias
  663.   end
  664.  
  665.   #--------------------------------------------------------------------------
  666.   # alias : item_apply
  667.   #--------------------------------------------------------------------------
  668.   alias item_apply_bubs_guts item_apply
  669.   def item_apply(user, item)
  670.     item_apply_bubs_guts(user, item) # alias
  671.    
  672.     if @result.hit? && item.guts_param != 0
  673.       add_guts(item.guts_param)
  674.     end
  675.   end
  676.  
  677.   #--------------------------------------------------------------------------
  678.   # new method : add_guts
  679.   #--------------------------------------------------------------------------
  680.   def add_guts(value)
  681.     if actor?
  682.       actor_guts = self.actor.guts_param
  683.       self.actor.guts_param = [[actor_guts + value, 0].max, guts_max].min.to_f
  684.     end
  685.   end
  686.  
  687.   #--------------------------------------------------------------------------
  688.   # new method : guts_chance
  689.   #--------------------------------------------------------------------------
  690.   def guts_chance
  691.     [[eval(Bubs::Guts::GUTS_CHANCE_FORMULA).to_f, 0.0].max, 1.0].min
  692.   end
  693.  
  694.   #--------------------------------------------------------------------------
  695.   # new method : activate_guts?
  696.   #--------------------------------------------------------------------------
  697.   def activate_guts?
  698.     rand < guts_chance
  699.   end
  700.  
  701.   #--------------------------------------------------------------------------
  702.   # new method : guts_hp_recovery
  703.   #--------------------------------------------------------------------------
  704.   def guts_hp_recovery
  705.     if actor?
  706.       self.hp += (mhp * (self.actor.guts_hp_recovery_rate * 0.01)).to_i
  707.     else
  708.       self.hp += (mhp * (self.enemy.guts_hp_recovery_rate * 0.01)).to_i
  709.     end
  710.   end
  711.  
  712.   #--------------------------------------------------------------------------
  713.   # new method : apply_guts_reduction
  714.   #--------------------------------------------------------------------------
  715.   def apply_guts_reduction
  716.     if actor?
  717.       guts_value = self.actor.guts_param
  718.       # Value here should be subtracted
  719.       guts_value += self.actor.guts_reduce
  720.       self.actor.guts_param = [[guts_value, 0.0].max, guts_max].min
  721.     end
  722.   end # def apply_guts_reduction
  723.  
  724.   #--------------------------------------------------------------------------
  725.   # new method : guts_animation_id
  726.   #--------------------------------------------------------------------------
  727.   def guts_animation_id
  728.     if actor?
  729.       self.actor.guts_animation
  730.     else
  731.       self.enemy.guts_animation
  732.     end
  733.   end # def guts_animation_id
  734.  
  735.   #--------------------------------------------------------------------------
  736.   # new method : personal_guts_text
  737.   #--------------------------------------------------------------------------
  738.   def personal_guts_text
  739.     if actor?
  740.       self.actor.guts_text
  741.     else
  742.       self.enemy.guts_text
  743.     end
  744.   end # def personal_guts_text
  745.  
  746.   #--------------------------------------------------------------------------
  747.   # new method : apply_guts_effects
  748.   #--------------------------------------------------------------------------
  749.   def apply_guts_effects(battler)
  750.     # Remove death state
  751.     revive
  752.     # Apply hp recovery value to battler
  753.     guts_hp_recovery
  754.     # Reduce actor's guts
  755.     apply_guts_reduction
  756.   end # def apply_guts_effects
  757. end # class Game_Battler
  758.  
  759.  
  760. #==============================================================================
  761. # ++ Scene_Battle
  762. #==============================================================================
  763. class Scene_Battle < Scene_Base
  764.   #--------------------------------------------------------------------------
  765.   # alias : process_action
  766.   #--------------------------------------------------------------------------
  767.   alias process_action_bubs_guts process_action
  768.   def process_action
  769.     process_action_bubs_guts # alias
  770.    
  771.    
  772.     return if $imported["BubsAutoLife"]
  773.     # process_action_end never gets called if the last party member is
  774.     # killed by an enemy with more Action Time+ actions in queue.
  775.     if !@subject.nil?
  776.       if @subject.current_action && $game_party.all_dead?
  777.         process_guts_check
  778.       end
  779.     end
  780.   end # def process_action
  781.  
  782.   #--------------------------------------------------------------------------
  783.   # alias : process_action_end
  784.   #--------------------------------------------------------------------------
  785.   alias process_action_end_bubs_guts process_action_end
  786.   def process_action_end
  787.     if Bubs::Guts::CHECK_AFTER_EACH_ACTION
  788.       process_guts_check unless $imported["BubsAutoLife"]
  789.     end
  790.    
  791.     process_action_end_bubs_guts # alias
  792.   end # def process_action_end
  793.  
  794.   #--------------------------------------------------------------------------
  795.   # alias : turn_end
  796.   #--------------------------------------------------------------------------
  797.   alias turn_end_bubs_guts turn_end
  798.   def turn_end
  799.     process_guts_check unless $imported["BubsAutoLife"]
  800.    
  801.     turn_end_bubs_guts
  802.   end
  803.  
  804.   #--------------------------------------------------------------------------
  805.   # new method : process_guts_check
  806.   #--------------------------------------------------------------------------
  807.   def process_guts_check
  808.     all_battle_members.each do |battler|
  809.       determine_guts(battler)
  810.     end
  811.   end # def process_guts_check
  812.  
  813.   #--------------------------------------------------------------------------
  814.   # new method : determine_guts
  815.   #--------------------------------------------------------------------------
  816.   def determine_guts(battler)
  817.     return unless battler.gutsable
  818.     # Set the battler guts flag off
  819.     battler.gutsable = false
  820.    
  821.     return if $game_switches[Bubs::Guts::DISABLE_GUTS_SWITCH_ID]
  822.     return unless battler.dead? && battler.activate_guts?
  823.    
  824.     @log_window.clear
  825.     # Display general revive text
  826.     @log_window.display_guts_effect_text(battler)
  827.    
  828.     battler.apply_guts_effects(battler)
  829.     @status_window.refresh
  830.     show_animation([battler], battler.guts_animation_id)
  831.     # Display personal guts text
  832.     @log_window.display_guts_text(battler)
  833.     wait(35)
  834.     @log_window.clear
  835.   end # def apply_guts_effects
  836.  
  837.   #--------------------------------------------------------------------------
  838.   # new method : clear_all_gutsable_flags
  839.   #--------------------------------------------------------------------------
  840.   def clear_all_gutsable_flags
  841.     all_battle_members.each do |member|
  842.       member.gutsable = false
  843.     end
  844.   end
  845.  
  846.   if $imported["YEA-BattleEngine"]
  847.   #--------------------------------------------------------------------------
  848.   # alias : debug_kill_all
  849.   #--------------------------------------------------------------------------
  850.   alias debug_kill_all_bubs_guts debug_kill_all
  851.   def debug_kill_all
  852.     debug_kill_all_bubs_guts # alias
  853.  
  854.     clear_all_gutsable_flags    
  855.   end
  856.   end # if $imported["YEA-BattleEngine"]
  857.  
  858. end # class Scene_Battle
  859.  
  860.  
  861. #==============================================================================
  862. # ++ Game_Interpreter
  863. #==============================================================================
  864. class Game_Interpreter
  865.   #--------------------------------------------------------------------------
  866.   # new method : gain_actor_guts
  867.   #--------------------------------------------------------------------------
  868.   def gain_actor_guts(actor_id, value)
  869.     $game_actors[actor_id].add_guts(value)
  870.   end
  871.  
  872.   #--------------------------------------------------------------------------
  873.   # alias : command_129                     # Change Party Member
  874.   #--------------------------------------------------------------------------
  875.   alias command_129_bubs_guts command_129
  876.   def command_129
  877.     command_129_bubs_guts # alias
  878.    
  879.     actor = $game_actors[@params[0]]
  880.     if actor
  881.       if @params[1] == 0    # Add
  882.         if @params[2] == 1  # Initialize
  883.           $game_actors[@params[0]].load_notetags_bubs_guts
  884.         end
  885.       end
  886.     end
  887.   end
  888.  
  889. end # class Game_Interpreter
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement