Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. =begin
  2.  
  3.   Script Name:   Tag Nacht System
  4.   Autor:         Tajiin
  5.   Datum:         04/12/2013 | tt/mm/jjjj
  6.  
  7.   Version: 1.5
  8.   Versions Datum: 24.05.2015
  9.  
  10.   Beschreibung:
  11.     Dieses Script färbt den Bildschirm nach einer bestimmten Zeit
  12.     um, um einen Tag Nacht Effekt zu erzielen.
  13.     Der Bildschirm wird wieder normal gefärbt wenn die eingestellte Zeit
  14.     nochmals um ist.
  15.     Das System kann gestoppt und die Wechsel (Tag -> Nacht; Nacht -> Tag)
  16.     durch einen Befehl ausgeführt werden.
  17.    
  18.    
  19. Skript-Befehle:
  20.     $game_system.daynightsystem.set_tone(t)
  21.    
  22.       - Mit diesem befehl kannst du auf einen bestimmen Farbton wechseln
  23.       - t: ist der Farbton index (0-7)
  24.      
  25.  
  26.   Was kann ich im EDIT-Bereich verändern:
  27.     Switch_ID: Hier kannst du die Switch ID verändern mit der du das Script
  28.                stoppen kannst. (True = An; False = Aus)
  29.                Wenn du eine "0" einstellst wird diese Funktion deaktiviert.
  30.                
  31.     Tag_Nacht_Time: Hier kannst du die Zeit angeben von 0Uhr bis 12Uhr
  32.                     (in Minuten)
  33.    
  34.     Change_Time: Hier kannst du die Zeit einstellen die der Bildschirm brauch um
  35.                  sich umzufärben. (in Sekunden)
  36.                  
  37.     Farbton: Hier kannst du die Farbton werte der einzelnen Tageszeiten ändern.
  38.  
  39.     Time_Variable_ID1: Hier kannst du die Variablen ID verändern in der die
  40.                        momentane Zeit ausgegeben wird. (in Frames)
  41.                        Wenn du eine "0" einstellst wird diese Funktion
  42.                        deaktiviert.
  43.                      
  44.     Time_Variable_ID2: Hier kannst du die Variablen ID verändern in der die
  45.                        momentane Zeit ausgegeben wird. (in Stunden)
  46.                        Wenn du eine "0" einstellst wird diese Funktion
  47.                        deaktiviert.
  48.                        
  49.     Time_Variable_ID3: Hier kannst du die Variablen ID verändern in der die
  50.                        momentane Zeit ausgegeben wird. (in Minuten)
  51.                        Wenn du eine "0" einstellst wird diese Funktion
  52.                        deaktiviert.
  53.                        
  54.     DayCount_Variable: Hier kannst du die Variablen ID verändern in der die
  55.                        bereits vergangenen Tage gezählt werden.
  56.                        Wenn du eine "0" einstellst wird diese Funktion
  57.                        deaktiviert.
  58.    
  59.   Viel Spaß
  60.  
  61. =end
  62.  
  63. module TagNachtSystem
  64.   #=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
  65.   #  EDIT-Bereich
  66.   #=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
  67.  
  68.   Switch_ID = 10
  69.  
  70.   Tag_Nacht_Time = 0.2
  71.  
  72.   Change_Time = 5
  73.  
  74.   Farbton = [
  75.               [-128, -128, -64, 128], #Mitternacht        Index: 0
  76.               [-34, -34, 0, 68], #Mitternacht > Morgen    Index: 1
  77.               [-16, -64, -64, 32], #Morgen                Index: 2
  78.               [0, 0, 0, 0], #Morgen > Mittag              Index: 3
  79.               [34, 34, 0, 0], #Mittag                     Index: 4
  80.               [68, -34, -34, 0], #Mittag > Abend          Index: 5
  81.               [-68, -68, -68, 0], #Abend                  Index: 6
  82.               [-68, -68, 0, 68]  #Abend > Mitternacht     Index: 7
  83.             ]
  84.  
  85.   Time_Variable_ID1 = 10
  86.  
  87.   Time_Variable_ID2 = 11
  88.  
  89.   Time_Variable_ID3 = 12
  90.  
  91.   Time_Variable_ID4 = 13
  92.  
  93.   DayCount_Variable = 14
  94.  
  95.   #=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
  96.   #  END
  97.   #=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
  98. end
  99. #==============================================================================
  100. # ** DataManager
  101. #------------------------------------------------------------------------------
  102. #  This module manages the database and game objects. Almost all of the
  103. # global variables used by the game are initialized by this module.
  104. #==============================================================================
  105. module DataManager
  106.   class << self
  107.     alias taj_datamanager_creategameobjects_uzgv21   create_game_objects
  108.     #--------------------------------------------------------------------------
  109.     # * Create Game Objects
  110.     #--------------------------------------------------------------------------
  111.     def create_game_objects
  112.       taj_datamanager_creategameobjects_uzgv21
  113.       $game_system.daynightsystem    = Day_Night.new
  114.     end
  115.   end
  116. end
  117. #==============================================================================
  118. # ** Game_System
  119. #------------------------------------------------------------------------------
  120. #  This class handles system data. It saves the disable state of saving and
  121. # menus. Instances of this class are referenced by $game_system.
  122. #==============================================================================
  123.  
  124. class Game_System
  125.   #--------------------------------------------------------------------------
  126.   # * Public Instance Variables
  127.   #--------------------------------------------------------------------------
  128.   attr_accessor     :daynightsystem
  129. end
  130. #==============================================================================
  131. # ** Game_Map
  132. #------------------------------------------------------------------------------
  133. #  This class handles maps. It includes scrolling and passage determination
  134. # functions. The instance of this class is referenced by $game_map.
  135. #==============================================================================
  136.  
  137. class Game_Map
  138.   alias taj_gamemap_update_jkbdsf9   update
  139.   #--------------------------------------------------------------------------
  140.   # * Frame Update
  141.   #--------------------------------------------------------------------------
  142.   def update(main = false)
  143.     taj_gamemap_update_jkbdsf9(main)
  144.     $game_system.daynightsystem.update if $game_switches[TagNachtSystem::Switch_ID]
  145.   end
  146. end
  147. class Day_Night
  148.   #--------------------------------------------------------------------------
  149.   # * Object Initialization
  150.   #--------------------------------------------------------------------------
  151.   def initialize
  152.     t = Tone.new(TagNachtSystem::Farbton[0][0],TagNachtSystem::Farbton[0][1],TagNachtSystem::Farbton[0][2],TagNachtSystem::Farbton[0][3])
  153.     $game_map.screen.start_tone_change(t, 0)
  154.     t = nil
  155.     @timer_in_value = 0
  156.     @timer_in_hours = 0
  157.     @timer_in_minutes = 0
  158.     @timer_in_hours_temp = 0
  159.     @daycount = 0
  160.     a = TagNachtSystem::Tag_Nacht_Time*3600
  161.     b = TagNachtSystem::Tag_Nacht_Time*3600*0.25
  162.     c = TagNachtSystem::Tag_Nacht_Time*3600*0.5
  163.     @timersettings = [
  164.                       0, (b - a*0.02).round, c.round, (b + c + a*0.02).round,
  165.                       a.round, (a + b - a*0.02).round, (a + c).round,
  166.                       (a + b + c + a*0.02).round, (a * 2).round
  167.                       ]
  168.     p @timersettings
  169.   end
  170.   #--------------------------------------------------------------------------
  171.   # * Frame Update
  172.   #--------------------------------------------------------------------------
  173.   def update
  174.     testfortime()
  175.     @timer_in_value += 1
  176.     set_variables()
  177.   end
  178.   #--------------------------------------------------------------------------
  179.   # * Sets the Variables
  180.   #--------------------------------------------------------------------------
  181.   def set_variables()
  182.     $game_variables[TagNachtSystem::Time_Variable_ID1] = @timer_in_value if TagNachtSystem::Time_Variable_ID1 != 0
  183.     if TagNachtSystem::Time_Variable_ID2 != 0
  184.       max = (TagNachtSystem::Tag_Nacht_Time*3600*2).to_f
  185.       mom = @timer_in_value.to_f
  186.       x = (max/mom).to_f if mom != 0
  187.       @timer_in_hours_temp = 24/x
  188.       @timer_in_hours = (24/x).to_i if x != 0
  189.       $game_variables[TagNachtSystem::Time_Variable_ID2] = "%02d" % @timer_in_hours
  190.       x = 0
  191.     end
  192.     if TagNachtSystem::Time_Variable_ID3 != 0
  193.       h = @timer_in_hours_temp - @timer_in_hours_temp.to_i
  194.       h2 = (@timer_in_hours_temp+1).to_i - @timer_in_hours_temp.to_i
  195.       x = (60*h/h2).to_i
  196.       @timer_in_minutes = x
  197.       $game_variables[TagNachtSystem::Time_Variable_ID3] = "%02d" % @timer_in_minutes
  198.       x = 0
  199.     end
  200.     $game_variables[TagNachtSystem::Time_Variable_ID4] = get_time() if TagNachtSystem::Time_Variable_ID4 != 0
  201.   end
  202.   #--------------------------------------------------------------------------
  203.   # * Test for Time
  204.   #--------------------------------------------------------------------------
  205.   def testfortime()
  206.     case @timer_in_value
  207.       when @timersettings[0] then set_color(0)
  208.       when @timersettings[1] then set_color(1)
  209.       when @timersettings[2] then set_color(2)
  210.       when @timersettings[3] then set_color(3)
  211.       when @timersettings[4] then set_color(4)
  212.       when @timersettings[5] then set_color(5)
  213.       when @timersettings[6] then set_color(6)
  214.       when @timersettings[7] then set_color(7)
  215.     end
  216.     if @timer_in_value == @timersettings[8] #mitternacht
  217.       set_color(0)
  218.       @timer_in_value = 0
  219.       @daycount += 1
  220.       $game_varibales[TagNachtSystem::DayCount_Variable] = @daycount if TagNachtSystem::DayCount_Variable != 0
  221.     end
  222.   end
  223.   #--------------------------------------------------------------------------
  224.   # * Set Color
  225.   #--------------------------------------------------------------------------
  226.   def set_color(n)
  227.     t = Tone.new(TagNachtSystem::Farbton[n][0],TagNachtSystem::Farbton[n][1],TagNachtSystem::Farbton[n][2],TagNachtSystem::Farbton[n][3])
  228.     $game_map.screen.start_tone_change(t, TagNachtSystem::Change_Time*60)
  229.   end
  230.   #--------------------------------------------------------------------------
  231.   # * Set Tone
  232.   #--------------------------------------------------------------------------
  233.   def set_tone(t)
  234.     case t
  235.       when 0 then @timer_in_value = @timersettings[0]
  236.       when 1 then @timer_in_value = @timersettings[1]
  237.       when 2 then @timer_in_value = @timersettings[2]
  238.       when 3 then @timer_in_value = @timersettings[3]
  239.       when 4 then @timer_in_value = @timersettings[4]
  240.       when 5 then @timer_in_value = @timersettings[5]
  241.       when 6 then @timer_in_value = @timersettings[6]
  242.       when 7 then @timer_in_value = @timersettings[7]
  243.     end
  244.   end
  245.   #--------------------------------------------------------------------------
  246.   # * get Time
  247.   #--------------------------------------------------------------------------
  248.   def get_time()
  249.     @t = false
  250.     @timersettings.each_with_index do |x, i|
  251.       if @timer_in_value >= @timersettings[i]
  252.         @t = true
  253.       else
  254.         return i
  255.       end
  256.     end
  257.   end
  258. end