Eir Posted January 29, 2015 Share Posted January 29, 2015 How exactly do you make animals (hounds, in particular) talk? I have studied the Satori mod, but I was confused. I don't want to change their functions; I just want certain animals to say something when they do a specific action (i.e. chase and attack). Link to comment Share on other sites More sharing options...
Eir Posted February 1, 2015 Author Share Posted February 1, 2015 bump Link to comment Share on other sites More sharing options...
Blueberrys Posted February 2, 2015 Share Posted February 2, 2015 @Eir You will need to add the talker component to the prefab, and some ChattyNode behaviours to the brain of the prefab.You can use the AddPrefabPostInit to modify the prefablocal function prefab_postinit(inst) -- Modify prefab inst:AddComponent("talker")endAddPrefabPostInit("prefab_name", prefab_postinit)And AddBrainPostInit to modify the prefab's brain.local function prefab_brain_postinit(inst) -- Modify brainendAddBrainPostInit("prefab_brain_name", prefab_brain_postinit)See this mod for prefab and brain modification examples. Locations of relevant lua files.Pigman prefab - (..\scripts\prefabs\pigman.lua)Pig brain - (..\scripts\brains\pigbrain.lua)Talker component - (..\scripts\components\talker.lua)ChattyNode behaviour - (..\scripts\behaviours\chattynode.lua) Link to comment Share on other sites More sharing options...
Eir Posted February 2, 2015 Author Share Posted February 2, 2015 @Eir You will need to add the talker component to the prefab, and some ChattyNode behaviours to the brain of the prefab.You can use the AddPrefabPostInit to modify the prefablocal function prefab_postinit(inst) -- Modify prefab inst:AddComponent("talker")endAddPrefabPostInit("prefab_name", prefab_postinit)And AddBrainPostInit to modify the prefab's brain.local function prefab_brain_postinit(inst) -- Modify brainendAddBrainPostInit("prefab_brain_name", prefab_brain_postinit)See this mod for prefab and brain modification examples. Locations of relevant lua files.Pigman prefab - (..\scripts\prefabs\pigman.lua)Pig brain - (..\scripts\brains\pigbrain.lua)Talker component - (..\scripts\components\talker.lua)ChattyNode behaviour - (..\scripts\behaviours\chattynode.lua) Thanks for helping me! Just one more thing: I can't figure out where to put the quotes I want them to say. In the local function prefab_brain_postinit(inst)? Link to comment Share on other sites More sharing options...
Blueberrys Posted February 2, 2015 Share Posted February 2, 2015 @Eir, err. That isn't the full code, just to be clear. It's an example on how you can get started on making the whole thing.See the function PigBrain:OnStart() in pigbrain.lua, it has these things called "ChattyNode". Notice that they are getting their second parameter from the global STRINGS variable.Ex,ChattyNode(self.inst, STRINGS.PIG_TALK_FIND_MEAT, ...You'll need to define your own ChattyNodes and inject them into the brain of the prefab you want. See the brainpostinit portion of the api examples mod (in modmain.lua) I linked for an example on how to do something like this.Then, when you have your ChattyNodes set up to inject in the brain, set their second parameter to something like,STRINGS.YOURPREFAB_TALK_ATTACKAnd define that near the top of your modmain.lua as so,STRINGS.YOURPREFAB_TALK_ATTACK = {"I'm gonna attack!", "Charge!", "Die foul beast!"}If set up correctly, your prefab will randomly use one of these strings when performing the corresponding action. Link to comment Share on other sites More sharing options...
Recommended Posts
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.