LordTS Posted March 25, 2015 Share Posted March 25, 2015 Hi, i am very new to modding, just yesterday i got the idea to make a character mod. With the help of some guides i have succeeded to make a basic character( changed only the base status and putted she on the game). The problem is, the character is supposed to be friends with the rabbits. She already have the vegetarian tag and i have removed the scaretoprey tag, but removing this tag makes any animal with the prey tag stay put without running from me. So, i want to know how to make only the rabbit to not be scared. Thank youObrigado Link to comment https://forums.kleientertainment.com/forums/topic/52336-help-with-rabbits/ Share on other sites More sharing options...
CarlZalph Posted March 25, 2015 Share Posted March 25, 2015 (edited) In scripts/brains/rabbitbrain.lua function RabbitBrain:OnStart() there is the behaviour of RunAway. You'd need to hook the brain's function to add the behaviour's shouldrunfunction. I'mma see about getting that hooked. Edit1:This is a bit more involved than I initially thought, will work on it tomorrow. Edited March 25, 2015 by CarlZalph Link to comment https://forums.kleientertainment.com/forums/topic/52336-help-with-rabbits/#findComment-624721 Share on other sites More sharing options...
Corrosive Posted March 25, 2015 Share Posted March 25, 2015 Since you presumably want the rabbits to respond to other threats while you're nearby, the only way I can imagine it working is to make a new behaviour based on RunAway. The new behaviour would have to accept a parameter to allow you to specify tags to exclude when using FindEntity. Link to comment https://forums.kleientertainment.com/forums/topic/52336-help-with-rabbits/#findComment-624740 Share on other sites More sharing options...
CarlZalph Posted March 25, 2015 Share Posted March 25, 2015 (edited) Since you presumably want the rabbits to respond to other threats while you're nearby, the only way I can imagine it working is to make a new behaviour based on RunAway. The new behaviour would have to accept a parameter to allow you to specify tags to exclude when using FindEntity.There's a function you can specify in the behaviour tree node for RunAway that is a secondary check which I'm trying to get the rabbit brain to get hooked into, but the timing on getting it to hook is being a bit pushy. Edit1:local function Rabbit_Brain_ShouldRunFn(hunter) return not hunter:HasTag("rabbitwhisperer")endlocal function PostInit_Brain_rabbitbrain(self) local theBehaviourTreeRoot = self.bt.root if(theBehaviourTreeRoot.children) then for _,v in ipairs(theBehaviourTreeRoot.children) do if(v.name=="RunAway") then -- This is where a backup of the old function should be, but I don't see how to do this. -- Problem is that the shouldrunfn doesn't contain the caller in its arguments. v.shouldrunfn = Rabbit_Brain_ShouldRunFn end end endendAddBrainPostInit("rabbitbrain", PostInit_Brain_rabbitbrain)You'll need to give your character the tag 'rabbitwhisperer' for rabbits to not be feared of you. There's a small error in that it's completely wiping out the old shouldrunfn, but that function doesn't pass the caller in its arguments so I don't know how to preserve the old shouldrunfn.Also in default code this doesn't exist for the rabbit at all, so this will only conflict with other mods. @rezecib Do you happen to have any ideas for preservation and calling of the old shouldrunfn to be used in the new shouldrunfn callback? Edited March 25, 2015 by CarlZalph Link to comment https://forums.kleientertainment.com/forums/topic/52336-help-with-rabbits/#findComment-624811 Share on other sites More sharing options...
Corrosive Posted March 25, 2015 Share Posted March 25, 2015 Is there a reason for not using AddBrainPostInit? Link to comment https://forums.kleientertainment.com/forums/topic/52336-help-with-rabbits/#findComment-624832 Share on other sites More sharing options...
CarlZalph Posted March 25, 2015 Share Posted March 25, 2015 (edited) Is there a reason for not using AddBrainPostInit?Yeah, because I'm not familiar with the modutil.lua's functions fully yet.Hoping that while I attempt to help others that I help myself to knowledge on the API. This Post Init cuts down the code a bit, and I'll be editing the post; thanks! Edited March 25, 2015 by CarlZalph Link to comment https://forums.kleientertainment.com/forums/topic/52336-help-with-rabbits/#findComment-624835 Share on other sites More sharing options...
LordTS Posted March 25, 2015 Author Share Posted March 25, 2015 Thanks for the help. And forgive my lack of knowledge, but where exactly should i put all that? Link to comment https://forums.kleientertainment.com/forums/topic/52336-help-with-rabbits/#findComment-624838 Share on other sites More sharing options...
CarlZalph Posted March 25, 2015 Share Posted March 25, 2015 Thanks for the help. And forgive my lack of knowledge, but where exactly should i put all that? modmain.lua Link to comment https://forums.kleientertainment.com/forums/topic/52336-help-with-rabbits/#findComment-624844 Share on other sites More sharing options...
LordTS Posted March 25, 2015 Author Share Posted March 25, 2015 modmain.lua Ah, thanks again. Link to comment https://forums.kleientertainment.com/forums/topic/52336-help-with-rabbits/#findComment-624846 Share on other sites More sharing options...
Corrosive Posted March 25, 2015 Share Posted March 25, 2015 (edited) @CarlZalph, @LordTS, You'd put this in modmain.lua:local function mod_rabbitbrain(inst) local player = GLOBAL.GetPlayer() for k,node in pairs(inst.bt.root.children) do if node.name and node.name == "RunAway" then node.shouldrunfn = function(hunter) return not hunter:HasTag("rabbitwhisperer") end end endendAddBrainPostInit("rabbitbrain", mod_rabbitbrain)But I stand by my first comment in that I don't think this is quite the correct approach. The problem is that the RunAway behaviour only checks for the closest entity. That means that when the player is the closest thing to the rabbit, the rabbit will ignore all other sources of danger. Edit: damn forum never notifies me of replies in time! Edited March 25, 2015 by Corrosive Link to comment https://forums.kleientertainment.com/forums/topic/52336-help-with-rabbits/#findComment-624847 Share on other sites More sharing options...
CarlZalph Posted March 25, 2015 Share Posted March 25, 2015 But I stand by my first comment in that I don't think this is quite the correct approach. The problem is that the RunAway behaviour only checks for the closest entity. That means that when the player is the closest thing to the rabbit, the rabbit will ignore all other sources of danger.Hmm, yeah. Though wouldn't having another behaviour for the rabbit make other mods that hook into the behaviour of the rabbit conflict? Link to comment https://forums.kleientertainment.com/forums/topic/52336-help-with-rabbits/#findComment-624850 Share on other sites More sharing options...
LordTS Posted March 25, 2015 Author Share Posted March 25, 2015 PrefabFiles = {"wme",} Assets = { Asset( "IMAGE", "images/saveslot_portraits/wme.tex" ), Asset( "IMAGE", "images/selectscreen_portraits/wme.tex" ), Asset( "IMAGE", "images/selectscreen_portraits/wme_silho.tex" ), Asset( "IMAGE", "bigportraits/wme.tex" ),} local function mod_rabbitbrain(inst) local player = GLOBAL.GetPlayer() for k,node in pairs(inst.bt.root.children) do if node.name and node.name == "RunAway" then node.shouldrunfn = function(hunter) return not hunter:HasTag("rabbitwhisperer") end end endend AddBrainPostInit("rabbitbrain", mod_rabbitbrain) AddModCharacter("wme") My modmain.lua is like this, but now the game chashes when i try to activate the mod :/(Also added the tag to the character) Link to comment https://forums.kleientertainment.com/forums/topic/52336-help-with-rabbits/#findComment-624855 Share on other sites More sharing options...
CarlZalph Posted March 25, 2015 Share Posted March 25, 2015 What's the stack trace from the crash? Link to comment https://forums.kleientertainment.com/forums/topic/52336-help-with-rabbits/#findComment-624857 Share on other sites More sharing options...
Corrosive Posted March 25, 2015 Share Posted March 25, 2015 @LordTS, what is the error you're getting? If none, check the log file. @CarlZalph, Conflicts are always a possibility, but if you're making a character that specifically changes how rabbits react, I think you're justified As long as those conflicting mods are written well enough, they should be able to handle a conflict gracefully, anyway. You could probably also manage to just extend the functionality of the RunAway behaviour, though that'd take a bit more work. Link to comment https://forums.kleientertainment.com/forums/topic/52336-help-with-rabbits/#findComment-624860 Share on other sites More sharing options...
LordTS Posted March 25, 2015 Author Share Posted March 25, 2015 On the screen "Mods installed!" The game freeze and then stop working. Where can i find the log file? Link to comment https://forums.kleientertainment.com/forums/topic/52336-help-with-rabbits/#findComment-624864 Share on other sites More sharing options...
CarlZalph Posted March 25, 2015 Share Posted March 25, 2015 (edited) For Windows it'd be in <your Documents folder>/Klei/DoNotStarve/log.txt See post here for log.txt for more information. Edited March 25, 2015 by CarlZalph Link to comment https://forums.kleientertainment.com/forums/topic/52336-help-with-rabbits/#findComment-624865 Share on other sites More sharing options...
LordTS Posted March 25, 2015 Author Share Posted March 25, 2015 Made it work, seems i just made a writing mistake. Tested and only the rabbit is confortable with me. Thanks, and sorry for time you wasted with me. ^^ Link to comment https://forums.kleientertainment.com/forums/topic/52336-help-with-rabbits/#findComment-624868 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