-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[RDY] [CR] item: point to mod item (not the base firearm item) from mod's "gun mode" #20215
[RDY] [CR] item: point to mod item (not the base firearm item) from mod's "gun mode" #20215
Conversation
…tem. PR CleverRaven#19515 correctly changed a second `if` to an `else-if`, but incorrectly pointed to the base firearm in the gun mode's constructor args. The doc line got me confused at first, requiring a bisect to confirm this pointer is the culprit. So, tried to clarify it.
Are you sure that is the correct fix? I don't mean it isn't, it's just that I can't tell from the comments for the relevant structures what exactly are the fields supposed to mean. |
I'm pretty sure, but will add more doc comments in |
That is, I'm pretty sure this is the correct fix for issue #20214. I've tried firing on a few targets, to Actually, I'll test some more, to make sure modes don't change "by themselves", or some other weirdness doesn't happen again. EDIT: clarify |
Firing an AK-74M in "auto" mode does not always result in the maximum 8 shots. Not sure of the cause - not enough moves? Distance to target? Target dies before burst over? (I've not used automatic mode enough to know.) Seems to be "pre-existing" - tried on Didn't notice anything else unexpected. |
Re-read forum post. Got wondering:
#15034 mentions this - but it's not yet implemented; there's also PR #11665... Need to review - didn't really check if only one of the damage types is applied, namely cut/pierce of the bayonet, but not bashing damage. EDIT: Was confused, see discussion below. |
I specifically did test that and it looks like only bashing is applied. |
I mean after applying this PR. Started writing detailed description of what has been changed here - will move to What is the expected behaviour? As I understand, the intent of current code was to apply bayonet's damage when "fired" in reach mode, and highest possible of melee damages from either the base gun (bashing) or any of the mods (cut/pierce). |
The intent is using the best damage of each type. There is an assumption that no gun will have both cutting and piercing damage at the same time, but there is no need to enforce that at the moment. |
Checked in this PR - whether using the bayonet for a reach attack or regular next-tile melee, both bash and cut are applied. E.g., a AK-74M with attached sword bayonet deals ~11 bash and ~25 cut for an all-skills 5 and STR 11. It is unexpected to me, but that's tangent.
Okay. Then it works as expected? Tested by adding: add_msg( "DEBUG b: %i c: %i p: %i",
dealt_dam.type_damage( DT_BASH ),
dealt_dam.type_damage( DT_CUT ),
dealt_dam.type_damage( DT_STAB ) ); at this line. |
Looks OK. |
Fixes #20214.
Summary
PR #19515 correctly changed a second
if
to anelse-if
, but incorrectly pointed to the base firearm in the gun mode's constructor args EDIT: instead of leaving as it was - pointing to the mod item.The doc line got me confused at first, requiring a bisect to confirm this pointer is the culprit. So, tried to clarify it.
Details
In current
git master
only bashing damage is applied (and displayed initem::info()
). The bashing comes from the base gun's melee quality. The cutting/piercing of bayonets isadded toreferenced from the firearm's "gun modes" (the ones cycled withF
), but damage from mods on the firearm isn't applied.Happens because during
gun_mode
init,this
is erroneously passed, which in the context ofitem::gun_all_modes()
means the "base gun"item
.What the
gun_mode
struct
constructor expects is the "part" from which the "gun mode" originates (base gun or some attached mod) - so that a mapping can be created:In current
git master
, the latter is instead:In theory, when
item::damage_melee()
is invoked, melee damage of all "gun modes" is considered, and thenstd::max_element()
of them is returned.However, in current
git master
,e.second.target != this && e.second.melee()
(here) is alwaysfalse
(inspected manually), since there is never agun_mode
that doesn't have the base gun as itstarget
. Therefore the fallback default of base gun's bashing damage is used.This PR properly sets the "bayonet"
gun_mode
'starget
to the bayonet item, so that the cut/pierce damage is again available. It is my belief that this change in PR #19515 was erroneous - to achieve its goal of fixing #19492 only the addition of anelse
was required.P.S. Perhaps
target
ingun_mode
is somewhat confusingly named. Or the code lacks a comment here and there.