Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> [Eventing]Day/Night, Seasons, Years, Pop-up Clock, Anything to do with time here.
rojse
post Jul 24 2008, 10:41 PM
Post #1


Level 19
Group Icon

Group: Revolutionary
Posts: 373
Type: None
RM Skill: Skilled




This tutorial is a day/night system with optional features such as months and years, random weather that changes according to in-game seasons, and a pop-up clock that can be activated at any time. Since the coding for the more complex ones relies on the Day/Night system, I felt it made sense to put them all into one tutorial.

I have colour-coded the tutorial so that any features you do not want to do can easily be skipped. Coding for the day/night system is normal text, the yearly cycle events are in bold, random weather events are in italics, and the pop-up clock is in both bold and italics. You can remove any or all of these features, and the others will work correctly, but having all of these adds extra features that some programmers or RPG-players may want.

To set our day/night system up, we need to go to Common Events (Tools, Database, Common Events). For our first event, we should create an event called Time Calculator. Make it a parallel processing event, and give it a switch called “Time Passing”. Turn this switch on when you want time to start updating, and turn it off while you want time to stop. The very first thing we need to do is set the time when we will first be using the event. If you don’t, your event will start at midnight.

Conditional Branch: Switch Start Time Changed == ON
Else
Switch Start Time Changed == ON
Variable Hours = Hour of start of RPG (You might want to start at 8:00am, so set this to 8)
For those implementing a yearly cycle:
Variable Days = Day of start of RPG
Variable Months = Month of start of RPG
Variable Years = Year of start of RPG.


Now, we need to set how the time progresses in the RPG.

Wait 20 Frames (1 second on RPG XP unless it is changed to run 40fps.)
Minutes + 1

For those implementing a yearly cycle:
Variable Minutes 2 + 1
Conditional Branch Minutes 2 >= 30
Variable Minutes 2 – 30
Variable Half-Hours + 1
(This is to change the length of day and night later in the coding, with a half-hour change being less obvious than a whole hour of change.)
Conditional Branch Minutes >= 60
Variable Minutes – 60
Variable Hours + 1
Conditional Branch Hours >=24
Variable Hours – 24
For those implementing a yearly cycle:
Variable Days + 1
Conditional Branch Days > 10
Variable Days – 10
Variable Months + 1
Conditional Branch Months >4
Variable Years + 1
Variable Months -4


Here, I have set up my game so that there are ten days to a month, and four months to a year. Obviously, you can change the amount of hours in a day, days in a month, and onths in a year, and it is not a large task to set up a system like the traditional European Calendar, but I felt it was not necessary for what I wished to do with my game. If you feel it is, though, just set up conditional branches based on month number and then the amount of days.

After entering the time-changing variables, you can have the time displayed by a button press if you choose. Set up a new parallel processing event, set the condition of it working identical to the time calculating event, and put this code in:

Key Input Processing: Key Input Variable
Conditional Branch: Key X pressed (A Button on keyboard)
Conditional Branch 24-Hour Time ON
(This allows users to switch between 12 hour and 24 hour display. If you prefer one over the other, just use the coding for that one style and do not put in the other style)
Conditional Branch Minutes = 0
Message: \v[hours]:00
(For those with days, months, years)
Message: \v[Years] year notation, \v[Months], \v[Days]
\v[hours]:00
Conditional Branch Minutes <= 9
(For those with days, months, years)
Message: \v[Years] year notation, \v[Months], \v[Days]
\v[hours]:0\v[Minutes
Message: \v[hours]:0\v[Minutes]
Else
(For those with days, months, years)
Message: \v[Years] year notation, \v[Months], \v[Days]
\v[hours]:\v[Minutes]
(For those with only hours)
Message: \v[hours]:\v[Minutes]
Else (24 Hour Time OFF)
Variable Operations Hours 2 = Hours
Conditional Branch Hours 2 > 12
Variable Hours 2 – 12
Conditional Branch Hours > 12
Conditional Branch Minutes = 0
(For those with days, months, years)
Message: \v[Years] year notation, \v[Months], \v[Days]
(For those with only hours)
Message: \v[hours 2]:00 pm
Conditional Branch Minutes <= 9
(For those with days, months, years)
Message: \v[Years] year notation, \v[Months], \v[Days]
\v[hours 2]:0\v[Minutes] pm
(For those with only hours)
\v[hours 2]:0\v[Minutes] pm
Else
(For those with days, months, years)
Message: \v[Years] year notation, \v[Months], \v[Days]
\v[hours 2]:\v[Minutes] pm
Else
Conditional Branch Minutes = 0
(For those with days, months, years)
Message: \v[Years] year notation, \v[Months], \v[Days]
\v[hours 2]:00 pm
Conditional Branch Minutes <= 9
(For those with days, months, years)
Message: \v[Years] year notation, \v[Months], \v[Days]
\v[hours 2]:0\v[Minutes] pm
Else
(For those with days, months, years)
Message: \v[Years] year notation, \v[Months], \v[Days]
\v[hours 2]:\v[Minutes] pm

By pressing the “X” key (default input is A button), the clock will be displayed for viewing by the player


Now that we have time changing through the day, we will want to change the picture tint depending on the time of day, so the player is able to visually tell approximately what time it is.

This is what my conditional branches look like (in RPG Maker XP, modify for 2k3 and VX as required)

Conditional Branch Hours <= 4
Tint Screen -150, -150, -100, 60 @120
Conditional Branch Hours <= 5
Tint Screen -50, -50, -25, 0 @60
Conditional Branch Hours <= 7
Tint Screen 0, 0, 0, 0 @60
Conditional Branch Hours <= 15
Tint Screen 25, 25, 0, 0 @60
Conditional Branch Hours <= 17
Tint Screen 0, 0, 0, 0 @60
Conditional Branch Hours <= 19
Tint Screen -50, -50, 0, 0 @60
Conditional Branch Hours <= 21
Tint Screen -150, -150, -100, 60 @60

Obviously, you can try and find your own desired settings should you not like these tints or transition times.

Copy these to a second common event. Make this a call event, change the transition for each to 20 frames, and call this “Going Outside.” When we wish to go outside where the day changes, we will want to automatically load the tint we require. Therefore, we will need to slightly alter the way in which we exit buildings through events.

Going Inside
Tint Screen: -255, -255, -255, @ 20
Wait 20 frames
Teleport
Switch Outside OFF
Tint Screen: 0, 0, 0, 0

Heading Outdoors
Tint Screen: -255, -255, -255, @ 20
Wait 20 frames
Teleport
Switch Outside ON
Call Event “Going Outside”

Those that are not putting in any year-based calendar or weather events can skip to the end of the tutorial.

However, for those that do, I will be using the same coding I put in my game – a three-season cycle (Long Dry, Little Death, and The Wet) with the dry season taking two months, while the others take one month each. The longest sunlight hours will take place in the first month of the Dry, while the shortest will be in the Little Death. The second month of Dry and Wet have the same length of day and night, Obviously, you can make your own seasons or take them straight from the European calendar.

Open up the Day/Night Cycle event.

For those implementing a yearly cycle:
Conditional Branch: Month ==1 (Dry season 1)
Time-Based Tinting Previously Specified
Conditional Branch: Month =-2 (Dry season 2)
Conditional Branch Half-Hours <= 9
Tint Screen -150, -150, -100, 60 @120
Conditional Branch Half-Hours <= 11
Tint Screen -50, -50, -25, 0 @60
Conditional Branch Half-Hours <= 15
Tint Screen 0, 0, 0, 0 @60
Conditional Branch Half-Hours <= 29
Tint Screen 25, 25, 0, 0 @60
Conditional Branch Half-Hours <= 33
Tint Screen 0, 0, 0, 0 @60
Conditional Branch Half-Hours <= 37
Tint Screen -50, -50, 0, 0 @60
Conditional Branch Half-Hours <= 41
Tint Screen -150, -150, -100, 60 @60

(This lengthens mornings and afternoons by half an hour each, decreasing the brightest part of the day by an hour.)

Conditional Branch Variable Month = 3
Conditional Branch Hours <= 5
Tint Screen -150, -150, -100, 60 @120
Conditional Branch Hours <= 6
Tint Screen -50, -50, -25, 0 @60
Conditional Branch Hours <= 8
Tint Screen 0, 0, 0, 0 @60
Conditional Branch Hours <= 14
Tint Screen 25, 25, 0, 0 @60
Conditional Branch Hours <= 16
Tint Screen 0, 0, 0, 0 @60
Conditional Branch Hours <= 18
Tint Screen -50, -50, 0, 0 @60
Conditional Branch Hours <= 20
Tint Screen -150, -150, -100, 60 @60

(Sunrise is half an hour later again in the mornings, and half an hour earlier in the evenings, than the previous month.)

Conditional Branch Variable Month = 4
Copy, Paste Tintings from Month 2.

Copy the tinting data to the Going Outside event, and change the transition times to 20 frames for each tint.

For those who want randomised weather, at the top of the Going Outside screen, above the coding for tinting, put this:

Variable Weather Change Hours 2 = Weather Change Hours
Variable Weather Change Hours 2 – Hours
Conditional Branch: Variable Weather Change Hours 2 >= 4
Variable Random Weather = Random 0 to 25

(This is so that weather changes when you go outside, but only after four hours have expired since the last weather change). If this was not there, it would change every time someone entered and exited a building.

Now, add your desired weather each month, beneath the screen tints for that month.

Month 1
Conditional Branch Random Weather <= 10
Change Map Settings: Fog None
Conditional Branch Random Weather <= 15
Change Map Settings: Fog 002-Clouds 1, 10, 10 , Magnify 200
Conditional Branch Random Weather <= 24
Change Map Settings: Fog 001-Fog 1, 5, 5, Magnify 200
Else
Weather Effects: Rain 2 @ 0
Month 2
Identical to first month.

Month 3
Conditional Branch Random Weather <= 10
Change Map Settings: Fog 001-Fog 1, 5, 5, Magnify 400
Conditional Branch Random Weather <= 15
Weather Effects: Snow 2 @ 0
Conditional Branch Random Weather <= 20
Weather Effects: Snow 4 @ 0
Conditional Branch Random Weather <= 24
Weather Effects: Snow 6 @ 0
Else
Weather Effects: Snow 9 @ 0

Month 4
Conditional Branch Random Weather <= 5
Change Map Settings: Fog None
Conditional Branch Random Weather <= 10
Change Map Settings: Fog 001-Fog 1, 5, 5, Magnify 200
Conditional Branch Random Weather <= 25
Change Map Settings: Fog 001-Fog 1, 5, 5, Magnify 200
Weather Effects: Rain 5
Conditional Branch Random Weather <= 20
Change Map Settings: Fog 001-Fog 1, 5, 5, Magnify 200
Weather Effects: Rain 7
Else
Change Map Settings: Fog 001-Fog 1, 5, 5, Magnify 200
Weather Effects: Snow 9 @ 0


This changes the weather for each season.

I hope you have found this tutorial useful, and can implement at least a part of it in your game. If you have any problems or suggestions with my tutorial, feel free to post.

Go to the top of the page
 
+Quote Post
   
HeroOfHyla
post Jul 25 2008, 02:14 PM
Post #2


Twirling towards freedom
Group Icon

Group: +Gold Member
Posts: 2,791
Type: Scripter
RM Skill: Advanced




Hey Rosje. I noticed that you've put this tutorial up 3 times. Is this the version you want to be visible?


__________________________
Asexual - Arizonan - Atheist
I've got a gmail account and a yahoo mail account under this name, if you need to contact me.
You can find me on facebook too. facebook.com/heroofhyla . If you send me a friend request, tell me who you are so I don't get confused.

PlagueRPG SITE IS WORKING! (if you see "test page," hit ctrl+f5)
Latest update: New battle system demo, April 19, 2010

http://heroofhyla.deviantart.com/ ----- http://heroofhyla.livejournal.com/ ----- http://thatonecomic.smackjeeves.com
Go to the top of the page
 
+Quote Post
   
rojse
post Aug 2 2008, 04:00 PM
Post #3


Level 19
Group Icon

Group: Revolutionary
Posts: 373
Type: None
RM Skill: Skilled




Yes. I have tried to put this tutorial up three times, but I did not get any email about it, nor did it appear when I examined the tutorial page.

Thanks.
Go to the top of the page
 
+Quote Post
   
wrong
post Aug 6 2008, 12:43 AM
Post #4


Level 2
Group Icon

Group: Member
Posts: 26
Type: None
RM Skill: Beginner




QUOTE (rojse @ Aug 2 2008, 04:22 PM) *
Yes. I have tried to put this tutorial up three times, but I did not get any email about it, nor did it appear when I examined the tutorial page.

Thanks.


The problem with this system is it will lag a lot doesn't it?
I tried to the same thing, but whenever i am in a big map with a lots of events. This thing lags the whole game.
Go to the top of the page
 
+Quote Post
   
VileoSufora
post Aug 13 2008, 04:29 PM
Post #5


This is not Sparta! This is...What is this I don't even
Group Icon

Group: Revolutionary
Posts: 169
Type: Event Designer
RM Skill: Skilled




QUOTE (wrong @ Aug 6 2008, 01:05 AM) *
The problem with this system is it will lag a lot doesn't it?
I tried to the same thing, but whenever i am in a big map with a lots of events. This thing lags the whole game.

Not if you have an Anti-Event Lag script.

On a side note, I liked this. I would've never thought of this, thanks. You might wanna add that one second in VX is 60 frames, for all the newbs who can't read the notes beside the entry fields, lol.

P.S. When you make a topic here, it has to go through moderation to make sure it's a valid entry, and not some newbish tutorial that tells you how to use Auto-Events in VX. Yes, I've seen one before on another site.


__________________________
Formerly HotSpot6


Anime-Planet.com - anime | manga | reviews
~ ~ ~
Go to the top of the page
 
+Quote Post
   
OMG_RAWR!
post Aug 13 2008, 04:56 PM
Post #6


Title: Master Map Maker
Group Icon

Group: Revolutionary
Posts: 466
Type: Developer
RM Skill: Advanced




It looks solid but It confuses me haha tongue.gif I want to do I yearly time with day/night and random weather effects but with what I've done so far I get an error when it switches to a new day, or when wether tries to set in (I think thats it)


EDIT:
Okay I changed it to exactly what this tutorial is saying (None of my 30 day months or 12 month years and stuff like that)
And Time doesnt even start now.. :[


__________________________

[Show/Hide] Dragon Egg Pouch


[Show/Hide] The Signature? :D


[Show/Hide] My Badges :D


[Show/Hide] Website Crap


Be the Ultimate Ninja! Play Billy Vs. SNAKEMAN today!


[Show/Hide] -Secret Solo Project-
Maps - 50%
NPCs - 30%
Story - 99%
Quests - 10%
Other - 18%

Total Progress = 64%
Go to the top of the page
 
+Quote Post
   
Twilight27
post Aug 20 2008, 10:47 AM
Post #7


Level 19
Group Icon

Group: Revolutionary
Posts: 371
Type: Event Designer
RM Skill: Beginner




I think beginners would love it if you had screenshots and/or a demo. It's a little tedious to read through all of this and not get confused.
I, myself, am a little confused, or just frustrated with reading all of that; screenshots would have made it a lot more pleasing to the eyes.


__________________________

Fall to the power of the Emo!
We have cookies!


Notice!! Check out my topic (http://www.rpgrevolution.com/forums/index.php?showtopic=45736&st=0#entry454175) if you're interested in helping me make a script that limits the number of characters & items you use in battle AND also an item durability feature! Thanks for any help in advance!
Go to the top of the page
 
+Quote Post
   
Psiclone
post Aug 20 2008, 12:43 PM
Post #8


Level 2
Group Icon

Group: Member
Posts: 29
Type: None
RM Skill: Skilled




Here's a picture of what my time looks like:

[Show/Hide] Screenie


You don't need to have the "loop" in there with it being a parallel process, I don't know why I put that there.

Of course, you can omit any of the time variables that you want. You could even make it just "Hour" and "Day", or any combination you wish. Again, the time variables I used are specific to my project, mainly the year. Hope this helped.


That shows a picture of the conditional branch with the time in one of my projects. Not sure if it's what rojse was getting at, but it's what I have.
Go to the top of the page
 
+Quote Post
   
ReokoD
post Aug 24 2008, 07:45 AM
Post #9


Level 7
Group Icon

Group: Member
Posts: 91
Type: Writer
RM Skill: Skilled




Hi, I'm trying to make this with Rm2k3 and ran into a spot of trouble. I got what the transitions are supposed to mean, although Rm2k3 doesn't have negative tint, but still ran into trouble. When I made the event changing transition from the hour, it would change the colors then freeze. Also, I must agree that the tutorial isn't very clear, although it's very helpful. Thanks!

EDIT: Actually, I can't really figure out the seasons or the weather too. confused.gif I may be just stupid, but I think it's not really all that clear. I would really like to put this in my current project, but I fail to understand, lol.

This post has been edited by ReokoD: Aug 24 2008, 07:57 AM


__________________________




My user sig and my current project sig, courtesy of Midnight Assassin!
Go to the top of the page
 
+Quote Post
   
rojse
post Aug 26 2008, 11:45 PM
Post #10


Level 19
Group Icon

Group: Revolutionary
Posts: 373
Type: None
RM Skill: Skilled




QUOTE (ReokoD @ Aug 24 2008, 07:07 AM) *
Hi, I'm trying to make this with Rm2k3 and ran into a spot of trouble. I got what the transitions are supposed to mean, although Rm2k3 doesn't have negative tint, but still ran into trouble. When I made the event changing transition from the hour, it would change the colors then freeze. Also, I must agree that the tutorial isn't very clear, although it's very helpful. Thanks!

EDIT: Actually, I can't really figure out the seasons or the weather too. confused.gif I may be just stupid, but I think it's not really all that clear. I would really like to put this in my current project, but I fail to understand, lol.


Apologies to those on here who thought my tutorial was too unclear. And apologies for the tardy replies, have been quite busy.

There is a weather event for 2k3. To get random weather, create a random variable in the variable event, and have several different conditional branches as I showed in the tutorial. For example, if "Random Weather Var" is <10, do nothing. Else, if "Random Weather Var" is <15, have level 2 rain, and and so forth. Does this clear up the weather problem?

As for your problem with the colour changing, I honestly can not really help here unless you send me along your coding.
Go to the top of the page
 
+Quote Post
   
webbo227
post Aug 28 2008, 02:58 AM
Post #11


Level 7
Group Icon

Group: Revolutionary
Posts: 100
Type: Event Designer
RM Skill: Intermediate




Is there no demo for this? I'm confused with these switches that are used. wallbash.gif


__________________________
"Oh c'mon Church. They say you're not completely dead as long as someone still remembers you."
"Yeah, but look who's left to remember me. It sure feels like being dead. Like all the way dead. Like being encased in cement and fired at the sun dead."


Red vs Blue - Recreation

[Show/Hide] Most Epic Forum Quote Ever Conceived
Homunculus - "It would be awesome to kill everyone by throwing the moon at earth. NO ONE WOULD EXPECT IT. AND EVEN IF THEY DID. WHAT CAN THEY DO? IT'S THE FUCKING MOON. " [Link]
Adriantepes313 - Agreed. But damn, the moon? Brilliant. But I have a better idea. if we have superpowers, why not throw the fucking sun? [Link]

Bow down to your new lords and masters.


-- Webbo
Go to the top of the page
 
+Quote Post
   
rojse
post Aug 28 2008, 03:28 AM
Post #12


Level 19
Group Icon

Group: Revolutionary
Posts: 373
Type: None
RM Skill: Skilled




I will put up some pictures next week, as it seems they will help people use the tutorial.
Go to the top of the page
 
+Quote Post
   
mars111
post Sep 21 2008, 02:46 PM
Post #13


Level 3
Group Icon

Group: Member
Posts: 30
Type: Developer
RM Skill: Beginner




Yeah, im trying to get this working... but im a newb on this.. and i got very confused, it is a very nice tutorial here... but some screens or a demo could make me get on the way smile.gif

This post has been edited by mars111: Sep 21 2008, 02:47 PM
Go to the top of the page
 
+Quote Post
   
rojse
post Sep 24 2008, 01:22 AM
Post #14


Level 19
Group Icon

Group: Revolutionary
Posts: 373
Type: None
RM Skill: Skilled




QUOTE (mars111 @ Sep 21 2008, 02:08 PM) *
Yeah, im trying to get this working... but im a newb on this.. and i got very confused, it is a very nice tutorial here... but some screens or a demo could make me get on the way smile.gif


I will get pictures up, have been extremely busy.

If you explain what your problems are, perhaps I could help.
Go to the top of the page
 
+Quote Post
   
superboypoop
post Oct 16 2008, 10:05 AM
Post #15


Level 4
Group Icon

Group: Member
Posts: 48
Type: Event Designer
RM Skill: Masterful




Basically every time 60 seconds go by you reset the seconds variable, then add 1 minute to the minute variable, 60 mins go by reset add one hour to the hour variable:


[v01]Seconds +1
wait 1 second

if [v01]seconds = 60
[v01]seconds = 0
[v02]minutes +1
end if

if [v02]minutes = 60
[v02]minutes = 0
[vo3]hours +1
end if

if [v03]hours = 24
[v04]days +1
[v03]hours = 0
end if

if [v04]days = 30
[v05]months +1
[v06]totaldays +30
[v04]days = 0
end if

so on and so forth.
Basically you can just work this up the line using the conditional branch function where i have the IF statements, and the rest will all be in the variable operations.


__________________________
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 23rd May 2013 - 07:52 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker