OnInserted status effect triggers even when you fail to insert
Discussed in https://github.com/FakeFishGames/Barotrauma/discussions/15283
Originally posted by A2ur3 November 30, 2024
Disclaimers
- [X] I have searched the issue tracker to check if the issue has already been reported.
- [X] My issue happened while using mods.
What happened?
<Item name="Experimental Rifle" identifier="ex_rifle" category="Weapon" cargocontaineridentifier="metalcrate" tags="mediumitem,weapon,gun,gunsmith,provocativetohumanai,mountableweapon" Scale="0.5" impactsoundtag="impact_metal_light">
<Sprite texture="Content/Items/Weapons/weapons_new.png" sourcerect="254,2,200,55" depth="0.55" origin="0.5,0.25" />
<Body width="190" height="50" density="25" />
<Holdable slots="Any,RightHand+LeftHand" controlpose="true" holdpos="40,-10" aimpos="55,5" handle1="-25,-16" handle2="26,0" holdangle="-40" msg="ItemMsgPickUpSelect" />
<ItemContainer capacity="1" maxstacksize="1" hideitems="false" containedstateindicatorstyle="bullet" containedstateindicatorslot="1" containedspritedepth="0.56">
<Containable items="grenade" hide="false" itempos="50,0">
<StatusEffect type="OnInserted" target="This">
<Sound file="Content/Items/Weapons/WEAPON_rifleGrenadeShot1.ogg" range="1000" />
</StatusEffect>
</Containable>
<SlotIcon slotindex="0" texture="Content/UI/StatusMonitorUI.png" sourcerect="448,448,64,64" origin="0.5,0.5" />
<SlotIcon slotindex="1" texture="Content/UI/StatusMonitorUI.png" sourcerect="256,448,64,64" origin="0.5,0.5" />
<SubContainer capacity="1" maxstacksize="2">
<Containable items="rifleammo" hide="true">
<StatusEffect type="OnInserted" target="This" condition="-5" disabledeltatime="true">
<Sound file="Content/Items/Weapons/WEAPON_rifleReload50-_1.ogg" range="500" />
</StatusEffect>
</Containable>
</SubContainer>
</ItemContainer>
</Item>
Reproduction steps
- test item "Experimental Rifle"
- insert 2 rifle bullets inside -> weapon condition will decrease 10% expected behavior
- try to insert smg magazine into bullet slot -> weapon condition will decrease 15%
Bug prevalence
Just once
Single player or multiplayer?
Single player
-
No response
Version
v1.6.19.1 (Unto the Breach Update Hotfix 2)
-
No response
Which operating system did you encounter this bug on?
Windows
Relevant error messages and crash reports
No response
Tested in autumn-update b7d9aaaf
Confirmed that the issue is still reproducible
Seems to happen when the rifle is already equipped with bullets, and the player tries to replace them with something that can not be equipped. Once the equipping fails, it seems like the bullets that were already placed in the rifle are re-equipped, causing further condition loss.
Can be easily reproduced by equipping the weapon with riflebullets and then attempting to replace the bullets with a SMG Round.
https://github.com/user-attachments/assets/5146bd85-a7a4-4b05-a1fd-25c898d7e090
Sending to bugfixes.