Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

event's location as a condition

In my RPG maker XP game, I want to make an event trigger when an event is at a certain location. (you can push the event around as you want) How do I do this?
 
You use a parallel-process event which checks variables that you set to the X and Y of that event. When both variables are at the coordinates that you want, you trigger the event.

If that wasn't clear, let me know-- I have a small army of screenshots illustrating the principal.
 
Sawnik":2ygv03yq said:
Sure, show me some screenshots. I didn't understand how to make it check the location... :P

Righto. Warning: Lots of screenshots.

Further warning: This is pretty much intended to be a teaching tool-- in an actual game, parts of it would be structured differently. I'll try to point these bits out.
BoulderPuzzle1.png

This here is the overall map. The object of the puzzle is to push the boulder onto the little patch of grass. When there's a weight on top of the patch of grass, whether it's boulder or player, the door is open. Otherwise, it's shut.
BoulderPuzzle2-1.png

Here's the boulder. Very simple.

BoulderPuzzle5.png

Here's the door, page one. It does nothing until page two's conditions are met.

BoulderPuzzle8.png

And here's page two of the door, activated by a switch that will be covered later.

BoulderPuzzle3.png

BoulderPuzzle4.png

These two events are how the game tracks the location of both player and boulder. Note that it is not necessary to actually make two different events-- I just did that to show each step. (Obviously, you also don't need to make them visible.)

Note that they are parallel process events without conditions-- they run the entire time that the player is on the map, in the background. Using too many of these will cause lag.

BoulderPuzzle6.png

This event is tracking whether or not the boulder or the player is on the patch of grass, by comparing their map coordinates to the coordinates of the patch of grass. If either one is, it opens the door by turning the "Door Open" switch ON.

The Door Open switch being ON activates the second page of that event...
BoulderPuzzle7A.png


BoulderPuzzle7B.png

This bit of code is trickier. What it's doing is checking to see if either the boulder or the player is on the switch. If neither is, it shuts the door again, resetting the event.

Want to make a simpler version? You can eliminate a lot of code if you don't want the player to be able to trigger the switch, and eliminate those last two screenshots entirely if the door doesn't close again.

On the other hand, I like this version of the puzzle-- it's a fair logic puzzle. The player can deduce that weight needs to stay on the switch, and thus can work out that the boulder can be pushed onto it.

Was that helpful enough?
 
if I'm not mistaken that coordinate would be 5,9.
RmXp is counting from left to right and up to down (the top left being 0,0). Just try to hover your mouse over the tile in the editor. In th lower left there should be shown wich coordinate it is.

Hope this helps

~Dalton~
 
Also, the way you've structured your code, Unka Josh, when checking if the player or boulder has moved off the event is wrong. You've got if the X AND Y are not equal to 9. So, a player could move off the switch while one of those two coordinates is still 9. What you want is to structure it more like; if X OR Y are not equal to 9, which you do by having multiple conditional branches. So it would be something like...

>Conditional (X !=9)
>Switch off
>End Branch
>Conditional (Y !=9)
>Switch off
>End Branch
 
When setting a conditional brach you have the option to "set handling when conditions do not apply".
Just uncheck that one and else is gone. However an empty elsehandling and no else handling at all do the same thing. It just is easier to read the code without empty ones.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top