Advertisement
Apellonyx

Needs System v1.02

Apr 3rd, 2013
1,421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 28.90 KB | None | 0 0
  1. =begin
  2. ======================================
  3.   Needs System v1.02
  4.   Created by: Apellonyx
  5.   Released: 2 April 2013
  6.   Last Update: 3 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 - First Version
  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 "reverse logic" stat, as suggested
  29.       by esrann. It is fully configurable in the "Apellonyx" module.
  30. ======================================
  31.   Requirements:
  32.     The requirements for this script depend on how easy you want handling it to
  33.     be. It actually doesn't require any other scripts, and will operate just
  34.     fine as is, but using Tsukihime's "Effect Manager" script along with his
  35.     "Effect: Set Variable" plugin will make the process of handling the needs
  36.     much easier. Alternatively, you could use Neon Black's "Item Variable and
  37.     Switch" script, which does the same thing as the previously mentioned ones,
  38.     only without the extended functionality. Using either of these scripts is
  39.     highly recommended for those who don't like common events or who want to
  40.     save their common events for more important things than just handling one
  41.     item each.
  42. ======================================
  43.   Description:
  44.     This sets up a needs system, which includes food, water, and rest, all of
  45.     which affect the main need, life. The 1.02 update also added a reverse logic
  46.     stat for toxin or radiation handling. All five stats are all handled by
  47.     variables, and those variables can be changed at any time with a simple
  48.     "control variables" event call (or script call; your choice).
  49. ======================================
  50.   Instructions:
  51.     First, you're going to want to set up how you want the script to run. All of
  52.     the options are in the first module of the script, named "Apellonyx." I
  53.     don't recommend changing anything after that module unless you know what you
  54.     are doing.
  55.    
  56.     Second, once you have all of your options set up, you can go about setting
  57.     up the nourishment items. This can be done in one of three ways, depending
  58.     on whether you chose to use any of the recommended "required" scripts or
  59.     not. If you did, then setting up the items is simple. Just tag it
  60.     appropriately, as the script describes (<eff: set_var id op val> for
  61.     Tsukihime's scripts, or variable[id op val] for Neon Black's script).
  62.    
  63.     If you don't use any of these scripts, it's still easy to make the items.
  64.     All you have to do is set it up in the database as you normally would, and
  65.     then attach an effect that calls a common event. Inside the common event,
  66.     use the "Control Variables" call to change the appropriate variable. It's
  67.     as simple as that.
  68.    
  69.     Remember to manually set up the initial values for each variable, and to
  70.     turn on the needs and menu switches (and the toxin switch if you're using
  71.     it). Otherwise, this script will do absolutely nothing.
  72. ======================================
  73.   Toxin Instructions:
  74.     The toxin stat is quite a bit more complicated than the rest. If you want to
  75.     activate the toxin portion in your game, you must first decide how you want
  76.     to use it. I have set up the script to handle a lot of different setups, but
  77.     to get what you want out of it, there is a bit you need to know first.
  78.    
  79.     First and foremost, if you set the TOXINSWITCH option to 0, it won't even
  80.     parse any other toxin related information. Your toxin stat won't change,
  81.     unless you change it manually through scripts or items. It doesn't disable
  82.     the system completely, but just keeps it out of the menu and keeps it from
  83.     changing on its own. I wouldn't recommend using the system without the
  84.     switch, since it can still kill you, and there's no way to know it's coming.
  85.    
  86.     If you set the TOXINSWITCH to something other than 0, but you set TOXINVAR
  87.     to 0, the game will somehow still manage to hold the value and change it
  88.     through the script if that option is enabled. Of course, you can't change it
  89.     ingame, even with script calls ($game_variables[0] += 20 will crash the
  90.     game, since $game_variables[0] can't exist), so you should set it to an
  91.     actual existing variable if you're going to use the TOXINSWITCH.
  92.     PS: I have no idea how the script manages to change a nonexistent variable,
  93.     but it does, and I think that's cool.
  94.    
  95.     Moving on, the TOXINRATEVAR is the variable that will designate the speed
  96.     at which the Toxin stat is changed. It works the same way as the rates for
  97.     the other stats (where a lower number will change the stat faster than a
  98.     higher number), but I made it a game variable so that you can change how
  99.     fast it goes depending on where you are or what you're doing. For example,
  100.     if you want to gain Toxin faster when you're walking through a swamp, or
  101.     when you're fighting some sort of toxic creature, you can do that by just
  102.     altering this variable. If you set the variable to 0, your Toxin stat won't
  103.     change over time, but can still be changed manually.
  104.    
  105.     TOXINMOD is the option that will decide how the stat is changed. If you set
  106.     it to a positive number, you will gain Toxin over time. If you set it to a
  107.     negative number, you'll lose toxin over time, and if you set it to zero, you
  108.     will have to change Toxin values manually.
  109.    
  110.     HIDETOXINZERO is a display option. If you want your Toxin bar to show at all
  111.     times, set it to false. However, if you want it only to show when you are
  112.     affected by Toxin, set it to true. So if it's set to true, and your toxin
  113.     stat is zero, the Toxin bar won't appear in the menu, but as soon as your
  114.     Toxin stat goes up, you'll know, because the Toxin bar will show up.
  115.    
  116.     And of course, TOXINDEATH is one of those options that allows you to kill
  117.     people off. If you set it to true, you'll get a gameover as soon as you
  118.     reach the Toxin maximum. If you set it to false, then your characters will
  119.     get to keep on living, even though they've been poisoned to death. Because
  120.     they're all zombie mutants.
  121.    
  122.     As for setting up medicines and whatnot, just create them in the same way
  123.     you make the food and water, but instead of having them increase a variable,
  124.     make them decrease the variable. Additionally, you could do like the Fallout
  125.     games and have certain foods increase your Toxin level in addition to sating
  126.     hunger. You know, just a suggestion.
  127. ======================================
  128. =end
  129.  
  130. module Apellonyx
  131.  
  132.   NEEDSXPOS = 0         # X position of the needs window
  133.   NEEDSYPOS = 248       # Y position of the needs window
  134.   NEEDSWIDTH = 160      # Width of the needs window
  135.   NEEDSSIZE = 20        # Text size in the needs window (looks best at 20)
  136.  
  137.   LIFEVOCAB = "Life"    # Term used in the menu for the Life stat
  138.   FOODVOCAB = "Food"    # Term used in the menu for the Food stat
  139.   WATERVOCAB = "Water"  # Term used in the menu for the Water stat
  140.   RESTVOCAB = "Rest"    # Term used in the menu for the Rest stat
  141.   TOXINVOCAB = "Toxin"  # Term used in the menu for the Toxin stat
  142.  
  143.   HIDETOXINZERO = true  # true: Will hide Toxin stat in menu when it is at zero.
  144.                         # false: If the TOXINSWITCH config option has been set,
  145.                         # it will show the Toxin stat in the menu, even if it is
  146.                         # at zero.
  147.  
  148.   NEEDSSWITCH = 1       # Switch ID that turns the system on
  149.   MENUSWITCH = 2        # Switch ID that turns the system off while in the menu
  150.   TOXINSWITCH = 5       # Switch ID that activates Toxin; set to 0 to disable
  151.  
  152.   LIFEVAR = 1           # Variable ID for the Life stat
  153.   LIFERATE = 900        # Number of frames before the Life stat updates
  154.   LIFEMAX = 100         # Maximum value for the Life stat
  155.   FOODVAR = 2           # Variable ID for the Food stat
  156.   FOODRATE = 480        # Number of frames before the Food stat updates
  157.   FOODMAX = 110         # Maximum value for the Food stat
  158.   WATERVAR = 3          # Variable ID for the Water stat
  159.   WATERRATE = 360       # Number of frames before the Water stat updates
  160.   WATERMAX = 110        # Maximum value for the Water stat
  161.   RESTVAR = 4           # Variable ID for the Rest stat
  162.   RESTRATE = 600        # Number of frames before the Rest stat updates
  163.   RESTMAX = 110         # Maximum value for the Rest stat
  164.   TOXINVAR = 5          # Variable ID for the Toxin stat; set to 0 to disable
  165.   TOXINMAX = 1000       # Maximum value for the Toxin stat
  166.   TOXINRATEVAR = 6      # Variable ID for the Toxin rate; 0 to disable
  167.   TOXINMOD = 0          # Value Toxin stat changes during each update
  168.  
  169.   TIMESCALE = 7         # Variable ID for the timescale. A timescale of 0 or 1
  170.                         # will have no effect on the needs rates. Setting it
  171.                         # higher, though, will make needs deplete faster, which
  172.                         # is useful for making depletion occur more quickly on
  173.                         # certain maps (especially world maps). Setting it to 2
  174.                         # will make needs drain twice as quickly, while 3 drains
  175.                         # them three times as fast, and so on.
  176.  
  177.   LIFEGCOLOR1 = 17      # Color to the left on Life stat's gauge
  178.   LIFEGCOLOR2 = 6       # Color to the right on Life stat's gauge
  179.   FOODGCOLOR1 = 3       # Color to the left on Food stat's gauge
  180.   FOODGCOLOR2 = 24      # Color to the right on Food stat's gauge
  181.   WATERGCOLOR1 = 16     # Color to the left on Water stat's gauge
  182.   WATERGCOLOR2 = 4      # Color to the right on Water stat's gauge
  183.   RESTGCOLOR1 = 31      # Color to the left on Rest stat's gauge
  184.   RESTGCOLOR2 = 13      # Color to the right on Rest stat's gauge
  185.   TOXINGCOLOR1 = 10     # Color to the left on Toxin stat's gauge
  186.   TOXINGCOLOR2 = 2      # Color to the right on Toxin stat's gauge
  187.  
  188.   EXCCOLOR = 11         # Color of gauge numbers when stat is above 100
  189.   SATCOLOR = 24         # Color of gauge numbers when stat is 75-100
  190.   AVECOLOR = 14         # Color of gauge numbers when stat is 25-74
  191.   DANCOLOR = 20         # Color of gauge numbers when stat is 1-24
  192.   DEPCOLOR = 18         # Color of gauge numbers when stat is 0
  193.  
  194.   DEATHATZERO = true    # Setting this to true will cause a gameover when your
  195.                         # life reaches zero. If false, nothing will happen when
  196.                         # you reach zero life.
  197.   TOXINDEATH = true     # Setting this to true will cause a gameover if your
  198.                         # Toxin stat reaches its maximum value. If false, it
  199.                         # will simply continue to alter the life value.
  200.  
  201. end # module Apellonyx
  202.  
  203. #===========================
  204. # Don't edit past this point unless you know what you're doing
  205. #===========================
  206.  
  207. class Scene_Base
  208.   alias needs_time_update update
  209.   def update
  210.     if $game_switches[Apellonyx::NEEDSSWITCH] == true
  211.       if $game_switches[Apellonyx::MENUSWITCH] == true
  212.         if $game_variables[Apellonyx::TIMESCALE] == 0
  213.           if Graphics.frame_count % Apellonyx::LIFERATE == 0
  214.             life_update
  215.           end # if Graphics.frame_count % Apellonyx::LIFERATE == 0
  216.         else
  217.           timed_liferate = Apellonyx::LIFERATE / $game_variables[Apellonyx::TIMESCALE]
  218.           if Graphics.frame_count % timed_liferate == 0
  219.             life_update
  220.           end # if Graphics.frame_count % timed_liferate == 0
  221.         end # if $game_variables[Apellonyx::TIMESCALE] == 0
  222.        
  223.         if $game_variables[Apellonyx::TIMESCALE] == 0
  224.           if Graphics.frame_count % Apellonyx::FOODRATE == 0
  225.             if $game_variables[Apellonyx::FOODVAR] >= 1
  226.               $game_variables[Apellonyx::FOODVAR] -= 1
  227.               puts "FOODVAR == " + $game_variables[Apellonyx::FOODVAR].to_s
  228.             end #if $game_variables[Apellonyx::FOODVAR] >= 1
  229.           end # if Graphics.frame_count % Apellonyx::FOODRATE == 0
  230.         else
  231.           timed_foodrate = Apellonyx::FOODRATE / $game_variables[Apellonyx::TIMESCALE]
  232.           if Graphics.frame_count % timed_foodrate == 0
  233.             if $game_variables[Apellonyx::FOODVAR] >= 1
  234.               $game_variables[Apellonyx::FOODVAR] -= 1
  235.               puts "FOODVAR == " + $game_variables[Apellonyx::FOODVAR].to_s
  236.             end # if $game_variables[Apellonyx::FOODVAR] >= 1
  237.           end #if Graphics.frame_count % timed_foodrate == 0
  238.         end # if $game_variables[Apellonyx::TIMESCALE] == 0
  239.        
  240.         if $game_variables[Apellonyx::TIMESCALE] == 0
  241.           if Graphics.frame_count % Apellonyx::WATERRATE == 0
  242.             if $game_variables[Apellonyx::WATERVAR] >= 1
  243.               $game_variables[Apellonyx::WATERVAR] -= 1
  244.               puts "WATERVAR == " + $game_variables[Apellonyx::WATERVAR].to_s
  245.             end # if $game_variables[Apellonyx::WATERVAR] >= 1
  246.           end # if Graphics.frame_count % Apellonyx::WATERRATE == 0
  247.         else
  248.           timed_waterrate = Apellonyx::WATERRATE / $game_variables[Apellonyx::TIMESCALE]
  249.           if Graphics.frame_count % timed_waterrate == 0
  250.             if $game_variables[Apellonyx::WATERVAR] >= 1
  251.               $game_variables[Apellonyx::WATERVAR] -= 1
  252.               puts "WATERVAR == " + $game_variables[Apellonyx::WATERVAR].to_s
  253.             end # if $game_variables[Apellonyx::WATERVAR] >= 1
  254.           end # if Graphics.frame_count % timed_waterrate == 0
  255.         end # if $game_variables[Apellonyx::TIMESCALE] == 0
  256.        
  257.         if $game_variables[Apellonyx::TIMESCALE] == 0
  258.           if Graphics.frame_count % Apellonyx::RESTRATE == 0
  259.             if $game_variables[Apellonyx::RESTVAR] >= 1
  260.               $game_variables[Apellonyx::RESTVAR] -= 1
  261.               puts "RESTVAR == " + $game_variables[Apellonyx::RESTVAR].to_s
  262.             end # if $game_variables[Apellonyx::RESTVAR] >= 1
  263.           end # if Graphics.frame_count % Apellonyx::RESTRATE == 0
  264.         else
  265.           timed_restrate = Apellonyx::RESTRATE / $game_variables[Apellonyx::TIMESCALE]
  266.           if Graphics.frame_count % timed_restrate == 0
  267.             if $game_variables[Apellonyx::RESTVAR] >= 1
  268.               $game_variables[Apellonyx::RESTVAR] -= 1
  269.               puts "RESTVAR == " + $game_variables[Apellonyx::RESTVAR].to_s
  270.             end # if $game_variables[Apellonyx::RESTVAR] >= 1
  271.           end # if Graphics.frame_count % timed_restrate == 0
  272.         end # if $game_variables[Apellonyx::TIMESCALE] == 0
  273.        
  274.         if Apellonyx::TOXINSWITCH != 0
  275.           if $game_switches[Apellonyx::TOXINSWITCH] == true
  276.             if Apellonyx::TOXINRATEVAR != 0
  277.               if $game_variables[Apellonyx::TOXINRATEVAR] != 0
  278.                 if $game_variables[Apellonyx::TIMESCALE] == 0
  279.                   if Graphics.frame_count % $game_variables[Apellonyx::TOXINRATEVAR] == 0
  280.                     if $game_variables[Apellonyx::TOXINVAR] < Apellonyx::TOXINMAX
  281.                       $game_variables[Apellonyx::TOXINVAR] += Apellonyx::TOXINMOD
  282.                       puts "TOXINVAR == " + $game_variables[Apellonyx::TOXINVAR].to_s
  283.                     end # if $game_variables[Apellonyx::TOXINVAR] < Apellonyx::TOXINMAX
  284.                   end # if Graphics.frame_count % $game_variables[Apellonyx::TOXINRATEVAR] == 0
  285.                 else
  286.                   timed_toxinrate = $game_variables[Apellonyx::TOXINRATEVAR] / $game_variables[Apellonyx::TIMESCALE]
  287.                   if Graphics.frame_count % timed_toxinrate == 0
  288.                     if $game_variables[Apellonyx::TOXINVAR] < Apellonyx::TOXINMAX
  289.                       $game_variables[Apellonyx::TOXINVAR] += Apellonyx::TOXINMOD
  290.                       puts "TOXINVAR == " + $game_variables[Apellonyx::TOXINVAR].to_s
  291.                     end # if $game_variables[Apellonyx::TOXINVAR] < Apellonyx::TOXINMAX
  292.                   end # if Graphics.frame_count % timed_toxinrate == 0
  293.                 end # if $game_variables[Apellonyx::TIMESCALE] == 0
  294.               end # if $game_variables[Apellonyx::TOXINRATEVAR] != 0
  295.             end # if Apellonyx::TOXINRATEVAR != 0
  296.           end # if $game_switches[Apellonyx::TOXINSWITCH] == true
  297.         end # if Apellonyx::TOXINSWITCH != 0
  298.       end # if $game_switches[Apellonyx::MENUSWITCH] == true
  299.      
  300.       if $game_variables[Apellonyx::LIFEVAR] > Apellonyx::LIFEMAX
  301.         $game_variables[Apellonyx::LIFEVAR] = Apellonyx::LIFEMAX
  302.       end
  303.       if $game_variables[Apellonyx::FOODVAR] > Apellonyx::FOODMAX
  304.         $game_variables[Apellonyx::FOODVAR] = Apellonyx::FOODMAX
  305.       end
  306.       if $game_variables[Apellonyx::WATERVAR] > Apellonyx::WATERMAX
  307.         $game_variables[Apellonyx::WATERVAR] = Apellonyx::WATERMAX
  308.       end
  309.       if $game_variables[Apellonyx::RESTVAR] > Apellonyx::RESTMAX
  310.         $game_variables[Apellonyx::RESTVAR] = Apellonyx::RESTMAX
  311.       end
  312.       if Apellonyx::TOXINVAR != 0
  313.         if Apellonyx::TOXINDEATH == true
  314.           if $game_variables[Apellonyx::TOXINVAR] >= Apellonyx::TOXINMAX
  315.             SceneManager.call(Scene_Gameover)
  316.           end # if $game_variables[Apellonyx::TOXINVAR] >= Apellonyx::TOXINMAX
  317.         else
  318.           if $game_variables[Apellonyx::TOXINVAR] > Apellonyx::TOXINMAX
  319.             $game_variables[Apellonyx::TOXINVAR] = Apellonyx::TOXINMAX
  320.           end
  321.         end # if Apellonyx::TOXINDEATH == true
  322.         if $game_variables[Apellonyx::TOXINVAR] < 0
  323.           $game_variables[Apellonyx::TOXINVAR] = 0
  324.         end
  325.       end # if Apellonyx::TOXINVAR != 0
  326.     end # if $game_switches[Apellonyx::NEEDSSWITCH] == true
  327.     needs_time_update
  328.   end # def update
  329.  
  330.   def life_update
  331.     food_mod = -2 if 0 >= $game_variables[Apellonyx::FOODVAR]
  332.     food_mod = -1 if (1..25) === $game_variables[Apellonyx::FOODVAR]
  333.     food_mod = 0 if (26..75) === $game_variables[Apellonyx::FOODVAR]
  334.     food_mod = 1 if (76..100) === $game_variables[Apellonyx::FOODVAR]
  335.     food_mod = 2 if 100 < $game_variables[Apellonyx::FOODVAR]
  336.     water_mod = -2 if 0 >= $game_variables[Apellonyx::WATERVAR]
  337.     water_mod = -1 if (1..25) === $game_variables[Apellonyx::WATERVAR]
  338.     water_mod = 0 if (26..75) === $game_variables[Apellonyx::WATERVAR]
  339.     water_mod = 1 if (76..100) === $game_variables[Apellonyx::WATERVAR]
  340.     water_mod = 2 if 100 < $game_variables[Apellonyx::WATERVAR]
  341.     rest_mod = -2 if 0 >= $game_variables[Apellonyx::FOODVAR]
  342.     rest_mod = -1 if (1..25) === $game_variables[Apellonyx::RESTVAR]
  343.     rest_mod = 0 if (26..75) === $game_variables[Apellonyx::RESTVAR]
  344.     rest_mod = 1 if (76..100) === $game_variables[Apellonyx::RESTVAR]
  345.     rest_mod = 2 if 100 < $game_variables[Apellonyx::RESTVAR]
  346.     if Apellonyx::TOXINSWITCH == 0
  347.       toxin_mod = 0
  348.     else
  349.       toxin_25 = Apellonyx::TOXINMAX / 4
  350.       toxin_26 = toxin_25 + 1
  351.       toxin_50 = toxin_25 * 2
  352.       toxin_51 = toxin_50 + 1
  353.       toxin_75 = toxin_25 * 3
  354.       toxin_76 = toxin_75 + 1
  355.       toxin_99 = Apellonyx::TOXINMAX - 1
  356.       toxin_mod = 1 if 0 >= $game_variables[Apellonyx::TOXINVAR]
  357.       toxin_mod = 0 if (1..toxin_25) === $game_variables[Apellonyx::TOXINVAR]
  358.       toxin_mod = -2 if (toxin_26..toxin_50) === $game_variables[Apellonyx::TOXINVAR]
  359.       toxin_mod = -4 if (toxin_51..toxin_75) === $game_variables[Apellonyx::TOXINVAR]
  360.       toxin_mod = -6 if (toxin_76..toxin_99) === $game_variables[Apellonyx::TOXINVAR]
  361.       toxin_mod = -8 if Apellonyx::TOXINMAX == $game_variables[Apellonyx::TOXINVAR]
  362.     end # if Apellonyx::TOXINVAR == 0
  363.     life_mod = food_mod + water_mod + rest_mod + toxin_mod
  364.     $game_variables[Apellonyx::LIFEVAR] += life_mod
  365.     puts "LIFEVAR == " + $game_variables[Apellonyx::LIFEVAR].to_s
  366.     if $game_variables[Apellonyx::LIFEVAR] > Apellonyx::LIFEMAX
  367.       $game_variables[Apellonyx::LIFEVAR] = Apellonyx::LIFEMAX
  368.       puts "LIFEVAR OVER 100 - SET TO " + $game_variables[Apellonyx::LIFEVAR].to_s
  369.     end # if $game_variables[Apellonyx::LIFEVAR] > 100
  370.     if $game_variables[Apellonyx::LIFEVAR] <= 0
  371.       $game_variables[Apellonyx::LIFEVAR] = 0
  372.       puts "LIFEVAR BELOW 0 - SET TO " + $game_variables[Apellonyx::LIFEVAR].to_s
  373.       if Apellonyx::DEATHATZERO == true
  374.         SceneManager.call(Scene_Gameover)
  375.       end
  376.     end # if $game_variables[Apellonyx::LIFEVAR] <= 0
  377.   end # def l_update
  378. end # class Scene_Base
  379.  
  380. class Scene_MenuBase < Scene_Base
  381.   alias needs_off_in_menu start
  382.   def start
  383.     $game_switches[Apellonyx::MENUSWITCH] = false
  384.     puts "MENUSWITCH == " + $game_switches[Apellonyx::MENUSWITCH].to_s
  385.     needs_off_in_menu
  386.   end # def start
  387.   alias needs_on_out_of_menu terminate
  388.   def terminate
  389.     $game_switches[Apellonyx::MENUSWITCH] = true
  390.     puts "MENUSWITCH == " + $game_switches[Apellonyx::MENUSWITCH].to_s
  391.     needs_on_out_of_menu
  392.   end # def terminate
  393. end # class Scene_MenuBase < Scene_Base
  394.  
  395. class Scene_Gameover < Scene_Base
  396.   alias needs_off_at_gameover start
  397.   def start
  398.     $game_switches[Apellonyx::NEEDSSWITCH] = false
  399.     $game_switches[Apellonyx::MENUSWITCH] = false
  400.     $game_switches[Apellonyx::TOXINSWITCH] = false
  401.     puts "NEEDSSWITCH == " + $game_switches[Apellonyx::MENUSWITCH].to_s
  402.     puts "MENUSWITCH == " + $game_switches[Apellonyx::MENUSWITCH].to_s
  403.     puts "TOXINSWITCH == " + $game_switches[Apellonyx::MENUSWITCH].to_s
  404.     needs_off_at_gameover
  405.   end # def start
  406. end # class Scene_Gameover < Scene_Base
  407.  
  408. class Scene_Menu < Scene_MenuBase
  409.   alias start_with_needs start
  410.   def start
  411.     create_needs_window
  412.     start_with_needs
  413.   end # def start
  414.   def create_needs_window
  415.     @needs_window = Window_Needs.new
  416.     @needs_window.x = (Apellonyx::NEEDSXPOS)
  417.     if Apellonyx::TOXINSWITCH == 0
  418.       @needs_window.y = (Apellonyx::NEEDSYPOS)
  419.     else
  420.       if Apellonyx::HIDETOXINZERO == false
  421.         @needs_window.y = (Apellonyx::NEEDSYPOS - 24)
  422.       else
  423.         if $game_variables[Apellonyx::TOXINVAR] == 0
  424.           @needs_window.y = (Apellonyx::NEEDSYPOS)
  425.         else
  426.           @needs_window.y = (Apellonyx::NEEDSYPOS - 24)
  427.         end # if $game_variables[Apellonyx::TOXINVAR] == 0
  428.       end # Apellonyx::HIDETOXINZERO == false
  429.     end # Apellonyx::TOXINSWITCH == 0
  430.   end # def create_needs_window
  431. end # class Scene_Menu < Scene_MenuBase
  432.  
  433. class Window_Needs < Window_Base
  434.   def initialize
  435.     if Apellonyx::TOXINSWITCH == 0
  436.       super(0, 0, Apellonyx::NEEDSWIDTH, fitting_height(4))
  437.     else
  438.       if Apellonyx::HIDETOXINZERO == false
  439.         super(0, 0, Apellonyx::NEEDSWIDTH, fitting_height(5))
  440.       else
  441.         if $game_variables[Apellonyx::TOXINVAR] == 0
  442.           super(0, 0, Apellonyx::NEEDSWIDTH, fitting_height(4))
  443.         else
  444.           super(0, 0, Apellonyx::NEEDSWIDTH, fitting_height(5))
  445.         end # if $game_variables[Apellonyx::TOXINVAR] == 0
  446.       end # Apellonyx::HIDETOXINZERO == false
  447.     end # Apellonyx::TOXINSWITCH == 0
  448.     refresh
  449.   end # def initialize
  450.  
  451.   def exc_color
  452.     text_color(Apellonyx::EXCCOLOR)
  453.   end # def exc_color
  454.   def sat_color
  455.     text_color(Apellonyx::SATCOLOR)
  456.   end # def sat_color
  457.   def ave_color
  458.     text_color(Apellonyx::AVECOLOR)
  459.   end # def ave_color
  460.   def dan_color
  461.     text_color(Apellonyx::DANCOLOR)
  462.   end # def dan_color
  463.   def dep_color
  464.     text_color(Apellonyx::DEPCOLOR)
  465.   end # def dep_color
  466.  
  467.   def refresh
  468.     contents.clear
  469.     contents.font.size = Apellonyx::NEEDSSIZE
  470.     draw_life(0, 0, 0)
  471.     draw_food(0, 0, 24)
  472.     draw_water(0, 0, 48)
  473.     draw_rest(0, 0, 72)
  474.     if Apellonyx::HIDETOXINZERO == true
  475.       if $game_variables[Apellonyx::TOXINVAR] != 0
  476.         draw_toxin(0, 0, 96)
  477.       end # if $game_variables[Apellonyx::TOXINVAR] != 0
  478.     else
  479.       if Apellonyx::TOXINSWITCH != 0
  480.         draw_toxin(0, 0, 96)
  481.       end # if Apellonyx::TOXINSWITCH != 0
  482.     end # if Apellonyx::HIDETOXINZERO == true
  483.   end # def refresh
  484.  
  485.   def draw_life(actor, x, y, width = Apellonyx::NEEDSWIDTH - 22)
  486.     life_color = exc_color if $game_variables[Apellonyx::LIFEVAR] > 100
  487.     life_color = sat_color if $game_variables[Apellonyx::LIFEVAR] <= 100
  488.     life_color = ave_color if $game_variables[Apellonyx::LIFEVAR] < 75
  489.     life_color = dan_color if $game_variables[Apellonyx::LIFEVAR] < 25
  490.     life_color = dep_color if $game_variables[Apellonyx::LIFEVAR] <= 0
  491.     life_rate = $game_variables[Apellonyx::LIFEVAR] / 100.0
  492.     draw_gauge(x, y, width, life_rate, text_color(Apellonyx::LIFEGCOLOR1),
  493.       text_color(Apellonyx::LIFEGCOLOR2))
  494.     change_color(system_color)
  495.     draw_text(x, y, 100, line_height, Apellonyx::LIFEVOCAB)
  496.     draw_current_and_max_values(x, y, width, $game_variables[Apellonyx::LIFEVAR],
  497.       "100%", life_color, life_color)
  498.   end # def draw_life
  499.   def draw_food(actor, x, y, width = Apellonyx::NEEDSWIDTH - 22)
  500.     food_color = exc_color if $game_variables[Apellonyx::FOODVAR] > 100
  501.     food_color = sat_color if $game_variables[Apellonyx::FOODVAR] <= 100
  502.     food_color = ave_color if $game_variables[Apellonyx::FOODVAR] < 75
  503.     food_color = dan_color if $game_variables[Apellonyx::FOODVAR] < 25
  504.     food_color = dep_color if $game_variables[Apellonyx::FOODVAR] <= 0
  505.     food_rate = $game_variables[Apellonyx::FOODVAR] / 100.0
  506.     draw_gauge(x, y, width, food_rate, text_color(Apellonyx::FOODGCOLOR1),
  507.       text_color(Apellonyx::FOODGCOLOR2))
  508.     change_color(system_color)
  509.     draw_text(x, y, 100, line_height, Apellonyx::FOODVOCAB)
  510.     draw_current_and_max_values(x, y, width, $game_variables[Apellonyx::FOODVAR],
  511.       "100%", food_color, food_color)
  512.   end # def draw_food
  513.   def draw_water(actor, x, y, width = Apellonyx::NEEDSWIDTH - 22)
  514.     water_color = exc_color if $game_variables[Apellonyx::WATERVAR] > 100
  515.     water_color = sat_color if $game_variables[Apellonyx::WATERVAR] <= 100
  516.     water_color = ave_color if $game_variables[Apellonyx::WATERVAR] < 75
  517.     water_color = dan_color if $game_variables[Apellonyx::WATERVAR] < 25
  518.     water_color = dep_color if $game_variables[Apellonyx::WATERVAR] <= 0
  519.     water_rate = $game_variables[Apellonyx::WATERVAR] / 100.0
  520.     draw_gauge(x, y, width, water_rate, text_color(Apellonyx::WATERGCOLOR1),
  521.       text_color(Apellonyx::WATERGCOLOR2))
  522.     change_color(system_color)
  523.     draw_text(x, y, 100, line_height, Apellonyx::WATERVOCAB)
  524.     draw_current_and_max_values(x, y, width, $game_variables[Apellonyx::WATERVAR],
  525.       "100%", water_color, water_color)
  526.   end # def draw_water
  527.   def draw_rest(actor, x, y, width = Apellonyx::NEEDSWIDTH - 22)
  528.     rest_color = exc_color if $game_variables[Apellonyx::RESTVAR] > 100
  529.     rest_color = sat_color if $game_variables[Apellonyx::RESTVAR] <= 100
  530.     rest_color = ave_color if $game_variables[Apellonyx::RESTVAR] < 75
  531.     rest_color = dan_color if $game_variables[Apellonyx::RESTVAR] < 25
  532.     rest_color = dep_color if $game_variables[Apellonyx::RESTVAR] <= 0
  533.     rest_rate = $game_variables[Apellonyx::RESTVAR] / 100.0
  534.     draw_gauge(x, y, width, rest_rate, text_color(Apellonyx::RESTGCOLOR1),
  535.       text_color(Apellonyx::RESTGCOLOR2))
  536.     change_color(system_color)
  537.     draw_text(x, y, 100, line_height, Apellonyx::RESTVOCAB)
  538.     draw_current_and_max_values(x, y, width, $game_variables[Apellonyx::RESTVAR],
  539.       "100%", rest_color, rest_color)
  540.   end # def draw_rest
  541.   def draw_toxin(actor, x, y, width = Apellonyx::NEEDSWIDTH - 22)
  542.     toxin_25 = Apellonyx::TOXINMAX / 4
  543.     toxin_75 = toxin_25 * 3
  544.     toxin_color = dep_color if $game_variables[Apellonyx::TOXINVAR] > Apellonyx::TOXINMAX
  545.     toxin_color = dan_color if $game_variables[Apellonyx::TOXINVAR] <= Apellonyx::TOXINMAX
  546.     toxin_color = ave_color if $game_variables[Apellonyx::TOXINVAR] < toxin_75
  547.     toxin_color = sat_color if $game_variables[Apellonyx::TOXINVAR] < toxin_25
  548.     toxin_color = exc_color if $game_variables[Apellonyx::TOXINVAR] <= 0
  549.     toxin_rate = $game_variables[Apellonyx::TOXINVAR] / Apellonyx::TOXINMAX.to_f
  550.     draw_gauge(x, y, width, toxin_rate, text_color(Apellonyx::TOXINGCOLOR1),
  551.       text_color(Apellonyx::TOXINGCOLOR2))
  552.     change_color(system_color)
  553.     draw_text(x, y, 100, line_height, Apellonyx::TOXINVOCAB)
  554.     draw_current_and_max_values(x, y, width, $game_variables[Apellonyx::TOXINVAR],
  555.       Apellonyx::TOXINMAX.to_s, toxin_color, toxin_color)
  556.   end # def draw_toxin
  557. end # class Window_Needs < Window_Base
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement