blakwhiteknight

Veteran
Veteran
Joined
Jun 30, 2013
Messages
37
Reaction score
7
First Language
English
Primarily Uses
So, I was able to get Yanfly's Stealth Mode to work, but now the problem is that I do not know how to do a cooldown system for it.

The general gist is that when you press 'F' key with a certain character, you enter Stealth Mode for 10 seconds. Once the 10 seconds are up, you cannot use the skill for 5 seconds (pressing F will just have nothing happen, or a buzzing SE). Obviously, once the 5 seconds are up, you can press F and use the Stealth Mode again. Then rinse and repeat.

Succeeded with press F key and Stealth Mode itself to work. But the cooldown system is what I'm unsure on how to go about it.
(Please ignore the 120 - it's there for test purposes but it'll be changed to 600 when everything's solved.)
1674490107664.png

Timers are probably my biggest weakness thus far and I want to try and understand them better as I've only had...well, lack of success with them.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
8,920
Reaction score
6,731
First Language
English
Primarily Uses
RMMV
Just to be clear, when you say Yanfly's Stealth Mode, do you mean Yanfly's Event Chase Stealth?

When asking for help, it's preferred that you provide a link to the plugin so we know what you're talking about - but if you don't do that, at least make sure it's the correct name :wink:

There are a few issues with your event. First, you shouldn't be executing that script call that changes the keyMapper every iteration. That should happen one time at the beginning of your game.

Next, you should almost never have a parallel even with no wait command in it - running every frame is bad practice. It would be a superior solution for this for you to use Yanfly's Button Common Events, which will take care of the input handling for you. (and you don't have the keyMapper script at all)

You mention the player going into stealth for 10 seconds, but then the plugin command you entered is StealthTime 120, which is 2 seconds.

SO: having said all that, I would put this into a common event, triggered by the Yanfly plugin. In that common event, put (this is pseudo-code):
Conditional Branch -> isStealthMode
- StealthMode Off
- Control Timer -> 5 seconds
- exit event processing
Conditional Branch -> Timer -> >0
- play error sound effect
- exit event processing
StealthMode 600
Control Timer -> 15 seconds
 

blakwhiteknight

Veteran
Veteran
Joined
Jun 30, 2013
Messages
37
Reaction score
7
First Language
English
Primarily Uses
Just to be clear, when you say Yanfly's Stealth Mode, do you mean Yanfly's Event Chase Stealth?

When asking for help, it's preferred that you provide a link to the plugin so we know what you're talking about - but if you don't do that, at least make sure it's the correct name :wink:

There are a few issues with your event. First, you shouldn't be executing that script call that changes the keyMapper every iteration. That should happen one time at the beginning of your game.

Next, you should almost never have a parallel even with no wait command in it - running every frame is bad practice. It would be a superior solution for this for you to use Yanfly's Button Common Events, which will take care of the input handling for you. (and you don't have the keyMapper script at all)

You mention the player going into stealth for 10 seconds, but then the plugin command you entered is StealthTime 120, which is 2 seconds.

SO: having said all that, I would put this into a common event, triggered by the Yanfly plugin. In that common event, put (this is pseudo-code):
Conditional Branch -> isStealthMode
- StealthMode Off
- Control Timer -> 5 seconds
- exit event processing
Conditional Branch -> Timer -> >0
- play error sound effect
- exit event processing
StealthMode 600
Control Timer -> 15 seconds
Yes, that's the plugin I meant - my bad on not including it and not naming it properly. Next time, I'll be sure to do so when I post for help. :kaoswt2: I'll be sure to also use the Button Common Events - it definitely looks handy. :kaoluv:

I actually did mention in brackets before the image to ignore the StealthTime 120 as it's only there for test purposes - once I sorted the system out, it would be changed to the intended 600/10 seconds.

So I've implemented things: used the Button Common Event plugin and designated to F key with a variable so that it only works with a certain character. However, while the timer and Stealth Mode work, the cooldown doesn't and it just resets everything when the F key is pressed again. I'm not too sure if I was meant to have Else branches in the Conditions or not, but could that be why it didn't work? Or did I not implement something I'm supposed to?
1674492543475.png
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
8,920
Reaction score
6,731
First Language
English
Primarily Uses
RMMV
You put the timer conditional backwards. You have it looking at the timer to be <= 0, not > 0.

As a side note, I see you have an extra Else at the bottom - if you don't need one, you can simply not check the box for Else when making a Conditional Branch.
 

blakwhiteknight

Veteran
Veteran
Joined
Jun 30, 2013
Messages
37
Reaction score
7
First Language
English
Primarily Uses
You put the timer conditional backwards. You have it looking at the timer to be <= 0, not > 0.

As a side note, I see you have an extra Else at the bottom - if you don't need one, you can simply not check the box for Else when making a Conditional Branch.
Fixed the timer as per your suggestion and it now does the cooldown properly...but after the 5 seconds are up, it remains in the cooldown state rather than resetting (buzz sound when hitting F key, timer is still up and says 0:00, Stealth Mode won't go on anymore).

I assume I'll have to put a stop timer somewhere in perhaps a conditional? That being said I'm not too sure where.
1674527170904.png

Thank you for all the help you're giving by the way. It's definitely helped me to get more progress and understanding than before. :smile:
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
8,920
Reaction score
6,731
First Language
English
Primarily Uses
RMMV
I assume I'll have to put a stop timer somewhere in perhaps a conditional?
Sorry, I'd never actually used the timer before :stickytongue: So this is a learning experience for me, too, I had no idea it didn't just go away when it stopped.

So you have two options. One is to use a plugin that manages timers (there are a number out there on Google).

The other is to do this. Make two parallel events (one for the timer at 5 seconds, the other for 15). Have them each triggered by a switch.

Add the Control Switch ON event command in the appropriate places in your common event (where you activate the timer for those durations).

All the parallel events have are a Wait command for the appropriate amount of time followed by a Control Timer Off command and a Control Switch OFF command.
 

Showsni

Villager
Member
Joined
Jun 21, 2022
Messages
27
Reaction score
19
First Language
English (UK)
Primarily Uses
RMMV
Another way to do it if you don't want to use timers is to set a variable to the current play time when you use first trigger the stealth, then compare the play time the next time the player tries to use stealth.

Something like:
We have two variables, Playtime1 and Playtime2. Let's say they both start at 0.
In a parallel event, when player presses F:
Use Control Variables -> Game Data -> Other -> Play Time to set Playtime1.
Use a control variable to subtract Playtime2 from Playtime1:
If Playtime1 - Playtime2 > 15, activate the 10 second stealth, and set Playtime2 to Playtime1's current value.
Else if Playtime1 - Playtime2 > 10, play a buzzer and do nothing.
Else deactivate stealth and set Playtime2 to Playtime1 - 10.

Like this:
BV4stKH.png


Does that work?

EDIT: Wait, I think that should be - 10 at the end, not +10. Oops. Well, whichever one works. :D
 

blakwhiteknight

Veteran
Veteran
Joined
Jun 30, 2013
Messages
37
Reaction score
7
First Language
English
Primarily Uses
Another way to do it if you don't want to use timers is to set a variable to the current play time when you use first trigger the stealth, then compare the play time the next time the player tries to use stealth.

Something like:
We have two variables, Playtime1 and Playtime2. Let's say they both start at 0.
In a parallel event, when player presses F:
Use Control Variables -> Game Data -> Other -> Play Time to set Playtime1.
Use a control variable to subtract Playtime2 from Playtime1:
If Playtime1 - Playtime2 > 15, activate the 10 second stealth, and set Playtime2 to Playtime1's current value.
Else if Playtime1 - Playtime2 > 10, play a buzzer and do nothing.
Else deactivate stealth and set Playtime2 to Playtime1 - 10.

Like this:
BV4stKH.png


Does that work?

EDIT: Wait, I think that should be - 10 at the end, not +10. Oops. Well, whichever one works. :D

So I tried this method (even with the -10 at the end of Playtime 2 variable) and the Stealth Mode just doesn't activate. Instead, the buzzing sound effect just happens when I press F.
1674640923156.png
 

Showsni

Villager
Member
Joined
Jun 21, 2022
Messages
27
Reaction score
19
First Language
English (UK)
Primarily Uses
RMMV
So I tried this method (even with the -10 at the end of Playtime 2 variable) and the Stealth Mode just doesn't activate. Instead, the buzzing sound effect just happens when I press F.
View attachment 251529

Hm, it might be reading the key inputs so fast that it triggers again immediately... Does changing the "isPressed" into an "isTriggered" do anything?
 

blakwhiteknight

Veteran
Veteran
Joined
Jun 30, 2013
Messages
37
Reaction score
7
First Language
English
Primarily Uses
Hm, it might be reading the key inputs so fast that it triggers again immediately... Does changing the "isPressed" into an "isTriggered" do anything?

Sadly, when I changed it to "isTriggered", pressing F then does nothing.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
8,920
Reaction score
6,731
First Language
English
Primarily Uses
RMMV
So I tried this method (even with the -10 at the end of Playtime 2 variable) and the Stealth Mode just doesn't activate.
Hm, it might be reading the key inputs so fast that it triggers again immediately...
It looks like there are some logical errors in the event.

The Playtime2 isn't initialized at the top, which means the first time you press F:
Playtime - Playtime2 = Playtime
So if you're starting a new play test and just hitting the button, Playtime might be, like, 4.

Then you only actually go into stealth mode if the difference between the two is > 15, which won't be true right away.

For this part to work properly, you'd need some conditionals at the top to see if Playtime 2 was previously set by stealth activating and completing.

Then, lower down, you have an Else that just turns off stealth without any assurance that it was on to begin with.
 

blakwhiteknight

Veteran
Veteran
Joined
Jun 30, 2013
Messages
37
Reaction score
7
First Language
English
Primarily Uses
It looks like there are some logical errors in the event.

The Playtime2 isn't initialized at the top, which means the first time you press F:
Playtime - Playtime2 = Playtime
So if you're starting a new play test and just hitting the button, Playtime might be, like, 4.

Then you only actually go into stealth mode if the difference between the two is > 15, which won't be true right away.

For this part to work properly, you'd need some conditionals at the top to see if Playtime 2 was previously set by stealth activating and completing.

Then, lower down, you have an Else that just turns off stealth without any assurance that it was on to begin with.
So, by pseudocode, how would this all look like? I'm not sure what to put in the Playtime 2 conditional at the top, and how many I'll need.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
8,920
Reaction score
6,731
First Language
English
Primarily Uses
RMMV
Just to be clear, your original post asked for help to implement this with a timer - you were given a working solution for that.

Are you now specifically asking for one that doesn't use a timer instead? If not, what do you need help with?
 

blakwhiteknight

Veteran
Veteran
Joined
Jun 30, 2013
Messages
37
Reaction score
7
First Language
English
Primarily Uses
Just to be clear, your original post asked for help to implement this with a timer - you were given a working solution for that.

Are you now specifically asking for one that doesn't use a timer instead? If not, what do you need help with?

Yes, sorry for being unclear. But yes, I'm now asking for help with creating a solution without a timer (specifically from the starting solution that Showsni gave). Admittedly, I just find the timer too fiddly and confusing, while I can understand Showsni's solution without it better.
 

Latest Threads

Latest Posts

Latest Profile Posts

With this, I'm gonna have a good night sleep
Damn. We’ve gotten so close to 0 reports, 0 approvals a few times over the past couple weeks. Does it matter? No. Is it realistic. No? Do I rely on your reports and want everyone to keep posting. Yes. Do I 100% games? …sigh… Yes.

Ah yes, all three of my moods all at once.
Here's a tutorial I did on how I made my Leonardo A.I.-assisted artworks for my game's recent update. :rhappy:

Disclaimer: This is meant to be a band-aid solution for people like me who aren't good artists or don't have the financial means to hire an amazing artist. If you have the means, please buy commissions and support your fav artists.:yhappy:

Forum statistics

Threads
131,756
Messages
1,223,009
Members
173,518
Latest member
Tiagrun
Top