Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hit detection respects priority & groundedness #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

floral-qua-floral
Copy link

I copied in some code I've written elsewhere and modified it a bit to make enemies more thorough in detecting hits. The most notable change is that enemies will respond better when they're intersecting multiple hitboxes. Specifically, it will select the highest-priority hitbox that's capable of hitting the enemy (i.e. doesn't belong to Player 5). I've also made it so that grounded-only and aerial-only hitboxes will only be able to connect if the enemy has the necessary free value. So now if someone were to make an attack that sends grounded and aerial opponents at different angles, by overlaying one grounded-only and one aerial-only hitbox over top of each other, that move would now interact with enemies correctly. This should also ensure that sweetspots and sourspots will connect the same way they would against a normal player. Also, while I haven't observed this being a problem, I'd assume that the old system could give an enemy de-facto invincibility if they're intersecting a friendly hitbox, since the hit_id = instance_place(x,y,pHitBox); could just return that friendly hitbox. I'm not sure how likely or unlikely that would be, since I don't know how GML decides which instance to return when there are multiple intersecting objects. Another small tweak is that the enemy no longer checks for hitbox collisions at all when hit_lockout > 0. From what I could tell from the code, it looked to me like hit lockout made the enemy check for hitbox collisions but then just throw them out.

I made sure that my code only runs when the initial check detects a hitbox, though, so this should only ever impact performance on the frame that an attack connects. It's also organized such that it checks collision last, preferring to eliminate potential hits through any of the less expensive checks first if possible.

I didn't make matching changes to the destructible terrain article. I figured that people probably won't care as much if it's harder or easier than normal to sweetspot destructible terrain as opposed to an enemy, and the grounded/aerial distinction is pretty meaningless for a terrain object.

One other thing I did that I'm not 100% sure about is adding support for Qua Mario's "only hit below" hitbox variable (line 780), which just makes it so the hitbox won't connect unless it's hitting the very top of the hurtbox. I tested this in-game to see how it felt, and I had mixed feelings about it. It doesn't affect combat against the short grounded enemies much. It made it harder to accidentally Stomp on the guards in the city, which I thought was nice. It also made combat against Rocko more engaging, since shorter jumps could no longer hit him. However I found that it made fighting the flying enemies way harder, and kind of annoying, since getting above them is so difficult. As a compromise, I made it so that it only respects the "only hit below" variable when the enemy is grounded. I'm not totally confident in this solution though. I also don't know if it might be a bit self-important of me to put in a compatibility check that only my character is likely to use 😅 You can do whatever you want with that check - comment it out, remove the grounded-only check, anything. I don't have strong opinions on the matter.

Also added compat for the Qua Mario "only hit below" variable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant