Barotrauma
Barotrauma copied to clipboard
MeleeWeapon does not specify the target component when creating EntityEvent
Disclaimers
- [X] I have searched the issue tracker to check if the issue has already been reported.
- [ ] My issue happened while using mods.
What happened?
As the title said, check the following code: https://github.com/FakeFishGames/Barotrauma/blob/0c433eb187b20f4bd24a1919b478529b387ee0bf/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Holdable/MeleeWeapon.cs#L477-L478 It will cause async on the client side Should change it to:
server.CreateEntityEvent(item, new Item.ApplyStatusEffectEventData(conditionalActionType, targetItemComponent: this, targetCharacter, targetLimb, useTarget: targetEntity));
server.CreateEntityEvent(item, new Item.ApplyStatusEffectEventData(ActionType.OnUse, targetItemComponent: this, targetCharacter, targetLimb, useTarget: targetEntity));
Reproduction steps
- Subscribe the mod(OTFX): https://steamcommunity.com/sharedfiles/filedetails/?id=2986787106
- Host a server and start game
- Enter cheat code: spawnitem otfx_assaultrifle2 inventory
- Double click RMB to switch attack mode for using its melee weapon
- Melee attack at something, you will notice your screen is shaking
- Shaking will not happen in single player mode
https://github.com/FakeFishGames/Barotrauma/assets/73634685/4f27760b-0172-44db-ab3d-283e48ccb687
Bug prevalence
Happens every now and then
Single player or multiplayer?
Multiplayer hosted from the in-game menu (= using a listen server)
-
No response
Version
v1.2.8.0 (Winter Update hotfix 2)
-
No response
Which operating system did you encounter this bug on?
Windows
Relevant error messages and crash reports
No response
Reproduction steps
- Subscribe the mod(OTFX): https://steamcommunity.com/sharedfiles/filedetails/?id=2986787106
- Host a server and start game
- Enter cheat code: spawnitem otfx_assaultrifle2 inventory
- Double click RMB to switch attack mode for using its melee weapon
- Melee attack at something, you will notice your screen is shaking
- Shaking will not happen in single player mode
Please note that I have fixed this problem in the otfx mod through a workaround; if you need to use this mod for testing, you need to find the xml code with the identifier otfx_assaultrifle2 and replace the following code:
- Replace
<StatusEffect type="OnUse" target="This" targetitemcomponent="RangedWeapon" reloadtimer="+0.5" isactive="true" disabledeltatime="true">
<Explosion range="150.0" force="2" shockwave="false" smoke="false" flames="false" flash="true" sparks="false" underwaterbubble="false" applyfireeffects="false" camerashake="6.0" />
<!-- Workaround to fix async on client side by this way here and other places, the issue has been reporeted in https://github.com/FakeFishGames/Barotrauma/issues/13405 -->
<RequiredItems items="otfx_assaultrifle2rw" type="Contained" />
</StatusEffect>
With
<StatusEffect type="OnUse" target="This" targetitemcomponent="RangedWeapon" reloadtimer="+0.5" isactive="true" disabledeltatime="true">
<Explosion range="150.0" force="2" shockwave="false" smoke="false" flames="false" flash="true" sparks="false" underwaterbubble="false" applyfireeffects="false" camerashake="6.0" />
</StatusEffect>
- Replace
<StatusEffect type="OnUse">
<ParticleEmitter particle="casingfirearm" particleamount="1" copyentityangle="true" anglemin="90" anglemax="150" velocitymin="50" velocitymax="250" />
<Explosion range="150.0" force="1" shockwave="false" smoke="false" flames="false" sparks="false" underwaterbubble="false" camerashake="12.0" />
<RequiredItems items="otfx_assaultrifle2rw" type="Contained" />
</StatusEffect>
With
<StatusEffect type="OnUse">
<ParticleEmitter particle="casingfirearm" particleamount="1" copyentityangle="true" anglemin="90" anglemax="150" velocitymin="50" velocitymax="250" />
<Explosion range="150.0" force="1" shockwave="false" smoke="false" flames="false" sparks="false" underwaterbubble="false" camerashake="12.0" />
</StatusEffect>
Fixed in https://github.com/FakeFishGames/Barotrauma-development/commit/538899695494acc73730df348723572791cfdd90
Merged, closing