Pixel Game Maker MV

Pixel Game Maker MV

RegalX7 Sep 18, 2021 @ 12:18pm
Prevent Infinite Attack Loop?
What would be the most effective way of creating a "window of opportunity" to attack an enemy? That is, as long as that "window" is open, the player may attack as many times as desired, and after a certain amount of time, regardless of whether the player attacks or not, the enemy returns to a "decide on next attack" state?

My attempts have resulted in the enemy being stun-locked, as long as the player keeps attacking, because it always returns to the "window of opportunity" after the enemy's Common Action "hit" state. I've experimented with switches and variables a lot, but if that's the answer, I'm obviously utilizing them incorrectly.

Just looking for some guidance, so I hope I was able to explain my problem properly. I don't think it's a bug that I'm misunderstanding as my ineptitude, this time, haha...
Originally posted by RegalX7:
I figured it out: it's the Timer Function.

I made a "Vulnerable" Object Self variable, default set to "2" or "3" or whatever (the "window of vulnerability" length). When that variable equals zero (from the countdown), proceed to the next Action Box. At any point, the "Vulnerability" Object Self variable is set back to two (also, the Timer Function has to be stopped at the same time, to maintain consistent timing).

I guess I mistakenly assumed the Timer Function is the same as the "After Certain Time Passes" link. I still don't entirely understand how, admittedly, but I hope I'm able to help others with similar problems.

I'd like to thank you guys, still. I never messed around with some of this stuff (e.g. Object Connections) before, so I expanded my knowledge in multiple ways, in the end!
< >
Showing 1-8 of 8 comments
erobotan Sep 18, 2021 @ 7:55pm 
super armor is popular to avoid this. The enemy is still taking hits & damage (if you want you can increase it's damage reduction variable too) but no longer flinch/knockback from it

just make a "super armor" switch and if it's on you can't go to flinch/knockback state
RegalX7 Sep 19, 2021 @ 11:41am 
Thank you for responding.

I was thinking along the lines of having feedback for each hit (since Objects don't have a visual or auditory "reaction" to Attack boxes meeting Collision boxes unless you make it so, whether it's the included "blinking" effect from the set invincibility period, or a more specific animation. In my case, I want to show the enemy's "hit" animation, accompanied by a sound effect). My first thought was that it runs parallel to the "state of vulnerability," but I've been unable to figure out how to do that with PGM.
erobotan Sep 19, 2021 @ 6:19pm 
the built in invulnerability stuff basically make all attack miss so you won't detect any collision during that time
RegalX7 Sep 20, 2021 @ 7:28pm 
Yeah, I was just using that as an example of a visual indicator that the attack is registering, but thank you all the same.

I tried studying & copying the Common Action method used in the "Witch & 66 Mushrooms" demo, but my limited understanding of Japanese has made it rather difficult to follow.

Looks like: Hit an Attack Detection -> Knife Hit = Switch ON -> Unconditionally return to previous Action Box. If Object Self Knife Hit = Switch ON -> Object Self Knife Hit Switch OFF -> unconditionally return to previous Action Box.

Of course, simply copying that leads to the "window of vulnerability" Action Box resetting each time the player attacks the enemy, leading to the player being able to "stun-lock" the enemy with attacks. I'd assume something other than the Common Actions & those particular switches is being utilized, but it's difficult to pinpoint the exact process... Whether it's the language barrier, I'm overlooking something simple, or I'm just stupid, I don't know.
erobotan Sep 20, 2021 @ 9:13pm 
if you don't want the common action to go back to the previous action, you can use "execute object action"
Baz Sep 21, 2021 @ 7:56am 
You might look into generating or connecting a object that controls the complete state of when the enemy can get hit or decide attack.

Also you can add other conditions like the objects Invincibility switch must be OFF.
Last edited by Baz; Sep 21, 2021 @ 11:35pm
A moderator of this forum has indicated that this post answers the original topic.
RegalX7 Sep 22, 2021 @ 1:38pm 
I figured it out: it's the Timer Function.

I made a "Vulnerable" Object Self variable, default set to "2" or "3" or whatever (the "window of vulnerability" length). When that variable equals zero (from the countdown), proceed to the next Action Box. At any point, the "Vulnerability" Object Self variable is set back to two (also, the Timer Function has to be stopped at the same time, to maintain consistent timing).

I guess I mistakenly assumed the Timer Function is the same as the "After Certain Time Passes" link. I still don't entirely understand how, admittedly, but I hope I'm able to help others with similar problems.

I'd like to thank you guys, still. I never messed around with some of this stuff (e.g. Object Connections) before, so I expanded my knowledge in multiple ways, in the end!
Last edited by RegalX7; Sep 22, 2021 @ 2:10pm
Baz Sep 22, 2021 @ 1:55pm 
Perfect, thanks for sharing!
< >
Showing 1-8 of 8 comments
Per page: 1530 50

Date Posted: Sep 18, 2021 @ 12:18pm
Posts: 8