Jump to content

Recommended Posts

I'm making a Gobbler follower mod and can't get him to stop running away from me. I made a custom brain and here's the whole function

function PerdBrain:OnStart()    local clock = GetClock()        local root = PriorityNode(    {        WhileNode( function() return self.inst.components.health.takingfiredamage end, "OnFire", Panic(self.inst)),        WhileNode(function() return clock and not clock:IsDay() end, "IsNight",            DoAction(self.inst, GoHomeAction, "Go Home", true )),        DoAction(self.inst, EatFoodAction, "Eat Food"),        RunAway(self.inst, "scarytoprey", SEE_PLAYER_DIST, STOP_RUN_DIST, function(target) return ShouldRunAway(self.inst, target) end ),        ChattyNode(self.inst, STRINGS.PERD,            FaceEntity(self.inst, GetTraderFn, KeepTraderFn)),	ChattyNode(self.inst, STRINGS.PERD,	Follow(self.inst, GetLeader, MIN_FOLLOW_DIST, TARGET_FOLLOW_DIST, MAX_FOLLOW_DIST)),	IfNode(function() return GetLeader(self.inst) end, "has leader",	ChattyNode(self.inst, STRINGS.PERD,	FaceEntity(self.inst, GetFaceTargetFn, KeepFaceTargetFn ))),        DoAction(self.inst, PickBerriesAction, "Pick Berries", true),        Wander(self.inst, HomePos, MAX_WANDER_DIST),    }, .25)    local follower = WhileNode( function(inst) return inst.components.follower end, "IsFollower",        PriorityNode{        RunAway(self.inst, function(guy) return guy:HasTag("scarytoprey") and not guy:HasTag("player") end,             SEE_PLAYER_DIST, STOP_RUN_DIST, function(target) return ShouldRunAway(self.inst, target) end ),        	},1)        self.bt = BT(self.inst, root)end

The section at fault is local follower, what I was trying to do is clarify that once the perd becomes a follower, the RunAway node is overidden, but I can't get the new node to work since I never messed with brains until now and I'm quite stale at programming in general. Help me please.

 

Also, what does "self.bt = BT(self.inst, root)" do?

Edited by Cyde042
Link to comment
https://forums.kleientertainment.com/forums/topic/54350-follower-wont-stay-put/
Share on other sites

I'm making a Gobbler follower mod and can't get him to stop running away from me. I made a custom brain and here's the whole function

 

-snip snap-

 

The section at fault is local follower, what I was trying to do is clarify that once the perd becomes a follower, the RunAway node is overidden, but I can't get the new node to work since I never messed with brains until now and I'm quite stale at programming in general. Help me please.

 

Also, what does "self.bt = BT(self.inst, root)" do?

 

It appears there's another "RunAway" in there. The behaviour tree (BT) runs from the top of a priority node (the root) to the bottom, so unless you put the "while I'm a follower" branch above the remaining "RunAway", the gobbler will continue to run away.

 

Maybe you can take a look at the pig brain? It's rather advanced, but well-structured.

Edited by Mobbstar

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...