Jump to content

Recommended Posts

Hello! I'm trying to create a weapon similar to hambat, but ran into a problem with it not being shown on the player or on the ground!
I tried a lot of things but it all just comes to it being invisible or game crashing :(

I was using this template to generate "swap_vegiebat" and "vegiebat" animation zip's


Thanks in advance!

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

local function UpdateDamage(inst)
    if inst.components.perishable and inst.components.weapon then
        local dmg = TUNING.HAMBAT_DAMAGE * inst.components.perishable:GetPercent()
    	
        dmg = Remap(dmg, 0, TUNING.HAMBAT_DAMAGE, TUNING.HAMBAT_MIN_DAMAGE_MODIFIER*TUNING.HAMBAT_DAMAGE, TUNING.HAMBAT_DAMAGE)
        inst.components.weapon:SetDamage(dmg)
    end
end



local function OnLoad(inst, data)
    UpdateDamage(inst)
end

local function onequip(inst, owner)
    UpdateDamage(inst)
    local skin_build = inst:GetSkinBuild()
    if skin_build ~= nil then
        owner:PushEvent("equipskinneditem", inst:GetSkinName())
        owner.AnimState:OverrideItemSkinSymbol("swap_vegiebat", skin_build, "swap_vegiebat", inst.GUID, "swap_vegiebat")
    else
        owner.AnimState:OverrideSymbol("swap_object", "swap_vegiebat", "vegiebat")
    end

    owner.AnimState:Show("ARM_carry")
    owner.AnimState:Hide("ARM_normal")
end

local function onunequip(inst, owner)
    UpdateDamage(inst)
    owner.AnimState:Hide("ARM_carry")
    owner.AnimState:Show("ARM_normal")
    local skin_build = inst:GetSkinBuild()
    if skin_build ~= nil then
        owner:PushEvent("unequipskinneditem", inst:GetSkinName())
    end
end

local function fn()
    local inst = CreateEntity()

    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    inst.entity:AddNetwork()

    MakeInventoryPhysics(inst)

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

    inst:AddTag("show_spoilage")
    inst:AddTag("icebox_valid")

    --weapon (from weapon component) added to pristine state for optimization
    inst:AddTag("weapon")

    local swap_data = {sym_build = "swap_vegiebat", bank = "vegiebat"}
    MakeInventoryFloatable(inst, "med", nil, {1.0, 0.5, 1.0}, true, -13, swap_data)

    inst.entity:SetPristine()

    if not TheWorld.ismastersim then
        return inst
    end

    inst:AddComponent("perishable")
    inst.components.perishable:SetPerishTime(TUNING.PERISH_MED)
    inst.components.perishable:StartPerishing()
    inst.components.perishable.onperishreplacement = "spoiled_food"

    inst:AddComponent("weapon")
    inst.components.weapon:SetDamage(TUNING.VEGIEBAT_DAMAGE)
    inst.components.weapon:SetOnAttack(UpdateDamage)

    inst:AddComponent("forcecompostable")
    inst.components.forcecompostable.green = true

    inst.OnLoad = OnLoad


    ---inst:AddComponent("edible")
    --inst.components.edible.foodtype = FOODTYPE.MEAT
    --inst.components.edible.healthvalue = -TUNING.HEALING_MEDSMALL
    --inst.components.edible.hungervalue = TUNING.CALORIES_MED
    --inst.components.edible.sanityvalue = -TUNING.SANITY_MED
 

    inst:AddComponent("inspectable")

    inst:AddComponent("inventoryitem")

    MakeHauntableLaunchAndPerish(inst)

    inst:AddComponent("equippable")
    inst.components.equippable:SetOnEquip(onequip)
    inst.components.equippable:SetOnUnequip(onunequip)

    return inst
end

return Prefab( "vegiebat", fn, assets)

 

12 hours ago, RexySeven said:

Hello! I'm trying to create a weapon similar to hambat, but ran into a problem with it not being shown on the player or on the ground!
I tried a lot of things but it all just comes to it being invisible or game crashing :(

I was using this template to generate "swap_vegiebat" and "vegiebat" animation zip's


Thanks in advance!

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

local function UpdateDamage(inst)
    if inst.components.perishable and inst.components.weapon then
        local dmg = TUNING.HAMBAT_DAMAGE * inst.components.perishable:GetPercent()
    	
        dmg = Remap(dmg, 0, TUNING.HAMBAT_DAMAGE, TUNING.HAMBAT_MIN_DAMAGE_MODIFIER*TUNING.HAMBAT_DAMAGE, TUNING.HAMBAT_DAMAGE)
        inst.components.weapon:SetDamage(dmg)
    end
end



local function OnLoad(inst, data)
    UpdateDamage(inst)
end

local function onequip(inst, owner)
    UpdateDamage(inst)
    local skin_build = inst:GetSkinBuild()
    if skin_build ~= nil then
        owner:PushEvent("equipskinneditem", inst:GetSkinName())
        owner.AnimState:OverrideItemSkinSymbol("swap_vegiebat", skin_build, "swap_vegiebat", inst.GUID, "swap_vegiebat")
    else
        owner.AnimState:OverrideSymbol("swap_object", "swap_vegiebat", "vegiebat")
    end

    owner.AnimState:Show("ARM_carry")
    owner.AnimState:Hide("ARM_normal")
end

local function onunequip(inst, owner)
    UpdateDamage(inst)
    owner.AnimState:Hide("ARM_carry")
    owner.AnimState:Show("ARM_normal")
    local skin_build = inst:GetSkinBuild()
    if skin_build ~= nil then
        owner:PushEvent("unequipskinneditem", inst:GetSkinName())
    end
end

local function fn()
    local inst = CreateEntity()

    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    inst.entity:AddNetwork()

    MakeInventoryPhysics(inst)

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

    inst:AddTag("show_spoilage")
    inst:AddTag("icebox_valid")

    --weapon (from weapon component) added to pristine state for optimization
    inst:AddTag("weapon")

    local swap_data = {sym_build = "swap_vegiebat", bank = "vegiebat"}
    MakeInventoryFloatable(inst, "med", nil, {1.0, 0.5, 1.0}, true, -13, swap_data)

    inst.entity:SetPristine()

    if not TheWorld.ismastersim then
        return inst
    end

    inst:AddComponent("perishable")
    inst.components.perishable:SetPerishTime(TUNING.PERISH_MED)
    inst.components.perishable:StartPerishing()
    inst.components.perishable.onperishreplacement = "spoiled_food"

    inst:AddComponent("weapon")
    inst.components.weapon:SetDamage(TUNING.VEGIEBAT_DAMAGE)
    inst.components.weapon:SetOnAttack(UpdateDamage)

    inst:AddComponent("forcecompostable")
    inst.components.forcecompostable.green = true

    inst.OnLoad = OnLoad


    ---inst:AddComponent("edible")
    --inst.components.edible.foodtype = FOODTYPE.MEAT
    --inst.components.edible.healthvalue = -TUNING.HEALING_MEDSMALL
    --inst.components.edible.hungervalue = TUNING.CALORIES_MED
    --inst.components.edible.sanityvalue = -TUNING.SANITY_MED
 

    inst:AddComponent("inspectable")

    inst:AddComponent("inventoryitem")

    MakeHauntableLaunchAndPerish(inst)

    inst:AddComponent("equippable")
    inst.components.equippable:SetOnEquip(onequip)
    inst.components.equippable:SetOnUnequip(onunequip)

    return inst
end

return Prefab( "vegiebat", fn, assets)

 

There may be a problem with the way you created the anim file, please upload your Vegiebat file here including the exported folder

8 hours ago, Haruhi Kawaii said:

There may be a problem with the way you created the anim file, please upload your Vegiebat file here including the exported folder


Here's the mod files
It's part of a character mod
I would be really thankful if you could help!
 

whispy.7z

12 hours ago, RexySeven said:


Here's the mod files
It's part of a character mod
I would be really thankful if you could help!
 

whispy.7z 4.03 MB · 1 download

I fixed, vegiebat, modmain and exported folder

whispy.zip

54 minutes ago, Haruhi Kawaii said:

I fixed, vegiebat, modmain and exported folder

whispy.zip 6.77 MB · 0 downloads


oh my god it works flawlessly!!! Thank you so much!!! You're a savior!! :D

What was the problem with it? I'm curious so I don't make same errors again

5 hours ago, RexySeven said:


oh my god it works flawlessly!!! Thank you so much!!! You're a savior!! :D

What was the problem with it? I'm curious so I don't make same errors again

You can visit this thread to better understand how to create in Spriter

Also that the drop to the ground doesn't work because the code from lines 57-59 is incorrect. In this thread he wrote a very clear comment on custom_handitem.lua


In modmain AddRecipe is deprecated, you should replace it with AddRecipe2

 

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...