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

[RDY] [CR] item: point to mod item (not the base firearm item) from mod's "gun mode" #20215

Merged

Conversation

keyspace
Copy link
Contributor

@keyspace keyspace commented Feb 6, 2017

Fixes #20214.

Summary

PR #19515 correctly changed a second if to an else-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 in item::info()). The bashing comes from the base gun's melee quality. The cutting/piercing of bayonets is added to referenced from the firearm's "gun modes" (the ones cycled with F), but damage from mods on the firearm isn't applied.

Happens because during gun_mode init, this is erroneously passed, which in the context of item::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:

  • auto -> base gun
  • single -> base gun
  • bayonet -> attached bayonet mod

In current git master, the latter is instead:

  • bayonet -> base gun

In theory, when item::damage_melee() is invoked, melee damage of all "gun modes" is considered, and then std::max_element() of them is returned.

However, in current git master, e.second.target != this && e.second.melee() (here) is always false (inspected manually), since there is never a gun_mode that doesn't have the base gun as its target. Therefore the fallback default of base gun's bashing damage is used.

This PR properly sets the "bayonet" gun_mode's target 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 an else was required.


P.S. Perhaps target in gun_mode is somewhat confusingly named. Or the code lacks a comment here and there.

…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.
@Coolthulhu
Copy link
Contributor

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.
If you decoded it, it could be a good idea to add comments regarding what is what in the structure (not necessary here).

@keyspace
Copy link
Contributor Author

keyspace commented Feb 6, 2017

I'm pretty sure, but will add more doc comments in a second 20 minutes.

@keyspace
Copy link
Contributor Author

keyspace commented Feb 6, 2017

That is, I'm pretty sure this is the correct fix for issue #20214. I've tried firing on a few targets, to check see if issue #19492 (that PR #19515 addressed) would reappear. Didn't get a debugmsg().

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

@keyspace
Copy link
Contributor Author

keyspace commented Feb 6, 2017

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 git master, get about the same.

Didn't notice anything else unexpected.

@keyspace
Copy link
Contributor Author

keyspace commented Feb 6, 2017

Re-read forum post. Got wondering:

I think the ability to use bayonets in hand to hand combat was removed in favor of reach combat.

#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 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
@Coolthulhu
Copy link
Contributor

I specifically did test that and it looks like only bashing is applied.
It doesn't really make sense to special-case it like that. From balance side, bayonets are underpowered. From realism side, spears are some of the most versatile weapons in terms of reach and rifle+bayonet is essentially a spear.

@keyspace
Copy link
Contributor Author

keyspace commented Feb 6, 2017

I mean after applying this PR.

Started writing detailed description of what has been changed here - will move to preample preamble.

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).

@Coolthulhu
Copy link
Contributor

The intent is using the best damage of each type.
The old behavior was that gun+bayonet deals as much damage as bashing with the gun and stabbing with the bayonet at the same time. For as long as this doesn't get better than dropping the rifle and shanking with a knife, there is no reason to nerf that further.

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.

@keyspace
Copy link
Contributor Author

keyspace commented Feb 8, 2017

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.

The old behavior was that gun+bayonet deals as much damage as bashing with the gun and stabbing with the bayonet at the same time. For as long as this doesn't get better than dropping the rifle and shanking with a knife, there is no reason to nerf that further.

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.

@Coolthulhu
Copy link
Contributor

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.

Looks OK.
Though the giant discrepancy between bash and cut damage is pretty alarming. After all the buffs bashing has gotten, it still sucks.

@keyspace keyspace changed the title [WIP] item: point to mod item (not the base firearm item) from mod's "gun mode" [RDY] [CR] item: point to mod item (not the base firearm item) from mod's "gun mode" Feb 9, 2017
@Coolthulhu Coolthulhu self-assigned this Feb 15, 2017
@Coolthulhu Coolthulhu merged commit eb77ad9 into CleverRaven:master Feb 16, 2017
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.

Bayonet attached as gunmod to gun does not give increased damage, including for reach attacks (regression)
2 participants