Jump to content

[SOLVED] Looping Eat Sound


Recommended Posts

I have created a food item that instigates a player transformation; however, the eat sound loops endlessly afterwards. I assume this is something to do with the animation not fully playing out because of how instantly the transformation takes place? I have attempted to play with the DoTaskInTime function, but can't seem to get it to work. Anybody have any suggestions? I have included the transformation script as well in case that interferes with the eating.

local function becomebob(inst)
 
        inst.wererabbit = false
 
        inst.AnimState:SetBank("wilson")
        inst.AnimState:SetBuild("bob")
        inst:SetStateGraph("SGwilson")
 local health_percent = inst.components.health:GetPercent()
 inst.components.health:SetMaxHealth(100)
 inst.components.health:SetPercent(health_percent, true)
 local sanity_percent = inst.components.sanity:GetPercent()
 inst.components.sanity.max = 120
 inst.components.sanity:SetPercent(sanity_percent, true)
 local hunger_percent = inst.components.hunger:GetPercent()
 inst.components.hunger:SetMax(bobbi_hunger)
 inst.components.hunger:SetPercent(hunger_percent, true)
        inst.Transform:SetScale(1., 1., 1.)
        inst:RemoveTag("scarytoprey")
 STRINGS.CHARACTERS.BOB = require "speech_bob"
 inst.components.talker.special_speech = false
      
end
 
 
local function becomewererabbit(inst)
 
        inst.wererabbit = true
 
        inst.AnimState:SetBank("manrabbit")
        inst.AnimState:SetBuild("manrabbit_build")
        inst:SetStateGraph("SGwererabbit")
 local health_percent = inst.components.health:GetPercent()
 inst.components.health:SetMaxHealth(200)
 inst.components.health:SetPercent(health_percent, true)
 local sanity_percent = inst.components.sanity:GetPercent()
 inst.components.sanity.max = 100
 inst.components.sanity:SetPercent(sanity_percent, true)
        inst.components.sanity:DoDelta(-TUNING.SANITY_HUGE)
 local hunger_percent = inst.components.hunger:GetPercent()
 inst.components.hunger:SetMax(wererabbit_hunger)
 inst.components.hunger:SetPercent(hunger_percent, true)
        inst.Transform:SetScale(1.25, 1.25, 1.25)
        inst.components.combat:SetDefaultDamage(TUNING.BUNNYMAN_DAMAGE)
        inst:AddTag("scarytoprey")
 STRINGS.CHARACTERS.BOB = require "speech_wob"
 inst.components.talker.special_speech = false
end
   
 
inst:ListenForEvent("oneat", function(inst, data)
 if data.food.prefab == "werecarrot" and not inst.wererabbit then
 EntityScript:DoTaskInTime(1.0)
  becomewererabbit(inst)
 elseif data.food.prefab == "werecarrot" and inst.wererabbit  then
 EntityScript:DoTaskInTime(1.0)
  becomebob(inst)
 end
end)

Bobbi - Copy.zip

Link to comment
Share on other sites

Strange I thought it had to do with the eating sound not being stopped in the wererabbit stategraph but I went with killing the sound from the werecarrot. I thought it be easier but it gets the job done:

local function oneaten(inst, eater)
    if eater:HasTag("player") then --never know if something else eats it
    eater.SoundEmitter:KillSound("eating")
    end

end

local function fn(Sim)--reference on where it goes

inst.components.edible:SetOnEatenFn(oneaten)

so read the notes and hope this helps.

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