Barotrauma

Barotrauma

THG Armory - 'Vanilla' Ancient Armory Pack
whosyourdaddy 14 Jun, 2023 @ 11:44pm
[Code Sugguestion] Improve hitbox for ancient spear
When you attack with an ancient spear, it will launchs a collider simulated as hitbox for damaging opponent and the collider will be removed after 0.21s.
But I noticed some problems:
  1. The collider will be heavily affected by gravity, the stab distance will be very different when hitting up or down, not only that, the collider's hitbox will be separated from the actual spear blade position after about 0.1s.
  2. In multiplayer, the client can't immediately receives a network event (such as removing the collider) from the server. So it always makes the collider "fly a little longer" in client side and caused asynchronous attack.
I have fixed them here: OTFX
How?
we just need to deactive the collider after 3 ticks:
add DeactivationTime="0.067" to projectile
and adjust physical body a little bit

In addition, I used Propulsion to simulate attack animations to enhance the sense of hit and it makes the attacking action look more natural.

compare xml before and after for quickly previewing
Before
<Item name="Ancient Spear" identifier="thghandheldspear3" category="Weapon" cargocontaineridentifier="metalcrate" tags="smallitem,weapon,mountableweapon" Scale="0.225" description="A huge, sharp, ancient wood-shafted spear with a hooked bladed head, designed to impale targets from long reaches. It's a little impractically long for use aboard most watercraft, but it's thrusts allow it to be used even in confined spaces, so long as there's enough room between you and your target." impactsoundtag="impact_metal_light"> <InventoryIcon texture="%ModDir%/ancientspearicon.png" sourcerect="0,0,64,64" /> <Sprite texture="%ModDir%/ancientspaer.png" sourcerect="2,713,1250,45" depth="0.55" origin="0.48,0.68" /> <BrokenSprite texture="%ModDir%/ancientspaer.png" sourcerect="2,762,1250,45" depth="0.55" maxcondition="0.01" fadein="False" /> <Body width="1250" height="40" density="25" /> <Price baseprice="450" sold="False" minavailable="0" minleveldifficulty="65"> <Price storeidentifier="merchantcity" multiplier="1.1" sold="true" maxavailable="1" /> </Price> <Deconstruct time="10"> <Item identifier="steel" /> <Item identifier="carbon" /> </Deconstruct> <Fabricate suitablefabricators="fabricator" requiredtime="30"> <RequiredSkill identifier="weapons" level="30" /> <RequiredItem identifier="steel" amount="2" /> <RequiredItem identifier="carbon" amount="1" /> </Fabricate> <Holdable slots="RightHand+LeftHand" controlpose="true" holdpos="-20,-15" aimpos="40,-40" handle1="-200,0" handle2="100,-10" holdangle="120" aimangle="15" msg="ItemMsgPickUpSelect" /> <RangedWeapon reload="1.55" weapondamagemodifier="1" penetration="0.45" holdtrigger="false" barrelpos="110,15" spread="0" unskilledspread="0" combatPriority="-1" drawhudwhenequipped="false" crosshairscale="0.2"> <StatusEffect type="OnUse" target="This" disabledeltatime="true" /> <StatusEffect type="OnUse" target="Contained"> <Use /> </StatusEffect> <StatusEffect type="OnUse" target="This"> <Spawnitem identifiers="thgspear3damagevolume" spawnposition="ThisInventory" /> </StatusEffect> </RangedWeapon> <Wearable slots="Bag" msg="ItemMsgEquipSelect" canbeselected="false" canbepicked="true" pickkey="Select"> <sprite name="Simple Spear Worn" texture="%ModDir%/ancientspaer.png" canbehiddenbyotherwearables="false" sourcerect="2,713,1250,45" rotation="270" inheritlimbdepth="false" depth="0.6" limb="Torso" scale="0.21" origin="0.55,-1.3" /> </Wearable> <ItemContainer capacity="1" maxstacksize="1" SpawnWithId="thgspear3thruster,thgspear3damagevolume" hideitems="false" drawinventory="false" canbeselected="false" removecontaineditemsondeconstruct="true" ShowConditionInContainedStateIndicator="true" containedspritedepth="0.56"> <Containable items="thgspear3thruster" hide="false" itempos="-65,0" /> <SubContainer capacity="1" maxstacksize="1" drawinventory="false" canbeselected="false"> <Containable items="thgspear3damagevolume" hide="false" itempos="85,0" /> </SubContainer> </ItemContainer> <aitarget sightrange="2000" soundrange="4000" fadeouttime="5" /> <Quality> <QualityStat stattype="FirepowerMultiplier" value="0.1" /> </Quality> </Item> <!-- Spear Thruster --> <Item name="ཀSpear Thruster" identifier="thgspear3thruster" hideinmenus="true" category="Material" Tags="smallitem" canbepicked="true" description="" cargocontaineridentifier="metalcrate" scale="0.35" impactsoundtag="impact_metal_light" spritecolor="0,0,0,0" inventoryiconcolor="0,0,0,0"> <InventoryIcon texture="%ModDir%/spaericon.png" sourcerect="0,0,69,69" /> <Sprite texture="%ModDir%/tantoicon.png" sourcerect="512,217,61,31" depth="0.55" origin="0.5,0.5" /> <Body width="45" height="30" density="30" /> <Holdable slots="Any,RightHand,LeftHand" handle1="0,0" msg="ItemMsgPickUpSelect"> <StatusEffect type="OnUse" target="this"> <Explosion range="100.0" force="8" shockwave="false" smoke="false" flames="false" sparks="false" underwaterbubble="false" flash="false" camerashake="0" /> </StatusEffect> </Holdable> </Item> <!-- Spear Damage Volume --> <Item name="ཀSpear Damage Volume" identifier="thgspear3damagevolume" hideinmenus="true" category="Material" Tags="smallitem" canbepicked="true" description="" cargocontaineridentifier="metalcrate" scale="0.35" spritecolor="0,0,0,0" inventoryiconcolor="0,0,0,0"> <InventoryIcon texture="%ModDir%/tantoicon.png" sourcerect="512,217,61,31" /> <Sprite texture="%ModDir%/tantoicon.png" sourcerect="512,217,61,31" depth="0.55" origin="0.5,0.5" /> <Body width="45" height="30" density="0" /> <Holdable slots="Any,RightHand,LeftHand" handle1="0,0" msg="ItemMsgPickUpSelect" /> <Projectile characterusable="false" launchimpulse="10" hitscan="false" removeonhit="true"> <Attack structuredamage="7" itemdamage="25" targetforce="25" severlimbsprobability="0.35"> <Affliction identifier="lacerations" strength="35" /> <Affliction identifier="bleeding" strength="15" /> <Affliction identifier="explosiondamage" strength="15" probability="0.1" /> <Affliction identifier="stun" strength=".6" /> <Sound file="Content/Sounds/Damage/LimbSlash1.ogg" selectionmode="random" range="500" /> <Sound file="Content/Sounds/Damage/LimbSlash2.ogg" range="500" /> <Sound file="Content/Sounds/Damage/LimbSlash3.ogg" range="500" /> <Sound file="Content/Sounds/Damage/LimbSlash4.ogg" range="500" /> <Sound file="Content/Sounds/Damage/LimbSlash5.ogg" range="500" /> <Sound file="Content/Sounds/Damage/LimbSlash6.ogg" range="500" /> </Attack> <StatusEffect type="OnUse" target="This" delay="0.21"> <Remove /> </StatusEffect> </Projectile> </Item>
After
<Item name="" identifier="otfx_ancienthhspear" category="Weapon" tags="smallitem,weapon,mountableweapon" scale="0.5" cargocontaineridentifier="metalcrate" impactsoundtag="impact_metal_light"> <InventoryIcon texture="%ModDir%/OTFX/Items/InventoryIconAtlas.png" sourcerect="0,0,64,64" /> <Sprite texture="%ModDir%/OTFX/Items/Weapons/weapons.png" sourcerect="0,320,613,21" depth="0.55" origin="0.5,0.5" /> <Body width="610" height="20" density="10.5" /> <Price baseprice="450" sold="False" minavailable="0" minleveldifficulty="65"> <Price storeidentifier="merchantcity" multiplier="1.1" sold="true" maxavailable="1" /> </Price> <Deconstruct time="10"> <Item identifier="steel" /> <Item identifier="carbon" /> </Deconstruct> <Fabricate suitablefabricators="fabricator" requiredtime="30"> <RequiredSkill identifier="weapons" level="30" /> <RequiredItem identifier="steel" amount="3" /> <RequiredItem identifier="carbon" amount="2" /> </Fabricate> <Holdable slots="Any,RightHand+LeftHand" controlpose="true" holdpos="40,-40" holdangle="0" aimpos="40,-40" aimangle="0" handle1="-100,0" handle2="15,0" msg="ItemMsgPickUpSelect" /> <RangedWeapon reload="0.9" reloadnoskill="1.1" reloadskillrequirement="100" penetration="0.45" holdtrigger="false" barrelpos="150,0" combatpriority="0"> <Sound file="%ModDir%/OTFX/Items/Weapons/ancienthhspear_stab.ogg" type="OnUse" range="500" frequency="1.3" volume="0.5" /> <StatusEffect type="OnFailure" target="This" reloadtimer="+0.1" disabledeltatime="true" /> <StatusEffect type="OnUse" target="Contained" targets="thruster"> <Use /> </StatusEffect> <StatusEffect type="OnUse" target="This" usablein="Both"> <Spawnitem identifiers="otfx_ancienthhspeardamagecollider" spawnposition="ThisInventory" /> </StatusEffect> <RequiredSkill identifier="weapons" level="50" /> </RangedWeapon> <Propulsion force="300" usablein="None" applytohands="true"> <StatusEffect type="OnUse" target="This" usablein="None" /> </Propulsion> <ItemContainer canbeselected="false" capacity="1" maxstacksize="1" hideitems="true" drawinventory="false" showcontainedstateindicator="false" removecontaineditemsondeconstruct="true" spawnwithid="otfx_ancienthhspeardamagecollider,otfx_ancienthhspearthruster"> <Containable items="otfx_ancienthhspeardamagecollider" /> <SubContainer capacity="1" maxstacksize="1"> <Containable items="otfx_ancienthhspearthruster" itempos="-70,20" /> </SubContainer> </ItemContainer> <AiTarget sightrange="2000" soundrange="4000" fadeouttime="5" /> <Quality> <QualityStat stattype="FirepowerMultiplier" value="0.1" /> </Quality> <SkillRequirementHint identifier="weapons" level="50" /> </Item> <Item name="" identifier="otfx_ancienthhspearthruster" tags="thruster" noninteractable="true" hideinmenus="true"> <Sprite texture="Content/Items/Weapons/weapons_new.png" sourcerect="0,0,2,2" depth="0.55" origin="0.5,0.5" /> <ItemComponent> <StatusEffect type="OnUse" target="This"> <Explosion range="100.0" force="8" showeffects="false" /> </StatusEffect> </ItemComponent> </Item> <Item name="" identifier="otfx_ancienthhspeardamagecollider" noninteractable="true" hideinmenus="true"> <Sprite texture="Content/Items/Weapons/weapons_new.png" sourcerect="0,0,2,2" depth="0.55" origin="0.5,0.5" /> <Body width="50" height="10" density="10" /> <Projectile characterusable="true" launchimpulse="30" deactivationtime="0.067" removeonhit="true"> <Attack targetforce="25" structuredamage="7" itemdamage="25" severlimbsprobability="0.35"> <Affliction identifier="lacerations" strength="35" /> <Affliction identifier="bleeding" strength="15" /> <Affliction identifier="explosiondamage" strength="15" probability="0.1" /> <Affliction identifier="stun" strength="0.6" /> <Sound file="Content/Sounds/Damage/LimbSlash1.ogg" selectionmode="random" range="500" /> <Sound file="Content/Sounds/Damage/LimbSlash2.ogg" range="500" /> <Sound file="Content/Sounds/Damage/LimbSlash3.ogg" range="500" /> <Sound file="Content/Sounds/Damage/LimbSlash4.ogg" range="500" /> <Sound file="Content/Sounds/Damage/LimbSlash5.ogg" range="500" /> <Sound file="Content/Sounds/Damage/LimbSlash6.ogg" range="500" /> </Attack> <StatusEffect type="OnUse" target="This" delay="0.067"> <Remove /> </StatusEffect> </Projectile> </Item>
Last edited by whosyourdaddy; 16 Jun, 2023 @ 9:58pm