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

Projectile does not consider whether the item has been flipped when being shot. #13479

Closed
2 tasks done
zhu-rengong opened this issue Feb 25, 2024 · 1 comment
Closed
2 tasks done
Assignees
Labels
Bug Something isn't working Code Programming task

Comments

@zhu-rengong
Copy link

Disclaimers

  • I have searched the issue tracker to check if the issue has already been reported.
  • My issue happened while using mods.

What happened?

Potential bugs for modding:
When you set deep diver duck's launch impulse to 20.0
and change its body element to <Body width="160" height="10" density="30" /> for easy observation
If you throw it to the right, it seems to fly forward
On the contrary, if you throw it towards the left, it will seem to fly backward.
This seems to be because the Throwable will require the item to be also flipped when its picker is flipped, and the projectile does not consider this situation when it is shot.

test video:
https://github.com/FakeFishGames/Barotrauma/assets/73634685/89263c05-f386-4318-b43d-fc49fa1bc20b

overrided xml code of deep diver duck:

<Override>
  <Item name="" identifier="deepdiverduck" category="Misc" Tags="smallitem,traitormissionitem" maxstacksize="1" impacttolerance="4" inventoryiconcolor="110,120,110,255" spritecolor="110,120,110" impactsoundtag="impact_metal_heavy">
    <PreferredContainer primary="storagecab" />
    <PreferredContainer secondary="wreckstorage,abandonedstoragecab" spawnprobability="0" />
    <Price baseprice="38" sold="false" canbespecial="false">
      <Price storeidentifier="merchantoutpost" multiplier="1.3" />
      <Price storeidentifier="merchantcity" multiplier="1.25" />
      <Price storeidentifier="merchantresearch" />
      <Price storeidentifier="merchantmilitary" multiplier="0.9" />
      <Price storeidentifier="merchantmine" multiplier="0.9" />
    </Price>
    <Fabricate suitablefabricators="fabricator" hidefornontraitors="true" requiredtime="10">
      <RequiredSkill identifier="helm" level="10" />
      <RequiredItem identifier="rubber" />
      <RequiredItem identifier="lead" />
    </Fabricate>
    <InventoryIcon texture="Content/Map/Outposts/Art/FactionItems.png" sourcerect="448,448,64,64" />
    <Sprite texture="Content/Map/Outposts/Art/FactionItems.png" sourcerect="394,200,43,43" depth="0.55" origin="0.5,0.5" />
    <Body width="160" height="10" density="30" />
    <ItemComponent>
      <StatusEffect type="OnImpact">
        <sound file="Content/Sounds/Damage/StructureBlunt1.ogg" range="500" frequencymultiplier="1.2" />
        <Explosion range="50.0" showeffects="false" structuredamage="10" decal="" />
      </StatusEffect>
    </ItemComponent>
    <Throwable slots="Any,RightHand,LeftHand" holdpos="0,0" handle1="0,0" throwforce="3.5" msg="ItemMsgPickUpSelect">
      <StatusEffect type="OnSecondaryUse" target="This" delay="0.1">
        <Use />
      </StatusEffect>
    </Throwable>
    <Projectile characterusable="false" launchimpulse="20.0" sticktocharacters="false">
      <Attack structuredamage="5">
        <Affliction identifier="blunttrauma" strength="5" />
        <Affliction identifier="stun" strength="0.5" />
        <StatusEffect type="OnUse" target="UseTarget">
          <Conditional entitytype="eq Character" />
          <Sound file="Content/Items/Weapons/Smack1.ogg" selectionmode="random" range="500" />
          <Sound file="Content/Items/Weapons/Smack2.ogg" range="500" />
        </StatusEffect>
        <StatusEffect type="OnUse" target="Limb" targetLimbs="Head">
          <Affliction identifier="concussion" strength="10" />
          <Affliction identifier="stun" strength="5" />
        </StatusEffect>
      </Attack>
    </Projectile>
  </Item>
</Override>

I found a workaround to fix it via modding:
Add the following code to the Throwable element:

<StatusEffect type="OnSecondaryUse" target="This" targetitemcomponent="Projectile" launchimpulse="20.0" setvalue="true" />
<StatusEffect type="OnSecondaryUse" target="This" targetitemcomponent="Projectile" launchimpulse="-20.0" setvalue="true">
  <Conditional flippedx="true" />
</StatusEffect>

Reproduction steps

  1. copy the above xml code to override deep diver duck
  2. spawn and throw it

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

@itchyOwl itchyOwl added Bug Something isn't working Code Programming task labels Feb 29, 2024
@itchyOwl itchyOwl assigned kumilanka and Regalis11 and unassigned kumilanka Feb 29, 2024
@giists
Copy link
Collaborator

giists commented May 23, 2024

Closing as completed

@giists giists closed this as completed May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Code Programming task
Projects
None yet
Development

No branches or pull requests

5 participants