Jump to content

[SOLVED] Custom weapon doesn't work on worlds with caves


Recommended Posts

I made a custom weapon for my character and everything was looking really good

But when i start a world with caves enabled, the weapon doesn't do the attack animation (looks like it punches, but without his arm) and it's invisible on the ground and on the inventory tab

maplespear.lua Code here:

Quote

 

local assets=

    Asset("ANIM", "anim/maplespear.zip"),
    Asset("ANIM", "anim/swap_maplespear.zip"), 

    Asset("ATLAS", "images/inventoryimages/maplespear.xml"),
    Asset("IMAGE", "images/inventoryimages/maplespear.tex"),
}

local function onequip(inst, owner) 
        --owner.AnimState:OverrideSymbol("swap_object", "swap_maplespears", "purplestaff")
        owner.AnimState:OverrideSymbol("swap_object", "swap_maplespear", "maplespear")
        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()
    local inst = CreateEntity()
    
    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    inst.entity:AddSoundEmitter()
    inst.entity:AddNetwork()

    MakeInventoryPhysics(inst)
    inst:AddTag("sharp")
    
    inst.entity:SetPristine()
     
     if not TheWorld.ismastersim then
        return inst
    end
    
    inst.AnimState:SetBank("maplespear")
    inst.AnimState:SetBuild("maplespear")
    inst.AnimState:PlayAnimation("idle")

     
    inst:AddComponent("weapon")
    inst.components.weapon:SetDamage(48)
    inst:AddComponent("inspectable")
    
    inst:AddComponent("finiteuses")
    inst.components.finiteuses:SetMaxUses(1000)
    inst.components.finiteuses:SetUses(1000)
    inst.components.finiteuses:SetOnFinished(inst.Remove)
    
    inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.imagename = "maplespear"
    inst.components.inventoryitem.atlasname = "images/inventoryimages/maplespear.xml"
    
    inst:AddComponent("equippable")
    inst.components.equippable:SetOnEquip(onequip)
    inst.components.equippable:SetOnUnequip(onunequip)

    MakeHauntableLaunch(inst)
    
    return inst
end

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

 

 

 

Can somebody please tell me what i'm doing bad and why the mods only works with world without caves?

I'm new at modding tho

If the problem is in other files, the entire mod is here:

Wavis1.rar

Edited by Rivecoder
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...