Jump to content

[In dev] Creatures fleeing to get assistance


Recommended Posts

Hello,

I have been writing this patch for some days now, but I face a problem I can't debug.

How is it supposed to work:

  • * Most humanoid creature will flee to get assistance if any around
    * Assisting mobs come attack you after 1.5 seconds
    * Caller stay near point he asked for help for 2 seconds zoning confused
    * Caller must return to combat walking
    * Any assistant can do the same 1 time and carry back more mobs.

What works:

  • * Creatures flee properly at <15% health and go to nearest same mobs
    * Assistants are coming back to attack you after 1.5 seconds
    * Any assistant can also flee for more assistance when < 15% health

What works not offlike:

  • * Assistance asker returns to attack (with a hack) running right after calling assistance (should be 2 seconds in Confused mode and return to combat walking).

What does not work:

  • * Not called code written: another move generator for the caller that does nothing for the moment except waiting some time before the caller return to combat, but it never return to combat if used (also I use same return hack). Caller just go back to spawnpoint walking.

MotionMaster is bugged it seams. The more you add Move Generators one after the others, the less Finalize calls for new Movement Generators work.

Here the patch I stop until someone can find the problem, I lost enough time on it myself without success.

Edit: Removed since a working patch is now done

To select the mobs able to flee to get assistance, I did add flag 256 to flags_extra in creature_template, so you can test this patch by running this query that set this for all humanoids mobs.

UPDATE creature_template SET flags_extra=flags_extra | 256 WHERE type=7;

About the problems:

Instead of the hack

    Unit *victim = unit.getVictim();
   unit.AttackStop(true);
   unit.Attack(victim, true);

This SHOULD work:

    unit.GetMotionMaster()->MoveChase(unit.getVictim());

Even

((Creature*)&unit)->AI()->AttackStart(victim);

does not work, I need to use:

unit.Attack(victim, true);

I am ready to finish this patch once someone finds the bug. Instead of the Distract MovementGenerator specialization, I plan to a specialize a timed Confuse one for an exactly offlike result.

Edit: please see http://getmangos.eu/community/showpost.php?p=64864&postcount=17 problems solved

Good luck.

Link to comment
Share on other sites

  • 39 years later...
so you do a new patch? so i can stop to develop on this?

What did you add to it except the visitor code moved ?

Btw you can stop yes, I finally guessed how to make it 100% core by coding the Finalize methods of Movement generators. You are welcome to help find what makes them to behave strange when one calls another one.

Link to comment
Share on other sites

What did you add to it except the visitor code moved ?

Btw you can stop yes, I finally guessed how to make it 100% core by coding the Finalize methods of Movement generators. You are welcome to help find what makes them to behave strange when one calls another one.

ok, because i did only a basic backport (what have i changed in the visitor code?^^).

but yeah, i can try to help you, when you explain me how it work's (i've no idea about the grid-system^^)

Link to comment
Share on other sites

Here, the part that need grid access (near mob lookup) is done, then so all resides in Motion Master.

The Creature:: DoFleeToGetAssistance() method is called when appropriate (Flag set and mob health < configured health level)

Then this method use a grid searcher to find the nearest assistant if any. If one is found I stack a AssistanceMovementGenerator motion else I stack a Feared motion.

If you take a look at AssistanceMovementGenerator, you will see it's just a child of PointMovementGenerator class with Finalize method overwritten.

In this Finalize method (when creature reach the target point), I call Creature::CallAssistance and I try to stack another Movement Generator to make the next step (do nothing for 1.5 seconds). It's here I currently had to call Unit::AttackStop() and Unit::Attack() because any Motion Master added here trying to make creature move does not work.

Link to comment
Share on other sites

and creature grouping would be nice (one waypoint movement assigned to whole group of NPCs)

One by one, be patient :P

I have it in my list. I already saw we need to alter a lot waypoint generator to make it assign a waypoint move gen to each follower because the leader cannot be followed easily. A creature with waypoint has no real coords until it reach the end point or you stop it. For system, we also need to take care of several aggro beaviors (if we agroo leader, do other attack you ? If we attack 1 follower ...)

This is off topic anyway. Once the bug in this one is found and solved, next path will follow.

Link to comment
Share on other sites

This is a version I think is enough.

I won't add the confused movement generator because this would add code for quite nothing.

What changed:

  • * When no assistant is found the flee is limited in time (7s) and configurable from conf
    * After flee or assistant call, the mob now return into combat walking

So this patch makes:

  • * When mob health is < at value configured in conf it will either

    • * Flee for 7 seconds if no assistant is around
      * Flee to the nearest assistant if one is found

    * If an assistant was found and called, the mob stay doing nothing for 1.5 seconds and assistant will run to you after this 1.5 seconds too

    * The mob that was fleeing return to combat walking

I would like you test the patch and apply the sql provided on first post. It's done to be run without SD2 and it depends only on the values in conf and DB data.

I request you to give feedback on general beaviour and what differences you see compared to offy.

In mean time, I may update the patch to change a bit the code without altering the actual behaviour.

When you agree on the behaviour, I will remove the calls and health setting from conf and push it so that it's called from SD2 and ACID until the AI part of SD2 is moved to core fully.

Here is latest:

http://pastebin.ca/1361424

Have fun and please revert back.

Link to comment
Share on other sites

So this patch makes:

  • * When mob health is < at value configured in conf it will either

    • * Flee for 7 seconds if no assistant is around
      * Flee to the nearest assistant if one is found

Hmm only problem I have is this "Flee at Health < value in conf".

Some creatures flee at different percent (ACID shows ~6 scripts currently with large variation on Flee Percent). select * from eventai_scripts where action1_type = 25;

Additionally some creatures should flee at full hp when they get in combat. The best example of this is the birds (Wild Sparrowhawk) on top Twilight Ridge (creature id = 22979). This is official behavior and is actually extremely frustrating because they are Red-Aggressive, keep you in combat when they are fleeing, and aggro more mobs...who end up fleeing the moment they are put in combat.

Perhaps what is better is allow DB developers "override this value" in db. For example by default field can be NULL or 0 which means use Config value. If there is a value in this field then creature will flee at specified percent of hp.

Link to comment
Share on other sites

This is a version I think is enough.

When you agree on the behaviour, I will remove the calls and health setting from conf and push it so that it's called from SD2 and ACID until the AI part of SD2 is moved to core fully.

Read the quote NTSC. It's to test the patch, after health % will be removed from conf and this system will not be used by core. It's for SD2.

Btw, since you are back, please put efforts to move AI to core.

Link to comment
Share on other sites

Read the quote NTSC. It's to test the patch, after health % will be removed from conf and this system will not be used by core. It's for SD2.

Btw, since you are back, please put efforts to move AI to core.

Haha my apologies. I've been trying to catch up on everything and I tend to skip over things =\\

Anyway I do think that it should be placed in the core and defined by a database field. EventAI is much slower than any simple HP check you can do in the MaNGOS core (its so bloated ugh). I just wanted to make sure there was a way to "override" it if needed.

Link to comment
Share on other sites

So that you can test it in production, this is the final patch called only from SD2

http://pastebin.ca/1367108

So you can either use the one posted 2 posts above (http://pastebin.ca/1366453) fully core side with DB flag, or this new one.

To make SD2 use this final one:

Index: scripts/creature/mob_event_ai.cpp
===================================================================
--- scripts/creature/mob_event_ai.cpp    (revision 924)
+++ scripts/creature/mob_event_ai.cpp    (working copy)
@@ -838,8 +838,7 @@
            break;
        case ACTION_T_FLEE:
            {
-                //TODO: Replace with Flee movement generator
-                m_creature->CastSpell(m_creature, SPELL_RUN_AWAY, true);
+                m_creature->DoFleeToGetAssistance();
            }
            break;
        case ACTION_T_QUEST_EVENT_ALL:

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use