Jump to content

Recommended Posts

Hey there!

 

I've tried to make a custom weapon for Shipwrecked. Everything works fine except one thing.

When the weapon is dropped on the ground, it is invisible. But when the weapon is dropped on water, it's visible and floating as intended. I've been trying to figure out why for some time and I have no choice but to ask your help.

Here is the code if you are interested:

 

Spoiler

 


local assets = {
    Asset("ANIM", "anim/bone_mace.zip"),
    Asset("ANIM", "anim/swap_bone_mace.zip"),
    
    Asset( "IMAGE", "images/inventoryimages/bone_mace.tex" ),
    Asset( "ATLAS", "images/inventoryimages/bone_mace.xml" ),
}

local function onequip(inst, owner)
    owner.AnimState:OverrideSymbol("swap_object", "swap_bone_mace", "swap_hammer")
    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()

    MakeInventoryPhysics(inst)

    if IsDLCEnabled(CAPY_DLC) then
        MakeInventoryFloatable(inst, "idle_water", "anim")
    end

    inst.AnimState:SetBank("hammer")
    inst.AnimState:SetBuild("bone_mace")
    inst.AnimState:PlayAnimation("idle")

    inst:AddComponent("characterspecific")
    inst.components.characterspecific:SetOwner("spunky")

    inst:AddComponent("inspectable")
    
    inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.atlasname = "images/inventoryimages/bone_mace.xml"
    
    inst:AddComponent("equippable")
    inst.components.equippable:SetOnEquip(onequip)
    inst.components.equippable:SetOnUnequip(onunequip)
    
    inst:AddComponent("weapon")
    inst.components.weapon:SetDamage(50)
    
    inst:AddComponent("tool")
    inst.components.tool:SetAction(ACTIONS.HAMMER)
    
    return inst
end

return Prefab("common/inventory/bone_mace", fn, assets)

 

I have used anims from the hammer (hammer.zip from dlc002 and swap_hammer.zip from vanilla), I have renamed builds and zips accordingly. I have no idea on what is wrong here.

Thank you in advance for your answers.

Edited by GalloViking

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
×
  • Create New...