Jump to content

Custom item doesn't drop correctly?


Recommended Posts

Hi, I was moving all my items over to my DST version of my mod when I came across this issue. When I drop an item in a cave-less world, the item's dropping animation plays just fine. But when I drop the item in a world with caves, it flies from off screen instead of dropping off my character? example.gif.2631aa22ade8f8fd82c9488c0a84e2b8.gif

Link to comment
Share on other sites

Quote

local assets=

    Asset("ANIM", "anim/wakes_spear.zip"),
    Asset("ANIM", "anim/wakes_spear_swap.zip"), 
    Asset("ATLAS", "images/inventoryimages/wakes_spear.xml"),
    Asset("IMAGE", "images/inventoryimages/wakes_spear.tex"),
}

local prefabs = 
{
}

 local function OnEquip(inst, owner) 
        owner.AnimState:OverrideSymbol("swap_object", "wakes_spear_swap", "wakes_spear")
        owner.AnimState:Show("ARM_carry") 
        owner.AnimState:Hide("ARM_normal") 
end

local function OnUnequip(inst, owner) 
        owner.AnimState:Hide("ARM_carry") 
        owner.AnimState:Show("ARM_normal") 
end    

local function fn(sim)
    local inst = CreateEntity()
    
    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    inst.entity:AddNetwork()

    inst.AnimState:SetBank("wakes_spear")
    inst.AnimState:SetBuild("wakes_spear")
    inst.AnimState:PlayAnimation("idle")
    

    inst:AddTag("sharp")
    inst:AddTag("weapon")
    
    MakeInventoryFloatable(inst, "med", 0.05, {1.1, 0.5, 1.1}, true, -9)
    
    inst.entity:SetPristine()

    if not TheWorld.ismastersim then
        return inst
    end
    
    inst:AddComponent("weapon")
    inst.components.weapon:SetDamage(TUNING.SPEAR_DAMAGE*1.25)
    
    inst:AddComponent("finiteuses")
    inst.components.finiteuses:SetMaxUses(TUNING.SPEAR_USES*1.35)
    inst.components.finiteuses:SetUses(TUNING.SPEAR_USES*1.35)
    
    inst:AddComponent("waterproofer")
    inst.components.waterproofer.effectiveness = 0

    inst:AddComponent("inspectable")

    inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.imagename = "wakes_spear"
    inst.components.inventoryitem.atlasname = "images/inventoryimages/wakes_spear.xml"
    
    inst:AddComponent("equippable")
    inst.components.equippable:SetOnEquip( OnEquip )
    inst.components.equippable:SetOnUnequip( OnUnequip )

    MakeHauntableLaunch(inst)
    
    return inst
end

return  Prefab("common/inventory/wakes_spear", fn, assets, prefabs)

There's the code

MakeInventoryPhysics(inst)! That's what I was missing. I must've took it out.

Now to figure out how to make them float in Return of Them. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...