Dragon_Soul

Villager
Member
Joined
Mar 26, 2021
Messages
11
Reaction score
0
First Language
English
Primarily Uses
RMMV
I don't know if this is possible but I figured I'd ask. Is it possible to have a timer, when it reaches 0, to trigger damage floors, and then turn the damage floors off when the timer is stopped? I am working on a game where you have to stay on the colored path, go off the path and a 5 second timer activates until you return to the path. If you don't return to the path in the 5 seconds, you start taking damage until you return to the path or you die. Is this type of thing possible or am I asking for something impossible?
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
6,052
Reaction score
5,708
First Language
English
Primarily Uses
RMVXA
I would probably do this by specifying Terrain Tags (or Region IDs) for the damage floor tiles in the editor, and then using a Parallel Process Event, rather than traditional Damage Floors. I think it would go something like:
Wait: 60 Frames
Get Location Info: Variable #25 (or whatever you want), Terrain Tag (or Region ID), Player
Conditional Branch: If Terrain Tag #25 = 1
.... Control Variables: Variable #30 (representing Seconds on Damage Floor), Add 1 to its value
.... Conditional Branch: If Var #30 > 5 (this ensures it's AT LEAST five seconds since stepping on)
........ Change HP: Party, Decrease by Whatever Amount, Allow Death
........ Flash Screen (to let the player know he's taking damage)
.... End Branch
Else
.... Control Variables: Variable #30, Set value to 0
End Branch

Note that if there are lots of maps in your game with these 5-second damage floors, it might be wiser to use a Parallel Process Common Event (just set its Condition Switch to be something that's always ON - it's okay that it will run continuously because the 60-frame wait lightens the processing load a lot), rather than a single Parallel Process Event on every map that has damage floors.
 

Dragon_Soul

Villager
Member
Joined
Mar 26, 2021
Messages
11
Reaction score
0
First Language
English
Primarily Uses
RMMV
My game has territories that follow the path rule so a common event is wise. How would I find the tag of the terrain?
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
6,052
Reaction score
5,708
First Language
English
Primarily Uses
RMVXA
My game has territories that follow the path rule so a common event is wise. How would I find the tag of the terrain?
Terrain Tags are set (by you) on the "Tilesets" tab of the database, and can be accessed using the Get Location Info event command.
 

Dragon_Soul

Villager
Member
Joined
Mar 26, 2021
Messages
11
Reaction score
0
First Language
English
Primarily Uses
RMMV
One last question and I think I have this figured out, do I want to have Damage Floors off for this to work? I hope I'm not spamming you.
 
Last edited:

Dragon_Soul

Villager
Member
Joined
Mar 26, 2021
Messages
11
Reaction score
0
First Language
English
Primarily Uses
RMMV
It works perfectly! Thank you so much for teaching me this!
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
6,052
Reaction score
5,708
First Language
English
Primarily Uses
RMVXA
One last question and I think I have this figured out, do I want to have Damage Floors off for this to work? I hope I'm not spamming you.
Yes, I believe the best way would be to keep the regular Damage Floor flags turned off.

It works perfectly! Thank you so much for teaching me this!
You're welcome! :D Glad you were able to get everything working as you like it.
 

Dragon_Soul

Villager
Member
Joined
Mar 26, 2021
Messages
11
Reaction score
0
First Language
English
Primarily Uses
RMMV
Now I am having an issue with this, it was working fine before, but the timer count for the common event won't go back to 0 when turned off, it stays at 5 and causes the player to take damage as soon as they step off the path. Did I do my code wrong?Common_Event_Timer.PNG
 

Frogboy

I'm not weak to fire
Veteran
Joined
Apr 19, 2016
Messages
1,834
Reaction score
2,340
First Language
English
Primarily Uses
RMMZ
I did something very similar for a puzzle game that I made called Heir to the Kingdom. Some puzzles have spiked floors that pop up and go down, pit traps that open and close or electric floors that turn on and off. It's tricky to get just right. I released the source code for this project so feel free to look through it to see how I implemented these on-screen hazards.
My traps are on a repeating loop so you'll have to figure out how to pause the traps until the player goes off the path to arm the traps but that shouldn't be too difficult.
 

Dragon_Soul

Villager
Member
Joined
Mar 26, 2021
Messages
11
Reaction score
0
First Language
English
Primarily Uses
RMMV
The floors aren't trapped when they walk off the path, it's a bit hard for me to explain, but the path is the safe area and when you walk off the path the timer starts. When the timer hits 0 you start taking damage because of the rules of the territories. I can't get the counter to reset for some reason, so players end up taking damage when the walk off again before the timer hits 0
 

Frogboy

I'm not weak to fire
Veteran
Joined
Apr 19, 2016
Messages
1,834
Reaction score
2,340
First Language
English
Primarily Uses
RMMZ
Looking closer at your event, it looks like the timer gets set or reset to zero while you're on the path for up to one second. While off the path, it waits 5-6 seconds and then damages you every second until you get back on the path for up to a second.

Your problem might be the full second delay. If you walk on the path and then back off, it might not reset. You might want to cut that down to quarter seconds and increase the counter by 4 to compensate.

Edit: To be clearer. Try a 15 frame wait and change to Timer > 20.
 
Last edited:

Dragon_Soul

Villager
Member
Joined
Mar 26, 2021
Messages
11
Reaction score
0
First Language
English
Primarily Uses
RMMV
I figured it out, in order for the common event to stop on the path, I have to have the path turn off the switch that triggers the event, so it never has the chance to reset, so I make the path reset the Variable Timer for the event instead. Works just fine.
 

Latest Threads

Latest Posts

Latest Profile Posts

For a long time I always consider XP soundtracks as the best one.
Just listened to some of MZ tracks from the free version.
It's... Quite mindblowing. xD
Only listened to the battles, towns, and fields.
But I'm sure the rest are equally good. :D
What do you guys want to see for the new Jump into Javascript? A continuation of the rpg_objects, or would you prefer a "lesson 0" where I go back to the absolute basics of Javascript and cover the fundamentals of the language and its construction?
Hey RPG members!!

How do you finish projects? Some new game developers start off strong but end up losing momentum. What keeps you motivated while working on new projects?
Feeling wee sleepy.. ZzzZ
So many threads to move to the right place. My post count is awesome, but 95% of it is due to moving things.

Forum statistics

Threads
112,454
Messages
1,068,395
Members
146,112
Latest member
YFAB
Top