diff --git a/datapack_development/data/scripts/handlers/MasterHandler.java b/datapack_development/data/scripts/handlers/MasterHandler.java index 2b85e23913371413937bd1a9d39a46f51cf164bd..13344416e10badd0dc335459d968b3e73c7ab5e9 100644 --- a/datapack_development/data/scripts/handlers/MasterHandler.java +++ b/datapack_development/data/scripts/handlers/MasterHandler.java @@ -14,6 +14,7 @@ */ package handlers; +import handlers.actionhandlers.*; import handlers.admincommandhandlers.*; import handlers.bypasshandlers.*; import handlers.chathandlers.*; @@ -25,6 +26,7 @@ import handlers.voicedcommandhandlers.*; import java.util.logging.Logger; import com.l2jserver.Config; +import com.l2jserver.gameserver.handler.ActionHandler; import com.l2jserver.gameserver.handler.AdminCommandHandler; import com.l2jserver.gameserver.handler.BypassHandler; import com.l2jserver.gameserver.handler.ChatHandler; @@ -41,7 +43,32 @@ import com.l2jserver.gameserver.handler.VoicedCommandHandler; public class MasterHandler { private static Logger _log = Logger.getLogger(MasterHandler.class.getName()); - + + private static void loadActionHandlers() + { + ActionHandler.getInstance().registerActionHandler(new L2ArtefactInstanceAction()); + ActionHandler.getInstance().registerActionHandler(new L2DecoyAction()); + ActionHandler.getInstance().registerActionHandler(new L2DoorInstanceAction()); + ActionHandler.getInstance().registerActionHandler(new L2NpcAction()); + ActionHandler.getInstance().registerActionHandler(new L2PcInstanceAction()); + ActionHandler.getInstance().registerActionHandler(new L2PetInstanceAction()); + ActionHandler.getInstance().registerActionHandler(new L2StaticObjectInstanceAction()); + ActionHandler.getInstance().registerActionHandler(new L2SummonAction()); + ActionHandler.getInstance().registerActionHandler(new L2TrapAction()); + _log.config("Loaded " + ActionHandler.getInstance().size() + " ActionHandlers"); + } + + private static void loadActionShiftHandlers() + { + ActionHandler.getInstance().registerActionShiftHandler(new L2DoorInstanceActionShift()); + ActionHandler.getInstance().registerActionShiftHandler(new L2MerchantInstanceActionShift()); + ActionHandler.getInstance().registerActionShiftHandler(new L2NpcActionShift()); + ActionHandler.getInstance().registerActionShiftHandler(new L2PcInstanceActionShift()); + ActionHandler.getInstance().registerActionShiftHandler(new L2StaticObjectInstanceActionShift()); + ActionHandler.getInstance().registerActionShiftHandler(new L2SummonActionShift()); + _log.config("Loaded " + ActionHandler.getInstance().sizeShift() + " ActionShiftHandlers"); + } + private static void loadAdminHandlers() { AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminAdmin()); @@ -280,6 +307,8 @@ public class MasterHandler public static void main(String[] args) { _log.config("Loading Handlers..."); + loadActionHandlers(); + loadActionShiftHandlers(); loadAdminHandlers(); loadBypassHandlers(); loadChatHandlers(); diff --git a/datapack_development/data/scripts/handlers/actionhandlers/L2ArtefactInstanceAction.java b/datapack_development/data/scripts/handlers/actionhandlers/L2ArtefactInstanceAction.java new file mode 100644 index 0000000000000000000000000000000000000000..d8ac36a68f43c3ea8e3e62620e6d5e56cd04cc87 --- /dev/null +++ b/datapack_development/data/scripts/handlers/actionhandlers/L2ArtefactInstanceAction.java @@ -0,0 +1,79 @@ +/* + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see <http://www.gnu.org/licenses/>. + */ +package handlers.actionhandlers; + +import com.l2jserver.gameserver.ai.CtrlIntention; +import com.l2jserver.gameserver.handler.IActionHandler; +import com.l2jserver.gameserver.model.L2Object.InstanceType; +import com.l2jserver.gameserver.model.actor.L2Character; +import com.l2jserver.gameserver.model.actor.L2Npc; +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; +import com.l2jserver.gameserver.network.serverpackets.MyTargetSelected; +import com.l2jserver.gameserver.network.serverpackets.ValidateLocation; + +public class L2ArtefactInstanceAction implements IActionHandler +{ + /** + * Manage actions when a player click on the L2ArtefactInstance.<BR> + * <BR> + * + * <B><U> Actions</U> :</B><BR> + * <BR> + * <li>Set the L2NpcInstance as target of the L2PcInstance player (if + * necessary)</li> <li>Send a Server->Client packet MyTargetSelected to the + * L2PcInstance player (display the select window)</li> <li>Send a + * Server->Client packet ValidateLocation to correct the L2NpcInstance + * position and heading on the client</li><BR> + * <BR> + * + * <B><U> Example of use </U> :</B><BR> + * <BR> + * <li>Client packet : Action, AttackRequest</li><BR> + * <BR> + */ + public boolean action(L2PcInstance activeChar, L2Character target, boolean interact) + { + if (!((L2Npc)target).canTarget(activeChar)) + return false; + + if (activeChar.getTarget() != target) + { + // Set the target of the L2PcInstance activeChar + activeChar.setTarget(target); + + // Send a Server->Client packet MyTargetSelected to the L2PcInstance activeChar + MyTargetSelected my = new MyTargetSelected(target.getObjectId(), 0); + activeChar.sendPacket(my); + + // Send a Server->Client packet ValidateLocation to correct the L2ArtefactInstance position and heading on the client + activeChar.sendPacket(new ValidateLocation(target)); + } + else if (interact) + { + // Calculate the distance between the L2PcInstance and the L2NpcInstance + if (!((L2Npc)target).canInteract(activeChar)) + { + // Notify the L2PcInstance AI with AI_INTENTION_INTERACT + activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target); + } + } + return true; + } + + public InstanceType getInstanceType() + { + return InstanceType.L2ArtefactInstance; + } +} \ No newline at end of file diff --git a/datapack_development/data/scripts/handlers/actionhandlers/L2DecoyAction.java b/datapack_development/data/scripts/handlers/actionhandlers/L2DecoyAction.java new file mode 100644 index 0000000000000000000000000000000000000000..94eafe427b52e7794c17d2767da767d8682beaf5 --- /dev/null +++ b/datapack_development/data/scripts/handlers/actionhandlers/L2DecoyAction.java @@ -0,0 +1,45 @@ +/* + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see <http://www.gnu.org/licenses/>. + */ +package handlers.actionhandlers; + +import com.l2jserver.gameserver.handler.IActionHandler; +import com.l2jserver.gameserver.model.L2Object.InstanceType; +import com.l2jserver.gameserver.model.actor.L2Character; +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; +import com.l2jserver.gameserver.network.SystemMessageId; +import com.l2jserver.gameserver.network.serverpackets.MyTargetSelected; +import com.l2jserver.gameserver.network.serverpackets.SystemMessage; + +public class L2DecoyAction implements IActionHandler +{ + public boolean action(L2PcInstance activeChar, L2Character target, boolean interact) + { + // Aggression target lock effect + if (activeChar.isLockedTarget() && activeChar.getLockedTarget() != target) + { + activeChar.sendPacket(new SystemMessage(SystemMessageId.FAILED_CHANGE_TARGET)); + return false; + } + + activeChar.setTarget(target); + activeChar.sendPacket(new MyTargetSelected(target.getObjectId(), activeChar.getLevel()- target.getLevel())); + return true; + } + + public InstanceType getInstanceType() + { + return InstanceType.L2Decoy; + } +} \ No newline at end of file diff --git a/datapack_development/data/scripts/handlers/actionhandlers/L2DoorInstanceAction.java b/datapack_development/data/scripts/handlers/actionhandlers/L2DoorInstanceAction.java new file mode 100644 index 0000000000000000000000000000000000000000..453f34b3996ae2441be631d6924dc145ce94ab18 --- /dev/null +++ b/datapack_development/data/scripts/handlers/actionhandlers/L2DoorInstanceAction.java @@ -0,0 +1,112 @@ +/* + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see <http://www.gnu.org/licenses/>. + */ +package handlers.actionhandlers; + +import com.l2jserver.gameserver.ai.CtrlIntention; +import com.l2jserver.gameserver.handler.IActionHandler; +import com.l2jserver.gameserver.model.L2Object.InstanceType; +import com.l2jserver.gameserver.model.actor.L2Character; +import com.l2jserver.gameserver.model.actor.L2Npc; +import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance; +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; +import com.l2jserver.gameserver.network.serverpackets.ConfirmDlg; +import com.l2jserver.gameserver.network.serverpackets.MyTargetSelected; +import com.l2jserver.gameserver.network.serverpackets.StaticObject; +import com.l2jserver.gameserver.network.serverpackets.ValidateLocation; + +public class L2DoorInstanceAction implements IActionHandler +{ + public boolean action(L2PcInstance activeChar, L2Character target, boolean interact) + { + // Check if the L2PcInstance already target the L2NpcInstance + if (activeChar.getTarget() != target) + { + // Set the target of the L2PcInstance activeChar + activeChar.setTarget(target); + + // Send a Server->Client packet MyTargetSelected to the L2PcInstance activeChar + activeChar.sendPacket(new MyTargetSelected(target.getObjectId(), 0)); + + StaticObject su; + // send HP amount if doors are inside castle/fortress zone + // TODO: needed to be added here doors from conquerable clanhalls + if ((((L2DoorInstance)target).getCastle() != null + && ((L2DoorInstance)target).getCastle().getCastleId() > 0) + || (((L2DoorInstance)target).getFort() != null + && ((L2DoorInstance)target).getFort().getFortId() > 0 + && !((L2DoorInstance)target).getIsCommanderDoor())) + su = new StaticObject((L2DoorInstance)target, true); + else + su = new StaticObject((L2DoorInstance)target, false); + + activeChar.sendPacket(su); + + // Send a Server->Client packet ValidateLocation to correct the L2NpcInstance position and heading on the client + activeChar.sendPacket(new ValidateLocation(target)); + } + else if (interact) + { + // MyTargetSelected my = new MyTargetSelected(getObjectId(), activeChar.getLevel()); + // activeChar.sendPacket(my); + if (target.isAutoAttackable(activeChar)) + { + if (Math.abs(activeChar.getZ() - target.getZ()) < 400) // this max heigth difference might need some tweaking + activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target); + } + else if (activeChar.getClan() != null + && ((L2DoorInstance)target).getClanHall() != null + && activeChar.getClanId() == ((L2DoorInstance)target).getClanHall().getOwnerId()) + { + if (!target.isInsideRadius(activeChar, L2Npc.INTERACTION_DISTANCE, false, false)) + { + activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target); + } + else + { + activeChar.gatesRequest((L2DoorInstance)target); + if (!((L2DoorInstance)target).getOpen()) + activeChar.sendPacket(new ConfirmDlg(1140)); + else + activeChar.sendPacket(new ConfirmDlg(1141)); + } + } + else if (activeChar.getClan() != null + && ((L2DoorInstance)target).getFort() != null + && activeChar.getClan() == ((L2DoorInstance)target).getFort().getOwnerClan() + && ((L2DoorInstance)target).isUnlockable() + && !((L2DoorInstance)target).getFort().getSiege().getIsInProgress()) + { + if (!target.isInsideRadius(activeChar, L2Npc.INTERACTION_DISTANCE, false, false)) + { + activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target); + } + else + { + activeChar.gatesRequest((L2DoorInstance)target); + if (!((L2DoorInstance)target).getOpen()) + activeChar.sendPacket(new ConfirmDlg(1140)); + else + activeChar.sendPacket(new ConfirmDlg(1141)); + } + } + } + return true; + } + + public InstanceType getInstanceType() + { + return InstanceType.L2DoorInstance; + } +} diff --git a/datapack_development/data/scripts/handlers/actionhandlers/L2DoorInstanceActionShift.java b/datapack_development/data/scripts/handlers/actionhandlers/L2DoorInstanceActionShift.java new file mode 100644 index 0000000000000000000000000000000000000000..637d90d98900b82555b2d7a70d5f0390eff1c99b --- /dev/null +++ b/datapack_development/data/scripts/handlers/actionhandlers/L2DoorInstanceActionShift.java @@ -0,0 +1,90 @@ +/* + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see <http://www.gnu.org/licenses/>. + */ +package handlers.actionhandlers; + +import com.l2jserver.gameserver.handler.IActionHandler; +import com.l2jserver.gameserver.model.L2Object.InstanceType; +import com.l2jserver.gameserver.model.actor.L2Character; +import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance; +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; +import com.l2jserver.gameserver.network.serverpackets.MyTargetSelected; +import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage; +import com.l2jserver.gameserver.network.serverpackets.StaticObject; +import com.l2jserver.gameserver.util.StringUtil; + +public class L2DoorInstanceActionShift implements IActionHandler +{ + public boolean action(L2PcInstance activeChar, L2Character target, boolean interact) + { + if (activeChar.getAccessLevel().isGm()) + { + activeChar.setTarget(target); + activeChar.sendPacket(new MyTargetSelected(target.getObjectId(), activeChar.getLevel())); + + StaticObject su; + // send HP amount if doors are inside castle/fortress zone + // TODO: needed to be added here doors from conquerable clanhalls + if ((((L2DoorInstance)target).getCastle() != null + && ((L2DoorInstance)target).getCastle().getCastleId() > 0) + || (((L2DoorInstance)target).getFort() != null + && ((L2DoorInstance)target).getFort().getFortId() > 0 + && !((L2DoorInstance)target).getIsCommanderDoor())) + su = new StaticObject((L2DoorInstance)target, true); + else + su = new StaticObject((L2DoorInstance)target, false); + + activeChar.sendPacket(su); + + NpcHtmlMessage html = new NpcHtmlMessage(target.getObjectId()); + final String html1 = StringUtil.concat( + "<html><body><center><font color=\"LEVEL\">Door Info</font></center><br><table border=0><tr><td>HP: </td><td>", + String.valueOf(target.getCurrentHp()), + " / ", + String.valueOf(target.getMaxHp()), + "</td></tr><tr><td>Max X,Y,Z: </td><td>", + String.valueOf(((L2DoorInstance)target).getXMax()), + ", ", + String.valueOf(((L2DoorInstance)target).getYMax()), + ", ", + String.valueOf(((L2DoorInstance)target).getZMax()), + "</td></tr><tr><td>Min X,Y,Z: </td><td>", + String.valueOf(((L2DoorInstance)target).getXMin()), + ", ", + String.valueOf(((L2DoorInstance)target).getYMin()), + ", ", + String.valueOf(((L2DoorInstance)target).getZMin()), + "</td></tr><tr><td>Object ID: </td><td>", + String.valueOf(target.getObjectId()), + "</td></tr><tr><td>Door ID: </td><td>", + String.valueOf(((L2DoorInstance)target).getDoorId()), + "</td></tr><tr><td><br></td></tr><tr><td>Class: </td><td>", + target.getClass().getSimpleName(), + "</td></tr></table><br><table><tr><td><button value=\"Open\" action=\"bypass -h admin_open ", + String.valueOf(((L2DoorInstance)target).getDoorId()), + "\" width=40 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><button value=\"Close\" action=\"bypass -h admin_close ", + String.valueOf(((L2DoorInstance)target).getDoorId()), + "\" width=40 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><button value=\"Kill\" action=\"bypass -h admin_kill\" width=40 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><button value=\"Delete\" action=\"bypass -h admin_delete\" width=40 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table></body></html>" + ); + html.setHtml(html1); + activeChar.sendPacket(html); + } + return true; + } + + public InstanceType getInstanceType() + { + return InstanceType.L2DoorInstance; + } +} \ No newline at end of file diff --git a/datapack_development/data/scripts/handlers/actionhandlers/L2MerchantInstanceActionShift.java b/datapack_development/data/scripts/handlers/actionhandlers/L2MerchantInstanceActionShift.java new file mode 100644 index 0000000000000000000000000000000000000000..b5e6c2e5419e4a94d724d77dfbd9634e2ec8edb9 --- /dev/null +++ b/datapack_development/data/scripts/handlers/actionhandlers/L2MerchantInstanceActionShift.java @@ -0,0 +1,99 @@ +/* + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see <http://www.gnu.org/licenses/>. + */ +package handlers.actionhandlers; + +import com.l2jserver.gameserver.handler.IActionHandler; +import com.l2jserver.gameserver.model.L2Object.InstanceType; +import com.l2jserver.gameserver.model.actor.L2Character; +import com.l2jserver.gameserver.model.actor.L2Npc; +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; +import com.l2jserver.gameserver.network.serverpackets.MyTargetSelected; +import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage; +import com.l2jserver.gameserver.network.serverpackets.StatusUpdate; +import com.l2jserver.gameserver.util.StringUtil; + +public class L2MerchantInstanceActionShift implements IActionHandler +{ + public boolean action(L2PcInstance activeChar, L2Character target, boolean interact) + { + if (activeChar.isGM()) + { + activeChar.setTarget(target); + + MyTargetSelected my = new MyTargetSelected(target.getObjectId(), activeChar.getLevel() - target.getLevel()); + activeChar.sendPacket(my); + + if (target.isAutoAttackable(activeChar)) + { + StatusUpdate su = new StatusUpdate(target.getObjectId()); + su.addAttribute(StatusUpdate.CUR_HP, (int) target.getCurrentHp()); + su.addAttribute(StatusUpdate.MAX_HP, target.getMaxHp()); + activeChar.sendPacket(su); + } + + NpcHtmlMessage html = new NpcHtmlMessage(target.getObjectId()); + final StringBuilder html1 = StringUtil.startAppend(2000, + "<html><body><center><font color=\"LEVEL\">Merchant Info</font></center><br><table border=0><tr><td>Object ID: </td><td>", + String.valueOf(target.getObjectId()), + "</td></tr><tr><td>Template ID: </td><td>", + String.valueOf(((L2Npc)target).getTemplate().npcId), + "</td></tr><tr><td><br></td></tr><tr><td>HP: </td><td>", + String.valueOf(target.getCurrentHp()), + "</td></tr><tr><td>MP: </td><td>", + String.valueOf(target.getCurrentMp()), + "</td></tr><tr><td>Level: </td><td>", + String.valueOf(target.getLevel()), + "</td></tr><tr><td><br></td></tr><tr><td>Class: </td><td>", + target.getClass().getSimpleName(), + "</td></tr><tr><td><br></td></tr></table><table><tr><td><button value=\"Edit NPC\" action=\"bypass -h admin_edit_npc ", + String.valueOf(((L2Npc)target).getTemplate().npcId), + "\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>" + + "<td><button value=\"Kill\" action=\"bypass -h admin_kill\" width=40 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>" + + "<tr><td><button value=\"Show DropList\" action=\"bypass -h admin_show_droplist ", + String.valueOf(((L2Npc)target).getTemplate().npcId), + "\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>" + + "<td><button value=\"Delete\" action=\"bypass -h admin_delete\" width=40 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>" + + "<tr><td><button value=\"View Shop\" action=\"bypass -h admin_showShop ", + String.valueOf(((L2Npc)target).getTemplate().npcId), + "\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table>" + ); + + /** Lease doesn't work at all for now!!! + StringUtil.append(html1, + "<button value=\"Lease next week\" action=\"bypass -h npc_", + String.valueOf(getObjectId()), + "_Lease\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + + "<button value=\"Abort current leasing\" action=\"bypass -h npc_", + String.valueOf(getObjectId()), + "_Lease next\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + + "<button value=\"Manage items\" action=\"bypass -h npc_", + String.valueOf(getObjectId()), + "_Lease manage\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + ); + */ + + html1.append("</body></html>"); + + html.setHtml(html1.toString()); + activeChar.sendPacket(html); + } + return true; + } + + public InstanceType getInstanceType() + { + return InstanceType.L2MerchantInstance; + } +} \ No newline at end of file diff --git a/datapack_development/data/scripts/handlers/actionhandlers/L2NpcAction.java b/datapack_development/data/scripts/handlers/actionhandlers/L2NpcAction.java new file mode 100644 index 0000000000000000000000000000000000000000..de9532c38c0b0705fbe8aec2c28f62e7955aa6ca --- /dev/null +++ b/datapack_development/data/scripts/handlers/actionhandlers/L2NpcAction.java @@ -0,0 +1,151 @@ +/* + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see <http://www.gnu.org/licenses/>. + */ +package handlers.actionhandlers; + +import com.l2jserver.gameserver.ai.CtrlIntention; +import com.l2jserver.gameserver.handler.IActionHandler; +import com.l2jserver.gameserver.model.L2Object.InstanceType; +import com.l2jserver.gameserver.model.actor.L2Character; +import com.l2jserver.gameserver.model.actor.L2Npc; +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; +import com.l2jserver.gameserver.model.entity.L2Event; +import com.l2jserver.gameserver.model.quest.Quest; +import com.l2jserver.gameserver.network.serverpackets.ActionFailed; +import com.l2jserver.gameserver.network.serverpackets.MyTargetSelected; +import com.l2jserver.gameserver.network.serverpackets.StatusUpdate; +import com.l2jserver.gameserver.network.serverpackets.ValidateLocation; +import com.l2jserver.util.Rnd; + +public class L2NpcAction implements IActionHandler +{ + /** + * Manage actions when a player click on the L2NpcInstance.<BR><BR> + * + * <B><U> Actions on first click on the L2NpcInstance (Select it)</U> :</B><BR><BR> + * <li>Set the L2NpcInstance as target of the L2PcInstance player (if necessary)</li> + * <li>Send a Server->Client packet MyTargetSelected to the L2PcInstance player (display the select window)</li> + * <li>If L2NpcInstance is autoAttackable, send a Server->Client packet StatusUpdate to the L2PcInstance in order to update L2NpcInstance HP bar </li> + * <li>Send a Server->Client packet ValidateLocation to correct the L2NpcInstance position and heading on the client </li><BR><BR> + * + * <B><U> Actions on second click on the L2NpcInstance (Attack it/Intercat with it)</U> :</B><BR><BR> + * <li>Send a Server->Client packet MyTargetSelected to the L2PcInstance player (display the select window)</li> + * <li>If L2NpcInstance is autoAttackable, notify the L2PcInstance AI with AI_INTENTION_ATTACK (after a height verification)</li> + * <li>If L2NpcInstance is NOT autoAttackable, notify the L2PcInstance AI with AI_INTENTION_INTERACT (after a distance verification) and show message</li><BR><BR> + * + * <FONT COLOR=#FF0000><B> <U>Caution</U> : Each group of Server->Client packet must be terminated by a ActionFailed packet in order to avoid + * that client wait an other packet</B></FONT><BR><BR> + * + * <B><U> Example of use </U> :</B><BR><BR> + * <li> Client packet : Action, AttackRequest</li><BR><BR> + * + * @param activeChar The L2PcInstance that start an action on the L2NpcInstance + * + */ + public boolean action(L2PcInstance activeChar, L2Character target, boolean interact) + { + if (!((L2Npc)target).canTarget(activeChar)) + return false; + + activeChar.setLastFolkNPC((L2Npc)target); + + // Check if the L2PcInstance already target the L2NpcInstance + if (target != activeChar.getTarget()) + { + // Set the target of the L2PcInstance activeChar + activeChar.setTarget(target); + + // Check if the activeChar is attackable (without a forced attack) + if (target.isAutoAttackable(activeChar)) + { + // Send a Server->Client packet MyTargetSelected to the L2PcInstance activeChar + // The activeChar.getLevel() - getLevel() permit to display the correct color in the select window + MyTargetSelected my = new MyTargetSelected(target.getObjectId(), activeChar.getLevel() - target.getLevel()); + activeChar.sendPacket(my); + + // Send a Server->Client packet StatusUpdate of the L2NpcInstance to the L2PcInstance to update its HP bar + StatusUpdate su = new StatusUpdate(target.getObjectId()); + su.addAttribute(StatusUpdate.CUR_HP, (int) target.getCurrentHp()); + su.addAttribute(StatusUpdate.MAX_HP, target.getMaxHp()); + activeChar.sendPacket(su); + } + else + { + // Send a Server->Client packet MyTargetSelected to the L2PcInstance activeChar + MyTargetSelected my = new MyTargetSelected(target.getObjectId(), 0); + activeChar.sendPacket(my); + } + + // Send a Server->Client packet ValidateLocation to correct the L2NpcInstance position and heading on the client + activeChar.sendPacket(new ValidateLocation(target)); + } + else if (interact) + { + activeChar.sendPacket(new ValidateLocation(target)); + // Check if the activeChar is attackable (without a forced attack) and isn't dead + if (target.isAutoAttackable(activeChar) && !target.isAlikeDead()) + { + // Check the height difference + if (Math.abs(activeChar.getZ() - target.getZ()) < 400) // this max heigth difference might need some tweaking + { + // Set the L2PcInstance Intention to AI_INTENTION_ATTACK + activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target); + // activeChar.startAttack(this); + } + else + { + // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet + activeChar.sendPacket(ActionFailed.STATIC_PACKET); + } + } + else if (!target.isAutoAttackable(activeChar)) + { + // Calculate the distance between the L2PcInstance and the L2NpcInstance + if (!((L2Npc)target).canInteract(activeChar)) + { + // Notify the L2PcInstance AI with AI_INTENTION_INTERACT + activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target); + } + else + { + if (((L2Npc)target).hasRandomAnimation()) + ((L2Npc)target).onRandomAnimation(Rnd.get(8)); + + // Open a chat window on client with the text of the L2NpcInstance + if (((L2Npc)target).isEventMob) + { + L2Event.showEventHtml(activeChar, String.valueOf(target.getObjectId())); + } + else + { + Quest[] qlsa = ((L2Npc)target).getTemplate().getEventQuests(Quest.QuestEventType.QUEST_START); + if ((qlsa != null) && qlsa.length > 0) + activeChar.setLastQuestNpcObject(target.getObjectId()); + Quest[] qlst = ((L2Npc)target).getTemplate().getEventQuests(Quest.QuestEventType.ON_FIRST_TALK); + if ((qlst != null) && qlst.length == 1) + qlst[0].notifyFirstTalk((L2Npc)target, activeChar); + else + ((L2Npc)target).showChatWindow(activeChar); + } + } + } + } + return true; + } + + public InstanceType getInstanceType() + { + return InstanceType.L2Npc; + } +} \ No newline at end of file diff --git a/datapack_development/data/scripts/handlers/actionhandlers/L2NpcActionShift.java b/datapack_development/data/scripts/handlers/actionhandlers/L2NpcActionShift.java new file mode 100644 index 0000000000000000000000000000000000000000..cc51890975676e2526be81b3011792a3785ec54a --- /dev/null +++ b/datapack_development/data/scripts/handlers/actionhandlers/L2NpcActionShift.java @@ -0,0 +1,347 @@ +/* + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see <http://www.gnu.org/licenses/>. + */ +package handlers.actionhandlers; + +import com.l2jserver.Config; +import com.l2jserver.gameserver.datatables.ItemTable; +import com.l2jserver.gameserver.handler.IActionHandler; +import com.l2jserver.gameserver.model.L2DropCategory; +import com.l2jserver.gameserver.model.L2DropData; +import com.l2jserver.gameserver.model.MobGroupTable; +import com.l2jserver.gameserver.model.L2Object.InstanceType; +import com.l2jserver.gameserver.model.actor.L2Attackable; +import com.l2jserver.gameserver.model.actor.L2Character; +import com.l2jserver.gameserver.model.actor.L2Npc; +import com.l2jserver.gameserver.model.actor.instance.L2ControllableMobInstance; +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; +import com.l2jserver.gameserver.network.serverpackets.MyTargetSelected; +import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage; +import com.l2jserver.gameserver.network.serverpackets.StatusUpdate; +import com.l2jserver.gameserver.skills.Stats; +import com.l2jserver.gameserver.templates.item.L2Item; +import com.l2jserver.gameserver.util.StringUtil; + +public class L2NpcActionShift implements IActionHandler +{ + /** + * Manage and Display the GM console to modify the L2NpcInstance (GM only).<BR><BR> + * + * <B><U> Actions (If the L2PcInstance is a GM only)</U> :</B><BR><BR> + * <li>Set the L2NpcInstance as target of the L2PcInstance player (if necessary)</li> + * <li>Send a Server->Client packet MyTargetSelected to the L2PcInstance player (display the select window)</li> + * <li>If L2NpcInstance is autoAttackable, send a Server->Client packet StatusUpdate to the L2PcInstance in order to update L2NpcInstance HP bar </li> + * <li>Send a Server->Client NpcHtmlMessage() containing the GM console about this L2NpcInstance </li><BR><BR> + * + * <FONT COLOR=#FF0000><B> <U>Caution</U> : Each group of Server->Client packet must be terminated by a ActionFailed packet in order to avoid + * that client wait an other packet</B></FONT><BR><BR> + * + * <B><U> Example of use </U> :</B><BR><BR> + * <li> Client packet : Action</li><BR><BR> + */ + public boolean action(L2PcInstance activeChar, L2Character target, boolean interact) + { + // Check if the L2PcInstance is a GM + if (activeChar.getAccessLevel().isGm()) + { + // Set the target of the L2PcInstance activeChar + activeChar.setTarget(target); + + // Send a Server->Client packet MyTargetSelected to the L2PcInstance activeChar + // The activeChar.getLevel() - getLevel() permit to display the correct color in the select window + MyTargetSelected my = new MyTargetSelected(target.getObjectId(), activeChar.getLevel() - target.getLevel()); + activeChar.sendPacket(my); + + // Check if the activeChar is attackable (without a forced attack) + if (target.isAutoAttackable(activeChar)) + { + // Send a Server->Client packet StatusUpdate of the L2NpcInstance to the L2PcInstance to update its HP bar + StatusUpdate su = new StatusUpdate(target.getObjectId()); + su.addAttribute(StatusUpdate.CUR_HP, (int) target.getCurrentHp()); + su.addAttribute(StatusUpdate.MAX_HP, target.getMaxHp()); + activeChar.sendPacket(su); + } + + // Send a Server->Client NpcHtmlMessage() containing the GM console about this L2NpcInstance + NpcHtmlMessage html = new NpcHtmlMessage(0); + final StringBuilder html1 = StringUtil.startAppend(500, + "<html><body><center><font color=\"LEVEL\">NPC Info</font></center><br>" + + "Instance Type: ", + getClass().getSimpleName(), + "<br1>Faction: ", + ((L2Npc)target).getFactionId() != null ? ((L2Npc)target).getFactionId() : "null" + ); + StringUtil.append(html1, + "<br1>Coords: ", + String.valueOf(target.getX()), + ", ", + String.valueOf(target.getY()), + ", ", + String.valueOf(target.getZ()) + ); + if (((L2Npc)target).getSpawn() != null) + StringUtil.append(html1, + "<br1>Spawn: ", + String.valueOf(((L2Npc)target).getSpawn().getLocx()), + ", ", + String.valueOf(((L2Npc)target).getSpawn().getLocy()), + ", ", + String.valueOf(((L2Npc)target).getSpawn().getLocz()), + " ; Loc ID: ", + String.valueOf(((L2Npc)target).getSpawn().getLocation()), + "<br1>Distance from spawn 2D: ", + String.valueOf((int)Math.sqrt(target.getPlanDistanceSq(((L2Npc)target).getSpawn().getLocx(), ((L2Npc)target).getSpawn().getLocy()))), + " ; 3D: ", + String.valueOf((int)Math.sqrt(target.getDistanceSq(((L2Npc)target).getSpawn().getLocx(), ((L2Npc)target).getSpawn().getLocy(), ((L2Npc)target).getSpawn().getLocz()))) + ); + + if (target.isInstanceType(InstanceType.L2ControllableMobInstance)) + { + StringUtil.append(html1, + "<br1>Mob Group: ", + String.valueOf(MobGroupTable.getInstance().getGroupForMob((L2ControllableMobInstance) target).getGroupId()), + "<br>" + ); + } + else + { + StringUtil.append(html1, + "<br1>Respawn Time: ", + (((L2Npc)target).getSpawn() != null ? String.valueOf(((L2Npc)target).getSpawn().getRespawnDelay() / 1000) : "?"), + " Seconds<br>" + ); + } + + StringUtil.append(html1, + "<table border=\"0\" width=\"100%\">" + + "<tr><td>Level</td><td>", + String.valueOf(target.getLevel()), + "</td><td> </td><td>NPC ID</td><td>", + String.valueOf(((L2Npc)target).getTemplate().npcId), + "</td></tr>" + + "<tr><td>Aggro</td><td>" + + String.valueOf((target.isInstanceType(InstanceType.L2Attackable)) ? ((L2Attackable) target).getAggroRange() : 0), + "</td><td> </td><td>Object ID</td><td>", + String.valueOf(target.getObjectId()), + "</td></tr>" + + "<tr><td>Castle</td><td>", + String.valueOf(((L2Npc)target).getCastle().getCastleId()), + "</td><td> </td><td>AI </td><td>", + (target.hasAI() ? String.valueOf(target.getAI().getIntention().name()) : "NULL"), + "</td></tr>" + + "</table><br>" + + "<font color=\"LEVEL\">Combat</font>" + + "<table border=\"0\" width=\"100%\">" + + "<tr><td>Current HP</td><td>", + String.valueOf(target.getCurrentHp()), + "</td><td>Current MP</td><td>", + String.valueOf(target.getCurrentMp()), + "</td></tr>" + + "<tr><td>Max.HP</td><td>", + String.valueOf((int) (target.getMaxHp() / target.getStat().calcStat(Stats.MAX_HP, 1, target, null))), + "*", + String.valueOf((int) (target.getStat().calcStat(Stats.MAX_HP, 1, target, null))), + "</td><td>Max.MP</td><td>", + String.valueOf(target.getMaxMp()), + "</td></tr>" + + "<tr><td>P.Atk.</td><td>", + String.valueOf(target.getPAtk(null)), + "</td><td>M.Atk.</td><td>", + String.valueOf(target.getMAtk(null, null)), + "</td></tr>" + + "<tr><td>P.Def.</td><td>", + String.valueOf(target.getPDef(null)), + "</td><td>M.Def.</td><td>", + String.valueOf(target.getMDef(null, null)), + "</td></tr>" + + "<tr><td>Accuracy</td><td>" + + String.valueOf(target.getAccuracy()), + "</td><td>Evasion</td><td>", + String.valueOf(target.getEvasionRate(null)), + "</td></tr>" + + "<tr><td>Critical</td><td>", + String.valueOf(target.getCriticalHit(null, null)), + "</td><td>Speed</td><td>", + String.valueOf(target.getRunSpeed()), + "</td></tr>" + + "<tr><td>Atk.Speed</td><td>", + String.valueOf(target.getPAtkSpd()), + "</td><td>Cast.Speed</td><td>", + String.valueOf(target.getMAtkSpd()), + "</td></tr>" + + "</table><br>" + + "<font color=\"LEVEL\">Basic Stats</font>" + + "<table border=\"0\" width=\"100%\">" + + "<tr><td>STR</td><td>", + String.valueOf(target.getSTR()), + "</td><td>DEX</td><td>", + String.valueOf(target.getDEX()), + "</td><td>CON</td><td>", + String.valueOf(target.getCON()), + "</td></tr>" + + "<tr><td>INT</td><td>", + String.valueOf(target.getINT()), + "</td><td>WIT</td><td>", + String.valueOf(target.getWIT()), + "</td><td>MEN</td><td>", + String.valueOf(target.getMEN()), + "</td></tr>" + + "</table>" + + "<br><center><table><tr><td><button value=\"Edit NPC\" action=\"bypass -h admin_edit_npc ", + String.valueOf(((L2Npc)target).getTemplate().npcId), + "\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><br1></td>" + + "<td><button value=\"Kill\" action=\"bypass -h admin_kill\" width=40 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><br1></tr>" + + "<tr><td><button value=\"Show DropList\" action=\"bypass -h admin_show_droplist ", + String.valueOf(((L2Npc)target).getTemplate().npcId), + "\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>" + + "<td><button value=\"Delete\" action=\"bypass -h admin_delete\" width=40 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>" + + "<tr><td><button value=\"Show SkillList\" action=\"bypass -h admin_show_skilllist_npc ", + String.valueOf(((L2Npc)target).getTemplate().npcId), + "\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td></td></tr></table></center><br></body></html>" + ); + + html.setHtml(html1.toString()); + activeChar.sendPacket(html); + } + else if (Config.ALT_GAME_VIEWNPC) + { + // Set the target of the L2PcInstance activeChar + activeChar.setTarget(target); + + // Send a Server->Client packet MyTargetSelected to the L2PcInstance activeChar + // The activeChar.getLevel() - getLevel() permit to display the correct color in the select window + MyTargetSelected my = new MyTargetSelected(target.getObjectId(), activeChar.getLevel() - target.getLevel()); + activeChar.sendPacket(my); + + // Check if the activeChar is attackable (without a forced attack) + if (target.isAutoAttackable(activeChar)) + { + // Send a Server->Client packet StatusUpdate of the L2NpcInstance to the L2PcInstance to update its HP bar + StatusUpdate su = new StatusUpdate(target.getObjectId()); + su.addAttribute(StatusUpdate.CUR_HP, (int) target.getCurrentHp()); + su.addAttribute(StatusUpdate.MAX_HP, target.getMaxHp()); + activeChar.sendPacket(su); + } + + NpcHtmlMessage html = new NpcHtmlMessage(0); + final StringBuilder html1 = StringUtil.startAppend( + 1000, + "<html><body>" + + "<br><center><font color=\"LEVEL\">[Combat Stats]</font></center>" + + "<table border=0 width=\"100%\">" + + "<tr><td>Max.HP</td><td>", + String.valueOf((int) (target.getMaxHp() / target.getStat().calcStat(Stats.MAX_HP, 1, target, null))), + "*", + String.valueOf((int) target.getStat().calcStat(Stats.MAX_HP, 1, target, null)), + "</td><td>Max.MP</td><td>", + String.valueOf(target.getMaxMp()), + "</td></tr>" + + "<tr><td>P.Atk.</td><td>", + String.valueOf(target.getPAtk(null)), + "</td><td>M.Atk.</td><td>", + String.valueOf(target.getMAtk(null, null)), + "</td></tr>" + + "<tr><td>P.Def.</td><td>", + String.valueOf(target.getPDef(null)), + "</td><td>M.Def.</td><td>", + String.valueOf(target.getMDef(null, null)), + "</td></tr>" + + "<tr><td>Accuracy</td><td>", + String.valueOf(target.getAccuracy()), + "</td><td>Evasion</td><td>", + String.valueOf(target.getEvasionRate(null)), + "</td></tr>" + + "<tr><td>Critical</td><td>", + String.valueOf(target.getCriticalHit(null, null)), + "</td><td>Speed</td><td>", + String.valueOf(target.getRunSpeed()), + "</td></tr>" + + "<tr><td>Atk.Speed</td><td>", + String.valueOf(target.getPAtkSpd()), + "</td><td>Cast.Speed</td><td>", + String.valueOf(target.getMAtkSpd()), + "</td></tr>" + + "<tr><td>Race</td><td>", + ((L2Npc)target).getTemplate().getRace().toString(), + "</td><td></td><td></td></tr>" + + "</table>" + + "<br><center><font color=\"LEVEL\">[Basic Stats]</font></center>" + + "<table border=0 width=\"100%\">" + + "<tr><td>STR</td><td>", + String.valueOf(target.getSTR()), + "</td><td>DEX</td><td>", + String.valueOf(target.getDEX()), + "</td><td>CON</td><td>", + String.valueOf(target.getCON()), + "</td></tr>" + + "<tr><td>INT</td><td>", + String.valueOf(target.getINT()), + "</td><td>WIT</td><td>", + String.valueOf(target.getWIT()), + "</td><td>MEN</td><td>", + String.valueOf(target.getMEN()), + "</td></tr>" + + "</table>" + ); + + if (((L2Npc)target).getTemplate().getDropData() != null) + { + StringUtil.append(html1, + "<br><center><font color=\"LEVEL\">[Drop Info]</font></center>" + + "<br>Rates legend: <font color=\"ff0000\">50%+</font> <font color=\"00ff00\">30%+</font> <font color=\"0000ff\">less than 30%</font>" + + "<table border=0 width=\"100%\">" + ); + for (L2DropCategory cat : ((L2Npc)target).getTemplate().getDropData()) + { + for (L2DropData drop : cat.getAllDrops()) + { + final L2Item item = ItemTable.getInstance().getTemplate(drop.getItemId()); + if (item == null) + continue; + + final String color; + + if (drop.getChance() >= 500000) + color = "ff0000"; + else if (drop.getChance() >= 300000) + color = "00ff00"; + else + color = "0000ff"; + + StringUtil.append(html1, + "<tr><td><font color=\"", + color, + "\">", + item.getName(), + "</font></td><td>", + (drop.isQuestDrop() ? "Quest" : (cat.isSweep() ? "Sweep" : "Drop")), + "</td></tr>" + ); + } + } + html1.append("</table>"); + } + html1.append("</body></html>"); + + html.setHtml(html1.toString()); + activeChar.sendPacket(html); + } + return true; + } + + public InstanceType getInstanceType() + { + return InstanceType.L2Npc; + } +} diff --git a/datapack_development/data/scripts/handlers/actionhandlers/L2PcInstanceAction.java b/datapack_development/data/scripts/handlers/actionhandlers/L2PcInstanceAction.java new file mode 100644 index 0000000000000000000000000000000000000000..a9050de01a063aa27b44fcdd7f031a00274c5414 --- /dev/null +++ b/datapack_development/data/scripts/handlers/actionhandlers/L2PcInstanceAction.java @@ -0,0 +1,137 @@ +/* + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see <http://www.gnu.org/licenses/>. + */ +package handlers.actionhandlers; + +import com.l2jserver.Config; +import com.l2jserver.gameserver.GeoData; +import com.l2jserver.gameserver.ai.CtrlIntention; +import com.l2jserver.gameserver.handler.IActionHandler; +import com.l2jserver.gameserver.model.L2Object.InstanceType; +import com.l2jserver.gameserver.model.actor.L2Character; +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; +import com.l2jserver.gameserver.model.entity.TvTEvent; +import com.l2jserver.gameserver.network.SystemMessageId; +import com.l2jserver.gameserver.network.serverpackets.ActionFailed; +import com.l2jserver.gameserver.network.serverpackets.MyTargetSelected; +import com.l2jserver.gameserver.network.serverpackets.SystemMessage; +import com.l2jserver.gameserver.network.serverpackets.ValidateLocation; + +public class L2PcInstanceAction implements IActionHandler +{ + /** + * Manage actions when a player click on this L2PcInstance.<BR><BR> + * + * <B><U> Actions on first click on the L2PcInstance (Select it)</U> :</B><BR><BR> + * <li>Set the target of the player</li> + * <li>Send a Server->Client packet MyTargetSelected to the player (display the select window)</li><BR><BR> + * + * <B><U> Actions on second click on the L2PcInstance (Follow it/Attack it/Intercat with it)</U> :</B><BR><BR> + * <li>Send a Server->Client packet MyTargetSelected to the player (display the select window)</li> + * <li>If target L2PcInstance has a Private Store, notify the player AI with AI_INTENTION_INTERACT</li> + * <li>If target L2PcInstance is autoAttackable, notify the player AI with AI_INTENTION_ATTACK</li><BR><BR> + * <li>If target L2PcInstance is NOT autoAttackable, notify the player AI with AI_INTENTION_FOLLOW</li><BR><BR> + * + * <B><U> Example of use </U> :</B><BR><BR> + * <li> Client packet : Action, AttackRequest</li><BR><BR> + * + * @param activeChar The player that start an action on target L2PcInstance + * + */ + public boolean action(L2PcInstance activeChar, L2Character target, boolean interact) + { + // See description in TvTEvent.java + if (!TvTEvent.onAction( activeChar, target.getObjectId())) + return false; + + // Check if the L2PcInstance is confused + if (activeChar.isOutOfControl()) + return false; + + // Aggression target lock effect + if (activeChar.isLockedTarget() && activeChar.getLockedTarget() != target) + { + activeChar.sendPacket(new SystemMessage(SystemMessageId.FAILED_CHANGE_TARGET)); + return false; + } + + // Check if the activeChar already target this L2PcInstance + if (activeChar.getTarget() != target) + { + // Set the target of the activeChar + activeChar.setTarget(target); + + // Send a Server->Client packet MyTargetSelected to the activeChar + // The color to display in the select window is White + activeChar.sendPacket(new MyTargetSelected(target.getObjectId(), 0)); + if (activeChar != target) activeChar.sendPacket(new ValidateLocation(target)); + } + else if (interact) + { + if (activeChar != target) activeChar.sendPacket(new ValidateLocation(target)); + // Check if this L2PcInstance has a Private Store + if (((L2PcInstance)target).getPrivateStoreType() != 0) + { + activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target); + } + else + { + // Check if this L2PcInstance is autoAttackable + if (target.isAutoAttackable(activeChar)) + { + // activeChar with lvl < 21 can't attack a cursed weapon holder + // And a cursed weapon holder can't attack activeChars with lvl < 21 + if ((((L2PcInstance)target).isCursedWeaponEquipped() && activeChar.getLevel() < 21) + || (activeChar.isCursedWeaponEquipped() && target.getLevel() < 21)) + { + activeChar.sendPacket(ActionFailed.STATIC_PACKET); + } + else + { + if (Config.GEODATA > 0) + { + if (GeoData.getInstance().canSeeTarget(activeChar, target)) + { + activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target); + activeChar.onActionRequest(); + } + } + else + { + activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target); + activeChar.onActionRequest(); + } + } + } else + { + // This Action Failed packet avoids activeChar getting stuck when clicking three or more times + activeChar.sendPacket(ActionFailed.STATIC_PACKET); + if (Config.GEODATA > 0) + { + if(GeoData.getInstance().canSeeTarget(activeChar, target)) + activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, target); + } + else + activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, target); + } + } + } + return true; + } + + public InstanceType getInstanceType() + { + return InstanceType.L2PcInstance; + } +} diff --git a/datapack_development/data/scripts/handlers/actionhandlers/L2PcInstanceActionShift.java b/datapack_development/data/scripts/handlers/actionhandlers/L2PcInstanceActionShift.java new file mode 100644 index 0000000000000000000000000000000000000000..6a95986cfb69aa4c62343eee5c00435b2ed1490b --- /dev/null +++ b/datapack_development/data/scripts/handlers/actionhandlers/L2PcInstanceActionShift.java @@ -0,0 +1,57 @@ +/* + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see <http://www.gnu.org/licenses/>. + */ +package handlers.actionhandlers; + +import com.l2jserver.gameserver.handler.AdminCommandHandler; +import com.l2jserver.gameserver.handler.IActionHandler; +import com.l2jserver.gameserver.handler.IAdminCommandHandler; +import com.l2jserver.gameserver.model.L2Object.InstanceType; +import com.l2jserver.gameserver.model.actor.L2Character; +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; +import com.l2jserver.gameserver.network.serverpackets.MyTargetSelected; +import com.l2jserver.gameserver.network.serverpackets.ValidateLocation; + +public class L2PcInstanceActionShift implements IActionHandler +{ + public boolean action(L2PcInstance activeChar, L2Character target, boolean interact) + { + if (activeChar.isGM()) + { + // Check if the gm already target this l2pcinstance + if (activeChar.getTarget() != target) + { + // Set the target of the L2PcInstance activeChar + activeChar.setTarget(target); + + // Send a Server->Client packet MyTargetSelected to the L2PcInstance activeChar + activeChar.sendPacket(new MyTargetSelected(target.getObjectId(), 0)); + } + + // Send a Server->Client packet ValidateLocation to correct the L2PcInstance position and heading on the client + if (activeChar != target) + activeChar.sendPacket(new ValidateLocation(target)); + + IAdminCommandHandler ach = AdminCommandHandler.getInstance().getAdminCommandHandler("admin_character_info"); + if (ach != null) + ach.useAdminCommand("admin_character_info " + target.getName(), activeChar); + } + return true; + } + + public InstanceType getInstanceType() + { + return InstanceType.L2PcInstance; + } +} diff --git a/datapack_development/data/scripts/handlers/actionhandlers/L2PetInstanceAction.java b/datapack_development/data/scripts/handlers/actionhandlers/L2PetInstanceAction.java new file mode 100644 index 0000000000000000000000000000000000000000..70dff1e72656b8faa50b718fe45bc712e835f583 --- /dev/null +++ b/datapack_development/data/scripts/handlers/actionhandlers/L2PetInstanceAction.java @@ -0,0 +1,113 @@ +/* + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see <http://www.gnu.org/licenses/>. + */ +package handlers.actionhandlers; + +import com.l2jserver.Config; +import com.l2jserver.gameserver.GeoData; +import com.l2jserver.gameserver.ai.CtrlIntention; +import com.l2jserver.gameserver.handler.IActionHandler; +import com.l2jserver.gameserver.model.L2Object.InstanceType; +import com.l2jserver.gameserver.model.actor.L2Character; +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; +import com.l2jserver.gameserver.model.actor.instance.L2PetInstance; +import com.l2jserver.gameserver.network.SystemMessageId; +import com.l2jserver.gameserver.network.serverpackets.MyTargetSelected; +import com.l2jserver.gameserver.network.serverpackets.PetStatusShow; +import com.l2jserver.gameserver.network.serverpackets.StatusUpdate; +import com.l2jserver.gameserver.network.serverpackets.SystemMessage; +import com.l2jserver.gameserver.network.serverpackets.ValidateLocation; + +public class L2PetInstanceAction implements IActionHandler +{ + public boolean action(L2PcInstance activeChar, L2Character target, boolean interact) + { + // Aggression target lock effect + if (activeChar.isLockedTarget() && activeChar.getLockedTarget() != target) + { + activeChar.sendPacket(new SystemMessage(SystemMessageId.FAILED_CHANGE_TARGET)); + return false; + } + + boolean isOwner = activeChar.getObjectId() == ((L2PetInstance)target).getOwner().getObjectId(); + + activeChar.sendPacket(new ValidateLocation(target)); + if(isOwner && activeChar != ((L2PetInstance)target).getOwner()) + ((L2PetInstance)target).updateRefOwner(activeChar); + if (activeChar.getTarget() != target) + { + if (Config.DEBUG) + _log.fine("new target selected:" + target.getObjectId()); + + // Set the target of the L2PcInstance activeChar + activeChar.setTarget(target); + + activeChar.sendPacket(new MyTargetSelected(target.getObjectId(), activeChar.getLevel() - target.getLevel())); + + // Send a Server->Client packet StatusUpdate of the L2PetInstance to the L2PcInstance to update its HP bar + StatusUpdate su = new StatusUpdate(target.getObjectId()); + su.addAttribute(StatusUpdate.CUR_HP, (int) target.getCurrentHp()); + su.addAttribute(StatusUpdate.MAX_HP, target.getMaxHp()); + activeChar.sendPacket(su); + } + else if (interact) + { + // Check if the pet is attackable (without a forced attack) and isn't dead + if (target.isAutoAttackable(activeChar) && !isOwner) + { + if (Config.GEODATA > 0) + { + if (GeoData.getInstance().canSeeTarget(activeChar, target)) + { + // Set the L2PcInstance Intention to AI_INTENTION_ATTACK + activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target); + activeChar.onActionRequest(); + } + } + else + { + activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target); + activeChar.onActionRequest(); + } + } + else if (!target.isInsideRadius(activeChar, 150, false, false)) + { + if (Config.GEODATA > 0) + { + if (GeoData.getInstance().canSeeTarget(activeChar, target)) + { + activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target); + activeChar.onActionRequest(); + } + } + else + { + activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target); + activeChar.onActionRequest(); + } + } + else + { + if (isOwner) + activeChar.sendPacket(new PetStatusShow((L2PetInstance)target)); + } + } + return true; + } + + public InstanceType getInstanceType() + { + return InstanceType.L2PetInstance; + } +} \ No newline at end of file diff --git a/datapack_development/data/scripts/handlers/actionhandlers/L2StaticObjectInstanceAction.java b/datapack_development/data/scripts/handlers/actionhandlers/L2StaticObjectInstanceAction.java new file mode 100644 index 0000000000000000000000000000000000000000..c3cc081a801aec3bd0da6008734a3f3497a17396 --- /dev/null +++ b/datapack_development/data/scripts/handlers/actionhandlers/L2StaticObjectInstanceAction.java @@ -0,0 +1,78 @@ +/* + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see <http://www.gnu.org/licenses/>. + */ +package handlers.actionhandlers; + +import com.l2jserver.gameserver.ai.CtrlIntention; +import com.l2jserver.gameserver.cache.HtmCache; +import com.l2jserver.gameserver.handler.IActionHandler; +import com.l2jserver.gameserver.model.L2Object.InstanceType; +import com.l2jserver.gameserver.model.actor.L2Character; +import com.l2jserver.gameserver.model.actor.L2Npc; +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; +import com.l2jserver.gameserver.model.actor.instance.L2StaticObjectInstance; +import com.l2jserver.gameserver.network.serverpackets.MyTargetSelected; +import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage; + +public class L2StaticObjectInstanceAction implements IActionHandler +{ + public boolean action(L2PcInstance activeChar, L2Character target, boolean interact) + { + if(((L2StaticObjectInstance)target).getType() < 0) + _log.info("L2StaticObjectInstance: StaticObject with invalid type! StaticObjectId: "+((L2StaticObjectInstance)target).getStaticObjectId()); + + // Check if the L2PcInstance already target the L2NpcInstance + if (activeChar.getTarget() != target) + { + // Set the target of the L2PcInstance activeChar + activeChar.setTarget(target); + activeChar.sendPacket(new MyTargetSelected(target.getObjectId(), 0)); + } + else if (interact) + { + activeChar.sendPacket(new MyTargetSelected(target.getObjectId(), 0)); + + // Calculate the distance between the L2PcInstance and the L2NpcInstance + if (!activeChar.isInsideRadius(target, L2Npc.INTERACTION_DISTANCE, false, false)) + { + // Notify the L2PcInstance AI with AI_INTENTION_INTERACT + activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target); + } + else + { + if(((L2StaticObjectInstance)target).getType() == 2) + { + String filename = "data/html/signboard.htm"; + String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), filename); + NpcHtmlMessage html = new NpcHtmlMessage(target.getObjectId()); + + if (content == null) + html.setHtml("<html><body>Signboard is missing:<br>"+filename+"</body></html>"); + else + html.setHtml(content); + + activeChar.sendPacket(html); + } + else if(((L2StaticObjectInstance)target).getType() == 0) + activeChar.sendPacket(((L2StaticObjectInstance)target).getMap()); + } + } + return true; + } + + public InstanceType getInstanceType() + { + return InstanceType.L2StaticObjectInstance; + } +} \ No newline at end of file diff --git a/datapack_development/data/scripts/handlers/actionhandlers/L2StaticObjectInstanceActionShift.java b/datapack_development/data/scripts/handlers/actionhandlers/L2StaticObjectInstanceActionShift.java new file mode 100644 index 0000000000000000000000000000000000000000..a4303cea6575046a358919d10e6c643797fdf184 --- /dev/null +++ b/datapack_development/data/scripts/handlers/actionhandlers/L2StaticObjectInstanceActionShift.java @@ -0,0 +1,67 @@ +/* + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see <http://www.gnu.org/licenses/>. + */ +package handlers.actionhandlers; + +import com.l2jserver.gameserver.handler.IActionHandler; +import com.l2jserver.gameserver.model.L2Object.InstanceType; +import com.l2jserver.gameserver.model.actor.L2Character; +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; +import com.l2jserver.gameserver.model.actor.instance.L2StaticObjectInstance; +import com.l2jserver.gameserver.network.serverpackets.MyTargetSelected; +import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage; +import com.l2jserver.gameserver.network.serverpackets.StaticObject; +import com.l2jserver.gameserver.util.StringUtil; + +public class L2StaticObjectInstanceActionShift implements IActionHandler +{ + public boolean action(L2PcInstance activeChar, L2Character target, boolean interact) + { + if (activeChar.getAccessLevel().isGm()) + { + activeChar.setTarget(target); + activeChar.sendPacket(new MyTargetSelected(target.getObjectId(), activeChar.getLevel())); + + StaticObject su = new StaticObject((L2StaticObjectInstance)target); + activeChar.sendPacket(su); + + NpcHtmlMessage html = new NpcHtmlMessage(target.getObjectId()); + final String html1 = StringUtil.concat( + "<html><body><center><font color=\"LEVEL\">Static Object Info</font></center><br><table border=0><tr><td>Coords X,Y,Z: </td><td>", + String.valueOf(target.getX()), + ", ", + String.valueOf(target.getY()), + ", ", + String.valueOf(target.getZ()), + "</td></tr><tr><td>Object ID: </td><td>", + String.valueOf(target.getObjectId()), + "</td></tr><tr><td>Static Object ID: </td><td>", + String.valueOf(((L2StaticObjectInstance)target).getStaticObjectId()), + "</td></tr><tr><td>Mesh Index: </td><td>", + String.valueOf(((L2StaticObjectInstance)target).getMeshIndex()), + "</td></tr><tr><td><br></td></tr><tr><td>Class: </td><td>", + target.getClass().getSimpleName(), + "</td></tr></table></body></html>" + ); + html.setHtml(html1); + activeChar.sendPacket(html); + } + return true; + } + + public InstanceType getInstanceType() + { + return InstanceType.L2StaticObjectInstance; + } +} diff --git a/datapack_development/data/scripts/handlers/actionhandlers/L2SummonAction.java b/datapack_development/data/scripts/handlers/actionhandlers/L2SummonAction.java new file mode 100644 index 0000000000000000000000000000000000000000..79bf761b9cec42bf6ef7993ad7410d45c0763f42 --- /dev/null +++ b/datapack_development/data/scripts/handlers/actionhandlers/L2SummonAction.java @@ -0,0 +1,105 @@ +/* + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see <http://www.gnu.org/licenses/>. + */ +package handlers.actionhandlers; + +import com.l2jserver.Config; +import com.l2jserver.gameserver.GeoData; +import com.l2jserver.gameserver.ai.CtrlIntention; +import com.l2jserver.gameserver.handler.IActionHandler; +import com.l2jserver.gameserver.model.L2Object.InstanceType; +import com.l2jserver.gameserver.model.actor.L2Character; +import com.l2jserver.gameserver.model.actor.L2Summon; +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; +import com.l2jserver.gameserver.network.SystemMessageId; +import com.l2jserver.gameserver.network.serverpackets.ActionFailed; +import com.l2jserver.gameserver.network.serverpackets.MyTargetSelected; +import com.l2jserver.gameserver.network.serverpackets.PetStatusShow; +import com.l2jserver.gameserver.network.serverpackets.StatusUpdate; +import com.l2jserver.gameserver.network.serverpackets.SystemMessage; +import com.l2jserver.gameserver.network.serverpackets.ValidateLocation; + +public class L2SummonAction implements IActionHandler +{ + public boolean action(L2PcInstance activeChar, L2Character target, boolean interact) + { + // Aggression target lock effect + if (activeChar.isLockedTarget() && activeChar.getLockedTarget() != target) + { + activeChar.sendPacket(new SystemMessage(SystemMessageId.FAILED_CHANGE_TARGET)); + return false; + } + + + if (activeChar == ((L2Summon)target).getOwner() && activeChar.getTarget() == target) + { + activeChar.sendPacket(new PetStatusShow((L2Summon)target)); + activeChar.sendPacket(ActionFailed.STATIC_PACKET); + } + else if (activeChar.getTarget() != target) + { + if (Config.DEBUG) + _log.fine("new target selected:"+target.getObjectId()); + + activeChar.setTarget(target); + activeChar.sendPacket(new ValidateLocation(target)); + MyTargetSelected my = new MyTargetSelected(target.getObjectId(), activeChar.getLevel() - target.getLevel()); + activeChar.sendPacket(my); + + //sends HP/MP status of the summon to other characters + StatusUpdate su = new StatusUpdate(target.getObjectId()); + su.addAttribute(StatusUpdate.CUR_HP, (int) target.getCurrentHp()); + su.addAttribute(StatusUpdate.MAX_HP, target.getMaxHp()); + activeChar.sendPacket(su); + } + else if (interact) + { + activeChar.sendPacket(new ValidateLocation(target)); + if (target.isAutoAttackable(activeChar)) + { + if (Config.GEODATA > 0) + { + if (GeoData.getInstance().canSeeTarget(activeChar, target)) + { + activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target); + activeChar.onActionRequest(); + } + } + else + { + activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target); + activeChar.onActionRequest(); + } + } + else + { + // This Action Failed packet avoids activeChar getting stuck when clicking three or more times + activeChar.sendPacket(ActionFailed.STATIC_PACKET); + if (Config.GEODATA > 0) + { + if (GeoData.getInstance().canSeeTarget(activeChar, target)) + activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, target); + } + else + activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, target); + } + } + return true; + } + + public InstanceType getInstanceType() + { + return InstanceType.L2Summon; + } +} diff --git a/datapack_development/data/scripts/handlers/actionhandlers/L2SummonActionShift.java b/datapack_development/data/scripts/handlers/actionhandlers/L2SummonActionShift.java new file mode 100644 index 0000000000000000000000000000000000000000..baf447538932fb51014ef891b5e2df85b737aa82 --- /dev/null +++ b/datapack_development/data/scripts/handlers/actionhandlers/L2SummonActionShift.java @@ -0,0 +1,55 @@ +/* + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see <http://www.gnu.org/licenses/>. + */ +package handlers.actionhandlers; + +import com.l2jserver.gameserver.handler.AdminCommandHandler; +import com.l2jserver.gameserver.handler.IActionHandler; +import com.l2jserver.gameserver.handler.IAdminCommandHandler; +import com.l2jserver.gameserver.model.L2Object.InstanceType; +import com.l2jserver.gameserver.model.actor.L2Character; +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; +import com.l2jserver.gameserver.network.serverpackets.MyTargetSelected; +import com.l2jserver.gameserver.network.serverpackets.ValidateLocation; + +public class L2SummonActionShift implements IActionHandler +{ + public boolean action(L2PcInstance activeChar, L2Character target, boolean interact) + { + if (activeChar.isGM()) + { + if (activeChar.getTarget() != target) + { + // Set the target of the L2PcInstance activeChar + activeChar.setTarget(target); + + // Send a Server->Client packet MyTargetSelected to the L2PcInstance activeChar + activeChar.sendPacket(new MyTargetSelected(target.getObjectId(), 0)); + } + + // Send a Server->Client packet ValidateLocation to correct the L2PcInstance position and heading on the client + activeChar.sendPacket(new ValidateLocation(target)); + + IAdminCommandHandler ach = AdminCommandHandler.getInstance().getAdminCommandHandler("admin_summon_info"); + if (ach != null) + ach.useAdminCommand("admin_summon_info", activeChar); + } + return true; + } + + public InstanceType getInstanceType() + { + return InstanceType.L2Summon; + } +} \ No newline at end of file diff --git a/datapack_development/data/scripts/handlers/actionhandlers/L2TrapAction.java b/datapack_development/data/scripts/handlers/actionhandlers/L2TrapAction.java new file mode 100644 index 0000000000000000000000000000000000000000..1325ff8ca26137d27b5bbc550c908a186ba1363a --- /dev/null +++ b/datapack_development/data/scripts/handlers/actionhandlers/L2TrapAction.java @@ -0,0 +1,46 @@ +/* + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see <http://www.gnu.org/licenses/>. + */ +package handlers.actionhandlers; + +import com.l2jserver.gameserver.handler.IActionHandler; +import com.l2jserver.gameserver.model.L2Object.InstanceType; +import com.l2jserver.gameserver.model.actor.L2Character; +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; +import com.l2jserver.gameserver.network.SystemMessageId; +import com.l2jserver.gameserver.network.serverpackets.MyTargetSelected; +import com.l2jserver.gameserver.network.serverpackets.SystemMessage; + +public class L2TrapAction implements IActionHandler +{ + public boolean action(L2PcInstance activeChar, L2Character target, boolean interact) + { + // Aggression target lock effect + if (activeChar.isLockedTarget() && activeChar.getLockedTarget() != target) + { + activeChar.sendPacket(new SystemMessage(SystemMessageId.FAILED_CHANGE_TARGET)); + return false; + } + + activeChar.setTarget(target); + MyTargetSelected my = new MyTargetSelected(target.getObjectId(), activeChar.getLevel()- target.getLevel()); + activeChar.sendPacket(my); + return true; + } + + public InstanceType getInstanceType() + { + return InstanceType.L2Trap; + } +} \ No newline at end of file diff --git a/datapack_development/data/scripts/handlers/bypasshandlers/ClanWarehouse.java b/datapack_development/data/scripts/handlers/bypasshandlers/ClanWarehouse.java index 2a277ca3558e57bb03f4e309c5be515335e448fe..b8b454aa6eac46a6ea2ce87bde01434a02bc4b54 100644 --- a/datapack_development/data/scripts/handlers/bypasshandlers/ClanWarehouse.java +++ b/datapack_development/data/scripts/handlers/bypasshandlers/ClanWarehouse.java @@ -41,8 +41,7 @@ public class ClanWarehouse implements IBypassHandler public boolean useBypass(String command, L2PcInstance activeChar, L2Character target) { - if (!(target.isInstanceType(InstanceType.L2WarehouseInstance) - || target.isInstanceType(InstanceType.L2ClanHallManagerInstance))) + if (!target.isInstanceType(InstanceType.L2WarehouseInstance, InstanceType.L2ClanHallManagerInstance)) return false; if (activeChar.isEnchanting())