AddThis Smart Layers

Get tutorials and game reviews by email

Name Email



 

Monday, 21 April 2014

RMXP Logo

A Simple RPG Maker XP Weather System


Why not add an extra level of realism to your game with a simple weather system. You could even set up specific events to take place during specific types of weather. Here we'll show you how...
Share this Tutorial →

There's a variety of weather systems available to producers that utilise scripting but I find these to be cumbersome and, if you aren't used to scripting then you'll find customisation of the system very difficult. This system, in my opinion is underrated and much more versatile for users of any experience. The system is split into 3 different specific events, the Timer, the Checker and the Changer. Setting up these events is very important as they are designed to work with each other.

Setting up the timer...


Step 1:

The first thing you need to do is set up your first common event. You can do this in the Database which you can access by pushing [F9] or by selecting the database tab at the top of the screen. You can create common events under the Common Events tab which is found towards the upper right hand side of the screen. The first event you need to create is your timer, as you can see below, I have named mine 'Weather Timer.' Notice that the trigger of the event is set to 'Parallel' to ensure that the event takes place as a parallel process, allowing other events to take place at the same time without hindrance. Additionally, the condition switch for this event is 'Weather Timer.' This is to ensure that the system can be easily turned on and off by turning on the corresponding switch (0001: Weather Timer).
This timer event exists to give the illusion that it the duration between weather changes is randomly generated when in-fact the durations are pre-determined. Which pre-determined duration is selected however is random, giving the effect of randomly generated system. So what do we need to set up something like this? Many events need to work in tandem here for the desired effect. 

Step 2:

The next thing we need to do is create a switch known as 'Weather Change.' This switch will not be used in this common event but, because it will be on at the end of the system, it needs to be turned off initially to prevent a loop from taking place. You don't really need to understand the reasoning for this but you definitely need to add this right at the beginning of your event.







Step 3:

So we've essentially wiped the slate clean with step 2, our event is now refreshed and ready to begin a brand new, clean loop. The first thing we need to do, as I have previously mentioned is create a list of pre-determined durations between weather changes and a system to randomly select one of these. This is done by using a variable and conditional statements. The first thing we'll do is set up an event that randomly selects a number to populate our chosen variable. Open the 'Control Variables' menu in the first tab of the event  commands selector. Name the variable something memorable, I have chosen 'Weather Timer' for mine. Make sure the operation is 'Set' and you've selected 'Random' between 0 and 4 as your operand. This basically means that this command will take the variable 'Weather Timer' and populate with a random number between 0 and 4. This means there are 5 possible outcomes from this operation, 0, 1, 2, 3 and 4. This means we need to set up numerous conditional statements to respond to when one of these numbers appears. 






Step 4:

Creating these conditional statements is very simple but, on the surface may appear complicated. The conditional statement you need to set up will look like this. In this example, our statement is looking out for instances where the random number generator variable (Weather Timer) is populated with the number 0. Make sure that you also select 'Set Handling when conditions do not apply.' 














Step 5:

So we've set up a conditional statement looking for 0 as the number in our variable. But what is going to happen when that number comes up? Not much really. To streamline the system we are splitting it up into various common events so that we don't have a heavy common event running throughout the game, increasing the likelihood of lag. As I've said, the point of this event is to randomly generate a time duration between weather changes and that is what we are going to do now. The first thing we need to do is set up a control timer that begins to countdown from a predetermined point. For the sake of testing, I have selected 10 seconds but you can choose any time you wish. The next thing to do is set up two switch controls. One to turn on a switch I have called 'Weather Check' and another to turn off our 'Weather Timer' event. This is because the next common event in our system will be turned on using our 'Weather Check' switch, and for one event to turn on, another has to turn off, hence the turning off of 'Weather Timer.' Hopefully, if all is going well then your common event should look like this.



Step 6:

We're not quite done with this event yet as we have to duplicate the conditional statement numerous times. This is because we need the event to react in different ways for each number that can randomly appear, this means that we need a conditional statement and set of events for each possible outcome. Because I have selected 0 - 4, or 5 instances, we need to create a further 3 conditional statements. I know what you're thinking...you need 5 instances, I've already done 1...surely that means 4 more but this is not the case. In a conditional statement you have the series of events that take place when a condition is satisfied and an 'else' set, that is enacted when the condition is not satisfied. As you can see from the image, this common event is a series of conditional statements that check for a specific condition, if it is not satisfied then it moves along the chain. At the last event, we are left with a stray 'else' set and we can use this to place our final set of events because if it can only be a number between 0 and 4, and it's not 0, 1, 2, or 3...then it has to be 4. All you have to do here is set out the events in the way I have, placing the subsequent conditional statement in the 'else' box of the predecessor. You also need to change the timer value for each statement so that the duration between weather changes can vary each time. In the end, you want your event to look like this:

Step 7:

We're done with this event and can now move onto the second one in the chain. The 'checker'. This event is very simple and holds a single purpose, to check the timer and alert the system when it has reached zero. Such as simple event only requires a few commands.

As you can see, first of all we need to set up a conditional statement that will be looking at the timer. All you have to do is set the trigger as the timer being 0 mins, 0 seconds or less. This means that when the timer hits zero, the next command will take place, in this case being a simple switch control. Remember the 'Weather Change' switch we put together at the beginning? Turn it on now. Note: This common event is set up in a similar manner to our previous event, being a Parallel process and relying on the switch - 0002: Weather Check to work.

Step 8:

We are now going to create our final event that will house our wonderful weather effects...or your wonderful weather effects. This common event is set up in the exact same way as our first event, using a random number generator in a variable to create a seemingly random chain of weather. Instead of actual weather events in my event however, I have used simple text prompts. This is simply for test purposes and to speed up the entire process of checking because I could use a different text remark for each outcome. In your case, you can use a mixture of weather effects, lighting and sound effects so get creative. The event should look like this:
There are some key differences that should be noted here however such as the first event...our 0 outcome. Say we're some way into our game and we've already got some rain going on. Sometimes we just want the weather to be normal and in this case, the 0 turns off any weather effects and sets the map to normal. The switches that then follow are designed to reset the event so that the cycle can then begin from our first event, restart the timer for a random duration. 


Step 9:

So we've created our common event and weather system, now we just have to tell the game that we want to use it. This is done very simply by placing a single event in the first map our player will visit. The event will then continue to work because its use is determined by a switch and not by a direct event command call out. Here, you simply have to create the following event:
As you can see, this event is a parallel process (to run in tandem with the rest of the game) and simply turns on the 'Weather Timer' switch which initiates the Weather Timer common event. In my experience, it's always good to then erase the event even though other tutorials don't mention this. I always like to get rid of any events that are un-needed plus in some cases the timer will not start properly and will keep looping at the very beginning, making your weather system completely useless.

Turning the system on and off:

There are two ways to deal with moments when you don't want your system to be active. The first, is to simply turn the system off. If you wish to turn the system off when you enter a building, simply create a command as part of the teleport event that turns the 'Weather Timer' switch off, essentially disabling the event for the duration of your time in the building. Just make sure the event that leads back outside also has a switch controller that turns 'Weather Timer' back on. There is one major drawback to this method however...the timer resets because the event is turned on and off. This creates the possibility that you will rarely see the weather change if you have a game that involves plenty of in-door spaces. A solution for this is to put the event into stasis. The first thing you have to do is set your weather to 'none' like I had. Then you need to stop the timer but not disable the event. You can do this by creating a 'stop timer' command on your teleport event. This means that the event is still running, but the timer has stopped. The only problem here is that the timer will reset to zero because it does not record the time that you stopped it on. You can combat this by then resetting the timer when you leave the building to something relatively low, like 2 minutes so that the weather changes shortly after leaving the building to make up for the lost timer and time spent in-doors. I would only recommend using this method on some buildings as doing it for every door can make for some very erratic weather. One other massive benefit to doing this is the creation of a truly random weather system as its behaviour is generally defined by the behaviour of the player, something that you have absolutely no control over. 

That's about it for this very long tutorial, if you've enjoyed it then please leave a comment below or share it! Thanks very much for reading.

No comments:

Post a Comment

 
© (2014) RPG Maker Guru - any reproduced content is done so in line with fair use policies