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

Friendly NPC won't wield another weapon after the current one was "traded" away from it #32613

Closed
l29ah opened this issue Jul 25, 2019 · 6 comments · Fixed by #34188
Closed
Assignees
Labels
<Bug> This needs to be fixed NPC / Factions NPCs, AI, Speech, Factions, Ownership (S2 - Confirmed) Bug that's been confirmed to exist
Milestone

Comments

@l29ah
Copy link
Contributor

l29ah commented Jul 25, 2019

Steps To Reproduce

Steps to reproduce the behavior:

  1. Load the game.
  2. Give the NPC a hatchet instead of his makeshift crowbar.
  3. He wields nothing.
  4. Try giving him a replacement weapon via g: I want you to use this item..
  5. He says his weapon is superior.
  6. Spawn a fat zombie near him.
  7. Observe him dealing no damage to the zombie.

Expected behavior

NPC picking the best weapon from his inventory if he holds nothing and sucks at unarmed fighting.

2019.07.22-buggy.zip

0.D-5829-g4a400484d3-dirty

@TychaiosIlithios
Copy link

I recently had similar stuff - npc had compound bow, traded away, tried to make him use a spear - said it sucked in comparison to mega points from the bow. Cured by reentering the game.

But in regard to your referenced unarmed - good point to mention yet again, should npc master unarmed it becomes extremely hard to convince him to train any other sort of weapon, like a proper pike for proper formation reach attacks.

@kevingranade
Copy link
Member

kevingranade commented Jul 26, 2019 via email

@ZhilkinSerg ZhilkinSerg added (S1 - Need confirmation) Report waiting on confirmation of reproducibility <Bug> This needs to be fixed NPC / Factions NPCs, AI, Speech, Factions, Ownership labels Jul 26, 2019
@ipcyborg
Copy link
Contributor

ipcyborg commented Aug 8, 2019

Tested in 0.D-6301-g3597e0f.

  1. Give the NPC a hatchet instead of his makeshift crowbar.
  2. He wields nothing.

Give hatchet using Hold on to this item and then remove makeshift crowbar using Trade. NPC wields nothing.

  1. Spawn a fat zombie near him.

It really depends on the distance from NPC to a zombie.
If it is close enough (=1), NPC goes unarmed, because wield_better_weapon is not called at all.
But if the distance is more than 1, NPC correctly selects a hatchet.

Another test:

  1. Try giving him a replacement weapon via g: I want you to use this item..

Works fine if you try to give a shotgun to an NPC at this step: changes makeshift crowbar to shotgun.

So the issue here seems to be avoiding of using wield_better_weapon when the monster is too close.
Also we have to consider the time required to wield a weapon: may be in some specific cases it would be better to remain unarmed?

@l29ah
Copy link
Contributor Author

l29ah commented Aug 8, 2019

Give hatchet using Hold on to this item and then remove makeshift crowbar using Trade. NPC wields nothing.

No, i meant trading makeshift crowbar for hatchet.

@kevingranade
Copy link
Member

kevingranade commented Aug 8, 2019 via email

@zt1415926
Copy link

Tested in 0.D-6301-g3597e0f.

  1. Give the NPC a hatchet instead of his makeshift crowbar.
  2. He wields nothing.

Give hatchet using Hold on to this item and then remove makeshift crowbar using Trade. NPC wields nothing.

  1. Spawn a fat zombie near him.

It really depends on the distance from NPC to a zombie.
If it is close enough (=1), NPC goes unarmed, because wield_better_weapon is not called at all.
But if the distance is more than 1, NPC correctly selects a hatchet.

Another test:

  1. Try giving him a replacement weapon via g: I want you to use this item..

Works fine if you try to give a shotgun to an NPC at this step: changes makeshift crowbar to shotgun.

So the issue here seems to be avoiding of using wield_better_weapon when the monster is too close.
Also we have to consider the time required to wield a weapon: may be in some specific cases it would be better to remain unarmed?

Before you spawn the zombie far from the NPC, it is very possible that you have reentered the game, so the NPC re-evaluate what it is wielding and choose the hatchet. So, it has nothing to do with the distance I guess. It is certainly fine if you try to give the NPC a shotgun to replace the makeshift crowbar, because the shotgun is evaluated as a better weapon. But what if you try to replace the shotgun with a makeshift crowbar? The NPC will refuse to wield it. And it will refuse to do so even after the shotgun is traded away unless you reenter the game.

@kevingranade kevingranade added this to the 0.E milestone Sep 6, 2019
@mlangsdorf mlangsdorf self-assigned this Sep 6, 2019
@ZhilkinSerg ZhilkinSerg added (S2 - Confirmed) Bug that's been confirmed to exist and removed (S1 - Need confirmation) Report waiting on confirmation of reproducibility labels Sep 18, 2019
mlangsdorf added a commit to mlangsdorf/Cataclysm-DDA that referenced this issue Sep 22, 2019
Fixes CleverRaven#32613

The trade interface allowed you to remove an NPC's weapon without
removing the cached value of the weapon.

Invalided the weapon value cache entry when a weapon is removed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bug> This needs to be fixed NPC / Factions NPCs, AI, Speech, Factions, Ownership (S2 - Confirmed) Bug that's been confirmed to exist
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants