Ray025 Posted February 1, 2018 Share Posted February 1, 2018 Can anyone help me coding a perk of my character? I want to make it so, that as long as I have carrot in my inventory, rabbits don't run away from my char. I appreciate your help. Thanks Link to comment Share on other sites More sharing options...
secXsQuared Posted February 2, 2018 Share Posted February 2, 2018 You will need to overwrite/duplicate (ewww) the rabbit brain file (rabbitbrain.lua): function RabbitBrain:OnStart() ...... RunAway(self.inst, "scarytoprey", AVOID_PLAYER_DIST, AVOID_PLAYER_STOP), RunAway(self.inst, "scarytoprey", SEE_PLAYER_DIST, STOP_RUN_DIST, nil, true), ...... end and I believe you will need to overwrite/duplicate "runaway.lua" (ewww) or add a custom action that checks the character type. Link to comment Share on other sites More sharing options...
Ray025 Posted February 7, 2018 Author Share Posted February 7, 2018 On 2/2/2018 at 5:51 PM, secXsQuared said: You will need to overwrite/duplicate (ewww) the rabbit brain file (rabbitbrain.lua): function RabbitBrain:OnStart() ...... RunAway(self.inst, "scarytoprey", AVOID_PLAYER_DIST, AVOID_PLAYER_STOP), RunAway(self.inst, "scarytoprey", SEE_PLAYER_DIST, STOP_RUN_DIST, nil, true), ...... end and I believe you will need to overwrite/duplicate "runaway.lua" (ewww) or add a custom action that checks the character type. that sounds really complicated. I'm afraid I can't do it by myself. I'm just an artist and don't really understand coding correctly Link to comment Share on other sites More sharing options...
secXsQuared Posted February 8, 2018 Share Posted February 8, 2018 8 hours ago, Ray025 said: that sounds really complicated. I'm afraid I can't do it by myself. I'm just an artist and don't really understand coding correctly Unfortunately, I don't have much time to help. I doubt most people here have time/are willing to write actual code for you. I do recommend that you look into it yourself. It's a mostly(?) enjoyable learning process until the game's APIs start to bite you. Plus, understanding the code helps you debug and update your mod in the future too. Link to comment Share on other sites More sharing options...
. . . Posted February 8, 2018 Share Posted February 8, 2018 this may be able do similar to what you want, put it inside YOURCHAR.lua in the master_postinit Spoiler local x, y, z = inst.Transform:GetWorldPosition() local rabbit = TheSim:FindEntities(x, y, z, 6, { "rabbit"}) inst:DoPeriodicTask(1, function() if rabbit and inst.components.inventory:Has("carrot", 1) then inst:RemoveTag("scarytoprey") else inst:AddTag("scarytoprey") end end) Link to comment Share on other sites More sharing options...
secXsQuared Posted February 8, 2018 Share Posted February 8, 2018 (edited) 34 minutes ago, SuperDavid said: this may be able do similar to what you want, put it inside YOURCHAR.lua in the master_postinit Hide contents local x, y, z = inst.Transform:GetWorldPosition() local rabbit = TheSim:FindEntities(x, y, z, 6, { "rabbit"}) inst:DoPeriodicTask(1, function() if rabbit and inst.components.inventory:Has("carrot", 1) then inst:RemoveTag("scarytoprey") else inst:AddTag("scarytoprey") end end) 1 Wouldn't that also make the rabbit not run away when other characters are around? Maybe change the period to 0.1 to make it smoother. Nice workaround though. EDIT: oops my bad. I thought you removed the tag from rabbits. But then you won't scare others away? as in you have both a rabbit and a koalaphant within radius 6. Edited February 8, 2018 by secXsQuared Link to comment Share on other sites More sharing options...
. . . Posted February 8, 2018 Share Posted February 8, 2018 (edited) 54 minutes ago, secXsQuared said: Wouldn't that also make the rabbit not run away when other characters are around? The rabbit will still run away from something which is scarytoprey even if you're standing close to it. 54 minutes ago, secXsQuared said: Maybe change the period to 0.1 to make it smoother. Well shorter periods may cause lag on weaker computers most likely, but if the op has a good pc then yes he could it to something faster than 1 second! 54 minutes ago, secXsQuared said: But then you won't scare others away? as in you have both a rabbit and a koalaphant within radius 6. Unfortunately, I do not know of any better ways to do this... & unless anyone else wants to make a code for rabbits to specifically not run away from a player with carrot in inventory (which will probably require editing rabbitbrain which brains are pretty complicated code) for the op then my help is closest to what he wants to achieve . Edited February 8, 2018 by SuperDavid Link to comment Share on other sites More sharing options...
Ray025 Posted February 9, 2018 Author Share Posted February 9, 2018 On 2/8/2018 at 8:48 AM, SuperDavid said: this may be able do similar to what you want, put it inside YOURCHAR.lua in the master_postinit Hide contents local x, y, z = inst.Transform:GetWorldPosition() local rabbit = TheSim:FindEntities(x, y, z, 6, { "rabbit"}) inst:DoPeriodicTask(1, function() if rabbit and inst.components.inventory:Has("carrot", 1) then inst:RemoveTag("scarytoprey") else inst:AddTag("scarytoprey") end end) I've added it to my character's master_posit but it doesn't seem to do the trick Link to comment Share on other sites More sharing options...
. . . Posted February 9, 2018 Share Posted February 9, 2018 23 minutes ago, Ray025 said: I've added it to my character's master_posit but it doesn't seem to do the trick I just tested it out and it works, are you sure you put it in YOURCHAR.lua inside master_postinit? Link to comment Share on other sites More sharing options...
Ray025 Posted February 9, 2018 Author Share Posted February 9, 2018 1 minute ago, SuperDavid said: I just tested it out and it works, are you sure you put it in YOURCHAR.lua inside master_postinit? sorry my bad it works perfectly fine. I put it in to a wrong character, no wonder it didn't do anything. Thanks you so much! Link to comment 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