When OK is pressed... Disable hold

Hello!


I'm doing a kind of action system in my rpg. I'm using just events for this.


Basically, the event is set as touch event trigger, and it does damage to the hero.


Then I'm using "if press OK", it activates a variable. For example, if OK is pressed, a random variable is activated 1 to 10. 1 to 3 is MISS, and 4 to 10 the event is hit.


Then, a self switch is activated, A... B... C... until the event is erased.


BUT!... If I stay holding OK, the whole thing just happens in a second. As if I were pressing 200 times per second.


I need help! Is there a way to disable this hold thing? And when the OK is pressed, it lost its function and it has to be pressed again?


Thank you in advance, and sorry for english mistakes!!
You can create a new event page ("parallel activation") with a wait() command to simulate a cooldown.


Also try to make sure you didn't install any plugin that overwrites how the character activates a event by pressing "ok". In js, "Input.isTriggered" is different from "Input.isPressed". The former will only detect the input a single time, the latter will detect the input on every iteration until the player releases the button.


But I'm not sure why is the game interpreting a hold action as multiple button hit. It shouldn't work like this... I think...
Can you show me the check for "if Press OK"? You might have used the wrong check.. If you're really checking "press", that actually means to check if the button is currently pressed, so as long as the button is pressed (on hold), it will really trigger your event continuously. For one time button press triggers (doesn't consider hold), you need to check for trigger not press. But whether or not you can do that in your setup, IDK coz you didn't put a screenshot of your event.


@Crabs - He seems to be checking for button press using the conditional branch condition for that (the condition is on the last tab of conditional branch), and that check actually uses Input.isPressed, and that is why he is having this problem.


I just checked the code for the conditional branch code for "Is Button Pressed?", and it does use press check instead of trigger and that is why it is returning true when you hold OK. Also take note that it doesn't just only take return true on hold, but normally based on my tests, a very fast press of a button actually stays for at least about 4 frames when running on 60 FPS, so even without holding, it would be triggering your actions more than once.


Replace your conditional branch condition with the "script" condition and use this as condition


Input.isTriggered("ok");
Hello guys! 


First of all thank you very much for your attention and time!


The best option that works perfectly was the Input.isTriggered("ok");!


It worked so nice, that if you just press "ok" next to the event, it don't works. You have to walk in the direction of the event, and press ok at the same time to make it work!


This gives more dynamic to my action system! Thank you very very much!


BUT... haha


I found another issue, the "touch event" trigger does the same thing. If the event touch the player, It also keep triggering very fast the actions.


And don't matter what I do, always when I touch the event, I got hitted. At most I can hit the event, but the event touch me as well.


I would like to know if there is a script line like you give me '' Input.isTriggered("ok");'' but for event touch.


If yes, I thought let the event as "action button", and create another condicional branch, doing the touch event happen as a content.


Then I can create a lot of "if", "elses" and "variables", to create a lot of possibilities.


Thank you in advance and sorry for english mistakes!
The best way that I know of is to simply add a wait at the end of your enemy event. It will never retrigger until the current instance finishes the wait.
I already tried this, but when the event touches the hero, the wait just stop the event to keep following the hero. But if I press "OK" in the event, it seems to reset and start all the contents from the begining imediatly.
It shouldn't be doing that, unless the event commands in your OK scenario is causing a refresh of the enemy event. I am assuming the enemy event and the OK handler are independent of each other. Since we don't actually know how your enemy event and how you hitting event are setup it's kind of hard to visualize things..
If you post a detailed explanation of what exactly want to create, we could find a better approach for this issue. Sometimes features can be easily implemented by installing a plugin, for instance.
Ok! Now I'm at work. I will do detailed as soon as I get home! Thank you very much!!
Hello, this is what I'm trying to do!


As you can see, I'm working with probability.


Random 1 - 4: Mean the probability of being hit.


(constant 2, 3, 4 you hit the event)  


(constant 1 you get hit by the event)


If you get hit, (constant 1): You will have another variable:


Random 5 - 8 it's the probability of how much it will be the damage (constant 5, 7, 8). Or, if you will dodge. (constant 6)


BUT, I don't know why it got too hard to hit the event. It seens that the ''event touch'' runs so fast, that the other contents don't run properly.


And then, when you are next a wall for example, you die in fraction of a second.


That's it.


Thank you very much for your atention!!

test.png
You should really have the player's own attack separate from the enemy event... It can cause lots of problems and it will also prevent the player from being able to hit the enemy unless the enemy attacks first.


Actually, now I don't see the point of why you even need the player to press OK, when it will only take effect if the enemy variable says that you can hit... You could have as well just made the player auto-attack when the variable rolls correctly..


One way I'd go about your problem with the trigger triggering too much is have another event page with a self switch condition and runs on parallel process. Your current page will switch ON that self switch at the end, then your new page will turn it off after a wait.
You should really have the player's own attack separate from the enemy event... It can cause lots of problems and it will also prevent the player from being able to hit the enemy unless the enemy attacks first.



I don't have knowlege enough to do this!! hahah1!! It's possible to do using events? Or, there is a script to do this kind of action system?

Actually, now I don't see the point of why you even need the player to press OK, when it will only take effect if the enemy variable says that you can hit... You could have as well just made the player auto-attack when the variable rolls correctly..



I did this because press a button to atack gives more adrenaline to the game! Haha!

One way I'd go about your problem with the trigger triggering too much is have another event page with a self switch condition and runs on parallel process. Your current page will switch ON that self switch at the end, then your new page will turn it off after a wait.



But, when this wait happen, the game will freezer a little bit. Then the game will not flow very well.


"You should really have the player's own attack separate from the enemy event", I think this is the best option for me.


Could you help me doing this? I don't know even how to start doing this...


Thank you and sorry for english mistakes!!
But, when this wait happen, the game will freezer a little bit. Then the game will not flow very well.



No it won't freeze the game coz you will set the event page with the wait command to be a parallel process event..

I did this because press a button to atack gives more adrenaline to the game! Haha!



Normally yes, but with your current set-up it's more of "pray to the random number generator so that it will allow you to attack"

"You should really have the player's own attack separate from the enemy event", I think this is the best option for me.


Could you help me doing this? I don't know even how to start doing this...



Simply put, you will make a parallel process that checks for the OK press, then checks if any "enemy event" is in front of the player then do "damage" to that enemy event. It's actually kinda clunky if you do it with pure eventing.
Simply put, you will make a parallel process that checks for the OK press, then checks if any "enemy event" is in front of the player then do "damage" to that enemy event. It's actually kinda clunky if you do it with pure eventing.



Sorry for ask, but I couldn't think in anything... How do I do this check to see if there is a event in front of the player??
You would loop thru the position of every event in the map and compare it with the position and facing of the player.. You'd most probably do it using a script call (to make it not look so clunky)
I got stuck here! Haha!


I did 4 variables:


If pagedown is pressed down:


map X event 1


map Y event 1


map X player


map Y player


Then, I don't know how to put correctly the variables to see if it's "in front of the player". Because if I put "If map x event 1 = map x player", it will only work if the player is literaly in the same spot as the event.


How can I tell to the conditional branch that's in front of the player?! Haha
NOOOO... you don't check if a button is pressed, you check the direction of facing of the player, there's a condition for that. Because if you check for button press, if the player is standing in place then he won't be able to attack. 


You will check if it's position of player +/- 1, now whether it's + or minus and whether you do it to X or Y depends on the facing...


If Player is Facing Down


Check if Map X of event and Player is the same


Check if Map Y of event is Map Y of Player + 1


If Player is Facing Up


Check if Map X of event and Player is the same


Check if Map Y of event is Map Y of Player - 1


If Player is Facing Right


Check if Map X of event is Map X of Player + 1


Check if Map Y of event and Player is the same


If Player is Facing Left


Check if Map X of event is Map X of Player - 1


Check if Map Y of event and Player is the same


Now if you have so many events in the map, this would be super clunky to write that it will better to shorten it up with script calls that will loop thru all events in the map.
I did!!! It worked! Yeah!!!


Thank you so much!!!


Now I can do so much more things! Thank you.

Now if you have so many events in the map, this would be super clunky to write that it will better to shorten it up with script calls that will loop thru all events in the map.





I don't know ANYTHING about script. Haha!!


But I think it's a good idea! haha!


Could you help me (again) on this??


I would like to thank you for everything you have done for me!

test 2.png
My level of knowledge of MV is not yet at that point where I can whip up working code without the editor so you'd need to wait for until I can get back on my comp for the scripted version that checks for all the events of the map. XD


BTW, your next ifs should be inside the very first If that checks the button press so that they will only be checked once the button press is done. That way you don't even need to recheck the button press for each direction of facing, since its already true by the time the checks are done anyway
My level of knowledge of MV is not yet at that point where I can whip up working code without the editor so you'd need to wait for until I can get back on my comp for the scripted version that checks for all the events of the map. XD



I just have to thank you. It's already excellent to me! Thank you!

BTW, your next ifs should be inside the very first If that checks the button press so that they will only be checked once the button press is done. That way you don't even need to recheck the button press for each direction of facing, since its already true by the time the checks are done anyway



Got it. I will do that! Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/when-ok-is-pressed-disable-hold.73393/