Jump to content

[Help] how to replace horn or flute animation with different item


Bleksmits

Recommended Posts

In my deerclops horn mood i can't add to play animation with my creation its always play with different item default horn or pan flute depends what is in [inst:AddTag("flute")] or  [inst:AddTag("horn")]
not mine. When i wrote [inst:AddTag("rags")] nothing hapen's.

 

 

rags mean horn in my language:)

 

 

local Assets =
{
    Asset("ANIM", "anim/rags_build.zip"),
    Asset("ATLAS", "images/inventoryimages/rags.xml"),

local function onfinished(inst)
    inst:Remove()
end

local function TryAddFollower(leader, follower) -- no erors
    if leader.components.leader
       and follower.components.follower
       and follower:HasTag("beefalo") and not follower:HasTag("baby")
       and leader.components.leader:CountFollowers("beefalo") < TUNING.HORN_MAX_FOLLOWERS then
        leader.components.leader:AddFollower(follower)
        follower.components.follower:AddLoyaltyTime(TUNING.HORN_EFFECTIVE_TIME+math.random())
        if follower.components.combat and follower.components.combat.target and follower.components.combat.target == leader then
            follower.components.combat:SetTarget(nil)
        end
        follower:DoTaskInTime(math.random(), function() follower.sg:PushEvent("heardhorn", {musician = leader} )end)
    end
end -- !!


local function HearRags(inst, musician, instrument)  -- OK no errors
    if musician.components.leader then
        local herd = nil
        if inst:HasTag("beefalo") and not inst:HasTag("baby") and inst.components.herdmember then
            if inst.components.combat and inst.components.combat.target then
                inst.components.combat:GiveUp()
            end
            TryAddFollower(musician, inst)
            herd = inst.components.herdmember:GetHerd()
        end
        if herd and herd.components.herd then
            for k,v in pairs(herd.components.herd.members) do
                TryAddFollower(musician, k)
            end
        end
    end
end  -- OK



local function fn(Sim)
    local inst = CreateEntity()
    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    
    inst:AddTag("flute")  -- !!!???
    
    MakeInventoryPhysics(inst)
    
    inst.AnimState:SetBank("horn")  
    inst.AnimState:SetBuild("rags_build")
    inst.AnimState:PlayAnimation("idle")  
    MakeInventoryPhysics(inst)  
    
    inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.atlasname = "images/inventoryimages/rags.xml"

    inst:AddComponent("inspectable")
    
    inst:AddComponent("instrument")  
    inst.components.instrument.range = TUNING.HORN_RANGE  
    inst.components.instrument:SetOnHeardFn(HearRags)
    
    inst:AddComponent("tool")  
    inst.components.tool:SetAction(ACTIONS.PLAY)  
    
    
    inst:AddComponent("fuel") -- ok
    inst.components.fuel.fuelvalue = TUNING.MED_FUEL -- ok can burn :)

    return inst
end

STRINGS.NAMES.RAGS = "Litle hornelio"
STRINGS.CHARACTERS.GENERIC.DESCRIBE.RAGS = "Should something do but don't!"

return Prefab( "common/inventory/rags", fn, Assets)

post-343123-0-59058100-1410003607_thumb.

Link to comment
Share on other sites

Tags don't change how the thing works, they only let other things know what it is.

 

Turns out the WilsonStateGraph handles the "Play"-action by checking for the horn/flute tag to determine the animations to be played.

Two ways to get your animation working is by overriding WilsonSG or changing the characters stategraph to one of your own. In both scenarios, another mod that does these ways will not work, keep yours from working or crash the game.

 

Sorry, I can't help more.

Link to comment
Share on other sites

Tags don't change how the thing works, they only let other things know what it is.

 

Turns out the WilsonStateGraph handles the "Play"-action by checking for the horn/flute tag to determine the animations to be played.

Two ways to get your animation working is by overriding WilsonSG or changing the characters stategraph to one of your own. In both scenarios, another mod that does these ways will not work, keep yours from working or crash the game.

 

Sorry, I can't help more.

 

Thanks! I'll see what I can do.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
×
  • Create New...