actual freya branch
This commit is contained in:
+80
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 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;
|
||||
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, L2Object 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((L2Character)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;
|
||||
}
|
||||
}
|
||||
+46
@@ -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;
|
||||
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, L2Object target, boolean interact)
|
||||
{
|
||||
// Aggression target lock effect
|
||||
if (activeChar.isLockedTarget() && activeChar.getLockedTarget() != target)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.FAILED_CHANGE_TARGET));
|
||||
return false;
|
||||
}
|
||||
|
||||
activeChar.setTarget(target);
|
||||
activeChar.sendPacket(new MyTargetSelected(target.getObjectId(), activeChar.getLevel()- ((L2Character)target).getLevel()));
|
||||
return true;
|
||||
}
|
||||
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2Decoy;
|
||||
}
|
||||
}
|
||||
+113
@@ -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.gameserver.ai.CtrlIntention;
|
||||
import com.l2jserver.gameserver.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
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, L2Object 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((L2Character)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 (!((L2Character)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 (!((L2Character)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;
|
||||
}
|
||||
}
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* 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;
|
||||
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;
|
||||
|
||||
public class L2DoorInstanceActionShift implements IActionHandler
|
||||
{
|
||||
public boolean action(L2PcInstance activeChar, L2Object 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(0);
|
||||
html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/doorinfo.htm");
|
||||
html.replace("%class%", target.getClass().getSimpleName());
|
||||
html.replace("%hp%", String.valueOf((int)((L2Character)target).getCurrentHp()));
|
||||
html.replace("%hpmax%", String.valueOf(((L2Character)target).getMaxHp()));
|
||||
html.replace("%objid%", String.valueOf(target.getObjectId()));
|
||||
html.replace("%doorid%", String.valueOf(((L2DoorInstance)target).getDoorId()));
|
||||
|
||||
html.replace("%minx%", String.valueOf(((L2DoorInstance)target).getXMin()));
|
||||
html.replace("%miny%", String.valueOf(((L2DoorInstance)target).getYMin()));
|
||||
html.replace("%minz%", String.valueOf(((L2DoorInstance)target).getZMin()));
|
||||
|
||||
html.replace("%maxx%", String.valueOf(((L2DoorInstance)target).getXMax()));
|
||||
html.replace("%maxy%", String.valueOf(((L2DoorInstance)target).getYMax()));
|
||||
html.replace("%maxz%", String.valueOf(((L2DoorInstance)target).getZMax()));
|
||||
html.replace("%unlock%", ((L2DoorInstance)target).isUnlockable() ? "<font color=00FF00>YES<font>" : "<font color=FF0000>NO</font>");
|
||||
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2DoorInstance;
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.instancemanager.MercTicketManager;
|
||||
import com.l2jserver.gameserver.model.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Object.InstanceType;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
public class L2ItemInstanceAction implements IActionHandler
|
||||
{
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
// this causes the validate position handler to do the pickup if the location is reached.
|
||||
// mercenary tickets can only be picked up by the castle owner.
|
||||
final int castleId = MercTicketManager.getInstance().getTicketCastleId(((L2ItemInstance)target).getItemId());
|
||||
|
||||
if (castleId > 0 && (!activeChar.isCastleLord(castleId) || activeChar.isInParty()))
|
||||
{
|
||||
if (activeChar.isInParty()) //do not allow owner who is in party to pick tickets up
|
||||
activeChar.sendMessage("You cannot pickup mercenaries while in a party.");
|
||||
else
|
||||
activeChar.sendMessage("Only the castle lord can pickup mercenaries.");
|
||||
|
||||
activeChar.setTarget(target);
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
|
||||
}
|
||||
else if (!activeChar.isFlying()) // cannot pickup
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_PICK_UP, target);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2ItemInstance;
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Object.InstanceType;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
public class L2ItemInstanceActionShift implements IActionHandler
|
||||
{
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
if (activeChar.getAccessLevel().isGm())
|
||||
{
|
||||
NpcHtmlMessage html = new NpcHtmlMessage(target.getObjectId());
|
||||
final String html1 = StringUtil.concat(
|
||||
"<html><body><center><font color=\"LEVEL\">Item Info</font></center><br><table border=0>",
|
||||
"<tr><td>Object ID: </td><td>",
|
||||
String.valueOf(target.getObjectId()),
|
||||
"</td></tr><tr><td>Item ID: </td><td>",
|
||||
String.valueOf(((L2ItemInstance)target).getItemId()),
|
||||
"</td></tr><tr><td>Owner ID: </td><td>",
|
||||
String.valueOf(((L2ItemInstance)target).getOwnerId()),
|
||||
"</td></tr><tr><td>Location: </td><td>",
|
||||
String.valueOf(((L2ItemInstance)target).getLocation()),
|
||||
"</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.L2ItemInstance;
|
||||
}
|
||||
}
|
||||
+153
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* 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;
|
||||
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 L2Npc.<BR><BR>
|
||||
*
|
||||
* <B><U> Actions on first click on the L2Npc (Select it)</U> :</B><BR><BR>
|
||||
* <li>Set the L2Npc 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 L2Npc is autoAttackable, send a Server->Client packet StatusUpdate to the L2PcInstance in order to update L2Npc HP bar </li>
|
||||
* <li>Send a Server->Client packet ValidateLocation to correct the L2Npc position and heading on the client </li><BR><BR>
|
||||
*
|
||||
* <B><U> Actions on second click on the L2Npc (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 L2Npc is autoAttackable, notify the L2PcInstance AI with AI_INTENTION_ATTACK (after a height verification)</li>
|
||||
* <li>If L2Npc 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 L2Npc
|
||||
*
|
||||
*/
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
if (!((L2Npc)target).canTarget(activeChar))
|
||||
return false;
|
||||
|
||||
activeChar.setLastFolkNPC((L2Npc)target);
|
||||
|
||||
// Check if the L2PcInstance already target the L2Npc
|
||||
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))
|
||||
{
|
||||
((L2Npc)target).getAI(); //wake up ai
|
||||
// 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() - ((L2Character)target).getLevel());
|
||||
activeChar.sendPacket(my);
|
||||
|
||||
// Send a Server->Client packet StatusUpdate of the L2Npc to the L2PcInstance to update its HP bar
|
||||
StatusUpdate su = new StatusUpdate(target);
|
||||
su.addAttribute(StatusUpdate.CUR_HP, (int) ((L2Character)target).getCurrentHp());
|
||||
su.addAttribute(StatusUpdate.MAX_HP, ((L2Character)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 L2Npc position and heading on the client
|
||||
activeChar.sendPacket(new ValidateLocation((L2Character)target));
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
activeChar.sendPacket(new ValidateLocation((L2Character)target));
|
||||
// Check if the activeChar is attackable (without a forced attack) and isn't dead
|
||||
if (target.isAutoAttackable(activeChar) && !((L2Character)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 L2Npc
|
||||
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 L2Npc
|
||||
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;
|
||||
}
|
||||
}
|
||||
+298
@@ -0,0 +1,298 @@
|
||||
/*
|
||||
* 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.Elementals;
|
||||
import com.l2jserver.gameserver.model.L2DropCategory;
|
||||
import com.l2jserver.gameserver.model.L2DropData;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
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.L2MerchantInstance;
|
||||
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.BaseStats;
|
||||
import com.l2jserver.gameserver.skills.Stats;
|
||||
import com.l2jserver.gameserver.templates.item.L2Item;
|
||||
import com.l2jserver.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, L2Object 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() - ((L2Character)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);
|
||||
su.addAttribute(StatusUpdate.CUR_HP, (int)((L2Character)target).getCurrentHp());
|
||||
su.addAttribute(StatusUpdate.MAX_HP, ((L2Character)target).getMaxHp());
|
||||
activeChar.sendPacket(su);
|
||||
}
|
||||
|
||||
NpcHtmlMessage html = new NpcHtmlMessage(0);
|
||||
html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/npcinfo.htm");
|
||||
|
||||
html.replace("%objid%", String.valueOf(target.getObjectId()));
|
||||
html.replace("%class%", target.getClass().getSimpleName());
|
||||
html.replace("%id%", String.valueOf(((L2Npc)target).getTemplate().npcId));
|
||||
html.replace("%lvl%", String.valueOf(((L2Npc)target).getTemplate().level));
|
||||
html.replace("%name%", String.valueOf(((L2Npc)target).getTemplate().name));
|
||||
html.replace("%tmplid%",String.valueOf(((L2Npc)target).getTemplate().npcId));
|
||||
html.replace("%aggro%", String.valueOf((target instanceof L2Attackable) ? ((L2Attackable) target).getAggroRange() : 0));
|
||||
html.replace("%hp%", String.valueOf((int)((L2Character)target).getCurrentHp()));
|
||||
html.replace("%hpmax%", String.valueOf(((L2Character)target).getMaxHp()));
|
||||
html.replace("%mp%", String.valueOf((int)((L2Character)target).getCurrentMp()));
|
||||
html.replace("%mpmax%", String.valueOf(((L2Character)target).getMaxMp()));
|
||||
|
||||
html.replace("%patk%", String.valueOf(((L2Character)target).getPAtk(null)));
|
||||
html.replace("%matk%", String.valueOf(((L2Character)target).getMAtk(null, null)));
|
||||
html.replace("%pdef%", String.valueOf(((L2Character)target).getPDef(null)));
|
||||
html.replace("%mdef%", String.valueOf(((L2Character)target).getMDef(null, null)));
|
||||
html.replace("%accu%", String.valueOf(((L2Character)target).getAccuracy()));
|
||||
html.replace("%evas%", String.valueOf(((L2Character)target).getEvasionRate(null)));
|
||||
html.replace("%crit%", String.valueOf(((L2Character)target).getCriticalHit(null, null)));
|
||||
html.replace("%rspd%", String.valueOf(((L2Character)target).getRunSpeed()));
|
||||
html.replace("%aspd%", String.valueOf(((L2Character)target).getPAtkSpd()));
|
||||
html.replace("%cspd%", String.valueOf(((L2Character)target).getMAtkSpd()));
|
||||
html.replace("%str%", String.valueOf(((L2Character)target).getSTR()));
|
||||
html.replace("%dex%", String.valueOf(((L2Character)target).getDEX()));
|
||||
html.replace("%con%", String.valueOf(((L2Character)target).getCON()));
|
||||
html.replace("%int%", String.valueOf(((L2Character)target).getINT()));
|
||||
html.replace("%wit%", String.valueOf(((L2Character)target).getWIT()));
|
||||
html.replace("%men%", String.valueOf(((L2Character)target).getMEN()));
|
||||
html.replace("%loc%", String.valueOf(target.getX()+" "+target.getY()+" "+target.getZ()));
|
||||
html.replace("%dist%", String.valueOf((int)Math.sqrt(activeChar.getDistanceSq(target))));
|
||||
|
||||
byte attackAttribute = ((L2Character)target).getAttackElement();
|
||||
html.replace("%ele_atk%", Elementals.getElementName(attackAttribute));
|
||||
html.replace("%ele_atk_value%", String.valueOf(((L2Character)target).getAttackElementValue(attackAttribute)));
|
||||
html.replace("%ele_dfire%", String.valueOf(((L2Character)target).getDefenseElementValue(Elementals.FIRE)));
|
||||
html.replace("%ele_dwater%", String.valueOf(((L2Character)target).getDefenseElementValue(Elementals.WATER)));
|
||||
html.replace("%ele_dwind%", String.valueOf(((L2Character)target).getDefenseElementValue(Elementals.WIND)));
|
||||
html.replace("%ele_dearth%", String.valueOf(((L2Character)target).getDefenseElementValue(Elementals.EARTH)));
|
||||
html.replace("%ele_dholy%", String.valueOf(((L2Character)target).getDefenseElementValue(Elementals.HOLY)));
|
||||
html.replace("%ele_ddark%", String.valueOf(((L2Character)target).getDefenseElementValue(Elementals.DARK)));
|
||||
|
||||
if (((L2Npc)target).getSpawn() != null)
|
||||
{
|
||||
html.replace("%spawn%", ((L2Npc)target).getSpawn().getLocx()+" "+((L2Npc)target).getSpawn().getLocy()+" "+((L2Npc)target).getSpawn().getLocz());
|
||||
html.replace("%loc2d%", String.valueOf((int)Math.sqrt(((L2Character)target).getPlanDistanceSq(((L2Npc)target).getSpawn().getLocx(), ((L2Npc)target).getSpawn().getLocy()))));
|
||||
html.replace("%loc3d%", String.valueOf((int)Math.sqrt(((L2Character)target).getDistanceSq(((L2Npc)target).getSpawn().getLocx(), ((L2Npc)target).getSpawn().getLocy(), ((L2Npc)target).getSpawn().getLocz()))));
|
||||
html.replace("%resp%", String.valueOf(((L2Npc)target).getSpawn().getRespawnDelay() / 1000));
|
||||
}
|
||||
else
|
||||
{
|
||||
html.replace("%spawn%", "<font color=FF0000>null</font>");
|
||||
html.replace("%loc2d%", "<font color=FF0000>--</font>");
|
||||
html.replace("%loc3d%", "<font color=FF0000>--</font>");
|
||||
html.replace("%resp%", "<font color=FF0000>--</font>");
|
||||
}
|
||||
|
||||
if (((L2Npc)target).hasAI())
|
||||
{
|
||||
html.replace("%ai_intention%", "<tr><td><table width=270 border=0 bgcolor=131210><tr><td width=100><font color=FFAA00>Intention:</font></td><td align=right width=170>"+String.valueOf(((L2Npc)target).getAI().getIntention().name())+"</td></tr></table></td></tr>");
|
||||
html.replace("%ai%", "<tr><td><table width=270 border=0><tr><td width=100><font color=FFAA00>AI</font></td><td align=right width=170>"+((L2Npc)target).getAI().getClass().getSimpleName()+"</td></tr></table></td></tr>");
|
||||
html.replace("%ai_type%", "<tr><td><table width=270 border=0 bgcolor=131210><tr><td width=100><font color=FFAA00>AIType</font></td><td align=right width=170>"+String.valueOf(((L2Npc)target).getAiType())+"</td></tr></table></td></tr>");
|
||||
html.replace("%ai_clan%", "<tr><td><table width=270 border=0><tr><td width=100><font color=FFAA00>Clan & Range:</font></td><td align=right width=170>"+String.valueOf(((L2Npc)target).getTemplate().getAIDataStatic().getClan())+" "+String.valueOf(((L2Npc)target).getTemplate().getAIDataStatic().getClanRange())+"</td></tr></table></td></tr>");
|
||||
html.replace("%ai_enemy_clan%", "<tr><td><table width=270 border=0 bgcolor=131210><tr><td width=100><font color=FFAA00>Enemy & Range:</font></td><td align=right width=170>"+String.valueOf(((L2Npc)target).getTemplate().getAIDataStatic().getEnemyClan())+" "+String.valueOf(((L2Npc)target).getTemplate().getAIDataStatic().getEnemyRange())+"</td></tr></table></td></tr>");
|
||||
}
|
||||
else
|
||||
{
|
||||
html.replace("%ai_intention%", "");
|
||||
html.replace("%ai%", "");
|
||||
html.replace("%ai_type%", "");
|
||||
html.replace("%ai_clan%", "");
|
||||
html.replace("%ai_enemy_clan%", "");
|
||||
}
|
||||
|
||||
if (target instanceof L2MerchantInstance)
|
||||
{
|
||||
html.replace("%butt%","<button value=\"Shop\" action=\"bypass -h admin_showShop "+String.valueOf(((L2Npc)target).getTemplate().npcId)+"\" width=60 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
|
||||
}
|
||||
else
|
||||
{
|
||||
html.replace("%butt%","");
|
||||
}
|
||||
|
||||
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() - ((L2Character)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);
|
||||
su.addAttribute(StatusUpdate.CUR_HP, (int) ((L2Character)target).getCurrentHp());
|
||||
su.addAttribute(StatusUpdate.MAX_HP, ((L2Character)target).getMaxHp());
|
||||
activeChar.sendPacket(su);
|
||||
}
|
||||
|
||||
NpcHtmlMessage html = new NpcHtmlMessage(0);
|
||||
int hpMul = Math.round((float)(((L2Character)target).getStat().calcStat(Stats.MAX_HP, 1, (L2Character)target, null) / BaseStats.CON.calcBonus((L2Character)target)));
|
||||
if (hpMul == 0)
|
||||
hpMul = 1;
|
||||
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(((L2Character)target).getMaxHp() / hpMul),
|
||||
"*",
|
||||
String.valueOf(hpMul),
|
||||
"</td><td>Max.MP</td><td>",
|
||||
String.valueOf(((L2Character)target).getMaxMp()),
|
||||
"</td></tr>" +
|
||||
"<tr><td>P.Atk.</td><td>",
|
||||
String.valueOf(((L2Character)target).getPAtk(null)),
|
||||
"</td><td>M.Atk.</td><td>",
|
||||
String.valueOf(((L2Character)target).getMAtk(null, null)),
|
||||
"</td></tr>" +
|
||||
"<tr><td>P.Def.</td><td>",
|
||||
String.valueOf(((L2Character)target).getPDef(null)),
|
||||
"</td><td>M.Def.</td><td>",
|
||||
String.valueOf(((L2Character)target).getMDef(null, null)),
|
||||
"</td></tr>" +
|
||||
"<tr><td>Accuracy</td><td>",
|
||||
String.valueOf(((L2Character)target).getAccuracy()),
|
||||
"</td><td>Evasion</td><td>",
|
||||
String.valueOf(((L2Character)target).getEvasionRate(null)),
|
||||
"</td></tr>" +
|
||||
"<tr><td>Critical</td><td>",
|
||||
String.valueOf(((L2Character)target).getCriticalHit(null, null)),
|
||||
"</td><td>Speed</td><td>",
|
||||
String.valueOf(((L2Character)target).getRunSpeed()),
|
||||
"</td></tr>" +
|
||||
"<tr><td>Atk.Speed</td><td>",
|
||||
String.valueOf(((L2Character)target).getPAtkSpd()),
|
||||
"</td><td>Cast.Speed</td><td>",
|
||||
String.valueOf(((L2Character)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(((L2Character)target).getSTR()),
|
||||
"</td><td>DEX</td><td>",
|
||||
String.valueOf(((L2Character)target).getDEX()),
|
||||
"</td><td>CON</td><td>",
|
||||
String.valueOf(((L2Character)target).getCON()),
|
||||
"</td></tr>" +
|
||||
"<tr><td>INT</td><td>",
|
||||
String.valueOf(((L2Character)target).getINT()),
|
||||
"</td><td>WIT</td><td>",
|
||||
String.valueOf(((L2Character)target).getWIT()),
|
||||
"</td><td>MEN</td><td>",
|
||||
String.valueOf(((L2Character)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;
|
||||
}
|
||||
}
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* 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;
|
||||
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, L2Object 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(SystemMessage.getSystemMessage(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((L2Character)target));
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
if (activeChar != target) activeChar.sendPacket(new ValidateLocation((L2Character)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() && ((L2Character)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;
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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;
|
||||
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, L2Object 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((L2Character)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;
|
||||
}
|
||||
}
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* 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;
|
||||
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, L2Object target, boolean interact)
|
||||
{
|
||||
// Aggression target lock effect
|
||||
if (activeChar.isLockedTarget() && activeChar.getLockedTarget() != target)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.FAILED_CHANGE_TARGET));
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean isOwner = activeChar.getObjectId() == ((L2PetInstance)target).getOwner().getObjectId();
|
||||
|
||||
activeChar.sendPacket(new ValidateLocation((L2Character)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() - ((L2Character)target).getLevel()));
|
||||
|
||||
// Send a Server->Client packet StatusUpdate of the L2PetInstance to the L2PcInstance to update its HP bar
|
||||
StatusUpdate su = new StatusUpdate(target);
|
||||
su.addAttribute(StatusUpdate.CUR_HP, (int) ((L2Character)target).getCurrentHp());
|
||||
su.addAttribute(StatusUpdate.MAX_HP, ((L2Character)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 (!((L2Character)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;
|
||||
}
|
||||
}
|
||||
Vendored
+78
@@ -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;
|
||||
import com.l2jserver.gameserver.model.L2Object.InstanceType;
|
||||
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, L2Object 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;
|
||||
}
|
||||
}
|
||||
Vendored
+67
@@ -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;
|
||||
import com.l2jserver.gameserver.model.L2Object.InstanceType;
|
||||
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.util.StringUtil;
|
||||
|
||||
public class L2StaticObjectInstanceActionShift implements IActionHandler
|
||||
{
|
||||
public boolean action(L2PcInstance activeChar, L2Object 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;
|
||||
}
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* 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;
|
||||
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, L2Object target, boolean interact)
|
||||
{
|
||||
// Aggression target lock effect
|
||||
if (activeChar.isLockedTarget() && activeChar.getLockedTarget() != target)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(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((L2Character)target));
|
||||
MyTargetSelected my = new MyTargetSelected(target.getObjectId(), activeChar.getLevel() - ((L2Character)target).getLevel());
|
||||
activeChar.sendPacket(my);
|
||||
|
||||
//sends HP/MP status of the summon to other characters
|
||||
StatusUpdate su = new StatusUpdate(target);
|
||||
su.addAttribute(StatusUpdate.CUR_HP, (int) ((L2Character)target).getCurrentHp());
|
||||
su.addAttribute(StatusUpdate.MAX_HP, ((L2Character)target).getMaxHp());
|
||||
activeChar.sendPacket(su);
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
activeChar.sendPacket(new ValidateLocation((L2Character)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;
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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;
|
||||
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, L2Object 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((L2Character)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;
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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;
|
||||
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, L2Object target, boolean interact)
|
||||
{
|
||||
// Aggression target lock effect
|
||||
if (activeChar.isLockedTarget() && activeChar.getLockedTarget() != target)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.FAILED_CHANGE_TARGET));
|
||||
return false;
|
||||
}
|
||||
|
||||
activeChar.setTarget(target);
|
||||
MyTargetSelected my = new MyTargetSelected(target.getObjectId(), activeChar.getLevel()- ((L2Character)target).getLevel());
|
||||
activeChar.sendPacket(my);
|
||||
return true;
|
||||
}
|
||||
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2Trap;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user