Closed osuphobia closed 1 week ago
@I-am-Erk is this the desired order of operations for archery?
I've been trying to review and understand this, @osuphobia, but even asking other devs we're all still a bit unclear on what exactly is going on. I think we need a more clear breakdown in the PR description of what you're doing and why in order to properly review this. I get the impression what you're doing is probably fine, but in order to know for sure, in the current state, I'd have to learn all the RAS weapon code from scratch.
If I'm understanding this correctly, the change here is "defer loading (including spending time and stamina on it) of reload and shoot weapons until you interact with the aim menu by either triggering an aim action or firing", and also "list whole cost of firing in UI, including reload time", is that right? If so I agree with your overall direction, the only hard blocker here is the static int I call out below, that has to go.
I've been trying to review and understand this, @osuphobia, but even asking other devs we're all still a bit unclear on what exactly is going on. I think we need a more clear breakdown in the PR description of what you're doing and why in order to properly review this. I get the impression what you're doing is probably fine, but in order to know for sure, in the current state, I'd have to learn all the RAS weapon code from scratch.
@I-am-Erk
What I did is basically the same as Kevin's description.
Before this PR, pressing f
will choose the ammo and immediately reload with it, the moves and stamina are also consumed at this point.
After my modifications, calling load_RAS_weapon only determines what ammo the RAS weapon will use, but you don't reload with it at this point, and the moves needed are also not consumed but added to the total time_to_attack needed.
It's just like you are only checking how your bow will perform with currently selected arrow in the "first turn". This also enabled the use of reload/switch ammo option for RAS weapon, the option was useless as you can't do anything with a weapon already fully loaded. Canceling at this point will also cost no moves and stamina, and the refunding of moves in unload_RAS_weapon is also needless now.
Once you decide to really use you RAS weapon with currently selected ammo, by either triggering an aim action or one of the four firing actions, you will then reload with it, and consume the moves and stamina needed.
Summary
Interface "Display RAS weapon reload time in aim ui"
Purpose of change
Port over and modified https://github.com/cataclysmbnteam/Cataclysm-BN/pull/2468 Fix https://github.com/CleverRaven/Cataclysm-DDA/issues/50571 Fix https://github.com/CleverRaven/Cataclysm-DDA/issues/54997 Fix https://github.com/CleverRaven/Cataclysm-DDA/issues/73287
Describe the solution
The move points needed for reloading RAS weapon is added to firing cost in aim ui, these moves are not consumed if you don't try to shoot or aim your bow. If you try to make your aim steadier by pressing
.
, your will reload your bow first. As https://github.com/CleverRaven/Cataclysm-DDA/commit/d94eea7b5acdb915e6c9908ff72e74456def0e61 is solved, AIM_AFTER_FIRING is enabled for RAS weapon. Deal with https://github.com/CleverRaven/Cataclysm-DDA/issues/73287, to make sure the stamina is cost correctly. Modified the reload time test case to compare the total firing cost.More details:
Before this PR, pressing
f
will choose the ammo and immediately reload with it, the moves and stamina are also consumed at this point. This caused several problems which are described in the issues. After my modifications, callingload_RAS_weapon
only determines what ammo the RAS weapon will use, but you don't reload with it at this point, and the moves needed are also not consumed but added to the total time_to_attack needed. The item_location of ammo selected for reloading is saved atreload_loc
, it is a reference of favorite ammo (if exists), or ammo manually selected.It's just like you are only checking how your bow will perform with currently selected arrow. The game will call
update_ammo_range_from_gun_mode
and use reload_loc to caculate and display ammo, range, and relevant data. This also enabled the use of reload/switch ammo option for RAS weapon, the option was useless as you can't do anything with a weapon already fully loaded. Canceling at this point will also cost no moves and stamina, and the refunding of moves inunload_RAS_weapon
is also needless now.Once you decide to really use you RAS weapon with currently selected ammo, by either triggering an aim action or one of the four firing actions, you will then reload with it, and consume the moves and stamina needed. The moves and stamina will not be refunded (and there is no need to do so anymore, as AIM_AFTER_FIRING will no longer trigger this mechanic).
Describe alternatives you've considered
Choose the way in https://github.com/CleverRaven/Cataclysm-DDA/pull/73305.
Testing
Compiled and tested locally.
Additional context
Based on https://github.com/CleverRaven/Cataclysm-DDA/pull/73305, it was reverted https://github.com/CleverRaven/Cataclysm-DDA/pull/73482 becuase of the attribution issue. Made further adjustment so the inconsistency pointed out in https://github.com/CleverRaven/Cataclysm-DDA/issues/73354#issuecomment-2081741740 is fixed. Please do not squash if this is to be merged to keep the credits.