#(Gargalon) NPC AI

18 messages · Page 1 of 1 (latest)

arctic hornet
#

I wanted to create a goal/behavior where a mob follows another mob but targets an enemy player if its within 10 blocks of its following target

Right now I have a follow behavior and a target behavior, the problem is that once it targets an enemy, the behavior status is RUNNING and its following behavior is never checked/ran, so it continues to target the player and ignores its 10 block follow behavior

I know this is probably easily doable in one behavior but Im wondering what is the best way to do it in two.

shy condorBOT
#

(Gargalon) NPC AI

shy condorBOT
#

Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.

royal nest
#

you could have a condition behavior wrapping them

#

there's so many ways to do this it's hard to say one

#

@arctic hornet

arctic hornet
# royal nest you could have a condition behavior wrapping them

like this?

GoalController goalController = npc.getDefaultGoalController();
goalController.addGoal(new IfElse(
        () -> target.getLocation().distanceSquared(npc.getStoredLocation()) < 10 * 10,
        new NPCTargetGoal(...),
        new NPCFollowGoal(...)
), 1);```
ive tried this before and it doesnt seem to work, since the condition is only checked once
royal nest
#

@arctic hornet you could have a StatusMapper there if you want to change the result sometimes

#

there's a lot of ways to do this

arctic hornet
#

i think just making a separate goal combining the two is the easiest, if you have a simpler solution im all ears

royal nest
arctic hornet
#

oh yea i see

royal nest
#

or you could have parallel behaviors

#

you know, there's a lot of ways to do this

gaunt scrollBOT
#
Thread Closing Reminder

Has your issue been resolved, or your question been answered?
If so, please use the </resolved:1028673926114594866> command to close your thread.
Or </invalid:1028673926898909185> if it's not possible to resolve.

If not yet resolved, please reply below to tell us what you still need.

(Note that if there is no reply for a few days, this thread will eventually close itself.)

#

@arctic hornet