Skip to content

Add Critical hit API #12319

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

Closed

Conversation

dawon
Copy link
Contributor

@dawon dawon commented Mar 19, 2025

See #12318

@dawon dawon requested a review from a team as a code owner March 19, 2025 14:30
@github-project-automation github-project-automation bot moved this to Awaiting review in Paper PR Queue Mar 19, 2025
@Doc94
Copy link
Contributor

Doc94 commented Mar 19, 2025

Hi, hmm currently by the event you can only prevent the hit but cannot know if already was "prevented" by the config not?

@dawon
Copy link
Contributor Author

dawon commented Mar 19, 2025

Oh I could default the value based on the config option, good idea!

@Owen1212055
Copy link
Member

I would rather have this as a separate event imo. Tying this to this event means that if this logic moves it'll make this setter painful to upkeep.

@Leguan16
Copy link
Contributor

I think I unfortunately have to agree with Owen here.

@dawon dawon force-pushed the feature/allow-preventing-critical-hits branch 2 times, most recently from f3ab6ff to b989cff Compare March 19, 2025 22:10
@dawon
Copy link
Contributor Author

dawon commented Mar 19, 2025

I've updated the PR so now there is a separate event, that you can use to cancel or enforce a critical hit as well as change the crit modifier...

@dawon dawon force-pushed the feature/allow-preventing-critical-hits branch from b989cff to a9751c9 Compare March 20, 2025 06:34
@notTamion
Copy link
Member

i think a better name would be something like PlayerAttackDamageEvent considering this event is called for all hits and not just critical ones

@dawon
Copy link
Contributor Author

dawon commented Mar 24, 2025

i think a better name would be something like PlayerAttackDamageEvent considering this event is called for all hits and not just critical ones

Well, but the only purpose of this event is to manage "criticallity" of hits... It can make non-critical hit critical and vice versa... I think therefore Critical should be part of the name...

@notTamion
Copy link
Member

why not expand on the event then? considering afaik we won't a nice way to modfiy e.g. the base damage of a specific attack. i just don't think we should call the event CriticalAttackEvent or similar because that is not what it is. it gets called when the damage gets calculated, so why should we restrict ourselves to have it only handle the criticality when it could expose more than just that.

@Owen1212055
Copy link
Member

Owen1212055 commented Mar 24, 2025

why not expand on the event then? considering afaik we won't a nice way to modfiy e.g. the base damage of a specific attack. i just don't think we should call the event CriticalAttackEvent or similar because that is not what it is. it gets called when the damage gets calculated, so why should we restrict ourselves to have it only handle the criticality when it could expose more than just that.

See the reasoning above. I think having a separate event is good here because damage logic should not be consolidated like the current damage event. It should only control criticality in my opinion.

@notTamion
Copy link
Member

notTamion commented Mar 24, 2025

See the reasoning above. I think having a separate event is good here because damage logic should not be consolidated like the current damage event. It should only control criticality in my opinion.

i am not saying we should'nt make this a seperate event (with "the event" i meant the event we are going to be adding in this PR), i am saying this event could expose more than just criticality considering the event is placed right around where this stuff is calculated and passed to the hurt methods which then call the damage events. we would'nt be consolidating/forcing this stuff into that event via trickery at all because the event is already placed nicely for that. either way i still don't think PlayerCriticalHitEntityEvent is the best name for this.

@kennytv kennytv added type: feature Request for a new Feature. scope: api labels Mar 24, 2025
@dawon
Copy link
Contributor Author

dawon commented Mar 25, 2025

I've collected some name suggestions from discord not sure which one to use, but maybe the original Tamion's one (PlayerHitCriticalityEvent) is probably the best. Any other suggestions/ideas?

PlayerHitCriticalityEvent
CriticalHitEvent
PlayerCriticalHitDetermineEvent
PlayerDetermineCriticalHitEvent
PlayerCriticalHitDecisionEvent
PlayerCritDecisionEvent

@dawon dawon changed the title Allow preventing critical hits Add Critical hit API Mar 25, 2025
@lynxplay
Copy link
Contributor

So, another bit that came up in some related discussion is that this concept also applies to e.g. sweeping edge attacks.
They also find themselves with similar "computation" logic in the attack bit.

Might be something to keep in mind when deciding between event naming, event layout etc. Not that I have much time for that rn, but for future reviews on this PR, the concept ought to be considered.

@dawon
Copy link
Contributor Author

dawon commented Mar 25, 2025

So, another bit that came up in some related discussion is that this concept also applies to e.g. sweeping edge attacks. They also find themselves with similar "computation" logic in the attack bit.

Might be something to keep in mind when deciding between event naming, event layout etc. Not that I have much time for that rn, but for future reviews on this PR, the concept ought to be considered.

Well I am not sure how this can be aligned other than naming the event specific enough for crits. It would be nice to have crits and sweaping under one event, but I don't think that can be done easily. Or you had some solution in mind to unify those two under one event?

@lynxplay
Copy link
Contributor

Heh I didn't have a solution in mind no.
Yea we can either look to unify these, making it potentially harder if they split, or we maybe look for a name that like, can just replace "Critical" with "Sweeping" or something and then they can be semi sister events. But yea, as said, for future people to just keep in mind when they review it.

I'd hate to name it something to specific to crit and then the sweeping edge one comming 3 commits later is named completely differently even tho they sit in the same logic bit.

@dawon
Copy link
Contributor Author

dawon commented Mar 25, 2025

Ah. got you! I will keep that in mind!

@dawon
Copy link
Contributor Author

dawon commented Mar 27, 2025

So how about:

PlayerResolveCriticalHitEvent or PlayerResolveCriticalAttackEvent
and potentially in the future PlayerResolveSweepAttackEvent

?

@Maxsh001
Copy link

Maxsh001 commented Apr 6, 2025

So how about:

PlayerResolveCriticalHitEvent or PlayerResolveCriticalAttackEvent and potentially in the future PlayerResolveSweepAttackEvent

?

Actually I think this should be one event, since you never crit & sweep at the same time. (There are 2 different sound effects for crits & sweeps specifically) Maybe just PlayerAttackEntityEvent and you can modify the "attack type"

@dawon
Copy link
Contributor Author

dawon commented Apr 6, 2025

So how about:

PlayerResolveCriticalHitEvent or PlayerResolveCriticalAttackEvent and potentially in the future PlayerResolveSweepAttackEvent

?

Actually I think this should be one event, since you never crit & sweep at the same time. (There are 2 different sound effects for crits & sweeps specifically) Maybe just PlayerAttackEntityEvent and you can modify the "attack type"

It would be cool, but those two mechanics are at two a bit different places so either both of the apis would be very limited or it needs to be split in two events.

@Maxsh001
Copy link

Maxsh001 commented Apr 6, 2025

So how about:
PlayerResolveCriticalHitEvent or PlayerResolveCriticalAttackEvent and potentially in the future PlayerResolveSweepAttackEvent
?

Actually I think this should be one event, since you never crit & sweep at the same time. (There are 2 different sound effects for crits & sweeps specifically) Maybe just PlayerAttackEntityEvent and you can modify the "attack type"

It would be cool, but those two mechanics are at two a bit different places so either both of the apis would be very limited or it needs to be split in two events.

I made this. I would say it's way better

@dawon
Copy link
Contributor Author

dawon commented Apr 8, 2025

It looks better, if it works, I will only be glad. Let's wait for the team.

So how about:
PlayerResolveCriticalHitEvent or PlayerResolveCriticalAttackEvent and potentially in the future PlayerResolveSweepAttackEvent
?

Actually I think this should be one event, since you never crit & sweep at the same time. (There are 2 different sound effects for crits & sweeps specifically) Maybe just PlayerAttackEntityEvent and you can modify the "attack type"

It would be cool, but those two mechanics are at two a bit different places so either both of the apis would be very limited or it needs to be split in two events.

I made this. I would say it's way better

@dawon
Copy link
Contributor Author

dawon commented Apr 9, 2025

Closing in favor of #12388.

@dawon dawon closed this Apr 9, 2025
@github-project-automation github-project-automation bot moved this from Awaiting review to Closed in Paper PR Queue Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: api type: feature Request for a new Feature.
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

8 participants