Jump to content

Follower won't stay put


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?

Link to comment
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.

Link to comment
Share on other sites

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.

×
  • Create New...