How do I...make an event damage the player on a particular page?

Joined
Jul 12, 2020
Messages
156
Reaction score
29
First Language
English
Primarily Uses
RMMV
So I have created an obstacle that has the following so far:
3 pages:
1st page (very back): Idle on a timer, turn on Self-switch A
2nd page (middle with condition of Self-Switch A on): still idle on a timer, turns on Self-Switch B.
3rd page (Very front with condition of Self-Switch B on): displays some emitting "gas" while on a timer, then both self-switches (A and B ) turn OFF to cycle back to page 1 all over again.


Throughout these events, the priority is below the characters, and the trigger is parallel.

How do I make it to where, on the 3rd page, if the player happens to be touching the event while on this page....the player suffers damage? I feel like it's something to do with the trigger, but I can't quite find a way to check if the player is touching the event during this page.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
32,835
Reaction score
8,232
First Language
German
Primarily Uses
RMMV
don't change the pages on a parallel process, especially not if there are dozens of similar events.

you'll need at least two different event.

one event on parallel process controlling all other changing trap events - especially if you have many more of them.

On the trap events themselves, all harmless pages should be action button an doing nothing, while the harmfull pages should be on player touch and have the commands to reduce HP or whatever.
 

Htlaets

Veteran
Veteran
Joined
Feb 1, 2017
Messages
208
Reaction score
113
First Language
English
Primarily Uses
I agree with Andar that it's best to have a master event. That being said, if you want to keep the current config, the best way to do it is to have the event loop several times before deactivating (Yanfly Self-variable or a temporary variable counting down), have each loop wait for less time than it takes for the player to move from one tile to the next, check player position vs the event position every loop, and if they match trigger the damage. Thhhattt being said you're far better off doing the master event idea.

If you want your gas events to have different timing, you could get creative with math to have a single variable control them all with different events active at different numbers e.g. gas event 1 is active when the temp variable is 1-5, gas event 2 is active from 3-8, etc.
 
Joined
Jul 12, 2020
Messages
156
Reaction score
29
First Language
English
Primarily Uses
RMMV
don't change the pages on a parallel process, especially not if there are dozens of similar events.

you'll need at least two different event.

one event on parallel process controlling all other changing trap events - especially if you have many more of them.

On the trap events themselves, all harmless pages should be action button an doing nothing, while the harmfull pages should be on player touch and have the commands to reduce HP or whatever.
I'm trying out your suggestion first, but how exactly do I tell the parallel event to turn pages on another event? I don't want to have to use a ton of switches for every single trap...
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
32,835
Reaction score
8,232
First Language
German
Primarily Uses
RMMV
there is a script command to change the self-switches of other events.

you'll have to look it up, it's a bit complex because you need to identify the switch by a data sequence, but it will allow you to change the pages by that event's self-switches.
 

Htlaets

Veteran
Veteran
Joined
Feb 1, 2017
Messages
208
Reaction score
113
First Language
English
Primarily Uses
All you need is a variable, you don't need to change switches. Just have a variable labeled "Tempvariable" and lay out the pages such that the variable can easily control the flow. You can reuse the variable elsewhere.
 
Joined
Jul 12, 2020
Messages
156
Reaction score
29
First Language
English
Primarily Uses
RMMV
All you need is a variable, you don't need to change switches. Just have a variable labeled "Tempvariable" and lay out the pages such that the variable can easily control the flow. You can reuse the variable elsewhere.

Hmm, could you perhaps walk me through how you would approach this example using Tempvariable?
I actually just finished trying out the previous suggestion, and it works just fine (shown in photo), but I feel like the way you're explaining it could potentially be more efficient...It would be nice to not have to use an array script every time I want to implement some traps haha.

Screen Shot 2021-05-14 at 2.59.58 PM.png
 

Htlaets

Veteran
Veteran
Joined
Feb 1, 2017
Messages
208
Reaction score
113
First Language
English
Primarily Uses
Hmm, could you perhaps walk me through how you would approach this example using Tempvariable?
I actually just finished trying out the previous suggestion, and it works just fine (shown in photo), but I feel like the way you're explaining it could potentially be more efficient...It would be nice to not have to use an array script every time I want to implement some traps haha.

View attachment 189298
Basically all your master has to do is push a variable once every tick (for that event, you'll have to keep the sounds in conditionals to go off when they're relevant).

What you'll need to change is your event pages. Say you have the variable increment every 60 frames and start at 0. To have the same effect:

Change the self-switch A portion of the event to be active when the tempvar >= 5 get rid of the self-switch condition.

Change the self-switch B portion of the event to only be active when tempvar >= 7 and get rid of the self-switch condition. In the master event, have a conditional where if tempvar >=7 play your sound on every loop.
Then, have the master event bring the tempvar back to 0 once it reaches 10. Timing should be exactly the same and it'll reset back to the first page.

So, your master should just be a Check condition for sound->Check condition for setting things back to 0->Tempvar +1->wait 60 frames.
 

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
4,006
Reaction score
1,520
First Language
Dutch
Primarily Uses
RMMV
more like variable x:
condition of pages
page 1 = no variable,
page 2 = variable x >= 1
page 3 = variable x >= 2

on page 1, after timer, variable x +=1
on page 2, after timer, variable x +=1
on 3rd page, after timer or attacking animation to damage the player
variable x = 0 (or variable x -= 2 (which is the same, but 0 reset

(which I would do) but the above one works too.
there are more methodes that achieve the same effect, but basicly, you need
2 pages, 1 with timer, 1 for attack and repeat, so why 3 pages?
 

Htlaets

Veteran
Veteran
Joined
Feb 1, 2017
Messages
208
Reaction score
113
First Language
English
Primarily Uses
more like variable x:
condition of pages
page 1 = no variable,
page 2 = variable x >= 1
page 3 = variable x >= 2

on page 1, after timer, variable x +=1
on page 2, after timer, variable x +=1
on 3rd page, after timer or attacking animation to damage the player
variable x = 0 (or variable x -= 2 (which is the same, but 0 reset

(which I would do) but the above one works too.
there are more methodes that achieve the same effect, but basicly, you need
2 pages, 1 with timer, 1 for attack and repeat, so why 3 pages?
The timing for stage one and 2 isn't the same in their event (300 frames for one, 120 for the other, and then the other runs for 180) so you have to have more increments. That being said, I'm assuming there's three pages because there's a "visual warning" sprite in-between before the player is gased.
 

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
4,006
Reaction score
1,520
First Language
Dutch
Primarily Uses
RMMV
wait 300
variable X += 1
wait 180
variable x += 1
wait 240
variable x +=1

unless animation change between page 1 (normal), 2 (charge), 3 (fire)
than it's a different story though. otherwise, variable or wait can be simple,
wait 300
wait 180 (or wait 480 in 1x)
than switch page. it depends what the exact event should look like :)
 

Htlaets

Veteran
Veteran
Joined
Feb 1, 2017
Messages
208
Reaction score
113
First Language
English
Primarily Uses
wait 300
variable X += 1
wait 180
variable x += 1
wait 240
variable x +=1

unless animation change between page 1 (normal), 2 (charge), 3 (fire)
than it's a different story though. otherwise, variable or wait can be simple,
wait 300
wait 180 (or wait 480 in 1x)
than switch page. it depends what the exact event should look like :)
You can work it this way, but there's another part of this: the sound that plays every 60 frames after the second stage. Basically, I'm just pointing out the way with the least clutter: two conditionals, one variable change, one wait. You'll need the same amount of event pages regardless, and you'll still need to reset the variable to 0 at the end.

And if you decide you want to add more traps that follow different rules you can have them activate based off this same event, just at different intervals.
 
Joined
Jul 12, 2020
Messages
156
Reaction score
29
First Language
English
Primarily Uses
RMMV
Yeah, just to clarify guys:
I have 3 pages because there's 3 different sprites (Well, really 9 but I have stepping on all the time so its fine)

On the 1st page, there's a 5 second wait (300 frames) before the sprite changes.
On the 2nd page, it changes to the "warning" sprite that lasts 2 seconds (120 frames) before giving damage.
On the 3rd page is finally when the obstacle emits the harmful gas for 3 seconds (180 frames) before reverting back to page 1 to start all over again.

Not really sure if that clarifies my goal, but the variable options sounds a bit promising. It's just gonna be a bit tricky to manage if I decide to have...well, more than 1 of said trap.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,363
Reaction score
2,486
First Language
English
Primarily Uses
RMMZ
Yeah, just to clarify guys:
I have 3 pages because there's 3 different sprites (Well, really 9 but I have stepping on all the time so its fine)

On the 1st page, there's a 5 second wait (300 frames) before the sprite changes.
On the 2nd page, it changes to the "warning" sprite that lasts 2 seconds (120 frames) before giving damage.
On the 3rd page is finally when the obstacle emits the harmful gas for 3 seconds (180 frames) before reverting back to page 1 to start all over again.

Not really sure if that clarifies my goal, but the variable options sounds a bit promising. It's just gonna be a bit tricky to manage if I decide to have...well, more than 1 of said trap.
Self switches are just an array like switches are; the only different is that rather than the key being a single digit, the key is itself an array consisting of the map ID, event ID and self switch letter (if you're changing them with code, you can even if you really want to have self switches beyond D and they don't even need to be letters, they can be numbers or entire phrases technically). The syntax for it is

$gameSelfSwitches.setValue([mapid, eventid, 'letter'], true/false)
 

Htlaets

Veteran
Veteran
Joined
Feb 1, 2017
Messages
208
Reaction score
113
First Language
English
Primarily Uses
Yeah, just to clarify guys:
I have 3 pages because there's 3 different sprites (Well, really 9 but I have stepping on all the time so its fine)

On the 1st page, there's a 5 second wait (300 frames) before the sprite changes.
On the 2nd page, it changes to the "warning" sprite that lasts 2 seconds (120 frames) before giving damage.
On the 3rd page is finally when the obstacle emits the harmful gas for 3 seconds (180 frames) before reverting back to page 1 to start all over again.

Not really sure if that clarifies my goal, but the variable options sounds a bit promising. It's just gonna be a bit tricky to manage if I decide to have...well, more than 1 of said trap.
The variable actually makes it easier to have more than 1 trap, you just have to math it out. You might need to add additional event pages for the loop around (let's say you only want Gas trap 1 active until tempvar = 10, but gas trap 2 needs tempvar to get to 14, then you would have to add additonal event pages to gas trap 1).

Either way, the parallel event I outlined should cover that, and be able to have a variable change for every second.
 
Joined
Jul 12, 2020
Messages
156
Reaction score
29
First Language
English
Primarily Uses
RMMV
The variable actually makes it easier to have more than 1 trap, you just have to math it out. You might need to add additional event pages for the loop around (let's say you only want Gas trap 1 active until tempvar = 10, but gas trap 2 needs tempvar to get to 14, then you would have to add additonal event pages to gas trap 1).

Either way, the parallel event I outlined should cover that, and be able to have a variable change for every second.

Okay! I'll go ahead and give this a shot and let you guys know if it's working or not.
 
Joined
Jul 12, 2020
Messages
156
Reaction score
29
First Language
English
Primarily Uses
RMMV
The variable actually makes it easier to have more than 1 trap, you just have to math it out. You might need to add additional event pages for the loop around (let's say you only want Gas trap 1 active until tempvar = 10, but gas trap 2 needs tempvar to get to 14, then you would have to add additonal event pages to gas trap 1).

Either way, the parallel event I outlined should cover that, and be able to have a variable change for every second.

Alright! I gave it a shot and tested it out a bit with some different values. I even offset some of the traps so they go off at different intervals. Works like a charm dude, thanks!! :D

I will be sure to use variables for more complex traps later on.
 

Latest Threads

Latest Profile Posts

It's almost 3 month and this piece of drawing is still not finished yet.
aaaa.jpg

Really busy with other stuffs like commission and coping with personal problem.
Stella & Elyune, maybe used for promotional art if my game project finished one day.
My ex put my heart upon a self he said don't give me no lines and keep my hands to myself :,(
An Old... old Harold | RPG Maker News #71

Did a test on myself and I was negative on COVID. I was sitting near my aunt the whole time while doing stuff.

Forum statistics

Threads
112,248
Messages
1,066,815
Members
145,854
Latest member
markikilouis231
Top