pickleplayer Posted July 26, 2015 Share Posted July 26, 2015 Hi! I've been working hard on my first mod, and have been pretty excited with what I've accomplished so far! But I'm into the scripting now, and I'm having a bit of trouble. I've been looking into the game files and codes for many hours, but I haven't found a solution, so I thought I'd ask here! currently, I'm trying to create an item that functions similarly to the panflute. But instead of putting creatures to sleep, I want it to make them run away instead. the panflute works by creating an area effect with "add sleepiness" to any Sleepers. (er, at least thats what it looks like from the code) I looked into the LocoMotor component, but it looks like there isnt any sort of simple "add runaway" function like there is for the Sleeper component. I know there is a "runaway" behaviorAnd I know there are creatures with "runaway" scripts in their "brains" (rabbits and pigs).[require "behaviours/runaway"]^ But not all of the creatures have this line of code in their "brain". Does that mean there isn't going to be an easy way to get these creatures to execute that behavior? What should I be looking into to find where to start? I don't even need specific answers, just some advice on what folders or areas of the code I should be looking into.Any advice will help! c: Also, should I be posting screenshots too? I'll bective here for a while to reply quickly, and I'll give any info or screenshots you might need. In case this helps, heres a referece to the panflute's code that causes the "add sleepiness" effect:local function HearPanFlute(inst, musician, instrument) if inst.components.sleeper then inst.components.sleeper:AddSleepiness(10, TUNING.PANFLUTE_SLEEPTIME) endend Link to comment Share on other sites More sharing options...
Mobbstar Posted July 26, 2015 Share Posted July 26, 2015 I don't know any universal way to allow that. But I do know that you can prevent a creature from deciding a new action by disabling the brain like so: inst:StopBrain() inst:RestartBrain() However, if you experiment a bit, you'll find that the creature still tries to execute the last decision. I wrote some code to counter that "memory", but it's still not 100% working: if ent.components.locomotor and not ent:HasTag("player") then if ent.components.locomotor.bufferedaction then ent.components.locomotor.bufferedaction:Fail() end ent.components.locomotor:Stop()end Maybe you can create a new bufferedaction, but I haven't looked into that. In fact, I only just came to think about it. Link to comment Share on other sites More sharing options...
pickleplayer Posted July 26, 2015 Author Share Posted July 26, 2015 I don't know any universal way to allow that. But I do know that you can prevent a creature from deciding a new action by disabling the brain like so: inst:StopBrain() inst:RestartBrain() However, if you experiment a bit, you'll find that the creature still tries to execute the last decision. I wrote some code to counter that "memory", but it's still not 100% working: if ent.components.locomotor and not ent:HasTag("player") then if ent.components.locomotor.bufferedaction then ent.components.locomotor.bufferedaction:Fail() end ent.components.locomotor:Stop()end Maybe you can create a new bufferedaction, but I haven't looked into that. In fact, I only just came to think about it. Ah, so then it's last decision would have been to stop before restarting the brain? Okay I think I see what you're saying. Hm, There is code for creatures to get the players position, right? To find the direction the player is in? Would it perhaps be possible to just have creatures just find the opposite direction and walk forward for a few seconds? Or to have them suddenly head toward a point a certain distance away without stopping for anything else? And thanks for the advice so far! Link to comment Share on other sites More sharing options...
pickleplayer Posted July 26, 2015 Author Share Posted July 26, 2015 Oh, I just realized I could maybe use the "GiveUp" command from the Combat component. But would that mean monsters would just instantly re-target the player again if its in range? Link to comment Share on other sites More sharing options...
pickleplayer Posted July 29, 2015 Author Share Posted July 29, 2015 aha! I have found out how to insert behaviors into brains, and now I can make anything run away! Everything is all good now 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.