Ability for gunmods to accept batteries, and have guns inherit attached mods "LIGHT_###" flag
Is your feature request related to a problem? Please describe.
Problem: Inability to add a functional under barrel flashlight
There are two things holding back the ability to add battery operated gun mods, and one thing holding back the ability to add light providing gun mods, as far as I've been able to find.
For battery operated mods, the first issue is that the game doesn't recognize the 'battery' ammo type for gun mods, throwing the following error.
I was actually able to work around this for testing purposes by closing the game, changing the item type to 'TOOL', opening the save, reload, save and quit, change the item type back to 'GUNMOD', and load back into the game. After doing this, the item retained the loaded battery, and behaved exactly as expected as long as it was in item form. But that leads to the second issue. As soon as I attached the under barrel flashlight to the gun, it stopped consuming charge while powered on.
The thing holding back gunmods from providing light is that guns don't seem to inherit the flag for light from the gunmod after it is attached, so as soon as the under barrel flashlight is attached, it stops providing light, despite still being able to be turned on or off.
Solution you would like.
I would like for gunmods to accept batteries as an ammo type. This seems like the easy part, most functionality is already there.
I would like for gunmods attached to guns to continue consuming battery as expected.
I would like for guns to inherit attached gunmods "LIGHT_###" flags
Describe alternatives you have considered.
Implement the under barrel light as in #71825, with the gunmod just being a pocket, and the flashlight being a seperate item. This would easily allow for implementation of the flashlight, but not implement a framework for adding battery operated gunmods in the future,
Additional context
This would also allow us to add a battery requirement to under barrel laser sights, which I'm sure everyone would just love :p
But being serious, it would implement a framework for battery powered gun mods, which sure, isn't a super major issue, but would be cool.
Here is the json file where I have added the definitions for the under barrel flashlight, and a save file with an m16 with the mockup under barrel flashlight attached. This is what I used to test the under barrel flashlight to figure out what is needed on the C++ side of things. The flashlight is able to be attached and detached as desired. The light works until attached to the gun, however it cannot be reloaded without following the steps above. The json file should go under data/json/items/gunmod (you could probably figure that out, but eh)
The thing holding back gunmods from providing light is that guns don't seem to inherit the flag for light from the gunmod after it is attached, so as soon as the under barrel flashlight is attached, it stops providing light, despite still being able to be turned on or off.
Regarding this, seems gunmods "deactivate" any generic field values, flags and so on (the ones not intrinsic to type: GUNMOD, like volume, weight, material, the flags, etc.) after attaching them to weapons.
I noticed that a gunmod with relic_data grants the enchantments properly when it's not attached. However, once you attach it, the enchantments disappear from the character. If you de-attach the gunmod and have it in your inventory, you get the enchantments again.
I was planning to do further testing before opening an issue asking for GUNMODs to support relic_data (so you can add talismans to weapons, make them scale from the character's stats, link them to eocs, etc.). Yet according to what you've tested, seems the problem is not limited to a single field.
Yup, sounds like the same issue I was encountering with the flashlight. I'm not familiar with c++ or I'd look at the code myself. Maybe one of these days I'll have to learn it.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Please do not bump or comment on this issue unless you are actively working on it. Stale issues, and stale issues that are closed are still considered.