Advertisement
LiTTleDRAgo

[RGSS/2/3] Hunger & Thirst - Cannibalism Patch

Sep 19th, 2013
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.20 KB | None | 0 0
  1. #==============================================================================
  2. # Hunger & Thirst - Cannibalism Patch
  3. # Version 1.02
  4. # Author : LiTTleDRAgo
  5. #==============================================================================
  6. #------------------------------------------------------------------------------
  7. # ** Notetags for Enemies
  8. #------------------------------------------------------------------------------
  9. # For VX and VXA user can use notetags at Enemy Tabs to determine
  10. # food / drink recovery rates    
  11. # (notetags configuration will be prioritized):
  12. #
  13. # <recover hunger by percent>
  14. # <recover thirst by percent>
  15. # <hunger: x>
  16. # <thirst: x>
  17. # <increase max hunger: x>   # fixed value only
  18. # <increase max thirst: x>   # fixed value only
  19. #
  20. #==============================================================================
  21. module LiTTleDRAgo
  22.  
  23. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  24. #                               BEGIN CONFIGURATION
  25. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  26.  
  27.   CANNIBALISM_RECOVER_HUNGER_THIRST = {
  28.   # Cannibalism recover hunger / thirst
  29.   # Set up your enemy recovery rates here. Recovery can be by either absolute
  30.   # value, or by percent. Setting :percent to true will make it by percent.
  31.     :id => [:hunger, :thirst, :percent],
  32.    
  33.     1   => [     -5,       5,    false],
  34.    
  35.   # For lazy user who wants to set every unconfigured enemy.
  36.     0   => [      10,      -3,    true],
  37.  
  38.   }
  39.  
  40. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  41. #                               END CONFIGURATION
  42. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  43.  
  44.   #----------------------------------------------------------------------------
  45.   # Don't edit
  46.   CANNIBALISM_HUNGER_THIRST_TAGS = {
  47.    :hunger        => /<hunger:\s*([-]?\d+)\s*>/i,
  48.    :thirst        => /<thirst:\s*([-]?\d+)\s*>/i,
  49.    :incmaxhunger  => /<increase[-_ ]?max[-_ ]?hunger:\s*([-]?\d+)\s*>/i,
  50.    :incmaxthirst  => /<increase[-_ ]?max[-_ ]?thirst:\s*([-]?\d+)\s*>/i,
  51.    :hungerpercent => /<recover[-_ ]?hunger[-_ ]?by[-_ ]?percent>/i,
  52.    :thirstpercent => /<recover[-_ ]?thirst[-_ ]?by[-_ ]?percent>/i,
  53.   }
  54.   #----------------------------------------------------------------------------
  55. end
  56.  
  57. ($imported||={})[:drg_hunger_thirst_cannibalism_patch] = 1.02
  58.  
  59. hunger_thirst = "This script needs Drago - Hunger & Thirst ver 1.05 or above"
  60. cannibalism = "This script needs Drago - Cannibalism ver 1.05 or above"
  61. ($imported[:drg_hunger_thirst] || 0) >= 1.05    || raise(hunger_thirst)
  62. ($imported[:drg_cannibalism_xp] || 0) >= 1.05   || raise(cannibalism)
  63. #==============================================================================
  64. # ** Game_Battler
  65. #------------------------------------------------------------------------------
  66. #  This class deals with battlers. It's used as a superclass for the Game_Actor
  67. #  and Game_Enemy classes.
  68. #==============================================================================
  69. Klass = LiTTleDRAgo::VXA ? Scene_Battle : Game_Battler
  70. class Klass
  71.   #--------------------------------------------------------------------------
  72.   # ● Public Instance Variables
  73.   #--------------------------------------------------------------------------
  74.   attr_sec_reader :ca_hunger_tags,'LiTTleDRAgo::CANNIBALISM_HUNGER_THIRST_TAGS'
  75.   #--------------------------------------------------------------------------
  76.   # ● Alias Listing
  77.   #--------------------------------------------------------------------------
  78.   alias_sec_method :devour_hunger_thirst, :devour
  79.   #--------------------------------------------------------------------------
  80.   # ● Aliased method: devour
  81.   #--------------------------------------------------------------------------
  82.   def devour(user, item)
  83.     irg = [user,item]
  84.     target, user = self, user
  85.     target, user = user, @subject if LiTTleDRAgo::VXA
  86.     if item.is_a?(RPG::Skill) && devour_skill?(item)&& user.is_a?(Game_Actor)&&
  87.       target.is_a?(Game_Enemy) && target.can_devour? && target.dead? &&
  88.         (user.devoured[target.enemy_id] || 0) < target.devour_limit
  89.       rec = LiTTleDRAgo::CANNIBALISM_RECOVER_HUNGER_THIRST[target.enemy_id]
  90.       rec ||= LiTTleDRAgo::CANNIBALISM_RECOVER_HUNGER_THIRST[0] || []
  91.       rec[0] = $1.to_i if target.get_note =~ ca_hunger_tags[:hunger]
  92.       rec[1] = $1.to_i if target.get_note =~ ca_hunger_tags[:thirst]
  93.       user.max_hunger += $1.to_i if target.get_note =~ ca_hunger_tags[:incmaxhunger]
  94.       user.max_thirst += $1.to_i if target.get_note =~ ca_hunger_tags[:incmaxthirst]
  95.       if rec.at(0).is_a?(Numeric) && rec.at(0) != 0
  96.         a = rec.at(2)==true||target.get_note =~ ca_hunger_tags[:hungerpercent]
  97.         rec[0] = (user.max_hunger*(rec.at(0)*0.01)).ceil  if a
  98.         user.hunger += rec.at(0)
  99.         $game_party.check_hunger_states
  100.       end
  101.       if rec.at(1).is_a?(Numeric) && rec.at(1) != 0
  102.         a = rec.at(2)==true||target.get_note =~ ca_hunger_tags[:thirstpercent]
  103.         rec[1] = (user.max_thirst*(rec.at(1)*0.01)).ceil if a
  104.         user.thirst += rec.at(1)
  105.         $game_party.check_thirst_states
  106.       end
  107.     end
  108.     devour_hunger_thirst(*irg)
  109.   end
  110. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement