Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign up[RDY] [CR] item: point to mod item (not the base firearm item) from mod's "gun mode" #20215
Conversation
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
I'm pretty sure, but will add more doc comments in |
This comment has been minimized.
This comment has been minimized.
|
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 |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
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. |
keyspace
changed the title
item: point to mod item from mod's "gun mode", not the base firearm item
[WIP] item: point to mod item (not the base firearm item) from mod's "gun mode"
Feb 6, 2017
This comment has been minimized.
This comment has been minimized.
|
I specifically did test that and it looks like only bashing is applied. |
This comment has been minimized.
This comment has been minimized.
|
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). |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
Looks OK. |
keyspace commentedFeb 6, 2017
•
edited
Fixes #20214.
Summary
PR #19515 correctly changed a second
ifto 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 masteronly 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_modeinit,thisis erroneously passed, which in the context ofitem::gun_all_modes()means the "base gun"item.What the
gun_modestructconstructor 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_modethat 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'stargetto 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 anelsewas required.P.S. Perhaps
targetingun_modeis somewhat confusingly named. Or the code lacks a comment here and there.