Advertisement
LiTTleDRAgo

[RGSS/2/3] Hunger & Thirst

Sep 19th, 2013
664
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 24.18 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  2. # Hunger and Thirst
  3. # Version: 1.07
  4. # Author: ForeverZer0, LiTTleDRAgo
  5. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  6. #
  7. # Explanations:
  8. #
  9. #   Based on ForeverZer0's Hunger/Thirst script
  10. #   This script adds another parameter to actors, hunger and thirst
  11. #   If hunger or thirst fall to certain amount, actor gets a state
  12. #
  13. # Instructions:
  14. #
  15. #   - The following script calls can be used in game:
  16. #
  17. #    ►  $game_party.hunger = (true/false)  
  18. #       - If false, hunger/thirst rates will not decrease. Good for long scenes
  19. #         where the player is not in control, etc.
  20. #         The system will remain ON/OFF until it is changed.
  21. #
  22. #    ►  $game_actors[ACTOR_ID].hunger = AMOUNT
  23. #    ►  $game_actors[ACTOR_ID].thirst = AMOUNT
  24. #    ►  $game_party.members[ACTOR_POS].hunger = AMOUNT
  25. #    ►  $game_party.members[ACTOR_POS].thirst = AMOUNT
  26. #       - Sets the hunger/thirst of actor in your database with ACTOR_ID or
  27. #        ACTOR_POS to the number specified by AMOUNT
  28. #
  29. #    ►  $game_actors[ACTOR_ID].max_hunger = AMOUNT
  30. #    ►  $game_actors[ACTOR_ID].max_thirst = AMOUNT
  31. #    ►  $game_party.members[ACTOR_POS].max_hunger = AMOUNT
  32. #    ►  $game_party.members[ACTOR_POS].max_thirst = AMOUNT
  33. #       - Sets the MAX hunger/thirst of actor in your database with ACTOR_ID or
  34. #        ACTOR_POS to the number specified by AMOUNT
  35. #
  36. #    ►  $game_actors[ACTOR_ID].recover_hunger
  37. #    ►  $game_party.members[ACTOR_POS].recover_hunger
  38. #       - Will recover all hunger to actor with ACTOR_ID or ACTOR_POS.
  39. #
  40. #    ►  $game_actors[ACTOR_ID].recover_thirst
  41. #    ►  $game_party.members[ACTOR_POS].recover_thirst
  42. #       - Will recover all hunger to actor with ACTOR_ID or ACTOR_POS.
  43. #
  44. #    ►  $game_party.recover_hunger
  45. #    ►  $game_party.recover_thirst
  46. #    ►  $game_party.recover_hunger_thirst
  47. #       - Will recover all hunger/thirst to party.
  48. #
  49. #    ►  $game_party.hunger_debugger
  50. #       - Displays info on-screen of each characters hunger/thirst, current
  51. #         count for steps and time, and shows which features are currently ON.
  52. #
  53. # For VXA :
  54. #
  55. #   If you want to use this on damage formula, do it like this example :
  56. #    
  57. #    (a.atk + a.mat * 4) * ((a.hunger / a.max_hunger.to_f) * 100).round  *
  58. #     ((a.thirst / a.max_thirst.to_f) * 100).round - b.def - b.mdf * 2
  59. #
  60. #    (a.atk + a.mat * 4) * a.hunger_percent *
  61. #           a.thirst_percent - b.def - b.mdf * 2
  62. #
  63. # Special Thanks:
  64. #   - ForeverZer0 for the original script
  65. #
  66. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  67. #                               NOTETAGS
  68. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  69. # For VX and VXA user can use notetags at Item Tabs to determine
  70. # food / drink recovery rates  
  71. # (notetags configuration will be prioritized):
  72. #
  73. #-------------------------------------------------------------------------------
  74. # ** Notetags for Items
  75. #-------------------------------------------------------------------------------
  76. #
  77. # <recover hunger by percent>
  78. # <recover thirst by percent>
  79. # <hunger: x>
  80. # <thirst: x>
  81. # <increase max hunger: x>   # fixed value only
  82. # <increase max thirst: x>   # fixed value only
  83. #
  84. # I believe the tags were self explanationed.
  85. #
  86. #-------------------------------------------------------------------------------
  87. # ** Notetags for Actor
  88. #-------------------------------------------------------------------------------
  89. #
  90. # Below is tags for Actor
  91. #
  92. #  <hunger lv up increase: x> # This one will increase max hunger on lvup
  93. #  <thirst lv up increase: x> # This one will increase max thirst on lvup
  94. #  <hunger max: x>            # This one will initialize max hunger
  95. #  <thirst max: x>            # This one will initialize max thirst
  96. #
  97. # Note that hunger_max and thirst_max is cannot be lower than 1
  98. #
  99. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  100. #                          BEGIN CONFIGURATION
  101. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  102.  
  103. module LiTTleDRAgo
  104.  
  105.   # Enable hunger system at the start of the game?
  106.   # Hunger system can be enabled with script call
  107.   # $game_party.hunger = (true/false)
  108.   ENABLE_HUNGER_AT_START = true
  109.  
  110.   DEFAULT_HUNGER = 100          
  111.   DEFAULT_THIRST = 100          
  112.   # Default max hunger/thirst players will begin with. This can be increased as
  113.   # the player becomes more powerful, through items, etc. if desired.
  114.  
  115.   BY_TIME   = true
  116.   BY_STEPS  = true
  117.   # There are two ways hunger and thirst can be calculated; one by just how many
  118.   # seconds pass, and the other by how many steps have been taken. You can use
  119.   # both if you like, but I would suggest that if you do to try to keep it more
  120.   # skewed to one or the other as the main method of decreasing, and use the
  121.   # other as a minor added dynamic.
  122.  
  123.   STEPS_HUNGER_DOWN = 100  
  124.   STEPS_THIRST_DOWN = 80
  125.   # Only if using 'BY_STEPS', otherwise ignore these. These are the amount
  126.   # of steps before hunger/thirst decrease.
  127.  
  128.   SECS_HUNGER_DOWN = 10
  129.   SECS_THIRST_DOWN = 10
  130.   # Only if using 'BY_TIME', otherwise ignore these. These are the amount
  131.   # of seconds before hunger/thirst decrease.
  132.  
  133.   LVL_UP_INCREASE = [:hunger, :thirst]
  134.   LVL_UP_INCREASE = [      5,       5]
  135.   # Increase max hunger/thirst at each level up,
  136.   # To disable it, set to 0 or false or nil
  137.  
  138. #-------------------------------------------------------------------------------
  139. # * Food / Drink Items
  140. #-------------------------------------------------------------------------------
  141.  
  142.  
  143.   ITEM_RECOVER_HUNGER_THIRST = {
  144.   # Food/Drink Items:
  145.   # Set up your food/drink items recovery rates here. Recovery can be by either
  146.   # absolute value, or by percent. Setting :percent to true will make it
  147.   # by percent.
  148.  
  149.     :id => [:hunger, :thirst, :percent],
  150.    
  151.      1  => [      1,       0,     true],
  152.        
  153.  
  154.   # For lazy user who wants to set every unconfigured item.
  155.   # You can disable some items (such as key items) by setting the value to 0
  156.   #  0   => [     10,      0,   false],
  157.   # 99   => [      0,      0,   false],
  158.  
  159.   }
  160.  
  161. #-------------------------------------------------------------------------------
  162. # * Hunger/Thirst States
  163. #
  164. #   Set up states that will be applied when an actors hunger/thirst fall within
  165. #   a defined range, such as 'Starvation', 'Dehydration', etc.
  166. #   Negative values will remove its states
  167. #   Configure like this:
  168. #
  169. #   when MIN..MAX then return [STATE_ID, -STATE_ID, .....]
  170. #
  171. #   If actor's hunger/thirst is equal to or between MIN and MAX, the state with
  172. #   STATE_ID will be applied. This method is refreshed everytime the system
  173. #   decreases hunger/thirst.
  174. #
  175. #   Keep in mind that these states will NOT be automatically cured if the
  176. #   actor's hunger/thirst rise above.
  177. #   Create your food/drink items to cure these states.
  178. #
  179. #-------------------------------------------------------------------------------
  180.  
  181.   def self.hunger_states(current_hunger)
  182.     case current_hunger
  183.     when 0      then return 1 # Death
  184.     when 1..9   then return 2
  185.     when 10..15 then return [3,4,5]
  186.     end
  187.   end
  188.  
  189.   def self.thirst_states(current_thirst)
  190.     case current_thirst
  191.     when 0      then return 1 # Death
  192.     when 1..9   then return 2
  193.     when 10..15 then return [3,4,5]
  194.     end
  195.   end
  196.      
  197. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  198. #                             END CONFIGURATION
  199. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  200.  
  201.   #----------------------------------------------------------------------------
  202.   # Don't Edit
  203.   HUNGER_THIRST_TAGS = {
  204.    :hunger        => /<hunger:\s*([-]?\d+)\s*>/i,
  205.    :thirst        => /<thirst:\s*([-]?\d+)\s*>/i,
  206.    :incmaxhunger  => /<increase[-_ ]?max[-_ ]?hunger:\s*([-]?\d+)\s*>/i,
  207.    :incmaxthirst  => /<increase[-_ ]?max[-_ ]?thirst:\s*([-]?\d+)\s*>/i,
  208.    :hungerpercent => /<recover[-_ ]?hunger[-_ ]?by[-_ ]?percent>/i,
  209.    :thirstpercent => /<recover[-_ ]?thirst[-_ ]?by[-_ ]?percent>/i,
  210.    :hungerlvup    => /<hunger[-_ ]?lvl[-_ ]?up[-_ ]?increase:\s*([-]?\d+)\s*>/i,
  211.    :thirstlvup    => /<thirst[-_ ]?lvl[-_ ]?up[-_ ]?increase:\s*([-]?\d+)\s*>/i,
  212.    :hunger_max    => /<hunger[-_ ]?max:\s*([-]?\d+)\s*>/,
  213.    :thirst_max    => /<thirst[-_ ]?max:\s*([-]?\d+)\s*>/,
  214.    }
  215.   #----------------------------------------------------------------------------
  216. end
  217.  
  218. ($imported||={})[:drg_hunger_thirst] = 1.07
  219.  
  220. core_engine = "This script needs Drago - Core Engine ver 1.48 or above"
  221. ($imported[:drg_core_engine] || 0) >= 1.48 || raise(core_engine)
  222.  
  223. #==============================================================================
  224. # ** Game_Actor
  225. #------------------------------------------------------------------------------
  226. #  This class handles actors. It is used within the Game_Actors class
  227. # ($game_actors) and is also referenced from the Game_Party class ($game_party).
  228. #==============================================================================
  229. class Game_Actor
  230.   #--------------------------------------------------------------------------
  231.   # ● Class Variables
  232.   #--------------------------------------------------------------------------
  233.   @@lvup_defined = method_defined?(:level_up) ? :level_up : :exp=
  234.   #--------------------------------------------------------------------------
  235.   # ● Aliased method: setup
  236.   #--------------------------------------------------------------------------
  237.   define_third_method(:setup, :drg_hunger_setup) do |*args|
  238.     drg_hunger_setup(*args)
  239.     @max_hunger = LiTTleDRAgo::DEFAULT_HUNGER
  240.     @max_thirst = LiTTleDRAgo::DEFAULT_THIRST
  241.     @max_hunger = $1.to_i if actor.get_note =~ hunger_tags[:hunger_max]
  242.     @max_thirst = $1.to_i if actor.get_note =~ hunger_tags[:thirst_max]
  243.     inc = hunger_and_thirst_increment_level_up
  244.     if @level > 1
  245.       @max_hunger += ((@level-1) * inc.at(0)).round if inc.at(0).is_a?(Numeric)
  246.       @max_thirst += ((@level-1) * inc.at(1)).round if inc.at(1).is_a?(Numeric)
  247.     end
  248.     recover_hunger
  249.     recover_thirst
  250.   end
  251.   #--------------------------------------------------------------------------
  252.   # ● Aliased method: level_up
  253.   #--------------------------------------------------------------------------
  254.   define_third_method(:drg_hunger_level_up, :"#{@@lvup_defined}") do |*exp|
  255.     level = @level
  256.     drg_hunger_level_up(*exp)
  257.     inc = hunger_and_thirst_increment_level_up
  258.     if level != @level
  259.       lvls = @level - level
  260.       self.max_hunger += (inc.at(0) * lvls).round if inc.at(0).is_a?(Numeric)
  261.       self.max_thirst += (inc.at(1) * lvls).round if inc.at(1).is_a?(Numeric)
  262.     end
  263.   end  
  264.   #--------------------------------------------------------------------------
  265.   # ● New method: hunger_and_thirst_increment_level_up
  266.   #--------------------------------------------------------------------------
  267.   def hunger_and_thirst_increment_level_up
  268.     increase = []
  269.     increase[0] = LiTTleDRAgo::LVL_UP_INCREASE[0]
  270.     increase[1] = LiTTleDRAgo::LVL_UP_INCREASE[1]
  271.     increase[0] = $1.to_i if actor.get_note =~ hunger_tags[:hungerlvup]
  272.     increase[1] = $1.to_i if actor.get_note =~ hunger_tags[:thirstlvup]
  273.     return increase
  274.   end
  275. end
  276. #==============================================================================
  277. # ** Game_Battler
  278. #------------------------------------------------------------------------------
  279. #  A battler class with methods for sprites and actions added. This class
  280. # is used as a super class of the Game_Actor class and Game_Enemy class.
  281. #==============================================================================
  282. Klass = $BlizzABS ? Map_Battler : Game_Battler
  283. class Klass
  284.   #--------------------------------------------------------------------------
  285.   # ● Class Variable
  286.   #--------------------------------------------------------------------------
  287.   @@item_hunger_effect = (VXA = LiTTleDRAgo::VXA) ? :use_item  : :item_effect
  288.   @@item_effect_test  = (VX = LiTTleDRAgo::VX) ? :item_test : :item_effect_test
  289.   #--------------------------------------------------------------------------
  290.   # ● Alias Listing
  291.   #--------------------------------------------------------------------------
  292.   alias_sec_method :drg_ht_item_effect,       :"#{@@item_hunger_effect}"
  293.   alias_sec_method :drg_ht_item_effect_test,  :"#{@@item_effect_test}"
  294.   #--------------------------------------------------------------------------
  295.   # ● Public Instance Variables
  296.   #--------------------------------------------------------------------------
  297.   attr_sec_accessor :hunger, :max_hunger, 'LiTTleDRAgo::DEFAULT_HUNGER'
  298.   attr_sec_accessor :thirst, :max_thirst, 'LiTTleDRAgo::DEFAULT_THIRST'
  299.   attr_sec_reader   :hunger_tags,         'LiTTleDRAgo::HUNGER_THIRST_TAGS'
  300.   #--------------------------------------------------------------------------
  301.   # ● New method: hunger=
  302.   #--------------------------------------------------------------------------
  303.   def hunger=(value)
  304.     @hunger = [[value, 0].max, max_hunger].min
  305.   end
  306.   #--------------------------------------------------------------------------
  307.   # ● New method: thirst=
  308.   #--------------------------------------------------------------------------
  309.   def thirst=(value)
  310.     @thirst = [[value, 0].max, max_thirst].min
  311.   end
  312.   #--------------------------------------------------------------------------
  313.   # ● New method: max_hunger=
  314.   #--------------------------------------------------------------------------
  315.   def max_hunger=(value)
  316.     @max_hunger = [value, 1].max
  317.     @hunger = [[hunger, 0].max, @max_hunger].min
  318.   end
  319.   #--------------------------------------------------------------------------
  320.   # ● New method: max_thirst=
  321.   #--------------------------------------------------------------------------
  322.   def max_thirst=(value)
  323.     @max_thirst = [value, 1].max
  324.     @thirst = [[thirst, 0].max, @max_thirst].min
  325.   end
  326.   #--------------------------------------------------------------------------
  327.   # ● New method: recover_hunger
  328.   #--------------------------------------------------------------------------
  329.   def recover_hunger
  330.     self.hunger = self.max_hunger
  331.   end  
  332.   #--------------------------------------------------------------------------
  333.   # ● New method: recover_thirst
  334.   #--------------------------------------------------------------------------
  335.   def recover_thirst
  336.     self.thirst = self.max_thirst
  337.   end  
  338.   #--------------------------------------------------------------------------
  339.   # ● New method: recover_hunger_thirst
  340.   #--------------------------------------------------------------------------
  341.   def recover_hunger_thirst
  342.     recover_hunger
  343.     recover_thirst
  344.   end  
  345.   #--------------------------------------------------------------------------
  346.   # ● New method: hunger_percent
  347.   #--------------------------------------------------------------------------
  348.   def hunger_percent
  349.     ((self.hunger / self.max_hunger.to_f) * 100).round
  350.   end  
  351.   #--------------------------------------------------------------------------
  352.   # ● New method: thirst_percent
  353.   #--------------------------------------------------------------------------
  354.   def thirst_percent
  355.     ((self.thirst / self.max_thirst.to_f) * 100).round
  356.   end  
  357.   #--------------------------------------------------------------------------
  358.   # * Application of Item Effects
  359.   #--------------------------------------------------------------------------
  360.   define_method(:"#{@@item_hunger_effect}") do |*args|
  361.     result = drg_ht_item_effect(*args)
  362.     item = args.find {|s| s.is_a?(RPG::Item)}
  363.     user = args.find {|s| s.is_a?(Game_Battler)}
  364.     user ||= $BlizzABS ? self.battler : self
  365.     if item.is_a?(RPG::Item) && user.is_a?(Game_Actor)
  366.       food_item = false
  367.       rec = LiTTleDRAgo::ITEM_RECOVER_HUNGER_THIRST
  368.       hunger_plus = (rec = rec[item.id] || rec[0] || [])[0]
  369.       thirst_plus = rec[1]
  370.       hunger_plus = $1.to_i if item.get_note =~ user.hunger_tags[:hunger]
  371.       thirst_plus = $1.to_i if item.get_note =~ user.hunger_tags[:thirst]
  372.       user.max_hunger += $1.to_i if item.get_note =~ user.hunger_tags[:incmaxhunger]
  373.       user.max_thirst += $1.to_i if item.get_note =~ user.hunger_tags[:incmaxthirst]
  374.       if hunger_plus.is_a?(Numeric) && hunger_plus != 0
  375.         a = rec[2] == true || item.get_note =~ user.hunger_tags[:hungerpercent]
  376.         hunger_plus = (user.max_hunger * (hunger_plus * 0.01)).ceil if a
  377.         user.hunger += hunger_plus    
  378.         food_item = true
  379.       end
  380.       if thirst_plus.is_a?(Numeric) && thirst_plus != 0
  381.         a = rec[2] == true || item.get_note =~ user.hunger_tags[:thirstpercent]
  382.         thirst_plus = (user.max_thirst * (thirst_plus * 0.01)).ceil if a
  383.         user.thirst += thirst_plus
  384.         food_item = true
  385.       end
  386.       if food_item && !VXA
  387.         if LiTTleDRAgo::VX
  388.           apply_state_changes(item)
  389.         else
  390.           states_plus(item.plus_state_set)
  391.           states_minus(item.minus_state_set)
  392.         end
  393.         result ||= true
  394.       end
  395.     end
  396.     return result
  397.   end
  398.   #--------------------------------------------------------------------------
  399.   # * Test Effect
  400.   #--------------------------------------------------------------------------
  401.   define_method("#{@@item_effect_test}") do |*args|
  402.     item_effect_hunger?(*args[0..1]) || drg_ht_item_effect_test(*args)
  403.   end
  404.   #--------------------------------------------------------------------------
  405.   # * Effect Hunger?
  406.   #--------------------------------------------------------------------------
  407.   def item_effect_hunger?(a,item)
  408.     recover = LiTTleDRAgo::ITEM_RECOVER_HUNGER_THIRST
  409.     hunger = (recover = recover[item.id] || recover[0] || [])[0]
  410.     thirst = recover[1]
  411.     hunger = $1.to_i if item.get_note =~ a.hunger_tags[:hunger]
  412.     thirst = $1.to_i if item.get_note =~ a.hunger_tags[:thirst]
  413.     hunger = a.hunger < a.max_hunger && hunger.is_a?(Numeric) && hunger != 0
  414.     thirst = a.thirst < a.max_thirst && thirst.is_a?(Numeric) && thirst != 0
  415.     a.alive? && (hunger || thirst)
  416.   end
  417. end
  418. #==============================================================================
  419. # ** Game_Party
  420. #------------------------------------------------------------------------------
  421. #  This class handles parties. Information such as gold and items is included.
  422. # Instances of this class are referenced by $game_party.
  423. #==============================================================================
  424. class Game_Party
  425.   #--------------------------------------------------------------------------
  426.   # ● Public Instance Variables
  427.   #--------------------------------------------------------------------------
  428.   attr_sec_accessor :hunger,      'LiTTleDRAgo::ENABLE_HUNGER_AT_START'
  429.   attr_sec_accessor :step_hunger, 'LiTTleDRAgo::STEPS_HUNGER_DOWN'
  430.   attr_sec_accessor :step_thirst, 'LiTTleDRAgo::STEPS_THIRST_DOWN'
  431.   #--------------------------------------------------------------------------
  432.   # ● New method: check_hunger_states
  433.   #--------------------------------------------------------------------------
  434.   def check_hunger_states
  435.     members.each do |actor|
  436.       state_id = [LiTTleDRAgo.hunger_states(actor.hunger)].flatten.compact
  437.       state_id.each do |id|
  438.         actor.add_state(id.to_i.abs)    if id.is_a?(Numeric) && id.to_i > 0
  439.         actor.remove_state(id.to_i.abs) if id.is_a?(Numeric) && id.to_i < 0
  440.       end
  441.     end
  442.   end
  443.   #--------------------------------------------------------------------------
  444.   # ● New method: check_thirst_states
  445.   #--------------------------------------------------------------------------
  446.   def check_thirst_states
  447.     members.each do |actor|
  448.       state_id = [LiTTleDRAgo.thirst_states(actor.thirst)].flatten.compact
  449.       state_id.each do |id|
  450.         actor.add_state(id.to_i.abs)    if id.is_a?(Numeric) && id.to_i > 0
  451.         actor.remove_state(id.to_i.abs) if id.is_a?(Numeric) && id.to_i < 0
  452.       end
  453.     end
  454.   end
  455.   #--------------------------------------------------------------------------
  456.   # ● New method: update_hunger_by_time
  457.   #--------------------------------------------------------------------------
  458.   def update_hunger_by_time
  459.     @time_hunger = (@time_hunger || 0) + 1
  460.     @time_thirst = (@time_thirst || 0) + 1
  461.     if @time_hunger >= (LiTTleDRAgo::SECS_HUNGER_DOWN * Graphics.frame_rate)
  462.       actor = members.find_all {|actor| actor.alive? && actor.hunger > 0 }
  463.       actor.each {|s| s.hunger -= 1 }
  464.       check_hunger_states
  465.       @time_hunger = 0
  466.     end
  467.     if @time_thirst >= (LiTTleDRAgo::SECS_THIRST_DOWN * Graphics.frame_rate)
  468.       actor = members.find_all {|actor| actor.alive? && actor.thirst > 0 }
  469.       actor.each {|s| s.thirst -= 1 }
  470.       check_thirst_states
  471.       @time_thirst = 0
  472.     end
  473.   end
  474.   #--------------------------------------------------------------------------
  475.   # ● New method: update_hunger_by_steps
  476.   #--------------------------------------------------------------------------
  477.   def update_hunger_by_steps
  478.     if steps >= step_hunger
  479.       actor = members.find_all {|actor| actor.alive? && actor.hunger > 0 }
  480.       actor.each {|s| s.hunger -= 1 }
  481.       check_hunger_states
  482.       @step_hunger = steps + LiTTleDRAgo::STEPS_HUNGER_DOWN
  483.     end
  484.     if steps >= step_thirst
  485.       actor = members.find_all {|actor| actor.alive? && actor.thirst > 0 }
  486.       actor.each {|s| s.thirst -= 1 }
  487.       check_thirst_states
  488.       @step_thirst = steps + LiTTleDRAgo::STEPS_THIRST_DOWN
  489.     end
  490.   end
  491.   #--------------------------------------------------------------------------
  492.   # ● New method: hunger_debugger
  493.   #--------------------------------------------------------------------------
  494.   def hunger_debugger
  495.     sys = "System ON: #{$game_party.hunger}\n\n" +
  496.           "By Time: #{LiTTleDRAgo::BY_TIME}\n" +
  497.           "By Steps: #{LiTTleDRAgo::BY_STEPS}\n\n"
  498.     actors = ''
  499.     time_hunger = $game_party.time_hunger / Graphics.frame_rate
  500.     time_thirst = $game_party.time_thirst / Graphics.frame_rate
  501.     $game_party.members.each {|actor| actors +=
  502.       "#{actor.name}\nHunger: #{actor.hunger}\\#{actor.max_hunger}\n" +
  503.       "Thirst: #{actor.thirst}\\#{actor.max_thirst}\n\n"}
  504.     ht = "HungerTime: #{time_hunger}\\#{LiTTleDRAgo::SECS_HUNGER_DOWN}\n"
  505.     tt = "ThirstTime: #{time_thirst}\\#{LiTTleDRAgo::SECS_THIRST_DOWN}\n"
  506.     hs = "HungerStep: #{$game_party.steps}\\#{$game_party.step_hunger}\n"
  507.     ts = "ThirstStep: #{$game_party.steps}\\#{$game_party.step_thirst}\n"
  508.     print(sys + actors + ht + tt + hs + ts)
  509.   end
  510.   #--------------------------------------------------------------------------
  511.   # ● New method: recover_hunger
  512.   #--------------------------------------------------------------------------
  513.   def recover_hunger
  514.     members.recover_hunger
  515.   end  
  516.   #--------------------------------------------------------------------------
  517.   # ● New method: recover_hunger
  518.   #--------------------------------------------------------------------------
  519.   def recover_thirst
  520.     members.recover_thirst
  521.   end  
  522.   #--------------------------------------------------------------------------
  523.   # ● New method: recover_hunger_thirst
  524.   #--------------------------------------------------------------------------
  525.   def recover_hunger_thirst
  526.     members.recover_hunger_thirst
  527.   end  
  528. end
  529.  
  530. #==============================================================================
  531. # ** Scene_Map
  532. #------------------------------------------------------------------------------
  533. #  This class performs the map screen processing.
  534. #==============================================================================
  535. class Scene_Map
  536.   #--------------------------------------------------------------------------
  537.   # ● Aliased method: Update
  538.   #--------------------------------------------------------------------------
  539.   define_third_method(:update, :drg_hunger_map_upd) do |*args|
  540.     drg_hunger_map_upd(*args)
  541.     update_hunger if $game_party.hunger
  542.   end
  543.   #--------------------------------------------------------------------------
  544.   # ● New method: update_hunger
  545.   #--------------------------------------------------------------------------
  546.   def update_hunger
  547.     $game_party.update_hunger_by_time  if LiTTleDRAgo::BY_TIME
  548.     $game_party.update_hunger_by_steps if LiTTleDRAgo::BY_STEPS
  549.   end
  550. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement