-
Notifications
You must be signed in to change notification settings - Fork 250
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
Rework Bionic weapon selection and make BIONIC_GUNS work for NPCs. Fix NPC Aiming. #1705
Conversation
1d15241
to
f15b4f8
Compare
5e2711e
to
ea49340
Compare
Done |
5cd6f63
to
a4ad1f4
Compare
Complete first implementation Update bionics.json NO_UNWIELD has no purpose on bionics, only fake_weapons. Lightning, wrist mounted rockets excluded from BIONIC_NPC_USABLE until we code in more sophisticated considerations for friendly fire. EMP gun excluded on basis that NPCs cannot distinguish vulnerabilities and do not care if they're actually doing damage.
DDA PR 35295 broke NPC confident_range_cache's. This fixes it, so now NPCs will actually aim their guns instead of attempting to use them in melee
Reload enough for one shot if your best weapon requires ammo to be loaded one by one, you're out of ammo, and you're in danger.
eaf23d3
to
ddb8043
Compare
Bionic Shotguns are now reloaded both in and out of combat depending on situation Added a "Menacing Debug Monster".
ddb8043
to
d80815d
Compare
33edcc9
to
f407de6
Compare
5755e02
to
b788347
Compare
Removed modes.clear(), seems to work for now.
188813f
to
62cfbc9
Compare
3370895
to
488eb9d
Compare
No need for std::max anymore
3d1351b
to
1ac631a
Compare
What's the point of having a definition for infinite charges if it's not used? Reorganizes ammo_count_for function and comments on something that might be obtuse. Accurately consider ammo drain
1ac631a
to
4b4f825
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
segmentation fault when reading cbm_weapon_index
from pre-PR saves. could you check on them?
tested with: EmptyWorld.zip
cbm_weapon_index defaults to -1 in legacy saves when empty
9c02725
to
1bdc7ae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm struggling to make npc with bionic shotgun CBM installed actually fire shotshells. it'd be appreciated if you could provide an example steps of testing the PR.
Are you able to get it working with finger lasers or other standard bionic guns? If so it might be something to do with differences in behavior between bionic ranged weapons that draw solely from bionic power vs the ones that need to be loaded. |
yes. i was able to make NPC fire their finger laser, but was unable to give them shotshell (they refuse because npcs think given ammo as 'weapons'), thus failed to test them. |
Ah, the "I want you to use this item" option? Yeah, picking that always makes them assume you want them to wield or wear the item being given. For giving ammo you have to use "let's trade" instead. EDIT: Huh, turns out they can also be made to use consumables from that prompt. Damn, I was tempted to change the line to "I want you to wield/wear this item" to make it more clear but wield/wear/consume would be a lot more clunky. |
Don't use "I want you to use this" but instead "I want you to hold on to this" further down. |
165e04e
to
382ca65
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Active Bionic Weapon test
0.finger-laser-test.mp4
Toggled Bionic Weapon test
Shotgun arm test (2 rounds)
1.bionic-shotgun-test-1.mp4
Shotgun arm test (10 rounds)
1.bionic-shotgun-test-2.mp4
Bionic Weapon selection test
NPC will activate only the Monomolecular Blade
2.blade-selection-test.mp4
NPC will only activate the shotgun
2.choose-bionic-shotgun-hand-bug.mp4
also bug confirmed
Reload/NPC AI fixes
M4A1 fires then reload magazine
3.m4a1-reload.mp4
Infinite loop found:
if npc has both weapon and bionic weapon, and wielded weapon gets empty, they will forever switch between weapon and bionic weapon. in the above video, i had to uninstall all the bionics to break the loop (and use m4a1). it may be related to the known noted error.
Shotguns fire once then reload once
https://user-images.githubuserconten
t.com/54838975/235451168-8f382c4e-9ac9-4159-920f-5bb8edd220f5.mp4
approving despite having bug, as
- it looks like a complex bug to solve
- it may be related to aforementioned known bug
- other than that, all tests work
Summary
SUMMARY: Bugfixes "Rework Bionic weapon selection and make BIONIC_GUNS work for NPCs. Fix NPC Aiming."
Purpose of change
Deals with an issue found in #1227 where bionic guns were not firing and instead being used as melee weapons.
Secondarily deal with bugs in NPC AI that prevented them from aiming guns.
Describe the solution
Goal here is in several parts.
check_or_use_weapon_cbm()
code to be reorganized. such that it compares all possible bionics, and picks the "best" of the lot.cbm_toggle
andcbm_active
store toggled and activated cbm weapons respectively.cbm_fake_active
stores a copy of the fake weapon from the activated CBM if one is chosen, to prevent segfaults from the item disappearing into the void after being initialized in a function.wield_better_weapon()
now allows swapping between bionic weapons and wielded weapons where applicable. On the first turn, beforewield_better_weapon()
is called a bionic toggled weapon will be selected first (and most likely pass unless you specifically tell them to wield something. Then, just after it will start to compare available weapons against the chosen bionic weapon. If a better one is found it will deactivate the bionic weapon and wield the selected one.Separate from all of this is a bugfix.
invalidate_ranged_cache()
is supposed to update theconfident_range_cache
usingconfident_shoot_range()
, but DDA PR #35295 broke it by makingconfident_shoot_range()
use theconfident_range_cache
if available, so it would never properly update after the first time.Describe alternatives you've considered
I can't think of any good alternatives. Probably due to myopia, the only other solution I can think of is to ignore this entirely because it's driving me insane.
Testing
Active Bionic Weapon test
Toggled Bionic Weapon test
Bionic Weapon selection test
Reload/NPC AI fixes
Additional context
Bug noted while testing.
npc_ai::weapon_value()
calls and writes to a cache, but the cached weapon value is only a snapshot for weapons with ammo requirements. To further complicate matters,npc_ai::weapon_value()
may be called to produce "ideal" values instead of current values, leading to wrong values being read from the cache during combat. Fixing this has been laborious and annoying, I'm relegating it to a separate PR.