Advertisement
Syrus_Kyury

ZCN - Time & Daily Events

Dec 30th, 2018
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 16.74 KB | None | 0 0
  1. =begin
  2.  ==============================================================================
  3.  ________                         __                              
  4. /\_____  \                       /\ \      __                    
  5. \/____//'/'    ___     ___    ___\ \ \___ /\_\    ___      __    
  6.      //'/'    / __`\  /'___\ /'___\ \  _ `\/\ \ /' _ `\  /'__`\  
  7.     //'/'___ /\ \L\ \/\ \__//\ \__/\ \ \ \ \ \ \/\ \/\ \/\ \L\.\_
  8.     /\_______\ \____/\ \____\ \____\\ \_\ \_\ \_\ \_\ \_\ \__/.\_\
  9.     \/_______/\/___/  \/____/\/____/ \/_/\/_/\/_/\/_/\/_/\/__/\/_/
  10.                                                                  
  11.                                                                  
  12.                   ____                               __          
  13.                  /\  _`\                  __        /\ \__        
  14.                  \ \,\L\_\    ___   _ __ /\_\  _____\ \ ,_\      
  15.                   \/_\__ \   /'___\/\`'__\/\ \/\ '__`\ \ \/      
  16.                     /\ \L\ \/\ \__/\ \ \/ \ \ \ \ \L\ \ \ \_      
  17.                     \ `\____\ \____\\ \_\  \ \_\ \ ,__/\ \__\    
  18.                      \/_____/\/____/ \/_/   \/_/\ \ \/  \/__/    
  19.                                                  \ \_\            
  20.                                                   \/_/  
  21.  ==============================================================================
  22.   ■ Time & Daily Events by Zocchina
  23.  
  24.       Versione di RPG Maker : Vx Ace
  25.       Versione 1.2
  26.       Difficoltà : ★
  27.      
  28.       Questo script permette di implementare un calendario "reale" all'interno  
  29.       del proprio progetto, un po' come nei giochi dei pokemon.
  30.      
  31.       Esso implementa:
  32.      
  33.       ● Ciclo Giorno/Notte
  34.       ● Salvataggio dei dati relativi alla data corrente nelle variabili di
  35.         gioco
  36.       ● Possibilità di avviare script in determinate date in modo da creare
  37.         i vostri eventi personalizzati senza aver bisogno di un aggiornamento!
  38.       ● Sistema anti-imbroglioni
  39.      
  40.      
  41.  
  42.  ==============================================================================
  43.   ■ Terms of Use
  44.     When using any Zocchina script, you agree with the following terms:
  45.    
  46.       ●  You must give credit to Zocchina;    
  47.       ●  All Zocchina scripts are licensed under a Creative Commons license;
  48.       ● You can’t give credit to yourself for posting any Zocchina script;
  49.      
  50.  ==============================================================================
  51.   ■ Come usare lo script
  52.  
  53.       ●  Per installare questo script apri il tuo script editor ed incolla
  54.          questo codice sotto ▼ Materials/素材 ma sopra ▼ Main.
  55.          Ricorda di salvare!
  56.      
  57.       ●  Configura lo script come preferisci seguendo le istruzioni qui
  58.          in basso
  59.          
  60.       ●  Comandi:
  61.      
  62.         * Per forzare l'esecuzione di uno script dell'evento giornaliero usa
  63.             => ZCN_RT::custom_event
  64.            
  65.  ==============================================================================
  66. =end
  67.  
  68. module ZCN_RT
  69. #==============================================================================
  70. # * Vuoi che i dati relativi al giorno, mese ed anno correnti vengano
  71. #   memorizzati in delle variabili di gioco?
  72. #  
  73. #   ● Se si, inserisci l'id della variabile in cui venga memorizzato il dato
  74. #   ● Se no, scrivi 0
  75. #==============================================================================
  76.   DAY_VAR = 1
  77.   MONTH_VAR = 2
  78.   YEAR_VAR = 3
  79.   HOUR_VAR = 4
  80.   MIN_VAR = 5
  81. #==============================================================================
  82. # * Stesso concetto della configurazione precedente.
  83. #   NB La variabile assumenrà solo i seguenti valori a seconda della stagione.
  84. #
  85. #  1 => Inverno, 2 => Primavera, 3 => Estate, 4 => Autunno
  86. #
  87. #==============================================================================
  88.   SEASON_VAR = 6
  89. #==============================================================================
  90. # * Vuoi attivare il ciclo Giorno/Notte?
  91. #==============================================================================
  92.   DAY_NIGHT = true
  93. #==============================================================================
  94. # * Per disattivare il ciclo Giorno/Notte in relative mappe, scrivi nei commenti
  95. #   del tileset che hai utilizzato per mappare il seguente codice:
  96. #
  97. #                                  <Interno>
  98. #
  99. #==============================================================================
  100.  
  101. #==============================================================================
  102. # * A seconda dell'orario lo schermo assumerà diverse colorazioni,
  103. #   qui sotto puoi personalizzarle.
  104. #
  105. #   Tra le parentesi del costruttore devi inserire :
  106. #
  107. #   Tone.new(ROSSO,VERDE,BLU,GRIGIO)
  108. #
  109. #   Puoi fare delle prove con gli eventi che mette a disposizione RPG Maker
  110. #==============================================================================
  111.   DEEP_NIGHT_TONE = Tone.new(-136,-136,0,85)
  112.   PRESUNRISE_TONE = Tone.new(-68,-68,-20,76)
  113.   SUNRISE_TONE    = Tone.new(-34,-34,17,0)
  114.   NOONSTART_TONE  = Tone.new(0,0,0,0)
  115.   NOONEND_TONE    = Tone.new(8,8,0,0)
  116.   PRESUNSET_TONE  = Tone.new(15,8,0,0)
  117.   SUNSET_TONE     = Tone.new(17,-17,-34,0)
  118.   TWILIGHT_TONE   = Tone.new(-17,-68,17,0)
  119.   MIDNIGHT_TONE   = Tone.new(-68,-68,0,68)
  120. #==============================================================================
  121. # * A che ora inizia una determinata fase del giorno?
  122. #==============================================================================
  123.   DEEP_NIGHT      = 0
  124.   PRESUNRISE_TIME = 4
  125.   SUNRISE_TIME    = 7
  126.   NOONSTART_TIME  = 10
  127.   NOONEND_TIME    = 13
  128.   PRESUNSET_TIME  = 15
  129.   SUNSET_TIME     = 17
  130.   TWILIGHT_TIME   = 19
  131.   NIGHT_TIME      = 21
  132. #==============================================================================
  133. # * In quanti secondi lo schermo deve cambiare colore quando si passa da una
  134. #   fase all'altra del giorno?
  135. #==============================================================================
  136.   ZCN_CHANGE_TIME = 1
  137. #==============================================================================
  138. # * Vuoi attivare gli eventi personalizzati?
  139. #==============================================================================
  140.   CUSTOM_EVENTS = true
  141. #==============================================================================
  142. # * Configurazione eventi personalizzati
  143. #==============================================================================  
  144.   $events_datas = {
  145. #==============================================================================
  146. # L'evento attiverà lo switch scelto nei giorni compresi tra le date dell'evento
  147. # Per configurare una data segui il seguente schema:
  148. # Time.local(ANNO,MESE,GIORNO)
  149. #
  150. # Se vuoi che l'evento venga ripetuto ogni anno setta true, altrimenti setta
  151. # false nell'ultima opzione del vettore sottostante.
  152. #
  153. # NB : Per gli eventi che si ripetono setta la data di inizio nell'anno 0
  154. #      e la fine nell'anno 0(oppure 1 se l'inizio e la fine non sono nello
  155. #      stesso anno)
  156. #=============================================================================
  157. # ID       INIZIO EVENTO           FINE EVENTO       SWITCH    RIPETI OGNI ANNO
  158. #==============================================================================
  159.   1 => [Time.local(0,12,30),     Time.local(1,2,1) ,    4            ,true],
  160.   2 => [Time.local(2012,12,30),  Time.local(2013,2,1) , 2            ,false],
  161.   3 => [Time.local(2012,12,30),  Time.local(2013,2,1) , 3            ,true]}
  162.  
  163.  
  164. #==============================================================================
  165. # Vuoi che il salvatggio venga corrotto nel caso il giocatore inizi ad
  166. # imbrogliare modificando data e ora?
  167. #
  168. # Il sistema funziona quando si carica il gioco in una data antecedente
  169. # alla data del salvataggio.
  170. #
  171. # Durante il debug(quando avvii il gioco da RPG maker) il sistema è disattivato
  172. # in modo da facilitare i test.
  173. #==============================================================================
  174.  
  175.   ANTI_CHEAT   = true
  176.  
  177. #==============================================================================
  178. # Che messaggio vuoi che compaia nel msgbox di errore?
  179. #==============================================================================
  180.  
  181.   MESSAGE = "Dati danneggiati"
  182.  
  183. =begin
  184. #==============================================================================#
  185. # If you don't wanna cry, don't edit anything after this point                 #
  186. #==============================================================================#
  187.        
  188.                              .ed"""" """$$$$be.
  189.                            -"           ^""**$$$e.
  190.                          ."                   '$$$c
  191.                         /                      "4$$b
  192.                        d  3                      $$$$
  193.                        $  *                   .$$$$$$
  194.                       .$  ^c           $$$$$e$$$$$$$$.
  195.                       d$L  4.         4$$$$$$$$$$$$$$b
  196.                       $$$$b ^ceeeee.  4$$ECL.F*$$$$$$$
  197.           e$""=.      $$$$P d$$$$F $ $$$$$$$$$- $$$$$$
  198.          z$$b. ^c     3$$$F "$$$$b   $"$$$$$$$  $$$$*"      .=""$c
  199.         4$$$$L        $$P"  "$$b   .$ $$$$$...e$$        .=  e$$$.
  200.         ^*$$$$$c  %..   *c    ..    $$ 3$$$$$$$$$$eF     zP  d$$$$$
  201.           "**$$$ec   "   %ce""    $$$  $$$$$$$$$$*    .r" =$$$$P""
  202.                 "*$b.  "c  *$e.    *** d$$$$$"L$$    .d"  e$$***"
  203.                   ^*$$c ^$c $$$      4J$$$$$% $$$ .e*".eeP"
  204.                      "$$$$$$"'$=e....$*$$**$cz$$" "..d$*"
  205.                        "*$$$  *=%4.$ L L$ P3$$$F $$$P"
  206.                           "$   "%*ebJLzb$e$$$$$b $P"
  207.                             %..      4$$$$$$$$$$ "
  208.                              $$$e   z$$$$$$$$$$%
  209.                               "*$c  "$$$$$$$P"
  210.                                ."""*$$$$$$$$bc
  211.                             .-"    .$***$$$"""*e.
  212.                          .-"    .e$"     "*$c  ^*b.
  213.                   .=*""""    .e$*"          "*bc  "*$e..
  214.                 .$"        .z*"               ^*$e.   "*****e.
  215.                 $$ee$c   .d"                     "*$.        3.
  216.                 ^*$E")$..$"                         *   .ee==d%
  217.                    $.d$$$*                           *  J$$$e*
  218.                     """""                              "$$$"
  219. #==============================================================================#
  220. # If you don't wanna cry, don't edit anything after this point                 #
  221. #==============================================================================#
  222. =end
  223.  
  224. #--------------------------------------------------------------------------
  225. # * Ciao scripter che sta leggendo il codice per capire come funziona!
  226. #   Se hai qualche idea su come migliorare lo script scrivimi
  227. #--------------------------------------------------------------------------
  228.  
  229.  
  230. #--------------------------------------------------------------------------
  231. # * Cambia colore dello schermo
  232. #--------------------------------------------------------------------------
  233.  
  234. def self.changetone
  235.  
  236.   if SceneManager::scene_is?(Scene_Map) then else return end
  237.   if DAY_NIGHT == true then else return end
  238.  
  239.   #Cambia il tono in base all'intervallo
  240.   case Time.now.hour
  241.     when DEEP_NIGHT..PRESUNRISE_TIME-1
  242.       $game_map.screen.start_tone_change(DEEP_NIGHT_TONE, 60*ZCN_CHANGE_TIME)
  243.      
  244.     when PRESUNRISE_TIME..SUNRISE_TIME-1
  245.       $game_map.screen.start_tone_change(PRESUNRISE_TONE, 60*ZCN_CHANGE_TIME)
  246.      
  247.     when SUNRISE_TIME..NOONSTART_TIME-1
  248.       $game_map.screen.start_tone_change(SUNRISE_TONE, 60*ZCN_CHANGE_TIME)
  249.      
  250.     when NOONSTART_TIME..NOONEND_TIME-1
  251.       $game_map.screen.start_tone_change(NOONSTART_TONE, 60*ZCN_CHANGE_TIME)
  252.      
  253.     when NOONEND_TIME..PRESUNSET_TIME-1
  254.       $game_map.screen.start_tone_change(NOONEND_TONE, 60*ZCN_CHANGE_TIME)
  255.      
  256.     when PRESUNSET_TIME..SUNSET_TIME-1  
  257.       $game_map.screen.start_tone_change(PRESUNSET_TONE, 60*ZCN_CHANGE_TIME)
  258.      
  259.     when SUNSET_TIME..TWILIGHT_TIME-1
  260.       $game_map.screen.start_tone_change(SUNSET_TONE, 60*ZCN_CHANGE_TIME)
  261.      
  262.     when TWILIGHT_TIME..NIGHT_TIME-1
  263.       $game_map.screen.start_tone_change(TWILIGHT_TONE, 60*ZCN_CHANGE_TIME)
  264.    
  265.     when NIGHT_TIME..24
  266.       $game_map.screen.start_tone_change(MIDNIGHT_TONE, 60*ZCN_CHANGE_TIME)
  267.     end
  268.      
  269.   end# Chiudo change tone
  270.  
  271. #--------------------------------------------------------------------------
  272. # * Calcola stagione
  273. #--------------------------------------------------------------------------
  274.  
  275.   def self.season_calc
  276.     orario = Time.now
  277.    
  278.     case orario.month
  279.       when 1..2
  280.         $game_variables[SEASON_VAR] = 1
  281.  
  282.       when 3..5
  283.         if orario.month == 3 && orario.day < 21
  284.           $game_variables[SEASON_VAR] = 1
  285.         else
  286.         $game_variables[SEASON_VAR] = 2
  287.       end
  288.  
  289.       when 6..8
  290.         if orario.month == 6 && orario.day < 21
  291.           $game_variables[SEASON_VAR] = 2
  292.         else
  293.         $game_variables[SEASON_VAR] = 4
  294.       end
  295.  
  296.       when 9..12
  297.       if orario.month == 9 && orario.day < 21
  298.           $game_variables[SEASON_VAR] = 4
  299.         else
  300.         $game_variables[SEASON_VAR] = 1
  301.       end
  302.     end
  303.   end
  304.  
  305. #--------------------------------------------------------------------------
  306. # * Calcola game variables
  307. #--------------------------------------------------------------------------
  308.  
  309.   def self.ass_game_var
  310.     orario = Time.now
  311.     $game_variables[DAY_VAR] = orario.day
  312.     $game_variables[MONTH_VAR] = orario.month
  313.     $game_variables[YEAR_VAR] = orario.year
  314.     $game_variables[HOUR_VAR] = orario.hour
  315.     $game_variables[MIN_VAR] = orario.min
  316.   end
  317.  
  318. #--------------------------------------------------------------------------
  319. # * Attiva gli eventi personalizzati
  320. #--------------------------------------------------------------------------
  321.  
  322.  def self.custom_event
  323.     for c in 1..$events_datas.size
  324.       if($events_datas[c][3]==true)
  325.         repeat(c)
  326.         else if(Time.now>=$events_datas[c][0] && Time.now<= $events_datas[c][1])
  327.           $game_switches[$events_datas[c][2]] = true    
  328.         else
  329.          $game_switches[$events_datas[c][2]] = false
  330.        end
  331.      end
  332.    end
  333.  end
  334.  
  335.  
  336.  
  337.   def self.repeat(c)
  338.     if($events_datas[c][0].year==$events_datas[c][1].year) #Se gli anni rilevati sono uguali allora li pone = 0
  339.        $events_datas[c][0] = Time.local(0,$events_datas[c][0].month,$events_datas[c][0].day)
  340.        $events_datas[c][1] = Time.local(0,$events_datas[c][1].month,$events_datas[c][1].day)
  341.      else #Altrimenti il primo = 0 e il secondo = 1
  342.       $events_datas[c][0] = Time.local(0,$events_datas[c][0].month,$events_datas[c][0].day)
  343.       $events_datas[c][1] = Time.local(1,$events_datas[c][1].month,$events_datas[c][1].day)
  344.     end
  345.     for d in 0..1
  346.     now=Time.local(d,Time.now.month,Time.now.day)
  347.     #Controllo se la data odierna (Senza considerare gli anni è compresa nella data dell'evento)
  348.     if (now>=$events_datas[c][0] && now<= $events_datas[c][1])
  349.       $game_switches[$events_datas[c][2]] = true
  350.       return
  351.     else
  352.       $game_switches[$events_datas[c][2]] = false
  353.     end
  354.   end
  355. end
  356.  
  357.    
  358. #--------------------------------------------------------------------------
  359. # * Metodo che si attiva quando i dati di gioco sono corrotti
  360. #--------------------------------------------------------------------------
  361.  
  362.   def self.anti_cheat
  363.     Audio.se_play("Audio/SE/Buzzer1.ogg", 100, 100)
  364.     msgbox(MESSAGE)
  365.     SceneManager.goto(Scene_Title)
  366.   end
  367.  
  368. end #Chiudo il modulo
  369.  
  370. #--------------------------------------------------------------------------
  371. # Modifica delle Scene
  372. #--------------------------------------------------------------------------
  373.  
  374. class Scene_Map < Scene_Base
  375.   alias zcn_update_map update
  376.   def update
  377.     zcn_update_map
  378.     ZCN_RT::season_calc
  379.     unless $game_map.tileset.note =~ /<Interno>/
  380.       ZCN_RT::changetone
  381.       ZCN_RT::ass_game_var
  382.     else
  383.       $game_map.screen.start_tone_change(Tone.new(0,0,0,0),0)
  384.    end
  385.  end
  386. end
  387.  
  388. #--------------------------------------------------------------------------
  389. # Sistema Anitcheat
  390. #--------------------------------------------------------------------------
  391.  
  392. class Scene_Load < Scene_File
  393.  
  394.   alias zcn_loadevent on_load_success
  395.  
  396.     def on_load_success
  397.       zcn_loadevent
  398.       ZCN_RT::custom_event
  399.         if(Time.now<$game_variables[5001])
  400.           if(ZCN_RT::ANTI_CHEAT==true && $TEST == false) then ZCN_RT::anti_cheat end
  401.         end
  402.       end
  403.     end
  404.  
  405.  
  406. module DataManager
  407.  
  408.   def self.save_game_without_rescue(index)
  409.       $game_variables[5001]=Time.now
  410.       File.open(make_filename(index), "wb") do |file|
  411.       $game_system.on_before_save
  412.       Marshal.dump(make_save_header, file)
  413.       Marshal.dump(make_save_contents, file)
  414.       @last_savefile_index = index
  415.     end
  416.     return true
  417.   end
  418. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement