Barotrauma icon indicating copy to clipboard operation
Barotrauma copied to clipboard

DelayedEffect with delaytype="ReachCursor" is always applied immediately, regardless of whether the projectile reaches the cursor or not

Open zhu-rengong opened this issue 1 year ago • 3 comments

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?

When you specify the DelayType of DelayedEffect as ReachCursor, before the Effect is applied, it will calculate the distance from the item to the Cursor position of its projectile.User. If the displacement of the projectile exceeds this distance, the Effect will be applied. But now, as the title says, the displacement has exceeded the predetermined distance before Effect is applied.

Reproduction steps

  1. Copy the following xml code into any projectile component of any item:
<StatusEffect type="OnUse" target="This" delaytype="ReachCursor">
    <Remove />
</StatusEffect>
  1. Shoot the modified projectile
  2. projectile will be removed immediately

Bug prevalence

Happens every now and then

Single player or multiplayer?

Single player

-

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

zhu-rengong avatar Feb 14 '24 08:02 zhu-rengong

The predetermined distance in this case seems to be 0 (as you have not defined any distance), so the expected behavior is that the effect triggers immediately (since the distance will always be larger than 0).

This is some ancient functionality btw that we didn't end up using for anything, so I'm not entirely sure if it'd work correctly even if the distance was defined. I'm kind of leaning towards just removing it (especially if it doesn't work).

Regalis11 avatar Feb 14 '24 10:02 Regalis11

Actually we don't need to give the distance, because distance = Vector2.Distance(projectile.WorldPosition,character.CursorWorldPosition), it depends on where your cursor position is.

zhu-rengong avatar Feb 14 '24 12:02 zhu-rengong

Ah, you're right, I'd missed that part of the code!

Fixed in https://github.com/FakeFishGames/Barotrauma-development/commit/c9d49ed77e5cfdc54a82c60b140b5002736a403d

Regalis11 avatar Feb 19 '24 09:02 Regalis11