Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

AOE ( Area of Event )

Status
Not open for further replies.
:please:
Hello All,
I am making a game that uses just one map. Yes I know it's stupid because it will lead to serious lag, but I have to or else one of my scripts won't work ( Tricksters Time System only works for the starting map for me, if you go to another it turns itself off ). So since I have this problem, I need a script that...

~ When the player is within a certian # of Squares the event is active ( the player is 11 squares away, the event isn't there, but gets 10 squares away and it appears )
~ When the player get far away ( lets say he goes 10 squares away, the event stops, or erases )
~ I don't want it to go away permentantly if you go out of range

Thanks for reading this :)

Hope someone can fill my request!
 
Code:
=begin
==============================================================================
 ●● Time System
------------------------------------------------------------------------------
 Trickster (tricksterguy@hotmail.com) (based on Deke's Version)
 Version 2.0
 Date 3/22/07
------------------------------------------------------------------------------
Introduction:
-------------
 And who said I only create scripts for battle systems, yeah that's right 
 This is a map system. This allows your game to have time. 
 Also includes a simple Day Night System. And Also you can setup events 
 that happen at a certain time (ex. at 0 to 6 minutes past each hour, or on 
 Tuesday March 20, 2007 at 3:00 PM to 4:00 the same day and year), 
 This script wasn't meant to be an exact copy of our calendar as it is not 
 accurate
------------------------------------------------------------------------------
Features:
---------
  * Simple
  * Can Set Time to a certain hour, minute, month, day, year
  * Can Speed up or slow down time
  * Can Disable Tinting
  * Tinting is disabled on inside maps
  * Can Setup Initial time
  * Can redefine the time system
  * Includes a Time HUD
------------------------------------------------------------------------------
Insrutctions:
-------------
  - If your map is in the inside of something add an [I] to its name so the
  Day Night toning is disabled
  - If you want to disable day night toning completely do this in a call script
  $game_time.tone_enabled = false and that will disable it
  - To Change the time just call $game_time.(value) = time replace (value) with
  either minute, hour, day, month or year and time is the new time
  - To Move Time forword just call $game_time.(value) += time replace (value)
  with either minute, hour, day, month, or year and time is the time to move 
  forward by
  
To Setup A Event's Time Condition:
----------------------------------
  - Use an Event Comment that says Time_Setup
  - To set the minutes the event is to happen type
      start_minute (minute)
      end_minute (minute)
    and that setups the event to happen starting at start_minute and ending at
    end_minute.
  - To set the other parameters (hours, days, months, and years) follow the 
    above but use start_hour and end_hour for hours, start_day and end_day for
    days, start_month and end_month for months, and start_year and end_year for
    years.
  - There are also two other parameters on_day and on_month which checks if it
    is on a day.
==============================================================================
=end
#--------------------------------------------------------------------------
# * Begin SDK Log
#--------------------------------------------------------------------------
SDK.log('Time System', 'Trickster', 2.0, '3.22.07')
#--------------------------------------------------------------------------
# * Begin SDK Enable Test
#--------------------------------------------------------------------------
if SDK.enabled?('Time System')
  
module Time_Setup
  #--------------------------------------------------------------------------
  # * Minute Length
  #   - How Many Seconds are in a Minute?
  #--------------------------------------------------------------------------
  Minute = 2
  #--------------------------------------------------------------------------
  # * Hour Length
  #   - How Many Minutes are in a Hour?
  #--------------------------------------------------------------------------
  Hour = 60
  #--------------------------------------------------------------------------
  # * Day Length
  #   - How Many Hours are in a Day?
  #--------------------------------------------------------------------------
  Day = 24
  #--------------------------------------------------------------------------
  # * Month Length
  #   - How Many Days are in a Month?
  #--------------------------------------------------------------------------
  Month = 30
  #--------------------------------------------------------------------------
  # * Year Length
  #   - How Many Months are in a Year?
  #--------------------------------------------------------------------------
  Year = 12
  #--------------------------------------------------------------------------
  # * Starting Time
  #   - Year, Month, Day, Hour, Minute
  #--------------------------------------------------------------------------
  Time = 2007, 3, 23, 10, 0
  #--------------------------------------------------------------------------
  # * Days of the Week
  #--------------------------------------------------------------------------
  Days = %W( Sunday Monday Tuesday Wednesday Thursday Friday Saturday )
  #--------------------------------------------------------------------------
  # * Months of the Year
  #--------------------------------------------------------------------------
  Months = %W( Janurary Feburary March April May June July August September
  October November December )
  #--------------------------------------------------------------------------
  # * Time Format
  #   0 - HHMM 1 - HH:MM 2 - HH:MM AM / PM (Splits Day Rate in Half)
  #--------------------------------------------------------------------------
  Time_Format = 2
  #--------------------------------------------------------------------------
  # * Morning
  #   - When is it Morning?
  #   - Default - Defined as 5AM to 12PM
  #--------------------------------------------------------------------------
  Morning = proc {|hour| hour >= 5 && hour < 12}
  #--------------------------------------------------------------------------
  # * Afternoon
  #   - When is it Afternoon?
  #   - Default - Defined as 12PM to 6PM
  #--------------------------------------------------------------------------
  Afternoon = proc {|hour| hour >= 12 && hour < 18}
  #--------------------------------------------------------------------------
  # * Evening
  #   - When is it Evening?
  #   - Default - Defined as 6PM to 10PM
  #--------------------------------------------------------------------------
  Evening = proc {|hour| hour >= 18 && hour < 22}
  #--------------------------------------------------------------------------
  # * Night
  #   - When is it Night time?
  #   - Default - Defined as 10PM to 5AM
  #--------------------------------------------------------------------------
  Night = proc {|hour| hour >= 22 && hour < 5}
  #--------------------------------------------------------------------------
  # * Time Effect
  #   0 - Wait (In Map Only) 1 - Wait2 (In Map in Battle) 2 - Active
  #--------------------------------------------------------------------------
  Time_Effect = 2
  #--------------------------------------------------------------------------
  # * Tone Enabled (At Start of Game)
  #--------------------------------------------------------------------------
  Tone_Enabled = true
  #--------------------------------------------------------------------------
  # * Time Speed (At Start of Game)
  #--------------------------------------------------------------------------
  Speed = 1
  #--------------------------------------------------------------------------
  # * Time Stopped (At Start of Game)
  #--------------------------------------------------------------------------
  Stopped = false
  #--------------------------------------------------------------------------
  # * Time Stopped During Events
  #--------------------------------------------------------------------------
  Stopped_Events = true
  #--------------------------------------------------------------------------
  # * Time Stopped Maps
  #   - syntax map_id => stopped flag true: stopped time false: otherwise
  #--------------------------------------------------------------------------
  Stopped_Maps = {}
  #--------------------------------------------------------------------------
  # * Time Stopped Maps Default
  #--------------------------------------------------------------------------
  Stopped_Maps.default = false
  #--------------------------------------------------------------------------
  # * Increase Speed up Time Maps
  #   - syntax map_id => speed
  #--------------------------------------------------------------------------
  Speed_Maps = {}
  #--------------------------------------------------------------------------
  # * Increase Speed up Time Maps Default
  #--------------------------------------------------------------------------
  Speed_Maps.default = 0
  #--------------------------------------------------------------------------
  # * Tone Disabled Maps
  #   - syntax map_id => disabled flag true: disabled false: enabled
  #--------------------------------------------------------------------------
  Tone_Disabled = {2 => true}
  #--------------------------------------------------------------------------
  # * Tone Disabled Maps Default
  #--------------------------------------------------------------------------
  Tone_Disabled.default = false
end

class Game_Time
  #--------------------------------------------------------------------------
  # * Include Time Setup
  #--------------------------------------------------------------------------
  include Time_Setup
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :minute_length
  attr_accessor :stop
  attr_accessor :speed
  attr_accessor :tone_enabled
  attr_accessor :stopped_event
  attr_writer :map_stop
  attr_writer :map_speed
  attr_reader :minutes
  attr_reader :hours
  attr_reader :days
  attr_reader :months
  attr_reader :years
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # Initialize Minute Length
    @minute_length = Minute
    # Setup Tone Disabled Flag
    @tone_enabled = Tone_Enabled
    # Time Stopped Setup
    @stop = Stopped
    # Setup Speed Multiplier
    @speed = Speed
    # Setup Stopped Event
    @stopped_event = Stopped_Events
    # Setup initial time
    @minutes = 0
    @hours = 0
    @days = 0
    @months = 0
    @years = 0
    # Add Minutes
    self.minutes += Time[4]
    # Add Hours
    self.hours += Time[3]
    # Add Days
    self.days += Time[2]
    # Add Months
    self.months += Time[1]
    # Add Years
    self.years += Time[0]
    # Setup Counter
    @counter = 0
  end
  #--------------------------------------------------------------------------
  # * Minutes
  #--------------------------------------------------------------------------
  def minutes=(minutes)
    # Set Minutes
    @minutes = minutes
    # Update Time
    update_time
  end
  #--------------------------------------------------------------------------
  # * Hours
  #--------------------------------------------------------------------------
  def hours=(hours)
    # Set Hours
    @hours = hours
    # Update Time
    update_time
  end
  #--------------------------------------------------------------------------
  # * Days
  #--------------------------------------------------------------------------
  def days=(days)
    # Set Days
    @days = days
    # Update Time
    update_time
  end
  #--------------------------------------------------------------------------
  # * Months
  #--------------------------------------------------------------------------
  def months=(months)
    # Set Months
    @months = months
    # Update Time
    update_time
  end
  #--------------------------------------------------------------------------
  # * Years
  #--------------------------------------------------------------------------
  def years=(years)
    # Set Years
    @years = years
    # Update Time
    update_time
  end
  #--------------------------------------------------------------------------
  # * Total Minutes
  #--------------------------------------------------------------------------
  def total_minutes
    return @minutes + total_hours * Hour
  end
  #--------------------------------------------------------------------------
  # * Total Hours
  #--------------------------------------------------------------------------
  def total_hours
    return @hours + total_days * Day
  end
  #--------------------------------------------------------------------------
  # * Total Days
  #--------------------------------------------------------------------------
  def total_days
    return @days + total_months * Month
  end
  #--------------------------------------------------------------------------
  # * Total Months
  #--------------------------------------------------------------------------
  def total_months
    return @months + total_years * Year
  end
  #--------------------------------------------------------------------------
  # * Total Years
  #--------------------------------------------------------------------------
  def total_years
    return @years
  end
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update
    # Return if time stopped
    return if @stop || @map_stop
    # Increase Counter
    @counter += 1
    # Return if not @minute_length seconds passed
    return if @counter / Graphics.frame_rate.to_f < @minute_length
    # Reset Counter
    @counter = 0
    # Add One Minute
    @minutes += @speed + (@map_speed.nil? ? 0 : @map_speed)
    # Update Time
    update_time
  end
  #--------------------------------------------------------------------------
  # * Update Time
  #--------------------------------------------------------------------------
  def update_time
    # Add To Amounts
    @hours += @minutes / Hour
    @days += @hours / Day
    @months += @days / Month
    @years += @months / Year
    # Restrict to [0, Max]
    @minutes %= Hour
    @hours %= Day
    @days %= Month
    @months %= Year
  end
  #--------------------------------------------------------------------------
  # * Is Morning?
  #--------------------------------------------------------------------------
  def is_morning?
    return Morning.call(hours)
  end
  #--------------------------------------------------------------------------
  # * Is Afternoon?
  #--------------------------------------------------------------------------
  def is_afternoon?
    return Afternoon.call(hours)
  end
  #--------------------------------------------------------------------------
  # * Is Evening?
  #--------------------------------------------------------------------------
  def is_evening?
    return Evening.call(hours)
  end
  #--------------------------------------------------------------------------
  # * Is Night?
  #--------------------------------------------------------------------------
  def is_night?
    return Night.call(hours)
  end
  #--------------------------------------------------------------------------
  # * Time
  #--------------------------------------------------------------------------
  def time
    # Get Number of Digits
    digits = Math.log10(Hour).to_i + 1
    # Branch By Time Format
    case Time_Format
    when 0 #HHMM
      time = hours.to_s + sprintf("%0#{digits}d", minutes)
    when 1 #HH:MM
      time = hours.to_s + sprintf(":%0#{digits}d", minutes)
    when 2 #HH:MM AM/PM
      # Restrict to [0, Day / 2 - 1]
      hour = hours % (Day / 2)
      # Set to Day / 2 if 0
      hour = Day / 2 if hour == 0
      # Get Time
      time = hour.to_s + sprintf(":%0#{digits}d", minutes)
      # Get AM and PM Text
      time += ' ' + (hours >= Day / 2 ? 'PM' : 'AM')
    end
    # Return String
    return time
  end
  #--------------------------------------------------------------------------
  # * Full Time
  #--------------------------------------------------------------------------
  def full_time
    # Get Number of Digits
    digits = Math.log10(Hour).to_i + 1
    # Get Year String
    year = self.years.to_s
    # Get Month String
    month = current_month
    # Get Day of Week
    day_name = current_day
    # Get Day
    day = self.days.to_s
    # Branch By Time Format
    case Time_Format
    when 0 #HHMM
      time = hours.to_s + sprintf("%0#{digits}d", minutes)
    when 1 #HH:MM
      time = hours.to_s + sprintf(":%0#{digits}d", minutes)
    when 2 #HH:MM AM/PM
      # Restrict to [0, Day / 2 - 1]
      hour = hours % (Day / 2)
      # Set to Day / 2 if 0
      hour = Day / 2 if hour == 0
      # Get Time
      time = hour.to_s + sprintf(":%0#{digits}d", minutes)
      # Get AM and PM Text
      time += ' ' + (hours >= Day / 2 ? 'PM' : 'AM')
    end
    # Return String
    return "#{time} #{day_name}, #{month} #{day}, #{year}"
  end
  #--------------------------------------------------------------------------
  # * Current Day
  #--------------------------------------------------------------------------
  def current_day
    return Days[total_days.to_i % Days.size]
  end
  #--------------------------------------------------------------------------
  # * Current Month
  #--------------------------------------------------------------------------
  def current_month
    return Months[total_months.to_i % Months.size]
  end
  #--------------------------------------------------------------------------
  # * Tone - Deke for Original Formula
  #--------------------------------------------------------------------------
  def tone
    period_length = Math::PI * (hours.to_f / Day)
    red_shift = -100 + 115 * Math.sin(period_length)
    green_shift = -140 + 155 * Math.sin(period_length)
    blue_shift = -150 + 165 * Math.sin(period_length)
    return Tone.new(red_shift, green_shift, blue_shift, 0)
  end
end 
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end
I also use the Addons MACL, MapInfo Script, and Time HUD Addon.
Even in you're demo, when I talk to the girl and she says, "Wanna go inside?" I say yes and everything turns light, and the toning stops, but the time continues. THen I go back out and the tone goes back to what time it is.
I also use:
Regular
Reflection - Rataime
Slipknots Advanced Message System - Slipknot
Weather Script - Ccoa
Fishing -GoldenShadow
SDK
SDK 2.2 I II III IV
MeisMe's Realistic Shop - MeisMe
Item System Diablo Style - DarkSchneider
Scene Introduction - rpgmaker
Mail Client v1.1 - GoldenShadow
NPC Interactions - Near Fantastica
Anti Event Lag Script - Near Fantastica
Quick Treasure Chest - SephirothSpawn
Particle Engine - Near Fantastica
Input Script v2 - Cybersam
 
You probably missed this

Code:
  #--------------------------------------------------------------------------
  # * Tone Disabled Maps
  #   - syntax map_id => disabled flag true: disabled false: enabled
  #--------------------------------------------------------------------------
  Tone_Disabled = {2 => true}
 
Lol, now I feel stupid, I never understood what it did, but since you pointed it out I tried changing the numbers and nothing happened.. so then I left it 2 but changed true to false and now it works for diffrent maps. It would still be nice for the AOE, but I don't HAVE to have it anymore.

Thanks for you're help.
 
Ok what that option does is disable the day/night toning for certain maps (like if you have a map that is inside a building you wouldn't want the tones to occur in there :p)

Well if you need anymore help just post in the topic

This topic has been resolved. If Sir Hiro or any other users have any questions or further problems regarding this topic, please create a new thread about them.

Thank you!
 
Status
Not open for further replies.

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top