LOCKED DOORS AND VANISHING EVENTS
Posts
Pages:
1
I'm using RPG Maker 2k3 and I need to know how to lock doors, use items on events and how to get rid of an event, as in a one-time use.
Eg. The character will enter a room and step on an event causing the door behind him to lock. My questions being: 1. How do I delete the event after I step on it? and 2. How do I unlock the door? That is to say switching it from a simple speech event to a teleport event by using a key on it.
Eg. The character will enter a room and step on an event causing the door behind him to lock. My questions being: 1. How do I delete the event after I step on it? and 2. How do I unlock the door? That is to say switching it from a simple speech event to a teleport event by using a key on it.
author=NilePro
That is to say switching it from a simple speech event to a teleport event by using a key on it...
... by using a switch! At the end of the code for talking to it you turn on a switch. That switch is used as a trigger condition for page 2 of the event that will be a teleport event.
You can't delete an event permanently. You need to use a switch to activate a blank 2nd page for one time events.
author=Link_2112author=NilePro... by using a switch! At the end of the code for talking to it you turn on a switch. That switch is used as a trigger condition for page 2 of the event that will be a teleport event.
That is to say switching it from a simple speech event to a teleport event by using a key on it...
You can't delete an event permanently. You need to use a switch to activate a blank 2nd page for one time events.
I have a lot of trouble setting up events, if you could guide me to a better tutorial than the one the site provides OR tell me yourself that would be just dandy.
author=NileProauthor=Link_2112Okay, how would that work?
I'll write something up for you
haha Well, that particular thing works by you waiting while I write something up :3
author=Link_2112author=NileProhaha Well, that particular thing works by you waiting while I write something up :3author=Link_2112Okay, how would that work?
I'll write something up for you
Oh, okay. ^^'''
Ok, so I'm writing a full tutorial that should teach you everything you need to know about events to figure it out. Rather than solving this one problem for you.
I'm not writing the tutorial specifically for you, been meaning to do something like this for a while heh but I can find out how helpful it is. It's still a WIP.
Read through it and maybe you'll have your answers. If not, just wait til I'm done and I'll have some specific examples you asked for.
-----------------------------------------------------------------------
Understanding Events
The purpose of this tutorial is to help newcomers understand how to do all the basic things that events can do. Everything will be accompanied by images for those who are visual learners. I will include some advanced stuff that you can skip if you don't fully understand it yet. Some of it might require more specific tutorials.
It all starts with a new project. A project is basically a database and a map tree.
The map tree is in the bottom left corner. Right click there to make a new map. I suggest getting into the habit of keeping it organized.
Use empty maps to contain and categorize all similar maps. Try not to make unnecessary long strings of a map inside a map inside a map, or randomly create new maps as you need them.
----------------------------------------------------------------------------
The database is where all behind-the-scenes data is set, but also it's where you find the very important Common Events tab.
=======
Maps are grids where you can place events, like this one. You can only create one event per tile, but you can later move multiple events to the same tile.
------------------------------------------------------------------
Events on a map will only work while you are on that map. When you teleport away from the map, all of the events will be reset the next time you go back. (Unless you use switches to permanently change the events.)
An event running from the Comment Events will work on every map. The way you activate them is different, you need to call them directly or use switches/variables.
Rather than create the same event on every map, you can create it once in the common area and use it on every map! Saves time and space, but you can worry about that later.
---------------------------------------------------------
I'll explain each area of the event.
ID - You can see this in the title bar. Each new event that is created uses the next lowest available number. If you make 10 events and delete ID4, the next event created will be ID4. ID is important when you are specifying an event using code inside of another event.
Name - It's a good habit to name your event to whatever it's function is. NPC1, Treasure4, pushrock, climbtree.... When you call on another event you need to pick it from a list of names.
Page - Each new page is represented by a tab. Click the tab to select the page. The buttons along the top affect the currently selected page.
Each page is basically a new event inside the event. Only 1 page can be active at one time during the game, and you use the Preconditions to change pages. No Preconditions means the page is always active. The page furthest to the right that has its Precondition met will be what shows in the game. If no Preconditions are met, the event will be invisible and inactive.
Preconditions - Leave this empty and the event will always be active. When you pick something from the list, that needs to be true in order for the event to activate.
If you pick two or more things, they all need to happen to trigger the page. By using multiple Preconditions, you can fit a lot of different behaviors and styles into a single NPC.
Event Commands - This is where you put all your code for this event/page. How this code triggers depends on how you set the Trigger Condition.
Event Graphic - This is where you decide the look of the NPC or visible event. Some events need to remain hidden, so you would choose something transparent. There is no "empty" choice, you need to pick something transparent.
Movement - There are some basic patterns in the list, but for more realistic NPC's it's best to create custom paths.
Speed - This controls how long it takes for the event to move to the next tile.
Movement Frequency - This controls how long the event takes to move onto the next movement command.
Animation Type - Determines the behavoir of the event graphic.
Non-Continuous will not cycle the frames while the event is standing still. When it moves the frames will cycle.
Continuous will cycle the frames all the time.
Fixed Dir / Fixed Direction means the event will not turn when going in different directions.
Fixed Graphic will never cycle the frames of the graphic. It's stuck on the the frame you choose when clicking the "Set" button to choose a graphic.
Spin Around will use only 1 frame of the animation, but it will make the event spin around all four directions. Useful for getting an extra frame of animation into a sprite.
Event Layer - There are only 3 layers, each altering the way the Trigger Conditions work. These 3 layers also apply to the tileset.
Below Hero - The player will be able to walk on top of this event. You need to be standing on top to activate the Action Key trigger, simply standing next to and facing it won't work.
Same Level as Hero - The player will not be able to walk through this event. You can stand next to and face to activate the Action Key trigger.
Above Hero - The player will be able to walk under this event. Like Below Hero, you need to occupy the same space to use the Action Key trigger.
Trigger Conditions - This dictates how the Event Commands will activate.
Action Key - The player needs to press the "talk" key on the event.
Touched by Hero - The player simply needs to walk on top of, into, or under the event.
Collision with Hero - This one is tricky and doesn't work as well as you might hope. The layer of the event plays a big part. Play around with it to figure out what works and what doesn't.
Auto-Start - This will happen right away when you teleport to the map, but it will freeze the player and other events until it is stopped. These can break the game if you're careless.
Parallel Process - This is the same as Auto-Start, except that it doesn't freeze anything. The player can move and other events can run at the same time. Even multiple Parallel Processes.
-------------------------------------------------------
Now that all the basic explanations are out of the way, let's start looking at practical examples.
Creating an NPC
Create a new event. Give it a name and a graphic.
This is the most basic example. This is all it takes to create something that will appear on the map. You can use the graphic of a box or a flower to create environment objects. You also can use copies of something in the tileset to create extra layers and fix map errors.
This NPC, Joey, will just be standing around. I imagine almost anyone can figure out how to use the other options to bring him to life so I won't get into that.
Using Pages
Let's say you want Joey to display a message when you talk to him.
Often times when you complete something in the story, you will want to Joey to display a different message. For this we use a Variable.
Simply put, a Variable is something you control that can hold a number. It starts at 0 and remains at 0 until you use a Variable command to change it.
So as the game goes on, let's say you beat the nearby thieves. At the end of that battle there would be a command to add 1 to a Variable we'll call "Main Story Progress". Now that I know which Variable I will be using, I can create a new page on Joey and set the Precondition.
Using Preconditions in this way, you can determine what events the player has completed in the game by tracking them with variables, then have events react based on what the variables are set to. This is an important concept to grasp for all ideas that needs to be coded in any game design program.
One way to look at page 2 is this. The Precondition is asking a basic question.
Is the Variable "Main Story Progress" equal to 1?
If Yes, then use page 2.
If No, then use page 1.
This is called logic and it's the basis of everything. If you can think a design element out using simple questions, there are commands to make it happen.
***More to come tomorrow***
I'm not writing the tutorial specifically for you, been meaning to do something like this for a while heh but I can find out how helpful it is. It's still a WIP.
Read through it and maybe you'll have your answers. If not, just wait til I'm done and I'll have some specific examples you asked for.
-----------------------------------------------------------------------
Understanding Events
The purpose of this tutorial is to help newcomers understand how to do all the basic things that events can do. Everything will be accompanied by images for those who are visual learners. I will include some advanced stuff that you can skip if you don't fully understand it yet. Some of it might require more specific tutorials.
It all starts with a new project. A project is basically a database and a map tree.

The map tree is in the bottom left corner. Right click there to make a new map. I suggest getting into the habit of keeping it organized.

Use empty maps to contain and categorize all similar maps. Try not to make unnecessary long strings of a map inside a map inside a map, or randomly create new maps as you need them.
----------------------------------------------------------------------------
The database is where all behind-the-scenes data is set, but also it's where you find the very important Common Events tab.

=======
Maps are grids where you can place events, like this one. You can only create one event per tile, but you can later move multiple events to the same tile.


------------------------------------------------------------------
Events on a map will only work while you are on that map. When you teleport away from the map, all of the events will be reset the next time you go back. (Unless you use switches to permanently change the events.)

An event running from the Comment Events will work on every map. The way you activate them is different, you need to call them directly or use switches/variables.

Rather than create the same event on every map, you can create it once in the common area and use it on every map! Saves time and space, but you can worry about that later.
---------------------------------------------------------
I'll explain each area of the event.

ID - You can see this in the title bar. Each new event that is created uses the next lowest available number. If you make 10 events and delete ID4, the next event created will be ID4. ID is important when you are specifying an event using code inside of another event.
Name - It's a good habit to name your event to whatever it's function is. NPC1, Treasure4, pushrock, climbtree.... When you call on another event you need to pick it from a list of names.
Page - Each new page is represented by a tab. Click the tab to select the page. The buttons along the top affect the currently selected page.
Each page is basically a new event inside the event. Only 1 page can be active at one time during the game, and you use the Preconditions to change pages. No Preconditions means the page is always active. The page furthest to the right that has its Precondition met will be what shows in the game. If no Preconditions are met, the event will be invisible and inactive.
Preconditions - Leave this empty and the event will always be active. When you pick something from the list, that needs to be true in order for the event to activate.
If you pick two or more things, they all need to happen to trigger the page. By using multiple Preconditions, you can fit a lot of different behaviors and styles into a single NPC.
Event Commands - This is where you put all your code for this event/page. How this code triggers depends on how you set the Trigger Condition.
Event Graphic - This is where you decide the look of the NPC or visible event. Some events need to remain hidden, so you would choose something transparent. There is no "empty" choice, you need to pick something transparent.
Movement - There are some basic patterns in the list, but for more realistic NPC's it's best to create custom paths.
Speed - This controls how long it takes for the event to move to the next tile.
Movement Frequency - This controls how long the event takes to move onto the next movement command.
Animation Type - Determines the behavoir of the event graphic.
Non-Continuous will not cycle the frames while the event is standing still. When it moves the frames will cycle.
Continuous will cycle the frames all the time.
Fixed Dir / Fixed Direction means the event will not turn when going in different directions.
Fixed Graphic will never cycle the frames of the graphic. It's stuck on the the frame you choose when clicking the "Set" button to choose a graphic.
Spin Around will use only 1 frame of the animation, but it will make the event spin around all four directions. Useful for getting an extra frame of animation into a sprite.
Event Layer - There are only 3 layers, each altering the way the Trigger Conditions work. These 3 layers also apply to the tileset.
Below Hero - The player will be able to walk on top of this event. You need to be standing on top to activate the Action Key trigger, simply standing next to and facing it won't work.
Same Level as Hero - The player will not be able to walk through this event. You can stand next to and face to activate the Action Key trigger.
Above Hero - The player will be able to walk under this event. Like Below Hero, you need to occupy the same space to use the Action Key trigger.
Trigger Conditions - This dictates how the Event Commands will activate.
Action Key - The player needs to press the "talk" key on the event.
Touched by Hero - The player simply needs to walk on top of, into, or under the event.
Collision with Hero - This one is tricky and doesn't work as well as you might hope. The layer of the event plays a big part. Play around with it to figure out what works and what doesn't.
Auto-Start - This will happen right away when you teleport to the map, but it will freeze the player and other events until it is stopped. These can break the game if you're careless.
Parallel Process - This is the same as Auto-Start, except that it doesn't freeze anything. The player can move and other events can run at the same time. Even multiple Parallel Processes.
-------------------------------------------------------
Now that all the basic explanations are out of the way, let's start looking at practical examples.
Creating an NPC
Create a new event. Give it a name and a graphic.

This is the most basic example. This is all it takes to create something that will appear on the map. You can use the graphic of a box or a flower to create environment objects. You also can use copies of something in the tileset to create extra layers and fix map errors.
This NPC, Joey, will just be standing around. I imagine almost anyone can figure out how to use the other options to bring him to life so I won't get into that.
Using Pages
Let's say you want Joey to display a message when you talk to him.

Often times when you complete something in the story, you will want to Joey to display a different message. For this we use a Variable.
Simply put, a Variable is something you control that can hold a number. It starts at 0 and remains at 0 until you use a Variable command to change it.
So as the game goes on, let's say you beat the nearby thieves. At the end of that battle there would be a command to add 1 to a Variable we'll call "Main Story Progress". Now that I know which Variable I will be using, I can create a new page on Joey and set the Precondition.

Using Preconditions in this way, you can determine what events the player has completed in the game by tracking them with variables, then have events react based on what the variables are set to. This is an important concept to grasp for all ideas that needs to be coded in any game design program.
One way to look at page 2 is this. The Precondition is asking a basic question.
Is the Variable "Main Story Progress" equal to 1?
If Yes, then use page 2.
If No, then use page 1.
This is called logic and it's the basis of everything. If you can think a design element out using simple questions, there are commands to make it happen.
***More to come tomorrow***
author=NilePro
That's all fine and dandy, but I still don't know how to use variables and switches precisely.
If reading tutorials didn't help then the only solution is to play around with them switches and variables until you do understand how they work. And honestly, it's not that complex.
author=Milennin
If reading tutorials didn't help then the only solution is to play around with them switches and variables until you do understand how they work. And honestly, it's not that complex.
I've tried.
You know what else this tutorial needs?
- Handling vehicle events
- Auto events and parallel events, and when to properly use each (alot of people think parallel are useless, but they're actually more effective for anything that does not involve Move Events, Teleport Events, or anything automated; in other words, you use auto-events for cutscenes and parallel for things that is supposed to go on while the character is doing stuff)
- How to effectively use switches in conditions.
author=NilePro
I've tried.
Then read the tutorial again and try more.
The tutorial above gives you the event commands through screenshots, you can literally copy it over and make it work for you. You won't get it simpler than that.
I never understood tutorials and didn't bother to watch to many.
I found that using stuff and seeing what it did was more useful.
There's a lot of crap in these programs, you need to filter it
out and find out the useful stuff and the best ways to use it.
But I still don't understand why newbies use such an old program.
VX Ace is more user friendly.
I learned more by tweaking other people's code and figuring why doing it that way produced X results. And fiddled around with trial and error seeing what would happen using different methods and/or figuring out whether I could find a simpler way.
author=me
Read through it and maybe you'll have your answers. If not, just wait til I'm done and I'll have some specific examples you asked for.
author=meThis is what a variable is.
Simply put, a Variable is something you control that can hold a number. It starts at 0 and remains at 0 until you use a Variable command to change it.
It's a place to store numbers and you tell the engine to look in that place to see what number is there. You have to use the Variable Operation command to make changes to a variable. If you don't, then it will stay at 0.
You can make the variable become a 7, or add 6 to it, or subtract 3, or divide it by 4. How old are you? Did you learn Algebra? X is a variable. X isn't a number unless it's defined. X can be any number.
The way you make use of Variables is to choose them as Preconditions for event pages or conditional branches. You tell an event to look at a variable, and set actions to happen based on what number is inside the variable.
Just think of every game where the hero has HP. If you want to know how much HP the hero has right now, you would look at the variable "Hero HP". When you get hit, the command is run to subtract a number from the variable. When you heal, the variable is increased.
It's a place to store a number. You tell the engine to watch that number, and if it equals 0, or is less than 0, it should trigger a game over.
Example 1
So let's say you are going use Variable 1. You give it a name, "Game Over", just to help identify it. You want to create an event that will trigger a game over when the variable is changed to 1. When you start the game, Variable 1 will be 0, so the game over will not trigger. Something in the game needs to happen to make the variable go from 0 to 1, and when that happens the game over event will trigger because Variable 1 is now has a 1 in it.
First you create an event with the Precondition of Variable 1 "is equal" to 1.
You set it to parallel process, and inside the event code you put a game over. Parallel process means it will run the game over code automatically, as opposed to the other triggers of Action Key and Touched by Hero.
When you start the game this won't trigger, because the variable is currently at 0.

Then you create another event, it's a tree, you set it to Action Key. So that when you talk to it on the map, it will turn the variable from 0 to 1. Then boom, instant game over because the trigger for the Game Over event just happened. The variable is now 1.

So let's say that we tell the game over event to do something if the variable is equal to 3. And lets say that the variable is "Hero Damage". When you get hit 3 times, game over happens.
There are enemy events walking around the map. When you touch one, it hits you, so it adds 1 to the variable "Hero Damage". The variable went from 0 to 1, but remember the page is now looking to see when the variable is 3. So nothing happens.
You get hit again. The variable goes from 1 to 2. Nothing happens.
You get hit again. The variable goes from 2 to 3. The page sees that the variable is now 3, so the game over triggers. You are dead.
-----------------------------------------
A switch is EXACTLY the same as a variable. The difference is that a switch can only be ON or OFF. It's the same as a variable that can only hold a 0 or a 1. They are used the same way. An event has to turn ON or OFF a switch, they don't do anything on their own. A second event needs to use the switch as a trigger.
Example 2
You want to unlock a door. Well what do you need? A door probably.
So the first step is to create a locked door.

If the player talks to it, oops, it's locked.
Now if you want something different to happen, you need to setup a conditional branch. If the player does not have the key, they should see the message about the door being locked. But, if they have the key, they should see a different message that says you can open the door.
That's the branch:
If the player has the key, do A.
If the player doesn't have the key, do B.
The branch will be looking in your inventory, checking for a specific item. The key.
Of course you need to go into the database and create the item. Then in your event you use the Conditional Branch command. What we need is on the second tab of commands, and as you can see it's checking if the party possesses the key.

The check box at the bottom is asking you if something should happen if the condition is not met. Since we do want something different to happen if the player does not have the key, we need to make sure that is checked.
In the next image, the first part is what an empty branch looks like. It tells you what it's looking at, it says "Branch if Key Possesed". So in the space directly following that is where you put the code for what should happen if that is true. Then it says "Else handler", this is where you put the code if that first thing is not true.
The second part is what it looks like when you put a message for each possible outcome.

So now the player would have to leave and go find the key. Maybe they talk to an NPC who gives them a key. You use the command for adding something to the players inventory, give them the key, and they will come back to the door.
So now that you have the key, and a way to for the door to tell if you have the key, you need to make the door change from locked to unlocked. To do that you add a second page to the event, and make it look and act like an open door.

You might make the graphic blank, but since this is set to below hero the player can now walk through. So now we need to make sure this page of the event is only active after the player talks to the door while holding the key. In order to do this we need a way to tell the engine that has happened. And for that we will use a switch.
You'll notice that I added a line of code in the part of the branch for when I have the key. I turned on a switch.

The last thing to do is tell page 2 to look for that switch being turned on. To do that you set it as a Precondition.

When the player talks to the door, it will see you have the key, say you can use the key, and turn on a switch. As soon as the switch is turned ON, page 2 becomes active, and the event changes to an unlocked door.
From now on, as long as that switch stays ON, the door will remain unlocked for the rest of the game. If you want to lock the door again, all you need to do is turn OFF the switch. It will cause page 1 to show instead of page 2, and you'll need to open the door again.
I used a switch in this example, but I could have used a variable. Instead of turning ON the switch in page 1, and using that switch as a Precondition in page 2. I could have added 1 to a variable in page 1, and used that same variable as a Precondition for page 2. I could have even given the player an item, then have page 2 to check if the player has the item I just gave it. Whatever you set as a Precondition for page 2, just make that happen in page 1 and it will turn the page.
You just have to remember that an event wants to activate the page with the highest number. So in this image:

There is no Precondition for page 2. When you walk up to this event in the game, it will be unlocked. Because page 2's Precondition is met. By setting a Precondition, you are restricting this page from showing until you say so. Turning on the switch is you "saying so".
If you understand these examples, then you should be able to make any basic event setup.
Thank you thank you thank you! I found a more simplified way of handling things. I eliminated the need for an inventory by using puzzle-based item system. I basically set it up so that containers using the "item" have a variable attached to a specific object that uses said item. Thank you so much for your help. I'll have to impliment a more hardened system in a later rpg.
Pages:
1















