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.
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
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.
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