From 844d6249f70c077825781a662e7eab4bf7141bac Mon Sep 17 00:00:00 2001 From: Rumen Nikiforov <unafraid89@gmail.com> Date: Sat, 23 Nov 2013 18:06:13 +0000 Subject: [PATCH] BETA: New implementation of geonengine using an abstraction layer allowing support for different engines. * Patch by: FBIagent * Tested by: lion, oscard, Konstantinos, Szponiasty, dEvilKinG, skyshadow, janiko, pandragon, badboy29, midnex, valanths1990 * Reviewed by: Zoey76, lion, BiggBoss --- .../dist/game/config/adminCommands.xml | 12 +- .../ai/npc/ForgeOfTheGods/TarBeetleSpawn.java | 2 +- .../admincommandhandlers/AdminGeodata.java | 154 ++++++------------ .../FinalEmperialTomb/FinalEmperialTomb.java | 2 +- .../instances/SeedOfDestruction/Stage1.java | 2 +- 5 files changed, 57 insertions(+), 115 deletions(-) diff --git a/L2J_DataPack_BETA/dist/game/config/adminCommands.xml b/L2J_DataPack_BETA/dist/game/config/adminCommands.xml index 9f4f0ac946..6e2081f38d 100644 --- a/L2J_DataPack_BETA/dist/game/config/adminCommands.xml +++ b/L2J_DataPack_BETA/dist/game/config/adminCommands.xml @@ -289,14 +289,10 @@ <admin command="admin_removefort" accessLevel="7" /> <!-- ADMIN GEODATA --> - <admin command="admin_geo_z" accessLevel="7" /> - <admin command="admin_geo_type" accessLevel="7" /> - <admin command="admin_geo_nswe" accessLevel="7" /> - <admin command="admin_geo_los" accessLevel="7" /> - <admin command="admin_geo_position" accessLevel="7" /> - <admin command="admin_geo_bug" accessLevel="7" /> - <admin command="admin_geo_load" accessLevel="7" /> - <admin command="admin_geo_unload" accessLevel="7" /> + <admin command="admin_geo_pos" accessLevel="7" /> + <admin command="admin_geo_spawn_pos" accessLevel="7" /> + <admin command="admin_geo_can_see" accessLevel="7" /> + <admin command="admin_geo_can_move" accessLevel="7" /> <!-- ADMIN GEO EDITOR --> <admin command="admin_ge_status" accessLevel="7" /> diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ForgeOfTheGods/TarBeetleSpawn.java b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ForgeOfTheGods/TarBeetleSpawn.java index 7ba09c7176..f07c3b1fe7 100644 --- a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ForgeOfTheGods/TarBeetleSpawn.java +++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ForgeOfTheGods/TarBeetleSpawn.java @@ -149,7 +149,7 @@ public class TarBeetleSpawn extends DocumentParser spawn.setHeading(Rnd.get(65535)); spawn.setX(loc[0]); spawn.setY(loc[1]); - spawn.setZ(GeoData.getInstance().getSpawnHeight(loc[0], loc[1], loc[2], loc[3], null)); + spawn.setZ(GeoData.getInstance().getSpawnHeight(loc[0], loc[1], loc[2], loc[3])); final L2Npc npc = spawn.doSpawn(); npc.setIsNoRndWalk(true); diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminGeodata.java b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminGeodata.java index ee065fdae4..1d6f37fb95 100644 --- a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminGeodata.java +++ b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminGeodata.java @@ -18,161 +18,107 @@ */ package handlers.admincommandhandlers; -import com.l2jserver.Config; import com.l2jserver.gameserver.GeoData; import com.l2jserver.gameserver.handler.IAdminCommandHandler; +import com.l2jserver.gameserver.model.L2Object; import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; +import com.l2jserver.gameserver.network.SystemMessageId; +import com.l2jserver.gameserver.network.serverpackets.SystemMessage; /** * @author -Nemesiss- + * @author FBIagent */ public class AdminGeodata implements IAdminCommandHandler { private static final String[] ADMIN_COMMANDS = { - "admin_geo_z", - "admin_geo_type", - "admin_geo_nswe", - "admin_geo_los", - "admin_geo_position", - "admin_geo_bug", - "admin_geo_load", - "admin_geo_unload" + "admin_geo_pos", + "admin_geo_spawn_pos", + "admin_geo_can_move", + "admin_geo_can_see" }; @Override public boolean useAdminCommand(String command, L2PcInstance activeChar) { - if (Config.GEODATA < 1) + if ("admin_geo_pos".equals(command)) { - activeChar.sendMessage("Geo Engine is Turned Off!"); - return true; - } - - if (command.equals("admin_geo_z")) - { - activeChar.sendMessage("GeoEngine: Geo_Z = " + GeoData.getInstance().getHeight(activeChar.getX(), activeChar.getY(), activeChar.getZ()) + " Loc_Z = " + activeChar.getZ()); - } - else if (command.equals("admin_geo_type")) - { - short type = GeoData.getInstance().getType(activeChar.getX(), activeChar.getY()); - activeChar.sendMessage("GeoEngine: Geo_Type = " + type); - short height = GeoData.getInstance().getHeight(activeChar.getX(), activeChar.getY(), activeChar.getZ()); - activeChar.sendMessage("GeoEngine: height = " + height); - } - else if (command.equals("admin_geo_nswe")) - { - String result = ""; - short nswe = GeoData.getInstance().getNSWE(activeChar.getX(), activeChar.getY(), activeChar.getZ()); - if ((nswe & 8) == 0) + int worldX = activeChar.getX(); + int worldY = activeChar.getY(); + int worldZ = activeChar.getZ(); + int geoX = GeoData.getInstance().getGeoX(worldX); + int geoY = GeoData.getInstance().getGeoY(worldY); + + if (GeoData.getInstance().hasGeoPos(geoX, geoY)) { - result += " N"; + activeChar.sendMessage("WorldX: " + worldX + ", WorldY: " + worldY + ", WorldZ: " + worldZ + ", GeoX: " + geoX + ", GeoY: " + geoY + ", GeoZ: " + GeoData.getInstance().getNearestZ(geoX, geoY, worldZ)); } - if ((nswe & 4) == 0) + else { - result += " S"; + activeChar.sendMessage("There is no geodata at this position."); } - if ((nswe & 2) == 0) + } + else if ("admin_geo_spawn_pos".equals(command)) + { + int worldX = activeChar.getX(); + int worldY = activeChar.getY(); + int worldZ = activeChar.getZ(); + int geoX = GeoData.getInstance().getGeoX(worldX); + int geoY = GeoData.getInstance().getGeoY(worldY); + + if (GeoData.getInstance().hasGeoPos(geoX, geoY)) { - result += " W"; + activeChar.sendMessage("WorldX: " + worldX + ", WorldY: " + worldY + ", WorldZ: " + worldZ + ", GeoX: " + geoX + ", GeoY: " + geoY + ", GeoZ: " + GeoData.getInstance().getSpawnHeight(worldX, worldY, worldZ, worldZ)); } - if ((nswe & 1) == 0) + else { - result += " E"; + activeChar.sendMessage("There is no geodata at this position."); } - activeChar.sendMessage("GeoEngine: Geo_NSWE -> " + nswe + "->" + result); } - else if (command.equals("admin_geo_los")) + else if ("admin_geo_can_move".equals(command)) { - if (activeChar.getTarget() != null) + L2Object target = activeChar.getTarget(); + if (target != null) { - if (GeoData.getInstance().canSeeTargetDebug(activeChar, activeChar.getTarget())) + if (GeoData.getInstance().canSeeTarget(activeChar, target)) { - activeChar.sendMessage("GeoEngine: Can See Target"); + activeChar.sendMessage("Can move beeline."); } else { - activeChar.sendMessage("GeoEngine: Can't See Target"); + activeChar.sendMessage("Can not move beeline!"); } - } else { - activeChar.sendMessage("None Target!"); + activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET); } } - else if (command.equals("admin_geo_position")) + else if ("admin_geo_can_see".equals(command)) { - activeChar.sendMessage("GeoEngine: Your current position: "); - activeChar.sendMessage(".... world coords: x: " + activeChar.getX() + " y: " + activeChar.getY() + " z: " + activeChar.getZ()); - activeChar.sendMessage(".... geo position: " + GeoData.getInstance().geoPosition(activeChar.getX(), activeChar.getY())); - } - else if (command.startsWith("admin_geo_load")) - { - String[] v = command.substring(15).split(" "); - if (v.length != 2) - { - activeChar.sendMessage("Usage: //admin_geo_load <regionX> <regionY>"); - } - else + L2Object target = activeChar.getTarget(); + if (target != null) { - try + if (GeoData.getInstance().canSeeTarget(activeChar, target)) { - byte rx = Byte.parseByte(v[0]); - byte ry = Byte.parseByte(v[1]); - - boolean result = GeoData.loadGeodataFile(rx, ry); - - if (result) - { - activeChar.sendMessage("GeoEngine: File for region [" + rx + "," + ry + "] loaded succesfuly"); - } - else - { - activeChar.sendMessage("GeoEngine: File for region [" + rx + "," + ry + "] couldn't be loaded"); - } + activeChar.sendMessage("Can see target."); } - catch (Exception e) + else { - activeChar.sendMessage("You have to write numbers of regions <regionX> <regionY>"); + activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANT_SEE_TARGET)); } } - } - else if (command.startsWith("admin_geo_unload")) - { - String[] v = command.substring(17).split(" "); - if (v.length != 2) - { - activeChar.sendMessage("Usage: //admin_geo_unload <regionX> <regionY>"); - } else { - try - { - byte rx = Byte.parseByte(v[0]); - byte ry = Byte.parseByte(v[1]); - - GeoData.unloadGeodata(rx, ry); - activeChar.sendMessage("GeoEngine: File for region [" + rx + "," + ry + "] unloaded."); - } - catch (Exception e) - { - activeChar.sendMessage("You have to write numbers of regions <regionX> <regionY>"); - } + activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET); } } - else if (command.startsWith("admin_geo_bug")) + else { - try - { - String comment = command.substring(14); - GeoData.getInstance().addGeoDataBug(activeChar, comment); - } - catch (StringIndexOutOfBoundsException e) - { - activeChar.sendMessage("Usage: //admin_geo_bug you coments here"); - } + return false; } + return true; } diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/instances/FinalEmperialTomb/FinalEmperialTomb.java b/L2J_DataPack_BETA/dist/game/data/scripts/instances/FinalEmperialTomb/FinalEmperialTomb.java index d7f2551b6b..cd0767901f 100644 --- a/L2J_DataPack_BETA/dist/game/data/scripts/instances/FinalEmperialTomb/FinalEmperialTomb.java +++ b/L2J_DataPack_BETA/dist/game/data/scripts/instances/FinalEmperialTomb/FinalEmperialTomb.java @@ -674,7 +674,7 @@ public final class FinalEmperialTomb extends Quest if (_spawnZoneList.containsKey(spw.zone)) { int[] point = _spawnZoneList.get(spw.zone).getRandomPoint(); - spawn(world, spw.npcId, point[0], point[1], GeoData.getInstance().getSpawnHeight(point[0], point[1], point[2], point[3], null), getRandom(65535), spw.isNeededNextFlag); + spawn(world, spw.npcId, point[0], point[1], GeoData.getInstance().getSpawnHeight(point[0], point[1], point[2], point[3]), getRandom(65535), spw.isNeededNextFlag); } else { diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/instances/SeedOfDestruction/Stage1.java b/L2J_DataPack_BETA/dist/game/data/scripts/instances/SeedOfDestruction/Stage1.java index f5954321f2..c2ca285353 100644 --- a/L2J_DataPack_BETA/dist/game/data/scripts/instances/SeedOfDestruction/Stage1.java +++ b/L2J_DataPack_BETA/dist/game/data/scripts/instances/SeedOfDestruction/Stage1.java @@ -606,7 +606,7 @@ public final class Stage1 extends Quest if (_spawnZoneList.containsKey(spw.zone)) { int[] point = _spawnZoneList.get(spw.zone).getRandomPoint(); - spawn(world, spw.npcId, point[0], point[1], GeoData.getInstance().getSpawnHeight(point[0], point[1], point[2], point[3], null), getRandom(65535), spw.isNeededNextFlag); + spawn(world, spw.npcId, point[0], point[1], GeoData.getInstance().getSpawnHeight(point[0], point[1], point[2], point[3]), getRandom(65535), spw.isNeededNextFlag); } else { -- GitLab