Finaltwist

Member
Greets!

in my OnThink, i have an instance where i want the mobile to follow a target, and another instance where i want them to flee.
Does anyone know of a method i can call on, or a way to achieve this?

I looked at BaseAI which has a few methods i could use (DoMove, DoActionFlee, etc) but i'm having difficulty in properly calling those from OnThink in a Mobile Class.

Any help always appreciated!
 
Look at AnimalAI.cs, right at the top. You'll see the options you're looking for -- you basically set their action equal to what you want them to do (Action = ActionType.Flee or Action = ActionType.Combat in your case)

To call them, place the code within the action(s) you want the check to occur.

Using AnimalAI as an example, you'll see sections for "public override bool DoActionWander()" and "public override bool DoActionCombat()"
Adding your checks in those sections will make the mobile check for your desired conditions either while it's wandering, or during combat, or wherever you place the checks. You'll need a check in each action section where you'd want it to evaluate your follow/flee situation.

You can copy an existing AI and give it a new name if you want to keep it separate from existing NPC behavior. Just call the new AI type from the NPCs that you want to have your special behavior.
 
so the only way to get them to follow/flee is to create a new AI? It's not possible to do from a mobile class? i was thinking of setting the target as focusmob, and giving them follow/flee commands. ill test that - id rather not have to create a new AI if i don't have to honestly.
Post automatically merged:

or is it possible to set actiontype from OnThink?
Post automatically merged:

I found a way to do this from onthink:

1. set controlled true
2. set controlorder to whatever you want
3. set controltarget to the mobile you want it done to

:D
 
Last edited:
Test it well -- some other tests for whether people can attack a mob have checks for iscontrolled. It might get treated as if it's another player's pet!
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back