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.

Moving Trap

Hello Eventers,

I am in the need of some assistance.
I am trying to create a trap in a dungeon level and am having a few issues with it.

What I'm trying to do is create a trap that moves horizontally across an area (ex. A fireball or something), and when it hits the player he is sent back to the beginning of the area. When it hits the wall it disappears and reappears back on the other side and loops again and again.

If you need any more information or even an example picture let me know.

Thanks to any who try.
 
The simplest method would be to create an event set to Event Touch that transfers the player back to the beginning of the area. Then give it a custom move route. If you want it to loop, either have a parallel process that moves it back every x frames, or set it to change opacity to 0, jump back to its original position, then reappear.
 
There are many different ways to handle this, and not knowing the version of RPGMaker you have, all I can offer is something less than psuedocode. Ideally, you want an event other than the 'trap event' to handle the resetting of the trap. So create two events. The first event is the 'trap event' and is the actual graphic of the trap. The second is the 'handler event' and is an invisible event that is off the area of the map where the player can move. Here is what you want to do:

For the 'trap event':

1) Set the trap at it's starting location. Remember the X and Y coordinates of that location, called the 'trap starting location'. You may or may not put them in a variable.

2) Set it's movement to automatic, one space to the left (or right), with 'ignore impossible movement' checked.

3) Set 'trap event' to trigger when 'Event Touch' (or if using RPGmaker 2003, use 'Collision with Hero'). This will ensure that the trap is triggered when the player and trap touch, not just if the player touches the trap.

4) In the list of event commands for the 'trap event', code in your effects for getting hitting and teleporting back to the 'player starting location'. You may or may not put that in a variable.

5) Now if you play your map, you will see that the trap moves ONCE, sending the player back to the start of the dungeon if it hits. You are halfway done.

6) Go to the map and write down the X and Y coordinates of the area where the trap should 'reset', the 'trap ending location'. The X should be different, and the Y should be the same as the values in 'trap starting location'. This is the 'trap ending location'. You WILL need a variable for this, let's call it 'trap current location'.

7) Go into 'handler event' and set it to 'Parallel Process'. For the list of event commands, enter the following (this is psuedocode, so exactly what you enter depends on the version of RPGMaker):

variable 'trap current location' = sprite 'trap event' x coordinate
if 'trap current location' >= 'trap ending location' (if moving from left to right...or =< if moving from right to left)
[*]set position of 'trap event' to 'trap starting location'
variable 'trap current location' = 'trap starting location'

8) Test your game. The trap should reset when it reaches the end of its run.

You may ask why you set the 'trap current event' to 'trap starting location' after teleporting the event? The reason is to ensure that, as unlikely as it can be, that the trap doesn't reset as soon as it resets. I've seen this problem with the game engine only happen with certain early hacked versions of RPGmaker 200 and 2003. More than likely, that last line of code is not needed.

If you're saavy, you can extend trap's movement beyond the walls of the 'dungeon' by one a piece to make it look like the trap is coming out of and going into the walls. This is more complex, and I'd urge you to experiment with it yourself so you can better learn event-scripting.

Good luck!
 
Thanks a lot MayorAnime for all the help.
I apologize I should have given some more background as to which version I am using.
I'm Using VX.

I got lost at one part though.
variable 'trap current location' = sprite 'trap event' x coordinate
if 'trap current location' >= 'trap ending location' (if moving from left to right...or =< if moving from right to left)
[*]set position of 'trap event' to 'trap starting location'
variable 'trap current location' = 'trap starting location'
If you would please just help me understand the exact procedures in which I am using here it would be great.
This is what I have done so far for the Handler's Event.
HELp.jpg
 
I am not experienced in VX at all, but from what I can tell, that should do it. Just make sure that event is 'Parallel Process'. Have you tried testing it? Trial and error are the best ways to learn here. It's not like you can delete your game by having an event coded incorrectly. :lol:

Good luck!
 
I don't know, I'm kinda feeling theres a better way. Two Events. Using no Variables. But I'm School, so I can't look at RM right now. But I'm going to try my hand at this. bare with me.

Ok so you need the event to always be on the move. So in the Autonomous Movement to the route that you want (looks like moveing left). Now when you have all the move events mapped out (the fireball (as the example you used) will move from left to the end of the hall (or what ever you want this in) and then it will stop), at the end of all that you need to turn on a switch (trap Restart). It will look something like this, assumeing your going right to left and your only moving 10 spaces, this is an example it can be what ever you need it to be:

Code:
Move event:

 

Move left

Move left

Move left

Move left

Move left

Move left

Move left

Move left

Move left

Move left

Turn Switch: Trap Reset = ON

The move event also has to be on repeat.

Now for the actually event commands. make the event Speed a bit faster and the Freq higher. That way it looks good and flows well. Next you need to set the trigger to Touch. Now on the event sheet make a command that the player is transfered (if its a trap like a fireball, you should make it hurt the player) back to the beginging of the area. This way when the player touches the event it transfers him. Thats its. Thats all for the Trap Event.

Next make an Event that is off to the side and no graphic. put it on Parralle Process. Then put a conditional Branch reading if the Trap Reset Switch is on. It should look something like this:

Code:
>Conditonal Branch: Switch: Trap Reset = ON

   > Set Event Location: [Event ID](this is like a transfer player command, but for events. you need to have it set to The ID of the Trap Event. Then have it set to where the Fire Ball was first at.)

 

   > Else

 

  >end

But again I'm at school. If i'm an epic fail tell me. I'm sure I'll get home and work it out anyway. I'm like that. If you need anything tell me. I don't know. It seemed like a simple request and I feel like there is a simple way to do it. I hope mine worked. Cause it would save you some Variables.
 

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