Author
Topic: [NPCs] NPC "Pack" Behaviors: Solved (Read 302 times)

Has anyone found a way to make a group of NPCs attack the player if only one is targeted? I'm trying to make a mob of hobos attack the player when one of them is attacked. The behavior tree is very limited right now and I can't find a way to make this happen.Thanks in advance.

Edit: After watching a video of Craig's, I have found the solution and I will post for anyone else who is wondering the same thing.When creating the behavior, you will see a "Message" behavior. My initial thought was that this is just a notification, but that is not the case. After a conditional statement, you can choose to have a "Message" sent or received. If the message is sent as well as received, the receiver will carry through the behavior that the sender of the message also carries out.In other words, I have setup a behavior where, when a hobo is targeted, he "Sends" a message 20 blocks out to other hobos. Since my conditional statement is "IsTargeted," the receiver of the message will act as if he has received the same conditional statement (he is now targeted by the attacker). I have my other two hobos wandering, yet receiving any incoming messages from other hobos that have the type "IsTargeted." Now when I attack any of the three hobos (they are all the same NPC with the same behavior tree), the other two will come to the rescue and all three attack the player.When creating the behavior, make sure your "CompareTarget" is set to target. If it is set to "Self," then the NPC will attack the prey (the other hobo in this case). If it is set to "Target," the NPC will attack the predator (in this case, the player).If I can figure out how to do it, I will screenshot and crop my behavior tree if someone tells me how to do so. Otherwise, it is a very simple behavior tree with only 8 nodes.

I do not believe that is possible. It might be worth looking into C# modding or asking somebody else to do that for you. Alternatively you could request ut be an addition in game by posting in the Ideas section.GLCrab.