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

Add weapon ammo to the weapon name #36474

Merged
merged 13 commits into from
Dec 30, 2019

Conversation

Hirmuolio
Copy link
Contributor

@Hirmuolio Hirmuolio commented Dec 26, 2019

Summary

SUMMARY: Features "Add weapon ammo to weapon name"

Purpose of change

Quick quiz: What kind of ammo does RM216 SPIW use?

The game has so many guns, many of them are exotic or fictional with very non descriptive name. Having to check the item info to see what ammo they use is tiresome.

The solution is to add the used ammo to the weapon name.

Describe the solution

The default ammo is added to after the ammo count. If the weapon has no ammo count (no magazine) then the ammo is just at the end of the name.

Same is done to magazines. They will also have the ammo names on their name.

If the weapon/magazine is loaded with ammo then the type of the loaded ammo is used.

UPS usage is not added to the name.

The feature can be disabled/enabled in options. "Add ammo to weapon names" option in interface settings. Default enabled.

Screenshot:
ammo2

Describe alternatives you've considered

The ammo is not technically in the name of the imtem. So you can not search for it.
I considered placing the ammo in the name properly but that would push the ammo count off screen and that would not be even worse.

Testing

It doesn't seem to crash.
It works on weapons that have had their ammo type changed by a gun mod.

Additional context

@ymber
Copy link
Member

ymber commented Dec 26, 2019

I'd much prefer this being behind an option. There's a lot more text in the list with this and that makes it harder for me to find what I want at a glance.

@Night-Pryanik
Copy link
Contributor

Even if the weapon accepts other ammo types and is loaded with other ammo types it will still show default ammo.

This will be highly confusing and will cause all sorts of "Why does it shows X ammo when I loaded it with Y ammo?" questions. I'd prefer it showing the actual ammo loaded, and default ammo only when the gun is unloaded.

@curstwist curstwist added Items: Ammo / Guns Ammunition for all kinds of weapons and these weapons themselves Info / User Interface Game - player communication, menus, etc. Items: Magazines Ammo holding items and objects. Ranged Ranged (firearms, bows, crossbows, throwing), balance, tactics [C++] Changes (can be) made in C++. Previously named `Code` labels Dec 27, 2019
@Hirmuolio
Copy link
Contributor Author

I am trying to make it show the current ammo if any is loaded.

There is some strange behaviour that I do not understand at all.

ammotext = ammotype( ammo_current() )->name();

This works only if the weapon/magazine are loaded with certain types of ammo. For example it works with "9x19mm JHP" but not with "9x19mm +P+". It gives this kind of error:

 DEBUG    : Tried to get invalid ammunition: 9mmP2

 FUNCTION : obj
 FILE     : d:\programming stuff\cataclysm-dda\src\ammo.cpp
 LINE     : 48

I have a feeling that I am doing something completely wrong and this shouldn't work at all.

@Hirmuolio
Copy link
Contributor Author

Hirmuolio commented Dec 27, 2019

The above was probably because the itype_id of the ammo was same as its ammotype. So the code just acted as if the itype_id was ammotype and worked.

Got something working. But I have a feeling this is a bad way to do this.

item( ammo_current() ).ammo_type()->name();

As far as I understand this gets the itype_id of currently loaded ammo, creates item from that itype_id, gets the ammotype of the created item and then gets the name of that ammotype.

The has to be a way to get the ammotype from a itype_id without creating an item.

src/item.cpp Outdated Show resolved Hide resolved
@Hirmuolio
Copy link
Contributor Author

I think this is pretty much ready.
Are there any weird weapons/magazines that hold non-ammo items or no ammo at all? Or anything else weird that could cause problems?

src/options.cpp Outdated Show resolved Hide resolved
Co-Authored-By: anothersimulacrum <[email protected]>
@Hirmuolio Hirmuolio deleted the caliber-in-name branch February 3, 2020 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Info / User Interface Game - player communication, menus, etc. Items: Ammo / Guns Ammunition for all kinds of weapons and these weapons themselves Items: Magazines Ammo holding items and objects. Ranged Ranged (firearms, bows, crossbows, throwing), balance, tactics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants