What follows are a series of guides explaining variables. I'll try to put it in the most basic terms. If you still don't get it, read on to hear some other views on the subject. If you still don't get it, don't post here asking, please. It cannot get any easier.
Those of you who've taken basic algebra know what a variable is. X. In this sense, consider all of the various variables as "X". Now, at the games start, all of the variables equal zero. You can have them equal 1, and this is how a "switch" worked in RPGM1. When something happens, you can change the variable to 1 and then make an event that checks that value. Thus, when the variable goes to 1, you can have an event anywhere on the map use a variable control branch to tell that something happened.
The variables can also go up all the way to 999. A good example of why this is needed are MMORPG style quests. Say you have to "kill six orcs" - make 6 events that have you fight one orc. Use variable increase instead of variable change, and it will go up by one each kill REGARDLESS OF THE ORDER IN WHICH YOU DO IT. This is a major point, and why variables are so helpful in the game.
Oh, and the difference between shared and internal variables? Nothing. It's just for organization purposes.
Still don't get Variables? Read on.
---
Obright on making a "monsters killed" code-
Those of you who've taken basic algebra know what a variable is. X. In this sense, consider all of the various variables as "X". Now, at the games start, all of the variables equal zero. You can have them equal 1, and this is how a "switch" worked in RPGM1. When something happens, you can change the variable to 1 and then make an event that checks that value. Thus, when the variable goes to 1, you can have an event anywhere on the map use a variable control branch to tell that something happened.
The variables can also go up all the way to 999. A good example of why this is needed are MMORPG style quests. Say you have to "kill six orcs" - make 6 events that have you fight one orc. Use variable increase instead of variable change, and it will go up by one each kill REGARDLESS OF THE ORDER IN WHICH YOU DO IT. This is a major point, and why variables are so helpful in the game.
Oh, and the difference between shared and internal variables? Nothing. It's just for organization purposes.
Still don't get Variables? Read on.
Originally posted by JPS
Originally posted by Crythania
View Post
Originally posted by Crimson Knight
View Post
Originally posted by Perversion
View Post
Obright on making a "monsters killed" code-
Doing it with random encounters:
- Make several enemy parties that contain the enemy you want to count. They can have 1-4 of this enemy in them (with other enemies also, or without).
- Make 4 treasure items, and call them the '_______ pelt' (or whatever). You can title them this way:
'Beast Pelt x1'
'Beast Pelt x2'
'Beast Pelt x3'
'Beast Pelt x4'
- Set the enemy parties to drop one of these 4 items ALWAYS. If the party has only one of the 'counted' enemies in it, make that party drop the 'Beast Pelt x1'...if there are 4 of the enemy, have them drop the 'Beast Pelt x4'...you see what I mean.
- Now, make 4 separate invisible auto-events in the area where you encounter these enemy parties. Each one of these events will lie dormant until your party has one of the 4 treasure items, so set the events to 'AUTO', and set the requirement for the events to be 'with treasure item', and select one of the 4 treasures (one for each event).
- On a separate sheet of paper, write "Shared Variable 01 - NUMBER OF MONSTERS DEFEATED" It doesn't have to be variable 01, but just for the sake of example, let's just say that it's 01.
EDIT - Or, you can download this template: http://i34.photobucket.com/albums/d1...stemplate2.jpg
Just print it out, and fill it in (preferably in pencil).
- Now, in the 4 invisible auto-events, go into the 'event codes' page, and add a Property Control>Increase Shared Variable code. Select variable 01, and increase that variable by 1-4, depending on the number of that enemy in the party. Then place a Party Control>Lose Treasures event code to remove the treasure item.
You can simplify this by using only one treasure item and one invisible auto-event, but you'll need to make sure that there is only 1 of the enemy in each party.
...................................
Doing it with event battles:
This method is simpler in certain ways. You just need to make several touch-activated events that contain a Control>Event Battles event code, and set the enemy party to be encountered. In addition to this code, you'll need a Control>Battle Result Branch to set what happens if the battle is won or lost. In the 'WIN' side, increase the 'number of monsters defeated' variable with the same event code mentioned earlier. At the end, you'll probably want a Display>Display OFF event code, so that the battle will only be fought once. That's pretty much all there is to it.
HOWEVER...now you'll need to set up events to check the value of variable 01, and give different results accordingly. You do this with Value-Conditional Branches (Control>Value-Conditional Branch).
Since you'll have 2 different sets of requirements (one for that 1 person, and one for everybody else), you'll need to have separate variables tracking whether each person is in the party or not......If you want to keep this idea in your game you CAN, but I can tell you it will be pretty complicated. in the event which checks variable 01, you'll need 2 Value-Conditional Branches...one for that 1 guy, and one for everybody else. You might set your variables list (on the separate sheet of paper) up like this:
Variable 01 - number of monsters defeated
Variable 02 - 'that one guy' is in the party
Now...in the event which checks your 'number of monsters defeated' variable,
place a V-C branch with 2 options - 1 for if 'that guy' is in the party (variable 02 = 1), and 1 for everybody else (variable 02 = 0). Within BOTH sides, place another 2-way V-C branch. Both will check the value of Variable 01, but the requirements will be different for each. This will also require you to have yet another event which takes characters in and out of your battle party and alters those variables accordingly...but my fingers are about to fall off.
In V-C Branch 1 (the one for everybody else), set option 1 to be if variable 01 is less than or equal to 9, and the second if 01 is greater than or equal to 10. In the first option, place a Display>Message Display saying something like 'You haven't defeated enough monsters yet!'. In the second, have a message saying 'You have defeated enough monsters!', and then give the reward(s).
In V-C Branch 2 (the one for the 1 guy), do the same thing, but this time set the requirements up like this: Set option 1 to be if variable 01 is less than or equal to 14, and the second if 01 is greater than or equal to 15.
Honestly though...I think you might be better off if you make the requirements the same for everybody, because there's no way to track which one of your characters makes the killing blow in battle...you'd have to make it so that each character fights alone during that part of the game, and then triggers the event alone.
I know this sounds complicated, but hopefully it will help. If you have any more questions, just ask!
- Make several enemy parties that contain the enemy you want to count. They can have 1-4 of this enemy in them (with other enemies also, or without).
- Make 4 treasure items, and call them the '_______ pelt' (or whatever). You can title them this way:
'Beast Pelt x1'
'Beast Pelt x2'
'Beast Pelt x3'
'Beast Pelt x4'
- Set the enemy parties to drop one of these 4 items ALWAYS. If the party has only one of the 'counted' enemies in it, make that party drop the 'Beast Pelt x1'...if there are 4 of the enemy, have them drop the 'Beast Pelt x4'...you see what I mean.
- Now, make 4 separate invisible auto-events in the area where you encounter these enemy parties. Each one of these events will lie dormant until your party has one of the 4 treasure items, so set the events to 'AUTO', and set the requirement for the events to be 'with treasure item', and select one of the 4 treasures (one for each event).
- On a separate sheet of paper, write "Shared Variable 01 - NUMBER OF MONSTERS DEFEATED" It doesn't have to be variable 01, but just for the sake of example, let's just say that it's 01.
EDIT - Or, you can download this template: http://i34.photobucket.com/albums/d1...stemplate2.jpg
Just print it out, and fill it in (preferably in pencil).
- Now, in the 4 invisible auto-events, go into the 'event codes' page, and add a Property Control>Increase Shared Variable code. Select variable 01, and increase that variable by 1-4, depending on the number of that enemy in the party. Then place a Party Control>Lose Treasures event code to remove the treasure item.
You can simplify this by using only one treasure item and one invisible auto-event, but you'll need to make sure that there is only 1 of the enemy in each party.
...................................
Doing it with event battles:
This method is simpler in certain ways. You just need to make several touch-activated events that contain a Control>Event Battles event code, and set the enemy party to be encountered. In addition to this code, you'll need a Control>Battle Result Branch to set what happens if the battle is won or lost. In the 'WIN' side, increase the 'number of monsters defeated' variable with the same event code mentioned earlier. At the end, you'll probably want a Display>Display OFF event code, so that the battle will only be fought once. That's pretty much all there is to it.
HOWEVER...now you'll need to set up events to check the value of variable 01, and give different results accordingly. You do this with Value-Conditional Branches (Control>Value-Conditional Branch).
Since you'll have 2 different sets of requirements (one for that 1 person, and one for everybody else), you'll need to have separate variables tracking whether each person is in the party or not......If you want to keep this idea in your game you CAN, but I can tell you it will be pretty complicated. in the event which checks variable 01, you'll need 2 Value-Conditional Branches...one for that 1 guy, and one for everybody else. You might set your variables list (on the separate sheet of paper) up like this:
Variable 01 - number of monsters defeated
Variable 02 - 'that one guy' is in the party
Now...in the event which checks your 'number of monsters defeated' variable,
place a V-C branch with 2 options - 1 for if 'that guy' is in the party (variable 02 = 1), and 1 for everybody else (variable 02 = 0). Within BOTH sides, place another 2-way V-C branch. Both will check the value of Variable 01, but the requirements will be different for each. This will also require you to have yet another event which takes characters in and out of your battle party and alters those variables accordingly...but my fingers are about to fall off.
In V-C Branch 1 (the one for everybody else), set option 1 to be if variable 01 is less than or equal to 9, and the second if 01 is greater than or equal to 10. In the first option, place a Display>Message Display saying something like 'You haven't defeated enough monsters yet!'. In the second, have a message saying 'You have defeated enough monsters!', and then give the reward(s).
In V-C Branch 2 (the one for the 1 guy), do the same thing, but this time set the requirements up like this: Set option 1 to be if variable 01 is less than or equal to 14, and the second if 01 is greater than or equal to 15.
Honestly though...I think you might be better off if you make the requirements the same for everybody, because there's no way to track which one of your characters makes the killing blow in battle...you'd have to make it so that each character fights alone during that part of the game, and then triggers the event alone.
I know this sounds complicated, but hopefully it will help. If you have any more questions, just ask!

).