Merged with released L2J-Unity files.
This commit is contained in:
@@ -1,100 +1,102 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.handler.IActionHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2DoorInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.clanhall.SiegableHall;
|
||||
import com.l2jmobius.gameserver.model.holders.DoorRequestHolder;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ConfirmDlg;
|
||||
|
||||
public class L2DoorInstanceAction implements IActionHandler
|
||||
{
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
// Check if the L2PcInstance already target the L2NpcInstance
|
||||
if (activeChar.getTarget() != target)
|
||||
{
|
||||
activeChar.setTarget(target);
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
final L2DoorInstance door = (L2DoorInstance) target;
|
||||
// MyTargetSelected my = new MyTargetSelected(getObjectId(), activeChar.getLevel());
|
||||
// activeChar.sendPacket(my);
|
||||
if (target.isAutoAttackable(activeChar))
|
||||
{
|
||||
if (Math.abs(activeChar.getZ() - target.getZ()) < 400)
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
|
||||
}
|
||||
}
|
||||
else if ((activeChar.getClan() != null) && (door.getClanHall() != null) && (activeChar.getClanId() == door.getClanHall().getOwnerId()))
|
||||
{
|
||||
if (!door.isInsideRadius(activeChar, L2Npc.INTERACTION_DISTANCE, false, false))
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
|
||||
}
|
||||
else if (!door.getClanHall().isSiegableHall() || !((SiegableHall) door.getClanHall()).isInSiege())
|
||||
{
|
||||
activeChar.addScript(new DoorRequestHolder(door));
|
||||
if (!door.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).isOpenableBySkill() && !((L2DoorInstance) target).getFort().getSiege().isInProgress())
|
||||
{
|
||||
if (!((L2Character) target).isInsideRadius(activeChar, L2Npc.INTERACTION_DISTANCE, false, false))
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.addScript(new DoorRequestHolder((L2DoorInstance) target));
|
||||
if (!((L2DoorInstance) target).getOpen())
|
||||
{
|
||||
activeChar.sendPacket(new ConfirmDlg(1140));
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(new ConfirmDlg(1141));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2DoorInstance;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ClanHallData;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.handler.IActionHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2DoorInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.ClanHall;
|
||||
import com.l2jmobius.gameserver.model.holders.DoorRequestHolder;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ConfirmDlg;
|
||||
|
||||
public class L2DoorInstanceAction implements IActionHandler
|
||||
{
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
// Check if the L2PcInstance already target the L2NpcInstance
|
||||
if (activeChar.getTarget() != target)
|
||||
{
|
||||
activeChar.setTarget(target);
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
final L2DoorInstance door = (L2DoorInstance) target;
|
||||
final ClanHall clanHall = ClanHallData.getInstance().getClanHallByDoorId(door.getId());
|
||||
// MyTargetSelected my = new MyTargetSelected(getObjectId(), activeChar.getLevel());
|
||||
// activeChar.sendPacket(my);
|
||||
if (target.isAutoAttackable(activeChar))
|
||||
{
|
||||
if (Math.abs(activeChar.getZ() - target.getZ()) < 400)
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
|
||||
}
|
||||
}
|
||||
else if ((activeChar.getClan() != null) && (clanHall != null) && (activeChar.getClanId() == clanHall.getOwnerId()))
|
||||
{
|
||||
if (!door.isInsideRadius(activeChar, L2Npc.INTERACTION_DISTANCE, false, false))
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.addScript(new DoorRequestHolder(door));
|
||||
if (!door.isOpen())
|
||||
{
|
||||
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).isOpenableBySkill() && !((L2DoorInstance) target).getFort().getSiege().isInProgress())
|
||||
{
|
||||
if (!((L2Character) target).isInsideRadius(activeChar, L2Npc.INTERACTION_DISTANCE, false, false))
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.addScript(new DoorRequestHolder((L2DoorInstance) target));
|
||||
if (!((L2DoorInstance) target).isOpen())
|
||||
{
|
||||
activeChar.sendPacket(new ConfirmDlg(1140));
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(new ConfirmDlg(1141));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2DoorInstance;
|
||||
}
|
||||
}
|
||||
|
@@ -1,62 +1,59 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.handler.IActionHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.MercTicketManager;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
public class L2ItemInstanceAction implements IActionHandler
|
||||
{
|
||||
@Override
|
||||
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(target.getId());
|
||||
|
||||
if ((castleId > 0) && (!activeChar.isCastleLord(castleId) || activeChar.isInParty()))
|
||||
{
|
||||
if (activeChar.isInParty())
|
||||
{
|
||||
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())
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_PICK_UP, target);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2ItemInstance;
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.handler.IActionHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.SiegeGuardManager;
|
||||
import com.l2jmobius.gameserver.model.ClanPrivilege;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.Castle;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
public class L2ItemInstanceAction implements IActionHandler
|
||||
{
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
final Castle castle = CastleManager.getInstance().getCastle(target);
|
||||
if ((castle != null) && (SiegeGuardManager.getInstance().getSiegeGuardByItem(castle.getResidenceId(), target.getId()) != null))
|
||||
{
|
||||
if ((activeChar.getClan() == null) || (castle.getOwnerId() != activeChar.getClanId()) || !activeChar.hasClanPrivilege(ClanPrivilege.CS_MERCENARIES))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_AUTHORITY_TO_CANCEL_MERCENARY_POSITIONING);
|
||||
activeChar.setTarget(target);
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!activeChar.isFlying())
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_PICK_UP, target);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2ItemInstance;
|
||||
}
|
||||
}
|
@@ -1,145 +1,150 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.GeoData;
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.handler.IActionHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.L2Event;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.events.EventType;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.npc.OnNpcFirstTalk;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MoveToPawn;
|
||||
import com.l2jmobius.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
|
||||
*/
|
||||
@Override
|
||||
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
|
||||
}
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
// Check if the activeChar is attackable (without a forced attack) and isn't dead
|
||||
if (target.isAutoAttackable(activeChar) && !((L2Npc) target).isAlikeDead())
|
||||
{
|
||||
if (GeoData.getInstance().canSeeTarget(activeChar, target))
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, GeoData.getInstance().moveCheck(activeChar, target));
|
||||
}
|
||||
}
|
||||
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
|
||||
{
|
||||
final L2Npc npc = (L2Npc) target;
|
||||
// Turn NPC to the player.
|
||||
activeChar.sendPacket(new MoveToPawn(activeChar, npc, 100));
|
||||
if (npc.hasRandomAnimation())
|
||||
{
|
||||
npc.onRandomAnimation(Rnd.get(8));
|
||||
}
|
||||
// Open a chat window on client with the text of the L2Npc
|
||||
if (npc.isEventMob())
|
||||
{
|
||||
L2Event.showEventHtml(activeChar, String.valueOf(target.getObjectId()));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (npc.hasListener(EventType.ON_NPC_QUEST_START))
|
||||
{
|
||||
activeChar.setLastQuestNpcObject(target.getObjectId());
|
||||
}
|
||||
if (npc.hasListener(EventType.ON_NPC_FIRST_TALK))
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcFirstTalk(npc, activeChar), npc);
|
||||
}
|
||||
else
|
||||
{
|
||||
npc.showChatWindow(activeChar);
|
||||
}
|
||||
}
|
||||
if ((Config.PLAYER_MOVEMENT_BLOCK_TIME > 0) && !activeChar.isGM())
|
||||
{
|
||||
activeChar.updateNotMoveUntil();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2Npc;
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.util.Rnd;
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.handler.IActionHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.L2Event;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.events.EventType;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.npc.OnNpcFirstTalk;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MoveToPawn;
|
||||
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
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
|
||||
}
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
// 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
|
||||
{
|
||||
final L2Npc npc = (L2Npc) target;
|
||||
// Turn NPC to the player.
|
||||
activeChar.sendPacket(new MoveToPawn(activeChar, npc, 100));
|
||||
if (npc.hasRandomAnimation())
|
||||
{
|
||||
npc.onRandomAnimation(Rnd.get(8));
|
||||
}
|
||||
// Open a chat window on client with the text of the L2Npc
|
||||
if (npc.getVariables().getBoolean("eventmob", false))
|
||||
{
|
||||
L2Event.showEventHtml(activeChar, String.valueOf(target.getObjectId()));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (npc.hasListener(EventType.ON_NPC_QUEST_START))
|
||||
{
|
||||
activeChar.setLastQuestNpcObject(target.getObjectId());
|
||||
}
|
||||
if (npc.hasListener(EventType.ON_NPC_FIRST_TALK))
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcFirstTalk(npc, activeChar), npc);
|
||||
}
|
||||
else
|
||||
{
|
||||
npc.showChatWindow(activeChar);
|
||||
}
|
||||
}
|
||||
if ((Config.PLAYER_MOVEMENT_BLOCK_TIME > 0) && !activeChar.isGM())
|
||||
{
|
||||
activeChar.updateNotMoveUntil();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2Npc;
|
||||
}
|
||||
}
|
@@ -1,135 +1,122 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.GeoData;
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.enums.PrivateStoreType;
|
||||
import com.l2jmobius.gameserver.handler.IActionHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.TvTEvent;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
|
||||
public class L2PcInstanceAction implements IActionHandler
|
||||
{
|
||||
private static final int CURSED_WEAPON_VICTIM_MIN_LEVEL = 21;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
@Override
|
||||
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(SystemMessageId.FAILED_TO_CHANGE_ENMITY);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the activeChar already target this L2PcInstance
|
||||
if (activeChar.getTarget() != target)
|
||||
{
|
||||
// Set the target of the activeChar
|
||||
activeChar.setTarget(target);
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
final L2PcInstance player = target.getActingPlayer();
|
||||
// Check if this L2PcInstance has a Private Store
|
||||
if (player.getPrivateStoreType() != PrivateStoreType.NONE)
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, player);
|
||||
}
|
||||
// Check if this L2PcInstance is autoAttackable
|
||||
else if (player.isAutoAttackable(activeChar))
|
||||
{
|
||||
if ((player.isCursedWeaponEquipped() && (activeChar.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)) //
|
||||
|| (activeChar.isCursedWeaponEquipped() && (player.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)))
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GeoData.getInstance().canSeeTarget(activeChar, player))
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, GeoData.getInstance().moveCheck(activeChar, player));
|
||||
}
|
||||
activeChar.onActionRequest();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// This Action Failed packet avoids activeChar getting stuck when clicking three or more times
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
if (GeoData.getInstance().canSeeTarget(activeChar, player))
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, player);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, GeoData.getInstance().moveCheck(activeChar, player));
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2PcInstance;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.GeoData;
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.enums.PrivateStoreType;
|
||||
import com.l2jmobius.gameserver.handler.IActionHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
// Check if the L2PcInstance is confused
|
||||
if (activeChar.isControlBlocked())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Aggression target lock effect
|
||||
if (activeChar.isLockedTarget() && (activeChar.getLockedTarget() != target))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.FAILED_TO_CHANGE_ENMITY);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the activeChar already target this L2PcInstance
|
||||
if (activeChar.getTarget() != target)
|
||||
{
|
||||
// Set the target of the activeChar
|
||||
activeChar.setTarget(target);
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
// Check if this L2PcInstance has a Private Store
|
||||
if (((L2PcInstance) target).getPrivateStoreType() != PrivateStoreType.NONE)
|
||||
{
|
||||
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 (GeoData.getInstance().canSeeTarget(activeChar, target))
|
||||
{
|
||||
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 (GeoData.getInstance().canSeeTarget(activeChar, target))
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2PcInstance;
|
||||
}
|
||||
}
|
||||
|
@@ -1,84 +1,87 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.cache.HtmCache;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.handler.IActionHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2StaticObjectInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
public class L2StaticObjectInstanceAction implements IActionHandler
|
||||
{
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
final L2StaticObjectInstance staticObject = (L2StaticObjectInstance) target;
|
||||
if (staticObject.getType() < 0)
|
||||
{
|
||||
_log.info("L2StaticObjectInstance: StaticObject with invalid type! StaticObjectId: " + staticObject.getId());
|
||||
}
|
||||
|
||||
// Check if the L2PcInstance already target the L2NpcInstance
|
||||
if (activeChar.getTarget() != staticObject)
|
||||
{
|
||||
// Set the target of the L2PcInstance activeChar
|
||||
activeChar.setTarget(staticObject);
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
// Calculate the distance between the L2PcInstance and the L2NpcInstance
|
||||
if (!activeChar.isInsideRadius(staticObject, L2Npc.INTERACTION_DISTANCE, false, false))
|
||||
{
|
||||
// Notify the L2PcInstance AI with AI_INTENTION_INTERACT
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, staticObject);
|
||||
}
|
||||
else if (staticObject.getType() == 2)
|
||||
{
|
||||
final String filename = (staticObject.getId() == 24230101) ? "html/signboards/tomb_of_crystalgolem.htm" : "html/signboards/pvp_signboard.htm";
|
||||
final String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), filename);
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(staticObject.getObjectId());
|
||||
|
||||
if (content != null)
|
||||
{
|
||||
html.setHtml(content);
|
||||
}
|
||||
else
|
||||
{
|
||||
html.setHtml("<html><body>Signboard is missing:<br>" + filename + "</body></html>");
|
||||
}
|
||||
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
else if (staticObject.getType() == 0)
|
||||
{
|
||||
activeChar.sendPacket(staticObject.getMap());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2StaticObjectInstance;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.cache.HtmCache;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.handler.IActionHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2StaticObjectInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
public class L2StaticObjectInstanceAction implements IActionHandler
|
||||
{
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
final L2StaticObjectInstance staticObject = (L2StaticObjectInstance) target;
|
||||
if (staticObject.getType() < 0)
|
||||
{
|
||||
_log.info("L2StaticObjectInstance: StaticObject with invalid type! StaticObjectId: " + staticObject.getId());
|
||||
}
|
||||
|
||||
// Check if the L2PcInstance already target the L2NpcInstance
|
||||
if (activeChar.getTarget() != staticObject)
|
||||
{
|
||||
// Set the target of the L2PcInstance activeChar
|
||||
activeChar.setTarget(staticObject);
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
// Calculate the distance between the L2PcInstance and the L2NpcInstance
|
||||
if (!activeChar.isInsideRadius(staticObject, L2Npc.INTERACTION_DISTANCE, false, false))
|
||||
{
|
||||
// Notify the L2PcInstance AI with AI_INTENTION_INTERACT
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, staticObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (staticObject.getType() == 2)
|
||||
{
|
||||
final String filename = (staticObject.getId() == 24230101) ? "data/html/signboards/tomb_of_crystalgolem.htm" : "data/html/signboards/pvp_signboard.htm";
|
||||
final String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), filename);
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(staticObject.getObjectId());
|
||||
|
||||
if (content == null)
|
||||
{
|
||||
html.setHtml("<html><body>Signboard is missing:<br>" + filename + "</body></html>");
|
||||
}
|
||||
else
|
||||
{
|
||||
html.setHtml(content);
|
||||
}
|
||||
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
else if (staticObject.getType() == 0)
|
||||
{
|
||||
activeChar.sendPacket(staticObject.getMap());
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2StaticObjectInstance;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user