[XP] Advanced Time and Environment System

Started by fugibo, March 09, 2008, 11:08:36 pm

Previous topic - Next topic

Blizzard

New game or saved game? What did you do to cause it? Are your scripts in the right order? (Lol, who am I asking?! xD) Do you have the clock turned on or off?
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Shadonking

the clock is turned off when i get the error (i havent tried is with in on yet)

its a new game and i have no save files any way

and yep my scripts are in the right order ( i check all the time)





Creator Of Music And Games
Spoiler: ShowHide
]

keywords: ShowHide
rmxp rmvx blizz-abs rpg maker xp vx abs cbs cms script tons of addons charsets autotiles HUD


come here if you have a ps3
http://forum.chaos-project.com/index.php?topic=1952.0

Blizzard

April 13, 2009, 04:56:22 pm #62 Last Edit: April 13, 2009, 05:06:07 pm by Blizzard
The order question was rhethorical. xD I'll look into it in a couple of minutes. Expect v0.32 in a few minutes then.

EDIT: Done.

@WcW: Are you gonna continue working on this?
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Shadonking






Creator Of Music And Games
Spoiler: ShowHide
]

keywords: ShowHide
rmxp rmvx blizz-abs rpg maker xp vx abs cbs cms script tons of addons charsets autotiles HUD


come here if you have a ps3
http://forum.chaos-project.com/index.php?topic=1952.0

Blizzard

I think that you didn't copy the script properly or that you got a cached version. Press F5 in the window where you usually copy the script to paste it into your window editor. It clearly takes 2 arguments in the version I uploaded. Only my dev version has a 5 argument constructor.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Shadonking

nope i copied it correctly, and i pressed F5 but all it does is it goes to the next script.





Creator Of Music And Games
Spoiler: ShowHide
]

keywords: ShowHide
rmxp rmvx blizz-abs rpg maker xp vx abs cbs cms script tons of addons charsets autotiles HUD


come here if you have a ps3
http://forum.chaos-project.com/index.php?topic=1952.0

Blizzard

Can you post the ATES you are using? Something's wrong here.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

nathmatt

Quote from: TheHackMan on August 15, 2008, 04:52:59 pm
I just tried out the script and whenever I have it turn on with
Call Script: ATES.on
I end up with ArgumentError on line 353
"wrong number of arguments(5 for 2)"

It would seem line 353 is:
      ATES.advance(1, 0, 0, 0, 0) if @frame_count % (ATES::LENGTH / 36) == 0

When I change it to:
      ATES.advance(1, 0) if @frame_count % (ATES::LENGTH / 36) == 0
Then it works without any problems
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


Shadonking

April 14, 2009, 02:25:03 pm #68 Last Edit: April 14, 2009, 02:27:12 pm by Shadonprincess
im using the one in the download link

here

Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Advanced Time and Environment System (ATES) by Blizzard
# Version: 0.32
# Type: Autonomous Timeflow and Environment Controller
# Date v0.3: 11.3.2008
# Date v0.31: 8.4.2008
# Date v0.32: 13.4.2008
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#  
#  This work is protected by the following license:
# #----------------------------------------------------------------------------
# # 
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# # 
# #  You are free:
# # 
# #  to Share - to copy, distribute and transmit the work
# #  to Remix - to adapt the work
# # 
# #  Under the following conditions:
# # 
# #  Attribution. You must attribute the work in the manner specified by the
# #  author or licensor (but not in any way that suggests that they endorse you
# #  or your use of the work).
# # 
# #  Noncommercial. You may not use this work for commercial purposes.
# # 
# #  Share alike. If you alter, transform, or build upon this work, you may
# #  distribute the resulting work only under the same or similar license to
# #  this one.
# # 
# #  - For any reuse or distribution, you must make clear to others the license
# #    terms of this work. The best way to do this is with a link to this web
# #    page.
# # 
# #  - Any of the above conditions can be waived if you get permission from the
# #    copyright holder.
# # 
# #  - Nothing in this license impairs or restricts the author's moral rights.
# # 
# #----------------------------------------------------------------------------
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Compatibility:
#
#   99% compatible with SDK v1.x. 90% compatible with SDK 2.x. WILL corrupt old
#   savegames. Can cause incompatibilty issues with DNS-es.
#
#
# Features:
#
#   - complete control over and easy manipulating of time
#   - nice day and night tinting
#   - HUD clock optional
#   - easier to control and more powerful than DDNS
#
#
# IMPORTANT NOTES:
#
# - This system has a working preconfiguration, be aware that a custom setup
#   will need you to understand what each option does, so please read the
#   configuration instructions.
# - Why does this system use switches to determine whether it's day or night?
#   Simple: You can use conditions in enemy attacks to determine whether an
#   attack should be used only at night or only at day.
#
#
# Instructions:
#
# - Explanation:
#
#   This Time System will make your game have daytime and nighttime periods.
#   The screen will be tinted accordingly. You can set up the length of the
#   day. Other features are explained below. Please be sure to configure this
#   system appropriately.
#
#
# - Basic manipulation of ATES:
#
#   This system is based upon your eventing. It will work basically if you
#   want, but with a little bit of using the "Call Script" event command you
#   are able to control this system fully. You can call following commands:
#
#     ATES.on
#   Turns ATES on.
#
#     ATES.off
#   Turns ATES off.
#
#     ATES.tint_on
#   Turns ATES's screen tinting on.
#
#     ATES.tint_off
#   Turns ATES's screen tinting off.
#
#     ATES.active?
#   Returns true if ATES is turned on, otherwise false.
#
#     ATES.tinting?
#   Returns true if ATES tinting is turned on, otherwise false.
#
#     ATES.day?
#   Returns true if it's day, otherwise false. Alternatively you can check the
#   assigned switch instead.
#
#     ATES.night?
#   Returns true if it's night, otherwise false. Alternatively you can check
#   the assigned switch instead.
#  
#     ATES.advance(M, H)
#   This will make the time advanced by M minutes and H hours. Any negative
#   value used will cancel the execution of this command.
#  
#     ATES.make_it_day
#   This is a feature from DDNS which allows you to quickly jump to the
#   daytime.
#  
#     ATES.make_it_night
#   This is a feature from DDNS which allows you to quickly jump to the
#   nighttime.
#  
#
# - Enhancement hints:
#
#   If you wish to implement the DDNS further into your game and e.g. allow
#   different behavious of monsters during day and night, you only need to
#   check the the state of the appropriate switch. e.g. If NSWITCH is turned
#   on inflict "Sleep" on one enemy.
#
#
# Additional info:
#
#   The daytime and nighttime tintings were tested appropriately and optimal
#   tinting is being used.
#   Keep in mind that ATES is initially turned off, you need to turn it on by
#   using the ATES.on and ATES.tint_on commands together.
#
#
# If you find any bugs, please report them here:
# http://forum.chaos-project.com
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

module ATES
 
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  # switch ID of the "day" switch
  DSWITCH = 51
  # switch ID of the "night" switch
  NSWITCH = 52
  # length of a day in seconds in-game, can't be less than 36, is being
  # quantized into intervals of 36 seconds
  LENGTH = 360
  # how much time is it when the "day" starts
  DAY_START = 8
  # how much time is it when the "night" starts
  NIGHT_START = 20
  # makes the screen brighter during "summer" days
  OVERLIGHTING = true
  # makes the screen darker during the night, not recommended
  OVERDARKENING = true
  # display HUD clock
  SHOW_CLOCK = false
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
  $ates = 0.32
 
  #============================================================================
  # ATES::Time
  #============================================================================
 
  class Time
   
    attr_accessor :min
    attr_accessor :hour
   
    def initialize(m, h)
      @min, @hour = m, h
    end
   
  end
 
  def self.on
    $game_system.ates.active = true
    return true
  end
 
  def self.off
    $game_system.ates.active = false
    return true
  end
 
  def self.tint_on
    $game_system.ates.tinting = true
    return true
  end
 
  def self.tint_off
    $game_system.ates.tinting = false
    return true
  end
 
  def self.active?
    return $game_system.ates.active
  end
 
  def self.tinting?
    return $game_system.ates.tinting
  end
 
  def self.day?
    return ($game_system.ates.time.hour.between?(DAY_START, NIGHT_START - 1))
  end
 
  def self.night?
    return (!self.day)
  end
 
  def self.make_it_day
    $game_system.ates.time.hour = DAY_START
    $game_system.ates.time.min = 0
    return true
  end
 
  def self.make_it_night
    $game_system.ates.time.hour = NIGHT_START
    $game_system.ates.time.min = 0
    return true
  end
 
  def self.day_start
    return DAY_START
  end
 
  def self.night_start
    return NIGHT_START
  end
 
  def self.advance(m, h)
    return false if [m, h].any? {|i| i < 0}
    h += ($game_system.ates.time.min + m) / 60
    $game_system.ates.time.min = ($game_system.ates.time.min + m) % 60
    $game_system.ates.time.hour = ($game_system.ates.time.hour + h) % 24
    return true
  end
 
end

if ATES::DAY_START > ATES::NIGHT_START
  raise 'ATEScfgError: A night can\'t start earlier than a day.'
elsif ATES::LENGTH < 36
  raise 'ATEScfgError: A day\'s length must be equal to or greater than 36 seconds!'
end

#==============================================================================
# Game_System
#==============================================================================

class Game_System
 
  attr_accessor :ates
  attr_accessor :show_clock
 
  alias init_ates_later initialize
  def initialize
    init_ates_later
    @ates = Game_ATES.new
    @show_clock = ATES::SHOW_CLOCK
  end

end

#==============================================================================
# Game_ATES
#==============================================================================

class Game_ATES
 
  attr_accessor :active
  attr_accessor :tinting
  attr_accessor :time
  attr_accessor :frame_count
 
  def initialize
    @time = ATES::Time.new(0, 0)
    @active = false
    @tinting = false
    @frame_count = 0
  end
 
  def get_tint
    red = 0
    green = 0
    blue = 0
    grey = 0
    if ATES.day?
      red = green = 0
      day = ATES.day_start
      night = ATES.night_start
      ratio = ((@time.hour-day)*60+@time.min) * 255 / (60*(night-day))
      if ratio >= 224
        red = (232-ratio)*4
        green = (208-ratio)*2
      elsif ratio >= 192
        red = ratio-192
        green = 192-ratio
      elsif ATES::OVERLIGHTING
        if ratio >= 160
          red = green = blue = 192-ratio
        elsif ratio >= 96
          red = green = blue = 32
        elsif ratio >= 64
          red = green = blue = ratio-64
        end
      end
    else
      red = green = -96
      day = ATES.day_start
      night = ATES.night_start
      hour = (@time.hour >= night ? @time.hour : @time.hour+24)
      ratio = ((hour-night)*60+@time.min) * 255 / (60*(day+24-night))
      if ratio >= 224
        red = (ratio-256)*2
        green = (ratio-256)*2
        blue = 255-ratio
      elsif ratio >= 192
        red = ratio-288
        green = ratio-288
        blue = ratio-192
      elsif ATES::OVERDARKENING
        if ratio >= 160
          red = ratio-288
          green = ratio-288
          blue = ratio-192
        elsif ratio >= 96
          red = -128
          green = -128
          blue = -32
        elsif ratio >= 64
          red = -32-ratio
          green = -32-ratio
          blue = 64-ratio
        end
      end
    end
    return Tone.new(red, green, blue, grey)
  end
 
  def update
    if @active
      @frame_count += 1
      ATES.advance(1, 0, 0, 0, 0) if @frame_count % (ATES::LENGTH / 36) == 0
    end
    if ATES.day?
      $game_map.need_refresh = true if $game_switches[ATES::NSWITCH]
      $game_switches[ATES::DSWITCH] = true
      $game_switches[ATES::NSWITCH] = false
    else
      $game_map.need_refresh = true if $game_switches[ATES::DSWITCH]
      $game_switches[ATES::DSWITCH] = false
      $game_switches[ATES::NSWITCH] = true
    end
    $game_screen.start_tone_change(get_tint, 0) if @tinting
  end
 
end

#==============================================================================
# Bitmap
#==============================================================================

class Bitmap

  if $tons_version == nil || $tons_version < 1.6
    alias draw_text_shaded_later draw_text
  end
  def draw_text_full(x2, y2, w2 = 0, h2 = 0, text2 = '', a2 = 0)
    if x2.is_a?(Rect)
      x, y, w, h, text, a = x2.x, x2.y, x2.width, x2.height, y2, w2
    else
      x, y, w, h, text, a = x2, y2, w2, h2, text2, a2
    end
    save_color = self.font.color.clone
    self.font.color = Color.new(0, 0, 0)
    [x-1, x+1].each {|xx| [y-1, y+1].each {|yy|
            draw_text_shaded_later(xx, yy, w, h, text, a)}}
    self.font.color = save_color
    draw_text_shaded_later(x, y, w, h, text, a)
  end
 
end

#==============================================================================
# Clock_Sprite
#==============================================================================

class Clock_Sprite < Sprite
 
  def initialize
    super
    self.x, self.y, self.z = 480, 8, 5000
    self.bitmap = Bitmap.new(128, 32)
    if $fontface != nil
      self.bitmap.font.name = $fontface
    elsif $defaultfonttype != nil
      self.bitmap.font.name = $defaultfonttype
    end
    self.bitmap.font.size = 26
    @odd = 0
    draw if $game_system.ates.active
  end
 
  def draw
    self.bitmap.clear
    hours = $game_system.ates.time.hour
    minutes = sprintf('%02d', $game_system.ates.time.min)
    if @odd % 2 == 0
      self.bitmap.draw_text_full(0, 0, 128, 32, "#{hours} #{minutes}", 2)
    else
      self.bitmap.draw_text_full(0, 0, 128, 32, "#{hours}:#{minutes}", 2)
    end
    @odd = (@odd + 1) % 2
  end
   
end

#==============================================================================
# Scene_Map
#==============================================================================

class Scene_Map
 
  alias main_ates_later main
  def main
    @clock = Clock_Sprite.new if $game_system.show_clock
    main_ates_later
    @clock.dispose unless @clock == nil
  end
 
  alias update_ates_later update
  def update
    $game_system.ates.update
    update_ates_later
    @clock.draw if @clock != nil && $game_system.ates.frame_count % 40 == 0
  end
 
  alias transfer_player_ates_later transfer_player
  def transfer_player
    $game_system.ates.update
    transfer_player_ates_later
  end
 
end






Creator Of Music And Games
Spoiler: ShowHide
]

keywords: ShowHide
rmxp rmvx blizz-abs rpg maker xp vx abs cbs cms script tons of addons charsets autotiles HUD


come here if you have a ps3
http://forum.chaos-project.com/index.php?topic=1952.0

nathmatt

do what i said in my last post will fix it
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


Shadonking

April 14, 2009, 04:30:03 pm #70 Last Edit: April 14, 2009, 04:38:03 pm by Shadonprincess
okay i'll try, i didnt see your email (which is wierd becuase i should have)

edit

it works thanks, also where do i change it so it counts in 1 sec at a time becuase it does 2 (i know it can be done its just its late and my brain is turned off)





Creator Of Music And Games
Spoiler: ShowHide
]

keywords: ShowHide
rmxp rmvx blizz-abs rpg maker xp vx abs cbs cms script tons of addons charsets autotiles HUD


come here if you have a ps3
http://forum.chaos-project.com/index.php?topic=1952.0

Mightylink

May 04, 2009, 06:24:48 am #71 Last Edit: May 04, 2009, 06:28:58 am by Mightylink
Quote from: Shadonking on April 13, 2009, 05:21:34 pm
new error, 
Spoiler: ShowHide



Well you locked the other thread and told me to come here, but I tried this new script and its giving me errors :S

Same one as above, I copied it properly, ordered it the way you said in your script order thread, started a new game and made an event to call script: ATES.on

Error points to this block of code:

      @frame_count += 1
      ATES.advance(1, 0, 0, 0, 0) if @frame_count % (ATES::LENGTH / 36) == 0
    end


Other then changing the day switch to 1 and night switch to 2, i didnt change anything else <_<

Please help, so far I prefered your DDNS, it actually worked :P

Blizzard

May 04, 2009, 07:23:50 am #72 Last Edit: May 04, 2009, 07:25:37 am by Blizzard
1.

Quote# Compatibility:
#
#   99% compatible with SDK v1.x. 90% compatible with SDK 2.x. WILL corrupt old
#   savegames.
Can cause incompatibilty issues with DNS-es.


2. If you don't post the error message, I can't do shit.

3. If you give me a block of code, I can't do shit either because there could be half a million reasons in just 5 lines of code. The error ALWAYS points to 1 line. Not more, not less.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Mightylink

May 04, 2009, 07:45:47 am #73 Last Edit: May 04, 2009, 07:55:46 am by Mightylink
The error was in the spoiler, and i did start a new game 0.0 Are you ok, I havent posted any problems in a wile and you act like I bug you all the time, im sorry...

I linked the other guys screenshot cause it was the same as mine:

Spoiler: ShowHide


And I used the newest version of it, I removed the old ddns, I dont know what other info I can provide you, im really sorry if I bothered you.

Blizzard

I'm sorry. My day practically just started and it's already been a rough one. -_- And a few minutes ago I found out that I have 2 weeks to make an application that will consume at least 20 working hours while I have a blitz-exam at friday, I have to finish my hands-on seminar till monday and next week are exams. Plus I have to finish the demo of "Shaman" for the publishers and I need to learn for the exams actually. And I bet I forgot something on this list. All of that would have been fine if I didn't have to make that f*cked up application for the course "Development of Information Systems". >:/ Man, I hate that professor.

The solution is basically what nathmatt said a few posts before. Or you can redownload the script, I put up v0.33.
Again, sorry for being rude. -_-
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Mightylink

May 04, 2009, 08:52:28 am #75 Last Edit: May 04, 2009, 09:03:48 am by Mightylink
Sorry to hear about your day, I tried the new script and it seems to work now but all your other scripts are going funny on me now...

The lagless hud from tons is showing up even when I set it to hide and stormtronics now crashes, ughh i'll try to solve this on my own, I guess I have to redownload every scripts newest version again <_<

I hope you have a better day and im sorry to bug you, some things are just more important then games :P

Blizzard

Thanks. And yeah, updating the versions of my scripts would be a good idea. xD
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Mightylink

May 04, 2009, 07:13:52 pm #77 Last Edit: May 04, 2009, 07:29:01 pm by Mightylink
Well everything works now cept for 1 thing, I cant get the clock to show and hide, I am using the command mentioned a few posts ago and it is also the same one I used in the older version:

$game_system.show_clock = true


$game_system.show_clock =
false


Am I sappose to use something else now, what is it?

Oh and I love the new tinting, best ddns system out there ^_^

Blizzard

I forgot to make that work properly. I uploaded v0.34. You can do it either this way or with the new commands ATES.clock_on and ATES.clock_off.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Mightylink

May 05, 2009, 03:55:27 am #79 Last Edit: May 05, 2009, 04:14:13 am by Mightylink
I like the new commands better :)

Oh no :(

Syntax Error:

  def draw<
    self.bitmap.clear
    hours = $game_system.ates.time.hour
    minutes = sprintf('%02d', $game_system.ates.time.min)
    if @odd % 2 == 0
      self.bitmap.draw_text_full(0, 0, 128, 32, "#{hours} #{minutes}", 2)
    else
      self.bitmap.draw_text_full(0, 0, 128, 32, "#{hours}:#{minutes}", 2)
    end
    @odd = (@odd + 1) % 2
  end