Jump to content

Teenbird "warcry"


Recommended Posts

Back here again with another weird idea that I need help doing.


I was wondering if there's a way to remove Teenbirds' "warcry" animation right before their first attack. It gets pretty annoying having to wait like 3 extra seconds each time I wanna send it to kill a bird or rabbit, while in a real fight it actually attacks relentlessly and much more efficiently, simply because it doesn't have to stop and start again.


I tried looking in smallbird.lua and smallbirdbrain.lua but I really don't understand enough to even figure out if it's there or not.


Any ideas?

Link to comment
Share on other sites

@Ran You could remove the taunt state from the stategraph (or modify it).

local function SGsmallbird_PostInit(sg)	sg.states["taunt"] = nil		-- or change it	-- sg.states["taunt"].timeline = {	-- ...	-- }endAddStategraphPostInit("smallbird", SGsmallbird_PostInit)

Untested code.

Link to comment
Share on other sites

Didn't even know there was a taunt state. Well now with the words "taunt" and "stategraph" I managed to find the SGsmallbird.lua. This is what you're talking about?

State{        name = "taunt",        tags = {"busy", "canrotate"},                onenter = function(inst)            inst.Physics:Stop()            inst.AnimState:PlayAnimation("call")            if inst.components.combat and inst.components.combat.target then                inst:FacePoint(Vector3(inst.components.combat.target.Transform:GetWorldPosition()))            end        end,                timeline=        {            TimeEvent(10*FRAMES, function(inst) inst.SoundEmitter:PlaySound("dontstarve/creatures/smallbird/chirp_short") end),            TimeEvent(17*FRAMES, function(inst) inst.SoundEmitter:PlaySound("dontstarve/creatures/smallbird/chirp_short") end),            TimeEvent(28*FRAMES, function(inst) inst.SoundEmitter:PlaySound("dontstarve/creatures/smallbird/chirp_short") end),        },                events=        {            EventHandler("animover", function(inst) inst.sg:GoToState("idle") end),        },    },

So I suppose that code basically nullifies all that or something?


Edit: I mean, more or less I get it. The first part would make that whole state null or somehting it seems, the other is where I could set my own timeline, right? Not sure if I wanna be touching that. I mean, I could change the frames but dunno how that'd affect the animation and sound, maybe it'd get all messed up.

Link to comment
Share on other sites

Welp, no dice so far. Setting the state to nil did nothing noticeable, while changing the amount of frames in the timeline causes a crash when I try to activate the mod. It doesn't even give me an error, it goes back to the main screen and then freezes there.

Link to comment
Share on other sites

Well, I tried putting the timeline just as it normally is and it still freezes all the same, so I guess the problem is not about changing the amount of frames. it's weird cause it freezes but it doesn't actually crash, I gotta close the process but it never says "not responding".
Just a heads up, this same mod has other stuff. I basically put all my follower changes on the same mod (called "Ran's Followers"), so I just added this to what I already had (which works perfectly otherwise), dunno if that shows in the log or what. For reference, the mod changes Chester's and Glommer's health and regen, Smallbirds and Teenbirds health (and adds regen to Teenbirds), hatch and grow times, and starve times.
Oh and tweaked a bunch of follow distances but that's not on the modmain.lua.


I suppose I just attach the log file...


Link to comment
Share on other sites


scripts/mods.lua(17,1) error calling StategraphPostInit: smallbird in mod Ran's Followers: ...dont_starve/data/../mods/Ran's Followers/modmain.lua:28: attempt to perform arithmetic on global 'FRAMES' (a nil value)

Add this to the top of your modmain:




Edit: I tested the code I posted, using the nil. It seems to be working for me, the smallbird doesn't chirp before going to attack. Wasn't that the intended result?


Edit 2: Since you're only changing the time, I think this might be a better approach.

local function SGsmallbird_PostInit(sg)    --sg.states["taunt"] = nil        for _, event in pairs(sg.states["taunt"].timeline) do        -- Halfs the time of all chirps        event.time = event.time/2    endend AddStategraphPostInit("smallbird", SGsmallbird_PostInit)
Link to comment
Share on other sites

Now I'm getting:

scripts/mods.lua(17,1) error calling StategraphPostInit: smallbird in mod Ran's Followers:...dont_starve/data/../mods/Ran's Followers/modmain.lua:30: attempt to call global 'TimeEvent' (a nil value)

Should I add a

TimeEvent = GLOBAL.TimeEvent

? Just guessing.


Edit: Well I went ahead and tried, and it does indeed not crash anymore. I only tested with the default values though so right now it does nothing. I'm gonna try actually changing the frames now. Wish me luck.


Link to comment
Share on other sites

@Ran Oh, hmm.

Teenbirds seem to be using the tallbird stategraph. (in smallbird.lua)


Try this. 

local function remove_sg_taunt(inst)    inst.sg.states["taunt"] = nilendAddPrefabPostInit("teenbird", remove_sg_taunt)

Add this for smallbirds:

AddPrefabPostInit("smallbird", remove_sg_taunt)
Link to comment
Share on other sites

Oh, damn, so it was the wrong file all along? Figures, lol. I'll try that.


Now I wonder, if I alter the taunt state in the SGtallbird.lua, would that change the normal non-follower Tallbird one too, or is it separate states?


Edit: Oh wait, at the end I gotta add that state myself anyway, so if I add it only to "teenbird" it shouldn't affect tallbirds, right? Soomething like:

local function SGtallbird_PostInit(sg)        sg.states["taunt"].timeline =        {        -- modified timeline here        }end AddStategraphPostInit("teenbird", SGtallbird_PostInit)
Link to comment
Share on other sites

Well this is weird. I tried that last code to remove the taunt, and it seems to be fine with Teenbirds ("seems" because my Teenbirds just suicided to a herd of Beefalo ¬¬ so I'm in the process of getting new ones), but when I add the line for Smallbirds it crashes when I load the save:


scripts/mods.lua(17,1) error calling PrefabPostInit: smallbird in mod Ran's Followers:
...dont_starve/data/../mods/Ran's Followers/modmain.lua:27: attempt to index field 'states' (a nil value)


It's even weirder considering it complains about states being a nil value, but somehow it has no problem using it for the Teenbird part. Or maybe it's because there's no Teenbirds around, so it just doesn't give the error yet...


Edit: Yep, there we go, crashed out of the game with the same error when the Smallbird grew into a Teenbird, lol. So I'm with that problem right now. I tried the GLOBAL thing but it didn't work this time, lol.

Link to comment
Share on other sites


IIRC the path to the stategraph states from the prefab instance is inst.sg.sg.states, no?


I don't think so.


function EntityScript:SetStateGraph(name)	if self.sg then		SGManager:RemoveInstance(self.sg)	end    local sg = LoadStateGraph(name)    assert(sg)    if sg then        self.sg = StateGraphInstance(sg, self)        SGManager:AddInstance(self.sg)        self.sg:GoToState(self.sg.sg.defaultstate)        return self.sg    endend 

and that function is called as:


So the "self" variable in the function refers to the prefab instance.


Edit: I just read over what I copied.. It's using "self.sg.sg" so, you're probably right, haha.


Link to comment
Share on other sites

Well, I managed to have both a Smallbird and Teenbird at the same time for testing, and unfortunately changing the timeline frames of the taunt seems to affect exactly what it says: the chirping sound for the Smallbird, and the ground scratching sound for the Teenbird. Only the sounds, not the animations.


Now I'm gonna try just removing them with the first method ( sg.states["taunt"] = nil ) which supposedly worked for the Smallbird, but I haven't tried it for the Teenbird yet.

Link to comment
Share on other sites

@Ran As Corrosive pointed out, try changing

inst.sg.states["taunt"] = nil


inst.sg.sg.states["taunt"] = nil

in the code I posted (using PrefabPostInit, not StategraphPostInit)



Also, the code you posted with "AddStategraphPostInit("teenbird", SGtallbird_PostInit)" will not work at all. There is no stategraph called "teenbird", they just use the same stategraph as the tallbirds. And yes, changing that (tallbird stategraph) will affect the tallbirds too.

Link to comment
Share on other sites

Hmm, I thought those Add("X", Y) meant stuff like "add or modify whatever function Y says to object X", to put it in non-coding language, lol. At least it seemed to work like that with other stuff.

Link to comment
Share on other sites

@Ran Actually, that's about right. The problem with your code was just that there is no such thing as "teenbird stategraph". You can't modify something that isn't there, haha. The code I posted attempts to modify the stategraph used in teenbirds, which is actually just an instance (somewhat like a copy) of the tallbird stategraph. Modifying the tallbird stategraph itself would mean that teenbirds and tallbirds will be affected because they both use it. I'm assuming that's not something you want.

Link to comment
Share on other sites

Hm, I figured what that was doing was modifying the tallbird stategraph, and then applying it to teenbirds. But I guess the "SGtallbird_PostInit" is just the function name, right? I was hoping that part was what told it to use the Tallbird one.


It's been a bit "eventful" lately (giant shenanigans and whatnot, lol) but I'll tell you how it goes as soon I can test that last one.


Edit: Yep, there we go, works wonders. Bit of a shame it ended up being an all-or-nothing thing, couldn't modify the times, but I guess that's what I asked for to begin with. I just kinda get carried away with these mod things and end up trying to figure out stuff I didn't even intend to, lol.

Link to comment
Share on other sites

People seem to get confused by this, so I guess I'll post an explanation of exactly what's going on here (in the second page of an unrelated topic, almost ensuring that nobody ever reads it, hah)


Moved it to a new topic, but please have a read anyway ;)

Link to comment
Share on other sites


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