L2JLisvus

Would you like to react to this message? Create an account in a few clicks or log in to continue.

3 posters

    Fix for : circling around the target [COMMITED]

    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    Fix for : circling around the target [COMMITED] Empty Fix for : circling around the target [COMMITED]

    Post  Karakan 12th June 2019, 16:30

    This prevents monsters from trying to run behind players ,and ending up inside walls.


    This "bug" was one of the major issues on my live server.
    Back then.... I had to completely remove the code ,because of stuck monsters inside walls was getting out of control.  Cool



    Now it works as intented.

    Monster will only try to circle around the charakter IF they can move to that location.
    If there is a wall they will skip and keep attacking from their current position.

    Did few quick tests on my local test server, and it works like a charm.


    I know its not a perfect and clean code, but its fixes a very annoying geodata "bug".
    Feel free to make suggestion how to improve the code.



    L2AttackableAI


    Code:


    Index: L2AttackableAI.java
    ===================================================================
    --- L2AttackableAI.java   (revision 614)
    +++ L2AttackableAI.java   (working copy)

    @@ -1359,30 +1368,76 @@
           // Else, if this is close enough for physical attacks
           // In case many mobs are trying to hit from same place, move a bit,
           // circling around the target
    -      if (Rnd.nextInt(100) <= 33) // check it once per 3 seconds
    -      {
    -         for (L2Object nearby : _actor.getKnownList().getKnownCharactersInRadius(20))
    -         {
    -            if ((nearby instanceof L2Attackable) && (nearby != _mostHatedAnalysis.character))
    -            {
    -               int diffx = Rnd.get(combinedCollision, combinedCollision + 40);
    -               if (Rnd.get(10) < 5)
    -               {
    -                  diffx = -diffx;
    -               }
    -              
    -               int diffy = Rnd.get(combinedCollision, combinedCollision + 40);
    -               if (Rnd.get(10) < 5)
    -               {
    -                  diffy = -diffy;
    -               }
    -              
    -               moveTo(_mostHatedAnalysis.character.getX() + diffx, _mostHatedAnalysis.character.getY() + diffy, _mostHatedAnalysis.character.getZ());
    -               return;
    -            }
    -         }
    -      }
    +     final int collision = (int) _actor.getTemplate().collisionRadius;
    +        if (!_actor.isMovementDisabled() && Rnd.nextInt(100) <= 33)
    +                   {
    +                           for (L2Object nearby : _actor.getKnownList().getKnownObjects().values())
    +                           {
    +                                   if (nearby instanceof L2Attackable && _actor.isInsideRadius(nearby, collision, false, false) && nearby != originalAttackTarget)
    +                                   {
    +                                           int newX = combinedCollision + Rnd.get(40);
    +                                           if (Rnd.nextBoolean())
    +                                           {
    +                                                   newX = originalAttackTarget.getX() + newX;
    +                                           }
    +                                           else
    +                                           {
    +                                                   newX = originalAttackTarget.getX() - newX;
    +                                           }
    +                                          
    +                                           int newY = combinedCollision + Rnd.get(40);
    +                                           if (Rnd.nextBoolean())
    +                                           {
    +                                                   newY = originalAttackTarget.getY() + newY;
    +                                           }
    +                                           else
    +                                           {
    +                                                   newY = originalAttackTarget.getY() - newY;
    +                                           }
    +
    +                                           if (!_actor.isInsideRadius(newX, newY, collision, false))
    +                                           {
    +                                                   int newZ = _actor.getZ() + 30;
    +                                                   if (GeoData.getInstance().canMove(_actor.getX(), _actor.getY(), _actor.getZ(), newX, newY, newZ))
    +                                                   {
    +                                                           moveTo(newX, newY, newZ);
    +                                                   }
    +                                           }                                              
    +                                           return;
    +                                   }
    +                           }
    +                   }      
    +


    Last edited by Karakan on 12th July 2019, 15:30; edited 2 times in total
    avatar
    confejulian


    Posts : 254
    Join date : 2016-08-27

    Fix for : circling around the target [COMMITED] Empty Re: Fix for : circling around the target [COMMITED]

    Post  confejulian 13th June 2019, 03:56

    When i started my server had the same problem with you. But you helped me time ago to solved.

    I have a question.

    This code have any difference on the solution you provide on this old thread?

    https://l2jlisvus.forumotion.com/t1184-geodata-question

    it's really nice to apply this codes modifications on the oficial code, this contribution is very important.

    Thank you for second time.
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    Fix for : circling around the target [COMMITED] Empty Re: Fix for : circling around the target [COMMITED]

    Post  Karakan 13th June 2019, 14:18

    confejulian wrote:
    I have a question.

    This code have any difference on the solution you provide on this old thread?

    https://l2jlisvus.forumotion.com/t1184-geodata-question



    Well, the post on the old thread was just a temp. solution ,and not really a fix.  
    It prevented monsters from running into walls.
    But it also removed the whole AI "circling" behaviour. (not retail like)


    With the new fix they can run around you, but there is a geodata check now,
    so they won't end up beeing stuck inside walls.


    Maybe there is a better way for this
    Its best to wait for DnR's reply.
    He should decide if this is worth getting commited.

    After all its better than no check at all.  

    Regards Cool


    Last edited by Karakan on 14th June 2019, 15:47; edited 1 time in total
    avatar
    confejulian


    Posts : 254
    Join date : 2016-08-27

    Fix for : circling around the target [COMMITED] Empty Re: Fix for : circling around the target [COMMITED]

    Post  confejulian 14th June 2019, 03:58

    Nice, thank for your answer
    DnR
    DnR
    Admin
    Admin


    Posts : 1475
    Join date : 2012-12-03
    Age : 34

    Fix for : circling around the target [COMMITED] Empty Re: Fix for : circling around the target [COMMITED]

    Post  DnR 15th June 2019, 14:31

    This is great!

    Your experience helped to solve this serious bug. I won't overeact if I say that weren't it for you, this case would still be open.
    I'll try to make an adaptation as soon as possible.

    I'm currently updating skill aggro system to a more decent version. I believe everyone is familiar with aggro points per skill system and now we'll stick to this system as well. Smile

    Thanks a lot for your efforts.

    BR,
    DnR
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    Fix for : circling around the target [COMMITED] Empty Re: Fix for : circling around the target [COMMITED]

    Post  Karakan 15th June 2019, 17:35

    DnR wrote:This is great!

    Your experience helped to solve this serious bug. I won't overeact if I say that weren't it for you, this case would still be open.
    I'll try to make an adaptation as soon as possible.

    I'm currently updating skill aggro system to a more decent version. I believe everyone is familiar with aggro points per skill system and now we'll stick to this system as well. Smile

    Thanks a lot for your efforts.

    BR,
    DnR


    Sounds Great !
    Cant wait for the new revision.

    I've several "things" i want to adapt/implement (mostly L2Off char/mob behaviour)
    But i dont want to flood your list of "thingsToDo" ,since you are busy anyways.  Cool



    Thank you.
    DnR
    DnR
    Admin
    Admin


    Posts : 1475
    Join date : 2012-12-03
    Age : 34

    Fix for : circling around the target [COMMITED] Empty Re: Fix for : circling around the target [COMMITED]

    Post  DnR 17th June 2019, 01:24

    Added to trunk. Thanks. Smile

    Sponsored content


    Fix for : circling around the target [COMMITED] Empty Re: Fix for : circling around the target [COMMITED]

    Post  Sponsored content


      Current date/time is 19th May 2024, 10:18