New l2j geoengine rework.
This commit is contained in:
		
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -23,8 +23,8 @@ a - Prerequisites | ||||
| b - Make it work | ||||
| ---------------------------------------------- | ||||
|  | ||||
| To make geodata working: | ||||
| * unpack your geodata files into "/data/geodata" folder | ||||
| * open "/config/GeoEngine.ini" with your favorite text editor and then edit following config: | ||||
|   - CoordSynchronize = 2 | ||||
| * If you do not use any geodata files, the server will automatically change this setting to -1. | ||||
| To make geodata work: | ||||
| * unpack your geodata files into "/data/geodata" folder (or any other folder) | ||||
| * open "/config/GeoEngine.ini" with your favorite text editor and then edit following configs: | ||||
| - GeoDataPath = set path to your geodata, if elsewhere than "./data/geodata/" | ||||
| - GeoDataType = set the geodata format, which you are using. | ||||
|   | ||||
| @@ -59,7 +59,7 @@ public class FleeMonsters extends AbstractNpcAI | ||||
| 		final int posX = (int) (npc.getX() + (FLEE_DISTANCE * Math.cos(radians))); | ||||
| 		final int posY = (int) (npc.getY() + (FLEE_DISTANCE * Math.sin(radians))); | ||||
| 		final int posZ = npc.getZ(); | ||||
| 		final Location destination = GeoEngine.getInstance().canMoveToTargetLoc(npc.getX(), npc.getY(), npc.getZ(), posX, posY, posZ, attacker.getInstanceWorld()); | ||||
| 		final Location destination = GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), posX, posY, posZ, npc.getInstanceWorld()); | ||||
| 		npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, destination); | ||||
| 		return super.onAttack(npc, attacker, damage, isSummon); | ||||
| 	} | ||||
|   | ||||
| @@ -55,7 +55,7 @@ public class RandomWalkingGuards extends AbstractNpcAI | ||||
| 			if (!npc.isInCombat()) | ||||
| 			{ | ||||
| 				final Location randomLoc = Util.getRandomPosition(npc.getSpawn().getLocation(), 0, Config.MAX_DRIFT_RANGE); | ||||
| 				addMoveToDesire(npc, GeoEngine.getInstance().canMoveToTargetLoc(npc.getX(), npc.getY(), npc.getZ(), randomLoc.getX(), randomLoc.getY(), randomLoc.getZ(), npc.getInstanceWorld()), 23); | ||||
| 				addMoveToDesire(npc, GeoEngine.getInstance().getValidLocation(npc.getX(), npc.getY(), npc.getZ(), randomLoc.getX(), randomLoc.getY(), randomLoc.getZ(), npc.getInstanceWorld()), 23); | ||||
| 			} | ||||
| 			startQuestTimer("RANDOM_WALK", getRandom(MIN_WALK_DELAY, MAX_WALK_DELAY), npc, null); | ||||
| 		} | ||||
|   | ||||
| @@ -55,8 +55,8 @@ public class AdminGeodata implements IAdminCommandHandler | ||||
| 				final int worldX = activeChar.getX(); | ||||
| 				final int worldY = activeChar.getY(); | ||||
| 				final int worldZ = activeChar.getZ(); | ||||
| 				final int geoX = GeoEngine.getInstance().getGeoX(worldX); | ||||
| 				final int geoY = GeoEngine.getInstance().getGeoY(worldY); | ||||
| 				final int geoX = GeoEngine.getGeoX(worldX); | ||||
| 				final int geoY = GeoEngine.getGeoY(worldY); | ||||
| 				 | ||||
| 				if (GeoEngine.getInstance().hasGeoPos(geoX, geoY)) | ||||
| 				{ | ||||
| @@ -73,8 +73,8 @@ public class AdminGeodata implements IAdminCommandHandler | ||||
| 				final int worldX = activeChar.getX(); | ||||
| 				final int worldY = activeChar.getY(); | ||||
| 				final int worldZ = activeChar.getZ(); | ||||
| 				final int geoX = GeoEngine.getInstance().getGeoX(worldX); | ||||
| 				final int geoY = GeoEngine.getInstance().getGeoY(worldY); | ||||
| 				final int geoX = GeoEngine.getGeoX(worldX); | ||||
| 				final int geoY = GeoEngine.getGeoY(worldY); | ||||
| 				 | ||||
| 				if (GeoEngine.getInstance().hasGeoPos(geoX, geoY)) | ||||
| 				{ | ||||
| @@ -133,8 +133,8 @@ public class AdminGeodata implements IAdminCommandHandler | ||||
| 			} | ||||
| 			case "admin_geomap": | ||||
| 			{ | ||||
| 				final int x = ((activeChar.getX() - World.MAP_MIN_X) >> 15) + World.TILE_X_MIN; | ||||
| 				final int y = ((activeChar.getY() - World.MAP_MIN_Y) >> 15) + World.TILE_Y_MIN; | ||||
| 				final int x = ((activeChar.getX() - World.WORLD_X_MIN) >> 15) + World.TILE_X_MIN; | ||||
| 				final int y = ((activeChar.getY() - World.WORLD_Y_MIN) >> 15) + World.TILE_Y_MIN; | ||||
| 				BuilderUtil.sendSysMessage(activeChar, "GeoMap: " + x + "_" + y + " (" + ((x - World.TILE_ZERO_COORD_X) * World.TILE_SIZE) + "," + ((y - World.TILE_ZERO_COORD_Y) * World.TILE_SIZE) + " to " + ((((x - World.TILE_ZERO_COORD_X) * World.TILE_SIZE) + World.TILE_SIZE) - 1) + "," + ((((y - World.TILE_ZERO_COORD_Y) * World.TILE_SIZE) + World.TILE_SIZE) - 1) + ")"); | ||||
| 				break; | ||||
| 			} | ||||
|   | ||||
| @@ -57,8 +57,8 @@ public class AdminMissingHtmls implements IAdminCommandHandler | ||||
| 		{ | ||||
| 			case "admin_geomap_missing_htmls": | ||||
| 			{ | ||||
| 				final int x = ((activeChar.getX() - World.MAP_MIN_X) >> 15) + World.TILE_X_MIN; | ||||
| 				final int y = ((activeChar.getY() - World.MAP_MIN_Y) >> 15) + World.TILE_Y_MIN; | ||||
| 				final int x = ((activeChar.getX() - World.WORLD_X_MIN) >> 15) + World.TILE_X_MIN; | ||||
| 				final int y = ((activeChar.getY() - World.WORLD_Y_MIN) >> 15) + World.TILE_Y_MIN; | ||||
| 				final int topLeftX = (x - World.TILE_ZERO_COORD_X) * World.TILE_SIZE; | ||||
| 				final int topLeftY = (y - World.TILE_ZERO_COORD_Y) * World.TILE_SIZE; | ||||
| 				final int bottomRightX = (((x - World.TILE_ZERO_COORD_X) * World.TILE_SIZE) + World.TILE_SIZE) - 1; | ||||
|   | ||||
| @@ -19,9 +19,9 @@ package handlers.admincommandhandlers; | ||||
| import java.util.List; | ||||
|  | ||||
| import org.l2jmobius.Config; | ||||
| import org.l2jmobius.gameserver.geoengine.GeoEnginePathfinding; | ||||
| import org.l2jmobius.gameserver.geoengine.pathfinding.AbstractNodeLoc; | ||||
| import org.l2jmobius.gameserver.geoengine.GeoEngine; | ||||
| import org.l2jmobius.gameserver.handler.IAdminCommandHandler; | ||||
| import org.l2jmobius.gameserver.model.Location; | ||||
| import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; | ||||
| import org.l2jmobius.gameserver.util.BuilderUtil; | ||||
|  | ||||
| @@ -44,13 +44,13 @@ public class AdminPathNode implements IAdminCommandHandler | ||||
| 			} | ||||
| 			if (activeChar.getTarget() != null) | ||||
| 			{ | ||||
| 				final List<AbstractNodeLoc> path = GeoEnginePathfinding.getInstance().findPath(activeChar.getX(), activeChar.getY(), (short) activeChar.getZ(), activeChar.getTarget().getX(), activeChar.getTarget().getY(), (short) activeChar.getTarget().getZ(), activeChar.getInstanceWorld()); | ||||
| 				final List<Location> path = GeoEngine.getInstance().findPath(activeChar.getX(), activeChar.getY(), (short) activeChar.getZ(), activeChar.getTarget().getX(), activeChar.getTarget().getY(), (short) activeChar.getTarget().getZ(), activeChar.getInstanceWorld()); | ||||
| 				if (path == null) | ||||
| 				{ | ||||
| 					BuilderUtil.sendSysMessage(activeChar, "No Route!"); | ||||
| 					return true; | ||||
| 				} | ||||
| 				for (AbstractNodeLoc a : path) | ||||
| 				for (Location a : path) | ||||
| 				{ | ||||
| 					BuilderUtil.sendSysMessage(activeChar, "x:" + a.getX() + " y:" + a.getY() + " z:" + a.getZ()); | ||||
| 				} | ||||
|   | ||||
| @@ -88,7 +88,7 @@ public class Blink extends AbstractEffect | ||||
| 		final int y = effected.getY() + y1; | ||||
| 		final int z = effected.getZ(); | ||||
| 		 | ||||
| 		final Location destination = GeoEngine.getInstance().canMoveToTargetLoc(effected.getX(), effected.getY(), effected.getZ(), x, y, z, effected.getInstanceWorld()); | ||||
| 		final Location destination = GeoEngine.getInstance().getValidLocation(effected.getX(), effected.getY(), effected.getZ(), x, y, z, effected.getInstanceWorld()); | ||||
| 		 | ||||
| 		effected.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE); | ||||
| 		effected.broadcastPacket(new FlyToLocation(effected, destination, _flyType, _flySpeed, _flyDelay, _animationSpeed)); | ||||
|   | ||||
| @@ -100,7 +100,7 @@ public class Fear extends AbstractEffect | ||||
| 		final int posY = (int) (effected.getY() + (FEAR_RANGE * Math.sin(radians))); | ||||
| 		final int posZ = effected.getZ(); | ||||
| 		 | ||||
| 		final Location destination = GeoEngine.getInstance().canMoveToTargetLoc(effected.getX(), effected.getY(), effected.getZ(), posX, posY, posZ, effected.getInstanceWorld()); | ||||
| 		final Location destination = GeoEngine.getInstance().getValidLocation(effected.getX(), effected.getY(), effected.getZ(), posX, posY, posZ, effected.getInstanceWorld()); | ||||
| 		effected.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, destination); | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -57,7 +57,7 @@ public class FlyAway extends AbstractEffect | ||||
| 		final int y = (int) (effector.getY() - (nRadius * (dy / distance))); | ||||
| 		final int z = effector.getZ(); | ||||
| 		 | ||||
| 		final Location destination = GeoEngine.getInstance().canMoveToTargetLoc(effected.getX(), effected.getY(), effected.getZ(), x, y, z, effected.getInstanceWorld()); | ||||
| 		final Location destination = GeoEngine.getInstance().getValidLocation(effected.getX(), effected.getY(), effected.getZ(), x, y, z, effected.getInstanceWorld()); | ||||
| 		 | ||||
| 		effected.broadcastPacket(new FlyToLocation(effected, destination, FlyType.THROW_UP)); | ||||
| 		effected.setXYZ(destination); | ||||
|   | ||||
| @@ -133,7 +133,7 @@ public class KnockBack extends AbstractEffect | ||||
| 			final int x = (int) (effected.getX() + (_distance * Math.cos(radians))); | ||||
| 			final int y = (int) (effected.getY() + (_distance * Math.sin(radians))); | ||||
| 			final int z = effected.getZ(); | ||||
| 			final Location loc = GeoEngine.getInstance().canMoveToTargetLoc(effected.getX(), effected.getY(), effected.getZ(), x, y, z, effected.getInstanceWorld()); | ||||
| 			final Location loc = GeoEngine.getInstance().getValidLocation(effected.getX(), effected.getY(), effected.getZ(), x, y, z, effected.getInstanceWorld()); | ||||
| 			 | ||||
| 			effected.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE); | ||||
| 			effected.broadcastPacket(new FlyToLocation(effected, loc, _type, _speed, _delay, _animationSpeed)); | ||||
|   | ||||
| @@ -73,7 +73,7 @@ public class PullBack extends AbstractEffect | ||||
| 		} | ||||
| 		 | ||||
| 		// In retail, you get debuff, but you are not even moved if there is obstacle. You are still disabled from using skills and moving though. | ||||
| 		if (GeoEngine.getInstance().canMoveToTarget(effected.getX(), effected.getY(), effected.getZ(), effector.getX(), effector.getY(), effector.getZ(), effector.getInstanceWorld())) | ||||
| 		if (GeoEngine.getInstance().canMoveToTarget(effected.getX(), effected.getY(), effected.getZ(), effector.getX(), effector.getY(), effector.getZ(), effected.getInstanceWorld())) | ||||
| 		{ | ||||
| 			effected.broadcastPacket(new FlyToLocation(effected, effector, _type, _speed, _delay, _animationSpeed)); | ||||
| 			effected.setXYZ(effector.getX(), effector.getY(), GeoEngine.getInstance().getHeight(effector.getX(), effector.getY(), effector.getZ()) + 10); | ||||
|   | ||||
| @@ -87,7 +87,7 @@ public class TeleportToSummon extends AbstractEffect | ||||
| 		final int y = (int) (py + (25 * Math.sin(ph))); | ||||
| 		final int z = summon.getZ(); | ||||
| 		 | ||||
| 		final Location loc = GeoEngine.getInstance().canMoveToTargetLoc(effector.getX(), effector.getY(), effector.getZ(), x, y, z, effector.getInstanceWorld()); | ||||
| 		final Location loc = GeoEngine.getInstance().getValidLocation(effector.getX(), effector.getY(), effector.getZ(), x, y, z,effector.getInstanceWorld()); | ||||
| 		 | ||||
| 		effector.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE); | ||||
| 		effector.broadcastPacket(new FlyToLocation(effector, loc.getX(), loc.getY(), loc.getZ(), FlyType.DUMMY)); | ||||
|   | ||||
| @@ -76,7 +76,7 @@ public class TeleportToTarget extends AbstractEffect | ||||
| 		final int y = (int) (py + (25 * Math.sin(ph))); | ||||
| 		final int z = effected.getZ(); | ||||
| 		 | ||||
| 		final Location loc = GeoEngine.getInstance().canMoveToTargetLoc(effector.getX(), effector.getY(), effector.getZ(), x, y, z, effector.getInstanceWorld()); | ||||
| 		final Location loc = GeoEngine.getInstance().getValidLocation(effector.getX(), effector.getY(), effector.getZ(), x, y, z,effector.getInstanceWorld()); | ||||
| 		 | ||||
| 		effector.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE); | ||||
| 		effector.broadcastPacket(new FlyToLocation(effector, loc.getX(), loc.getY(), loc.getZ(), FlyType.DUMMY)); | ||||
|   | ||||
| @@ -65,7 +65,7 @@ public class RollingDice implements IItemHandler | ||||
| 		final int x = player.getX() + x1; | ||||
| 		final int y = player.getY() + y1; | ||||
| 		final int z = player.getZ(); | ||||
| 		final Location destination = GeoEngine.getInstance().canMoveToTargetLoc(player.getX(), player.getY(), player.getZ(), x, y, z, player.getInstanceWorld()); | ||||
| 		final Location destination = GeoEngine.getInstance().getValidLocation(player.getX(), player.getY(), player.getZ(), x, y, z, player.getInstanceWorld()); | ||||
| 		Broadcast.toSelfAndKnownPlayers(player, new Dice(player.getObjectId(), itemId, number, destination.getX(), destination.getY(), destination.getZ())); | ||||
| 		 | ||||
| 		final SystemMessage sm = new SystemMessage(SystemMessageId.C1_HAS_ROLLED_A_S2); | ||||
|   | ||||
| @@ -52,7 +52,7 @@ public class Ground implements ITargetTypeHandler | ||||
| 					return null; | ||||
| 				} | ||||
| 				 | ||||
| 				if (!GeoEngine.getInstance().canSeeTarget(creature, worldPosition)) | ||||
| 				if (!GeoEngine.getInstance().canSeeLocation(creature, worldPosition)) | ||||
| 				{ | ||||
| 					if (sendMessage) | ||||
| 					{ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 MobiusDevelopment
					MobiusDevelopment