Jump to content

Swap Animation not working for some reason


Recommended Posts

Dear readers,

For my character mod: Drok the Caveman, I decided to replace the normal (metal) axe for a more primitive one. I made a new prefab called "primitive_axe" and made it craftable only for Drok. The problem i am having is the swap animation is not working. I took the swap_axe zip from the game files, renamed the zip to "swap_primitive_axe", renamed the build to "swap_primitive_axe", and changed the atlas-0.tex to my own custom one, a reskinned version of the metal axe.

Now everything works in game: Inventory image, crafting, chopping trees with it, inspecting it, ground animation... everything! Except one thing... The character is holding an invisibile axe! 

Does anyone know how to fix this? This is the "primitive_axe.lua":

 

local assets =
{
    Asset("ANIM", "anim/primitive_axe.zip"),
    Asset("ANIM", "anim/swap_primitive_axe.zip"),

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

local function onequip(inst, owner)
    owner.AnimState:OverrideSymbol("swap_object", "swap_primitive_axe", "swap_primitive_axe")
    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") 
    inst.AnimState:PlayAnimation("idle")
end

local function fn(Sim)
    local inst = CreateEntity()
    local trans = inst.entity:AddTransform()
    local anim = inst.entity:AddAnimState()
    local sound = inst.entity:AddSoundEmitter()

    inst.entity:AddNetwork()
    if not TheWorld.ismastersim then
        return inst
    end
    inst.entity:SetPristine()
    MakeHauntableLaunch(inst)

    MakeInventoryPhysics(inst)

    anim:SetBank("primitive_axe")
    anim:SetBuild("primitive_axe")
    anim:PlayAnimation("idle")

    inst:AddTag("sharp")

    inst.entity:SetPristine()

    inst:AddComponent("weapon")
    inst.components.weapon:SetDamage(TUNING.AXE_DAMAGE)

    inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.imagename = "primitive_axe"
    inst.components.inventoryitem.atlasname = "images/inventoryimages/primitive_axe.xml"
    -----
    inst:AddComponent("tool")
    inst.components.tool:SetAction(ACTIONS.CHOP)
    -------
    inst:AddComponent("finiteuses")
    inst.components.finiteuses:SetMaxUses(TUNING.AXE_USES)
    inst.components.finiteuses:SetUses(TUNING.AXE_USES)
    inst.components.finiteuses:SetOnFinished(inst.Remove)
    inst.components.finiteuses:SetConsumption(ACTIONS.CHOP, 1)
    -------

    inst:AddComponent("inspectable")
    
    inst:AddComponent("equippable")

    inst.components.equippable:SetOnEquip(onequip)

    inst.components.equippable:SetOnUnequip(onunequip)

   

    return inst
end

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

 

Thank you in advance

Edited by QuickShot010
Link to comment
Share on other sites

Im guessing for the axe, you just modified a normal axe's atlas-0.tex and renamed things? if so, try this:

--change this:
owner.AnimState:OverrideSymbol("swap_object", "swap_primitive_axe", "swap_primitive_axe")
--to:
owner.AnimState:OverrideSymbol("swap_object", "swap_primitive_axe", "swap_axe")

 

Link to comment
Share on other sites

FJqZTmu.png

 

@Aquaterion I thank you! 

Do you happen to know something about sortkey?
If i put the axe on sortkey=1 in the tools tab, it would disable the crafting of the standard axe and replaces it with the primitive one is that correct? And would it disable the recipe only for this character or for all characters?

Or maybe you know a more efficient way to do this?

Thanks once more!

 

Link to comment
Share on other sites

48 minutes ago, QuickShot010 said:

FJqZTmu.png

 

@Aquaterion I thank you! 

Do you happen to know something about sortkey?
If i put the axe on sortkey=1 in the tools tab, it would disable the crafting of the standard axe and replaces it with the primitive one is that correct? And would it disable the recipe only for this character or for all characters?

Or maybe you know a more efficient way to do this?

Thanks once more!

 

You didn't really specific what you want, but rather how you tried to achieve it but I'm guessing you want to replace the normal axe with this cave axe for that character only. I haven't really messed around too much with replacing recipes, especially for specific characters, but I guess you could do it like lucy(woodie's axe)? When you craft a normal axe, if the character is this guy, it changes to the cave axe. Is that good for you?

Link to comment
Share on other sites

32 minutes ago, Aquaterion said:

You didn't really specific what you want, but rather how you tried to achieve it but I'm guessing you want to replace the normal axe with this cave axe for that character only. I haven't really messed around too much with replacing recipes, especially for specific characters, but I guess you could do it like lucy(woodie's axe)? When you craft a normal axe, if the character is this guy, it changes to the cave axe. Is that good for you?

That is excactly what i meant! :D

I just want the normal axe to be disabled for only this character, and the primitive axe on the same spot as the normal axe, so you don't have to scroll down all the way (i already made the primitive axe only craftable for my character, but now i need to disable the normal axe only for my character)

 

For some reason using " primitive_axe.sortkey = 1 " crashes the game, did sortkeys change in DST?

Edited by QuickShot010
Link to comment
Share on other sites

2 hours ago, Aquaterion said:

Not really sure as I never used sortkeys, but I did see a post that had someone want to sort things:

It might help, but if you want the method of making a normal axe, which then transforms into the new axe, lemme know

The method you have in mind is a bit cleaner right? And I am planning on making the pickaxe primitive at some point as well, this way it would still be able to craft the heat rock thing for example right?

I have a few questions though, does your method allow for custom dialogue, the axe being named "primitive axe", inventory images and ground animations?

I'm interested to see what you have in mind!

Cheers!

Edited by QuickShot010
Link to comment
Share on other sites

46 minutes ago, QuickShot010 said:

The method you have in mind is a bit cleaner right? And I am planning on making the pickaxe primitive at some point as well, this way it would still be able to craft the heat rock thing for example right?

I have a few questions though, does your method allow for custom dialogue, the axe being named "primitive axe", inventory images and ground animations?

I'm interested to see what you have in mind!

Cheers!

Hmm they way I was thinking is just, when you make a NORMAL axe, after it is made, it will check if the player who made it is a caveman, and if it is, it instantly turns it into the caveman axe

Link to comment
Share on other sites

4 minutes ago, Aquaterion said:

Hmm they way I was thinking is just, when you make a NORMAL axe, after it is made, it will check if the player who made it is a caveman, and if it is, it instantly turns it into the caveman axe

I think it will not really make a difference with the way i have it right now. The only thing i still have left to do is disable the normal axe crafting for my character (i don't know how to do that? Maybe change the science needed to craft it to 9999 only for my character?) and i need to get those sortkeys working, but i'm having a bad time with them. The game just tell me it has an error and i need to check the log but the log says NOTHING useful at all as far as i can see.

Do you think you can help me with this?

cheers!

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