# NPC throwing their weapons problem

**URL:** https://discourse.cataclysmdda.org/t/npc-throwing-their-weapons-problem/28312
**Category:** The Garage
**Created:** [November 6, 2022, 11:04am UTC](https://discourse.cataclysmdda.org/t/npc-throwing-their-weapons-problem/28312 "2022-11-06T11:04:44Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![Eren\_Rager](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/eren_rager/32/11883_2.png) [@Eren\_Rager](https://discourse.cataclysmdda.org/u/Eren_Rager)
#### Post date: [November 6, 2022, 11:04am UTC](https://discourse.cataclysmdda.org/t/npc-throwing-their-weapons-problem/28312/1 "2022-11-06T11:04:44Z")

</div>

I’ve seen it, and have read some topics about it. Just now I had my companions throw all of their weapons at a shady zombie, then ganged up on it with their fists alone. They were armed with a bo staff, 2 PR batons, 2 hatchets, and a trench mace, and they threw it all.

Is there a fix underway? Because this has been going on for some time now, and I find it hard to fight with a group of companions, heck even a single one I armed with a bat one time just threw it three times in a row everytime I give it back to him until I got frustrated and just let him die. And they’re not that great in ranged combat too, especially in a group, having them melee would’ve been a good idea if they weren’t throwing it a lot.

I gotta ask. Why even let them throw stuff besides throwing knives and other things meant to be thrown? There is a flag called ‘npc throw’ or something for such items, why not just restrict the AI to that? They rarely have the skill level to hurt anyone with a thrown aluminum can, and they don’t even have a working logic to select things to throw and when to throw. It would be a huge blessing to even remove their ability to do so, for now at least until this phenomena is dealt with.

---

<div class="post-metadata">

### Author: ![anothersimulacrum](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/anothersimulacrum/32/10770_2.png) [@anothersimulacrum](https://discourse.cataclysmdda.org/u/anothersimulacrum)
#### Post date: [November 6, 2022, 10:30pm UTC](https://discourse.cataclysmdda.org/t/npc-throwing-their-weapons-problem/28312/2 "2022-11-06T22:30:39Z")

</div>

This has been fixed in the experimental version of the game.

> <https://github.com/CleverRaven/Cataclysm-DDA/pull/56746>
>
> \#### Summary
> Bugfixes "Stop NPCs from throwing their guns"
> 
> \#### Purpose of c…hange
> Stop NPCs from throwing weapons they do not mean to, allow them to throw weapons they are not wielding.
> 
> \#### Describe the solution
> When #49907 was cleaning up NPC attack logic, it introduced a check into many of the npc\_attack\_\*::use functions to ensure that the NPC was wielding the weapon of choice, and if they were not wielding it, ensure that they did so they could perform that attack next.
> 
> However, for the throwing attack, it checked if the wielded item was not being wielded, causing this section to never be entered, and so the NPC would throw whatever their wielded item was, or, if they were not wielding an item, fail to perform an attack.
> 
> In addition to this, add a check to ensure we can wield the appropriate item to npc\_attack\_throw::can\_use.
> 
> Also, make sure all NPC actions have a name to ease debugging.
> 
> \#### Testing
> Go near some hostile NPCs - see them throw items, and not their guns.
> 
> \#### Additional context
> I couldn't find any open issues for this bug.

---

<div class="post-metadata">

### Author: ![Eren\_Rager](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/eren_rager/32/11883_2.png) [@Eren\_Rager](https://discourse.cataclysmdda.org/u/Eren_Rager)
#### Post date: [November 7, 2022, 1:40pm UTC](https://discourse.cataclysmdda.org/t/npc-throwing-their-weapons-problem/28312/3 "2022-11-07T13:40:17Z")

</div>

Seems it didn’t fix it for the melee weapons tho. What anomaly in their code makes them insist on throwing good melee weapons at enemies despite how bad they are at it, to the point that they even hit me when I was behind them while the enemy was in front of them.

---

<div class="post-metadata">

### Author: ![anothersimulacrum](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/anothersimulacrum/32/10770_2.png) [@anothersimulacrum](https://discourse.cataclysmdda.org/u/anothersimulacrum)
#### Post date: [November 7, 2022, 6:41pm UTC](https://discourse.cataclysmdda.org/t/npc-throwing-their-weapons-problem/28312/4 "2022-11-07T18:41:30Z")

</div>

The fix doesn’t distinguish between types of weapons, it fixes a bug where when an npc decided it want to throw something, it would throw whatever is in it’s hands instead of what it wanted to throw.  
What version of the game are you playing? It is possible the evaluation that they want to throw a weapon is more optimistic than it should be.

---

<div class="post-metadata">

### Author: ![Entity](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/entity/32/3376_2.png) [@Entity](https://discourse.cataclysmdda.org/u/Entity)
#### Post date: [November 7, 2022, 8:13pm UTC](https://discourse.cataclysmdda.org/t/npc-throwing-their-weapons-problem/28312/5 "2022-11-07T20:13:12Z")

</div>

I had this happen too a couple of months ago, I dont know which build it was, but definitely after it was supposedly patched.

Just out of curiosity, did you use the debug to take control of a follower? I was using that feature, and if you were too than perhaps that has something to do with the bug.

---

<div class="post-metadata">

### Author: ![Eren\_Rager](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/eren_rager/32/11883_2.png) [@Eren\_Rager](https://discourse.cataclysmdda.org/u/Eren_Rager)
#### Post date: [November 7, 2022, 11:31pm UTC](https://discourse.cataclysmdda.org/t/npc-throwing-their-weapons-problem/28312/6 "2022-11-07T23:31:33Z")

</div>

I updated version to the latest before trying again and it still did it. My companions have nothing else in their inventory so perhaps they should just not throw anything if they have nothing to throw besides their own weapons?

---

<div class="post-metadata">

### Author: ![Eren\_Rager](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/eren_rager/32/11883_2.png) [@Eren\_Rager](https://discourse.cataclysmdda.org/u/Eren_Rager)
#### Post date: [November 7, 2022, 11:32pm UTC](https://discourse.cataclysmdda.org/t/npc-throwing-their-weapons-problem/28312/7 "2022-11-07T23:32:53Z")

</div>

Haven’t used that debug function in this one yet. Do you remember you companion having anything else in their inventory before deciding to still throw their weapons?

---

<div class="post-metadata">

### Author: ![Entity](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/entity/32/3376_2.png) [@Entity](https://discourse.cataclysmdda.org/u/Entity)
#### Post date: [November 7, 2022, 11:48pm UTC](https://discourse.cataclysmdda.org/t/npc-throwing-their-weapons-problem/28312/8 "2022-11-07T23:48:45Z")

</div>

They threw whatever was in their hand, once their weapon was gone they would take off their helmet and use that as a weapon.

I don’t remember if they had any other weapons in the inventory, I’m 90% sure they had random stuff in their pockets though.

---

<div class="post-metadata">

### Author: ![Eren\_Rager](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/eren_rager/32/11883_2.png) [@Eren\_Rager](https://discourse.cataclysmdda.org/u/Eren_Rager)
#### Post date: [November 8, 2022, 12:08am UTC](https://discourse.cataclysmdda.org/t/npc-throwing-their-weapons-problem/28312/9 "2022-11-08T00:08:30Z")

</div>

That sounds like an old scenario. Mine doesn’t even have any actual armour on, not even a belt, to they fight with fists after throwing their weapons.

---

<div class="post-metadata">

### Author: ![Fris0uman](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/fris0uman/32/8607_2.png) [@Fris0uman](https://discourse.cataclysmdda.org/u/Fris0uman)
#### Post date: [November 8, 2022, 1:36pm UTC](https://discourse.cataclysmdda.org/t/npc-throwing-their-weapons-problem/28312/10 "2022-11-08T13:36:38Z")

</div>

[Refugee Center NPCs throw instead of shoot · Issue #56908 · CleverRaven/Cataclysm-DDA · GitHub](https://github.com/CleverRaven/Cataclysm-DDA/issues/56908) this might be related

---

<div class="post-metadata">

### Author: ![Eren\_Rager](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/eren_rager/32/11883_2.png) [@Eren\_Rager](https://discourse.cataclysmdda.org/u/Eren_Rager)
#### Post date: [November 9, 2022, 3:25am UTC](https://discourse.cataclysmdda.org/t/npc-throwing-their-weapons-problem/28312/11 "2022-11-09T03:25:27Z")

</div>

I always get free guns from the Teamsters dropping them, and I kinda accept that more than them shooting, since they don’t seem to care about hitting my back in fights last time they joined.

---

<div class="post-metadata">

### Author: ![Eren\_Rager](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/eren_rager/32/11883_2.png) [@Eren\_Rager](https://discourse.cataclysmdda.org/u/Eren_Rager)
#### Post date: [November 9, 2022, 3:29am UTC](https://discourse.cataclysmdda.org/t/npc-throwing-their-weapons-problem/28312/12 "2022-11-09T03:29:52Z")

</div>

Companions only stop throwing their weapons when within like 3 tiles of an enemy. And they throw weapons too when within moving vehicles, not doing so only if explicitly told not to engage or their target is point blank, or when an untraversible terrain is on the way like some quarterpanels.

They never throw clothing though, armour sure, but not clothing. Seems like they just happened to want to throw something when they have a melee weapon equipped, and since they were updated to not throw ranged weapons some time ago they just drop that or put it away, really wanting to throw stuff.
