Eranthis Posted March 11, 2018 Share Posted March 11, 2018 This is something I've noticed for the character WX78 and his perk of eating gears. The default food crunch audio from his eating animation is silenced and replaced with the wx78/levelup sound, which had me wondering how one would implement a way to replace the audio for animations for actions like eating, healing, or building. Here's the code from wx78 as an example: local function oneat(inst, food) if food and food.components.edible and food.components.edible.foodtype == FOODTYPE.GEARS then inst.level = inst.level + 1 applyupgrades(inst) inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") end end Does anyone know how to utilize this to apply to other items? AND since this is part of wx78's prefab file, it most likely only applies to his character whereas I'm more curious how this can be applicable to mod items for anyone to use. Link to comment https://forums.kleientertainment.com/forums/topic/88588-new-sound-for-animations/ Share on other sites More sharing options...
K1NGT1GER609 Posted March 15, 2018 Share Posted March 15, 2018 (edited) There's a lot of options on overriding certain sounds through ListenForEvent and SetOn*something*Fn(function), as their the most common in the prefab files of the game. Problem is getting the events for listenforevent isn't simple, as I can't find all possible event names so its a bit of a search to say the least. Plus you'll need the soundemitter code+search path(s) and sound files for custom sounds (if you plan on using non dontstarve game sounds). If anything I'll give a couple of examples to say the least: local function oneaten(inst, eater) eater.SoundEmitter:PlaySound("dontstarve/wilson/eat", "eating") end local function fnab() inst.entity:AddSoundEmitter() inst:AddComponent("edible") inst.components.edible:SetOnEatenFn(oneaten) ---------------------------------------------------- local function OnBuilt(inst) inst.SoundEmitter:PlaySound("dontstarve/common/tent_craft") end local function fnab() inst.entity:AddSoundEmitter() inst:ListenForEvent("onbuilt", onbuiltfn) Edited March 15, 2018 by K1NGT1GER609 Link to comment https://forums.kleientertainment.com/forums/topic/88588-new-sound-for-animations/#findComment-1015660 Share on other sites More sharing options...
IronHunter Posted March 16, 2018 Share Posted March 16, 2018 (edited) The real problem, is the eating sounds are played in the wilson stategraphs and are specifically not played when the edible item is foodtype.gears, modifying stategraphs is pretty annoying as to properly modify them requires making them twice one for quick eat and one for eating meat and twice more for clients. I have experimented with killing the sound loop for "eating" with minimal success. I believe the sound loop could be killed, but I always manage to cut it off after a fraction of a second of it playing. Obviously you don't want to make them foodtype.gears to prevent wx78 from acting wierd if he consumes them. I am curious what sound you plan coach to say. But there is nothing stopping you from playing custom sounds atm, if you don't mind hearing the default ones or working on cloning custom eat and quick eat stategraphs for your character. Edited March 16, 2018 by IronHunter Added a signature Link to comment https://forums.kleientertainment.com/forums/topic/88588-new-sound-for-animations/#findComment-1015698 Share on other sites More sharing options...
Eranthis Posted March 18, 2018 Author Share Posted March 18, 2018 Well if anyone finds a flawless way to replace audio, let me know. I have the sounds ready to go but I just need the proper coding. Link to comment https://forums.kleientertainment.com/forums/topic/88588-new-sound-for-animations/#findComment-1016602 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now