For my game, I'm making a room that has your typical spikes on the floor. I know that you have to use region ids for the player to take damage, but how can I do it when the spikes move like this?
Spikes on the floor with a certain order.
RPG Maker MV SupportI think not doing that might work better in this case, actually.
I threw together a quick proof of concept for you in MV.
Set up your event like this:
For that script call to work, you'll need the following code in a plugin. If you don't want to use a plugin, you could make an autorun event on the map and put it in a script call, followed by a Control Self Switch A = ON command.
JavaScript:
Game_Interpreter.prototype.checkPlayerHere = function() {
var ev = $gameMap.event(this.eventId());
if(!ev) return false;
return $gamePlayer.x == ev.x && $gamePlayer.y == ev.y;
};
The key points on the left-hand side are the custom move route and the Parallel type. The move route should look like this:
You'll probably want to change the wait values both in the move route and the event contents – I set it to 5 for testing, but that's quite slow. If it's best with no wait at all in the move route, you might need to fiddle with the event commands to avoid lag (possibly move the wait into the inner conditional and figure out what value works).
Again, this works in MV, and would probably work in MZ as well. The concept probably works in other makers as well, but the JS code would need to be translated into Ruby.
I tried to replicate it, but when the player steps, nothing happens.
Did I do something wrong?
You could try removing the wait in the event contents. I think that might cause some other problems (in my testing, spikes are getting out of sync with each other when offscreen), but it should make it trigger every time the spikes are up.
you could have also had one parallel event increment a variable, use a modulus so that its values can ever only be 1-5, and then set each of those events as player touch with page conditions for each being specific variable values.
you wouldnt need to check the pattern or set up movement routes. youd just have 2 pages where the default is that the spikes are down and an active page where theyre up
you wouldnt need to check the pattern or set up movement routes. youd just have 2 pages where the default is that the spikes are down and an active page where theyre up
I don't think that works without a plugin? You can only check if a variable is greater than or equal to a specified value, but for this use-case you need to check exactly equal to. It would probably work with something like HIME_CustomPageConditions though… but I'm not sure how the two intermediate frames of the animation would fit in with that model. (The original poster appears to have chosen not to use them, but personally I would prefer to use them.)
the loop of the 4 rows, the top 3 (start in middle has those wait.
30, 45 // row 1
25, 40 // row 2
20, 35 // row 3
15, 55 // row 4
5, 50 // row 5
numbers are wait, so you have a move route of 30 wait, same moveroute
below it, but with 45 wait in between, 4/5 frames per turning (down/left/right/up)
and back down.
so you have the effect like: 1,2,3,4,5,3,4,5,1,2,3,4,5,3,4,5 in repeat session.
30, 45 // row 1
25, 40 // row 2
20, 35 // row 3
15, 55 // row 4
5, 50 // row 5
numbers are wait, so you have a move route of 30 wait, same moveroute
below it, but with 45 wait in between, 4/5 frames per turning (down/left/right/up)
and back down.
so you have the effect like: 1,2,3,4,5,3,4,5,1,2,3,4,5,3,4,5 in repeat session.
ah, forgot there wasnt a choice there, but it just means the logic just needs a slight adjustment. since the variables are integers, you can make equal cases by using equal to or greater than comparisons.
base case is the spikes are disabled, theres an active case where the spikes are up and its requirement is the variable is of equal or greater value to something, and then an additional active case to disable the spikes again for the value above the previous one
Code:
$gamePlayer.x === $gameMap.event(this.eventId()).x && $gamePlayer.y === $gameMap.event(this.eventId()).y
Switches could have also been used instead of variables, but depending on how many possibilities of active spikes there should be it might take a bit more to set up.
Yeah, I just think it's clearer to put it in a function like I did in my previous post.
I ended up with something pretty similar to robro33's solution, but using HIME_CustomPageConditions and my custom checkPlayerHere() script:
Note that the move routes are set not to repeat. Then the only thing I needed to change on individual spikes is the frame I'm checking for in the conditional statement (on both pages).
found out it can be done without the active spikes being parallel. they can be changed to player touch and the controller can use a base engine script call to run the spike event if the player is on it when it changes. I thought it hadnt worked earlier, but it seems to have just needed a minor delay.
Spike
Controller
Controller
That seems like it would trigger any event the player happens to be standing on, not just the spikes. It might be fine if you don't have any other events the player would stand on, though.
any player touch event the player is standing on. other trigger types wont count, and if the map has other player touch events that arent spikes that may be stood on, a conditional branch that checks the region the player is in can be used to filter them out
Yes! This is exactly how I wanted it! The variables do make it work better.
There was a problem with the game over sequence, but that was a mistake on my part, fixed now.
Original thread: https://forums.rpgmakerweb.com/threads/spikes-on-the-floor-with-a-certain-order.179814/