¡Bienvenido a Universo Maker!
¿Es esta la primera vez que visitas el foro? Si es así te recomendamos que te registres para tener completo acceso a todas las áreas y secciones del foro, así también podrás participar activamente en la comunidad. Si ya tienes una cuenta, conectate cuanto antes.
Iniciar Sesión Registrarme

No estás conectado. Conéctate o registrate

Ver el tema anterior Ver el tema siguiente Ir abajo Mensaje [Página 1 de 1.]

#1 Ayuda con script el Lun Jul 27, 2015 5:02 am

Cerberos_diamond

avatar
Hola chicos que tal, n_n vengo a pedirles una pequeña ayuda, se trata de que en un script vi un sistema bastante completo de day/night  + clima.
Este script funciona junto con otros en un hud personalizado, pero yo no necesito tooodo el HUD y solo necesito que la "ventanita" del tiempo se muestre cuando yo pulse un boton, aca una img la unica parte del hud que yo necesito esta a la derecha arriba

IMG:


#2 Re: Ayuda con script el Lun Jul 27, 2015 5:06 am

Cerberos_diamond

avatar
quise publicar todo en un solo mensaje pero me decia que estaba muy largo, he aca el script
Script:

#==============================================================================
# ** Melly-Mel's Calendar System
#------------------------------------------------------------------------------
#    by DerVVulfman
#    version 1.7
#    06-01-2012
#    RGSS / RPGMaker XP
#==============================================================================
#
#  INTRODUCTION:
#
#  Based on designs by Kylock  and features employed by  Near Fantastica in his
#  original system,  this Day Night system gives the user mastery over the time
#  system in his project.
#  
#  By manipulating the script's configuration section, one can control how fast
#  time runs in the game, the actual increments used,  and even how many months
#  there are in a year.  The creator has full control over the game's calendar.
#
#  Not only that,  you can program weather patterns based on months or dates of
#  your choice. Of course, using a [SET WEATHER EFFECTS] event works as normal.
#
#------------------------------------------------------------------------------
#
# INSTRUCTIONS:
#
# The configurables are fairly self explanatory, and each heading and value has
# enough instructions alone to assist the user of this script.
#
# ^_^ Probably more instructions than most Day/Night scripts anyway.
#
#
#------------------------------------------------------------------------------
#
#  SCRIPT CALLS:
#    The following calls are used to retrieve calendar information that is
#    used by this system.  All data, even the numeric values, are passed as
#    strings.  If used for numeric calculations, conversion to integers is
#    advised.
#
#    * $game_time.get_weekday_number        Returns a numeric value of the weekday
#    * $game_time.get_weekday_name          Returns the actual text of the weekday
#    * $game_time.get_day_of_year           Returns the day of the year (ex: 1-365)
#    * $game_time.get_month_name            Returns the name of the current month
#    * $game_time.get_month_number          Returns the month as a number (ex:1-12)
#    * $game_time.get_day_of_month          Returns the day for that month (ex 1-31)
#    * $game_time.get_light_setting_name    Returns text describing the day (Dawn)
#    * $game_time.get_light_setting_number  Returns a numeric value for the time of day
#    * $game_time.get_year                  Returns the current year
#    * $game_time.get_total_days            Returns the total number of days
#
#   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .
#
#    The following values are used to retrieve clock/time information that is
#    used by this system.
#    * $game_time.clock_seconds             Returns the current seconds(ex 1-60)
#    * $game_time.clock_minutes             Returns the current minutes(ex 1-60)
#    * $game_time.clock_hours               Returns the current hours(ex 1-24)
#
#   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .
#
#    The following calls are used to manipulate the current information that is
#    used by the system.  These can increase or decrease the number of days,
#    hours or years.
#
#    * $game_time.adjust_seconds(number)    Increases or decreases the seconds
#    * $game_time.adjust_minutes(number)    Increases or decreases the minutes
#    * $game_time.adjust_hours(number)      Increases or decreases the hours
#    * $game_time.adjust_days(number)       Increases or decreases the days
#    * $game_time.adjust_years(number)      Increases or decreases the years
#
#   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .
#
#    The following callse are used to turn  on/off  the system's pause feature.
#    When the system is paused, an RMXP game switch that can be used by events
#    will be turned on for game use (see DN_Pause_Switch).
#
#    * $game_time.start_pause               Pauses the time system
#    * $game_time.stop_pause                Starts the time system
#
#    You can continue adjusting the game's clock  through script calls such as
#    the ones  mentioned above.   They are  not inhibited  by the pause system.
#    And calling the  $game_time.stop_pause  command while the pause system is
#    already engaged will not have any effect.
#
#   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .
#
#    This script has a feature  that allows for different weather  based on the
#    changing days.  It does not rewrite the weather system, so you may find it
#    compatible with the weather script by ccoa.   You can turn on and off this
#    system with the following script call:
#
#    * $game_system.dn_weather_on = value   A simple 'true/false' value
#
#    And you can retrieve the type and strength of the current weather with the
#    following values:
#
#    * $game_system.dn_weather_type         The type of weather pattern
#    * $game_system.dn_weather_power        How strong the weather pattern is
#
#------------------------------------------------------------------------------
#
#  COMPATIBILITY:
#
#  Given the number of aliases in use  and the creation  of its own 'Game_Time'
#  class, it should be compatible with most other scripts... with the exception
#  of other Day/Night or time scripts.
#
#  Also note that this system can function along with the 'Weather Script' by
#  Ccoa (with ideas by ScriptKitty and Mr.DJ).
#
#------------------------------------------------------------------------------
#
#  THANKS:
#
#  Thanks to PK8... (among other aliases)... for requesting  a time script that
#  included weather control, which I added to this script.   To Near Fantastica
#  and Kylock for the basics of this Day/Night script.  And to Kalier, who gave
#  me a few ideas while discussing fun game features.   Also to Yin who gave me
#  the idea of making a switch system useful for event switches like night-time
#  campfires or lamp post lights. And thanks goes to both Kalier and Rosair who
#  wanted a revision of the Switch system  to allow for multiple switches which
#  can be controlled by the time system. And more thanks to Rosair for noticing
#  a bug related to the day-overlap function that interefered with the script's
#  game switch toggling system. Lastly to derula and Yin for noticing something
#  that could cause crash errors while using saves in a project's development.
#  
#
#==============================================================================



#==============================================================================#
#                                                                              #
#         * * *    C O N F I G U R A T I O N   S E C T I O N    * * *          #
#                  -----------------------------------------                   #
#==============================================================================#


# GENERAL SYSTEM SETTINGS ===================================================
# ===========================================================================
#
# This section calibrates the speed  of the day/night system,  allows one to
# set up the actual time increments (how many seconds in a minute, etc.) and
# what the time is when the game starts.
#
# ===========================================================================


  # SPEED AND SYSTEM
  # These set general clock speed and display manners.  It also determines
  # whether the battle screen also becomes adjusted by the day/night system.
  #
    DN_Clock_Speed    = 10  # Clock speed (1-10) or nil/0 for default speed
    DN_Clock_System   = true  # If true, uses 'am/pm'-like system
    DN_Battle_Tint    = true  # Battlesystem will tint to match if set to 'true'
    DN_DayTag_1       = "AM"  # Tag used in am/pm system (for 1st half of day)
    DN_DayTag_2       = "PM"  # Tag used in am/pm system (for 2nd half of day)
    DN_Pause_Switch   =   6   # An RMXP switch that is turned on if the time
                              # system is paused.
   
  # CLOCK INCREMENTS
  # This allows you to adjust the clock system.  Normal day/night clocks have
  # a 24 hour day / 60 minutes an hour system.  However, one can control or
  # create a 20 hour day and/or 100 seconds a minute system.
  #
    DN_By_Seconds     =   30  # How many Seconds in a Minute
    DN_By_Minutes     =   60  # How many Minutes in an Hour
    DN_By_Hours       =   24  # How many Hours in a Day (must be multiple of 2)

  # CLOCK START SETTINGS
  # This allows you to set the time of day in which your game will start.  It
  # is dependent upon the 'CLOCK INCREMENTS' system above for an accurately
  # set day/time start.  (IE: Don't set the start minutes to 45 if you only
  # have 20 minutes an hour.)
  #
    DN_Start_Hour     =   12  # 1st hour in the game, based on 24hr clock
    DN_Start_Minute   =    4  # 1st minute (of the hour) in the game
    DN_Start_Day      =    1  # 1st day if the game, based on day of the year
    DN_Start_Weekday  =    2  # 1st weekday of the game (see DN_Weekday_Array)
    DN_Start_Year     = 2010  # 1st year of the game

   

# SYSTEM CALENDAR ARRAYS ====================================================
# ===========================================================================
#
# These values gives the system  the ability to distinguish days of the week
# as well as setting the months of the year and number of days in each.  Not
# only that, but it also contains an array so you can set the tone (or light)
# setting for different times of the day,  and which maps are 'outdoor' maps
# that are affected.
#
# Current values are based on the modern Gregorian calendar.
#
# ===========================================================================


  # DAYS OF THE WEEK
  # This lists the days of the week.  The system is flexible enough to even
  # count the weekdays within this array.  The DN_Start_Weekday value (above)
  # relies on this array so to display the proper day of the week.
  #
    DN_Weekday_Array  = [ "Sunday", "Monday", "Tuesday", "Wednesday",
                           "Thursday", "Friday", "Saturday" ]
   
  # MONTHS IN THE YEAR
  # This lists the individual months of the year, and how many days are in
  # each individual month.  As such, the system can calculate how many days
  # are in a year as well as which month of the year the time is now set.
  #
    DN_Month_Array    = [ [31, "Jan"], [28, "Feb"], [31, "Mar"],
                          [30, "Apr"], [31, "May"], [30, "Jun"],
                          [31, "Jul"], [31, "Aug"], [30, "Sept"],
                          [31, "Oct"], [30, "Nov"], [31, "Dec"]  ]


  # DAYLIGHT SETTING
  # This lists the individual daylight settings.   Herein, you set the text
  # that can describe the time of day, the hour range for the settings, the
  # screen tint (in red,green,blue,alpha) and how long it takes (in frames)
  # for the system to update the screen.
  #
  # The range for the light settings are only based on hours in the day.
  #
  #                         Name        Hours     RR    GG    BB    AA  Dur
  #                         ========    ======  ====  ====  ====  ====  ===
    DN_Lighting_Array = [ [ "Dawn",      0,  5, -187, -119,  -17,  68,  20 ],
                          [ "Morning",   6,  6,   17,  -51, -102,   0,  20 ],
                          [ "Day",       7, 18,    0,    0,    0,   0,  20 ],
                          [ "Evening",  19, 19,  -68, -136,  -34,   0,  20 ],
                          [ "Twilight", 20, 24, -187, -119,  -17,  68,  20 ]  ]


  # THE SWITCH SYSTEM
  # This system identifies RPGMaker XP Game Switches and the time, date and
  # weekday in which will set each one to ON/True.   This feature  is quite
  # useful to have campfires visible only within certain hour ranges.
  #
  # The first array is a list of your switches that are turned 'on' or 'off'.
  # The second 'set' of arrays define a switch and the hour range,  calendar
  # date and weekday that turns the switch on and off.  All hours are set on
  # a 24 hour-like system.  Each value set (hours, date, weekday) may be set
  # to nil, so you may set the switch(es) to work on weekdays or dates alone
  # or combinations of the like.  However, you cannot set the second array
  # to have all values set to nil.
  #
  # One default for switch #5, turns on at 19 (or 7pm) and turns off at 6am
  # but only for  Weekday #3 (Tuesday).   It overlaps  to Wednesday morning.
  # Date values are in month/day order, so an array for February 12th would
  # be set to [2,12].  The other default is for switch #7 that shows how to
  # use the month/day feature  as it turns on at 7am  and off at 6pm (hence
  # the 18 value), but only functions on January 2.
  #
  DN_Light_Switches     = {}  # <==  Do not touch (used to create the array.
 
  # List of RMXP Game Switches
    DN_Light_List           = [5,7] # The list of switches referred below.
   
  # List of Checked Switches    Hours,    Date,   WkDay
  #                             ======    ======  ======
    DN_Light_Switches[5]    = [ [19, 6],  [],     3]
    DN_Light_Switches[7]    = [ [7, 18],  [1,2],  nil]

   
  # THE OUTDOOR MAP ARRAY
  # This array holds the IDs of any and all maps that are outdoor maps and
  # are affected visually by the day/night system.  Any in this list will
  # visibly tint based on values within the DAYLIGHT SETTING array (above).
  #
    DN_Map_Array = [2]

   
   
# SYSTEM WEATHER CONTROLS ===================================================
# ===========================================================================
#
#  Weather pattern consists of 4 values:
#  Chance of weather (1-100),  the type (0-3), power (1-9),  delay in frames.
#  So an array of [50, 2, 1, 40]  would give a 50% of a weak storm that takes
#  a couple of seconds (40 frames) to fade in.
#
#  Um, you can set nil to an array if you don't want weather patterns. ^_^
#
#  The weather changes on the start/stop of each day, so no 'mid-day' weather
#  changes are programmable with the system.   You'll need to use the default
#  'SET WEATHER EFFECTS' map effect for that.
#
#  Compatible with Ccoa's Weather system.
#
# ===========================================================================

  # WEATHER_SYSTEM
  # This is a the default setting switch that determines whether or not you
  # decide to use this script's weather system.   It is a true/false switch
  # which can also be changed by the '$game_system.dn_weather_on' value.
  #
    DN_Weather_System   = true
   
  # EVENT_WEATHER_SAVE
  # This is a switch that determines if weather values created from the map
  # event feature [CHANGE MAP WEATHER] will be stored in save games. When it
  # is set to true, map event weather will be restored.  If set to false, it
  # doesn't save map weather created with the map event code.  Set to false
  # by default.  It's normally not saved, even without this script.
  #
    DN_Map_Weather_Save = false

  # MONTHLY WEATHER
  # This array holds the value of individual months and the generic weather
  # effects that are common for that month (ie April (#4) and rain).    
  #
  #                       Mth           =>  [chance, type,  power,  delay]
    DN_Weather_Month  = { 1             =>  [45,      3,    4,      0],
                          2             =>  [25,      1,    5,      0],
                          4             =>  [50,      2,    9,      0],
                          12            =>  [60,      3,    5,      0]}
 
   
  # DAILY WEATHER
  # Similar to  the Monthly weather array,  this allows you to set specific
  # month/day combinations to give certain days in a year a weather effect.
  # So... one could set up a holiday like Christmas Day to always be snowy.
  # Unlike the monthly weather system, the month/day value being checked is
  # to be a string, like so: "03/14" in a MM/DD pattern,  this representing
  # the 14th of March.
  #
  #                       Mth/Day       =>  [chance, type,  power,  delay]
    DN_Weather_Daily  =   nil

  # CALENDAR WEATHER
  # This is the most comprehensive  of the weather arrays  as it forces one
  # to specify the month, day and year for each weather pattern within. And
  # it follows upon a YYYYMMDD pattern, so entries must be as the following:
  # "20100422"... which would represent April 22, 2010.
  #
  #                       Year/Mth/Day  =>  [chance, type,  power,  delay]
    DN_Weather_Calen  = { "20100107"    =>  [100,     2,    9,      0],
                          "20100108"    =>  [100,     3,    5,      20]}

                           
   
# EVENT FRIENDLY VARIABLES ==================================================
# ===========================================================================
#
# One thing to note.   It may be easier  to access time system variables  if
# they are already assigned to $game_variable variables, but it can slow the
# system down (if only for a couple of frames).  
#
# ===========================================================================

  DN_Variables    = true  # If true, you can get the game time from variables
  DN_Var_Second   = 1     # This assigned variable stores the clock seconds
  DN_Var_Minute   = 2     # This assigned variable stores the clock minutes
  DN_Var_Hour     = 3     # This assigned variable stores the clock hour
  DN_Var_Day      = 4     # This assigned variable stores the total days
  DN_Var_Weekday  = 5     # This assigned variable stores the weekday
  DN_Var_Lighting = 6     # This assigned variable stores the daylight name
  DN_Var_Month    = 7     # This assigned variable stores the calendar month
  DN_Var_MonthDay = 8     # This assigned variable stores the calendar day
  DN_Var_Year     = 9     # This assigned variable stores the calendar year
   

 
#==============================================================================
# ** Game_Temp
#------------------------------------------------------------------------------
#  This class handles temporary data that is not included with save data.
#  Refer to "$game_temp" for the instance of this class.
#==============================================================================

class Game_Temp
#-----------------------------------------------------------------------------
# * Public Instance Values
#-----------------------------------------------------------------------------
attr_reader      :map_infos
attr_reader      :outside_array
#-----------------------------------------------------------------------------
# * Object Initialization
#-----------------------------------------------------------------------------
alias dn_initalize initialize
def initialize
  # Perform the original call
  dn_initalize
  # Create the map array
  @outside_array = Array.new
  # Gain map data
  @map_infos = load_data("Data/MapInfos.rxdata")
  # Sort through map data
  for key in @map_infos.keys
    # Set map value to true if map is an outside map
    @outside_array[key] = true if DN_Map_Array.include?(key)
  end
end
end



#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
#  This class handles data surrounding the system. Backround music, etc.
#  is managed here as well. Refer to "$game_system" for the instance of
#  this class.
#==============================================================================

class Game_System
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :dn_weather_type          # Day/Night weather type
attr_accessor :dn_weather_power         # Day/Night weather strength  
attr_accessor :dn_weather_on            # Day/Night weather_flag
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias dn_game_system_init initialize
def initialize
  # Perform the original call
  dn_game_system_init
  # Weather values
  @dn_weather_type, @dn_weather_power = 0, 0    
  @dn_weather_on = DN_Weather_System
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------  
alias dn_game_system_update update
def update      
  # Perform the original call
  dn_game_system_update
  # Update the clock
  $game_time.update
end  
end



#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
#  This class handles the map. It includes scrolling and passable determining
#  functions. Refer to "$game_map" for the instance of this class.
#==============================================================================

class Game_Map
#--------------------------------------------------------------------------
# * Setup
#     map_id : map ID
#--------------------------------------------------------------------------  
alias dn_game_map_setup setup
def setup(map_id)
  # Perform the original call
  dn_game_map_setup(map_id)
  # Prevent gametime update and tint if not loaded
  return if $game_time.nil?
  # Update the clock
  $game_time.update
  # Immediately tint on map load
  $game_time.instant_tint
end  
end



#==============================================================================
# ** Game_Time
#------------------------------------------------------------------------------
#  This class handles the calculations for the day night clock system.
#  Refer to "$game_time" for the instance of this class.
#==============================================================================

class Game_Time
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :pause_tint               # Pause screen tinting flag
attr_accessor :manual_tint              # Manual tint control flag
attr_accessor :weather_type             # Game_Time's Weather type
attr_accessor :weather_power            # Game_Time's Weather power level
attr_accessor :weather_duration         # Game_Time's Weather duration
attr_accessor :clock_seconds            # Game_Time's current seconds
attr_accessor :clock_minutes            # Game_Time's current minutes
attr_accessor :clock_hours              # Game_Time's current hours
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
  # Create in-Game Arrays
  @array_month    = []
  @array_light    = []
  @pause_value    = Graphics.frame_count
  @pause_boolean  = nil
  # Create Increments for calculations
  @calc_seconds = DN_By_Seconds.to_i
  @calc_minutes = DN_By_Minutes.to_i
  @calc_hours   = DN_By_Hours.to_i
  # Create Total Sums for calculations
  @sum_minutes  = DN_By_Seconds.to_i
  @sum_hours    = DN_By_Seconds.to_i * DN_By_Minutes.to_i
  @sum_days     = DN_By_Seconds.to_i * DN_By_Minutes.to_i * DN_By_Hours.to_i
  # Calendar System
  month_tally = 0
  for month in DN_Month_Array
    temp = []
    month_tally += month[0]
    temp.push(month_tally)
    temp.push(month[1])
    temp.push(month[0])
    @array_month.push(temp)
  end
  # Number of seconds in a year
  @sum_year   = month_tally * @sum_days
  @calc_year  = month_tally
  # Light System
  for light in DN_Lighting_Array
    @array_light.push(light)
  end
  # Speed Offsets
  @calc_speed   = 0
  unless DN_Clock_Speed == nil or DN_Clock_Speed.to_i == 0
    @calc_speed   = (DN_Clock_Speed.to_i * 3) + 9
  end
  # Starting Time Offset
  @calc_offset  = (DN_Start_Minute.to_i * @sum_minutes) +
                  (DN_Start_Hour.to_i   * @sum_hours) +
                  (DN_Start_Day.to_i    * @sum_days)
  # Set the flag                
  @pause_tint       = false
  @manual_tint      = false
  # Set the weather
  @weather_type     = 0
  @weather_power    = 0
  @weather_duration = 0
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
  if @pause_boolean == true
    # Calculate total number of seconds
    @total_seconds = (@pause_value / (Graphics.frame_rate - @calc_speed )) + @calc_offset
  else
    # Calculate total number of seconds
    @total_seconds = (Graphics.frame_count / (Graphics.frame_rate - @calc_speed )) + @calc_offset
  end
  # Calculate seconds, minutes, hours and days
  total_minutes = @total_seconds / @sum_minutes
  total_hours   = @total_seconds / @sum_hours
  @total_days   = @total_seconds / @sum_days
  @total_years  = (@total_seconds-@sum_days) / @sum_year
  # Clock Update
  @clock_seconds = @total_seconds % @calc_seconds
  @clock_minutes = total_minutes  % @calc_minutes
  @clock_hours   = total_hours    % @calc_hours
  # Update Game Variables if used
  if DN_Variables
    $game_variables[DN_Var_Second.to_i]    = @clock_seconds
    $game_variables[DN_Var_Minute.to_i]    = @clock_minutes
    $game_variables[DN_Var_Hour.to_i]      = @clock_hours
    $game_variables[DN_Var_Day.to_i]       = @total_days
    $game_variables[DN_Var_Weekday.to_i]   = get_weekday_number
    $game_variables[DN_Var_Lighting.to_i]  = get_light_setting_number
    $game_variables[DN_Var_Month.to_i]     = get_month_number
    $game_variables[DN_Var_MonthDay.to_i]  = get_day_of_month
    $game_variables[DN_Var_Year.to_i]      = get_year
  end
  # Check for changing Days
  if @old_days != @total_days
    @clock_changed = true
    @old_days = @total_days
  end  
  # Check Lightswitch
  unless DN_Light_List.nil? or DN_Light_List == []
    # Cycle through the list of switches available
    for light_list in DN_Light_List
      # Check Light Switch
      switch_val = update_light_switch(light_list)
      # Get the old switch value
      old_switch = $game_switches[light_list]
      # Apply the switch to the game switch
      $game_switches[light_list] = switch_val
      # Refresh map if different switch
      $game_map.refresh if old_switch == switch_val        
    end
  end
  # Perform weather check if different day
  change_weather if @clock_changed == true
end
#--------------------------------------------------------------------------
# * Update Light Switch
#--------------------------------------------------------------------------  
def start_pause
  @pause_value = Graphics.frame_count
  @pause_boolean = true
  $game_switches[DN_Pause_Switch] = true
end
#--------------------------------------------------------------------------
# * Update Light Switch
#--------------------------------------------------------------------------  
def stop_pause
  return if @pause_boolean.nil?
  Graphics.frame_count = @pause_value
  @pause_boolean = nil
  $game_switches[DN_Pause_Switch] = false
end
#--------------------------------------------------------------------------
# * Update Light Switch
#--------------------------------------------------------------------------  
def update_light_switch(light_list)
  light_switch_set = DN_Light_Switches[light_list]
  # Make the temp switch flags
  switch_hours    = false
  switch_date     = false
  switch_weekday  = false
  switch_val      = false
  overlap_day     = false
  chk1 = chk2 = chk3 = false
  # Check for all-nil sets
  chk1 = true if light_switch_set[0].nil?
  chk1 = true if light_switch_set[0] == []
  chk2 = true if light_switch_set[1].nil?
  chk2 = true if light_switch_set[1] == []
  chk3 = true if light_switch_set[2].nil?
  return false if chk1 && chk2 && chk3
  # Determine if light switch hours indicate day overlap
  if light_switch_set[0] != nil or light_switch_set[0] != []
    overlap_day   = true if light_switch_set[0][0] > light_switch_set[0][1]
  end
  # switch val control for hourly basis
  if light_switch_set[0] != nil or light_switch_set != []
    if overlap_day
      switch_hours = true if light_switch_set[0][0] <= @clock_hours or light_switch_set[0][1] >= @clock_hours        
    else
      switch_hours = true if light_switch_set[0][0] <= @clock_hours and light_switch_set[0][1] >= @clock_hours
    end
  else
    switch_hours = true
  end
  # switch val control for calendar
  if light_switch_set[1].nil?
    switch_date = true
  elsif light_switch_set[1] == []
    switch_date = true  
  else
    if overlap_day
      day_val = light_switch_set[1][1].to_i + 1
      day_val = 1 if day_val > DN_Month_Array[get_month_number.to_i-1][0]
      if day_val == 1
        month_val = light_switch_set[1][0].to_i + 1
        month_val = 1 if month_val > DN_Month_Array.size
      end
      # Before hours change day
      switch_date = true if light_switch_set[1][0] == get_month_number.to_i && (light_switch_set[1][1] == get_day_of_month.to_i) && light_switch_set[0][0] <= @clock_hours
      # If Overlap and month changes
      if day_val == 1
        switch_date = true if month_val == get_month_number.to_i && (day_val == get_day_of_month.to_i) && light_switch_set[0][1] >= @clock_hours
      # Otherwise, overlap and only day changes
      else
        switch_date = true if light_switch_set[1][0] == get_month_number.to_i && (day_val == get_day_of_month.to_i) && light_switch_set[0][1] >= @clock_hours
      end
    else
      switch_date = true if (light_switch_set[1][0] == get_month_number.to_i) && (light_switch_set[1][1] == get_day_of_month.to_i)
    end
  end
  # switch val control for weekdays
  if light_switch_set[2].nil?
    switch_weekday = true
  else
    if overlap_day
      wkday = light_switch_set[2].to_i + 1
      wkday = 1 if wkday >= DN_Weekday_Array.size
      switch_weekday  = true if light_switch_set[2] == get_weekday_number.to_i+1 && light_switch_set[0][0] <= @clock_hours
      switch_weekday  = true if               wkday == get_weekday_number.to_i+1 && light_switch_set[0][1] >= @clock_hours
    else
      switch_weekday  = true if light_switch_set[2] == get_weekday_number.to_i+1
    end
  end
  switch_val = true if switch_hours && switch_date && switch_weekday
  return switch_val
end
#--------------------------------------------------------------------------
# * Return Weekday Name
#--------------------------------------------------------------------------
def get_weekday_name
  # Get the weekday number
  weekday = get_weekday_number.to_i - 1
  # Obtain and return the name from the Weekday Array
  return DN_Weekday_Array[weekday]
end
#--------------------------------------------------------------------------
# * Return Weekday Number
#--------------------------------------------------------------------------
def get_weekday_number
  # Get the estimated weekday number
  weekday = @total_days % DN_Weekday_Array.length
  # Adjust and reset with 'Starting Weekday' figure
  weekday -= 1
  weekday += DN_Start_Weekday
  # Return the weekday number
  return weekday.to_s
end
#--------------------------------------------------------------------------
# * Return Day of Year
#--------------------------------------------------------------------------  
def get_day_of_year
  # Obtain the total days
  day = @total_days
  # Calculate off accumulated years
  day  = day  % @calc_year if day > @calc_year
  # Ensure no '0' values'
  day = 1 if day < 1
  # Return the day
  return day.to_s
end
#--------------------------------------------------------------------------
# * Return Month Name (actual text)
#--------------------------------------------------------------------------  
def get_month_name
  # Get the day of the year
  day = get_day_of_year.to_i
  # Reset the month name to the starting month
  month_name = @array_month[0][1]
  # Sort through the month array
  for month in @array_month
    # If day exceeds accumulated month day total
    if day <= month[0]
      # Reset the month name
      month_name = month[1]
      # and exit the loop
      break
    end
  end
  # Return the name
  return month_name
end
#--------------------------------------------------------------------------
# * Return Month Number (months in a year)
#--------------------------------------------------------------------------  
def get_month_number
  # Get the day of the year
  day = get_day_of_year.to_i
  # Reset Tally
  tally = 0
  # Sort through the month array
  for month in @array_month
    # Increase Tally by 1
    tally += 1
    # Escape loop if day exceeds accumulated month day total
    break if day.to_i <= month[0].to_i
  end
  # Return tally
  return tally.to_s
end  
#--------------------------------------------------------------------------
# * Return Day of the Month
#--------------------------------------------------------------------------  
def get_day_of_month
  # Get the day of the year
  day = get_day_of_year.to_i
  # Reset tally
  tally = 0
  # Sort through the month array
  for month in @array_month
    # Escape loop if day exceeds accumulated month day total
    break if day.to_i <= month[0].to_i
    # Increase value by days in month
    tally += month[2]
  end
  # Subtract tally from day of the year
  day -= tally
  return day.to_s
end  
#--------------------------------------------------------------------------
# * Return the light setting name
#--------------------------------------------------------------------------    
def get_light_setting_name
  return @array_light[(get_light_setting_number.to_i)-1][0]
end
#--------------------------------------------------------------------------
# * Return the light setting
#--------------------------------------------------------------------------  
def get_light_setting_number
  # Reset Tally
  tally = 0
  # Sort through the lighting array
  for light in @array_light
    # Increase value by 1
    tally += 1
    # Escape loop if hour range is found
    break if @clock_hours >= light[1] and @clock_hours <= light[2]
  end    
  return tally.to_s
end
#--------------------------------------------------------------------------
# * Return the number of game days
#--------------------------------------------------------------------------  
def get_year
  return (@total_years + DN_Start_Year).to_s
end
#--------------------------------------------------------------------------
# * Return the number of game days
#--------------------------------------------------------------------------
def get_total_days
  return @total_days.to_s
end
#--------------------------------------------------------------------------
# * Adjust Seconds
#     seconds : seconds
#--------------------------------------------------------------------------
def adjust_seconds(seconds = 0)
  @calc_offset += seconds
end
#--------------------------------------------------------------------------
# * Adjust Minutes
#     minutes : minutes
#--------------------------------------------------------------------------
def adjust_minutes(minutes = 0)
  @calc_offset += minutes * @sum_minutes
end
#--------------------------------------------------------------------------
# * Adjust Hours
#     hours : hours
#--------------------------------------------------------------------------
def adjust_hours(hours = 0)
  @calc_offset += hours * @sum_hours
end  
#--------------------------------------------------------------------------
# * Adjust Days
#     days : days
#--------------------------------------------------------------------------
def adjust_days(days = 0)
  @calc_offset += days * @sum_days
end
#--------------------------------------------------------------------------
# * Adjust Years
#     years : years
#--------------------------------------------------------------------------
def adjust_years(years = 0)
  @calc_offset += years * @sum_year
end  
#--------------------------------------------------------------------------
# * Time
#--------------------------------------------------------------------------
# Formats the time string  
def time
  # Formats 12-hour clock
  if DN_Clock_System
    # If bottom half of the day (PM)
    if @clock_hours > (DN_By_Hours/2)-1
      # Garner current hour (hour - the hour max)
      # and reset '0' to 1/2 of the hour cap if appropriate
      clock_ampm  = @clock_hours - (DN_By_Hours/2)
      clock_ampm  = (DN_By_Hours/2)  if clock_ampm == 0
      # Format the time
      time = sprintf("%02d:%02d" +" "+DN_DayTag_2, clock_ampm, @clock_minutes)
      # Return the string
      return time
    # If upper half of the day (AM)  
    else
      # Garner current Hour
      # and reset '0' hour to 1/2 the hour cap if appropriate
      clock_ampm  = @clock_hours
      clock_ampm  = (DN_By_Hours/2)  if clock_ampm == 0
      # Format the time
      time = sprintf("%02d:%02d" +" "+DN_DayTag_1, clock_ampm, @clock_minutes)
      # Return the string
      return time
    end
  # Formats 24-hour clock
  else
    # Garner current Hour and reset '0' hour to the hour cap if appropriate
    clock_ampm  = @clock_hours
    clock_ampm  = DN_By_Hours  if clock_ampm == 0
    # Format the time
    time = sprintf("%02d:%02d" + " ", clock_ampm, @clock_minutes)
    # Return the string
    return time
  end
end
#--------------------------------------------------------------------------
# * Frame Update (when updating the screen tint)
#--------------------------------------------------------------------------
def update_tint
  # Update if an outside map is beginning a tint change
  if $game_temp.outside_array[$game_map.map_id] and $game_time.pause_tint == false
    # Sort through the lighting array
    for light in @array_light
      # Perform if within a recognized hour range
      if @clock_hours >= light[1] and @clock_hours <= light[2]
        # Change the tone
        $game_screen.start_tone_change(Tone.new(light[3],light[4],light[5],light[6]),light[7])
        $game_time_current_tone = Tone.new(light[3],light[4],light[5],light[6])
      end
    end
  # Or the tone is normal
  else
    $game_time_current_tone = Tone.new(0,0,0,0)
  end
end
#--------------------------------------------------------------------------
# * Instant screen tinting
#--------------------------------------------------------------------------
def instant_tint
  # Perform if an outside map is beginning a tint change
  if $game_temp.outside_array[$game_map.map_id] and $game_time.pause_tint == false
    # Set tone change flag
    $game_time.manual_tint = false
    # Sort through the lighting array
    for light in @array_light
      # Perform if within a recognized hour range
      if @clock_hours >= light[1] and @clock_hours <= light[2]
        # Change the tone
        $game_screen.start_tone_change(Tone.new(light[3],light[4],light[5],light[6]),0)
        $game_time_current_tone = Tone.new(light[3],light[4],light[5],light[6])
      end
    end
  else
    # Prevent reset if changing the tone
    if $game_time.manual_tint == false
      $game_screen.start_tone_change(Tone.new(0,0,0,0),0)
      $game_time_current_tone = Tone.new(0,0,0,0)
    end
  end
end
#--------------------------------------------------------------------------
# * Change the weather
#--------------------------------------------------------------------------
def change_weather
  # Turn switch back off
  @clock_changed = false
  # Turn off if weather system is off
  return unless $game_system.dn_weather_on == true
  # Create weather array
  weather = []
  # Obtain current month and matching weather pattern
  unless DN_Weather_Month.nil?
    month   = get_month_number.to_i
    weather = DN_Weather_Month[month]  if DN_Weather_Month.include?(month)
  end
  # Obtain current day and matching weather pattern
  unless DN_Weather_Daily.nil?
    mm  = sprintf("%2.2d", get_month_number.to_i)
    dd  = sprintf("%2.2d", get_day_of_month.to_i)
    day = mm+dd
    weather = DN_Weather_Daily[day]    if DN_Weather_Daily.include?(day)
  end
  # Obtain current date and matching weather pattern
  unless DN_Weather_Calen.nil?
    yy  = sprintf("%4.4d", get_year.to_i)
    mm  = sprintf("%2.2d", get_month_number.to_i)
    dd  = sprintf("%2.2d", get_day_of_month.to_i)
    cal = yy+mm+dd
    weather = DN_Weather_Calen[cal]    if DN_Weather_Calen.include?(cal)
  end
  # Return nil weather if no valid weather pattern
  return $game_screen.weather(0, 0, 0) if weather == []
  # Set chance of effect
  chance = rand(100)
  # If the weather's chance succeeds...
  if chance < weather[0]
    @weather_type     = weather[1]
    @weather_power    = weather[2]
    @weather_duration = weather[3]
    update_weather
  else
    @weather_type     = 0
    @weather_power    = 0
    @weather_duration = weather[3]
    update_weather
  end
end
#--------------------------------------------------------------------------
# * Update Weather
#     new_map    : if switching to a new map
#     new_map_id : id of the new map if switching to one
#--------------------------------------------------------------------------
def update_weather(new_map = false, new_map_id = 0)
  map_id = $game_map.map_id
  map_id = new_map_id if new_map
  if $game_temp.outside_array[map_id]
    # If transported to a new map, weather is already going.
    if new_map
      $game_screen.weather(@weather_type, @weather_power, 0)
    # Otherwise, duration values work
    else
      $game_screen.weather(@weather_type, @weather_power, @weather_duration)
    end
  else
    if $game_system.dn_weather_on == nil
      $game_screen.weather(@weather_type, @weather_power, @weather_duration)
    else
      $game_screen.weather(0, 0, 0)  
    end
  end
end
end



#==============================================================================
# ** Interpreter
#------------------------------------------------------------------------------
#  This interpreter runs event commands. This class is used within the
#  Game_System class and the Game_Event class.
#==============================================================================

class Interpreter
#--------------------------------------------------------------------------
# * Change Screen Color Tone
#--------------------------------------------------------------------------
alias dn_Interpreter_command_223 command_223
def command_223
  # Manual Tone Adjustment flag is true
  $game_time.manual_tint = true
  # Perform the original call
  return dn_Interpreter_command_223
end
#--------------------------------------------------------------------------
# * Set Weather Effects
#--------------------------------------------------------------------------
alias dn_Interpreter_command_236 command_236
def command_236
  # Set Script Weather feature Off
  $game_system.dn_weather_on = nil
  # Save values
  if DN_Map_Weather_Save
    $game_time.weather_type     = @parameters[0]
    $game_time.weather_power    = @parameters[1]
    $game_time.weather_duration = @parameters[2]
  end
  # Perform the original call
  return dn_Interpreter_command_236
end  
end



#==============================================================================
# ** Scene_Title
#------------------------------------------------------------------------------
#  This class performs title screen processing.
#==============================================================================

class Scene_Title
#--------------------------------------------------------------------------
# * Command: New Game
#--------------------------------------------------------------------------
alias dn_command_new_game command_new_game
def command_new_game  
  # Make the $game_time object
  $game_time=Game_Time.new
  # Perform the original call
  dn_command_new_game
end
#--------------------------------------------------------------------------
# * Battle Test
#--------------------------------------------------------------------------
alias dn_battle_test battle_test
def battle_test
  # Make the $game_time object
  $game_time=Game_Time.new
  # Perform the original call
  dn_battle_test
end

end  



#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs map screen processing.
#==============================================================================

class Scene_Map
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------  
alias dn_scene_map_update update
def update
  # Perform the original call
  dn_scene_map_update
  # Update the tint
  $game_time.update_tint
end  
#--------------------------------------------------------------------------
# * Battle Call
#--------------------------------------------------------------------------
alias dn_call_battle call_battle
def call_battle
  # If battle system also tints with the day
  if DN_Battle_Tint == false
    $game_time.pause_tint = true
    $game_screen.start_tone_change(Tone.new(0,0,0,0),0)
  end
  # Perform the original call
  dn_call_battle
end
#--------------------------------------------------------------------------
# * Player Place Move
#--------------------------------------------------------------------------
alias dn_transfer_player transfer_player
def transfer_player
  # If move destination is different than current map
  if $game_map.map_id != $game_temp.player_new_map_id
    $game_time.update_weather(true, $game_temp.player_new_map_id)
  end
  # Perform the original call
  dn_transfer_player
end
end



#==============================================================================
# ** Scene_Save
#------------------------------------------------------------------------------
#  This class performs save screen processing.
#==============================================================================

class Scene_Save < Scene_File
#--------------------------------------------------------------------------
# * Write Save Data
#     file : write file object (opened)
#--------------------------------------------------------------------------  
alias dn_write_save_data write_save_data
def write_save_data(file)
  # Perform the original call
  dn_write_save_data(file)
  # Write the $game_time object
  Marshal.dump($game_time, file)
end
end  



#==============================================================================
# ** Scene_Load
#------------------------------------------------------------------------------
#  This class performs load screen processing.
#==============================================================================

class Scene_Load < Scene_File
#--------------------------------------------------------------------------
# * Read Save Data
#     file : file object for reading (opened)
#--------------------------------------------------------------------------  
alias dn_read_save_data read_save_data
def read_save_data(file)
  # Perform the original call
  dn_read_save_data(file)
  # Read the $game_time object
  $game_time = Marshal.load(file)
  # Set weather pattern to loaded one
  $game_time.update_weather
end
end



#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle
#--------------------------------------------------------------------------
# * Battle Ends
#     result : results (0:win 1:lose 2:escape)
#--------------------------------------------------------------------------
alias dn_battle_end battle_end
def battle_end(result)
  # Reset the pause flag
  $game_time.pause_tint = false
  # Perform the original call
  dn_battle_end(result)
end
end

Ver el tema anterior Ver el tema siguiente Volver arriba  Mensaje [Página 1 de 1.]

Permisos de este foro:
No puedes responder a temas en este foro.