This commit is contained in:
71
trunk/dist/game/data/scripts/handlers/actionhandlers/L2ArtefactInstanceAction.java
vendored
Normal file
71
trunk/dist/game/data/scripts/handlers/actionhandlers/L2ArtefactInstanceAction.java
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack 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.
|
||||
*
|
||||
* L2J DataPack 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.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
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>
|
||||
*/
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
if (!((L2Npc) target).canTarget(activeChar))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (activeChar.getTarget() != target)
|
||||
{
|
||||
activeChar.setTarget(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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2ArtefactInstance;
|
||||
}
|
||||
}
|
48
trunk/dist/game/data/scripts/handlers/actionhandlers/L2DecoyAction.java
vendored
Normal file
48
trunk/dist/game/data/scripts/handlers/actionhandlers/L2DecoyAction.java
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack 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.
|
||||
*
|
||||
* L2J DataPack 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.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
|
||||
public class L2DecoyAction implements IActionHandler
|
||||
{
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
// Aggression target lock effect
|
||||
if (activeChar.isLockedTarget() && (activeChar.getLockedTarget() != target))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.FAILED_TO_CHANGE_ENMITY);
|
||||
return false;
|
||||
}
|
||||
|
||||
activeChar.setTarget(target);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2Decoy;
|
||||
}
|
||||
}
|
102
trunk/dist/game/data/scripts/handlers/actionhandlers/L2DoorInstanceAction.java
vendored
Normal file
102
trunk/dist/game/data/scripts/handlers/actionhandlers/L2DoorInstanceAction.java
vendored
Normal file
@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack 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.
|
||||
*
|
||||
* L2J DataPack 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.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
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.model.entity.clanhall.SiegableHall;
|
||||
import com.l2jserver.gameserver.model.holders.DoorRequestHolder;
|
||||
import com.l2jserver.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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
64
trunk/dist/game/data/scripts/handlers/actionhandlers/L2ItemInstanceAction.java
vendored
Normal file
64
trunk/dist/game/data/scripts/handlers/actionhandlers/L2ItemInstanceAction.java
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack 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.
|
||||
*
|
||||
* L2J DataPack 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.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.MercTicketManager;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.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;
|
||||
}
|
||||
}
|
149
trunk/dist/game/data/scripts/handlers/actionhandlers/L2NpcAction.java
vendored
Normal file
149
trunk/dist/game/data/scripts/handlers/actionhandlers/L2NpcAction.java
vendored
Normal file
@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack 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.
|
||||
*
|
||||
* L2J DataPack 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.ai.CtrlIntention;
|
||||
import com.l2jserver.gameserver.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
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.events.EventDispatcher;
|
||||
import com.l2jserver.gameserver.model.events.EventType;
|
||||
import com.l2jserver.gameserver.model.events.impl.character.npc.OnNpcFirstTalk;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jserver.gameserver.network.serverpackets.MoveToPawn;
|
||||
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
|
||||
*/
|
||||
@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.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;
|
||||
}
|
||||
}
|
145
trunk/dist/game/data/scripts/handlers/actionhandlers/L2PcInstanceAction.java
vendored
Normal file
145
trunk/dist/game/data/scripts/handlers/actionhandlers/L2PcInstanceAction.java
vendored
Normal file
@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack 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.
|
||||
*
|
||||
* L2J DataPack 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.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.enums.PrivateStoreType;
|
||||
import com.l2jserver.gameserver.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
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;
|
||||
|
||||
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)
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
// 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 (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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2PcInstance;
|
||||
}
|
||||
}
|
115
trunk/dist/game/data/scripts/handlers/actionhandlers/L2PetInstanceAction.java
vendored
Normal file
115
trunk/dist/game/data/scripts/handlers/actionhandlers/L2PetInstanceAction.java
vendored
Normal file
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack 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.
|
||||
*
|
||||
* L2J DataPack 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.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
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.model.actor.instance.L2PetInstance;
|
||||
import com.l2jserver.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jserver.gameserver.model.events.impl.character.player.OnPlayerSummonTalk;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.PetStatusShow;
|
||||
|
||||
public class L2PetInstanceAction implements IActionHandler
|
||||
{
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
// Aggression target lock effect
|
||||
if (activeChar.isLockedTarget() && (activeChar.getLockedTarget() != target))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.FAILED_TO_CHANGE_ENMITY);
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean isOwner = activeChar.getObjectId() == ((L2PetInstance) target).getOwner().getObjectId();
|
||||
|
||||
if (isOwner && (activeChar != ((L2PetInstance) target).getOwner()))
|
||||
{
|
||||
((L2PetInstance) target).updateRefOwner(activeChar);
|
||||
}
|
||||
if (activeChar.getTarget() != target)
|
||||
{
|
||||
// Set the target of the L2PcInstance activeChar
|
||||
activeChar.setTarget(target);
|
||||
}
|
||||
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));
|
||||
|
||||
// Notify to scripts
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerSummonTalk((L2Summon) target), (L2Summon) target);
|
||||
}
|
||||
activeChar.updateNotMoveUntil();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2PetInstance;
|
||||
}
|
||||
}
|
89
trunk/dist/game/data/scripts/handlers/actionhandlers/L2StaticObjectInstanceAction.java
vendored
Normal file
89
trunk/dist/game/data/scripts/handlers/actionhandlers/L2StaticObjectInstanceAction.java
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack 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.
|
||||
*
|
||||
* L2J DataPack 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.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
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.NpcHtmlMessage;
|
||||
|
||||
public class L2StaticObjectInstanceAction implements IActionHandler
|
||||
{
|
||||
@Override
|
||||
public boolean action(final L2PcInstance activeChar, final L2Object target, final 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;
|
||||
}
|
||||
}
|
107
trunk/dist/game/data/scripts/handlers/actionhandlers/L2SummonAction.java
vendored
Normal file
107
trunk/dist/game/data/scripts/handlers/actionhandlers/L2SummonAction.java
vendored
Normal file
@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack 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.
|
||||
*
|
||||
* L2J DataPack 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.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.L2Summon;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jserver.gameserver.model.events.impl.character.player.OnPlayerSummonTalk;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jserver.gameserver.network.serverpackets.PetStatusShow;
|
||||
|
||||
public class L2SummonAction implements IActionHandler
|
||||
{
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
// Aggression target lock effect
|
||||
if (activeChar.isLockedTarget() && (activeChar.getLockedTarget() != target))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.FAILED_TO_CHANGE_ENMITY);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((activeChar == ((L2Summon) target).getOwner()) && (activeChar.getTarget() == target))
|
||||
{
|
||||
activeChar.sendPacket(new PetStatusShow((L2Summon) target));
|
||||
activeChar.updateNotMoveUntil();
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
|
||||
// Notify to scripts
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerSummonTalk((L2Summon) target), (L2Summon) target);
|
||||
}
|
||||
else if (activeChar.getTarget() != target)
|
||||
{
|
||||
activeChar.setTarget(target);
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
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 (((L2Summon) target).isInsideRadius(activeChar, 150, false, false))
|
||||
{
|
||||
activeChar.updateNotMoveUntil();
|
||||
}
|
||||
else 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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2Summon;
|
||||
}
|
||||
}
|
48
trunk/dist/game/data/scripts/handlers/actionhandlers/L2TrapAction.java
vendored
Normal file
48
trunk/dist/game/data/scripts/handlers/actionhandlers/L2TrapAction.java
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack 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.
|
||||
*
|
||||
* L2J DataPack 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.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
|
||||
public class L2TrapAction implements IActionHandler
|
||||
{
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
// Aggression target lock effect
|
||||
if (activeChar.isLockedTarget() && (activeChar.getLockedTarget() != target))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.FAILED_TO_CHANGE_ENMITY);
|
||||
return false;
|
||||
}
|
||||
|
||||
activeChar.setTarget(target);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2TrapInstance;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user