Advertisement
Apellonyx

Survival System v1.11

Apr 6th, 2013
4,805
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 31.02 KB | None | 0 0
  1. =begin
  2. ======================================
  3.   Survival System v1.11 (formerly known as Needs System)
  4.   Created by: Apellonyx
  5.   Released: 2 April 2013
  6.   Last Update: 5 April 2013
  7. ======================================
  8.   Terms of Use:
  9.     You are free to use this system however you wish, in commercial and non-
  10.     commercial games alike. If you edit the script extensively, it is not
  11.     necessary to credit me (since you clearly only used my code as a framework),
  12.     but I would appreciate credit if it is used in its current form, or if only
  13.     minor changes were made to the script.
  14. ======================================
  15.   Support:
  16.     While I am not wildly active, I usually log onto "rpgmakervxace.com" daily,
  17.     so if you have any questions pertaining to the script, you can ask any
  18.     questions there, in the topic in which this script was released. Just as a
  19.     warning, though, I will not edit the script to make it compatible with any
  20.     special menu systems, but I will try to fix bugs as they come up. If you
  21.     find one, let me know, and I'll do my best to squash the thing.
  22. ======================================
  23.   Changelog:
  24.     v1.0: 2 April 2013 - Original version. Included food, water, rest, and life.
  25.     v1.01: 3 April 2013 - Added configurable maximum values for food,
  26.       water, and rest, and made the maximum for life a configurable value. The
  27.       failsafe mentioned in v1.0's Instructions is no longer needed.
  28.     v1.02: 3 April 2013 - Added support for a fully configurable "reverse logic"
  29.       stat, as suggested by esrann.
  30.     v1.10: 5 April 2013 - Complete rewrite using global variables rather than
  31.       game variables and switches. All stats are now optional, configurable,
  32.       and can be hidden from the menu.
  33.     v1.11: 17 May 2013 - Fixed a major bug involving the use of float values.
  34.       Floats should work just fine now without causing the game to crash or
  35.       the script to just die randomly. Also added background opacity config.
  36. ======================================
  37.   Requirements:
  38.     There are no longer any requirements for this script. I'm working on a
  39.     script that will allow the global variables to be changed through note
  40.     calls, but it may be a minute for that.
  41. ======================================
  42.   Description:
  43.     This sets up a needs system, which includes food, water, and rest, all of
  44.     which affect the main need, life. The 1.02 update also added a reverse logic
  45.     stat for toxin or radiation handling. All five stats, along with their
  46.     update rates, are handled by global variables, and can be changed at any
  47.     time with a simple script call.
  48. ======================================
  49.   Instructions:
  50.     First, you're going to want to set up how you want the script to run. All of
  51.     the options are in the first module of the script, named "Anyx." I don't
  52.     recommend changing anything after that module unless you know what you are
  53.     doing.
  54.    
  55.     Second, once you have all of your options set up, you can go about setting
  56.     up the nourishment items. All you have to do is set it up in the database as
  57.     you normally would, and then attach an effect that calls a common event.
  58.     Inside the common event, use one of the following scripts call to change the
  59.     appropriate variable. It's as simple as that.
  60.    
  61.     $survival_v[id] op value
  62.     id = The stat you want to change. 1 is for life, 2 food, 3 water, 4 rest,
  63.       and 5 toxin. Ids 6-10 are used to hold the stats' rates. 6 is for life, 7
  64.       food, 8 water, 9 rest, and 10 toxin (setting any of these rates to 0 will
  65.       disable updates for its stat, effectively pausing the system for that stat
  66.       individually without pausing it for the others)
  67.     op = The operator used to formulate the new value. += is used to add, -= is
  68.       for subtraction, *= is for multiplication, /= is for division, and %= is
  69.       for modulus. There are others, and they all work, but I don't imagine you
  70.       would use them for this script, so I won't explain them here.
  71.     value = The value you would like to alter the variable by. For example, if
  72.       you are adding 10 to a variable, this would be 10.
  73.      
  74.     $survival_s[id] = value
  75.     id = The stat you wish to enable or disable. 1 is for life, 2 food, 3 water,
  76.       4 rest, 5 toxin. Ids 6-10 are used to hide the stat bars from the menu.
  77.     value = true/false. Setting the value to true for ids 1-5 will enable the
  78.       associated stat. Setting it to false will disable it completely. For ids
  79.       6-10, setting the value to true will hide that stat from the menu, but
  80.       still allow it to update (this can be customized using the LIFEHIDEVAL,
  81.       FOODHIDEVAL, WATERHIDEVAL, RESTHIDEVAL, and TOXINHIDEVAL options in the
  82.       Anyx module below. When the hide option is true, that stat will be hidden
  83.       from the menu until the stat is below the (STAT)HIDEVAL's value, or above
  84.       the TOXINHIDEVAL's value for the toxin stat). If false, the stat will be
  85.       visible in the menu at all times.
  86.    
  87.     You no longer need to manually set the initial values for each variable, as
  88.     this can be done through the script, but you do need to turn on the survival
  89.     switch manually, or the script won't do anything.
  90. ======================================
  91. =end
  92.  
  93. $imported = {} if $imported.nil?
  94. $imported['Apellonyx-Survival'] = true
  95.  
  96. puts "Load: Survival System v1.10 by Apellonyx"
  97.  
  98. module Anyx
  99.  
  100.   WINXPOS       = 0 # X position of the survival window
  101.   WINYPOS       = 320 # Y position of the survival window
  102.   WINWIDTH      = 160 # Width of the survival window
  103.   WINTEXT       = 20 # Text size used in the survival window (looks best at 20)
  104.   WINOPACITY    = 255 # Opacity of the survival window
  105.  
  106.   SURVIVALSWITCH  = 1 # Game switch ID for enabling and disabling the system
  107.   ONINBATTLE      = true # Whether the system will update during battle scenes
  108.   DEATHATZERO     = true # If true, will cause a gameover when the life stat
  109.                          # reaches 0
  110.   DEATHFULLTOXIN  = true # If true, will cause a gameover when the toxin stat
  111.                          # reaches its maximum value
  112.  
  113.   LIFEVOCAB       = "Life" # Vocab used for the life stat in the menu
  114.   LIFEINIT        = 100 # Initial value of the life stat in new games
  115.   LIFERATE        = 300 # Number of frames between life stat updates
  116.   LIFEMAX         = 100 # Maximum value for the life bar in the menu
  117.   LIFEEXC         = 100 # Maximum value for the life stat (can exceed LIFEMAX)
  118.   LIFEENABLE      = true # If true, the life stat will be enabled
  119.   LIFEHIDE        = true # If true, the life bar will be hidden from the menu
  120.   LIFEHIDEVAL     = 100 # If LIFEHIDE is true, the life bar will appear when it
  121.                         # falls below this value.
  122.  
  123.   FOODVOCAB       = "Food" # Vocab used for the food stat in the menu
  124.   FOODINIT        = 100 # Initial value of the food stat in new games
  125.   FOODRATE        = 1200 # Number of frames between food stat updates
  126.   FOODMAX         = 100 # Maximum value for the food bar in the menu
  127.   FOODEXC         = 110 # Maximum value for the food stat (can exceed FOODMAX)
  128.   FOODMOD         = -1.0 # Value of the food stat's change each update; positive
  129.                          # values will increase the stat over time, negative
  130.                          # values decrease the stat over time, and 0 will cause
  131.                          # no update to occur over time. Accepts float values.
  132.   FOODENABLE      = true # If true, the food stat will be enabled
  133.   FOODHIDE        = true # If true, the food bar will be hidden from the menu
  134.   FOODHIDEVAL     = 100 # If FOODHIDE is true, the food bar will appear when it
  135.                         # falls below this value.
  136.  
  137.   WATERVOCAB      = "Water" # Vocab used for the water stat in the menu
  138.   WATERINIT       = 100 # Initial value of the water stat in new games
  139.   WATERRATE       = 900 # Number of frames between water stat updates
  140.   WATERMAX        = 100 # Maximum value for the water bar in the menu
  141.   WATEREXC        = 110 # Maximum value for the water stat (can exceed WATERMAX)
  142.   WATERMOD        = -1.0 # Value of the water stat's change each update; positive
  143.                          # values will increase the stat over time, negative
  144.                          # values decrease the stat over time, and 0 will cause
  145.                          # no update to occur over time. Accepts float values.
  146.   WATERENABLE     = true # If true, the water stat will be enabled
  147.   WATERHIDE       = true # If true, the water bar will be hidden from the menu
  148.   WATERHIDEVAL    = 100 # If WATERHIDE is true, the water bar will appear when
  149.                         # it falls below this value.
  150.  
  151.   RESTVOCAB       = "Rest" # Vocab used for the rest stat in the menu
  152.   RESTINIT        = 100 # Initial value of the rest stat in new games
  153.   RESTRATE        = 1500 # Number of frames between rest stat updates
  154.   RESTMAX         = 100 # Maximum value for the rest bar in the menu
  155.   RESTEXC         = 110 # Maximum value for the rest stat (can exceed RESTMAX)
  156.   RESTMOD         = -1.0 # Value of the rest stat's change each update; positive
  157.                          # values will increase the stat over time, negative
  158.                          # values decrease the stat over time, and 0 will cause
  159.                          # no update to occur over time. Accepts float values.
  160.   RESTENABLE      = true # If true, the rest stat will be enabled
  161.   RESTHIDE        = true # If true, the rest bar will be hidden from the menu
  162.   RESTHIDEVAL     = 100 # If RESTHIDE is true, the rest bar will appear when it
  163.                         # falls below this value.
  164.  
  165.   TOXINVOCAB      = "Toxin" # Vocab used for the toxin stat in the menu
  166.   TOXININIT       = 0 # Initial value of the toxin stat in new games
  167.   TOXINRATE       = 100 # Number of frames between toxin stat updates
  168.   TOXINMAX        = 1000 # Maximum value for the toxin stat and toxin bar
  169.   TOXINMOD        = 0.1 # Value of the toxin stat's change each update; positive
  170.                         # values will increase the stat over time, negative
  171.                         # values decrease the stat over time, and 0 will cause
  172.                         # no update to occur over time. Accepts float values.
  173.   TOXINENABLE     = true # If true, the toxin stat will be enabled
  174.   TOXINHIDE       = true # If true, the toxin bar will be hidden from the menu
  175.   TOXINHIDEVAL    = 0 # If TOXINHIDE is true, the toxin bar will appear when it
  176.                       # rises above this value.
  177.  
  178.   LIFECOLORL      = 17 # Color ID of the left side of the life bar
  179.   LIFECOLORR      = 6 # Color ID of the right side of the life bar
  180.   FOODCOLORL      = 3 # Color ID of the left side of the food bar
  181.   FOODCOLORR      = 24 # Color ID of the right side of the food bar
  182.   WATERCOLORL     = 16 # Color ID of the left side of the water bar
  183.   WATERCOLORR     = 4 # Color ID of the right side of the water bar
  184.   RESTCOLORL      = 31 # Color ID of the left side of the rest bar
  185.   RESTCOLORR      = 13 # Color ID of the right side of the rest bar
  186.   TOXINCOLORL     = 10 # Color ID of the left side of the toxin bar
  187.   TOXINCOLORR     = 2 # Color ID of the right side of the toxin bar
  188.  
  189.   EXCCOLOR        = 11 # Color ID of text for stat values over 100%
  190.   SATCOLOR        = 24 # Color ID of text for stat values between 76 and 100%
  191.   AVECOLOR        = 17 # Color ID of text for stat values between 51 and 75%
  192.   LOWCOLOR        = 14 # Color ID of text for stat values between 26 and 50%
  193.   DANCOLOR        = 20 # Color ID of text for stat values between 1 and 25%
  194.   DEPCOLOR        = 18 # Color ID of text for stat values of 0%
  195.  
  196. ################################################################################
  197. ################################################################################
  198. ###                                                                          ###
  199. ###  I don't recommend editing anything past this line unless you know what  ###
  200. ###   you are doing. If you do know what you're doing, however, go for it!   ###
  201. ###                                                                          ###
  202. ################################################################################
  203. ################################################################################
  204.  
  205.   def self.create_survival_commands
  206.     $survival_v       =   Survival_Variables.new
  207.     $survival_s       =   Survival_Switches.new
  208.     $survival_v[1]    =   LIFEINIT
  209.     $survival_v[6]    =   LIFERATE
  210.     $survival_s[1]    =   LIFEENABLE
  211.     $survival_s[6]    =   LIFEHIDE
  212.     $survival_v[2]    =   FOODINIT
  213.     $survival_v[7]    =   FOODRATE
  214.     $survival_s[2]    =   FOODENABLE
  215.     $survival_s[7]    =   FOODHIDE
  216.     $survival_v[3]    =   WATERINIT
  217.     $survival_v[8]    =   WATERRATE
  218.     $survival_s[3]    =   WATERENABLE
  219.     $survival_s[8]    =   WATERHIDE
  220.     $survival_v[4]    =   RESTINIT
  221.     $survival_v[9]    =   RESTRATE
  222.     $survival_s[4]    =   RESTENABLE
  223.     $survival_s[9]    =   RESTHIDE
  224.     $survival_v[5]    =   TOXININIT
  225.     $survival_v[10]   =   TOXINRATE
  226.     $survival_s[5]    =   TOXINENABLE
  227.     $survival_s[10]   =   TOXINHIDE
  228.   end # def self.create_survival_commands
  229.  
  230.   class Survival_Variables
  231.     def initialize
  232.       @data = []
  233.     end # def initialize
  234.     def [](variable_id)
  235.       @data[variable_id] || 0
  236.     end # def [](variable_id)
  237.     def []=(variable_id, value)
  238.       @data[variable_id] = value
  239.       on_change
  240.     end # def []=(variable_id, value)
  241.     def on_change
  242.       $game_map.need_refresh = true
  243.     end # def on_change
  244.   end # class Survival_Variables
  245.  
  246.   class Survival_Switches
  247.     def initialize
  248.       @data = []
  249.     end # def initialize
  250.     def [](switch_id)
  251.       @data[switch_id] || false
  252.     end # def [](switch_id)
  253.     def []=(switch_id, value)
  254.       @data[switch_id] = value
  255.       on_change
  256.     end # def []=(switch_id, value)
  257.     def on_change
  258.       $game_map.need_refresh = true
  259.     end # def on_change
  260.   end # class Survival_Switches
  261.  
  262.   def self.update
  263.     if $game_switches[SURVIVALSWITCH] == true
  264.       if $survival_s[1] == true
  265.         if $survival_v[6] > 0
  266.           if Graphics.frame_count % $survival_v[6] == 0
  267.             Anyx.life_update
  268.           end # if Graphics.frame_count % $survival_v[6] == 0
  269.         end # if $survival_v[6] > 0
  270.       end # if $survival_s[1] == true
  271.       if $survival_s[2] == true
  272.         if $survival_v[7] > 0
  273.           if Graphics.frame_count % $survival_v[7] == 0
  274.             if $survival_v[2] < FOODEXC
  275.               $survival_v[2] += FOODMOD if $survival_v[2] > 0
  276.             end
  277.           end # if Graphics.frame_count % $survival_v[7] == 0
  278.         end # if $survival_v[7] > 0
  279.       end # if $survival_s[1] == true
  280.       if $survival_s[3] == true
  281.         if $survival_v[8] > 0
  282.           if Graphics.frame_count % $survival_v[8] == 0
  283.             if $survival_v[3] < WATEREXC
  284.               $survival_v[3] += WATERMOD if $survival_v[3] > 0
  285.             end
  286.           end # if Graphics.frame_count % $survival_v[8] == 0
  287.         end # if $survival_v[8] > 0
  288.       end # if $survival_s[3] == true
  289.       if $survival_s[4] == true
  290.         if $survival_v[9] > 0
  291.           if Graphics.frame_count % $survival_v[9] == 0
  292.             if $survival_v[4] < RESTEXC
  293.               $survival_v[4] += RESTMOD if $survival_v[4] > 0
  294.             end
  295.           end # if Graphics.frame_count % $survival_v[9] == 0
  296.         end # if $survival_v[9] > 0
  297.       end # if $survival_s[4] == true
  298.       if $survival_s[5] == true
  299.         if $survival_v[10] > 0
  300.           if Graphics.frame_count % $survival_v[10] == 0
  301.             if $survival_v[5] < TOXINMAX
  302.               $survival_v[5] += TOXINMOD if $survival_v[5] > 0
  303.             end
  304.           end # if Graphics.frame_count % $survival_v[10] == 0
  305.         end # if $survival_v[10] > 0
  306.       end # if $survival_s[5] == true
  307.       $survival_v[1] = 0 if $survival_v[1] < 0
  308.       $survival_v[2] = 0 if $survival_v[2] < 0
  309.       $survival_v[3] = 0 if $survival_v[3] < 0
  310.       $survival_v[4] = 0 if $survival_v[4] < 0
  311.       $survival_v[5] = 0 if $survival_v[5] < 0
  312.       $survival_v[1] = LIFEEXC if $survival_v[1] > LIFEEXC
  313.       $survival_v[2] = FOODEXC if $survival_v[2] > FOODEXC
  314.       $survival_v[3] = WATEREXC if $survival_v[3] > WATEREXC
  315.       $survival_v[4] = RESTEXC if $survival_v[4] > RESTEXC
  316.       $survival_v[5] = TOXINMAX if $survival_v[5] > TOXINMAX
  317.       if $survival_v[1] <= 0
  318.         SceneManager.call(Scene_Gameover) if DEATHATZERO
  319.       end # if $survival_v[1] <= 0
  320.       if $survival_v[5] >= TOXINMAX
  321.         SceneManager.call(Scene_Gameover) if DEATHFULLTOXIN
  322.       end # if $survival_v[5] >= TOXINMAX
  323.     end # if $game_switches[SURVIVALSWITCH] == true
  324.   end # def update
  325.  
  326.   def self.life_update
  327.     if $survival_s[2] == true
  328.       food_25 = FOODMAX / 4
  329.       food_26 = food_25 + 0.001
  330.       food_50 = food_25 * 2
  331.       food_51 = food_50 + 0.001
  332.       food_75 = food_25 * 3
  333.       food_76 = food_75 + 0.001
  334.       food_mod = -0.3 if 0 >= $survival_v[2]
  335.       food_mod = -0.2 if (1..food_25) === $survival_v[2]
  336.       food_mod = -0.1 if (food_26..food_50) === $survival_v[2]
  337.       food_mod =  0.0 if (food_51..food_75) === $survival_v[2]
  338.       food_mod =  0.1 if (food_76..FOODMAX) === $survival_v[2]
  339.       food_mod =  0.2 if FOODMAX < $survival_v[2]
  340.     else
  341.       food_mod = 0
  342.     end # if $survival_s[2] == true
  343.     if $survival_s[3] == true
  344.       water_25 = WATERMAX / 4
  345.       water_26 = water_25 + 0.001
  346.       water_50 = water_25 * 2
  347.       water_51 = water_50 + 0.001
  348.       water_75 = water_25 * 3
  349.       water_76 = water_75 + 0.001
  350.       water_mod = -0.3 if 0 >= $survival_v[3]
  351.       water_mod = -0.2 if (1..water_25) === $survival_v[3]
  352.       water_mod = -0.1 if (water_26..water_50) === $survival_v[3]
  353.       water_mod =  0.0 if (water_51..water_75) === $survival_v[3]
  354.       water_mod =  0.1 if (water_76..WATERMAX) === $survival_v[3]
  355.       water_mod =  0.2 if WATERMAX < $survival_v[3]
  356.     else
  357.       water_mod = 0
  358.     end # if $survival_s[4] == true
  359.     if $survival_s[4] == true
  360.       rest_25 = RESTMAX / 4
  361.       rest_26 = rest_25 + 0.001
  362.       rest_50 = rest_25 * 2
  363.       rest_51 = rest_50 + 0.001
  364.       rest_75 = rest_25 * 3
  365.       rest_76 = rest_75 + 0.001
  366.       rest_mod = -0.3 if 0 >= $survival_v[4]
  367.       rest_mod = -0.2 if (1..rest_25) === $survival_v[4]
  368.       rest_mod = -0.1 if (rest_26..rest_50) === $survival_v[4]
  369.       rest_mod =  0.0 if (rest_51..rest_75) === $survival_v[4]
  370.       rest_mod =  0.1 if (rest_76..RESTMAX) === $survival_v[4]
  371.       rest_mod =  0.2 if RESTMAX < $survival_v[4]
  372.     else
  373.       rest_mod = 0
  374.     end # if $survival_s[4] == true
  375.     if $survival_s[5] == true
  376.       toxin_25 = TOXINMAX / 4
  377.       toxin_26 = toxin_25 + 0.001
  378.       toxin_50 = toxin_25 * 2
  379.       toxin_51 = toxin_50 + 0.001
  380.       toxin_75 = toxin_25 * 3
  381.       toxin_76 = toxin_75 + 0.001
  382.       toxin_99 = TOXINMAX - 0.001
  383.       toxin_mod =  0.1 if 0 >= $survival_v[5]
  384.       toxin_mod =  0.0 if (1..toxin_25) === $survival_v[5]
  385.       toxin_mod = -0.2 if (toxin_26..toxin_50) === $survival_v[5]
  386.       toxin_mod = -0.4 if (toxin_51..toxin_75) === $survival_v[5]
  387.       toxin_mod = -0.6 if (toxin_76..toxin_99) === $survival_v[5]
  388.       toxin_mod = -0.8 if TOXINMAX <= $survival_v[5]
  389.     else
  390.       toxin_mod = 0.0
  391.     end # if $survival_s[5] == true
  392.     life_mod = food_mod + water_mod + rest_mod + toxin_mod
  393.     $survival_v[1] += life_mod.round.to_i
  394.   end # def life_update()
  395.  
  396. end # module Anyx
  397.  
  398. class Scene_Title
  399.   alias survival_new_game command_new_game
  400.   def command_new_game
  401.     Anyx.create_survival_commands
  402.     survival_new_game
  403.   end # def command_new_game
  404. end # class Scene_Title
  405.  
  406. class Scene_Map < Scene_Base
  407.   alias survival_map_update update
  408.   def update
  409.     Anyx.update
  410.     survival_map_update
  411.   end # def update
  412. end # class Scene_Base
  413.  
  414. class Scene_Battle < Scene_Base
  415.   alias survival_battle_update update
  416.   def update
  417.     if Anyx::ONINBATTLE == true
  418.       Anyx.update
  419.       survival_battle_update
  420.     end # if Anyx::ONINBATTLE == true
  421.   end # def update
  422. end # class Scene_Base
  423.  
  424. class Scene_Menu < Scene_MenuBase
  425.   alias survival_menu_start start
  426.   def start
  427.     create_survival_window
  428.     survival_menu_start
  429.   end # def start
  430.   def create_survival_window
  431.     barcount = 0
  432.     if $survival_s[1] == true
  433.       barcount += 1 if $survival_s[6] == false || $survival_v[1] < Anyx::LIFEHIDEVAL
  434.     end # if $survival_s[1] == true
  435.     if $survival_s[2] == true
  436.       barcount += 1 if $survival_s[7] == false || $survival_v[2] < Anyx::FOODHIDEVAL
  437.     end # if $survival_s[2] == true
  438.     if $survival_s[3] == true
  439.       barcount += 1 if $survival_s[8] == false || $survival_v[3] < Anyx::WATERHIDEVAL
  440.     end # if $survival_s[3] == true
  441.     if $survival_s[4] == true
  442.       barcount += 1 if $survival_s[9] == false || $survival_v[4] < Anyx::RESTHIDEVAL
  443.     end # if $survival_s[4] == true
  444.     if $survival_s[5] == true
  445.       barcount += 1 if $survival_s[10] == false || $survival_v[5] > Anyx::TOXINHIDEVAL
  446.     end # if $survival_s[5] == true
  447.     @survival_window = Window_Survival.new
  448.     @survival_window.contents.draw_text(0, 0, 500, 24, " Survival System") if barcount == 0
  449.     barcount -= 1 if barcount >= 1
  450.     survivalwinypos = Anyx::WINYPOS - (24 * barcount)
  451.     @survival_window.x = Anyx::WINXPOS
  452.     @survival_window.y = survivalwinypos
  453.     @survival_window.opacity = Anyx::WINOPACITY
  454.   end # def create_survival_window
  455. end # class Scene_Menu < Scene_MenuBase
  456.  
  457. class Window_Survival < Window_Base
  458.   def initialize
  459.     winheight = 0
  460.     if $survival_s[1] == true
  461.       winheight += 1 if $survival_s[6] == false || $survival_v[1] < Anyx::LIFEHIDEVAL
  462.     end # if $survival_s[1] == true
  463.     if $survival_s[2] == true
  464.       winheight += 1 if $survival_s[7] == false || $survival_v[2] < Anyx::FOODHIDEVAL
  465.     end # if $survival_s[2] == true
  466.     if $survival_s[3] == true
  467.       winheight += 1 if $survival_s[8] == false || $survival_v[3] < Anyx::WATERHIDEVAL
  468.     end # if $survival_s[3] == true
  469.     if $survival_s[4] == true
  470.       winheight += 1 if $survival_s[9] == false || $survival_v[4] < Anyx::RESTHIDEVAL
  471.     end # if $survival_s[4] == true
  472.     if $survival_s[5] == true
  473.       winheight += 1 if $survival_s[10] == false || $survival_v[5] > Anyx::TOXINHIDEVAL
  474.     end # if $survival_s[5] == true
  475.     if winheight == 0
  476.       winheight = 1
  477.     end # if winheight == 0
  478.     super(0, 0, Anyx::WINWIDTH, fitting_height(winheight))
  479.     self.opacity = Anyx::WINOPACITY
  480.     refresh
  481.   end # def initialize
  482.  
  483.   def exc_color
  484.     text_color(Anyx::EXCCOLOR)
  485.   end # def exc_color
  486.   def sat_color
  487.     text_color(Anyx::SATCOLOR)
  488.   end # def sat_color
  489.   def ave_color
  490.     text_color(Anyx::AVECOLOR)
  491.   end # def ave_color
  492.   def low_color
  493.     text_color(Anyx::LOWCOLOR)
  494.   end # def low_color
  495.   def dan_color
  496.     text_color(Anyx::DANCOLOR)
  497.   end # def dan_color
  498.   def dep_color
  499.     text_color(Anyx::DEPCOLOR)
  500.   end # def dep_color
  501.  
  502.   def refresh
  503.     contents.clear
  504.     contents.font.size = Anyx::WINTEXT
  505.     lineheight = 0
  506.     if $survival_s[1] == true
  507.       if $survival_s[6] == false || $survival_v[1] < Anyx::LIFEHIDEVAL
  508.         draw_life(0,0,lineheight)
  509.         lineheight += 24
  510.       end # if $survival_s[6] == false || $survival_v[1] < Anyx::LIFEHIDEVAL
  511.     end # if $survival_s[1] == true
  512.     if $survival_s[2] == true
  513.       if $survival_s[7] == false || $survival_v[2] < Anyx::FOODHIDEVAL
  514.         draw_food(0,0,lineheight)
  515.         lineheight += 24
  516.       end # if $survival_s[7] == false || $survival_v[2] < Anyx::FOODHIDEVAL
  517.     end # if $survival_s[2] == true
  518.     if $survival_s[3] == true
  519.       if $survival_s[8] == false || $survival_v[3] < Anyx::WATERHIDEVAL
  520.         draw_water(0,0,lineheight)
  521.         lineheight += 24
  522.       end # if $survival_s[8] == false || $survival_v[3] < Anyx::WATERHIDEVAL
  523.     end # if $survival_s[3] == true
  524.     if $survival_s[4] == true
  525.       if $survival_s[9] == false || $survival_v[4] < Anyx::RESTHIDEVAL
  526.         draw_rest(0,0,lineheight)
  527.         lineheight += 24
  528.       end # if $survival_s[9] == false || $survival_v[4] < Anyx::RESTHIDEVAL
  529.     end # if $survival_s[4] == true
  530.     if $survival_s[5] == true
  531.       if $survival_s[10] == false || $survival_v[5] > Anyx::TOXINHIDEVAL
  532.         draw_toxin(0,0,lineheight)
  533.         lineheight += 24
  534.       end # if $survival_s[10] == false || $survival_v[5] > Anyx::TOXINHIDEVAL
  535.     end # if $survival_s[5] == true
  536.   end # def refresh
  537.  
  538.   def draw_life(actor, x, y, width = Anyx::WINWIDTH - 22)
  539.     life_25 = Anyx::LIFEMAX / 4
  540.     life_26 = life_25 + 0.001
  541.     life_50 = life_25 * 2
  542.     life_51 = life_50 + 0.001
  543.     life_75 = life_25 * 3
  544.     life_76 = life_75 + 0.001
  545.     life_99 = Anyx::LIFEMAX - 0.001
  546.     life_color = dep_color if 1 > $survival_v[1]
  547.     life_color = dan_color if (1..life_25) === $survival_v[1]
  548.     life_color = low_color if (life_26..life_50) === $survival_v[1]
  549.     life_color = ave_color if (life_51..life_75) === $survival_v[1]
  550.     life_color = sat_color if (life_76..life_99) === $survival_v[1]
  551.     life_color = exc_color if Anyx::LIFEMAX <= $survival_v[1]
  552.     life_rate = $survival_v[1] / Anyx::LIFEMAX.to_f
  553.     draw_gauge(x, y, width, life_rate, text_color(Anyx::LIFECOLORL), text_color(Anyx::LIFECOLORR))
  554.     change_color(system_color)
  555.     draw_text(x, y, 100, line_height, Anyx::LIFEVOCAB)
  556.     draw_current_and_max_values(x, y, width, $survival_v[1].round.to_i, Anyx::LIFEMAX, life_color, life_color)
  557.   end # def draw_life(actor, x, y, width = Anyx::WINWIDTH - 22)
  558.   def draw_food(actor, x, y, width = Anyx::WINWIDTH - 22)
  559.     food_25 = Anyx::FOODMAX / 4
  560.     food_26 = food_25 + 0.001
  561.     food_50 = food_25 * 2
  562.     food_51 = food_50 + 0.001
  563.     food_75 = food_25 * 3
  564.     food_76 = food_75 + 0.001
  565.     food_99 = Anyx::FOODMAX - 0.001
  566.     food_color = dep_color if 1 > $survival_v[2]
  567.     food_color = dan_color if (1..food_25) === $survival_v[2]
  568.     food_color = low_color if (food_26..food_50) === $survival_v[2]
  569.     food_color = ave_color if (food_51..food_75) === $survival_v[2]
  570.     food_color = sat_color if (food_76..food_99) === $survival_v[2]
  571.     food_color = exc_color if Anyx::FOODMAX <= $survival_v[2]
  572.     food_rate = $survival_v[2] / Anyx::FOODMAX.to_f
  573.     draw_gauge(x, y, width, food_rate, text_color(Anyx::FOODCOLORL), text_color(Anyx::FOODCOLORR))
  574.     change_color(system_color)
  575.     draw_text(x, y, 100, line_height, Anyx::FOODVOCAB)
  576.     draw_current_and_max_values(x, y, width, $survival_v[2].round.to_i, Anyx::FOODMAX, food_color, food_color)
  577.   end # def draw_food(actor, x, y, width = Anyx::WINWIDTH - 22)
  578.   def draw_water(actor, x, y, width = Anyx::WINWIDTH - 22)
  579.     water_25 = Anyx::WATERMAX / 4
  580.     water_26 = water_25 + 0.001
  581.     water_50 = water_25 * 2
  582.     water_51 = water_50 + 0.001
  583.     water_75 = water_25 * 3
  584.     water_76 = water_75 + 0.001
  585.     water_99 = Anyx::WATERMAX - 0.001
  586.     water_color = dep_color if 1 > $survival_v[3]
  587.     water_color = dan_color if (1..water_25) === $survival_v[3]
  588.     water_color = low_color if (water_26..water_50) === $survival_v[3]
  589.     water_color = ave_color if (water_51..water_75) === $survival_v[3]
  590.     water_color = sat_color if (water_76..water_99) === $survival_v[3]
  591.     water_color = exc_color if Anyx::WATERMAX <= $survival_v[3]
  592.     water_rate = $survival_v[3] / Anyx::WATERMAX.to_f
  593.     draw_gauge(x, y, width, water_rate, text_color(Anyx::WATERCOLORL), text_color(Anyx::WATERCOLORR))
  594.     change_color(system_color)
  595.     draw_text(x, y, 100, line_height, Anyx::WATERVOCAB)
  596.     draw_current_and_max_values(x, y, width, $survival_v[3].round.to_i, Anyx::WATERMAX, water_color, water_color)
  597.   end # def draw_water(actor, x, y, width = Anyx::WINWIDTH - 22)
  598.   def draw_rest(actor, x, y, width = Anyx::WINWIDTH - 22)
  599.     rest_25 = Anyx::WATERMAX / 4
  600.     rest_26 = rest_25 + 0.001
  601.     rest_50 = rest_25 * 2
  602.     rest_51 = rest_50 + 0.001
  603.     rest_75 = rest_25 * 3
  604.     rest_76 = rest_75 + 0.001
  605.     rest_99 = Anyx::RESTMAX - 0.001
  606.     rest_color = dep_color if 1 > $survival_v[4]
  607.     rest_color = dan_color if (1..rest_25) === $survival_v[4]
  608.     rest_color = low_color if (rest_26..rest_50) === $survival_v[4]
  609.     rest_color = ave_color if (rest_51..rest_75) === $survival_v[4]
  610.     rest_color = sat_color if (rest_76..rest_99) === $survival_v[4]
  611.     rest_color = exc_color if Anyx::RESTMAX <= $survival_v[4]
  612.     rest_rate = $survival_v[4] / Anyx::RESTMAX.to_f
  613.     draw_gauge(x, y, width, rest_rate, text_color(Anyx::RESTCOLORL), text_color(Anyx::RESTCOLORR))
  614.     change_color(system_color)
  615.     draw_text(x, y, 100, line_height, Anyx::RESTVOCAB)
  616.     draw_current_and_max_values(x, y, width, $survival_v[4].round.to_i, Anyx::RESTMAX, rest_color, rest_color)
  617.   end # def draw_rest(actor, x, y, width = Anyx::WINWIDTH - 22)
  618.   def draw_toxin(actor, x, y, width = Anyx::WINWIDTH - 22)
  619.     toxin_25 = Anyx::TOXINMAX / 4
  620.     toxin_26 = toxin_25 + 0.001
  621.     toxin_50 = toxin_25 * 2
  622.     toxin_51 = toxin_50 + 0.001
  623.     toxin_75 = toxin_25 * 3
  624.     toxin_76 = toxin_75 + 0.001
  625.     toxin_99 = Anyx::TOXINMAX - 0.001
  626.     toxin_color = exc_color if 1 > $survival_v[5]
  627.     toxin_color = sat_color if (1..toxin_25) === $survival_v[5]
  628.     toxin_color = ave_color if (toxin_26..toxin_50) === $survival_v[5]
  629.     toxin_color = low_color if (toxin_51..toxin_75) === $survival_v[5]
  630.     toxin_color = dan_color if (toxin_76..toxin_99) === $survival_v[5]
  631.     toxin_color = dep_color if Anyx::TOXINMAX <= $survival_v[5]
  632.     toxin_rate = $survival_v[5] / Anyx::TOXINMAX.to_f
  633.     draw_gauge(x, y, width, toxin_rate, text_color(Anyx::TOXINCOLORL), text_color(Anyx::TOXINCOLORR))
  634.     change_color(system_color)
  635.     draw_text(x, y, 100, line_height, Anyx::TOXINVOCAB)
  636.     draw_current_and_max_values(x, y, width, $survival_v[5].round.to_i, Anyx::TOXINMAX, toxin_color, toxin_color)
  637.   end # def draw_toxin(actor, x, y, width = Anyx::WINWIDTH - 22)
  638. end # class
  639.  
  640. module DataManager
  641.   def self.make_save_contents
  642.     contents = {}
  643.     contents[:system]        = $game_system
  644.     contents[:timer]         = $game_timer
  645.     contents[:message]       = $game_message
  646.     contents[:switches]      = $game_switches
  647.     contents[:variables]     = $game_variables
  648.     contents[:self_switches] = $game_self_switches
  649.     contents[:actors]        = $game_actors
  650.     contents[:party]         = $game_party
  651.     contents[:troop]         = $game_troop
  652.     contents[:map]           = $game_map
  653.     contents[:player]        = $game_player
  654.     contents[:anyx_ss]       = $survival_s
  655.     contents[:anyx_sv]       = $survival_v
  656.     contents
  657.   end # self.make_save_contents
  658.   def self.extract_save_contents(contents)
  659.     $game_system        = contents[:system]
  660.     $game_timer         = contents[:timer]
  661.     $game_message       = contents[:message]
  662.     $game_switches      = contents[:switches]
  663.     $game_variables     = contents[:variables]
  664.     $game_self_switches = contents[:self_switches]
  665.     $game_actors        = contents[:actors]
  666.     $game_party         = contents[:party]
  667.     $game_troop         = contents[:troop]
  668.     $game_map           = contents[:map]
  669.     $game_player        = contents[:player]
  670.     $survival_s         = contents[:anyx_ss]
  671.     $survival_v         = contents[:anyx_sv]
  672.   end # self.extract_save_contents(contents)
  673. end # module DataManager
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement