Neko Fondateur
Messages : 184 Date d'inscription : 14/07/2013 Age : 25 Localisation : Ici, la plupart du temps.
| Sujet: ( RMVXace ) ~ Calendrier sur la map Mer 24 Juil - 16:02 | |
| Auetur :Reika Neige BlancheBooster votre jeu avec ce script qui va vous permettre d'afficher un calendrier sur la map mais euh non je me perds, enfin vous verrai sur le screen Screen : Voilà la bête . Instructions traduites par Shin. - Code:
-
=begin ======================================================================= ☆ ajout de la fonction calendrier par 白雪レイカ (reika neige blanche) ☆ traduction et légère modification par zibroph (Le Palais Du Making => shin) ------------------------------------------------------------------------------- ajout du temps pendant le jeu. Les musique (BGM) ainssi que la teinte de l'ecrant change en fonction de l'heure de la journer et de la meteo. La méteo change de facons aleatoire et en fonction de la saisons. L'ensemble des principles donnée sont enregistré dans des variable. vous pouvez donc les utiliser dans des event. -------------------------------------------------------------------------------
◆manuel présentation de certain réglage de base.
Fuseau horaire
3:00 ~ 5:59 => tôt le matin (:early_morning) 6:00 ~ 10:59 => matin (:morning) 11:00 ~ 15:59 => jour (:noon) 16:00 ~ 18:59 => soirée (:evening) 19:00 ~ 22:59 => nuit (:night) 23:00 ~ 2:59 => minuit (:midnight)
est devenue (j'ai pas compris la trad me parait bisard ^^)
changement de BGM en fonction du fuseau horaire ne marche que lorsque la case "BGM natif" est coché mettre ce qui suit dans la parti commentaire de la map
(j'ai galéré a trouver ça avec le traducteur tout les mots sont melanger et pareil por la ponctuation)
on peut aussi remplacer early par : morning, noon, evening, night, mid; en fonction du moment de la journer ou las musique doit etre joué (on peut mettre 6 musique par map c'est trop puissant ^^) il n'est pas nécessaire de mettre l'extention du BGM
○ réglage avec évent à utiliser avec la commande script
set_time(hour, min) # régler les heures et les minutes
set_date(month, date, day) # régle la date (mois,jour) et le jour (samedi, dimanche ...) # le jour est difinie par :
# dimanche => :Sun lundi => :Mon mardi => :Tue # mercredi => :Wed jeudi => :Thr vendredi => :Fri # samedi => :Sat
set_year(year) # permet de régler l'année。
shift_date(date) # pérmet d'avancer d'un ou plusieur jour en fonction de ce qu'on a mis entre parenthèse。
shift_month(month) # pareil que ci-dessus mais pour les mois
shift_year(year) # pareil que ci-dessus mais pour les années
shift_date_to(month, date[, year]) # avance jusqu'à la date spécifiée # si vous ne mettez pas l'année ça restera à l'année en cours. # vous pouvez spécifié une date anterieur
set_weather(weather) # modifier la météo # la méteo est définie par :
# ensolellé => :fine pluis => :rain neige => :snow # tonnerre => :thunder tempette => :storm nuageux (nuit) => :star (pas compris a quoi il sert il mets juste l'icon de nuit) # blizzard => :s_storm
=end #============================================================================== # ■ paramètres #============================================================================== module WhiteSnow
# ↓↓réglage initial↓↓
INITAL_MIN = 50 # minutes en debut de jeu
INITAL_HOUR = 2 # heure en debut de jeu
INITAL_DATE = 9 # jour en debut de jeu
INITAL_DAY = :Sun # jour en debut de jeu
INITAL_MONTH = 9 # mois en debut de jeu
INITAL_YEAR = 2000 # année en debut de jeu
# ↑↑fin reglage initial↑↑
TIME_COUNT_FORBID_SID = 10 # id de l'interupteur permettant d'arreter le temps
TONE_CHANGE_FORBID_SID = 11 # id de l'interupteur permettant d'empecher le changement de couleur de l'ecran (utile pour les maisons)
WEATHER_EFFECT_FORBID_SID = 12 # id de l'interupteur permettant d'empecher la météo (utile pour les maisons)
CALENDER_WINDOW_HIDE_SID = 13 #id de l'interupteur permettant d'enlever la fenetre du calendrier #le temps continue de défiler quand elle est pas affiché
INSIDE_FLAG_SID = 14 # id de l'interupteur permetant d'empecher la teinte de l'écran # permet de mettre le drapeux a l'interieur(pas trop compris(je croit qu'il permet d'activer le INSIDE_BGS_TYPE))
WEATHER_BGS_ENABLE = true # true = activer les bruitage météo # false = désactive bruitage météo
INSIDE_BGS_TYPE = 1 # 0 = désctive les bruitage météo # 1 = réduit le volume des BGS à 60% # 2 = bruitage météo à 100%
WEATHER_BGS_DISABLE = 15 # id de l'interupteur permettant de désactiver le temps, la météo, et les BGS. # il est indiqué qu'il sert surtout pour de court moment perso j'ai pas trop trouvée d'utiliter (peut-être au moment de rentrer dans un batiment)
MIN_STORE_VID = 101 # id variable contenant les minutes
HOUR_STORE_VID = 102 # id variable contenant les heurs
TIME_ZONE_STORE_VID = 103 # id variable des "time zone" # 0 tot le matin 1 matin 2 midi 3 soir 4 nuit 5 minuit
DATE_STORE_VID = 104 # id variable contenant le jour
DAY_STORE_VID = 105 # id variable contenant le jour # 0 dimanche 1 lundi 2 mardi 3 mercredi 4 jeudi 5 vendredi 6 samedi
MONTH_STORE_VID = 106 # id variable contenant le mois
SEASON_STORE_VID = 107 # id variable contenant la saison # 0 printemps 1 été 2 autumne 3 hiver
WEATHER_STORE_VID = 108 # id variable contenant la météo # 0 soleil 1 pluie 2 neige 3 tonnerre 4 tempete 5 nuageux 6 blizzard
YEAR_STORE_VID = 109 # id variable contenant l'année
EARLY_MORNING_SCREEN_TONE = [15, 10, 0, 0] # couleur ecrant tot le matin # R, G, B, obscurité
MORNING_SCREEN_TONE = [0, 0, 0, 0] # couleur ecrant le matin # R, G, B, obscurité
NOON_SCREEN_TONE = [15, 15, 15, 0] # couleur ecrant le midi # R, G, B, obscuriter
AFTERNOON_SCREEN_TONE = [32, -8, -32, 16] # couleur ecrant soir # R, G, B, obscuriter
NIGHT_SCREEN_TONE = [-64, -64, -16, 32] # couleur ecrant nuit # R, G, B, obscuriter
MIDNIGHT_SCREEN_TONE = [-72, -72, -20, 48] # couleur ecrant minuit # R, G, B, obscuriter
DAYS_TABLE = {0 => 31, 1 => 31, 2 => 28, 3 => 31, 4 => 30, 5 => 31, 6 => 30, 7 => 31, 8 => 31, 9 => 30, 10 => 31, 11 => 30, 12 => 31} # tableau nombre de jours par mois (je ne sais pas pourquois il a mis un mois 0 il ne l'utilise pas dans le script)
# liste condition météo
# exemple config # WEATHER = {:icon => n° dans l'iconset # :weather => [effet, force]}, # :bgs => ["nom_BGS", volume, vitesse](si la vitesse n'est pas spécifier elle sera normale), # # effet météo :none = rien :rain = pluie # :storm = tempete :snow = neige
FINE = {:icon => 1, :weather => [:none, 0], :bgs => nil} # beau temps
RAIN = {:icon => 2, :weather => [:rain, 5], :bgs => ["Rain", 50, 90]} # pluie
SNOW = {:icon => 3, :weather => [:snow, 4], :bgs => nil} # neige
THUNDER = {:icon => 4, :weather => [:storm, 4], :bgs => ["Storm", 60, 75],
:flash => [255, 255, 200, 180, 12], :se => ["Thunder9", 80, 95]} # tonnerre # réglage effet tonnerre # :flash => [(couleur)R, G, B, Alpha, longuer du flash] # :se => BGS qui suit le flash se config comme les autres BGS
STORM = {:icon => 5, :weather => [:storm, 8], :bgs => ["Storm", 70, 100]} # tempette
STAR = {:icon => 6, :weather => [:none, 0], :bgs => nil} # nuageux (nuit)
S_STORM = {:icon => 7, :weather => [:snow, 9], :bgs => ["Wind", 70, 95]} # blizzard end
#============================================================================== # ■ Calender #------------------------------------------------------------------------------ # class du calendrier #==============================================================================
class Calender #-------------------------------------------------------------------------- # ● instance public #-------------------------------------------------------------------------- attr_accessor :count attr_accessor :min attr_accessor :hour attr_accessor :date attr_accessor :day attr_accessor :month attr_accessor :season attr_accessor :year attr_accessor :weather attr_accessor :weather_count attr_accessor :time_zone attr_reader :interpreter attr_accessor :thunder_count #-------------------------------------------------------------------------- # ● initialisation objet #-------------------------------------------------------------------------- def initialize @count = 0 @weather = :fine @interpreter = Game_Interpreter.new init_calender change_weather end #-------------------------------------------------------------------------- # ● initialisation calendrier #-------------------------------------------------------------------------- def init_calender @min = WhiteSnow::INITAL_MIN @hour = WhiteSnow::INITAL_HOUR @date = WhiteSnow::INITAL_DATE @day = WhiteSnow::INITAL_DAY @month = WhiteSnow::INITAL_MONTH @year = WhiteSnow::INITAL_YEAR get_time_zone
$game_variables[WhiteSnow::MIN_STORE_VID] = @min $game_variables[WhiteSnow::HOUR_STORE_VID] = @hour $game_variables[WhiteSnow::DATE_STORE_VID] = @date
case @month when 1..2 @season = :Winter $game_variables[WhiteSnow::SEASON_STORE_VID] = 3 when 3..5 @season = :Spring $game_variables[WhiteSnow::SEASON_STORE_VID] = 0 when 6..8 @season = :Summer $game_variables[WhiteSnow::SEASON_STORE_VID] = 1 when 9..11 @season = :Autumn $game_variables[WhiteSnow::SEASON_STORE_VID] = 2 when 12 @season = :Winter $game_variables[WhiteSnow::SEASON_STORE_VID] = 3 end
case @day when :Sun $game_variables[WhiteSnow::DAY_STORE_VID] = 0 when :Mon $game_variables[WhiteSnow::DAY_STORE_VID] = 1 when :Tue $game_variables[WhiteSnow::DAY_STORE_VID] = 2 when :Wed $game_variables[WhiteSnow::DAY_STORE_VID] = 3 when :Thr $game_variables[WhiteSnow::DAY_STORE_VID] = 4 when :Fri $game_variables[WhiteSnow::DAY_STORE_VID] = 5 when :Sat $game_variables[WhiteSnow::DAY_STORE_VID] = 6 end $game_variables[WhiteSnow::MONTH_STORE_VID] = @month $game_variables[WhiteSnow::YEAR_STORE_VID] = @year change_tone_by_calender end #-------------------------------------------------------------------------- # ● fuseau horaire #-------------------------------------------------------------------------- def get_time_zone case @hour when 0..2 @time_zone = :midnight $game_variables[WhiteSnow::TIME_ZONE_STORE_VID] = 5 when 3..5 @time_zone = :early_morning $game_variables[WhiteSnow::TIME_ZONE_STORE_VID] = 0 when 6..10 @time_zone = :morning $game_variables[WhiteSnow::TIME_ZONE_STORE_VID] = 1 when 11..15 @time_zone = :noon $game_variables[WhiteSnow::TIME_ZONE_STORE_VID] = 2 when 16..18 @time_zone = :evening $game_variables[WhiteSnow::TIME_ZONE_STORE_VID] = 3 when 19..22 @time_zone = :night $game_variables[WhiteSnow::TIME_ZONE_STORE_VID] = 4 when 23..24 @time_zone = :midnight $game_variables[WhiteSnow::TIME_ZONE_STORE_VID] = 5 end end #-------------------------------------------------------------------------- # ● aleatoire de la météo #-------------------------------------------------------------------------- def randomize_weather_count @weather_count = p_ex_rand(40, 100) + (109 - p_ex_rand(40, 110)) + 90 end #-------------------------------------------------------------------------- # ● changement de la couleur de l'écrant #-------------------------------------------------------------------------- def change_tone_by_calender(dur = 60) return if $game_switches[WhiteSnow::TONE_CHANGE_FORBID_SID] return if $game_switches[WhiteSnow::INSIDE_FLAG_SID] case @time_zone when :early_morning tone = WhiteSnow::EARLY_MORNING_SCREEN_TONE @interpreter.change_tone(tone[0], tone[1], tone[2], tone[3], dur) when :morning tone = WhiteSnow::MORNING_SCREEN_TONE @interpreter.change_tone(tone[0], tone[1], tone[2], tone[3], dur) when :noon tone = WhiteSnow::NOON_SCREEN_TONE @interpreter.change_tone(tone[0], tone[1], tone[2], tone[3], dur) when :evening tone = WhiteSnow::AFTERNOON_SCREEN_TONE @interpreter.change_tone(tone[0], tone[1], tone[2], tone[3], dur) when :night tone = WhiteSnow::NIGHT_SCREEN_TONE @interpreter.change_tone(tone[0], tone[1], tone[2], tone[3], dur) when :midnight tone = WhiteSnow::MIDNIGHT_SCREEN_TONE @interpreter.change_tone(tone[0], tone[1], tone[2], tone[3], dur) end end #-------------------------------------------------------------------------- # ● changement condition météo #-------------------------------------------------------------------------- def change_weather srand p_weather = @weather case @month when 1 case rand when 0...0.2 if @hour >= 3 and @hour < 18 @weather = :fine else @weather = :star end when 0.2...0.8 @weather = :snow when 0.8...1 @weather = :s_storm end when 2 case rand when 0...0.3 if @hour >= 3 and @hour < 18 @weather = :fine else @weather = :star end when 0.3...0.8 @weather = :snow when 0.8...0.9 @weather = :rain when 0.9...1 @weather = :s_storm end when 3..4 case rand when 0...0.8 if @hour >= 3 and @hour < 18 @weather = :fine else @weather = :star end when 0.8...0.9 @weather = :rain when 0.9...1 @weather = :storm end when 5 case rand when 0...0.7 if @hour >= 3 and @hour < 18 @weather = :fine else @weather = :star end when 0.7...0.8 @weather = :rain when 0.8...0.9 @weather = :thunder when 0.9...1 @weather = :storm end when 6 case rand when 0...0.4 if @hour >= 3 and @hour < 18 @weather = :fine else @weather = :star end when 0.4...0.8 @weather = :rain when 0.8...0.9 @weather = :thunder when 0.9...1 @weather = :storm end when 7..8 case rand when 0...0.6 if @hour >= 3 and @hour < 18 @weather = :fine else @weather = :star end when 0.6...0.7 @weather = :rain when 0.7...0.9 @weather = :storm when 0.9...1 @weather = :thunder end when 9..10 case rand when 0...0.6 if @hour >= 3 and @hour < 18 @weather = :fine else @weather = :star end when 0.6...0.8 @weather = :storm when 0.8...0.9 @weather = :rain when 0.9...1 @weather = :thunder end when 11 if @date < 25 case rand when 0...0.7 if @hour >= 3 and @hour < 18 @weather = :fine else @weather = :star end when 0.7...0.8 @weather = :storm when 0.8...0.9 @weather = :rain when 0.9...1 @weather = :thunder end else case rand when 0...0.6 if @hour >= 3 and @hour < 18 @weather = :fine else @weather = :star end when 0.6...0.7 @weather = :storm when 0.7...0.8 @weather = :rain when 0.8...0.9 @weather = :thunder when 0.9...1 @weather = :snow end end when 12 case rand when 0...0.2 if @hour >= 3 and @hour < 18 @weather = :fine else @weather = :star end when 0.2...0.8 @weather = :snow when 0.8...1 @weather = :s_storm end end if @weather != p_weather RPG::BGS.fade(10) perform_weather_effect end randomize_weather_count end #-------------------------------------------------------------------------- # ● effet météo #-------------------------------------------------------------------------- def perform_weather_effect(dur = 30) return unless SceneManager.scene_is?(Scene_Map) return if $game_switches[WhiteSnow::WEATHER_EFFECT_FORBID_SID] return if $game_switches[WhiteSnow::INSIDE_FLAG_SID] case @weather when :fine weather = WhiteSnow::FINE @interpreter.change_weather(weather[:weather][0], weather[:weather][1], dur) if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE] bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1], weather[:bgs][2]) bgs.play end $game_variables[WhiteSnow::WEATHER_STORE_VID] = 0
when :rain weather = WhiteSnow::RAIN @interpreter.change_weather(weather[:weather][0], weather[:weather][1], dur) if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE] bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1], weather[:bgs][2]) bgs.play end $game_variables[WhiteSnow::WEATHER_STORE_VID] = 1
when :snow weather = WhiteSnow::SNOW @interpreter.change_weather(weather[:weather][0], weather[:weather][1], dur) if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE] bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1], weather[:bgs][2]) bgs.play end $game_variables[WhiteSnow::WEATHER_STORE_VID] = 2
when :thunder weather = WhiteSnow::THUNDER @interpreter.change_weather(weather[:weather][0], weather[:weather][1], dur) if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE] bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1], weather[:bgs][2]) bgs.play end $game_variables[WhiteSnow::WEATHER_STORE_VID] = 3
when :storm weather = WhiteSnow::STORM @interpreter.change_weather(weather[:weather][0], weather[:weather][1], dur) if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE] bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1], weather[:bgs][2]) bgs.play end $game_variables[WhiteSnow::WEATHER_STORE_VID] = 4
when :star weather = WhiteSnow::STAR @interpreter.change_weather(weather[:weather][0], weather[:weather][1], dur) if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE] bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1], weather[:bgs][2]) bgs.play end $game_variables[WhiteSnow::WEATHER_STORE_VID] = 5
when :s_storm weather = WhiteSnow::S_STORM @interpreter.change_weather(weather[:weather][0], weather[:weather][1], dur) if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE] bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1], weather[:bgs][2]) bgs.play end $game_variables[WhiteSnow::WEATHER_STORE_VID] = 6 end end #-------------------------------------------------------------------------- # ● éxecution BGS interieur #-------------------------------------------------------------------------- def play_inside_bgs case @weather when :fine weather = WhiteSnow::FINE if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE] bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1] * 0.6, weather[:bgs][2]) bgs.play end
when :rain weather = WhiteSnow::RAIN if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE] bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1] * 0.7, weather[:bgs][2]) bgs.play end
when :snow weather = WhiteSnow::SNOW if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE] bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1] * 0.7, weather[:bgs][2]) bgs.play end
when :thunder weather = WhiteSnow::THUNDER if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE] bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1] * 0.7, weather[:bgs][2]) bgs.play end
when :storm weather = WhiteSnow::STORM if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE] bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1] * 0.7, weather[:bgs][2]) bgs.play end
when :star weather = WhiteSnow::STAR if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE] bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1] * 0.7, weather[:bgs][2]) bgs.play end
when :s_storm weather = WhiteSnow::S_STORM if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE] bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1] * 0.7, weather[:bgs][2]) bgs.play end end end #-------------------------------------------------------------------------- # ● effet tonnerre #-------------------------------------------------------------------------- def perform_thunder_effect(r, g, b, alpha, dur) @interpreter.perform_flash(r, g, b, alpha, dur) end #-------------------------------------------------------------------------- # ● MAJ jour de la semaine #-------------------------------------------------------------------------- def shift_day case @day when :Sun @day = :Mon $game_variables[WhiteSnow::DAY_STORE_VID] = 1 when :Mon @day = :Tue $game_variables[WhiteSnow::DAY_STORE_VID] = 2 when :Tue @day = :Wed $game_variables[WhiteSnow::DAY_STORE_VID] = 3 when :Wed @day = :Thr $game_variables[WhiteSnow::DAY_STORE_VID] = 4 when :Thr @day = :Fri $game_variables[WhiteSnow::DAY_STORE_VID] = 5 when :Fri @day = :Sat $game_variables[WhiteSnow::DAY_STORE_VID] = 6 when :Sat @day = :Sun $game_variables[WhiteSnow::DAY_STORE_VID] = 0 end end #-------------------------------------------------------------------------- # ● retour jour de la semaine #-------------------------------------------------------------------------- def back_day case @day when :Sun @day = :Sat $game_variables[WhiteSnow::DAY_STORE_VID] = 1 when :Sat @day = :Fri $game_variables[WhiteSnow::DAY_STORE_VID] = 2 when :Fri @day = :Thr $game_variables[WhiteSnow::DAY_STORE_VID] = 3 when :Thr @day = :Wed $game_variables[WhiteSnow::DAY_STORE_VID] = 4 when :Wed @day = :Tue $game_variables[WhiteSnow::DAY_STORE_VID] = 5 when :Tue @day = :Mon $game_variables[WhiteSnow::DAY_STORE_VID] = 6 when :Mon @day = :Sun $game_variables[WhiteSnow::DAY_STORE_VID] = 0 end end #-------------------------------------------------------------------------- # ● Maj du mois #-------------------------------------------------------------------------- def shift_month case @month when 1 return unless @date > 31 @month += 1 @date = 1 when 2 return unless @date > 28 @month += 1 @season = :Spring @date = 1 $game_variables[WhiteSnow::SEASON_STORE_VID] = 0 when 3 return unless @date > 31 @month += 1 @date = 1 when 4 return unless @date > 30 @month += 1 @date = 1 when 5 return unless @date > 31 @month += 1 @season = :Summer @date = 1 $game_variables[WhiteSnow::SEASON_STORE_VID] = 1 when 6 return unless @date > 30 @month += 1 @date = 1 when 7 return unless @date > 31 @month += 1 @date = 1 when 8 return unless @date > 31 @month += 1 @season = :Autumn @date = 1 $game_variables[WhiteSnow::SEASON_STORE_VID] = 2 when 9 return unless @date > 30 @month += 1 @date = 1 when 10 return unless @date > 31 @month += 1 @date = 1 when 11 return unless @date > 30 @month += 1 @season = :Winter @date = 1 $game_variables[WhiteSnow::SEASON_STORE_VID] = 3 when 12 return unless @date > 31 @year += 1 @month = 1 @date = 1 $game_variables[WhiteSnow::YEAR_STORE_VID] = @year end $game_variables[WhiteSnow::DATE_STORE_VID] = @date $game_variables[WhiteSnow::MONTH_STORE_VID] = @month end #-------------------------------------------------------------------------- # ● retour du mois #-------------------------------------------------------------------------- def back_month return unless @date < 1 case @month when 1 @month = 12 @date = 31 @year -= 1 $game_variables[WhiteSnow::YEAR_STORE_VID] = @year when 2 @month -= 1 @date = 31 when 3 @month -= 1 @date = 28 @season = :Winter $game_variables[WhiteSnow::SEASON_STORE_VID] = 3 when 4 @month -= 1 @date = 31 when 5 @month -= 1 @date = 30 when 6 @month -= 1 @date = 31 @season = :Spring $game_variables[WhiteSnow::SEASON_STORE_VID] = 0 when 7 @month -= 1 @date = 30 when 8 @month -= 1 @date = 31 when 9 @month -= 1 @date = 31 @season = :Summer $game_variables[WhiteSnow::SEASON_STORE_VID] = 1 when 10 @month -= 1 @date = 30 when 11 @month -= 1 @date = 31 when 12 @month -= 1 @date = 30 @season = :Autumn $game_variables[WhiteSnow::SEASON_STORE_VID] = 2 end $game_variables[WhiteSnow::DATE_STORE_VID] = @date $game_variables[WhiteSnow::MONTH_STORE_VID] = @month end #-------------------------------------------------------------------------- # ● avancer date #-------------------------------------------------------------------------- def shift_date @date += 1 shift_day shift_month $game_variables[WhiteSnow::HOUR_STORE_VID] = @hour $game_variables[WhiteSnow::DATE_STORE_VID] = @date end #-------------------------------------------------------------------------- # ● retour date #-------------------------------------------------------------------------- def back_date @date += 1 back_day back_month $game_variables[WhiteSnow::HOUR_STORE_VID] = @hour $game_variables[WhiteSnow::DATE_STORE_VID] = @date end #-------------------------------------------------------------------------- # ● calcule heure/date #-------------------------------------------------------------------------- def days_dif(y, m, d) table = WhiteSnow::DAYS_TABLE dy_n = (@year - 1) * 365 dy_s = (y - 1) * 365 dm_n = 0 ; 1.upto(@month - 1){|n| dm_n += table[n]} unless @month == 1 dm_s = 0 ; 1.upto(m - 1){|n| dm_s += table[n]} unless m == 1 d_n = @date - 1 d_s = d - 1 n = dy_n + dm_n + d_n s = dy_s + dm_s + d_s return s - n end end
#============================================================================== # ■ Window_Calender #------------------------------------------------------------------------------ # affichage calendrier #==============================================================================
class Window_Calender < Window_Base #-------------------------------------------------------------------------- # ● initialisation objet #-------------------------------------------------------------------------- def initialize(x = Graphics.width - 250, y = 0, w = 250) super(x, y, w, fitting_height(2)) refresh end #-------------------------------------------------------------------------- # ● MAJ fenetre #-------------------------------------------------------------------------- def update if $game_switches[WhiteSnow::CALENDER_WINDOW_HIDE_SID] == true self.visible = true else self.visible = false end
super refresh if $calender.count == 0 end #-------------------------------------------------------------------------- # ● MAJ #-------------------------------------------------------------------------- def refresh contents.clear draw_year draw_date draw_time draw_weather_icon end #-------------------------------------------------------------------------- # ● affichage année saison #-------------------------------------------------------------------------- def draw_year season = $calender.season.to_s season.gsub!("Spring"){"Printemps"} season.gsub!("Summer"){"Eté"} season.gsub!("Autumn"){"Autumne"} season.gsub!("Winter"){"Hiver"} draw_text(0, 0, contents_width, line_height, "Année " + "#{$calender.year}") draw_text(40, 0, contents_width, line_height, season, 1) end #-------------------------------------------------------------------------- # ● affichage date mois jour #-------------------------------------------------------------------------- def draw_date w = contents_width h = line_height month = $calender.month.to_s month.gsub! ("1"){"Janvier"} month.gsub! ("2"){"Fevrier"} month.gsub! ("3"){"Mars"} month.gsub! ("4"){"Avril"} month.gsub! ("5"){"Mai"} month.gsub! ("6"){"Juin"} month.gsub! ("7"){"Juillet"} month.gsub! ("8"){"Aout"} month.gsub! ("9"){"Septembre"} month.gsub! ("10"){"Octobre"} month.gsub! ("11"){"Novembre"} month.gsub! ("12"){"Decembre"} date = $calender.date.to_s
day = $calender.day.to_s day.gsub!("Sun"){"Dim"} day.gsub!("Mon"){"Lun"} day.gsub!("Tue"){"Mar"} day.gsub!("Wed"){"Mer"} day.gsub!("Thr"){"Jeu"} day.gsub!("Fri"){"Ven"} day.gsub!("Sat"){"Sam"} draw_text_ex(0, h, date + " " + month + "(" + day + ")") end #-------------------------------------------------------------------------- # ● affichage heure minute #-------------------------------------------------------------------------- def draw_time w = contents_width - 6 h = line_height hour = "#{$calender.hour}" min = $calender.min if (0..9).to_a.include?(min) min = "0" + min.to_s else min = min.to_s end draw_text(0, h, w, h, hour + ":" + min, 2) end #-------------------------------------------------------------------------- # ● affichage icon météo #-------------------------------------------------------------------------- def draw_weather_icon case $calender.weather when :fine icon_index = WhiteSnow::FINE[:icon] when :rain icon_index = WhiteSnow::RAIN[:icon] when :snow icon_index = WhiteSnow::SNOW[:icon] when :thunder icon_index = WhiteSnow::THUNDER[:icon] when :storm icon_index = WhiteSnow::STORM[:icon] when :star icon_index = WhiteSnow::STAR[:icon] when :s_storm icon_index = WhiteSnow::S_STORM[:icon] end draw_icon(icon_index, contents_width - 30, 0) end end
#============================================================================== # ■ Window_MenuCalender #------------------------------------------------------------------------------ # affichage calendrier dans le menu #==============================================================================
class Window_MenuCalender < Window_Base #-------------------------------------------------------------------------- # ● initialisation objet #-------------------------------------------------------------------------- def initialize(x = Graphics.width - 250, y = 0, w = 250) super(x, y, w, fitting_height(3)) refresh end #-------------------------------------------------------------------------- # ● MAJ #-------------------------------------------------------------------------- def refresh contents.clear draw_year draw_date draw_time draw_weather_icon end #-------------------------------------------------------------------------- # ● affichage année saison #-------------------------------------------------------------------------- def draw_year h = line_height season = $calender.season.to_s season.gsub!("Spring"){"Pri"} season.gsub!("Summer"){"Eté"} season.gsub!("Autumn"){"Aut"} season.gsub!("Winter"){"Hiv"} draw_text(0, 0, contents_width, line_height, "A " + "#{$calender.year}") draw_text(10, 0, contents_width + 12, line_height, season, 1) end #-------------------------------------------------------------------------- # ● affichage date mois jour #-------------------------------------------------------------------------- def draw_date w = contents_width h = line_height month = $calender.month.to_s month.gsub! ("1"){"Janv"} month.gsub! ("2"){"Fevr"} month.gsub! ("3"){"Mars"} month.gsub! ("4"){"Avr"} month.gsub! ("5"){"Mai"} month.gsub! ("6"){"Juin"} month.gsub! ("7"){"Juil"} month.gsub! ("8"){"Aout"} month.gsub! ("9"){"Sept"} month.gsub! ("10"){"Octo"} month.gsub! ("11"){"Nove"} month.gsub! ("12"){"Dece"} date = $calender.date.to_s
day = $calender.day.to_s day.gsub!("Sun"){"Dim"} day.gsub!("Mon"){"Lun"} day.gsub!("Tue"){"Mar"} day.gsub!("Wed"){"Mer"} day.gsub!("Thr"){"Jeu"} day.gsub!("Fri"){"Ven"} day.gsub!("Sat"){"Sam"}
draw_text_ex(0, h, date + " " + month + " (" + day + ")") end #-------------------------------------------------------------------------- # ● affichage heure minute #-------------------------------------------------------------------------- def draw_time w = contents_width - 12 h = line_height hour = "#{$calender.hour}" min = $calender.min if (0..9).to_a.include?(min) min = "0" + min.to_s else min = min.to_s end
draw_text(0, h * 2, w, h, hour + ":" + min, 2) end #-------------------------------------------------------------------------- # ● affichge icon météo #-------------------------------------------------------------------------- def draw_weather_icon case $calender.weather when :fine icon_index = WhiteSnow::FINE[:icon] when :rain icon_index = WhiteSnow::RAIN[:icon] when :snow icon_index = WhiteSnow::SNOW[:icon] when :thunder icon_index = WhiteSnow::THUNDER[:icon] when :storm icon_index = WhiteSnow::STORM[:icon] when :star icon_index = WhiteSnow::STAR[:icon] when :s_storm icon_index = WhiteSnow::S_STORM[:icon] end draw_icon(icon_index, contents_width - 30, 0) end end
#============================================================================== # ■ Scene_Map #------------------------------------------------------------------------------ # class érant carte #==============================================================================
class Scene_Map < Scene_Base #-------------------------------------------------------------------------- # ● creation des fenetre #-------------------------------------------------------------------------- alias calender_create_all_windows create_all_windows def create_all_windows calender_create_all_windows create_calender_window end #-------------------------------------------------------------------------- # ● cretaion fenetre affichage de la date #-------------------------------------------------------------------------- def create_calender_window @calender_window = Window_Calender.new end end
#============================================================================== # ■ Scene_Base #------------------------------------------------------------------------------ # superclass toute les scene du jeu #==============================================================================
class Scene_Base #-------------------------------------------------------------------------- # ● MAJ cadre base #-------------------------------------------------------------------------- alias calender_update_basic update_basic def update_basic calender_update_basic update_calender end #-------------------------------------------------------------------------- # ● MAJ temps #-------------------------------------------------------------------------- def update_calender return unless SceneManager.scene_is?(Scene_Map) return if $game_switches[WhiteSnow::TIME_COUNT_FORBID_SID] $calender.count += 1 if $calender.weather == :thunder and !($game_switches[WhiteSnow::WEATHER_EFFECT_FORBID_SID] or $game_switches[WhiteSnow::INSIDE_FLAG_SID]) $calender.thunder_count ||= [Graphics.frame_rate * 5 + (rand * Graphics.frame_rate * 10).floor, false] $calender.thunder_count[0] -= 1 if $calender.thunder_count[1] if $calender.thunder_count[0] == 0 se = RPG::SE.new(WhiteSnow::THUNDER[:se][0], WhiteSnow::THUNDER[:se][1], WhiteSnow::THUNDER[:se][2]) se.play $calender.thunder_count = nil end elsif $calender.thunder_count[0] < 12 + rand(43) flash = WhiteSnow::THUNDER[:flash] $calender.perform_thunder_effect(flash[0], flash[1], flash[2], flash[3], flash[4]) $calender.thunder_count[1] = true end else $calender.thunder_count = nil end if $calender.count % Graphics.frame_rate == 0 $calender.min += 1 $calender.count = 0 $game_variables[WhiteSnow::MIN_STORE_VID] = $calender.min $calender.weather_count -= 1 $calender.change_weather if $calender.weather_count <= 0 end if $calender.min == 60 $calender.hour += 1 $calender.min = 0 if $calender.hour >= 3 and $calender.hour < 19 $calender.weather = :fine if $calender.weather == :star else $calender.weather = :star if $calender.weather == :fine end $calender.get_time_zone $calender.change_tone_by_calender $game_map.autoplay $game_variables[WhiteSnow::MIN_STORE_VID] = $calender.min $game_variables[WhiteSnow::HOUR_STORE_VID] = $calender.hour end if $calender.hour == 24 $calender.hour = 0 $calender.shift_date end end end
#============================================================================== # ■ Scene_Menu #------------------------------------------------------------------------------ # class de traitement de l'ecrant menu #==============================================================================
class Scene_Menu #-------------------------------------------------------------------------- # ● debut traitement #-------------------------------------------------------------------------- alias calender_start start def start calender_start create_calender_window end #-------------------------------------------------------------------------- # ● creation fenetre #-------------------------------------------------------------------------- def create_calender_window x = 0 w = @gold_window.width @calender_window = Window_MenuCalender.new(x, 0, w) @calender_window.y = Graphics.height - @gold_window.height - @calender_window.height end end
#============================================================================== # ■ DataManager #------------------------------------------------------------------------------ # medule de gestion des objet #==============================================================================
module DataManager #-------------------------------------------------------------------------- # ● methode specifique pour alias #-------------------------------------------------------------------------- class << self alias :calender_create_game_objects :create_game_objects alias :calender_extract_save_contents :extract_save_contents end #-------------------------------------------------------------------------- # ● creation d'objet divers du jeu #-------------------------------------------------------------------------- def self.create_game_objects calender_create_game_objects $calender = Calender.new end #-------------------------------------------------------------------------- # ● sauvegarde de la reation de contenu #-------------------------------------------------------------------------- def self.make_save_contents contents = {} contents[:system] = $game_system contents[:timer] = $game_timer contents[:message] = $game_message contents[:switches] = $game_switches contents[:variables] = $game_variables contents[:self_switches] = $game_self_switches contents[:actors] = $game_actors contents[:party] = $game_party contents[:troop] = $game_troop contents[:map] = $game_map contents[:player] = $game_player contents[:calender] = $calender contents end #-------------------------------------------------------------------------- # ● creation contenue economiser #-------------------------------------------------------------------------- def self.extract_save_contents(contents) calender_extract_save_contents(contents) $calender = contents[:calender] end end
#============================================================================== # ■ Game_Interpreter #------------------------------------------------------------------------------ # interpreteur d'event #==============================================================================
class Game_Interpreter #-------------------------------------------------------------------------- # ● changer couleur écran #-------------------------------------------------------------------------- def change_tone(r, g, b, gray = 0, dur = 60) tone = Tone.new(r, g, b, gray) screen.start_tone_change(tone, dur) end #-------------------------------------------------------------------------- # ● changement condition météo #-------------------------------------------------------------------------- def change_weather(type, power, dur = 30) return if $game_party.in_battle screen.change_weather(type, power, dur) end #-------------------------------------------------------------------------- # ● réglage heure #-------------------------------------------------------------------------- def set_time(hour, min) hour = 23 if hour > 23 hour = 0 if hour < 0 min = 59 if min > 59 min = 0 if min < 0 $calender.hour = hour $calender.min = min $calender.get_time_zone $game_variables[WhiteSnow::MIN_STORE_VID] = $calender.min $game_variables[WhiteSnow::HOUR_STORE_VID] = $calender.hour $game_variables[WhiteSnow::DATE_STORE_VID] = $calender.date $game_map.autoplay $calender.change_weather $calender.change_tone_by_calender if $calender.hour >= 3 and $calender.hour < 19 $calender.weather = :fine if $calender.weather == :star else $calender.weather = :star if $calender.weather == :fine end end #-------------------------------------------------------------------------- # ● réglage date #-------------------------------------------------------------------------- def set_date(month, date, day) $calender.month = month $calender.date = date $calender.day = day $game_variables[WhiteSnow::MIN_STORE_VID] = $calender.month $game_variables[WhiteSnow::DATE_STORE_VID] = $calender.date case $calender.day when :Sun $game_variables[WhiteSnow::DAY_STORE_VID] = 0 when :Mon $game_variables[WhiteSnow::DAY_STORE_VID] = 1 when :Tue $game_variables[WhiteSnow::DAY_STORE_VID] = 2 when :Wed $game_variables[WhiteSnow::DAY_STORE_VID] = 3 when :Thr $game_variables[WhiteSnow::DAY_STORE_VID] = 4 when :Fri $game_variables[WhiteSnow::DAY_STORE_VID] = 5 when :Sat $game_variables[WhiteSnow::DAY_STORE_VID] = 6 end
case $calender.month when 1..2 $calender.season = :Winter $game_variables[WhiteSnow::SEASON_STORE_VID] = 3 when 3..5 $calender.season = :Spring $game_variables[WhiteSnow::SEASON_STORE_VID] = 0 when 6..8 $calender.season = :Summer $game_variables[WhiteSnow::SEASON_STORE_VID] = 1 when 9..11 $calender.season = :Autumn $game_variables[WhiteSnow::SEASON_STORE_VID] = 2 when 12 $calender.season = :Winter $game_variables[WhiteSnow::SEASON_STORE_VID] = 3 end $calender.change_weather end #-------------------------------------------------------------------------- # ● réglage année #-------------------------------------------------------------------------- def set_year(year) $calender.year = year $game_variables[WhiteSnow::YEAR_STORE_VID] = year $calender.change_weather end #-------------------------------------------------------------------------- # ● réglage temps #-------------------------------------------------------------------------- def set_weather(weather) $calender.weather = weather $calender.randomize_weather_count $calender.perform_weather_effect case weather when :fine $game_variables[WhiteSnow::WEATHER_STORE_VID] = 0 when :rain $game_variables[WhiteSnow::WEATHER_STORE_VID] = 1 when :snow $game_variables[WhiteSnow::WEATHER_STORE_VID] = 2 when :thunder $game_variables[WhiteSnow::WEATHER_STORE_VID] = 3 when :storm $game_variables[WhiteSnow::WEATHER_STORE_VID] = 4 when :star $game_variables[WhiteSnow::WEATHER_STORE_VID] = 5 when :s_storm $game_variables[WhiteSnow::WEATHER_STORE_VID] = 6 end end #-------------------------------------------------------------------------- # ● activation effet météo #-------------------------------------------------------------------------- def perform_weather_effect $calender.perform_weather_effect end #-------------------------------------------------------------------------- # ● flash écran #-------------------------------------------------------------------------- def perform_flash(r, g, b, alpha, dur = 12) color = Color.new(r, g, b, alpha) screen.start_flash(color, dur) end #-------------------------------------------------------------------------- # ● avancer date #-------------------------------------------------------------------------- def shift_date(num) num.times{$calender.shift_date} $calender.change_weather end #-------------------------------------------------------------------------- # ● avancer mois #-------------------------------------------------------------------------- def shift_month(num) table = WhiteSnow::DAYS_TABLE days = table[$calender.month] - $calender.date + 1 for i in 1..num days += table[($calender.month + i) % 12] end days.times{$calender.shift_date} $calender.change_weather end #-------------------------------------------------------------------------- # ● avancer année #-------------------------------------------------------------------------- def shift_year(num) (num * 365).times{$calender.shift_date} $calender.change_weather end #-------------------------------------------------------------------------- # ● avancer jusqu'à date spécifique #-------------------------------------------------------------------------- def shift_date_to(m, d, y = -1) y = $calender.year if y == -1 if $calender.days_dif(y, m, d) > 0 $calender.days_dif(y, m, d).times{$calender.shift_date} else $calender.days_dif(y, m, d).abs.times{$calender.back_date} end $calender.change_weather end end
#============================================================================== # ■ SceneManager #------------------------------------------------------------------------------ # module de transition #==============================================================================
module SceneManager #-------------------------------------------------------------------------- # ● méthode spécifique pour les alias #-------------------------------------------------------------------------- class << self alias :calender_goto :goto alias :calender_call :call alias :calender_return :return end #-------------------------------------------------------------------------- # ● transition directe #-------------------------------------------------------------------------- def self.goto(scene_class) calender_goto(scene_class) if scene_class == Scene_Map $calender.perform_weather_effect $calender.change_tone_by_calender end end #-------------------------------------------------------------------------- # ● appel #-------------------------------------------------------------------------- def self.call(scene_class) calender_call(scene_class) if scene_class == Scene_Map $calender.perform_weather_effect $calender.change_tone_by_calender end end #-------------------------------------------------------------------------- # ● retour appel #-------------------------------------------------------------------------- def self.return calender_return if @scene.class == Scene_Map $calender.perform_weather_effect $calender.change_tone_by_calender end end end
#============================================================================== # ■ Game_Switches #------------------------------------------------------------------------------ # class gerant les interrupteur #==============================================================================
class Game_Switches #-------------------------------------------------------------------------- # ● réglage interupteur # value : ON (true) / OFF (false) #-------------------------------------------------------------------------- def []=(switch_id, value) @data[switch_id] = value on_change if switch_id == WhiteSnow::TONE_CHANGE_FORBID_SID or switch_id == WhiteSnow::INSIDE_FLAG_SID case value when true $calender.interpreter.change_tone(0, 0, 0, 0, 0) when false $calender.change_tone_by_calender(0) end end if switch_id == WhiteSnow::WEATHER_EFFECT_FORBID_SID or switch_id == WhiteSnow::INSIDE_FLAG_SID case value when true $calender.interpreter.change_weather(:none, 0, 0) RPG::BGS.stop if (WhiteSnow::WEATHER_BGS_ENABLE and [0, 1].include?(WhiteSnow::INSIDE_BGS_TYPE)) or $game_switches[WhiteSnow::WEATHER_BGS_DISABLE] $calender.play_inside_bgs if WhiteSnow::WEATHER_BGS_ENABLE and WhiteSnow::INSIDE_BGS_TYPE == 1 and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE] when false $calender.perform_weather_effect(0) end end end end
#============================================================================== # ■ Game_Player #------------------------------------------------------------------------------ # class gerant le calendrier en foncton du joueur #==============================================================================
class Game_Player #-------------------------------------------------------------------------- # ● deplacement à l'execution (pas compris) #-------------------------------------------------------------------------- alias calender_perform_transfer perform_transfer def perform_transfer if transfer? $calender.perform_weather_effect(0) $calender.change_tone_by_calender(0) end calender_perform_transfer end end
#============================================================================== # ■ RPG::Map #------------------------------------------------------------------------------ # class de donné de la carte #==============================================================================
class RPG::Map #-------------------------------------------------------------------------- # ● carte BGM #-------------------------------------------------------------------------- def bgm bgm = Hash.new(@bgm) @note.each_line do |line| case line when /<(?:早朝|early)\s*(.+)\s*\,\s*(\d+)\s*\,\s*(\d+)>/ bgm[:early_morning] = RPG::BGM.new($1, $2.to_i, $3.to_i) when /<(?:朝|morning)\s*(.+)\s*\,\s*(\d+)\s*\,\s*(\d+)>/ bgm[:morning] = RPG::BGM.new($1, $2.to_i, $3.to_i) when /<(?:昼|noon)\s*(.+)\s*\,\s*(\d+)\s*\,\s*(\d+)>/ bgm[:noon] = RPG::BGM.new($1, $2.to_i, $3.to_i) when /<(?:夕方|evening)\s*(.+)\s*\,\s*(\d+)\s*\,\s*(\d+)>/ bgm[:evening] = RPG::BGM.new($1, $2.to_i, $3.to_i) when /<(?:夜|night)\s*(.+)\s*\,\s*(\d+)\s*\,\s*(\d+)>/ bgm[:night] = RPG::BGM.new($1, $2.to_i, $3.to_i) when /<(?:深夜|mid)\s*(.+)\s*\,\s*(\d+)\s*\,\s*(\d+)>/ bgm[:midnight] = RPG::BGM.new($1, $2.to_i, $3.to_i) end end return bgm end end
#============================================================================== # ■ Game_Map #------------------------------------------------------------------------------ # class gerant la carte #==============================================================================
class Game_Map #-------------------------------------------------------------------------- # ● commutation automatique des BGM / BGS #-------------------------------------------------------------------------- def autoplay case $calender.time_zone when :early_morning @map.bgm[:early_morning].play if @map.autoplay_bgm when :morning @map.bgm[:morning].play if @map.autoplay_bgm when :noon @map.bgm[:noon].play if @map.autoplay_bgm when :evening @map.bgm[:evening].play if @map.autoplay_bgm when :night @map.bgm[:night].play if @map.autoplay_bgm when :midnight @map.bgm[:midnight].play if @map.autoplay_bgm end @map.bgs.play if @map.autoplay_bgs end end
module Kernel #-------------------------------------------------------------------------- # ● génération de nombre aleatoire pondéré #-------------------------------------------------------------------------- def p_ex_rand(rate, n = 0) srand rate = 99 if rate == 100 if n == 0 r = 1 - rand ** (1 - rate * 0.01) if r == 1 return 0 else return r end else num = n.truncate r = 1 - rand ** (1 - rate * 0.01) r = 0 if r == 1 return (r * num).floor end end end | |
|