Project update.
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network;
|
||||
|
||||
import com.l2jmobius.util.Rnd;
|
||||
|
||||
/**
|
||||
* Blowfish keygen for GameServer client connections.
|
||||
* @author KenM
|
||||
*/
|
||||
public class BlowFishKeygen
|
||||
{
|
||||
private static final int CRYPT_KEYS_SIZE = 20;
|
||||
private static final byte[][] CRYPT_KEYS = new byte[CRYPT_KEYS_SIZE][16];
|
||||
static
|
||||
{
|
||||
// init the GS encryption keys on class load
|
||||
|
||||
for (int i = 0; i < CRYPT_KEYS_SIZE; i++)
|
||||
{
|
||||
// randomize the 8 first bytes
|
||||
for (int j = 0; j < CRYPT_KEYS[i].length; j++)
|
||||
{
|
||||
CRYPT_KEYS[i][j] = (byte) Rnd.get(255);
|
||||
}
|
||||
|
||||
// the last 8 bytes are static
|
||||
CRYPT_KEYS[i][8] = (byte) 0xc8;
|
||||
CRYPT_KEYS[i][9] = (byte) 0x27;
|
||||
CRYPT_KEYS[i][10] = (byte) 0x93;
|
||||
CRYPT_KEYS[i][11] = (byte) 0x01;
|
||||
CRYPT_KEYS[i][12] = (byte) 0xa1;
|
||||
CRYPT_KEYS[i][13] = (byte) 0x6c;
|
||||
CRYPT_KEYS[i][14] = (byte) 0x31;
|
||||
CRYPT_KEYS[i][15] = (byte) 0x97;
|
||||
}
|
||||
}
|
||||
|
||||
// block instantiation
|
||||
private BlowFishKeygen()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a key from this keygen pool, the logical ownership is retained by this keygen.<BR>
|
||||
* Thus when getting a key with interests other then read-only a copy must be performed.<BR>
|
||||
* @return A key from this keygen pool.
|
||||
*/
|
||||
public static byte[] getRandomKey()
|
||||
{
|
||||
return CRYPT_KEYS[Rnd.get(CRYPT_KEYS_SIZE)];
|
||||
}
|
||||
}
|
||||
248
trunk/java/com/l2jmobius/gameserver/network/ClientStats.java
Normal file
248
trunk/java/com/l2jmobius/gameserver/network/ClientStats.java
Normal file
@@ -0,0 +1,248 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
|
||||
public class ClientStats
|
||||
{
|
||||
public int processedPackets = 0;
|
||||
public int droppedPackets = 0;
|
||||
public int unknownPackets = 0;
|
||||
public int totalQueueSize = 0;
|
||||
public int maxQueueSize = 0;
|
||||
public int totalBursts = 0;
|
||||
public int maxBurstSize = 0;
|
||||
public int shortFloods = 0;
|
||||
public int longFloods = 0;
|
||||
public int totalQueueOverflows = 0;
|
||||
public int totalUnderflowExceptions = 0;
|
||||
|
||||
private final int[] _packetsInSecond;
|
||||
private long _packetCountStartTick = 0;
|
||||
private int _head;
|
||||
private int _totalCount = 0;
|
||||
|
||||
private int _floodsInMin = 0;
|
||||
private long _floodStartTick = 0;
|
||||
private int _unknownPacketsInMin = 0;
|
||||
private long _unknownPacketStartTick = 0;
|
||||
private int _overflowsInMin = 0;
|
||||
private long _overflowStartTick = 0;
|
||||
private int _underflowReadsInMin = 0;
|
||||
private long _underflowReadStartTick = 0;
|
||||
|
||||
private volatile boolean _floodDetected = false;
|
||||
private volatile boolean _queueOverflowDetected = false;
|
||||
|
||||
private final int BUFFER_SIZE;
|
||||
|
||||
public ClientStats()
|
||||
{
|
||||
BUFFER_SIZE = Config.CLIENT_PACKET_QUEUE_MEASURE_INTERVAL;
|
||||
_packetsInSecond = new int[BUFFER_SIZE];
|
||||
_head = BUFFER_SIZE - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if incoming packet need to be dropped
|
||||
*/
|
||||
protected final boolean dropPacket()
|
||||
{
|
||||
final boolean result = _floodDetected || _queueOverflowDetected;
|
||||
if (result)
|
||||
{
|
||||
droppedPackets++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Later during flood returns true (and send ActionFailed) once per second.
|
||||
* @param queueSize
|
||||
* @return true if flood detected first and ActionFailed packet need to be sent.
|
||||
*/
|
||||
protected final boolean countPacket(int queueSize)
|
||||
{
|
||||
processedPackets++;
|
||||
totalQueueSize += queueSize;
|
||||
if (maxQueueSize < queueSize)
|
||||
{
|
||||
maxQueueSize = queueSize;
|
||||
}
|
||||
if (_queueOverflowDetected && (queueSize < 2))
|
||||
{
|
||||
_queueOverflowDetected = false;
|
||||
}
|
||||
|
||||
return countPacket();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Counts unknown packets and return true if threshold is reached.
|
||||
*/
|
||||
protected final boolean countUnknownPacket()
|
||||
{
|
||||
unknownPackets++;
|
||||
|
||||
final long tick = System.currentTimeMillis();
|
||||
if ((tick - _unknownPacketStartTick) > 60000)
|
||||
{
|
||||
_unknownPacketStartTick = tick;
|
||||
_unknownPacketsInMin = 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
_unknownPacketsInMin++;
|
||||
return _unknownPacketsInMin > Config.CLIENT_PACKET_QUEUE_MAX_UNKNOWN_PER_MIN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param count - current number of processed packets in burst
|
||||
* @return burst length and return true if execution of the queue need to be aborted.
|
||||
*/
|
||||
protected final boolean countBurst(int count)
|
||||
{
|
||||
if (count > maxBurstSize)
|
||||
{
|
||||
maxBurstSize = count;
|
||||
}
|
||||
|
||||
if (count < Config.CLIENT_PACKET_QUEUE_MAX_BURST_SIZE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
totalBursts++;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Counts queue overflows and return true if threshold is reached.
|
||||
*/
|
||||
protected final boolean countQueueOverflow()
|
||||
{
|
||||
_queueOverflowDetected = true;
|
||||
totalQueueOverflows++;
|
||||
|
||||
final long tick = System.currentTimeMillis();
|
||||
if ((tick - _overflowStartTick) > 60000)
|
||||
{
|
||||
_overflowStartTick = tick;
|
||||
_overflowsInMin = 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
_overflowsInMin++;
|
||||
return _overflowsInMin > Config.CLIENT_PACKET_QUEUE_MAX_OVERFLOWS_PER_MIN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Counts underflow exceptions and return true if threshold is reached.
|
||||
*/
|
||||
protected final boolean countUnderflowException()
|
||||
{
|
||||
totalUnderflowExceptions++;
|
||||
|
||||
final long tick = System.currentTimeMillis();
|
||||
if ((tick - _underflowReadStartTick) > 60000)
|
||||
{
|
||||
_underflowReadStartTick = tick;
|
||||
_underflowReadsInMin = 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
_underflowReadsInMin++;
|
||||
return _underflowReadsInMin > Config.CLIENT_PACKET_QUEUE_MAX_UNDERFLOWS_PER_MIN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if maximum number of floods per minute is reached.
|
||||
*/
|
||||
protected final boolean countFloods()
|
||||
{
|
||||
return _floodsInMin > Config.CLIENT_PACKET_QUEUE_MAX_FLOODS_PER_MIN;
|
||||
}
|
||||
|
||||
private final boolean longFloodDetected()
|
||||
{
|
||||
return (_totalCount / BUFFER_SIZE) > Config.CLIENT_PACKET_QUEUE_MAX_AVERAGE_PACKETS_PER_SECOND;
|
||||
}
|
||||
|
||||
/**
|
||||
* Later during flood returns true (and send ActionFailed) once per second.
|
||||
* @return true if flood detected first and ActionFailed packet need to be sent.
|
||||
*/
|
||||
private final synchronized boolean countPacket()
|
||||
{
|
||||
_totalCount++;
|
||||
final long tick = System.currentTimeMillis();
|
||||
if ((tick - _packetCountStartTick) > 1000)
|
||||
{
|
||||
_packetCountStartTick = tick;
|
||||
|
||||
// clear flag if no more flooding during last seconds
|
||||
if (_floodDetected && !longFloodDetected() && (_packetsInSecond[_head] < (Config.CLIENT_PACKET_QUEUE_MAX_PACKETS_PER_SECOND / 2)))
|
||||
{
|
||||
_floodDetected = false;
|
||||
}
|
||||
|
||||
// wrap head of the buffer around the tail
|
||||
if (_head <= 0)
|
||||
{
|
||||
_head = BUFFER_SIZE;
|
||||
}
|
||||
_head--;
|
||||
|
||||
_totalCount -= _packetsInSecond[_head];
|
||||
_packetsInSecond[_head] = 1;
|
||||
return _floodDetected;
|
||||
}
|
||||
|
||||
final int count = ++_packetsInSecond[_head];
|
||||
if (!_floodDetected)
|
||||
{
|
||||
if (count > Config.CLIENT_PACKET_QUEUE_MAX_PACKETS_PER_SECOND)
|
||||
{
|
||||
shortFloods++;
|
||||
}
|
||||
else if (longFloodDetected())
|
||||
{
|
||||
longFloods++;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_floodDetected = true;
|
||||
if ((tick - _floodStartTick) > 60000)
|
||||
{
|
||||
_floodStartTick = tick;
|
||||
_floodsInMin = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_floodsInMin++;
|
||||
}
|
||||
|
||||
return true; // Return true only in the beginning of the flood
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface ClientString
|
||||
{
|
||||
public int id();
|
||||
|
||||
public String message();
|
||||
}
|
||||
111
trunk/java/com/l2jmobius/gameserver/network/Debug.java
Normal file
111
trunk/java/com/l2jmobius/gameserver/network/Debug.java
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.l2jmobius.gameserver.datatables.ItemTable;
|
||||
import com.l2jmobius.gameserver.model.Elementals;
|
||||
import com.l2jmobius.gameserver.model.StatsSet;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.TutorialShowHtml;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class Debug
|
||||
{
|
||||
public static void sendSkillDebug(L2Character attacker, L2Character target, Skill skill, StatsSet set)
|
||||
{
|
||||
if (!attacker.isPlayer())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (Entry<String, Object> entry : set.getSet().entrySet())
|
||||
{
|
||||
sb.append("<tr><td>" + entry.getKey() + "</td><td><font color=\"LEVEL\">" + entry.getValue() + "</font></td></tr>");
|
||||
}
|
||||
|
||||
final NpcHtmlMessage msg = new NpcHtmlMessage();
|
||||
msg.setFile(attacker.getActingPlayer().getHtmlPrefix(), "html/admin/skilldebug.htm");
|
||||
msg.replace("%patk%", target.getPAtk(target));
|
||||
msg.replace("%matk%", target.getMAtk(target, skill));
|
||||
msg.replace("%pdef%", target.getPDef(target));
|
||||
msg.replace("%mdef%", target.getMDef(target, skill));
|
||||
msg.replace("%acc%", target.getAccuracy());
|
||||
msg.replace("%evas%", target.getEvasionRate(target));
|
||||
msg.replace("%crit%", target.getCriticalHit(target, skill));
|
||||
msg.replace("%speed%", target.getRunSpeed());
|
||||
msg.replace("%pAtkSpd%", target.getPAtkSpd());
|
||||
msg.replace("%mAtkSpd%", target.getMAtkSpd());
|
||||
msg.replace("%str%", target.getSTR());
|
||||
msg.replace("%dex%", target.getDEX());
|
||||
msg.replace("%con%", target.getCON());
|
||||
msg.replace("%int%", target.getINT());
|
||||
msg.replace("%wit%", target.getWIT());
|
||||
msg.replace("%men%", target.getMEN());
|
||||
msg.replace("%atkElemType%", Elementals.getElementName(target.getAttackElement()));
|
||||
msg.replace("%atkElemVal%", target.getAttackElementValue(target.getAttackElement()));
|
||||
msg.replace("%fireDef%", target.getDefenseElementValue((byte) 0));
|
||||
msg.replace("%waterDef%", target.getDefenseElementValue((byte) 1));
|
||||
msg.replace("%windDef%", target.getDefenseElementValue((byte) 2));
|
||||
msg.replace("%earthDef%", target.getDefenseElementValue((byte) 3));
|
||||
msg.replace("%holyDef%", target.getDefenseElementValue((byte) 4));
|
||||
msg.replace("%darkDef%", target.getDefenseElementValue((byte) 5));
|
||||
msg.replace("%skill%", skill.toString());
|
||||
msg.replace("%details%", sb.toString());
|
||||
attacker.sendPacket(new TutorialShowHtml(msg.getHtml()));
|
||||
}
|
||||
|
||||
public static void sendItemDebug(L2PcInstance player, L2ItemInstance item, StatsSet set)
|
||||
{
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (Entry<String, Object> entry : set.getSet().entrySet())
|
||||
{
|
||||
sb.append("<tr><td>" + entry.getKey() + "</td><td><font color=\"LEVEL\">" + entry.getValue() + "</font></td></tr>");
|
||||
}
|
||||
|
||||
final NpcHtmlMessage msg = new NpcHtmlMessage();
|
||||
msg.setFile(player.getHtmlPrefix(), "html/admin/itemdebug.htm");
|
||||
msg.replace("%itemName%", item.getName());
|
||||
msg.replace("%itemSlot%", getBodyPart(item.getItem().getBodyPart()));
|
||||
msg.replace("%itemType%", item.isArmor() ? "Armor" : item.isWeapon() ? "Weapon" : "Etc");
|
||||
msg.replace("%enchantLevel%", item.getEnchantLevel());
|
||||
msg.replace("%isMagicWeapon%", item.getItem().isMagicWeapon());
|
||||
msg.replace("%item%", item.toString());
|
||||
msg.replace("%details%", sb.toString());
|
||||
player.sendPacket(new TutorialShowHtml(msg.getHtml()));
|
||||
}
|
||||
|
||||
private static String getBodyPart(int bodyPart)
|
||||
{
|
||||
for (Entry<String, Integer> entry : ItemTable.SLOTS.entrySet())
|
||||
{
|
||||
if ((entry.getValue() & bodyPart) == bodyPart)
|
||||
{
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
90
trunk/java/com/l2jmobius/gameserver/network/GameCrypt.java
Normal file
90
trunk/java/com/l2jmobius/gameserver/network/GameCrypt.java
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
*/
|
||||
public class GameCrypt
|
||||
{
|
||||
private final byte[] _inKey = new byte[16];
|
||||
private final byte[] _outKey = new byte[16];
|
||||
private boolean _isEnabled;
|
||||
|
||||
public void setKey(byte[] key)
|
||||
{
|
||||
System.arraycopy(key, 0, _inKey, 0, 16);
|
||||
System.arraycopy(key, 0, _outKey, 0, 16);
|
||||
}
|
||||
|
||||
public void decrypt(byte[] raw, final int offset, final int size)
|
||||
{
|
||||
if (!_isEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int temp = 0;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
final int temp2 = raw[offset + i] & 0xFF;
|
||||
raw[offset + i] = (byte) (temp2 ^ _inKey[i & 15] ^ temp);
|
||||
temp = temp2;
|
||||
}
|
||||
|
||||
int old = _inKey[8] & 0xff;
|
||||
old |= (_inKey[9] << 8) & 0xff00;
|
||||
old |= (_inKey[10] << 0x10) & 0xff0000;
|
||||
old |= (_inKey[11] << 0x18) & 0xff000000;
|
||||
|
||||
old += size;
|
||||
|
||||
_inKey[8] = (byte) (old & 0xff);
|
||||
_inKey[9] = (byte) ((old >> 0x08) & 0xff);
|
||||
_inKey[10] = (byte) ((old >> 0x10) & 0xff);
|
||||
_inKey[11] = (byte) ((old >> 0x18) & 0xff);
|
||||
}
|
||||
|
||||
public void encrypt(byte[] raw, final int offset, final int size)
|
||||
{
|
||||
if (!_isEnabled)
|
||||
{
|
||||
_isEnabled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
int temp = 0;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
final int temp2 = raw[offset + i] & 0xFF;
|
||||
temp = temp2 ^ _outKey[i & 15] ^ temp;
|
||||
raw[offset + i] = (byte) temp;
|
||||
}
|
||||
|
||||
int old = _outKey[8] & 0xff;
|
||||
old |= (_outKey[9] << 8) & 0xff00;
|
||||
old |= (_outKey[10] << 0x10) & 0xff0000;
|
||||
old |= (_outKey[11] << 0x18) & 0xff000000;
|
||||
|
||||
old += size;
|
||||
|
||||
_outKey[8] = (byte) (old & 0xff);
|
||||
_outKey[9] = (byte) ((old >> 0x08) & 0xff);
|
||||
_outKey[10] = (byte) ((old >> 0x10) & 0xff);
|
||||
_outKey[11] = (byte) ((old >> 0x18) & 0xff);
|
||||
}
|
||||
}
|
||||
1194
trunk/java/com/l2jmobius/gameserver/network/L2GameClient.java
Normal file
1194
trunk/java/com/l2jmobius/gameserver/network/L2GameClient.java
Normal file
File diff suppressed because it is too large
Load Diff
2752
trunk/java/com/l2jmobius/gameserver/network/L2GamePacketHandler.java
Normal file
2752
trunk/java/com/l2jmobius/gameserver/network/L2GamePacketHandler.java
Normal file
File diff suppressed because it is too large
Load Diff
36532
trunk/java/com/l2jmobius/gameserver/network/NpcStringId.java
Normal file
36532
trunk/java/com/l2jmobius/gameserver/network/NpcStringId.java
Normal file
File diff suppressed because it is too large
Load Diff
15469
trunk/java/com/l2jmobius/gameserver/network/SystemMessageId.java
Normal file
15469
trunk/java/com/l2jmobius/gameserver/network/SystemMessageId.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,614 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.enums.ItemLocation;
|
||||
import com.l2jmobius.gameserver.enums.PrivateStoreType;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.request.EnchantItemAttributeRequest;
|
||||
import com.l2jmobius.gameserver.model.actor.request.EnchantItemRequest;
|
||||
import com.l2jmobius.gameserver.model.items.L2Armor;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
import com.l2jmobius.gameserver.model.items.L2Weapon;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.items.type.CrystalType;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
public abstract class AbstractRefinePacket extends L2GameClientPacket
|
||||
{
|
||||
public static final int GRADE_NONE = 0;
|
||||
public static final int GRADE_MID = 1;
|
||||
public static final int GRADE_HIGH = 2;
|
||||
public static final int GRADE_TOP = 3;
|
||||
public static final int GRADE_ACC = 4; // Accessory LS
|
||||
|
||||
protected static final int GEMSTONE_D = 2130;
|
||||
protected static final int GEMSTONE_C = 2131;
|
||||
protected static final int GEMSTONE_B = 2132;
|
||||
protected static final int GEMSTONE_A = 2133;
|
||||
|
||||
private static final Map<Integer, LifeStone> _lifeStones = new HashMap<>();
|
||||
|
||||
protected static final class LifeStone
|
||||
{
|
||||
// lifestone level to player level table
|
||||
private static final int[] LEVELS =
|
||||
{
|
||||
46,
|
||||
49,
|
||||
52,
|
||||
55,
|
||||
58,
|
||||
61,
|
||||
64,
|
||||
67,
|
||||
70,
|
||||
76,
|
||||
80,
|
||||
82,
|
||||
84,
|
||||
85,
|
||||
95,
|
||||
99
|
||||
};
|
||||
private final int _grade;
|
||||
private final int _level;
|
||||
|
||||
public LifeStone(int grade, int level)
|
||||
{
|
||||
_grade = grade;
|
||||
_level = level;
|
||||
}
|
||||
|
||||
public final int getLevel()
|
||||
{
|
||||
return _level;
|
||||
}
|
||||
|
||||
public final int getGrade()
|
||||
{
|
||||
return _grade;
|
||||
}
|
||||
|
||||
public final int getPlayerLevel()
|
||||
{
|
||||
return LEVELS[_level];
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
// itemId, (LS grade, LS level)
|
||||
_lifeStones.put(8723, new LifeStone(GRADE_NONE, 0));
|
||||
_lifeStones.put(8724, new LifeStone(GRADE_NONE, 1));
|
||||
_lifeStones.put(8725, new LifeStone(GRADE_NONE, 2));
|
||||
_lifeStones.put(8726, new LifeStone(GRADE_NONE, 3));
|
||||
_lifeStones.put(8727, new LifeStone(GRADE_NONE, 4));
|
||||
_lifeStones.put(8728, new LifeStone(GRADE_NONE, 5));
|
||||
_lifeStones.put(8729, new LifeStone(GRADE_NONE, 6));
|
||||
_lifeStones.put(8730, new LifeStone(GRADE_NONE, 7));
|
||||
_lifeStones.put(8731, new LifeStone(GRADE_NONE, 8));
|
||||
_lifeStones.put(8732, new LifeStone(GRADE_NONE, 9));
|
||||
|
||||
_lifeStones.put(8733, new LifeStone(GRADE_MID, 0));
|
||||
_lifeStones.put(8734, new LifeStone(GRADE_MID, 1));
|
||||
_lifeStones.put(8735, new LifeStone(GRADE_MID, 2));
|
||||
_lifeStones.put(8736, new LifeStone(GRADE_MID, 3));
|
||||
_lifeStones.put(8737, new LifeStone(GRADE_MID, 4));
|
||||
_lifeStones.put(8738, new LifeStone(GRADE_MID, 5));
|
||||
_lifeStones.put(8739, new LifeStone(GRADE_MID, 6));
|
||||
_lifeStones.put(8740, new LifeStone(GRADE_MID, 7));
|
||||
_lifeStones.put(8741, new LifeStone(GRADE_MID, 8));
|
||||
_lifeStones.put(8742, new LifeStone(GRADE_MID, 9));
|
||||
|
||||
_lifeStones.put(8743, new LifeStone(GRADE_HIGH, 0));
|
||||
_lifeStones.put(8744, new LifeStone(GRADE_HIGH, 1));
|
||||
_lifeStones.put(8745, new LifeStone(GRADE_HIGH, 2));
|
||||
_lifeStones.put(8746, new LifeStone(GRADE_HIGH, 3));
|
||||
_lifeStones.put(8747, new LifeStone(GRADE_HIGH, 4));
|
||||
_lifeStones.put(8748, new LifeStone(GRADE_HIGH, 5));
|
||||
_lifeStones.put(8749, new LifeStone(GRADE_HIGH, 6));
|
||||
_lifeStones.put(8750, new LifeStone(GRADE_HIGH, 7));
|
||||
_lifeStones.put(8751, new LifeStone(GRADE_HIGH, 8));
|
||||
_lifeStones.put(8752, new LifeStone(GRADE_HIGH, 9));
|
||||
|
||||
_lifeStones.put(8753, new LifeStone(GRADE_TOP, 0));
|
||||
_lifeStones.put(8754, new LifeStone(GRADE_TOP, 1));
|
||||
_lifeStones.put(8755, new LifeStone(GRADE_TOP, 2));
|
||||
_lifeStones.put(8756, new LifeStone(GRADE_TOP, 3));
|
||||
_lifeStones.put(8757, new LifeStone(GRADE_TOP, 4));
|
||||
_lifeStones.put(8758, new LifeStone(GRADE_TOP, 5));
|
||||
_lifeStones.put(8759, new LifeStone(GRADE_TOP, 6));
|
||||
_lifeStones.put(8760, new LifeStone(GRADE_TOP, 7));
|
||||
_lifeStones.put(8761, new LifeStone(GRADE_TOP, 8));
|
||||
_lifeStones.put(8762, new LifeStone(GRADE_TOP, 9));
|
||||
|
||||
_lifeStones.put(9573, new LifeStone(GRADE_NONE, 10));
|
||||
_lifeStones.put(9574, new LifeStone(GRADE_MID, 10));
|
||||
_lifeStones.put(9575, new LifeStone(GRADE_HIGH, 10));
|
||||
_lifeStones.put(9576, new LifeStone(GRADE_TOP, 10));
|
||||
|
||||
_lifeStones.put(10483, new LifeStone(GRADE_NONE, 11));
|
||||
_lifeStones.put(10484, new LifeStone(GRADE_MID, 11));
|
||||
_lifeStones.put(10485, new LifeStone(GRADE_HIGH, 11));
|
||||
_lifeStones.put(10486, new LifeStone(GRADE_TOP, 11));
|
||||
|
||||
_lifeStones.put(12754, new LifeStone(GRADE_ACC, 0));
|
||||
_lifeStones.put(12755, new LifeStone(GRADE_ACC, 1));
|
||||
_lifeStones.put(12756, new LifeStone(GRADE_ACC, 2));
|
||||
_lifeStones.put(12757, new LifeStone(GRADE_ACC, 3));
|
||||
_lifeStones.put(12758, new LifeStone(GRADE_ACC, 4));
|
||||
_lifeStones.put(12759, new LifeStone(GRADE_ACC, 5));
|
||||
_lifeStones.put(12760, new LifeStone(GRADE_ACC, 6));
|
||||
_lifeStones.put(12761, new LifeStone(GRADE_ACC, 7));
|
||||
_lifeStones.put(12762, new LifeStone(GRADE_ACC, 8));
|
||||
_lifeStones.put(12763, new LifeStone(GRADE_ACC, 9));
|
||||
|
||||
_lifeStones.put(12821, new LifeStone(GRADE_ACC, 10));
|
||||
_lifeStones.put(12822, new LifeStone(GRADE_ACC, 11));
|
||||
|
||||
_lifeStones.put(12840, new LifeStone(GRADE_ACC, 0));
|
||||
_lifeStones.put(12841, new LifeStone(GRADE_ACC, 1));
|
||||
_lifeStones.put(12842, new LifeStone(GRADE_ACC, 2));
|
||||
_lifeStones.put(12843, new LifeStone(GRADE_ACC, 3));
|
||||
_lifeStones.put(12844, new LifeStone(GRADE_ACC, 4));
|
||||
_lifeStones.put(12845, new LifeStone(GRADE_ACC, 5));
|
||||
_lifeStones.put(12846, new LifeStone(GRADE_ACC, 6));
|
||||
_lifeStones.put(12847, new LifeStone(GRADE_ACC, 7));
|
||||
_lifeStones.put(12848, new LifeStone(GRADE_ACC, 8));
|
||||
_lifeStones.put(12849, new LifeStone(GRADE_ACC, 9));
|
||||
_lifeStones.put(12850, new LifeStone(GRADE_ACC, 10));
|
||||
_lifeStones.put(12851, new LifeStone(GRADE_ACC, 11));
|
||||
|
||||
_lifeStones.put(14008, new LifeStone(GRADE_ACC, 12));
|
||||
|
||||
_lifeStones.put(14166, new LifeStone(GRADE_NONE, 12));
|
||||
_lifeStones.put(14167, new LifeStone(GRADE_MID, 12));
|
||||
_lifeStones.put(14168, new LifeStone(GRADE_HIGH, 12));
|
||||
_lifeStones.put(14169, new LifeStone(GRADE_TOP, 12));
|
||||
|
||||
_lifeStones.put(16160, new LifeStone(GRADE_NONE, 13));
|
||||
_lifeStones.put(16161, new LifeStone(GRADE_MID, 13));
|
||||
_lifeStones.put(16162, new LifeStone(GRADE_HIGH, 13));
|
||||
_lifeStones.put(16163, new LifeStone(GRADE_TOP, 13));
|
||||
_lifeStones.put(16177, new LifeStone(GRADE_ACC, 13));
|
||||
|
||||
_lifeStones.put(16164, new LifeStone(GRADE_NONE, 13));
|
||||
_lifeStones.put(16165, new LifeStone(GRADE_MID, 13));
|
||||
_lifeStones.put(16166, new LifeStone(GRADE_HIGH, 13));
|
||||
_lifeStones.put(16167, new LifeStone(GRADE_TOP, 13));
|
||||
_lifeStones.put(16178, new LifeStone(GRADE_ACC, 13));
|
||||
|
||||
_lifeStones.put(18563, new LifeStone(GRADE_NONE, 13));
|
||||
_lifeStones.put(18564, new LifeStone(GRADE_MID, 13));
|
||||
_lifeStones.put(18565, new LifeStone(GRADE_HIGH, 13));
|
||||
_lifeStones.put(18566, new LifeStone(GRADE_TOP, 13));
|
||||
_lifeStones.put(19166, new LifeStone(GRADE_ACC, 13));
|
||||
|
||||
_lifeStones.put(18568, new LifeStone(GRADE_NONE, 14));
|
||||
_lifeStones.put(18569, new LifeStone(GRADE_MID, 14));
|
||||
_lifeStones.put(18570, new LifeStone(GRADE_HIGH, 14));
|
||||
_lifeStones.put(18571, new LifeStone(GRADE_TOP, 14));
|
||||
_lifeStones.put(19167, new LifeStone(GRADE_ACC, 14));
|
||||
|
||||
_lifeStones.put(18573, new LifeStone(GRADE_NONE, 15));
|
||||
_lifeStones.put(18574, new LifeStone(GRADE_MID, 15));
|
||||
_lifeStones.put(18575, new LifeStone(GRADE_HIGH, 15));
|
||||
_lifeStones.put(18576, new LifeStone(GRADE_TOP, 15));
|
||||
_lifeStones.put(19168, new LifeStone(GRADE_ACC, 15));
|
||||
}
|
||||
|
||||
protected static final LifeStone getLifeStone(int itemId)
|
||||
{
|
||||
return _lifeStones.get(itemId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks player, source item, lifestone and gemstone validity for augmentation process
|
||||
* @param player
|
||||
* @param item
|
||||
* @param refinerItem
|
||||
* @param gemStones
|
||||
* @return
|
||||
*/
|
||||
protected static final boolean isValid(L2PcInstance player, L2ItemInstance item, L2ItemInstance refinerItem, L2ItemInstance gemStones)
|
||||
{
|
||||
if (!isValid(player, item, refinerItem))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// GemStones must belong to owner
|
||||
if (gemStones.getOwnerId() != player.getObjectId())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// .. and located in inventory
|
||||
if (gemStones.getItemLocation() != ItemLocation.INVENTORY)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final CrystalType grade = item.getItem().getCrystalType();
|
||||
final LifeStone ls = _lifeStones.get(refinerItem.getId());
|
||||
|
||||
// Check for item id
|
||||
if (getGemStoneId(grade) != gemStones.getId())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// Count must be greater or equal of required number
|
||||
if (getGemStoneCount(grade, ls.getGrade()) > gemStones.getCount())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks player, source item and lifestone validity for augmentation process
|
||||
* @param player
|
||||
* @param item
|
||||
* @param refinerItem
|
||||
* @return
|
||||
*/
|
||||
protected static final boolean isValid(L2PcInstance player, L2ItemInstance item, L2ItemInstance refinerItem)
|
||||
{
|
||||
if (!isValid(player, item))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Item must belong to owner
|
||||
if (refinerItem.getOwnerId() != player.getObjectId())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// Lifestone must be located in inventory
|
||||
if (refinerItem.getItemLocation() != ItemLocation.INVENTORY)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final LifeStone ls = _lifeStones.get(refinerItem.getId());
|
||||
if (ls == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// weapons can't be augmented with accessory ls
|
||||
if ((item.getItem() instanceof L2Weapon) && (ls.getGrade() == GRADE_ACC))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// and accessory can't be augmented with weapon ls
|
||||
if ((item.getItem() instanceof L2Armor) && (ls.getGrade() != GRADE_ACC))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// check for level of the lifestone
|
||||
if (player.getLevel() < ls.getPlayerLevel())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check both player and source item conditions for augmentation process
|
||||
* @param player
|
||||
* @param item
|
||||
* @return
|
||||
*/
|
||||
protected static final boolean isValid(L2PcInstance player, L2ItemInstance item)
|
||||
{
|
||||
if (!isValid(player))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Item must belong to owner
|
||||
if (item.getOwnerId() != player.getObjectId())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (item.isAugmented())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (item.isHeroItem())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (item.isShadowItem())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (item.isCommonItem())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (item.isEtcItem())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (item.isTimeLimitedItem())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (item.isPvp() && !Config.ALT_ALLOW_AUGMENT_PVP_ITEMS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (item.getItem().getCrystalType().isLesser(CrystalType.C))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Source item can be equipped or in inventory
|
||||
switch (item.getItemLocation())
|
||||
{
|
||||
case INVENTORY:
|
||||
case PAPERDOLL:
|
||||
{
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (item.getItem() instanceof L2Weapon)
|
||||
{
|
||||
switch (((L2Weapon) item.getItem()).getItemType())
|
||||
{
|
||||
case NONE:
|
||||
case FISHINGROD:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (item.getItem() instanceof L2Armor)
|
||||
{
|
||||
// only accessories can be augmented
|
||||
switch (item.getItem().getBodyPart())
|
||||
{
|
||||
case L2Item.SLOT_LR_FINGER:
|
||||
case L2Item.SLOT_LR_EAR:
|
||||
case L2Item.SLOT_NECK:
|
||||
{
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false; // neither weapon nor armor ?
|
||||
}
|
||||
|
||||
// blacklist check
|
||||
if (Arrays.binarySearch(Config.AUGMENTATION_BLACKLIST, item.getId()) >= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if player's conditions valid for augmentation process
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
protected static final boolean isValid(L2PcInstance player)
|
||||
{
|
||||
if (player.getPrivateStoreType() != PrivateStoreType.NONE)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_AUGMENT_ITEMS_WHILE_A_PRIVATE_STORE_OR_PRIVATE_WORKSHOP_IS_IN_OPERATION);
|
||||
return false;
|
||||
}
|
||||
if (player.getActiveTradeList() != null)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_AUGMENT_ITEMS_WHILE_ENGAGED_IN_TRADE_ACTIVITIES);
|
||||
return false;
|
||||
}
|
||||
if (player.isDead())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_AUGMENT_ITEMS_WHILE_DEAD);
|
||||
return false;
|
||||
}
|
||||
if (player.isParalyzed())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_AUGMENT_ITEMS_WHILE_PARALYZED);
|
||||
return false;
|
||||
}
|
||||
if (player.isFishing())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_AUGMENT_ITEMS_WHILE_FISHING);
|
||||
return false;
|
||||
}
|
||||
if (player.isSitting())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_AUGMENT_ITEMS_WHILE_SITTING_DOWN);
|
||||
return false;
|
||||
}
|
||||
if (player.isCursedWeaponEquipped())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (player.hasRequest(EnchantItemRequest.class, EnchantItemAttributeRequest.class) || player.isProcessingTransaction())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param itemGrade
|
||||
* @return GemStone itemId based on item grade
|
||||
*/
|
||||
protected static final int getGemStoneId(CrystalType itemGrade)
|
||||
{
|
||||
switch (itemGrade)
|
||||
{
|
||||
case C:
|
||||
case B:
|
||||
{
|
||||
return GEMSTONE_D;
|
||||
}
|
||||
case A:
|
||||
case S:
|
||||
{
|
||||
return GEMSTONE_C;
|
||||
}
|
||||
case S80:
|
||||
case S84:
|
||||
{
|
||||
return GEMSTONE_B;
|
||||
}
|
||||
case R:
|
||||
case R95:
|
||||
case R99:
|
||||
{
|
||||
return GEMSTONE_A;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Different for weapon and accessory augmentation.
|
||||
* @param itemGrade
|
||||
* @param lifeStoneGrade
|
||||
* @return GemStone count based on item grade and life stone grade
|
||||
*/
|
||||
protected static final int getGemStoneCount(CrystalType itemGrade, int lifeStoneGrade)
|
||||
{
|
||||
switch (lifeStoneGrade)
|
||||
{
|
||||
case GRADE_ACC:
|
||||
{
|
||||
switch (itemGrade)
|
||||
{
|
||||
case C:
|
||||
{
|
||||
return 200;
|
||||
}
|
||||
case B:
|
||||
{
|
||||
return 300;
|
||||
}
|
||||
case A:
|
||||
{
|
||||
return 200;
|
||||
}
|
||||
case S:
|
||||
{
|
||||
return 250;
|
||||
}
|
||||
case S80:
|
||||
{
|
||||
return 360;
|
||||
}
|
||||
case S84:
|
||||
{
|
||||
return 480;
|
||||
}
|
||||
case R:
|
||||
{
|
||||
return 540;
|
||||
}
|
||||
case R95:
|
||||
{
|
||||
return 620;
|
||||
}
|
||||
case R99:
|
||||
{
|
||||
return 700;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
default:
|
||||
{
|
||||
switch (itemGrade)
|
||||
{
|
||||
case C:
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
case B:
|
||||
{
|
||||
return 30;
|
||||
}
|
||||
case A:
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
case S:
|
||||
{
|
||||
return 25;
|
||||
}
|
||||
case S80:
|
||||
case S84:
|
||||
{
|
||||
return 36;
|
||||
}
|
||||
case R:
|
||||
{
|
||||
return 55;
|
||||
}
|
||||
case R95:
|
||||
{
|
||||
return 70;
|
||||
}
|
||||
case R99:
|
||||
{
|
||||
return 95;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.enums.DuelState;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.PcCondOverride;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
||||
import com.l2jmobius.gameserver.model.skills.AbnormalType;
|
||||
import com.l2jmobius.gameserver.model.skills.BuffInfo;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
public final class Action extends L2GameClientPacket
|
||||
{
|
||||
private static final String __C__1F_ACTION = "[C] 1F Action";
|
||||
|
||||
private int _objectId;
|
||||
private int _originX;
|
||||
private int _originY;
|
||||
private int _originZ;
|
||||
private int _actionId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_objectId = readD(); // Target object Identifier
|
||||
_originX = readD();
|
||||
_originY = readD();
|
||||
_originZ = readD();
|
||||
_actionId = readC(); // Action identifier : 0-Simple click, 1-Shift click
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.info(getType() + ": " + (_actionId == 0 ? "Simple-click" : "Shift-click") + " Target object ID: " + _objectId + " orignX: " + _originX + " orignY: " + _originY + " orignZ: " + _originZ);
|
||||
}
|
||||
|
||||
// Get the current L2PcInstance of the player
|
||||
final L2PcInstance activeChar = getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.inObserverMode())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.OBSERVERS_CANNOT_PARTICIPATE);
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
final BuffInfo info = activeChar.getEffectList().getBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
|
||||
if (info != null)
|
||||
{
|
||||
for (AbstractEffect effect : info.getEffects())
|
||||
{
|
||||
if (!effect.checkCondition(-4))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REPORTED_AS_AN_ILLEGAL_PROGRAM_USER_SO_YOUR_ACTIONS_HAVE_BEEN_RESTRICTED);
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final L2Object obj;
|
||||
if (activeChar.getTargetId() == _objectId)
|
||||
{
|
||||
obj = activeChar.getTarget();
|
||||
}
|
||||
else if (activeChar.isInAirShip() && (activeChar.getAirShip().getHelmObjectId() == _objectId))
|
||||
{
|
||||
obj = activeChar.getAirShip();
|
||||
}
|
||||
else
|
||||
{
|
||||
obj = L2World.getInstance().findObject(_objectId);
|
||||
}
|
||||
|
||||
// If object requested does not exist, add warn msg into logs
|
||||
if (obj == null)
|
||||
{
|
||||
// pressing e.g. pickup many times quickly would get you here
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj.isPlayable() && (obj.getActingPlayer().getDuelState() == DuelState.DEAD))
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
activeChar.getActingPlayer().sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THE_OTHER_PARTY_IS_FROZEN_PLEASE_WAIT_A_MOMENT));
|
||||
return;
|
||||
}
|
||||
if (!obj.isTargetable() && !activeChar.canOverrideCond(PcCondOverride.TARGET_ALL))
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Players can't interact with objects in the other instances, except from multiverse
|
||||
if ((obj.getInstanceId() != activeChar.getInstanceId()) && (activeChar.getInstanceId() != -1))
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Only GMs can directly interact with invisible characters
|
||||
if (!obj.isVisibleFor(activeChar))
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the target is valid, if the player haven't a shop or isn't the requester of a transaction (ex : FriendInvite, JoinAlly, JoinParty...)
|
||||
if (activeChar.getActiveRequester() != null)
|
||||
{
|
||||
// Actions prohibited when in trade
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (_actionId)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
obj.onAction(activeChar);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if (!activeChar.isGM() && !(obj.isNpc() && Config.ALT_GAME_VIEWNPC))
|
||||
{
|
||||
obj.onAction(activeChar, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.onActionShift(activeChar);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
// Invalid action detected (probably client cheating), log this
|
||||
_log.warning(getType() + ": Character: " + activeChar.getName() + " requested invalid action: " + _actionId);
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return __C__1F_ACTION;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.TradeItem;
|
||||
import com.l2jmobius.gameserver.model.TradeList;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.TradeOtherAdd;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.TradeOwnAdd;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.TradeUpdate;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.5.2.2.2.5 $ $Date: 2005/03/27 15:29:29 $
|
||||
*/
|
||||
public final class AddTradeItem extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__1B_ADDTRADEITEM = "[C] 1B AddTradeItem";
|
||||
|
||||
private int _tradeId;
|
||||
private int _objectId;
|
||||
private long _count;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_tradeId = readD();
|
||||
_objectId = readD();
|
||||
_count = readQ();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance player = getClient().getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final TradeList trade = player.getActiveTradeList();
|
||||
if (trade == null)
|
||||
{
|
||||
_log.warning("Character: " + player.getName() + " requested item:" + _objectId + " add without active tradelist:" + _tradeId);
|
||||
return;
|
||||
}
|
||||
|
||||
final L2PcInstance partner = trade.getPartner();
|
||||
if ((partner == null) || (L2World.getInstance().getPlayer(partner.getObjectId()) == null) || (partner.getActiveTradeList() == null))
|
||||
{
|
||||
// Trade partner not found, cancel trade
|
||||
if (partner != null)
|
||||
{
|
||||
_log.warning("Character:" + player.getName() + " requested invalid trade object: " + _objectId);
|
||||
}
|
||||
player.sendPacket(SystemMessageId.THAT_PLAYER_IS_NOT_ONLINE);
|
||||
player.cancelActiveTrade();
|
||||
return;
|
||||
}
|
||||
|
||||
if (trade.isConfirmed() || partner.getActiveTradeList().isConfirmed())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_MAY_NO_LONGER_ADJUST_ITEMS_IN_THE_TRADE_BECAUSE_THE_TRADE_HAS_BEEN_CONFIRMED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.getAccessLevel().allowTransaction())
|
||||
{
|
||||
player.sendMessage("Transactions are disabled for your Access Level.");
|
||||
player.cancelActiveTrade();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.validateItemManipulation(_objectId, "trade"))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.NOTHING_HAPPENED);
|
||||
return;
|
||||
}
|
||||
|
||||
final TradeItem item = trade.addItem(_objectId, _count);
|
||||
if (item != null)
|
||||
{
|
||||
player.sendPacket(new TradeOwnAdd(item));
|
||||
player.sendPacket(new TradeUpdate(player, item));
|
||||
partner.sendPacket(new TradeOtherAdd(item));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__1B_ADDTRADEITEM;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jmobius.gameserver.model.L2Clan;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
public final class AllyDismiss extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__8F_ALLYDISMISS = "[C] 8F AllyDismiss";
|
||||
|
||||
private String _clanName;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_clanName = readS();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
if (_clanName == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final L2PcInstance player = getClient().getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (player.getClan() == null)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_ARE_NOT_A_CLAN_MEMBER_AND_CANNOT_PERFORM_THIS_ACTION);
|
||||
return;
|
||||
}
|
||||
final L2Clan leaderClan = player.getClan();
|
||||
if (leaderClan.getAllyId() == 0)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_ARE_NOT_CURRENTLY_ALLIED_WITH_ANY_CLANS);
|
||||
return;
|
||||
}
|
||||
if (!player.isClanLeader() || (leaderClan.getId() != leaderClan.getAllyId()))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.THIS_FEATURE_IS_ONLY_AVAILABLE_TO_ALLIANCE_LEADERS);
|
||||
return;
|
||||
}
|
||||
final L2Clan clan = ClanTable.getInstance().getClanByName(_clanName);
|
||||
if (clan == null)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.THAT_CLAN_DOES_NOT_EXIST);
|
||||
return;
|
||||
}
|
||||
if (clan.getId() == leaderClan.getId())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.ALLIANCE_LEADERS_CANNOT_WITHDRAW);
|
||||
return;
|
||||
}
|
||||
if (clan.getAllyId() != leaderClan.getAllyId())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.DIFFERENT_ALLIANCE);
|
||||
return;
|
||||
}
|
||||
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
leaderClan.setAllyPenaltyExpiryTime(currentTime + (Config.ALT_ACCEPT_CLAN_DAYS_WHEN_DISMISSED * 86400000L), L2Clan.PENALTY_TYPE_DISMISS_CLAN); // 24*60*60*1000 = 86400000
|
||||
leaderClan.updateClanInDB();
|
||||
|
||||
clan.setAllyId(0);
|
||||
clan.setAllyName(null);
|
||||
clan.changeAllyCrest(0, true);
|
||||
clan.setAllyPenaltyExpiryTime(currentTime + (Config.ALT_ALLY_JOIN_DAYS_WHEN_DISMISSED * 86400000L), L2Clan.PENALTY_TYPE_CLAN_DISMISSED); // 24*60*60*1000 = 86400000
|
||||
clan.updateClanInDB();
|
||||
|
||||
player.sendPacket(SystemMessageId.YOU_HAVE_SUCCEEDED_IN_EXPELLING_THE_CLAN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__8F_ALLYDISMISS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.L2Clan;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
public final class AllyLeave extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__8E_ALLYLEAVE = "[C] 8E AllyLeave";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance player = getClient().getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (player.getClan() == null)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_ARE_NOT_A_CLAN_MEMBER_AND_CANNOT_PERFORM_THIS_ACTION);
|
||||
return;
|
||||
}
|
||||
if (!player.isClanLeader())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.ONLY_THE_CLAN_LEADER_MAY_APPLY_FOR_WITHDRAWAL_FROM_THE_ALLIANCE);
|
||||
return;
|
||||
}
|
||||
final L2Clan clan = player.getClan();
|
||||
if (clan.getAllyId() == 0)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_ARE_NOT_CURRENTLY_ALLIED_WITH_ANY_CLANS);
|
||||
return;
|
||||
}
|
||||
if (clan.getId() == clan.getAllyId())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.ALLIANCE_LEADERS_CANNOT_WITHDRAW);
|
||||
return;
|
||||
}
|
||||
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
clan.setAllyId(0);
|
||||
clan.setAllyName(null);
|
||||
clan.changeAllyCrest(0, true);
|
||||
clan.setAllyPenaltyExpiryTime(currentTime + (Config.ALT_ALLY_JOIN_DAYS_WHEN_LEAVED * 86400000L), L2Clan.PENALTY_TYPE_CLAN_LEAVED); // 24*60*60*1000 = 86400000
|
||||
clan.updateClanInDB();
|
||||
|
||||
player.sendPacket(SystemMessageId.YOU_HAVE_WITHDRAWN_FROM_THE_ALLIANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__8E_ALLYLEAVE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExRotation;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SocialAction;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author JIV
|
||||
*/
|
||||
public class AnswerCoupleAction extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_7A_ANSWERCOUPLEACTION = "[C] D0:7A AnswerCoupleAction";
|
||||
|
||||
private int _charObjId;
|
||||
private int _actionId;
|
||||
private int _answer;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_actionId = readD();
|
||||
_answer = readD();
|
||||
_charObjId = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getActiveChar();
|
||||
final L2PcInstance target = L2World.getInstance().getPlayer(_charObjId);
|
||||
if ((activeChar == null) || (target == null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ((target.getMultiSocialTarget() != activeChar.getObjectId()) || (target.getMultiSociaAction() != _actionId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_answer == 0) // cancel
|
||||
{
|
||||
target.sendPacket(SystemMessageId.THE_COUPLE_ACTION_WAS_DENIED);
|
||||
}
|
||||
else if (_answer == 1) // approve
|
||||
{
|
||||
final int distance = (int) activeChar.calculateDistance(target, false, false);
|
||||
if ((distance > 125) || (distance < 15) || (activeChar.getObjectId() == target.getObjectId()))
|
||||
{
|
||||
sendPacket(SystemMessageId.THE_REQUEST_CANNOT_BE_COMPLETED_BECAUSE_THE_TARGET_DOES_NOT_MEET_LOCATION_REQUIREMENTS);
|
||||
target.sendPacket(SystemMessageId.THE_REQUEST_CANNOT_BE_COMPLETED_BECAUSE_THE_TARGET_DOES_NOT_MEET_LOCATION_REQUIREMENTS);
|
||||
return;
|
||||
}
|
||||
int heading = Util.calculateHeadingFrom(activeChar, target);
|
||||
activeChar.broadcastPacket(new ExRotation(activeChar.getObjectId(), heading));
|
||||
activeChar.setHeading(heading);
|
||||
heading = Util.calculateHeadingFrom(target, activeChar);
|
||||
target.setHeading(heading);
|
||||
target.broadcastPacket(new ExRotation(target.getObjectId(), heading));
|
||||
activeChar.broadcastPacket(new SocialAction(activeChar.getObjectId(), _actionId));
|
||||
target.broadcastPacket(new SocialAction(_charObjId, _actionId));
|
||||
}
|
||||
else if (_answer == -1) // refused
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_SET_TO_REFUSE_COUPLE_ACTIONS_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION);
|
||||
sm.addPcName(activeChar);
|
||||
target.sendPacket(sm);
|
||||
}
|
||||
target.setMultiSocialAction(0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_7A_ANSWERCOUPLEACTION;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.PartyMatchRoom;
|
||||
import com.l2jmobius.gameserver.model.PartyMatchRoomList;
|
||||
import com.l2jmobius.gameserver.model.PartyMatchWaitingList;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExManagePartyRoomMember;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExPartyRoomMember;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PartyMatchDetail;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* Format: (ch) d
|
||||
* @author -Wooden-, Tryskell
|
||||
*/
|
||||
public final class AnswerJoinPartyRoom extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_30_ANSWERJOINPARTYROOM = "[C] D0:30 AnswerJoinPartyRoom";
|
||||
private int _answer; // 1 or 0
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_answer = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance player = getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2PcInstance partner = player.getActiveRequester();
|
||||
if (partner == null)
|
||||
{
|
||||
// Partner hasn't been found, cancel the invitation
|
||||
player.sendPacket(SystemMessageId.THAT_PLAYER_IS_NOT_ONLINE);
|
||||
player.setActiveRequester(null);
|
||||
return;
|
||||
}
|
||||
else if (L2World.getInstance().getPlayer(partner.getObjectId()) == null)
|
||||
{
|
||||
// Partner hasn't been found, cancel the invitation
|
||||
player.sendPacket(SystemMessageId.THAT_PLAYER_IS_NOT_ONLINE);
|
||||
player.setActiveRequester(null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.FACTION_SYSTEM_ENABLED && ((player.isEvil() && partner.isGood()) || (player.isGood() && partner.isEvil())))
|
||||
{
|
||||
player.sendMessage("You cannot party with different team members.");
|
||||
player.setActiveRequester(null);
|
||||
return;
|
||||
}
|
||||
|
||||
// If answer is positive, join the requester's PartyRoom.
|
||||
if ((_answer == 1) && !partner.isRequestExpired())
|
||||
{
|
||||
final PartyMatchRoom room = PartyMatchRoomList.getInstance().getRoom(partner.getPartyRoom());
|
||||
if (room == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((player.getLevel() >= room.getMinLvl()) && (player.getLevel() <= room.getMaxLvl()))
|
||||
{
|
||||
// Remove from waiting list
|
||||
PartyMatchWaitingList.getInstance().removePlayer(player);
|
||||
|
||||
player.setPartyRoom(partner.getPartyRoom());
|
||||
|
||||
player.sendPacket(new PartyMatchDetail(player, room));
|
||||
player.sendPacket(new ExPartyRoomMember(player, room, 0));
|
||||
|
||||
for (L2PcInstance member : room.getPartyMembers())
|
||||
{
|
||||
if (member == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
member.sendPacket(new ExManagePartyRoomMember(player, room, 0));
|
||||
member.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_ENTERED_THE_PARTY_ROOM).addPcName(player));
|
||||
}
|
||||
room.addMember(player);
|
||||
|
||||
// Info Broadcast
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_DO_NOT_MEET_THE_REQUIREMENTS_TO_ENTER_THAT_PARTY_ROOM);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
partner.sendPacket(SystemMessageId.THE_RECIPIENT_OF_YOUR_INVITATION_DID_NOT_ACCEPT_THE_PARTY_MATCHING_INVITATION);
|
||||
}
|
||||
|
||||
// reset transaction timers
|
||||
player.setActiveRequester(null);
|
||||
partner.onTransactionResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_30_ANSWERJOINPARTYROOM;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Party;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* @author JIV
|
||||
*/
|
||||
public class AnswerPartyLootModification extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_79_ANSWERPARTYLOOTMODIFICATION = "[C] D0:79 AnswerPartyLootModification";
|
||||
|
||||
public int _answer;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_answer = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final L2Party party = activeChar.getParty();
|
||||
if (party != null)
|
||||
{
|
||||
party.answerLootChangeRequest(activeChar, _answer == 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_79_ANSWERPARTYLOOTMODIFICATION;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.TradeDone;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.5.4.2 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public final class AnswerTradeRequest extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__55_ANSWERTRADEREQUEST = "[C] 55 AnswerTradeRequest";
|
||||
|
||||
private int _response;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_response = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance player = getClient().getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.getAccessLevel().allowTransaction())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT);
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
final L2PcInstance partner = player.getActiveRequester();
|
||||
if (partner == null)
|
||||
{
|
||||
// Trade partner not found, cancel trade
|
||||
player.sendPacket(new TradeDone(0));
|
||||
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THAT_PLAYER_IS_NOT_ONLINE));
|
||||
player.setActiveRequester(null);
|
||||
return;
|
||||
}
|
||||
else if (L2World.getInstance().getPlayer(partner.getObjectId()) == null)
|
||||
{
|
||||
// Trade partner not found, cancel trade
|
||||
player.sendPacket(new TradeDone(0));
|
||||
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THAT_PLAYER_IS_NOT_ONLINE));
|
||||
player.setActiveRequester(null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.FACTION_SYSTEM_ENABLED && ((player.isEvil() && partner.isGood()) || (player.isGood() && partner.isEvil())))
|
||||
{
|
||||
player.sendPacket(new TradeDone(0));
|
||||
player.sendMessage("You cannot trade with different team members.");
|
||||
player.setActiveRequester(null);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_response == 1) && !partner.isRequestExpired())
|
||||
{
|
||||
player.startTrade(partner);
|
||||
}
|
||||
else
|
||||
{
|
||||
final SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_DENIED_YOUR_REQUEST_TO_TRADE);
|
||||
msg.addString(player.getName());
|
||||
partner.sendPacket(msg);
|
||||
}
|
||||
|
||||
// Clears requesting status
|
||||
player.setActiveRequester(null);
|
||||
partner.onTransactionResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__55_ANSWERTRADEREQUEST;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.UserInfo;
|
||||
|
||||
/**
|
||||
* Appearing Packet Handler
|
||||
* <p>
|
||||
* <p>
|
||||
* 0000: 30
|
||||
* <p>
|
||||
* <p>
|
||||
* @version $Revision: 1.3.4.4 $ $Date: 2005/03/29 23:15:33 $
|
||||
*/
|
||||
public final class Appearing extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__3A_APPEARING = "[C] 3A Appearing";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (activeChar.isTeleporting())
|
||||
{
|
||||
activeChar.onTeleported();
|
||||
}
|
||||
|
||||
sendPacket(new UserInfo(activeChar));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__3A_APPEARING;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.PrivateStoreType;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.PcCondOverride;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
||||
import com.l2jmobius.gameserver.model.skills.AbnormalType;
|
||||
import com.l2jmobius.gameserver.model.skills.BuffInfo;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
|
||||
/**
|
||||
* TODO: This class is a copy of AttackRequest, we should get proper structure for both.
|
||||
*/
|
||||
public final class Attack extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__01_ATTACK = "[C] 01 Attack";
|
||||
|
||||
// cddddc
|
||||
private int _objectId;
|
||||
@SuppressWarnings("unused")
|
||||
private int _originX;
|
||||
@SuppressWarnings("unused")
|
||||
private int _originY;
|
||||
@SuppressWarnings("unused")
|
||||
private int _originZ;
|
||||
@SuppressWarnings("unused")
|
||||
private int _attackId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_objectId = readD();
|
||||
_originX = readD();
|
||||
_originY = readD();
|
||||
_originZ = readD();
|
||||
_attackId = readC(); // 0 for simple click 1 for shift-click
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Avoid Attacks in Boat.
|
||||
if (activeChar.isPlayable() && activeChar.isInBoat())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_IS_NOT_ALLOWED_WHILE_RIDING_A_FERRY_OR_BOAT);
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
final BuffInfo info = activeChar.getEffectList().getBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
|
||||
if (info != null)
|
||||
{
|
||||
for (AbstractEffect effect : info.getEffects())
|
||||
{
|
||||
if (!effect.checkCondition(-1))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REPORTED_AS_AN_ILLEGAL_PROGRAM_USER_SO_YOUR_ACTIONS_HAVE_BEEN_RESTRICTED);
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// avoid using expensive operations if not needed
|
||||
final L2Object target;
|
||||
if (activeChar.getTargetId() == _objectId)
|
||||
{
|
||||
target = activeChar.getTarget();
|
||||
}
|
||||
else
|
||||
{
|
||||
target = L2World.getInstance().findObject(_objectId);
|
||||
}
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!target.isTargetable() && !activeChar.canOverrideCond(PcCondOverride.TARGET_ALL))
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Players can't attack objects in the other instances
|
||||
// except from multiverse
|
||||
else if ((target.getInstanceId() != activeChar.getInstanceId()) && (activeChar.getInstanceId() != -1))
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Only GMs can directly attack invisible characters
|
||||
else if (!target.isVisibleFor(activeChar))
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.getTarget() != target)
|
||||
{
|
||||
target.onAction(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((target.getObjectId() != activeChar.getObjectId()) && (activeChar.getPrivateStoreType() == PrivateStoreType.NONE) && (activeChar.getActiveRequester() == null))
|
||||
{
|
||||
target.onForcedAttack(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__01_ATTACK;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.PrivateStoreType;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.PcCondOverride;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
||||
import com.l2jmobius.gameserver.model.skills.AbnormalType;
|
||||
import com.l2jmobius.gameserver.model.skills.BuffInfo;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
|
||||
public final class AttackRequest extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__32_ATTACKREQUEST = "[C] 32 AttackRequest";
|
||||
|
||||
// cddddc
|
||||
private int _objectId;
|
||||
@SuppressWarnings("unused")
|
||||
private int _originX;
|
||||
@SuppressWarnings("unused")
|
||||
private int _originY;
|
||||
@SuppressWarnings("unused")
|
||||
private int _originZ;
|
||||
@SuppressWarnings("unused")
|
||||
private int _attackId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_objectId = readD();
|
||||
_originX = readD();
|
||||
_originY = readD();
|
||||
_originZ = readD();
|
||||
_attackId = readC(); // 0 for simple click 1 for shift-click
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final BuffInfo info = activeChar.getEffectList().getBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
|
||||
if (info != null)
|
||||
{
|
||||
for (AbstractEffect effect : info.getEffects())
|
||||
{
|
||||
if (!effect.checkCondition(-1))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REPORTED_AS_AN_ILLEGAL_PROGRAM_USER_SO_YOUR_ACTIONS_HAVE_BEEN_RESTRICTED);
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// avoid using expensive operations if not needed
|
||||
final L2Object target;
|
||||
if (activeChar.getTargetId() == _objectId)
|
||||
{
|
||||
target = activeChar.getTarget();
|
||||
}
|
||||
else
|
||||
{
|
||||
target = L2World.getInstance().findObject(_objectId);
|
||||
}
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
else if (!target.isTargetable() && !activeChar.canOverrideCond(PcCondOverride.TARGET_ALL))
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Players can't attack objects in the other instances
|
||||
// except from multiverse
|
||||
else if ((target.getInstanceId() != activeChar.getInstanceId()) && (activeChar.getInstanceId() != -1))
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Only GMs can directly attack invisible characters
|
||||
else if (!target.isVisibleFor(activeChar))
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.getTarget() != target)
|
||||
{
|
||||
target.onAction(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((target.getObjectId() != activeChar.getObjectId()) && (activeChar.getPrivateStoreType() == PrivateStoreType.NONE) && (activeChar.getActiveRequester() == null))
|
||||
{
|
||||
target.onForcedAttack(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__32_ATTACKREQUEST;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.LoginServerThread;
|
||||
import com.l2jmobius.gameserver.LoginServerThread.SessionKey;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.9.2.3.2.4 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public final class AuthLogin extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__2B_AUTHLOGIN = "[C] 2B AuthLogin";
|
||||
|
||||
// loginName + keys must match what the loginserver used.
|
||||
private String _loginName;
|
||||
/*
|
||||
* private final long _key1; private final long _key2; private final long _key3; private final long _key4;
|
||||
*/
|
||||
private int _playKey1;
|
||||
private int _playKey2;
|
||||
private int _loginKey1;
|
||||
private int _loginKey2;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_loginName = readS().toLowerCase();
|
||||
_playKey2 = readD();
|
||||
_playKey1 = readD();
|
||||
_loginKey1 = readD();
|
||||
_loginKey2 = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2GameClient client = getClient();
|
||||
if (_loginName.isEmpty() || !client.isProtocolOk())
|
||||
{
|
||||
client.close((L2GameServerPacket) null);
|
||||
return;
|
||||
}
|
||||
final SessionKey key = new SessionKey(_loginKey1, _loginKey2, _playKey1, _playKey2);
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.info("user:" + _loginName);
|
||||
_log.info("key:" + key);
|
||||
}
|
||||
|
||||
// avoid potential exploits
|
||||
if (client.getAccountName() == null)
|
||||
{
|
||||
// Preventing duplicate login in case client login server socket was disconnected or this packet was not sent yet
|
||||
if (LoginServerThread.getInstance().addGameServerLogin(_loginName, client))
|
||||
{
|
||||
client.setAccountName(_loginName);
|
||||
LoginServerThread.getInstance().addWaitingClientAndSendRequest(_loginName, client, key);
|
||||
}
|
||||
else
|
||||
{
|
||||
client.close((L2GameServerPacket) null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__2B_AUTHLOGIN;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExBrLoadEventTopRankers;
|
||||
|
||||
/**
|
||||
* Halloween rank list client packet. Format: (ch)ddd
|
||||
*/
|
||||
public class BrEventRankerList extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_7B_BREVENTRANKERLIST = "[C] D0:7B BrEventRankerList";
|
||||
|
||||
private int _eventId;
|
||||
private int _day;
|
||||
@SuppressWarnings("unused")
|
||||
private int _ranking;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_eventId = readD();
|
||||
_day = readD(); // 0 - current, 1 - previous
|
||||
_ranking = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
// TODO count, bestScore, myScore
|
||||
final int count = 0;
|
||||
final int bestScore = 0;
|
||||
final int myScore = 0;
|
||||
getClient().sendPacket(new ExBrLoadEventTopRankers(_eventId, _day, count, bestScore, myScore));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_7B_BREVENTRANKERLIST;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IUserCommandHandler;
|
||||
import com.l2jmobius.gameserver.handler.UserCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.1.2.1.2.2 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public class BypassUserCmd extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__B3_BYPASSUSERCMD = "[C] B3 BypassUserCmd";
|
||||
|
||||
private int _command;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_command = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance player = getClient().getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final IUserCommandHandler handler = UserCommandHandler.getInstance().getHandler(_command);
|
||||
|
||||
if (handler == null)
|
||||
{
|
||||
if (player.isGM())
|
||||
{
|
||||
player.sendMessage("User commandID " + _command + " not implemented yet.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
handler.useUserCommand(_command, getClient().getActiveChar());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__B3_BYPASSUSERCMD;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.ai.CtrlEvent;
|
||||
import com.l2jmobius.gameserver.model.Location;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.1.2.1.2.4 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public final class CannotMoveAnymore extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__47_STOPMOVE = "[C] 47 CannotMoveAnymore";
|
||||
|
||||
private int _x;
|
||||
private int _y;
|
||||
private int _z;
|
||||
private int _heading;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_x = readD();
|
||||
_y = readD();
|
||||
_z = readD();
|
||||
_heading = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance player = getClient().getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("client: x:" + _x + " y:" + _y + " z:" + _z + " server x:" + player.getX() + " y:" + player.getY() + " z:" + player.getZ());
|
||||
}
|
||||
if (player.getAI() != null)
|
||||
{
|
||||
player.getAI().notifyEvent(CtrlEvent.EVT_ARRIVED_BLOCKED, new Location(_x, _y, _z, _heading));
|
||||
}
|
||||
/*
|
||||
* if (player.getParty() != null) { player.getParty().broadcastToPartyMembers(player, new PartyMemberPosition(player)); }
|
||||
*/
|
||||
|
||||
// player.stopMove();
|
||||
//
|
||||
// if (Config.DEBUG)
|
||||
// _log.fine("client: x:"+_x+" y:"+_y+" z:"+_z+
|
||||
// " server x:"+player.getX()+" y:"+player.getZ()+" z:"+player.getZ());
|
||||
// StopMove smwl = new StopMove(player);
|
||||
// getClient().getActiveChar().sendPacket(smwl);
|
||||
// getClient().getActiveChar().broadcastPacket(smwl);
|
||||
//
|
||||
// StopRotation sr = new StopRotation(getClient().getActiveChar(),
|
||||
// _heading);
|
||||
// getClient().getActiveChar().sendPacket(sr);
|
||||
// getClient().getActiveChar().broadcastPacket(sr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__47_STOPMOVE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.Location;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.StopMoveInVehicle;
|
||||
|
||||
/**
|
||||
* @author Maktakien
|
||||
*/
|
||||
public final class CannotMoveAnymoreInVehicle extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__76_CANNOTMOVEANYMOREINVEHICLE = "[C] 76 CannotMoveAnymoreInVehicle";
|
||||
|
||||
private int _x;
|
||||
private int _y;
|
||||
private int _z;
|
||||
private int _heading;
|
||||
private int _boatId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_boatId = readD();
|
||||
_x = readD();
|
||||
_y = readD();
|
||||
_z = readD();
|
||||
_heading = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance player = getClient().getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (player.isInBoat())
|
||||
{
|
||||
if (player.getBoat().getObjectId() == _boatId)
|
||||
{
|
||||
player.setInVehiclePosition(new Location(_x, _y, _z));
|
||||
player.setHeading(_heading);
|
||||
final StopMoveInVehicle msg = new StopMoveInVehicle(player, _boatId);
|
||||
player.broadcastPacket(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__76_CANNOTMOVEANYMOREINVEHICLE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,389 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.InitialEquipmentData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.InitialShortcutData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PlayerTemplateData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SkillTreesData;
|
||||
import com.l2jmobius.gameserver.datatables.SkillData;
|
||||
import com.l2jmobius.gameserver.model.L2SkillLearn;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.Location;
|
||||
import com.l2jmobius.gameserver.model.actor.appearance.PcAppearance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.stat.PcStat;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2PcTemplate;
|
||||
import com.l2jmobius.gameserver.model.base.ClassId;
|
||||
import com.l2jmobius.gameserver.model.events.Containers;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerCreate;
|
||||
import com.l2jmobius.gameserver.model.items.PcItemTemplate;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CharCreateFail;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CharCreateOk;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CharSelectionInfo;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class CharacterCreate extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__0C_CHARACTERCREATE = "[C] 0C CharacterCreate";
|
||||
protected static final Logger _logAccounting = Logger.getLogger("accounting");
|
||||
|
||||
// cSdddddddddddd
|
||||
private String _name;
|
||||
private int _race;
|
||||
private byte _sex;
|
||||
private int _classId;
|
||||
private int _int;
|
||||
private int _str;
|
||||
private int _con;
|
||||
private int _men;
|
||||
private int _dex;
|
||||
private int _wit;
|
||||
private byte _hairStyle;
|
||||
private byte _hairColor;
|
||||
private byte _face;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_name = readS();
|
||||
_race = readD();
|
||||
_sex = (byte) readD();
|
||||
_classId = readD();
|
||||
_int = readD();
|
||||
_str = readD();
|
||||
_con = readD();
|
||||
_men = readD();
|
||||
_dex = readD();
|
||||
_wit = readD();
|
||||
_hairStyle = (byte) readD();
|
||||
_hairColor = (byte) readD();
|
||||
_face = (byte) readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
// Last Verified: May 30, 2009 - Gracia Final - Players are able to create characters with names consisting of as little as 1,2,3 letter/number combinations.
|
||||
if ((_name.length() < 1) || (_name.length() > 16))
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("Character Creation Failure: Character name " + _name + " is invalid. Message generated: Your title cannot exceed 16 characters in length. Please try again.");
|
||||
}
|
||||
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_16_ENG_CHARS));
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.FORBIDDEN_NAMES.length > 1)
|
||||
{
|
||||
for (String st : Config.FORBIDDEN_NAMES)
|
||||
{
|
||||
if (_name.toLowerCase().contains(st.toLowerCase()))
|
||||
{
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_INCORRECT_NAME));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Last Verified: May 30, 2009 - Gracia Final
|
||||
if (!Util.isAlphaNumeric(_name) || !isValidName(_name))
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("Character Creation Failure: Character name " + _name + " is invalid. Message generated: Incorrect name. Please try again.");
|
||||
}
|
||||
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_INCORRECT_NAME));
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_face > 2) || (_face < 0))
|
||||
{
|
||||
_log.warning("Character Creation Failure: Character face " + _face + " is invalid. Possible client hack. " + getClient());
|
||||
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED));
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_hairStyle < 0) || ((_sex == 0) && (_hairStyle > 4)) || ((_sex != 0) && (_hairStyle > 6)))
|
||||
{
|
||||
_log.warning("Character Creation Failure: Character hair style " + _hairStyle + " is invalid. Possible client hack. " + getClient());
|
||||
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED));
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_hairColor > 3) || (_hairColor < 0))
|
||||
{
|
||||
_log.warning("Character Creation Failure: Character hair color " + _hairColor + " is invalid. Possible client hack. " + getClient());
|
||||
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED));
|
||||
return;
|
||||
}
|
||||
|
||||
L2PcInstance newChar = null;
|
||||
L2PcTemplate template = null;
|
||||
|
||||
/*
|
||||
* DrHouse: Since checks for duplicate names are done using SQL, lock must be held until data is written to DB as well.
|
||||
*/
|
||||
synchronized (CharNameTable.getInstance())
|
||||
{
|
||||
if ((CharNameTable.getInstance().getAccountCharacterCount(getClient().getAccountName()) >= Config.MAX_CHARACTERS_NUMBER_PER_ACCOUNT) && (Config.MAX_CHARACTERS_NUMBER_PER_ACCOUNT != 0))
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("Max number of characters reached. Creation failed.");
|
||||
}
|
||||
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_TOO_MANY_CHARACTERS));
|
||||
return;
|
||||
}
|
||||
else if (CharNameTable.getInstance().doesCharNameExist(_name))
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("Character Creation Failure: Message generated: You cannot create another character. Please delete the existing character and try again.");
|
||||
}
|
||||
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_NAME_ALREADY_EXISTS));
|
||||
return;
|
||||
}
|
||||
|
||||
template = PlayerTemplateData.getInstance().getTemplate(_classId);
|
||||
if ((template == null) || (ClassId.getClassId(_classId).level() > 0))
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("Character Creation Failure: " + _name + " classId: " + _classId + " Template: " + template + " Message generated: Your character creation has failed.");
|
||||
}
|
||||
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED));
|
||||
return;
|
||||
}
|
||||
|
||||
// Custom Feature: Disallow a race to be created.
|
||||
// Example: Humans can not be created if AllowHuman = False in Custom.properties
|
||||
switch (template.getRace())
|
||||
{
|
||||
case HUMAN:
|
||||
{
|
||||
if (!Config.ALLOW_HUMAN)
|
||||
{
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ELF:
|
||||
{
|
||||
if (!Config.ALLOW_ELF)
|
||||
{
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DARK_ELF:
|
||||
{
|
||||
if (!Config.ALLOW_DARKELF)
|
||||
{
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ORC:
|
||||
{
|
||||
if (!Config.ALLOW_ORC)
|
||||
{
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DWARF:
|
||||
{
|
||||
if (!Config.ALLOW_DWARF)
|
||||
{
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case KAMAEL:
|
||||
{
|
||||
if (!Config.ALLOW_KAMAEL)
|
||||
{
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ERTHEIA:
|
||||
{
|
||||
if (!Config.ALLOW_ERTHEIA)
|
||||
{
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
final PcAppearance app = new PcAppearance(_face, _hairColor, _hairStyle, _sex != 0);
|
||||
newChar = L2PcInstance.create(template, getClient().getAccountName(), _name, app);
|
||||
}
|
||||
|
||||
// HP and MP are at maximum and CP is zero by default.
|
||||
newChar.setCurrentHp(newChar.getMaxHp());
|
||||
newChar.setCurrentMp(newChar.getMaxMp());
|
||||
// newChar.setMaxLoad(template.getBaseLoad());
|
||||
|
||||
sendPacket(new CharCreateOk());
|
||||
|
||||
initNewChar(getClient(), newChar);
|
||||
|
||||
final LogRecord record = new LogRecord(Level.INFO, "Created new character");
|
||||
record.setParameters(new Object[]
|
||||
{
|
||||
newChar,
|
||||
getClient()
|
||||
});
|
||||
_logAccounting.log(record);
|
||||
}
|
||||
|
||||
private static boolean isValidName(String text)
|
||||
{
|
||||
return Config.CHARNAME_TEMPLATE_PATTERN.matcher(text).matches();
|
||||
}
|
||||
|
||||
private void initNewChar(L2GameClient client, L2PcInstance newChar)
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("Character init start");
|
||||
}
|
||||
|
||||
L2World.getInstance().storeObject(newChar);
|
||||
|
||||
if (Config.STARTING_ADENA > 0)
|
||||
{
|
||||
newChar.addAdena("Init", Config.STARTING_ADENA, null, false);
|
||||
}
|
||||
|
||||
final L2PcTemplate template = newChar.getTemplate();
|
||||
|
||||
if (Config.CUSTOM_STARTING_LOC)
|
||||
{
|
||||
final Location createLoc = new Location(Config.CUSTOM_STARTING_LOC_X, Config.CUSTOM_STARTING_LOC_Y, Config.CUSTOM_STARTING_LOC_Z);
|
||||
newChar.setXYZInvisible(createLoc.getX(), createLoc.getY(), createLoc.getZ());
|
||||
}
|
||||
else if (Config.FACTION_SYSTEM_ENABLED)
|
||||
{
|
||||
newChar.setXYZInvisible(Config.FACTION_STARTING_LOCATION.getX(), Config.FACTION_STARTING_LOCATION.getY(), Config.FACTION_STARTING_LOCATION.getZ());
|
||||
}
|
||||
else
|
||||
{
|
||||
final Location createLoc = template.getCreationPoint();
|
||||
newChar.setXYZInvisible(createLoc.getX(), createLoc.getY(), createLoc.getZ());
|
||||
}
|
||||
newChar.setTitle("");
|
||||
|
||||
if (Config.ENABLE_VITALITY)
|
||||
{
|
||||
newChar.setVitalityPoints(Math.min(Config.STARTING_VITALITY_POINTS, PcStat.MAX_VITALITY_POINTS), true);
|
||||
}
|
||||
if (Config.STARTING_LEVEL > 1)
|
||||
{
|
||||
newChar.getStat().addLevel((byte) (Config.STARTING_LEVEL - 1));
|
||||
}
|
||||
if (Config.STARTING_SP > 0)
|
||||
{
|
||||
newChar.getStat().addSp(Config.STARTING_SP);
|
||||
}
|
||||
|
||||
final List<PcItemTemplate> initialItems = InitialEquipmentData.getInstance().getEquipmentList(newChar.getClassId());
|
||||
if (initialItems != null)
|
||||
{
|
||||
for (PcItemTemplate ie : initialItems)
|
||||
{
|
||||
final L2ItemInstance item = newChar.getInventory().addItem("Init", ie.getId(), ie.getCount(), newChar, null);
|
||||
if (item == null)
|
||||
{
|
||||
_log.warning("Could not create item during char creation: itemId " + ie.getId() + ", amount " + ie.getCount() + ".");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item.isEquipable() && ie.isEquipped())
|
||||
{
|
||||
newChar.getInventory().equipItem(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (L2SkillLearn skill : SkillTreesData.getInstance().getAvailableSkills(newChar, newChar.getClassId(), false, true))
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("Adding starter skill:" + skill.getSkillId() + " / " + skill.getSkillLevel());
|
||||
}
|
||||
|
||||
newChar.addSkill(SkillData.getInstance().getSkill(skill.getSkillId(), skill.getSkillLevel()), true);
|
||||
}
|
||||
|
||||
// Register all shortcuts for actions, skills and items for this new character.
|
||||
InitialShortcutData.getInstance().registerAllShortcuts(newChar);
|
||||
|
||||
EventDispatcher.getInstance().notifyEvent(new OnPlayerCreate(newChar, newChar.getObjectId(), newChar.getName(), client), Containers.Players());
|
||||
|
||||
newChar.setOnlineStatus(true, false);
|
||||
if (Config.SHOW_GOD_VIDEO_INTRO)
|
||||
{
|
||||
newChar.getVariables().set("intro_god_video", true);
|
||||
}
|
||||
newChar.deleteMe();
|
||||
|
||||
final CharSelectionInfo cl = new CharSelectionInfo(client.getAccountName(), client.getSessionId().playOkID1);
|
||||
client.setCharSelection(cl.getCharInfo());
|
||||
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("Character init end");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__0C_CHARACTERCREATE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.CharSelectInfoPackage;
|
||||
import com.l2jmobius.gameserver.model.events.Containers;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerDelete;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CharDeleteFail;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CharDeleteSuccess;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CharSelectionInfo;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.8.2.1.2.3 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public final class CharacterDelete extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__0C_CHARACTERDELETE = "[C] 0D CharacterDelete";
|
||||
|
||||
// cd
|
||||
private int _charSlot;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_charSlot = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
// if (!getClient().getFloodProtectors().getCharacterSelect().tryPerformAction("CharacterDelete"))
|
||||
// {
|
||||
// sendPacket(new CharDeleteFail(CharDeleteFail.REASON_DELETION_FAILED));
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("deleting slot:" + _charSlot);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
final byte answer = getClient().markToDeleteChar(_charSlot);
|
||||
|
||||
switch (answer)
|
||||
{
|
||||
default:
|
||||
case -1: // Error
|
||||
{
|
||||
break;
|
||||
}
|
||||
case 0: // Success!
|
||||
{
|
||||
sendPacket(new CharDeleteSuccess());
|
||||
final CharSelectInfoPackage charInfo = getClient().getCharSelection(_charSlot);
|
||||
EventDispatcher.getInstance().notifyEvent(new OnPlayerDelete(charInfo.getObjectId(), charInfo.getName(), getClient()), Containers.Players());
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
sendPacket(new CharDeleteFail(CharDeleteFail.REASON_YOU_MAY_NOT_DELETE_CLAN_MEMBER));
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
sendPacket(new CharDeleteFail(CharDeleteFail.REASON_CLAN_LEADERS_MAY_NOT_BE_DELETED));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.SEVERE, "Error:", e);
|
||||
}
|
||||
|
||||
final CharSelectionInfo cl = new CharSelectionInfo(getClient().getAccountName(), getClient().getSessionId().playOkID1);
|
||||
sendPacket(cl);
|
||||
getClient().setCharSelection(cl.getCharInfo());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__0C_CHARACTERDELETE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.CharSelectInfoPackage;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerRestore;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CharSelectionInfo;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.4.2.1.2.2 $ $Date: 2005/03/27 15:29:29 $
|
||||
*/
|
||||
public final class CharacterRestore extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__7B_CHARACTERRESTORE = "[C] 7B CharacterRestore";
|
||||
|
||||
// cd
|
||||
private int _charSlot;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_charSlot = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
if (!getClient().getFloodProtectors().getCharacterSelect().tryPerformAction("CharacterRestore"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
getClient().markRestoredChar(_charSlot);
|
||||
final CharSelectionInfo cl = new CharSelectionInfo(getClient().getAccountName(), getClient().getSessionId().playOkID1);
|
||||
sendPacket(cl);
|
||||
getClient().setCharSelection(cl.getCharInfo());
|
||||
final CharSelectInfoPackage charInfo = getClient().getCharSelection(_charSlot);
|
||||
EventDispatcher.getInstance().notifyEvent(new OnPlayerRestore(charInfo.getObjectId(), charInfo.getName(), getClient()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__7B_CHARACTERRESTORE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SecondaryAuthData;
|
||||
import com.l2jmobius.gameserver.instancemanager.AntiFeedManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.PunishmentManager;
|
||||
import com.l2jmobius.gameserver.model.CharSelectInfoPackage;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.events.Containers;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerSelect;
|
||||
import com.l2jmobius.gameserver.model.events.returns.TerminateReturn;
|
||||
import com.l2jmobius.gameserver.model.punishment.PunishmentAffect;
|
||||
import com.l2jmobius.gameserver.model.punishment.PunishmentType;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient.GameClientState;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CharSelected;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ServerClose;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.5.2.1.2.5 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public class CharacterSelect extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__12_CHARACTERSELECT = "[C] 12 CharacterSelect";
|
||||
protected static final Logger _logAccounting = Logger.getLogger("accounting");
|
||||
|
||||
// cd
|
||||
private int _charSlot;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private int _unk1; // new in C4
|
||||
@SuppressWarnings("unused")
|
||||
private int _unk2; // new in C4
|
||||
@SuppressWarnings("unused")
|
||||
private int _unk3; // new in C4
|
||||
@SuppressWarnings("unused")
|
||||
private int _unk4; // new in C4
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_charSlot = readD();
|
||||
_unk1 = readH();
|
||||
_unk2 = readD();
|
||||
_unk3 = readD();
|
||||
_unk4 = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2GameClient client = getClient();
|
||||
if (!client.getFloodProtectors().getCharacterSelect().tryPerformAction("CharacterSelect"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (SecondaryAuthData.getInstance().isEnabled() && !client.getSecondaryAuth().isAuthed())
|
||||
{
|
||||
client.getSecondaryAuth().openDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
// We should always be able to acquire the lock
|
||||
// But if we can't lock then nothing should be done (i.e. repeated packet)
|
||||
if (client.getActiveCharLock().tryLock())
|
||||
{
|
||||
try
|
||||
{
|
||||
// should always be null
|
||||
// but if not then this is repeated packet and nothing should be done here
|
||||
if (client.getActiveChar() == null)
|
||||
{
|
||||
final CharSelectInfoPackage info = client.getCharSelection(_charSlot);
|
||||
if (info == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Banned?
|
||||
if (PunishmentManager.getInstance().hasPunishment(info.getObjectId(), PunishmentAffect.CHARACTER, PunishmentType.BAN) || PunishmentManager.getInstance().hasPunishment(client.getAccountName(), PunishmentAffect.ACCOUNT, PunishmentType.BAN) || PunishmentManager.getInstance().hasPunishment(client.getConnectionAddress().getHostAddress(), PunishmentAffect.IP, PunishmentType.BAN))
|
||||
{
|
||||
client.close(ServerClose.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Selected character is banned (compatibility with previous versions).
|
||||
if (info.getAccessLevel() < 0)
|
||||
{
|
||||
client.close(ServerClose.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((Config.L2JMOD_DUALBOX_CHECK_MAX_PLAYERS_PER_IP > 0) && !AntiFeedManager.getInstance().tryAddClient(AntiFeedManager.GAME_ID, client, Config.L2JMOD_DUALBOX_CHECK_MAX_PLAYERS_PER_IP))
|
||||
{
|
||||
final NpcHtmlMessage msg = new NpcHtmlMessage();
|
||||
msg.setFile(info.getHtmlPrefix(), "html/mods/IPRestriction.htm");
|
||||
msg.replace("%max%", String.valueOf(AntiFeedManager.getInstance().getLimit(client, Config.L2JMOD_DUALBOX_CHECK_MAX_PLAYERS_PER_IP)));
|
||||
client.sendPacket(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.FACTION_SYSTEM_ENABLED && Config.FACTION_BALANCE_ONLINE_PLAYERS)
|
||||
{
|
||||
if (info.isGood() && (L2World.getInstance().getAllGoodPlayersCount() >= ((L2World.getInstance().getAllEvilPlayersCount() + Config.FACTION_BALANCE_PLAYER_EXCEED_LIMIT))))
|
||||
{
|
||||
final NpcHtmlMessage msg = new NpcHtmlMessage();
|
||||
msg.setFile(info.getHtmlPrefix(), "html/mods/Faction/ExceededOnlineLimit.htm");
|
||||
msg.replace("%more%", Config.FACTION_GOOD_TEAM_NAME);
|
||||
msg.replace("%less%", Config.FACTION_EVIL_TEAM_NAME);
|
||||
client.sendPacket(msg);
|
||||
return;
|
||||
}
|
||||
if (info.isEvil() && (L2World.getInstance().getAllEvilPlayersCount() >= ((L2World.getInstance().getAllGoodPlayersCount() + Config.FACTION_BALANCE_PLAYER_EXCEED_LIMIT))))
|
||||
{
|
||||
final NpcHtmlMessage msg = new NpcHtmlMessage();
|
||||
msg.setFile(info.getHtmlPrefix(), "html/mods/Faction/ExceededOnlineLimit.htm");
|
||||
msg.replace("%more%", Config.FACTION_EVIL_TEAM_NAME);
|
||||
msg.replace("%less%", Config.FACTION_GOOD_TEAM_NAME);
|
||||
client.sendPacket(msg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// The L2PcInstance must be created here, so that it can be attached to the L2GameClient
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("selected slot:" + _charSlot);
|
||||
}
|
||||
|
||||
// load up character from disk
|
||||
final L2PcInstance cha = client.loadCharFromDisk(_charSlot);
|
||||
if (cha == null)
|
||||
{
|
||||
return; // handled in L2GameClient
|
||||
}
|
||||
L2World.getInstance().addPlayerToWorld(cha);
|
||||
CharNameTable.getInstance().addName(cha);
|
||||
|
||||
cha.setClient(client);
|
||||
client.setActiveChar(cha);
|
||||
cha.setOnlineStatus(true, true);
|
||||
|
||||
final TerminateReturn terminate = EventDispatcher.getInstance().notifyEvent(new OnPlayerSelect(cha, cha.getObjectId(), cha.getName(), getClient()), Containers.Players(), TerminateReturn.class);
|
||||
if ((terminate != null) && terminate.terminate())
|
||||
{
|
||||
cha.deleteMe();
|
||||
return;
|
||||
}
|
||||
|
||||
client.setState(GameClientState.IN_GAME);
|
||||
sendPacket(new CharSelected(cha, client.getSessionId().playOkID1));
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
client.getActiveCharLock().unlock();
|
||||
}
|
||||
|
||||
final LogRecord record = new LogRecord(Level.INFO, "Logged in");
|
||||
record.setParameters(new Object[]
|
||||
{
|
||||
client
|
||||
});
|
||||
_logAccounting.log(record);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__12_CHARACTERSELECT;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jmobius.gameserver.enums.PlayerAction;
|
||||
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerDlgAnswer;
|
||||
import com.l2jmobius.gameserver.model.events.returns.TerminateReturn;
|
||||
import com.l2jmobius.gameserver.model.holders.DoorRequestHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.SummonRequestHolder;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.util.GMAudit;
|
||||
|
||||
/**
|
||||
* @author Dezmond_snz
|
||||
*/
|
||||
public final class DlgAnswer extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__C6_DLGANSWER = "[C] C6 DlgAnswer";
|
||||
private int _messageId;
|
||||
private int _answer;
|
||||
private int _requesterId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_messageId = readD();
|
||||
_answer = readD();
|
||||
_requesterId = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final TerminateReturn term = EventDispatcher.getInstance().notifyEvent(new OnPlayerDlgAnswer(activeChar, _messageId, _answer, _requesterId), activeChar, TerminateReturn.class);
|
||||
if ((term != null) && term.terminate())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_messageId == SystemMessageId.S13.getId())
|
||||
{
|
||||
if (activeChar.removeAction(PlayerAction.USER_ENGAGE))
|
||||
{
|
||||
if (Config.L2JMOD_ALLOW_WEDDING)
|
||||
{
|
||||
activeChar.engageAnswer(_answer);
|
||||
}
|
||||
}
|
||||
else if (activeChar.removeAction(PlayerAction.ADMIN_COMMAND))
|
||||
{
|
||||
final String cmd = activeChar.getAdminConfirmCmd();
|
||||
activeChar.setAdminConfirmCmd(null);
|
||||
if (_answer == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final String command = cmd.split(" ")[0];
|
||||
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(command);
|
||||
if (AdminData.getInstance().hasAccess(command, activeChar.getAccessLevel()))
|
||||
{
|
||||
if (Config.GMAUDIT)
|
||||
{
|
||||
GMAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", cmd, (activeChar.getTarget() != null ? activeChar.getTarget().getName() : "no-target"));
|
||||
}
|
||||
ach.useAdminCommand(cmd, activeChar);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((_messageId == SystemMessageId.C1_IS_ATTEMPTING_TO_DO_A_RESURRECTION_THAT_RESTORES_S2_S3_XP_ACCEPT.getId()) || (_messageId == SystemMessageId.YOUR_CHARM_OF_COURAGE_IS_TRYING_TO_RESURRECT_YOU_WOULD_YOU_LIKE_TO_RESURRECT_NOW.getId()))
|
||||
{
|
||||
activeChar.reviveAnswer(_answer);
|
||||
}
|
||||
else if (_messageId == SystemMessageId.C1_WISHES_TO_SUMMON_YOU_FROM_S2_DO_YOU_ACCEPT.getId())
|
||||
{
|
||||
final SummonRequestHolder holder = activeChar.removeScript(SummonRequestHolder.class);
|
||||
if ((_answer == 1) && (holder != null) && (holder.getTarget().getObjectId() == _requesterId))
|
||||
{
|
||||
activeChar.teleToLocation(holder.getTarget().getLocation(), true);
|
||||
}
|
||||
}
|
||||
else if (_messageId == SystemMessageId.WOULD_YOU_LIKE_TO_OPEN_THE_GATE.getId())
|
||||
{
|
||||
final DoorRequestHolder holder = activeChar.removeScript(DoorRequestHolder.class);
|
||||
if ((holder != null) && (holder.getDoor() == activeChar.getTarget()) && (_answer == 1))
|
||||
{
|
||||
holder.getDoor().openMe();
|
||||
}
|
||||
}
|
||||
else if (_messageId == SystemMessageId.WOULD_YOU_LIKE_TO_CLOSE_THE_GATE.getId())
|
||||
{
|
||||
final DoorRequestHolder holder = activeChar.removeScript(DoorRequestHolder.class);
|
||||
if ((holder != null) && (holder.getDoor() == activeChar.getTarget()) && (_answer == 1))
|
||||
{
|
||||
holder.getDoor().closeMe();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__C6_DLGANSWER;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
/**
|
||||
* @author zabbix Lets drink to code!
|
||||
*/
|
||||
public final class DummyPacket extends L2GameClientPacket
|
||||
{
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runImpl()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return "DummyPacket";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* @author JIV
|
||||
*/
|
||||
public final class EndScenePlayer extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_5B_ENDSCENEPLAYER = "[C] D0:5B EndScenePlayer";
|
||||
|
||||
private int _movieId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_movieId = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_movieId == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (activeChar.getMovieId() != _movieId)
|
||||
{
|
||||
_log.warning("Player " + getClient() + " sent EndScenePlayer with wrong movie id: " + _movieId);
|
||||
return;
|
||||
}
|
||||
activeChar.setMovieId(0);
|
||||
activeChar.setIsTeleporting(true, false); // avoid to get player removed from L2World
|
||||
activeChar.decayMe();
|
||||
activeChar.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());
|
||||
activeChar.setIsTeleporting(false, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_5B_ENDSCENEPLAYER;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,777 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.LoginServerThread;
|
||||
import com.l2jmobius.gameserver.cache.HtmCache;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.AnnouncementsTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.OfflineTradersTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.BeautyShopData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SkillTreesData;
|
||||
import com.l2jmobius.gameserver.enums.Race;
|
||||
import com.l2jmobius.gameserver.enums.SubclassInfoType;
|
||||
import com.l2jmobius.gameserver.instancemanager.CHSiegeManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.ClanHallManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.CoupleManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.FortManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.FortSiegeManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.MailManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.PetitionManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.QuestManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.SiegeManager;
|
||||
import com.l2jmobius.gameserver.model.L2Clan;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.PcCondOverride;
|
||||
import com.l2jmobius.gameserver.model.TeleportWhereType;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2ClassMasterInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.Castle;
|
||||
import com.l2jmobius.gameserver.model.entity.Couple;
|
||||
import com.l2jmobius.gameserver.model.entity.Fort;
|
||||
import com.l2jmobius.gameserver.model.entity.FortSiege;
|
||||
import com.l2jmobius.gameserver.model.entity.L2Event;
|
||||
import com.l2jmobius.gameserver.model.entity.Siege;
|
||||
import com.l2jmobius.gameserver.model.entity.TvTEvent;
|
||||
import com.l2jmobius.gameserver.model.entity.clanhall.AuctionableHall;
|
||||
import com.l2jmobius.gameserver.model.entity.clanhall.SiegableHall;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.quest.Quest;
|
||||
import com.l2jmobius.gameserver.model.quest.QuestState;
|
||||
import com.l2jmobius.gameserver.model.quest.State;
|
||||
import com.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
|
||||
import com.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.AcquireSkillList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.AllyCrest;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.Die;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExAcquireAPSkillList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExAdenaInvenCount;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExAutoSoulShot;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExBasicActionList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExBeautyItemList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExCastleState;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExGetBookMarkInfoPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExNewSkillToLearnByLevelUp;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExNoticePostArrived;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExNotifyPremiumItem;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExPCCafePointInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExPledgeCount;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExPledgeWaitingListAlarm;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExRotation;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExShowScreenMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExShowUsm;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExStorageMaxCount;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExSubjobInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExUnReadMailCount;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExUserInfoEquipSlot;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExUserInfoInvenWeight;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExVitalityEffectInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExVoteSystemInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExWorldChatCnt;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.HennaInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ItemList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PledgeCrest;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PledgeShowMemberListAll;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PledgeShowMemberListUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PledgeSkillList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.QuestList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ShortCutInit;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SkillCoolTime;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SkillList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.dailymission.ExConnectedTimeAndGetTableReward;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.friend.L2FriendList;
|
||||
|
||||
/**
|
||||
* Enter World Packet Handler
|
||||
*/
|
||||
public class EnterWorld extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__11_ENTERWORLD = "[C] 11 EnterWorld";
|
||||
|
||||
private final int[][] tracert = new int[5][4];
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
readB(new byte[32]); // Unknown Byte Array
|
||||
readD(); // Unknown Value
|
||||
readD(); // Unknown Value
|
||||
readD(); // Unknown Value
|
||||
readD(); // Unknown Value
|
||||
readB(new byte[32]); // Unknown Byte Array
|
||||
readD(); // Unknown Value
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
for (int o = 0; o < 4; o++)
|
||||
{
|
||||
tracert[i][o] = readC();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
_log.warning("EnterWorld failed! activeChar returned 'null'.");
|
||||
getClient().closeNow();
|
||||
return;
|
||||
}
|
||||
|
||||
final String[] adress = new String[5];
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3];
|
||||
}
|
||||
|
||||
LoginServerThread.getInstance().sendClientTracert(activeChar.getAccountName(), adress);
|
||||
|
||||
getClient().setClientTracert(tracert);
|
||||
|
||||
// Restore to instanced area if enabled
|
||||
if (Config.RESTORE_PLAYER_INSTANCE)
|
||||
{
|
||||
activeChar.setInstanceId(InstanceManager.getInstance().getPlayerInstance(activeChar.getObjectId()));
|
||||
}
|
||||
else
|
||||
{
|
||||
final int instanceId = InstanceManager.getInstance().getPlayerInstance(activeChar.getObjectId());
|
||||
if (instanceId > 0)
|
||||
{
|
||||
InstanceManager.getInstance().getInstance(instanceId).removePlayer(activeChar.getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
if (L2World.getInstance().findObject(activeChar.getObjectId()) != null)
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.warning("User already exists in Object ID map! User " + activeChar.getName() + " is a character clone.");
|
||||
}
|
||||
}
|
||||
|
||||
// Apply special GM properties to the GM when entering
|
||||
if (activeChar.isGM())
|
||||
{
|
||||
if (Config.GM_STARTUP_INVULNERABLE && AdminData.getInstance().hasAccess("admin_invul", activeChar.getAccessLevel()))
|
||||
{
|
||||
activeChar.setIsInvul(true);
|
||||
}
|
||||
|
||||
if (Config.GM_STARTUP_INVISIBLE && AdminData.getInstance().hasAccess("admin_invisible", activeChar.getAccessLevel()))
|
||||
{
|
||||
activeChar.setInvisible(true);
|
||||
activeChar.startAbnormalVisualEffect(AbnormalVisualEffect.STEALTH);
|
||||
}
|
||||
|
||||
if (Config.GM_STARTUP_SILENCE && AdminData.getInstance().hasAccess("admin_silence", activeChar.getAccessLevel()))
|
||||
{
|
||||
activeChar.setSilenceMode(true);
|
||||
}
|
||||
|
||||
if (Config.GM_STARTUP_DIET_MODE && AdminData.getInstance().hasAccess("admin_diet", activeChar.getAccessLevel()))
|
||||
{
|
||||
activeChar.setDietMode(true);
|
||||
activeChar.refreshOverloaded();
|
||||
}
|
||||
|
||||
if (Config.GM_STARTUP_AUTO_LIST && AdminData.getInstance().hasAccess("admin_gmliston", activeChar.getAccessLevel()))
|
||||
{
|
||||
AdminData.getInstance().addGm(activeChar, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
AdminData.getInstance().addGm(activeChar, true);
|
||||
}
|
||||
|
||||
if (Config.GM_GIVE_SPECIAL_SKILLS)
|
||||
{
|
||||
SkillTreesData.getInstance().addSkills(activeChar, false);
|
||||
}
|
||||
|
||||
if (Config.GM_GIVE_SPECIAL_AURA_SKILLS)
|
||||
{
|
||||
SkillTreesData.getInstance().addSkills(activeChar, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Set dead status if applies
|
||||
if (activeChar.getCurrentHp() < 0.5)
|
||||
{
|
||||
activeChar.setIsDead(true);
|
||||
}
|
||||
|
||||
if (Config.ENABLE_VITALITY)
|
||||
{
|
||||
activeChar.sendPacket(new ExVitalityEffectInfo(activeChar));
|
||||
}
|
||||
|
||||
// Send Macro List
|
||||
activeChar.getMacros().sendAllMacros();
|
||||
|
||||
// Send Teleport Bookmark List
|
||||
sendPacket(new ExGetBookMarkInfoPacket(activeChar));
|
||||
|
||||
// Send Item List
|
||||
sendPacket(new ItemList(activeChar, false));
|
||||
|
||||
// Send Shortcuts
|
||||
sendPacket(new ShortCutInit(activeChar));
|
||||
|
||||
// Send Action list
|
||||
activeChar.sendPacket(ExBasicActionList.STATIC_PACKET);
|
||||
|
||||
// Send blank skill list
|
||||
activeChar.sendPacket(new SkillList());
|
||||
|
||||
// Send castle state.
|
||||
for (Castle castle : CastleManager.getInstance().getCastles())
|
||||
{
|
||||
activeChar.sendPacket(new ExCastleState(castle));
|
||||
}
|
||||
|
||||
// Send GG check
|
||||
activeChar.queryGameGuard();
|
||||
|
||||
// Send Dye Information
|
||||
activeChar.sendPacket(new HennaInfo(activeChar));
|
||||
|
||||
// Send Skill list
|
||||
activeChar.sendSkillList();
|
||||
|
||||
// Send acquirable skill list
|
||||
activeChar.sendPacket(new AcquireSkillList(activeChar));
|
||||
|
||||
// Send EtcStatusUpdate
|
||||
activeChar.sendPacket(new EtcStatusUpdate(activeChar));
|
||||
|
||||
// Clan packets
|
||||
if (activeChar.getClan() != null)
|
||||
{
|
||||
final L2Clan clan = activeChar.getClan();
|
||||
activeChar.sendPacket(new PledgeShowMemberListUpdate(activeChar));
|
||||
sendPacket(new PledgeShowMemberListAll(clan));
|
||||
activeChar.sendPacket(new PledgeSkillList(clan));
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(ExPledgeWaitingListAlarm.STATIC_PACKET);
|
||||
}
|
||||
|
||||
// Used as a tempfix for Clan crests.
|
||||
activeChar.broadcastUserInfo();
|
||||
|
||||
// Send SubClass Info
|
||||
activeChar.sendPacket(new ExSubjobInfo(activeChar, SubclassInfoType.NO_CHANGES));
|
||||
|
||||
// Send Unread Mail Count
|
||||
if (MailManager.getInstance().hasUnreadPost(activeChar))
|
||||
{
|
||||
activeChar.sendPacket(new ExUnReadMailCount(activeChar));
|
||||
}
|
||||
|
||||
// Faction System
|
||||
if (Config.FACTION_SYSTEM_ENABLED)
|
||||
{
|
||||
if (activeChar.isGood())
|
||||
{
|
||||
activeChar.getAppearance().setNameColor(Config.FACTION_GOOD_NAME_COLOR);
|
||||
activeChar.getAppearance().setTitleColor(Config.FACTION_GOOD_NAME_COLOR);
|
||||
activeChar.sendMessage("Welcome " + activeChar.getName() + ", you are fighting for the " + Config.FACTION_GOOD_TEAM_NAME + " faction.");
|
||||
activeChar.sendPacket(new ExShowScreenMessage("Welcome " + activeChar.getName() + ", you are fighting for the " + Config.FACTION_GOOD_TEAM_NAME + " faction.", 10000));
|
||||
}
|
||||
else if (activeChar.isEvil())
|
||||
{
|
||||
activeChar.getAppearance().setNameColor(Config.FACTION_EVIL_NAME_COLOR);
|
||||
activeChar.getAppearance().setTitleColor(Config.FACTION_EVIL_NAME_COLOR);
|
||||
activeChar.sendMessage("Welcome " + activeChar.getName() + ", you are fighting for the " + Config.FACTION_EVIL_TEAM_NAME + " faction.");
|
||||
activeChar.sendPacket(new ExShowScreenMessage("Welcome " + activeChar.getName() + ", you are fighting for the " + Config.FACTION_EVIL_TEAM_NAME + " faction.", 10000));
|
||||
}
|
||||
}
|
||||
|
||||
Quest.playerEnter(activeChar);
|
||||
|
||||
// Send Quest List
|
||||
activeChar.sendPacket(new QuestList());
|
||||
|
||||
boolean showClanNotice = false;
|
||||
|
||||
// Clan related checks are here
|
||||
if (activeChar.getClan() != null)
|
||||
{
|
||||
notifyClanMembers(activeChar);
|
||||
|
||||
notifySponsorOrApprentice(activeChar);
|
||||
|
||||
final AuctionableHall clanHall = ClanHallManager.getInstance().getClanHallByOwner(activeChar.getClan());
|
||||
|
||||
if (clanHall != null)
|
||||
{
|
||||
if (!clanHall.getPaid())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.PAYMENT_FOR_YOUR_CLAN_HALL_HAS_NOT_BEEN_MADE_PLEASE_MAKE_PAYMENT_TO_YOUR_CLAN_WAREHOUSE_BY_S1_TOMORROW);
|
||||
}
|
||||
}
|
||||
|
||||
for (Siege siege : SiegeManager.getInstance().getSieges())
|
||||
{
|
||||
if (!siege.isInProgress())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (siege.checkIsAttacker(activeChar.getClan()))
|
||||
{
|
||||
activeChar.setSiegeState((byte) 1);
|
||||
activeChar.setSiegeSide(siege.getCastle().getResidenceId());
|
||||
}
|
||||
else if (siege.checkIsDefender(activeChar.getClan()))
|
||||
{
|
||||
activeChar.setSiegeState((byte) 2);
|
||||
activeChar.setSiegeSide(siege.getCastle().getResidenceId());
|
||||
}
|
||||
}
|
||||
|
||||
for (FortSiege siege : FortSiegeManager.getInstance().getSieges())
|
||||
{
|
||||
if (!siege.isInProgress())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (siege.checkIsAttacker(activeChar.getClan()))
|
||||
{
|
||||
activeChar.setSiegeState((byte) 1);
|
||||
activeChar.setSiegeSide(siege.getFort().getResidenceId());
|
||||
}
|
||||
else if (siege.checkIsDefender(activeChar.getClan()))
|
||||
{
|
||||
activeChar.setSiegeState((byte) 2);
|
||||
activeChar.setSiegeSide(siege.getFort().getResidenceId());
|
||||
}
|
||||
}
|
||||
|
||||
for (SiegableHall hall : CHSiegeManager.getInstance().getConquerableHalls().values())
|
||||
{
|
||||
if (!hall.isInSiege())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (hall.isRegistered(activeChar.getClan()))
|
||||
{
|
||||
activeChar.setSiegeState((byte) 1);
|
||||
activeChar.setSiegeSide(hall.getId());
|
||||
activeChar.setIsInHideoutSiege(true);
|
||||
}
|
||||
}
|
||||
|
||||
// Residential skills support
|
||||
if (activeChar.getClan().getCastleId() > 0)
|
||||
{
|
||||
CastleManager.getInstance().getCastleByOwner(activeChar.getClan()).giveResidentialSkills(activeChar);
|
||||
}
|
||||
|
||||
if (activeChar.getClan().getFortId() > 0)
|
||||
{
|
||||
FortManager.getInstance().getFortByOwner(activeChar.getClan()).giveResidentialSkills(activeChar);
|
||||
}
|
||||
|
||||
showClanNotice = activeChar.getClan().isNoticeEnabled();
|
||||
|
||||
// Show clan crest
|
||||
if (activeChar.getClan().getCrestId() > 0)
|
||||
{
|
||||
sendPacket(new PledgeCrest(activeChar.getClan().getCrestId()));
|
||||
}
|
||||
// Show ally crest
|
||||
if (activeChar.getClan().getAllyCrestId() > 0)
|
||||
{
|
||||
sendPacket(new AllyCrest(activeChar.getClan().getAllyCrestId()));
|
||||
}
|
||||
}
|
||||
|
||||
if (!Config.DISABLE_TUTORIAL)
|
||||
{
|
||||
loadTutorial(activeChar);
|
||||
}
|
||||
|
||||
if (Config.PLAYER_SPAWN_PROTECTION > 0)
|
||||
{
|
||||
activeChar.setProtection(true);
|
||||
}
|
||||
|
||||
activeChar.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());
|
||||
activeChar.sendPacket(new ExRotation(activeChar.getObjectId(), activeChar.getHeading()));
|
||||
|
||||
activeChar.getInventory().applyItemSkills();
|
||||
|
||||
if (L2Event.isParticipant(activeChar))
|
||||
{
|
||||
L2Event.restorePlayerEventStatus(activeChar);
|
||||
}
|
||||
|
||||
// Wedding Checks
|
||||
if (Config.L2JMOD_ALLOW_WEDDING)
|
||||
{
|
||||
engage(activeChar);
|
||||
notifyPartner(activeChar, activeChar.getPartnerId());
|
||||
}
|
||||
|
||||
if (activeChar.isCursedWeaponEquipped())
|
||||
{
|
||||
CursedWeaponsManager.getInstance().getCursedWeapon(activeChar.getCursedWeaponEquippedId()).cursedOnLogin();
|
||||
}
|
||||
|
||||
if (Config.PC_BANG_ENABLED)
|
||||
{
|
||||
if (activeChar.getPcBangPoints() > 0)
|
||||
{
|
||||
activeChar.sendPacket(new ExPCCafePointInfo(activeChar.getPcBangPoints(), 0, 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(new ExPCCafePointInfo());
|
||||
}
|
||||
}
|
||||
|
||||
activeChar.updateEffectIcons();
|
||||
|
||||
// Expand Skill
|
||||
activeChar.sendPacket(new ExStorageMaxCount(activeChar));
|
||||
|
||||
// Friend list
|
||||
sendPacket(new L2FriendList(activeChar));
|
||||
|
||||
if (Config.SHOW_GOD_VIDEO_INTRO && activeChar.getVariables().getBoolean("intro_god_video", false))
|
||||
{
|
||||
activeChar.getVariables().remove("intro_god_video");
|
||||
if (activeChar.getRace() == Race.ERTHEIA)
|
||||
{
|
||||
activeChar.sendPacket(ExShowUsm.ERTHEIA_INTRO_FOR_ERTHEIA);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(ExShowUsm.ERTHEIA_INTRO_FOR_OTHERS);
|
||||
}
|
||||
}
|
||||
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOUR_FRIEND_S1_JUST_LOGGED_IN);
|
||||
sm.addString(activeChar.getName());
|
||||
for (int id : activeChar.getFriendList().keySet())
|
||||
{
|
||||
final L2Object obj = L2World.getInstance().findObject(id);
|
||||
if (obj != null)
|
||||
{
|
||||
obj.sendPacket(sm);
|
||||
}
|
||||
}
|
||||
|
||||
activeChar.broadcastUserInfo();
|
||||
// Send Inventory Info
|
||||
activeChar.sendPacket(new ExUserInfoInvenWeight(activeChar));
|
||||
// Send Adena / Inventory Count Info
|
||||
activeChar.sendPacket(new ExAdenaInvenCount(activeChar));
|
||||
// Send Equipped Items
|
||||
activeChar.sendPacket(new ExUserInfoEquipSlot(activeChar));
|
||||
|
||||
activeChar.sendPacket(SystemMessageId.WELCOME_TO_THE_WORLD_OF_LINEAGE_II);
|
||||
|
||||
AnnouncementsTable.getInstance().showAnnouncements(activeChar);
|
||||
|
||||
if (showClanNotice)
|
||||
{
|
||||
final NpcHtmlMessage notice = new NpcHtmlMessage();
|
||||
notice.setFile(activeChar.getHtmlPrefix(), "html/clanNotice.htm");
|
||||
notice.replace("%clan_name%", activeChar.getClan().getName());
|
||||
notice.replace("%notice_text%", activeChar.getClan().getNotice());
|
||||
notice.disableValidation();
|
||||
sendPacket(notice);
|
||||
}
|
||||
else if (Config.SERVER_NEWS)
|
||||
{
|
||||
final String serverNews = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/servnews.htm");
|
||||
if (serverNews != null)
|
||||
{
|
||||
sendPacket(new NpcHtmlMessage(serverNews));
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.PETITIONING_ALLOWED)
|
||||
{
|
||||
PetitionManager.getInstance().checkPetitionMessages(activeChar);
|
||||
}
|
||||
|
||||
if (activeChar.isAlikeDead()) // dead or fake dead
|
||||
{
|
||||
// no broadcast needed since the player will already spawn dead to others
|
||||
sendPacket(new Die(activeChar));
|
||||
}
|
||||
|
||||
activeChar.onPlayerEnter();
|
||||
|
||||
sendPacket(new SkillCoolTime(activeChar));
|
||||
sendPacket(new ExVoteSystemInfo(activeChar));
|
||||
|
||||
for (L2ItemInstance i : activeChar.getInventory().getItems())
|
||||
{
|
||||
if (i.isTimeLimitedItem())
|
||||
{
|
||||
i.scheduleLifeTimeTask();
|
||||
}
|
||||
if (i.isShadowItem() && i.isEquipped())
|
||||
{
|
||||
i.decreaseMana(false);
|
||||
}
|
||||
}
|
||||
|
||||
for (L2ItemInstance i : activeChar.getWarehouse().getItems())
|
||||
{
|
||||
if (i.isTimeLimitedItem())
|
||||
{
|
||||
i.scheduleLifeTimeTask();
|
||||
}
|
||||
}
|
||||
|
||||
if (activeChar.getClanJoinExpiryTime() > System.currentTimeMillis())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_HAVE_RECENTLY_BEEN_DISMISSED_FROM_A_CLAN_YOU_ARE_NOT_ALLOWED_TO_JOIN_ANOTHER_CLAN_FOR_24_HOURS);
|
||||
}
|
||||
|
||||
// remove combat flag before teleporting
|
||||
if (activeChar.getInventory().getItemByItemId(9819) != null)
|
||||
{
|
||||
final Fort fort = FortManager.getInstance().getFort(activeChar);
|
||||
if (fort != null)
|
||||
{
|
||||
FortSiegeManager.getInstance().dropCombatFlag(activeChar, fort.getResidenceId());
|
||||
}
|
||||
else
|
||||
{
|
||||
final int slot = activeChar.getInventory().getSlotFromItem(activeChar.getInventory().getItemByItemId(9819));
|
||||
activeChar.getInventory().unEquipItemInBodySlot(slot);
|
||||
activeChar.destroyItem("CombatFlag", activeChar.getInventory().getItemByItemId(9819), null, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Attacker or spectator logging in to a siege zone.
|
||||
// Actually should be checked for inside castle only?
|
||||
if (!activeChar.canOverrideCond(PcCondOverride.ZONE_CONDITIONS) && activeChar.isInsideZone(ZoneId.SIEGE) && (!activeChar.isInSiege() || (activeChar.getSiegeState() < 2)))
|
||||
{
|
||||
activeChar.teleToLocation(TeleportWhereType.TOWN);
|
||||
}
|
||||
|
||||
// Remove demonic weapon if character is not cursed weapon equipped
|
||||
if ((activeChar.getInventory().getItemByItemId(8190) != null) && !activeChar.isCursedWeaponEquipped())
|
||||
{
|
||||
activeChar.destroyItem("Zariche", activeChar.getInventory().getItemByItemId(8190), null, true);
|
||||
}
|
||||
if ((activeChar.getInventory().getItemByItemId(8689) != null) && !activeChar.isCursedWeaponEquipped())
|
||||
{
|
||||
activeChar.destroyItem("Akamanah", activeChar.getInventory().getItemByItemId(8689), null, true);
|
||||
}
|
||||
|
||||
if (Config.ALLOW_MAIL)
|
||||
{
|
||||
if (MailManager.getInstance().hasUnreadPost(activeChar))
|
||||
{
|
||||
sendPacket(ExNoticePostArrived.valueOf(false));
|
||||
}
|
||||
}
|
||||
|
||||
TvTEvent.onLogin(activeChar);
|
||||
|
||||
if (Config.WELCOME_MESSAGE_ENABLED)
|
||||
{
|
||||
activeChar.sendPacket(new ExShowScreenMessage(Config.WELCOME_MESSAGE_TEXT, Config.WELCOME_MESSAGE_TIME));
|
||||
}
|
||||
|
||||
L2ClassMasterInstance.showQuestionMark(activeChar);
|
||||
|
||||
final int birthday = activeChar.checkBirthDay();
|
||||
if (birthday == 0)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.HAPPY_BIRTHDAY_ALEGRIA_HAS_SENT_YOU_A_BIRTHDAY_GIFT);
|
||||
// activeChar.sendPacket(new ExBirthdayPopup()); Removed in H5?
|
||||
}
|
||||
else if (birthday != -1)
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.THERE_ARE_S1_DAYS_REMAINING_UNTIL_YOUR_BIRTHDAY_ON_YOUR_BIRTHDAY_YOU_WILL_RECEIVE_A_GIFT_THAT_ALEGRIA_HAS_CAREFULLY_PREPARED);
|
||||
sm.addString(Integer.toString(birthday));
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
|
||||
if (!activeChar.getPremiumItemList().isEmpty())
|
||||
{
|
||||
activeChar.sendPacket(ExNotifyPremiumItem.STATIC_PACKET);
|
||||
}
|
||||
|
||||
if ((Config.OFFLINE_TRADE_ENABLE || Config.OFFLINE_CRAFT_ENABLE) && Config.STORE_OFFLINE_TRADE_IN_REALTIME)
|
||||
{
|
||||
OfflineTradersTable.onTransaction(activeChar, true, false);
|
||||
}
|
||||
|
||||
if (BeautyShopData.getInstance().hasBeautyData(activeChar.getRace(), activeChar.getAppearance().getSexType()))
|
||||
{
|
||||
activeChar.sendPacket(new ExBeautyItemList(activeChar));
|
||||
}
|
||||
|
||||
if (SkillTreesData.getInstance().hasAvailableSkills(activeChar, activeChar.getClassId()))
|
||||
{
|
||||
activeChar.sendPacket(ExNewSkillToLearnByLevelUp.STATIC_PACKET);
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new ExAcquireAPSkillList(activeChar));
|
||||
activeChar.sendPacket(new ExWorldChatCnt(activeChar));
|
||||
|
||||
// Underground auto shots system.
|
||||
activeChar.sendPacket(new ExAutoSoulShot(0, 0, 0));
|
||||
activeChar.sendPacket(new ExAutoSoulShot(0, 0, 1));
|
||||
activeChar.sendPacket(new ExAutoSoulShot(0, 0, 2));
|
||||
activeChar.sendPacket(new ExAutoSoulShot(0, 0, 3));
|
||||
|
||||
// Underground daily rewards system.
|
||||
activeChar.sendPacket(ExConnectedTimeAndGetTableReward.STATIC_PACKET);
|
||||
|
||||
// Unstuck players that had client open when server crashed.
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
|
||||
private void engage(L2PcInstance cha)
|
||||
{
|
||||
final int chaId = cha.getObjectId();
|
||||
|
||||
for (Couple cl : CoupleManager.getInstance().getCouples())
|
||||
{
|
||||
if ((cl.getPlayer1Id() == chaId) || (cl.getPlayer2Id() == chaId))
|
||||
{
|
||||
if (cl.getMaried())
|
||||
{
|
||||
cha.setMarried(true);
|
||||
}
|
||||
|
||||
cha.setCoupleId(cl.getId());
|
||||
|
||||
if (cl.getPlayer1Id() == chaId)
|
||||
{
|
||||
cha.setPartnerId(cl.getPlayer2Id());
|
||||
}
|
||||
else
|
||||
{
|
||||
cha.setPartnerId(cl.getPlayer1Id());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cha
|
||||
* @param partnerId
|
||||
*/
|
||||
private void notifyPartner(L2PcInstance cha, int partnerId)
|
||||
{
|
||||
final int objId = cha.getPartnerId();
|
||||
if (objId != 0)
|
||||
{
|
||||
final L2PcInstance partner = L2World.getInstance().getPlayer(objId);
|
||||
if (partner != null)
|
||||
{
|
||||
partner.sendMessage("Your Partner has logged in.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
*/
|
||||
private void notifyClanMembers(L2PcInstance activeChar)
|
||||
{
|
||||
final L2Clan clan = activeChar.getClan();
|
||||
if (clan != null)
|
||||
{
|
||||
clan.getClanMember(activeChar.getObjectId()).setPlayerInstance(activeChar);
|
||||
|
||||
final SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.CLAN_MEMBER_S1_HAS_LOGGED_INTO_GAME);
|
||||
msg.addString(activeChar.getName());
|
||||
clan.broadcastToOtherOnlineMembers(msg, activeChar);
|
||||
clan.broadcastToOtherOnlineMembers(new PledgeShowMemberListUpdate(activeChar), activeChar);
|
||||
clan.broadcastToOnlineMembers(new ExPledgeCount(clan));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
*/
|
||||
private void notifySponsorOrApprentice(L2PcInstance activeChar)
|
||||
{
|
||||
if (activeChar.getSponsor() != 0)
|
||||
{
|
||||
final L2PcInstance sponsor = L2World.getInstance().getPlayer(activeChar.getSponsor());
|
||||
if (sponsor != null)
|
||||
{
|
||||
final SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.YOUR_APPRENTICE_S1_HAS_LOGGED_IN);
|
||||
msg.addString(activeChar.getName());
|
||||
sponsor.sendPacket(msg);
|
||||
}
|
||||
}
|
||||
else if (activeChar.getApprentice() != 0)
|
||||
{
|
||||
final L2PcInstance apprentice = L2World.getInstance().getPlayer(activeChar.getApprentice());
|
||||
if (apprentice != null)
|
||||
{
|
||||
final SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.YOUR_SPONSOR_C1_HAS_LOGGED_IN);
|
||||
msg.addString(activeChar.getName());
|
||||
apprentice.sendPacket(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadTutorial(L2PcInstance player)
|
||||
{
|
||||
QuestState qs = player.getQuestState("Q00255_Tutorial");
|
||||
if (qs == null)
|
||||
{
|
||||
qs = QuestManager.getInstance().getQuest("Q00255_Tutorial").newQuestState(player);
|
||||
qs.setState(State.STARTED);
|
||||
}
|
||||
qs.getQuest().notifyEvent("user_connected", null, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__11_ENTERWORLD;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
/**
|
||||
* Format: (c) dddd d: dx d: dy d: dz d: AirShip id ??
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class ExGetOnAirShip extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_36_EXGETONAIRSHIP = "[C] D0:36 ExGetOnAirShip";
|
||||
|
||||
private int _x;
|
||||
private int _y;
|
||||
private int _z;
|
||||
private int _shipId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_x = readD();
|
||||
_y = readD();
|
||||
_z = readD();
|
||||
_shipId = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
_log.info("[T1:ExGetOnAirShip] x: " + _x);
|
||||
_log.info("[T1:ExGetOnAirShip] y: " + _y);
|
||||
_log.info("[T1:ExGetOnAirShip] z: " + _z);
|
||||
_log.info("[T1:ExGetOnAirShip] ship ID: " + _shipId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_36_EXGETONAIRSHIP;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
public class ExPCCafeRequestOpenWindowWithoutNPC extends L2GameClientPacket
|
||||
{
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance _activeChar = getClient().getActiveChar();
|
||||
if ((_activeChar != null) && Config.PC_BANG_ENABLED)
|
||||
{
|
||||
getHtmlPage(_activeChar);
|
||||
}
|
||||
}
|
||||
|
||||
public void getHtmlPage(L2PcInstance player)
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage();
|
||||
html.setFile(player.getHtmlPrefix(), "html/pccafe.htm");
|
||||
player.sendPacket(html);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return getClass().getName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.StopRotation;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.1.4.3 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public final class FinishRotating extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__5C_FINISHROTATING = "[C] 5C FinishRotating";
|
||||
|
||||
private int _degree;
|
||||
@SuppressWarnings("unused")
|
||||
private int _unknown;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_degree = readD();
|
||||
_unknown = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
StopRotation sr;
|
||||
if (activeChar.isInAirShip() && activeChar.getAirShip().isCaptain(activeChar))
|
||||
{
|
||||
activeChar.getAirShip().setHeading(_degree);
|
||||
sr = new StopRotation(activeChar.getAirShip().getObjectId(), _degree, 0);
|
||||
activeChar.getAirShip().broadcastPacket(sr);
|
||||
}
|
||||
else
|
||||
{
|
||||
sr = new StopRotation(activeChar.getObjectId(), _degree, 0);
|
||||
activeChar.broadcastPacket(sr);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__5C_FINISHROTATING;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
|
||||
/**
|
||||
* Format: c dddd
|
||||
* @author KenM
|
||||
*/
|
||||
public class GameGuardReply extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__CB_GAMEGUARDREPLY = "[C] CB GameGuardReply";
|
||||
|
||||
private static final byte[] VALID =
|
||||
{
|
||||
(byte) 0x88,
|
||||
0x40,
|
||||
0x1c,
|
||||
(byte) 0xa7,
|
||||
(byte) 0x83,
|
||||
0x42,
|
||||
(byte) 0xe9,
|
||||
0x15,
|
||||
(byte) 0xde,
|
||||
(byte) 0xc3,
|
||||
0x68,
|
||||
(byte) 0xf6,
|
||||
0x2d,
|
||||
0x23,
|
||||
(byte) 0xf1,
|
||||
0x3f,
|
||||
(byte) 0xee,
|
||||
0x68,
|
||||
0x5b,
|
||||
(byte) 0xc5,
|
||||
};
|
||||
|
||||
private final byte[] _reply = new byte[8];
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
readB(_reply, 0, 4);
|
||||
readD();
|
||||
readB(_reply, 4, 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2GameClient client = getClient();
|
||||
try
|
||||
{
|
||||
final MessageDigest md = MessageDigest.getInstance("SHA");
|
||||
final byte[] result = md.digest(_reply);
|
||||
if (Arrays.equals(result, VALID))
|
||||
{
|
||||
client.setGameGuardOk(true);
|
||||
}
|
||||
}
|
||||
catch (NoSuchAlgorithmException e)
|
||||
{
|
||||
_log.log(Level.WARNING, "", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__CB_GAMEGUARDREPLY;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import java.nio.BufferUnderflowException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.mmocore.ReceivablePacket;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* Packets received by the game server from clients
|
||||
* @author KenM
|
||||
*/
|
||||
public abstract class L2GameClientPacket extends ReceivablePacket<L2GameClient>
|
||||
{
|
||||
protected static final Logger _log = Logger.getLogger(L2GameClientPacket.class.getName());
|
||||
|
||||
@Override
|
||||
public boolean read()
|
||||
{
|
||||
try
|
||||
{
|
||||
readImpl();
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.SEVERE, "Client: " + getClient().toString() + " - Failed reading: " + getType() + " ; " + e.getMessage(), e);
|
||||
|
||||
if (e instanceof BufferUnderflowException)
|
||||
{
|
||||
getClient().onBufferUnderflow();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected abstract void readImpl();
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
runImpl();
|
||||
|
||||
/*
|
||||
* Removes onspawn protection - player has faster computer than average Since GE: True for all packets except RequestItemList and UseItem (in case the item is a Scroll of Escape (736)
|
||||
*/
|
||||
if (triggersOnActionRequest())
|
||||
{
|
||||
final L2PcInstance actor = getClient().getActiveChar();
|
||||
if ((actor != null) && (actor.isSpawnProtected() || actor.isInvul()))
|
||||
{
|
||||
actor.onActionRequest();
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.info("Spawn protection for player " + actor.getName() + " removed by packet: " + getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
_log.log(Level.SEVERE, "Client: " + getClient().toString() + " - Failed running: " + getType() + " ; " + t.getMessage(), t);
|
||||
// in case of EnterWorld error kick player from game
|
||||
if (this instanceof EnterWorld)
|
||||
{
|
||||
getClient().closeNow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void runImpl();
|
||||
|
||||
/**
|
||||
* Sends a game server packet to the client.
|
||||
* @param gsp the game server packet
|
||||
*/
|
||||
protected final void sendPacket(L2GameServerPacket gsp)
|
||||
{
|
||||
getClient().sendPacket(gsp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a system message to the client.
|
||||
* @param id the system message Id
|
||||
*/
|
||||
public void sendPacket(SystemMessageId id)
|
||||
{
|
||||
sendPacket(SystemMessage.getSystemMessage(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A String with this packet name for debugging purposes
|
||||
*/
|
||||
public String getType()
|
||||
{
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden with true value on some packets that should disable spawn protection (RequestItemList and UseItem only)
|
||||
* @return
|
||||
*/
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the active player if exist, otherwise null.
|
||||
*/
|
||||
protected final L2PcInstance getActiveChar()
|
||||
{
|
||||
return getClient().getActiveChar();
|
||||
}
|
||||
|
||||
protected final void sendActionFailed()
|
||||
{
|
||||
if (getClient() != null)
|
||||
{
|
||||
getClient().sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.L2Event;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.9.4.3 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public final class Logout extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__00_LOGOUT = "[C] 00 Logout";
|
||||
protected static final Logger _logAccounting = Logger.getLogger("accounting");
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance player = getClient().getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.hasItemRequest())
|
||||
{
|
||||
player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.isLocked())
|
||||
{
|
||||
_log.warning("Player " + player.getName() + " tried to logout during class change.");
|
||||
player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't allow leaving if player is fighting
|
||||
if (AttackStanceTaskManager.getInstance().hasAttackStanceTask(player))
|
||||
{
|
||||
if (player.isGM() && Config.GM_RESTART_FIGHTING)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_EXIT_THE_GAME_WHILE_IN_COMBAT);
|
||||
player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if (L2Event.isParticipant(player))
|
||||
{
|
||||
player.sendMessage("A superior power doesn't allow you to leave the event.");
|
||||
player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove player from Boss Zone
|
||||
player.removeFromBossZone();
|
||||
|
||||
final LogRecord record = new LogRecord(Level.INFO, "Disconnected");
|
||||
record.setParameters(new Object[]
|
||||
{
|
||||
getClient()
|
||||
});
|
||||
_logAccounting.log(record);
|
||||
|
||||
player.logout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__00_LOGOUT;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import java.nio.BufferUnderflowException;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.instancemanager.JumpManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.JumpManager.JumpWay;
|
||||
import com.l2jmobius.gameserver.model.Location;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExFlyMove;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.StopMove;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.11.2.4.2.4 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public class MoveBackwardToLocation extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__0F_MOVEBACKWARDTOLOC = "[C] 0F MoveBackwardToLoc";
|
||||
|
||||
// cdddddd
|
||||
private int _targetX;
|
||||
private int _targetY;
|
||||
private int _targetZ;
|
||||
private int _originX;
|
||||
private int _originY;
|
||||
private int _originZ;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private int _moveMovement;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_targetX = readD();
|
||||
_targetY = readD();
|
||||
_targetZ = readD();
|
||||
_originX = readD();
|
||||
_originY = readD();
|
||||
_originZ = readD();
|
||||
try
|
||||
{
|
||||
_moveMovement = readD(); // is 0 if cursor keys are used 1 if mouse is used
|
||||
}
|
||||
catch (BufferUnderflowException e)
|
||||
{
|
||||
if (Config.L2WALKER_PROTECTION)
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " is trying to use L2Walker and got kicked.", Config.DEFAULT_PUNISH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((Config.PLAYER_MOVEMENT_BLOCK_TIME > 0) && !activeChar.isGM() && (activeChar.getNotMoveUntil() > System.currentTimeMillis()))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_MOVE_WHILE_SPEAKING_TO_AN_NPC_ONE_MOMENT_PLEASE);
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_targetX == _originX) && (_targetY == _originY) && (_targetZ == _originZ))
|
||||
{
|
||||
activeChar.sendPacket(new StopMove(activeChar));
|
||||
return;
|
||||
}
|
||||
|
||||
// Correcting targetZ from floor level to head level (?)
|
||||
// Client is giving floor level as targetZ but that floor level doesn't
|
||||
// match our current geodata and teleport coords as good as head level!
|
||||
// L2J uses floor, not head level as char coordinates. This is some
|
||||
// sort of incompatibility fix.
|
||||
// Validate position packets sends head level.
|
||||
_targetZ += activeChar.getTemplate().getCollisionHeight();
|
||||
|
||||
if (activeChar.getTeleMode() > 0)
|
||||
{
|
||||
// Sayune
|
||||
if ((activeChar.getTeleMode() == 3) || (activeChar.getTeleMode() == 4))
|
||||
{
|
||||
if (activeChar.getTeleMode() == 3)
|
||||
{
|
||||
activeChar.setTeleMode(0);
|
||||
}
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
activeChar.stopMove(null, false);
|
||||
activeChar.abortAttack();
|
||||
activeChar.abortCast();
|
||||
activeChar.setTarget(null);
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
|
||||
final JumpWay jw = JumpManager.getInstance().new JumpWay();
|
||||
jw.add(JumpManager.getInstance().new JumpNode(_targetX, _targetY, _targetZ, -1));
|
||||
activeChar.sendPacket(new ExFlyMove(activeChar.getObjectId(), -1, jw));
|
||||
activeChar.setXYZ(_targetX, _targetY, _targetZ);
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.getTeleMode() == 1)
|
||||
{
|
||||
activeChar.setTeleMode(0);
|
||||
}
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
activeChar.teleToLocation(new Location(_targetX, _targetY, _targetZ));
|
||||
return;
|
||||
}
|
||||
|
||||
final double dx = _targetX - activeChar.getX();
|
||||
final double dy = _targetY - activeChar.getY();
|
||||
// Can't move if character is confused, or trying to move a huge distance
|
||||
if (activeChar.isOutOfControl() || (((dx * dx) + (dy * dy)) > 98010000)) // 9900*9900
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(_targetX, _targetY, _targetZ));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__0F_MOVEBACKWARDTOLOC;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.instancemanager.AirShipManager;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.Location;
|
||||
import com.l2jmobius.gameserver.model.VehiclePathPoint;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2AirShipInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
public class MoveToLocationAirShip extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_38_MOVETOLOCATIONAIRSHIP = "[C] D0:38 MoveToLocationAirShip";
|
||||
|
||||
public static final int MIN_Z = -895;
|
||||
public static final int MAX_Z = 6105;
|
||||
public static final int STEP = 300;
|
||||
|
||||
private int _command;
|
||||
private int _param1;
|
||||
private int _param2 = 0;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_command = readD();
|
||||
_param1 = readD();
|
||||
if (_buf.remaining() > 0)
|
||||
{
|
||||
_param2 = readD();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!activeChar.isInAirShip())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2AirShipInstance ship = activeChar.getAirShip();
|
||||
if (!ship.isCaptain(activeChar))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int z = ship.getZ();
|
||||
|
||||
switch (_command)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if (!ship.canBeControlled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_param1 < L2World.GRACIA_MAX_X)
|
||||
{
|
||||
ship.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(_param1, _param2, z));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if (!ship.canBeControlled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
ship.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
if (!ship.canBeControlled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (z < L2World.GRACIA_MAX_Z)
|
||||
{
|
||||
z = Math.min(z + STEP, L2World.GRACIA_MAX_Z);
|
||||
ship.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(ship.getX(), ship.getY(), z));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
if (!ship.canBeControlled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (z > L2World.GRACIA_MIN_Z)
|
||||
{
|
||||
z = Math.max(z - STEP, L2World.GRACIA_MIN_Z);
|
||||
ship.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(ship.getX(), ship.getY(), z));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
if (!ship.isInDock() || ship.isMoving())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final VehiclePathPoint[] dst = AirShipManager.getInstance().getTeleportDestination(ship.getDockId(), _param1);
|
||||
if (dst == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Consume fuel, if needed
|
||||
final int fuelConsumption = AirShipManager.getInstance().getFuelConsumption(ship.getDockId(), _param1);
|
||||
if (fuelConsumption > 0)
|
||||
{
|
||||
if (fuelConsumption > ship.getFuel())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOUR_AIRSHIP_CANNOT_TELEPORT_BECAUSE_DUE_TO_LOW_FUEL);
|
||||
return;
|
||||
}
|
||||
ship.setFuel(ship.getFuel() - fuelConsumption);
|
||||
}
|
||||
|
||||
ship.executePath(dst);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_38_MOVETOLOCATIONAIRSHIP;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.Location;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2AirShipInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.type.WeaponType;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExMoveToLocationInAirShip;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.StopMoveInVehicle;
|
||||
|
||||
/**
|
||||
* format: ddddddd X:%d Y:%d Z:%d OriginX:%d OriginY:%d OriginZ:%d
|
||||
* @author GodKratos
|
||||
*/
|
||||
public class MoveToLocationInAirShip extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_20_MOVETOLOCATIONINAIRSHIP = "[C] D0:20 MoveToLocationInAirShip";
|
||||
|
||||
private int _shipId;
|
||||
private int _targetX;
|
||||
private int _targetY;
|
||||
private int _targetZ;
|
||||
private int _originX;
|
||||
private int _originY;
|
||||
private int _originZ;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_shipId = readD();
|
||||
_targetX = readD();
|
||||
_targetY = readD();
|
||||
_targetZ = readD();
|
||||
_originX = readD();
|
||||
_originY = readD();
|
||||
_originZ = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_targetX == _originX) && (_targetY == _originY) && (_targetZ == _originZ))
|
||||
{
|
||||
activeChar.sendPacket(new StopMoveInVehicle(activeChar, _shipId));
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.isAttackingNow() && (activeChar.getActiveWeaponItem() != null) && (activeChar.getActiveWeaponItem().getItemType() == WeaponType.BOW))
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.isSitting() || activeChar.isMovementDisabled())
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!activeChar.isInAirShip())
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
final L2AirShipInstance airShip = activeChar.getAirShip();
|
||||
if (airShip.getObjectId() != _shipId)
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
activeChar.setInVehiclePosition(new Location(_targetX, _targetY, _targetZ));
|
||||
activeChar.broadcastPacket(new ExMoveToLocationInAirShip(activeChar));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_20_MOVETOLOCATIONINAIRSHIP;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
/**
|
||||
* Format: (c) ddd d: dx d: dy d: dz
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class MoveWithDelta extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__52_MOVEWITHDELTA = "[C] 52 MoveWithDelta";
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private int _dx;
|
||||
@SuppressWarnings("unused")
|
||||
private int _dy;
|
||||
@SuppressWarnings("unused")
|
||||
private int _dz;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_dx = readD();
|
||||
_dy = readD();
|
||||
_dz = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
// TODO this
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__52_MOVEWITHDELTA;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,478 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import static com.l2jmobius.gameserver.model.actor.L2Npc.INTERACTION_DISTANCE;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.MultisellData;
|
||||
import com.l2jmobius.gameserver.model.Elementals;
|
||||
import com.l2jmobius.gameserver.model.L2Augmentation;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.PcInventory;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.multisell.Entry;
|
||||
import com.l2jmobius.gameserver.model.multisell.Ingredient;
|
||||
import com.l2jmobius.gameserver.model.multisell.PreparedListContainer;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExUserInfoInvenWeight;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ItemList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.util.Rnd;
|
||||
|
||||
/**
|
||||
* The Class MultiSellChoose.
|
||||
*/
|
||||
public class MultiSellChoose extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__B0_MULTISELLCHOOSE = "[C] B0 MultiSellChoose";
|
||||
|
||||
private int _listId;
|
||||
private int _entryId;
|
||||
private long _amount;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_listId = readD();
|
||||
_entryId = readD();
|
||||
_amount = readQ();
|
||||
// _unk1 = readH();
|
||||
// _unk2 = readD();
|
||||
// _unk3 = readD();
|
||||
// _unk4 = readH(); // elemental attributes
|
||||
// _unk5 = readH(); // elemental attributes
|
||||
// _unk6 = readH(); // elemental attributes
|
||||
// _unk7 = readH(); // elemental attributes
|
||||
// _unk8 = readH(); // elemental attributes
|
||||
// _unk9 = readH(); // elemental attributes
|
||||
// _unk10 = readH(); // elemental attributes
|
||||
// _unk11 = readH(); // elemental attributes
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runImpl()
|
||||
{
|
||||
final L2PcInstance player = getClient().getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!getClient().getFloodProtectors().getMultiSell().tryPerformAction("multisell choose"))
|
||||
{
|
||||
player.setMultiSell(null);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_amount < 1) || (_amount > 5000))
|
||||
{
|
||||
player.setMultiSell(null);
|
||||
return;
|
||||
}
|
||||
|
||||
final PreparedListContainer list = player.getMultiSell();
|
||||
if ((list == null) || (list.getListId() != _listId))
|
||||
{
|
||||
player.setMultiSell(null);
|
||||
return;
|
||||
}
|
||||
|
||||
final L2Npc npc = player.getLastFolkNPC();
|
||||
if (!list.isNpcAllowed(-1) && (((npc != null) && !list.isNpcAllowed(npc.getId())) || ((npc == null) && list.isNpcOnly())))
|
||||
{
|
||||
player.setMultiSell(null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.isGM() && (npc != null) && !list.isNpcAllowed(-1))
|
||||
{
|
||||
if (!player.isInsideRadius(npc, INTERACTION_DISTANCE, true, false) || (player.getInstanceId() != npc.getInstanceId()))
|
||||
{
|
||||
player.setMultiSell(null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (Entry entry : list.getEntries())
|
||||
{
|
||||
if (entry.getEntryId() == _entryId)
|
||||
{
|
||||
if (!entry.isStackable() && (_amount > 1))
|
||||
{
|
||||
_log.severe("Character: " + player.getName() + " is trying to set amount > 1 on non-stackable multisell, id:" + _listId + ":" + _entryId);
|
||||
player.setMultiSell(null);
|
||||
return;
|
||||
}
|
||||
|
||||
final PcInventory inv = player.getInventory();
|
||||
|
||||
int slots = 0;
|
||||
int weight = 0;
|
||||
for (Ingredient e : entry.getProducts())
|
||||
{
|
||||
if (e.getItemId() < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!e.isStackable())
|
||||
{
|
||||
slots += e.getItemCount() * _amount;
|
||||
}
|
||||
else if (player.getInventory().getItemByItemId(e.getItemId()) == null)
|
||||
{
|
||||
slots++;
|
||||
}
|
||||
weight += e.getItemCount() * _amount * e.getWeight();
|
||||
}
|
||||
|
||||
if (!inv.validateWeight(weight))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_HAVE_EXCEEDED_THE_WEIGHT_LIMIT);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!inv.validateCapacity(slots))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOUR_INVENTORY_IS_FULL);
|
||||
return;
|
||||
}
|
||||
|
||||
final ArrayList<Ingredient> ingredientsList = new ArrayList<>(entry.getIngredients().size());
|
||||
// Generate a list of distinct ingredients and counts in order to check if the correct item-counts
|
||||
// are possessed by the player
|
||||
boolean newIng;
|
||||
for (Ingredient e : entry.getIngredients())
|
||||
{
|
||||
newIng = true;
|
||||
// at this point, the template has already been modified so that enchantments are properly included
|
||||
// whenever they need to be applied. Uniqueness of items is thus judged by item id AND enchantment level
|
||||
for (int i = ingredientsList.size(); --i >= 0;)
|
||||
{
|
||||
final Ingredient ex = ingredientsList.get(i);
|
||||
// if the item was already added in the list, merely increment the count
|
||||
// this happens if 1 list entry has the same ingredient twice (example 2 swords = 1 dual)
|
||||
if ((ex.getItemId() == e.getItemId()) && (ex.getEnchantLevel() == e.getEnchantLevel()))
|
||||
{
|
||||
if ((ex.getItemCount() + e.getItemCount()) > Integer.MAX_VALUE)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_HAVE_EXCEEDED_THE_QUANTITY_THAT_CAN_BE_INPUTTED);
|
||||
return;
|
||||
}
|
||||
// two same ingredients, merge into one and replace old
|
||||
final Ingredient ing = ex.getCopy();
|
||||
ing.setItemCount(ex.getItemCount() + e.getItemCount());
|
||||
ingredientsList.set(i, ing);
|
||||
newIng = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (newIng)
|
||||
{
|
||||
// if it's a new ingredient, just store its info directly (item id, count, enchantment)
|
||||
ingredientsList.add(e);
|
||||
}
|
||||
}
|
||||
|
||||
// now check if the player has sufficient items in the inventory to cover the ingredients' expences
|
||||
for (Ingredient e : ingredientsList)
|
||||
{
|
||||
if ((e.getItemCount() * _amount) > Integer.MAX_VALUE)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_HAVE_EXCEEDED_THE_QUANTITY_THAT_CAN_BE_INPUTTED);
|
||||
return;
|
||||
}
|
||||
if (e.getItemId() < 0)
|
||||
{
|
||||
if (!MultisellData.hasSpecialIngredient(e.getItemId(), e.getItemCount() * _amount, player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// if this is not a list that maintains enchantment, check the count of all items that have the given id.
|
||||
// otherwise, check only the count of items with exactly the needed enchantment level
|
||||
final long required = ((Config.ALT_BLACKSMITH_USE_RECIPES || !e.getMaintainIngredient()) ? (e.getItemCount() * _amount) : e.getItemCount());
|
||||
if (inv.getInventoryItemCount(e.getItemId(), (list.getMaintainEnchantment() || (e.getEnchantLevel() > 0)) ? e.getEnchantLevel() : -1, false) < required)
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_NEED_S2_S1_S);
|
||||
sm.addItemName(e.getTemplate());
|
||||
sm.addLong(required);
|
||||
player.sendPacket(sm);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final List<L2Augmentation> augmentation = new ArrayList<>();
|
||||
Elementals[] elemental = null;
|
||||
/** All ok, remove items and add final product */
|
||||
|
||||
for (Ingredient e : entry.getIngredients())
|
||||
{
|
||||
if (e.getItemId() < 0)
|
||||
{
|
||||
if (!MultisellData.takeSpecialIngredient(e.getItemId(), e.getItemCount() * _amount, player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
L2ItemInstance itemToTake = inv.getItemByItemId(e.getItemId()); // initialize and initial guess for the item to take.
|
||||
if (itemToTake == null)
|
||||
{ // this is a cheat, transaction will be aborted and if any items already taken will not be returned back to inventory!
|
||||
_log.severe("Character: " + player.getName() + " is trying to cheat in multisell, id:" + _listId + ":" + _entryId);
|
||||
player.setMultiSell(null);
|
||||
return;
|
||||
}
|
||||
|
||||
// if (itemToTake.isEquipped())
|
||||
// {
|
||||
// this is a cheat, transaction will be aborted and if any items already taken will not be returned back to inventory!
|
||||
// _log.severe("Character: " + player.getName() + " is trying to cheat in multisell, exchanging equipped item, merchatnt id:" + merchant.getNpcId());
|
||||
// player.setMultiSell(null);
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (Config.ALT_BLACKSMITH_USE_RECIPES || !e.getMaintainIngredient())
|
||||
{
|
||||
// if it's a stackable item, just reduce the amount from the first (only) instance that is found in the inventory
|
||||
if (itemToTake.isStackable())
|
||||
{
|
||||
if (!player.destroyItem("Multisell", itemToTake.getObjectId(), (e.getItemCount() * _amount), player.getTarget(), true))
|
||||
{
|
||||
player.setMultiSell(null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// for non-stackable items, one of two scenaria are possible:
|
||||
// a) list maintains enchantment: get the instances that exactly match the requested enchantment level
|
||||
// b) list does not maintain enchantment: get the instances with the LOWEST enchantment level
|
||||
|
||||
// a) if enchantment is maintained, then get a list of items that exactly match this enchantment
|
||||
if (list.getMaintainEnchantment() || (e.getEnchantLevel() > 0))
|
||||
{
|
||||
// loop through this list and remove (one by one) each item until the required amount is taken.
|
||||
final L2ItemInstance[] inventoryContents = inv.getAllItemsByItemId(e.getItemId(), e.getEnchantLevel(), false);
|
||||
for (int i = 0; i < (e.getItemCount() * _amount); i++)
|
||||
{
|
||||
if (inventoryContents[i].isAugmented())
|
||||
{
|
||||
augmentation.add(inventoryContents[i].getAugmentation());
|
||||
}
|
||||
if (inventoryContents[i].getElementals() != null)
|
||||
{
|
||||
elemental = inventoryContents[i].getElementals();
|
||||
}
|
||||
if (!player.destroyItem("Multisell", inventoryContents[i].getObjectId(), 1, player.getTarget(), true))
|
||||
{
|
||||
player.setMultiSell(null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
// b) enchantment is not maintained. Get the instances with the LOWEST enchantment level
|
||||
{
|
||||
// NOTE: There are 2 ways to achieve the above goal.
|
||||
// 1) Get all items that have the correct itemId, loop through them until the lowest enchantment
|
||||
// level is found. Repeat all this for the next item until proper count of items is reached.
|
||||
// 2) Get all items that have the correct itemId, sort them once based on enchantment level,
|
||||
// and get the range of items that is necessary.
|
||||
// Method 1 is faster for a small number of items to be exchanged.
|
||||
// Method 2 is faster for large amounts.
|
||||
//
|
||||
// EXPLANATION:
|
||||
// Worst case scenario for algorithm 1 will make it run in a number of cycles given by:
|
||||
// m*(2n-m+1)/2 where m is the number of items to be exchanged and n is the total
|
||||
// number of inventory items that have a matching id.
|
||||
// With algorithm 2 (sort), sorting takes n*log(n) time and the choice is done in a single cycle
|
||||
// for case b (just grab the m first items) or in linear time for case a (find the beginning of items
|
||||
// with correct enchantment, index x, and take all items from x to x+m).
|
||||
// Basically, whenever m > log(n) we have: m*(2n-m+1)/2 = (2nm-m*m+m)/2 >
|
||||
// (2nlogn-logn*logn+logn)/2 = nlog(n) - log(n*n) + log(n) = nlog(n) + log(n/n*n) =
|
||||
// nlog(n) + log(1/n) = nlog(n) - log(n) = (n-1)log(n)
|
||||
// So for m < log(n) then m*(2n-m+1)/2 > (n-1)log(n) and m*(2n-m+1)/2 > nlog(n)
|
||||
//
|
||||
// IDEALLY:
|
||||
// In order to best optimize the performance, choose which algorithm to run, based on whether 2^m > n
|
||||
// if ( (2<<(e.getItemCount()// _amount)) < inventoryContents.length )
|
||||
// // do Algorithm 1, no sorting
|
||||
// else
|
||||
// // do Algorithm 2, sorting
|
||||
//
|
||||
// CURRENT IMPLEMENTATION:
|
||||
// In general, it is going to be very rare for a person to do a massive exchange of non-stackable items
|
||||
// For this reason, we assume that algorithm 1 will always suffice and we keep things simple.
|
||||
// If, in the future, it becomes necessary that we optimize, the above discussion should make it clear
|
||||
// what optimization exactly is necessary (based on the comments under "IDEALLY").
|
||||
//
|
||||
|
||||
// choice 1. Small number of items exchanged. No sorting.
|
||||
for (int i = 1; i <= (e.getItemCount() * _amount); i++)
|
||||
{
|
||||
final L2ItemInstance[] inventoryContents = inv.getAllItemsByItemId(e.getItemId(), false);
|
||||
|
||||
itemToTake = inventoryContents[0];
|
||||
// get item with the LOWEST enchantment level from the inventory...
|
||||
// +0 is lowest by default...
|
||||
if (itemToTake.getEnchantLevel() > 0)
|
||||
{
|
||||
for (L2ItemInstance item : inventoryContents)
|
||||
{
|
||||
if (item.getEnchantLevel() < itemToTake.getEnchantLevel())
|
||||
{
|
||||
itemToTake = item;
|
||||
// nothing will have enchantment less than 0. If a zero-enchanted
|
||||
// item is found, just take it
|
||||
if (itemToTake.getEnchantLevel() == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!player.destroyItem("Multisell", itemToTake.getObjectId(), 1, player.getTarget(), true))
|
||||
{
|
||||
player.setMultiSell(null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final double itemRandom = 100 * Rnd.nextDouble();
|
||||
float cumulativeChance = 0;
|
||||
|
||||
boolean matched = false;
|
||||
// Generate the appropriate items
|
||||
for (Ingredient e : entry.getProducts())
|
||||
{
|
||||
if (list.isNewMultisell())
|
||||
{
|
||||
// Skip first entry.
|
||||
if (e.getChance() < 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Calculate chance
|
||||
matched = (itemRandom < (cumulativeChance += e.getChance()));
|
||||
if (!matched)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (e.getItemId() < 0)
|
||||
{
|
||||
MultisellData.giveSpecialProduct(e.getItemId(), e.getItemCount() * _amount, player);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (e.isStackable())
|
||||
{
|
||||
inv.addItem("Multisell", e.getItemId(), e.getItemCount() * _amount, player, player.getTarget());
|
||||
}
|
||||
else
|
||||
{
|
||||
L2ItemInstance product = null;
|
||||
for (int i = 0; i < (e.getItemCount() * _amount); i++)
|
||||
{
|
||||
product = inv.addItem("Multisell", e.getItemId(), 1, player, player.getTarget());
|
||||
if ((product != null) && (list.getMaintainEnchantment() || (e.getEnchantLevel() > 0)))
|
||||
{
|
||||
if (i < augmentation.size())
|
||||
{
|
||||
product.setAugmentation(new L2Augmentation(augmentation.get(i).getAugmentationId()));
|
||||
}
|
||||
if (elemental != null)
|
||||
{
|
||||
for (Elementals elm : elemental)
|
||||
{
|
||||
product.setElementAttr(elm.getElement(), elm.getValue());
|
||||
}
|
||||
}
|
||||
product.setEnchantLevel(e.getEnchantLevel());
|
||||
product.updateDatabase();
|
||||
}
|
||||
}
|
||||
}
|
||||
// msg part
|
||||
SystemMessage sm;
|
||||
|
||||
if ((e.getItemCount() * _amount) > 1)
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S2_S1_S);
|
||||
sm.addItemName(e.getItemId());
|
||||
sm.addLong(e.getItemCount() * _amount);
|
||||
player.sendPacket(sm);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (list.getMaintainEnchantment() && (e.getEnchantLevel() > 0))
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.ACQUIRED_S1_S2);
|
||||
sm.addLong(e.getEnchantLevel());
|
||||
sm.addItemName(e.getItemId());
|
||||
}
|
||||
else
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1);
|
||||
sm.addItemName(e.getItemId());
|
||||
}
|
||||
player.sendPacket(sm);
|
||||
}
|
||||
}
|
||||
|
||||
if (matched)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
player.sendPacket(new ItemList(player, false));
|
||||
player.sendPacket(new ExUserInfoInvenWeight(player));
|
||||
|
||||
// finally, give the tax to the castle...
|
||||
if ((npc != null) && (entry.getTaxAmount() > 0))
|
||||
{
|
||||
npc.getCastle().addToTreasury(entry.getTaxAmount() * _amount);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__B0_MULTISELLCHOOSE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PlayerTemplateData;
|
||||
import com.l2jmobius.gameserver.model.base.ClassId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NewCharacterSuccess;
|
||||
|
||||
/**
|
||||
* @author Zoey76
|
||||
*/
|
||||
public final class NewCharacter extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__13_NEWCHARACTER = "[C] 13 NewCharacter";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine(_C__13_NEWCHARACTER);
|
||||
}
|
||||
|
||||
final NewCharacterSuccess ct = new NewCharacterSuccess();
|
||||
ct.addChar(PlayerTemplateData.getInstance().getTemplate(ClassId.FIGHTER)); // Human Figther
|
||||
ct.addChar(PlayerTemplateData.getInstance().getTemplate(ClassId.MAGE)); // Human Mystic
|
||||
ct.addChar(PlayerTemplateData.getInstance().getTemplate(ClassId.ELVEN_FIGHTER)); // Elven Fighter
|
||||
ct.addChar(PlayerTemplateData.getInstance().getTemplate(ClassId.ELVEN_MAGE)); // Elven Mystic
|
||||
ct.addChar(PlayerTemplateData.getInstance().getTemplate(ClassId.DARK_FIGHTER)); // Dark Fighter
|
||||
ct.addChar(PlayerTemplateData.getInstance().getTemplate(ClassId.DARK_MAGE)); // Dark Mystic
|
||||
ct.addChar(PlayerTemplateData.getInstance().getTemplate(ClassId.ORC_FIGHTER)); // Orc Fighter
|
||||
ct.addChar(PlayerTemplateData.getInstance().getTemplate(ClassId.ORC_MAGE)); // Orc Mystic
|
||||
ct.addChar(PlayerTemplateData.getInstance().getTemplate(ClassId.DWARVEN_FIGHTER)); // Dwarf Fighter
|
||||
ct.addChar(PlayerTemplateData.getInstance().getTemplate(ClassId.MALE_SOLDIER)); // Male Kamael Soldier
|
||||
ct.addChar(PlayerTemplateData.getInstance().getTemplate(ClassId.FEMALE_SOLDIER)); // Female Kamael Soldier
|
||||
ct.addChar(PlayerTemplateData.getInstance().getTemplate(ClassId.ERTHEIA_FIGHTER)); // Ertheia Fighter
|
||||
ct.addChar(PlayerTemplateData.getInstance().getTemplate(ClassId.ERTHEIA_WIZARD)); // Ertheia Wizard
|
||||
sendPacket(ct);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__13_NEWCHARACTER;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.UserInfoType;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.UserInfo;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class NotifyExitBeautyShop extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_E1_NOTIFYEXITBEAUTYSHOP = "[C] D0:E1 NotifyExitBeautyShop";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final UserInfo userInfo = new UserInfo(activeChar, false);
|
||||
userInfo.addComponentType(UserInfoType.APPAREANCE);
|
||||
sendPacket(userInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_E1_NOTIFYEXITBEAUTYSHOP;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.7.4.4 $ $Date: 2005/03/27 18:46:19 $
|
||||
*/
|
||||
public final class ObserverReturn extends L2GameClientPacket
|
||||
{
|
||||
private static final String __C__C1_OBSERVERRETURN = "[C] C1 ObserverReturn";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (activeChar.inObserverMode())
|
||||
{
|
||||
activeChar.leaveObserverMode();
|
||||
// activeChar.teleToLocation(activeChar.getObsX(), activeChar.getObsY(), activeChar.getObsZ());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return __C__C1_OBSERVERRETURN;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.KeyPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.5.2.8.2.8 $ $Date: 2005/04/02 10:43:04 $
|
||||
*/
|
||||
public final class ProtocolVersion extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__0E_PROTOCOLVERSION = "[C] 0E ProtocolVersion";
|
||||
private static final Logger _logAccounting = Logger.getLogger("accounting");
|
||||
|
||||
private int _version;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_version = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
// this packet is never encrypted
|
||||
if (_version == -2)
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.info("Ping received");
|
||||
}
|
||||
// this is just a ping attempt from the new C2 client
|
||||
getClient().close((L2GameServerPacket) null);
|
||||
}
|
||||
else if (!Config.PROTOCOL_LIST.contains(_version))
|
||||
{
|
||||
final LogRecord record = new LogRecord(Level.WARNING, "Wrong protocol");
|
||||
record.setParameters(new Object[]
|
||||
{
|
||||
_version,
|
||||
getClient()
|
||||
});
|
||||
_logAccounting.log(record);
|
||||
final KeyPacket pk = new KeyPacket(getClient().enableCrypt(), 0);
|
||||
getClient().setProtocolOk(false);
|
||||
getClient().close(pk);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("Client Protocol Revision is ok: " + _version);
|
||||
}
|
||||
|
||||
final KeyPacket pk = new KeyPacket(getClient().enableCrypt(), 1);
|
||||
getClient().sendPacket(pk);
|
||||
getClient().setProtocolOk(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__0E_PROTOCOLVERSION;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExAcquireAPSkillList;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class RequestAbilityList extends L2GameClientPacket
|
||||
{
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
// Nothing to read
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((activeChar.getLevel() < 99) || !activeChar.isNoble())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.ABILITIES_CAN_BE_USED_BY_NOBLESSE_EXALTED_LV_99_OR_ABOVE);
|
||||
return;
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new ExAcquireAPSkillList(activeChar));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExAcquireAPSkillList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExCloseAPListWnd;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class RequestAbilityWndClose extends L2GameClientPacket
|
||||
{
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
// Nothing to read
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((activeChar.getLevel() < 99) || !activeChar.isNoble())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.ABILITIES_CAN_BE_USED_BY_NOBLESSE_EXALTED_LV_99_OR_ABOVE);
|
||||
return;
|
||||
}
|
||||
|
||||
activeChar.sendPacket(ExCloseAPListWnd.STATIC_PACKET);
|
||||
activeChar.sendPacket(new ExAcquireAPSkillList(activeChar));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExAcquireAPSkillList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExShowAPListWnd;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class RequestAbilityWndOpen extends L2GameClientPacket
|
||||
{
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((activeChar.getLevel() < 99) || !activeChar.isNoble())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.ABILITIES_CAN_BE_USED_BY_NOBLESSE_EXALTED_LV_99_OR_ABOVE);
|
||||
return;
|
||||
}
|
||||
|
||||
activeChar.sendPacket(ExShowAPListWnd.STATIC_PACKET);
|
||||
activeChar.sendPacket(new ExAcquireAPSkillList(activeChar));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SkillTreesData;
|
||||
import com.l2jmobius.gameserver.model.L2SkillLearn;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExAcquireAPSkillList;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class RequestAcquireAbilityList extends L2GameClientPacket
|
||||
{
|
||||
private final List<SkillHolder> _skills = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
readD(); // Total size
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
final int size = readD();
|
||||
for (int j = 0; j < size; j++)
|
||||
{
|
||||
_skills.add(new SkillHolder(readD(), readD()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((activeChar.getAbilityPoints() == 0) || (activeChar.getAbilityPoints() == activeChar.getAbilityPointsUsed()))
|
||||
{
|
||||
_log.warning(getClass().getSimpleName() + ": Player " + activeChar + " is trying to learn ability without ability points!");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((activeChar.getLevel() < 99) || !activeChar.isNoble())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.ABILITIES_CAN_BE_USED_BY_NOBLESSE_EXALTED_LV_99_OR_ABOVE);
|
||||
return;
|
||||
}
|
||||
|
||||
for (SkillHolder holder : _skills)
|
||||
{
|
||||
final L2SkillLearn learn = SkillTreesData.getInstance().getAbilitySkill(holder.getSkillId(), holder.getSkillLvl());
|
||||
if (learn == null)
|
||||
{
|
||||
_log.warning(getClass().getSimpleName() + ": SkillLearn " + holder.getSkillId() + "(" + holder.getSkillLvl() + ") not found!");
|
||||
sendActionFailed();
|
||||
break;
|
||||
}
|
||||
|
||||
final Skill skill = holder.getSkill();
|
||||
if (skill == null)
|
||||
{
|
||||
_log.warning(getClass().getSimpleName() + ": SkillLearn " + holder.getSkillId() + "(" + holder.getSkillLvl() + ") not found!");
|
||||
sendActionFailed();
|
||||
break;
|
||||
}
|
||||
final int points;
|
||||
final int knownLevel = activeChar.getSkillLevel(holder.getSkillId());
|
||||
if (knownLevel == -1) // player didn't knew it at all!
|
||||
{
|
||||
points = holder.getSkillLvl();
|
||||
}
|
||||
else
|
||||
{
|
||||
points = holder.getSkillLvl() - knownLevel;
|
||||
}
|
||||
|
||||
if ((activeChar.getAbilityPoints() - activeChar.getAbilityPointsUsed()) < points)
|
||||
{
|
||||
_log.warning(getClass().getSimpleName() + ": Player " + activeChar + " is trying to learn ability without ability points!");
|
||||
sendActionFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
activeChar.addSkill(skill, true);
|
||||
activeChar.setAbilityPointsUsed(activeChar.getAbilityPointsUsed() + points);
|
||||
}
|
||||
activeChar.sendPacket(new ExAcquireAPSkillList(activeChar));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,759 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SkillTreesData;
|
||||
import com.l2jmobius.gameserver.datatables.SkillData;
|
||||
import com.l2jmobius.gameserver.enums.CategoryType;
|
||||
import com.l2jmobius.gameserver.enums.IllegalActionPunishmentType;
|
||||
import com.l2jmobius.gameserver.enums.Race;
|
||||
import com.l2jmobius.gameserver.enums.UserInfoType;
|
||||
import com.l2jmobius.gameserver.model.ClanPrivilege;
|
||||
import com.l2jmobius.gameserver.model.L2Clan;
|
||||
import com.l2jmobius.gameserver.model.L2SkillLearn;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2FishermanInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2VillageMasterInstance;
|
||||
import com.l2jmobius.gameserver.model.base.AcquireSkillType;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerSkillLearn;
|
||||
import com.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
import com.l2jmobius.gameserver.model.quest.QuestState;
|
||||
import com.l2jmobius.gameserver.model.skills.CommonSkill;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.variables.PlayerVariables;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.AcquireSkillDone;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.AcquireSkillList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExAcquirableSkillListByClass;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExBasicActionList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExStorageMaxCount;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ItemList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PledgeSkillList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ShortCutInit;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.UserInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.alchemy.ExAlchemySkillList;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* Request Acquire Skill client packet implementation.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public final class RequestAcquireSkill extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__7C_REQUESTACQUIRESKILL = "[C] 7C RequestAcquireSkill";
|
||||
private static final String[] REVELATION_VAR_NAMES =
|
||||
{
|
||||
"RevelationSkill1",
|
||||
"RevelationSkill2"
|
||||
};
|
||||
|
||||
private static final String[] DUALCLASS_REVELATION_VAR_NAMES =
|
||||
{
|
||||
"DualclassRevelationSkill1",
|
||||
"DualclassRevelationSkill2"
|
||||
};
|
||||
|
||||
private int _id;
|
||||
private int _level;
|
||||
private AcquireSkillType _skillType;
|
||||
private int _subType;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_id = readD();
|
||||
_level = readD();
|
||||
_skillType = AcquireSkillType.getAcquireSkillType(readD());
|
||||
if (_skillType == AcquireSkillType.SUBPLEDGE)
|
||||
{
|
||||
_subType = readD();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_level < 1) || (_level > 10000) || (_id < 1) || (_id > 32000))
|
||||
{
|
||||
Util.handleIllegalPlayerAction(activeChar, "Wrong Packet Data in Aquired Skill", Config.DEFAULT_PUNISH);
|
||||
_log.warning("Recived Wrong Packet Data in Aquired Skill - id: " + _id + " level: " + _level + " for " + activeChar);
|
||||
return;
|
||||
}
|
||||
|
||||
final L2Npc trainer = activeChar.getLastFolkNPC();
|
||||
if (!(trainer instanceof L2NpcInstance) && (_skillType != AcquireSkillType.CLASS))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_skillType != AcquireSkillType.CLASS) && !trainer.canInteract(activeChar) && !activeChar.isGM())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Skill skill = SkillData.getInstance().getSkill(_id, _level);
|
||||
if (skill == null)
|
||||
{
|
||||
_log.warning(RequestAcquireSkill.class.getSimpleName() + ": Player " + activeChar.getName() + " is trying to learn a null skill Id: " + _id + " level: " + _level + "!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Hack check. Doesn't apply to all Skill Types
|
||||
final int prevSkillLevel = activeChar.getSkillLevel(_id);
|
||||
if ((_skillType != AcquireSkillType.TRANSFER) && (_skillType != AcquireSkillType.SUBPLEDGE))
|
||||
{
|
||||
if (prevSkillLevel == _level)
|
||||
{
|
||||
_log.warning("Player " + activeChar.getName() + " is trying to learn a skill that already knows, Id: " + _id + " level: " + _level + "!");
|
||||
return;
|
||||
}
|
||||
|
||||
final int tmpLv = (prevSkillLevel == -1) ? 0 : prevSkillLevel;
|
||||
if (tmpLv != (_level - 1))
|
||||
{
|
||||
// The previous level skill has not been learned.
|
||||
activeChar.sendPacket(SystemMessageId.THE_PREVIOUS_LEVEL_SKILL_HAS_NOT_BEEN_LEARNED);
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " is requesting skill Id: " + _id + " level " + _level + " without knowing it's previous level!", IllegalActionPunishmentType.NONE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final L2SkillLearn s = SkillTreesData.getInstance().getSkillLearn(_skillType, _id, _level, activeChar);
|
||||
if (s == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (_skillType)
|
||||
{
|
||||
case CLASS:
|
||||
{
|
||||
if (checkPlayerSkill(activeChar, trainer, s))
|
||||
{
|
||||
giveSkill(activeChar, trainer, skill);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TRANSFORM:
|
||||
{
|
||||
// Hack check.
|
||||
if (!canTransform(activeChar))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_HAVE_NOT_COMPLETED_THE_NECESSARY_QUEST_FOR_SKILL_ACQUISITION);
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " is requesting skill Id: " + _id + " level " + _level + " without required quests!", IllegalActionPunishmentType.NONE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (checkPlayerSkill(activeChar, trainer, s))
|
||||
{
|
||||
giveSkill(activeChar, trainer, skill);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FISHING:
|
||||
{
|
||||
if (checkPlayerSkill(activeChar, trainer, s))
|
||||
{
|
||||
giveSkill(activeChar, trainer, skill);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PLEDGE:
|
||||
{
|
||||
if (!activeChar.isClanLeader())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2Clan clan = activeChar.getClan();
|
||||
final int repCost = s.getLevelUpSp();
|
||||
if (clan.getReputationScore() >= repCost)
|
||||
{
|
||||
if (Config.LIFE_CRYSTAL_NEEDED)
|
||||
{
|
||||
for (ItemHolder item : s.getRequiredItems())
|
||||
{
|
||||
if (!activeChar.destroyItemByItemId("Consume", item.getId(), item.getCount(), trainer, false))
|
||||
{
|
||||
// Doesn't have required item.
|
||||
activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_NECESSARY_MATERIALS_OR_PREREQUISITES_TO_LEARN_THIS_SKILL);
|
||||
L2VillageMasterInstance.showPledgeSkillList(activeChar);
|
||||
return;
|
||||
}
|
||||
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S2_S1_S_DISAPPEARED);
|
||||
sm.addItemName(item.getId());
|
||||
sm.addLong(item.getCount());
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
}
|
||||
|
||||
clan.takeReputationScore(repCost, true);
|
||||
|
||||
final SystemMessage cr = SystemMessage.getSystemMessage(SystemMessageId.S1_POINT_S_HAVE_BEEN_DEDUCTED_FROM_THE_CLAN_S_REPUTATION);
|
||||
cr.addInt(repCost);
|
||||
activeChar.sendPacket(cr);
|
||||
|
||||
clan.addNewSkill(skill);
|
||||
|
||||
clan.broadcastToOnlineMembers(new PledgeSkillList(clan));
|
||||
|
||||
activeChar.sendPacket(new AcquireSkillDone());
|
||||
|
||||
L2VillageMasterInstance.showPledgeSkillList(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THE_ATTEMPT_TO_ACQUIRE_THE_SKILL_HAS_FAILED_BECAUSE_OF_AN_INSUFFICIENT_CLAN_REPUTATION);
|
||||
L2VillageMasterInstance.showPledgeSkillList(activeChar);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SUBPLEDGE:
|
||||
{
|
||||
if (!activeChar.isClanLeader() || !activeChar.hasClanPrivilege(ClanPrivilege.CL_TROOPS_FAME))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2Clan clan = activeChar.getClan();
|
||||
if ((clan.getFortId() == 0) && (clan.getCastleId() == 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Hack check. Check if SubPledge can accept the new skill:
|
||||
if (!clan.isLearnableSubPledgeSkill(skill, _subType))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_SQUAD_SKILL_HAS_ALREADY_BEEN_LEARNED);
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " is requesting skill Id: " + _id + " level " + _level + " without knowing it's previous level!", IllegalActionPunishmentType.NONE);
|
||||
return;
|
||||
}
|
||||
|
||||
final int repCost = s.getLevelUpSp();
|
||||
if (clan.getReputationScore() < repCost)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THE_ATTEMPT_TO_ACQUIRE_THE_SKILL_HAS_FAILED_BECAUSE_OF_AN_INSUFFICIENT_CLAN_REPUTATION);
|
||||
return;
|
||||
}
|
||||
|
||||
for (ItemHolder item : s.getRequiredItems())
|
||||
{
|
||||
if (!activeChar.destroyItemByItemId("SubSkills", item.getId(), item.getCount(), trainer, false))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_NECESSARY_MATERIALS_OR_PREREQUISITES_TO_LEARN_THIS_SKILL);
|
||||
return;
|
||||
}
|
||||
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S2_S1_S_DISAPPEARED);
|
||||
sm.addItemName(item.getId());
|
||||
sm.addLong(item.getCount());
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
|
||||
if (repCost > 0)
|
||||
{
|
||||
clan.takeReputationScore(repCost, true);
|
||||
final SystemMessage cr = SystemMessage.getSystemMessage(SystemMessageId.S1_POINT_S_HAVE_BEEN_DEDUCTED_FROM_THE_CLAN_S_REPUTATION);
|
||||
cr.addInt(repCost);
|
||||
activeChar.sendPacket(cr);
|
||||
}
|
||||
|
||||
clan.addNewSkill(skill, _subType);
|
||||
clan.broadcastToOnlineMembers(new PledgeSkillList(clan));
|
||||
activeChar.sendPacket(new AcquireSkillDone());
|
||||
|
||||
showSubUnitSkillList(activeChar);
|
||||
break;
|
||||
}
|
||||
case TRANSFER:
|
||||
{
|
||||
if (checkPlayerSkill(activeChar, trainer, s))
|
||||
{
|
||||
giveSkill(activeChar, trainer, skill);
|
||||
}
|
||||
|
||||
final List<L2SkillLearn> skills = SkillTreesData.getInstance().getAvailableTransferSkills(activeChar);
|
||||
if (skills.isEmpty())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THERE_ARE_NO_OTHER_SKILLS_TO_LEARN);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(new ExAcquirableSkillListByClass(skills, AcquireSkillType.TRANSFER));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SUBCLASS:
|
||||
{
|
||||
if (activeChar.isSubClassActive())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_SKILL_CANNOT_BE_LEARNED_WHILE_IN_THE_SUBCLASS_STATE_PLEASE_TRY_AGAIN_AFTER_CHANGING_TO_THE_MAIN_CLASS);
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " is requesting skill Id: " + _id + " level " + _level + " while Sub-Class is active!", IllegalActionPunishmentType.NONE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (checkPlayerSkill(activeChar, trainer, s))
|
||||
{
|
||||
final PlayerVariables vars = activeChar.getVariables();
|
||||
String list = vars.getString("SubSkillList", "");
|
||||
if ((prevSkillLevel > 0) && list.contains(_id + "-" + prevSkillLevel))
|
||||
{
|
||||
list = list.replace(_id + "-" + prevSkillLevel, _id + "-" + _level);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!list.isEmpty())
|
||||
{
|
||||
list += ";";
|
||||
}
|
||||
list += _id + "-" + _level;
|
||||
}
|
||||
vars.set("SubSkillList", list);
|
||||
giveSkill(activeChar, trainer, skill, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DUALCLASS:
|
||||
{
|
||||
if (activeChar.isSubClassActive())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_SKILL_CANNOT_BE_LEARNED_WHILE_IN_THE_SUBCLASS_STATE_PLEASE_TRY_AGAIN_AFTER_CHANGING_TO_THE_MAIN_CLASS);
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " is requesting skill Id: " + _id + " level " + _level + " while Sub-Class is active!", IllegalActionPunishmentType.NONE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (checkPlayerSkill(activeChar, trainer, s))
|
||||
{
|
||||
final PlayerVariables vars = activeChar.getVariables();
|
||||
String list = vars.getString("DualSkillList", "");
|
||||
if ((prevSkillLevel > 0) && list.contains(_id + "-" + prevSkillLevel))
|
||||
{
|
||||
list = list.replace(_id + "-" + prevSkillLevel, _id + "-" + _level);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!list.isEmpty())
|
||||
{
|
||||
list += ";";
|
||||
}
|
||||
list += _id + "-" + _level;
|
||||
}
|
||||
vars.set("DualSkillList", list);
|
||||
giveSkill(activeChar, trainer, skill, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case COLLECT:
|
||||
{
|
||||
if (checkPlayerSkill(activeChar, trainer, s))
|
||||
{
|
||||
giveSkill(activeChar, trainer, skill);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ALCHEMY:
|
||||
{
|
||||
if (activeChar.getRace() != Race.ERTHEIA)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (checkPlayerSkill(activeChar, trainer, s))
|
||||
{
|
||||
giveSkill(activeChar, trainer, skill);
|
||||
|
||||
activeChar.sendPacket(new AcquireSkillDone());
|
||||
activeChar.sendPacket(new ExAlchemySkillList(activeChar));
|
||||
|
||||
final List<L2SkillLearn> alchemySkills = SkillTreesData.getInstance().getAvailableAlchemySkills(activeChar);
|
||||
|
||||
if (alchemySkills.isEmpty())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THERE_ARE_NO_OTHER_SKILLS_TO_LEARN);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(new ExAcquirableSkillListByClass(alchemySkills, AcquireSkillType.ALCHEMY));
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case REVELATION:
|
||||
{
|
||||
if (activeChar.isSubClassActive())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_SKILL_CANNOT_BE_LEARNED_WHILE_IN_THE_SUBCLASS_STATE_PLEASE_TRY_AGAIN_AFTER_CHANGING_TO_THE_MAIN_CLASS);
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " is requesting skill Id: " + _id + " level " + _level + " while Sub-Class is active!", IllegalActionPunishmentType.NONE);
|
||||
return;
|
||||
}
|
||||
if ((activeChar.getLevel() < 85) || !activeChar.isInCategory(CategoryType.AWAKEN_GROUP))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_NECESSARY_MATERIALS_OR_PREREQUISITES_TO_LEARN_THIS_SKILL);
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " is requesting skill Id: " + _id + " level " + _level + " while not being level 85 or awaken!", IllegalActionPunishmentType.NONE);
|
||||
return;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
|
||||
for (String varName : REVELATION_VAR_NAMES)
|
||||
{
|
||||
if (activeChar.getVariables().getInt(varName, 0) > 0)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (count >= 2)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_NECESSARY_MATERIALS_OR_PREREQUISITES_TO_LEARN_THIS_SKILL);
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " is requesting skill Id: " + _id + " level " + _level + " while having already learned 2 skills!", IllegalActionPunishmentType.NONE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (checkPlayerSkill(activeChar, trainer, s))
|
||||
{
|
||||
final String varName = count == 0 ? REVELATION_VAR_NAMES[0] : REVELATION_VAR_NAMES[1];
|
||||
|
||||
activeChar.getVariables().set(varName, skill.getId());
|
||||
|
||||
giveSkill(activeChar, trainer, skill);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case REVELATION_DUALCLASS:
|
||||
{
|
||||
if (activeChar.isSubClassActive() && !activeChar.isDualClassActive())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_SKILL_CANNOT_BE_LEARNED_WHILE_IN_THE_SUBCLASS_STATE_PLEASE_TRY_AGAIN_AFTER_CHANGING_TO_THE_MAIN_CLASS);
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " is requesting skill Id: " + _id + " level " + _level + " while Sub-Class is active!", IllegalActionPunishmentType.NONE);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((activeChar.getLevel() < 85) || !activeChar.isInCategory(CategoryType.AWAKEN_GROUP))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_NECESSARY_MATERIALS_OR_PREREQUISITES_TO_LEARN_THIS_SKILL);
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " is requesting skill Id: " + _id + " level " + _level + " while not being level 85 or awaken!", IllegalActionPunishmentType.NONE);
|
||||
return;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
|
||||
for (String varName : DUALCLASS_REVELATION_VAR_NAMES)
|
||||
{
|
||||
if (activeChar.getVariables().getInt(varName, 0) > 0)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (count >= 2)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_NECESSARY_MATERIALS_OR_PREREQUISITES_TO_LEARN_THIS_SKILL);
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " is requesting skill Id: " + _id + " level " + _level + " while having already learned 2 skills!", IllegalActionPunishmentType.NONE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (checkPlayerSkill(activeChar, trainer, s))
|
||||
{
|
||||
final String varName = count == 0 ? DUALCLASS_REVELATION_VAR_NAMES[0] : DUALCLASS_REVELATION_VAR_NAMES[1];
|
||||
|
||||
activeChar.getVariables().set(varName, skill.getId());
|
||||
|
||||
giveSkill(activeChar, trainer, skill);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
_log.warning("Recived Wrong Packet Data in Aquired Skill, unknown skill type:" + _skillType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void showSubUnitSkillList(L2PcInstance activeChar)
|
||||
{
|
||||
final List<L2SkillLearn> skills = SkillTreesData.getInstance().getAvailableSubPledgeSkills(activeChar.getClan());
|
||||
|
||||
if (skills.isEmpty())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THERE_ARE_NO_OTHER_SKILLS_TO_LEARN);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(new ExAcquirableSkillListByClass(skills, AcquireSkillType.SUBPLEDGE));
|
||||
}
|
||||
}
|
||||
|
||||
public final static void showSubSkillList(L2PcInstance activeChar)
|
||||
{
|
||||
final List<L2SkillLearn> skills = SkillTreesData.getInstance().getAvailableSubClassSkills(activeChar);
|
||||
if (!skills.isEmpty())
|
||||
{
|
||||
activeChar.sendPacket(new ExAcquirableSkillListByClass(skills, AcquireSkillType.SUBCLASS));
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THERE_ARE_NO_OTHER_SKILLS_TO_LEARN);
|
||||
}
|
||||
}
|
||||
|
||||
public final static void showDualSkillList(L2PcInstance activeChar)
|
||||
{
|
||||
final List<L2SkillLearn> skills = SkillTreesData.getInstance().getAvailableDualClassSkills(activeChar);
|
||||
if (!skills.isEmpty())
|
||||
{
|
||||
activeChar.sendPacket(new ExAcquirableSkillListByClass(skills, AcquireSkillType.DUALCLASS));
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THERE_ARE_NO_OTHER_SKILLS_TO_LEARN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a simple check for current player and skill.<br>
|
||||
* Takes the needed SP if the skill require it and all requirements are meet.<br>
|
||||
* Consume required items if the skill require it and all requirements are meet.<br>
|
||||
* @param player the skill learning player.
|
||||
* @param trainer the skills teaching Npc.
|
||||
* @param s the skill to be learn.
|
||||
* @return {@code true} if all requirements are meet, {@code false} otherwise.
|
||||
*/
|
||||
private boolean checkPlayerSkill(L2PcInstance player, L2Npc trainer, L2SkillLearn s)
|
||||
{
|
||||
if (s != null)
|
||||
{
|
||||
if ((s.getSkillId() == _id) && (s.getSkillLevel() == _level))
|
||||
{
|
||||
// Hack check.
|
||||
if (s.getGetLevel() > player.getLevel())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_DO_NOT_MEET_THE_SKILL_LEVEL_REQUIREMENTS);
|
||||
Util.handleIllegalPlayerAction(player, "Player " + player.getName() + ", level " + player.getLevel() + " is requesting skill Id: " + _id + " level " + _level + " without having minimum required level, " + s.getGetLevel() + "!", IllegalActionPunishmentType.NONE);
|
||||
return false;
|
||||
}
|
||||
|
||||
// First it checks that the skill require SP and the player has enough SP to learn it.
|
||||
final int levelUpSp = s.getCalculatedLevelUpSp(player.getClassId(), player.getLearningClass());
|
||||
if ((levelUpSp > 0) && (levelUpSp > player.getSp()))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_ENOUGH_SP_TO_LEARN_THIS_SKILL);
|
||||
showSkillList(trainer, player);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Config.DIVINE_SP_BOOK_NEEDED && (_id == CommonSkill.DIVINE_INSPIRATION.getId()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for required skills.
|
||||
if (!s.getPreReqSkills().isEmpty())
|
||||
{
|
||||
for (SkillHolder skill : s.getPreReqSkills())
|
||||
{
|
||||
if (player.getSkillLevel(skill.getSkillId()) != skill.getSkillLvl())
|
||||
{
|
||||
if (skill.getSkillId() == CommonSkill.ONYX_BEAST_TRANSFORMATION.getId())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_MUST_LEARN_THE_ONYX_BEAST_SKILL_BEFORE_YOU_CAN_LEARN_FURTHER_SKILLS);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_NECESSARY_MATERIALS_OR_PREREQUISITES_TO_LEARN_THIS_SKILL);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check for required items.
|
||||
if (!s.getRequiredItems().isEmpty())
|
||||
{
|
||||
// Then checks that the player has all the items
|
||||
long reqItemCount = 0;
|
||||
for (ItemHolder item : s.getRequiredItems())
|
||||
{
|
||||
reqItemCount = player.getInventory().getInventoryItemCount(item.getId(), -1);
|
||||
if (reqItemCount < item.getCount())
|
||||
{
|
||||
// Player doesn't have required item.
|
||||
player.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_NECESSARY_MATERIALS_OR_PREREQUISITES_TO_LEARN_THIS_SKILL);
|
||||
showSkillList(trainer, player);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// If the player has all required items, they are consumed.
|
||||
for (ItemHolder itemIdCount : s.getRequiredItems())
|
||||
{
|
||||
if (!player.destroyItemByItemId("SkillLearn", itemIdCount.getId(), itemIdCount.getCount(), trainer, true))
|
||||
{
|
||||
Util.handleIllegalPlayerAction(player, "Somehow player " + player.getName() + ", level " + player.getLevel() + " lose required item Id: " + itemIdCount.getId() + " to learn skill while learning skill Id: " + _id + " level " + _level + "!", IllegalActionPunishmentType.NONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!s.getRemoveSkills().isEmpty())
|
||||
{
|
||||
s.getRemoveSkills().forEach(skillId ->
|
||||
{
|
||||
if (player.getSkillLevel(skillId) > 0)
|
||||
{
|
||||
final Skill skillToRemove = player.getKnownSkill(skillId);
|
||||
if (skillToRemove != null)
|
||||
{
|
||||
player.removeSkill(skillToRemove, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// If the player has SP and all required items then consume SP.
|
||||
if (levelUpSp > 0)
|
||||
{
|
||||
player.setSp(player.getSp() - levelUpSp);
|
||||
final UserInfo ui = new UserInfo(player);
|
||||
ui.addComponentType(UserInfoType.CURRENT_HPMPCP_EXP_SP);
|
||||
player.sendPacket(ui);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the skill to the player and makes proper updates.
|
||||
* @param player the player acquiring a skill.
|
||||
* @param trainer the Npc teaching a skill.
|
||||
* @param skill the skill to be learn.
|
||||
*/
|
||||
private void giveSkill(L2PcInstance player, L2Npc trainer, Skill skill)
|
||||
{
|
||||
giveSkill(player, trainer, skill, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the skill to the player and makes proper updates.
|
||||
* @param player the player acquiring a skill.
|
||||
* @param trainer the Npc teaching a skill.
|
||||
* @param skill the skill to be learn.
|
||||
* @param store
|
||||
*/
|
||||
private void giveSkill(L2PcInstance player, L2Npc trainer, Skill skill, boolean store)
|
||||
{
|
||||
// Send message.
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S12);
|
||||
sm.addSkillName(skill);
|
||||
player.sendPacket(sm);
|
||||
|
||||
player.addSkill(skill, store);
|
||||
|
||||
player.sendPacket(new ItemList(player, false));
|
||||
player.sendPacket(new ShortCutInit(player));
|
||||
player.sendPacket(new ExBasicActionList(ExBasicActionList.DEFAULT_ACTION_LIST));
|
||||
player.sendSkillList(skill.getId());
|
||||
|
||||
player.updateShortCuts(_id, _level);
|
||||
showSkillList(trainer, player);
|
||||
|
||||
// If skill is expand type then sends packet:
|
||||
if ((_id >= 1368) && (_id <= 1372))
|
||||
{
|
||||
player.sendPacket(new ExStorageMaxCount(player));
|
||||
}
|
||||
|
||||
// Notify scripts of the skill learn.
|
||||
if (trainer != null)
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerSkillLearn(trainer, player, skill, _skillType), trainer);
|
||||
}
|
||||
else
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerSkillLearn(trainer, player, skill, _skillType), player);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper for returning the skill list to the player after it's done with current skill.
|
||||
* @param trainer the Npc which the {@code player} is interacting
|
||||
* @param player the active character
|
||||
*/
|
||||
private void showSkillList(L2Npc trainer, L2PcInstance player)
|
||||
{
|
||||
if ((_skillType == AcquireSkillType.TRANSFORM) || (_skillType == AcquireSkillType.TRANSFER))
|
||||
{
|
||||
// Managed in Datapack.
|
||||
return;
|
||||
}
|
||||
|
||||
if (_skillType == AcquireSkillType.SUBCLASS)
|
||||
{
|
||||
showSubSkillList(player);
|
||||
}
|
||||
else if (_skillType == AcquireSkillType.DUALCLASS)
|
||||
{
|
||||
showDualSkillList(player);
|
||||
}
|
||||
else if (trainer instanceof L2FishermanInstance)
|
||||
{
|
||||
L2FishermanInstance.showFishSkillList(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(new AcquireSkillList(player));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if the player can transform.
|
||||
* @param player the player to verify
|
||||
* @return {@code true} if the player meets the required conditions to learn a transformation, {@code false} otherwise
|
||||
*/
|
||||
public static boolean canTransform(L2PcInstance player)
|
||||
{
|
||||
if (Config.ALLOW_TRANSFORM_WITHOUT_QUEST)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
final QuestState st = player.getQuestState("Q00136_MoreThanMeetsTheEye");
|
||||
return (st != null) && st.isCompleted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__7C_REQUESTACQUIRESKILL;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SkillTreesData;
|
||||
import com.l2jmobius.gameserver.datatables.SkillData;
|
||||
import com.l2jmobius.gameserver.enums.CategoryType;
|
||||
import com.l2jmobius.gameserver.enums.Race;
|
||||
import com.l2jmobius.gameserver.model.ClanPrivilege;
|
||||
import com.l2jmobius.gameserver.model.L2SkillLearn;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.base.AcquireSkillType;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.AcquireSkillInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExAcquireSkillInfo;
|
||||
|
||||
/**
|
||||
* Request Acquire Skill Info client packet implementation.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public final class RequestAcquireSkillInfo extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__73_REQUESTACQUIRESKILLINFO = "[C] 73 RequestAcquireSkillInfo";
|
||||
|
||||
private int _id;
|
||||
private int _level;
|
||||
private AcquireSkillType _skillType;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_id = readD();
|
||||
_level = readD();
|
||||
_skillType = AcquireSkillType.getAcquireSkillType(readD());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
if ((_id <= 0) || (_level <= 0))
|
||||
{
|
||||
_log.warning(RequestAcquireSkillInfo.class.getSimpleName() + ": Invalid Id: " + _id + " or level: " + _level + "!");
|
||||
return;
|
||||
}
|
||||
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2Npc trainer = activeChar.getLastFolkNPC();
|
||||
if (!(trainer instanceof L2NpcInstance) && (_skillType != AcquireSkillType.CLASS))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_skillType != AcquireSkillType.CLASS) && !trainer.canInteract(activeChar) && !activeChar.isGM())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Skill skill = SkillData.getInstance().getSkill(_id, _level);
|
||||
if (skill == null)
|
||||
{
|
||||
_log.warning(RequestAcquireSkillInfo.class.getSimpleName() + ": Skill Id: " + _id + " level: " + _level + " is undefined. " + RequestAcquireSkillInfo.class.getName() + " failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Hack check. Doesn't apply to all Skill Types
|
||||
final int prevSkillLevel = activeChar.getSkillLevel(_id);
|
||||
if ((prevSkillLevel > 0) && !((_skillType == AcquireSkillType.TRANSFER) || (_skillType == AcquireSkillType.SUBPLEDGE)))
|
||||
{
|
||||
if (prevSkillLevel == _level)
|
||||
{
|
||||
_log.warning(RequestAcquireSkillInfo.class.getSimpleName() + ": Player " + activeChar.getName() + " is trequesting info for a skill that already knows, Id: " + _id + " level: " + _level + "!");
|
||||
}
|
||||
else if (prevSkillLevel != (_level - 1))
|
||||
{
|
||||
_log.warning(RequestAcquireSkillInfo.class.getSimpleName() + ": Player " + activeChar.getName() + " is requesting info for skill Id: " + _id + " level " + _level + " without knowing it's previous level!");
|
||||
}
|
||||
}
|
||||
|
||||
final L2SkillLearn s = SkillTreesData.getInstance().getSkillLearn(_skillType, _id, _level, activeChar);
|
||||
if (s == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (_skillType)
|
||||
{
|
||||
case TRANSFORM:
|
||||
case FISHING:
|
||||
case SUBCLASS:
|
||||
case COLLECT:
|
||||
case TRANSFER:
|
||||
case DUALCLASS:
|
||||
{
|
||||
sendPacket(new AcquireSkillInfo(_skillType, s));
|
||||
break;
|
||||
}
|
||||
case CLASS:
|
||||
{
|
||||
final int customSp = s.getCalculatedLevelUpSp(activeChar.getClassId(), activeChar.getLearningClass());
|
||||
sendPacket(new ExAcquireSkillInfo(activeChar, s, customSp));
|
||||
break;
|
||||
}
|
||||
case PLEDGE:
|
||||
{
|
||||
if (!activeChar.isClanLeader())
|
||||
{
|
||||
return;
|
||||
}
|
||||
sendPacket(new AcquireSkillInfo(_skillType, s));
|
||||
break;
|
||||
}
|
||||
case SUBPLEDGE:
|
||||
{
|
||||
if (!activeChar.isClanLeader() || !activeChar.hasClanPrivilege(ClanPrivilege.CL_TROOPS_FAME))
|
||||
{
|
||||
return;
|
||||
}
|
||||
sendPacket(new AcquireSkillInfo(_skillType, s));
|
||||
break;
|
||||
}
|
||||
case ALCHEMY:
|
||||
{
|
||||
if (activeChar.getRace() != Race.ERTHEIA)
|
||||
{
|
||||
return;
|
||||
}
|
||||
sendPacket(new AcquireSkillInfo(_skillType, s));
|
||||
break;
|
||||
}
|
||||
case REVELATION:
|
||||
{
|
||||
if ((activeChar.getLevel() < 85) || !activeChar.isInCategory(CategoryType.AWAKEN_GROUP))
|
||||
{
|
||||
return;
|
||||
}
|
||||
sendPacket(new AcquireSkillInfo(_skillType, s));
|
||||
break;
|
||||
}
|
||||
case REVELATION_DUALCLASS:
|
||||
{
|
||||
if (!activeChar.isSubClassActive() || !activeChar.isDualClassActive())
|
||||
{
|
||||
return;
|
||||
}
|
||||
sendPacket(new AcquireSkillInfo(_skillType, s));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__73_REQUESTACQUIRESKILLINFO;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.instancemanager.QuestManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.quest.Quest;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class RequestAddExpandQuestAlarm extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_7A_REQUESTADDEXPANDQUESTALARM = "[C] D0;7A RequestAddExpandQuestAlarm";
|
||||
|
||||
private int _questId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_questId = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Quest quest = QuestManager.getInstance().getQuest(_questId);
|
||||
|
||||
if (quest != null)
|
||||
{
|
||||
quest.sendNpcLogList(activeChar);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_7A_REQUESTADDEXPANDQUESTALARM;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExShowAgitInfo;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
*/
|
||||
public class RequestAllAgitInfo extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_3E_REQUESTALLAGITINFO = "[C] D0:3E RequestAllAgitInfo";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2GameClient client = getClient();
|
||||
if (client != null)
|
||||
{
|
||||
client.sendPacket(new ExShowAgitInfo());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_3E_REQUESTALLAGITINFO;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExShowCastleInfo;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
*/
|
||||
public class RequestAllCastleInfo extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_3C_REQUESTALLCASTLEINFO = "[C] D0:3C RequestAllCastleInfo";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
// trigger
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2GameClient client = getClient();
|
||||
if (client != null)
|
||||
{
|
||||
client.sendPacket(new ExShowCastleInfo());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_3C_REQUESTALLCASTLEINFO;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExShowFortressInfo;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
*/
|
||||
public class RequestAllFortressInfo extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_3D_REQUESTALLFORTRESSINFO = "[C] D0:3D RequestAllFortressInfo";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
// trigger packet
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2GameClient client = getClient();
|
||||
if (client != null)
|
||||
{
|
||||
client.sendPacket(ExShowFortressInfo.STATIC_PACKET);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_3D_REQUESTALLFORTRESSINFO;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.AllyCrest;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public final class RequestAllyCrest extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__92_REQUESTALLYCREST = "[C] 92 RequestAllyCrest";
|
||||
|
||||
private int _crestId;
|
||||
private int _allyId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_crestId = readD();
|
||||
_allyId = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
if (_crestId == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if ((activeChar.getAllyId() > 0) && (activeChar.getAllyId() == _allyId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
sendPacket(new AllyCrest(_crestId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__92_REQUESTALLYCREST;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.ClanInfo;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.AllianceInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1479 $ $Date: 2005-11-09 00:47:42 +0100 (mer., 09 nov. 2005) $
|
||||
*/
|
||||
public final class RequestAllyInfo extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__2E_REQUESTALLYINFO = "[C] 2E RequestAllyInfo";
|
||||
|
||||
@Override
|
||||
public void readImpl()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SystemMessage sm;
|
||||
final int allianceId = activeChar.getAllyId();
|
||||
if (allianceId > 0)
|
||||
{
|
||||
final AllianceInfo ai = new AllianceInfo(allianceId);
|
||||
activeChar.sendPacket(ai);
|
||||
|
||||
// send for player
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.ALLIANCE_INFORMATION);
|
||||
activeChar.sendPacket(sm);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.ALLIANCE_NAME_S1);
|
||||
sm.addString(ai.getName());
|
||||
activeChar.sendPacket(sm);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.ALLIANCE_LEADER_S2_OF_S1);
|
||||
sm.addString(ai.getLeaderC());
|
||||
sm.addString(ai.getLeaderP());
|
||||
activeChar.sendPacket(sm);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.CONNECTION_S1_TOTAL_S2);
|
||||
sm.addInt(ai.getOnline());
|
||||
sm.addInt(ai.getTotal());
|
||||
activeChar.sendPacket(sm);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.AFFILIATED_CLANS_TOTAL_S1_CLAN_S);
|
||||
sm.addInt(ai.getAllies().length);
|
||||
activeChar.sendPacket(sm);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.CLAN_INFORMATION);
|
||||
for (ClanInfo aci : ai.getAllies())
|
||||
{
|
||||
activeChar.sendPacket(sm);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.CLAN_NAME_S1);
|
||||
sm.addString(aci.getClan().getName());
|
||||
activeChar.sendPacket(sm);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.CLAN_LEADER_S1);
|
||||
sm.addString(aci.getClan().getLeaderName());
|
||||
activeChar.sendPacket(sm);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.CLAN_LEVEL_S1);
|
||||
sm.addInt(aci.getClan().getLevel());
|
||||
activeChar.sendPacket(sm);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.CONNECTION_S1_TOTAL_S2);
|
||||
sm.addInt(aci.getOnline());
|
||||
sm.addInt(aci.getTotal());
|
||||
activeChar.sendPacket(sm);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.EMPTY4);
|
||||
}
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.EMPTY5);
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_ARE_NOT_CURRENTLY_ALLIED_WITH_ANY_CLANS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__2E_REQUESTALLYINFO;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Clan;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
public final class RequestAnswerJoinAlly extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__8D_REQUESTANSWERJOINALLY = "[C] 8D RequestAnswerJoinAlly";
|
||||
|
||||
private int _response;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_response = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2PcInstance requestor = activeChar.getRequest().getPartner();
|
||||
if (requestor == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_response == 0)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.NO_RESPONSE_YOUR_ENTRANCE_TO_THE_ALLIANCE_HAS_BEEN_CANCELLED);
|
||||
requestor.sendPacket(SystemMessageId.NO_RESPONSE_INVITATION_TO_JOIN_AN_ALLIANCE_HAS_BEEN_CANCELLED);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(requestor.getRequest().getRequestPacket() instanceof RequestJoinAlly))
|
||||
{
|
||||
return; // hax
|
||||
}
|
||||
|
||||
final L2Clan clan = requestor.getClan();
|
||||
// we must double check this cause of hack
|
||||
if (clan.checkAllyJoinCondition(requestor, activeChar))
|
||||
{
|
||||
// TODO: Need correct message id
|
||||
requestor.sendPacket(SystemMessageId.THAT_PERSON_HAS_BEEN_SUCCESSFULLY_ADDED_TO_YOUR_FRIEND_LIST);
|
||||
activeChar.sendPacket(SystemMessageId.YOU_HAVE_ACCEPTED_THE_ALLIANCE);
|
||||
|
||||
activeChar.getClan().setAllyId(clan.getAllyId());
|
||||
activeChar.getClan().setAllyName(clan.getAllyName());
|
||||
activeChar.getClan().setAllyPenaltyExpiryTime(0, 0);
|
||||
activeChar.getClan().changeAllyCrest(clan.getAllyCrestId(), true);
|
||||
activeChar.getClan().updateClanInDB();
|
||||
}
|
||||
}
|
||||
|
||||
activeChar.getRequest().onRequestResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__8D_REQUESTANSWERJOINALLY;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Party;
|
||||
import com.l2jmobius.gameserver.model.PartyMatchRoom;
|
||||
import com.l2jmobius.gameserver.model.PartyMatchRoomList;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.request.PartyRequest;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExManagePartyRoomMember;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.JoinParty;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
public final class RequestAnswerJoinParty extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__43_REQUESTANSWERPARTY = "[C] 43 RequestAnswerJoinParty";
|
||||
|
||||
private int _response;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_response = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance player = getClient().getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final PartyRequest request = player.getRequest(PartyRequest.class);
|
||||
if ((request == null) || request.isProcessing())
|
||||
{
|
||||
return;
|
||||
}
|
||||
request.setProcessing(true);
|
||||
final L2PcInstance requestor = request.getActiveChar();
|
||||
if (requestor == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final L2Party party = requestor.getParty();
|
||||
|
||||
requestor.sendPacket(new JoinParty(_response));
|
||||
|
||||
switch (_response)
|
||||
{
|
||||
case -1: // Party disable by player client config
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_SET_TO_REFUSE_PARTY_REQUESTS_AND_CANNOT_RECEIVE_A_PARTY_REQUEST);
|
||||
sm.addPcName(player);
|
||||
requestor.sendPacket(sm);
|
||||
break;
|
||||
}
|
||||
case 0: // Party cancel by player
|
||||
{
|
||||
// requestor.sendPacket(SystemMessageId.THE_PLAYER_DECLINED_TO_JOIN_YOUR_PARTY); FIXME: Done in client?
|
||||
break;
|
||||
}
|
||||
case 1: // Party accept by player
|
||||
{
|
||||
if (requestor.isInParty())
|
||||
{
|
||||
if (requestor.getParty().getMemberCount() >= 7)
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.THE_PARTY_IS_FULL);
|
||||
player.sendPacket(sm);
|
||||
requestor.sendPacket(sm);
|
||||
return;
|
||||
}
|
||||
player.joinParty(requestor.getParty());
|
||||
}
|
||||
else
|
||||
{
|
||||
requestor.setParty(new L2Party(requestor, requestor.getPartyDistributionType()));
|
||||
player.joinParty(requestor.getParty());
|
||||
}
|
||||
|
||||
if (requestor.isInPartyMatchRoom() && player.isInPartyMatchRoom())
|
||||
{
|
||||
final PartyMatchRoomList list = PartyMatchRoomList.getInstance();
|
||||
if ((list != null) && (list.getPlayerRoomId(requestor) == list.getPlayerRoomId(player)))
|
||||
{
|
||||
final PartyMatchRoom room = list.getPlayerRoom(requestor);
|
||||
if (room != null)
|
||||
{
|
||||
final ExManagePartyRoomMember packet = new ExManagePartyRoomMember(player, room, 1);
|
||||
for (L2PcInstance member : room.getPartyMembers())
|
||||
{
|
||||
if (member != null)
|
||||
{
|
||||
member.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (requestor.isInPartyMatchRoom() && !player.isInPartyMatchRoom())
|
||||
{
|
||||
final PartyMatchRoomList list = PartyMatchRoomList.getInstance();
|
||||
if (list != null)
|
||||
{
|
||||
final PartyMatchRoom room = list.getPlayerRoom(requestor);
|
||||
if (room != null)
|
||||
{
|
||||
room.addMember(player);
|
||||
final ExManagePartyRoomMember packet = new ExManagePartyRoomMember(player, room, 1);
|
||||
for (L2PcInstance member : room.getPartyMembers())
|
||||
{
|
||||
if (member != null)
|
||||
{
|
||||
member.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
player.setPartyRoom(room.getId());
|
||||
// player.setPartyMatching(1);
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (party != null)
|
||||
{
|
||||
party.setPendingInvitation(false); // if party is null, there is no need of decreasing
|
||||
}
|
||||
|
||||
request.setProcessing(false);
|
||||
player.removeRequest(request.getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__43_REQUESTANSWERPARTY;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.FortManager;
|
||||
import com.l2jmobius.gameserver.model.L2Clan;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExPledgeCount;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.JoinPledge;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PledgeShowInfoUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PledgeShowMemberListAdd;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PledgeShowMemberListAll;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.4.2.1.2.3 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public final class RequestAnswerJoinPledge extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__27_REQUESTANSWERJOINPLEDGE = "[C] 27 RequestAnswerJoinPledge";
|
||||
|
||||
private int _answer;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_answer = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2PcInstance requestor = activeChar.getRequest().getPartner();
|
||||
if (requestor == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_answer == 0)
|
||||
{
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_DIDN_T_RESPOND_TO_S1_S_INVITATION_JOINING_HAS_BEEN_CANCELLED);
|
||||
sm.addString(requestor.getName());
|
||||
activeChar.sendPacket(sm);
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_DID_NOT_RESPOND_INVITATION_TO_THE_CLAN_HAS_BEEN_CANCELLED);
|
||||
sm.addString(activeChar.getName());
|
||||
requestor.sendPacket(sm);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(requestor.getRequest().getRequestPacket() instanceof RequestJoinPledge))
|
||||
{
|
||||
return; // hax
|
||||
}
|
||||
|
||||
final RequestJoinPledge requestPacket = (RequestJoinPledge) requestor.getRequest().getRequestPacket();
|
||||
final L2Clan clan = requestor.getClan();
|
||||
// we must double check this cause during response time conditions can be changed, i.e. another player could join clan
|
||||
if (clan.checkClanJoinCondition(requestor, activeChar, requestPacket.getPledgeType()))
|
||||
{
|
||||
activeChar.sendPacket(new JoinPledge(requestor.getClanId()));
|
||||
|
||||
activeChar.setPledgeType(requestPacket.getPledgeType());
|
||||
if (requestPacket.getPledgeType() == L2Clan.SUBUNIT_ACADEMY)
|
||||
{
|
||||
activeChar.setPowerGrade(9); // Academy
|
||||
activeChar.setLvlJoinedAcademy(activeChar.getLevel());
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.setPowerGrade(5); // new member starts at 5, not confirmed
|
||||
}
|
||||
|
||||
clan.addClanMember(activeChar);
|
||||
activeChar.setClanPrivileges(activeChar.getClan().getRankPrivs(activeChar.getPowerGrade()));
|
||||
activeChar.sendPacket(SystemMessageId.ENTERED_THE_CLAN);
|
||||
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_JOINED_THE_CLAN);
|
||||
sm.addString(activeChar.getName());
|
||||
clan.broadcastToOnlineMembers(sm);
|
||||
|
||||
if (clan.getCastleId() > 0)
|
||||
{
|
||||
CastleManager.getInstance().getCastleByOwner(clan).giveResidentialSkills(activeChar);
|
||||
}
|
||||
if (clan.getFortId() > 0)
|
||||
{
|
||||
FortManager.getInstance().getFortByOwner(clan).giveResidentialSkills(activeChar);
|
||||
}
|
||||
activeChar.sendSkillList();
|
||||
|
||||
clan.broadcastToOtherOnlineMembers(new PledgeShowMemberListAdd(activeChar), activeChar);
|
||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||
clan.broadcastToOnlineMembers(new ExPledgeCount(clan));
|
||||
|
||||
// this activates the clan tab on the new member
|
||||
activeChar.sendPacket(new PledgeShowMemberListAll(clan));
|
||||
activeChar.setClanJoinExpiryTime(0);
|
||||
activeChar.broadcastUserInfo();
|
||||
}
|
||||
}
|
||||
|
||||
activeChar.getRequest().onRequestResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__27_REQUESTANSWERJOINPLEDGE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExAskJoinPartyRoom;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* Format: (ch) S
|
||||
* @author -Wooden-, Tryskell
|
||||
*/
|
||||
public class RequestAskJoinPartyRoom extends L2GameClientPacket
|
||||
{
|
||||
private String _name;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_name = readS();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance player = getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Send PartyRoom invite request (with activeChar) name to the target
|
||||
final L2PcInstance target = L2World.getInstance().getPlayer(_name);
|
||||
if (target != null)
|
||||
{
|
||||
if (!target.isProcessingRequest())
|
||||
{
|
||||
player.onTransactionRequest(target);
|
||||
target.sendPacket(new ExAskJoinPartyRoom(player));
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ON_ANOTHER_TASK_PLEASE_TRY_AGAIN_LATER).addPcName(target));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(SystemMessageId.THAT_PLAYER_IS_NOT_ONLINE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return "[C] D0:14 RequestAskJoinPartyRoom";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.PrivateStoreType;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Summon;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.items.type.ActionType;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExAutoSoulShot;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* @author Unknown, UnAfraid
|
||||
*/
|
||||
public final class RequestAutoSoulShot extends L2GameClientPacket
|
||||
{
|
||||
// format cd
|
||||
private int _itemId;
|
||||
private int _type; // 1 = on : 0 = off;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_itemId = readD();
|
||||
_type = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((activeChar.getPrivateStoreType() == PrivateStoreType.NONE) && (activeChar.getActiveRequester() == null) && !activeChar.isDead())
|
||||
{
|
||||
final L2ItemInstance item = activeChar.getInventory().getItemByItemId(_itemId);
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_type == 1)
|
||||
{
|
||||
if (!activeChar.getInventory().canManipulateWithItemId(item.getId()))
|
||||
{
|
||||
activeChar.sendMessage("Cannot use this item.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (isSummonShot(item.getItem()))
|
||||
{
|
||||
if (activeChar.hasSummon())
|
||||
{
|
||||
final boolean isSoulshot = item.getEtcItem().getDefaultAction() == ActionType.SUMMON_SOULSHOT;
|
||||
final boolean isSpiritshot = item.getEtcItem().getDefaultAction() == ActionType.SUMMON_SPIRITSHOT;
|
||||
if (isSoulshot)
|
||||
{
|
||||
int soulshotCount = 0;
|
||||
final L2Summon pet = activeChar.getPet();
|
||||
if (pet != null)
|
||||
{
|
||||
soulshotCount += pet.getSoulShotsPerHit();
|
||||
}
|
||||
for (L2Summon servitor : activeChar.getServitors().values())
|
||||
{
|
||||
soulshotCount += servitor.getSoulShotsPerHit();
|
||||
}
|
||||
if (soulshotCount > item.getCount())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_DON_T_HAVE_ENOUGH_SOULSHOTS_NEEDED_FOR_A_PET_SERVITOR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (isSpiritshot)
|
||||
{
|
||||
int spiritshotCount = 0;
|
||||
final L2Summon pet = activeChar.getPet();
|
||||
if (pet != null)
|
||||
{
|
||||
spiritshotCount += pet.getSpiritShotsPerHit();
|
||||
}
|
||||
for (L2Summon servitor : activeChar.getServitors().values())
|
||||
{
|
||||
spiritshotCount += servitor.getSpiritShotsPerHit();
|
||||
}
|
||||
if (spiritshotCount > item.getCount())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_DON_T_HAVE_ENOUGH_SOULSHOTS_NEEDED_FOR_A_PET_SERVITOR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Activate shots
|
||||
activeChar.addAutoSoulShot(_itemId);
|
||||
activeChar.sendPacket(new ExAutoSoulShot(_itemId, 1, isSoulshot ? 2 : 3));
|
||||
|
||||
// Send message
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.THE_AUTOMATIC_USE_OF_S1_HAS_BEEN_ACTIVATED);
|
||||
sm.addItemName(item);
|
||||
activeChar.sendPacket(sm);
|
||||
|
||||
// Recharge summon's shots
|
||||
final L2Summon pet = activeChar.getPet();
|
||||
if (pet != null)
|
||||
{
|
||||
pet.rechargeShots(isSoulshot, isSpiritshot);
|
||||
}
|
||||
activeChar.getServitors().values().forEach(s ->
|
||||
{
|
||||
s.rechargeShots(isSoulshot, isSpiritshot);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_A_SERVITOR_OR_PET_AND_THEREFORE_CANNOT_USE_THE_AUTOMATIC_USE_FUNCTION);
|
||||
}
|
||||
}
|
||||
else if (isPlayerShot(item.getItem()))
|
||||
{
|
||||
final boolean isSoulshot = (item.getEtcItem().getDefaultAction() == ActionType.SOULSHOT) || (item.getEtcItem().getDefaultAction() == ActionType.FISHINGSHOT);
|
||||
final boolean isSpiritshot = item.getEtcItem().getDefaultAction() == ActionType.SPIRITSHOT;
|
||||
if ((activeChar.getActiveWeaponItem() == activeChar.getFistsWeaponItem()) || (item.getItem().getCrystalType() != activeChar.getActiveWeaponItem().getCrystalTypePlus()))
|
||||
{
|
||||
activeChar.sendPacket(isSoulshot ? SystemMessageId.THE_SOULSHOT_YOU_ARE_ATTEMPTING_TO_USE_DOES_NOT_MATCH_THE_GRADE_OF_YOUR_EQUIPPED_WEAPON : SystemMessageId.YOUR_SPIRITSHOT_DOES_NOT_MATCH_THE_WEAPON_S_GRADE);
|
||||
return;
|
||||
}
|
||||
|
||||
// Activate shots
|
||||
activeChar.addAutoSoulShot(_itemId);
|
||||
activeChar.sendPacket(new ExAutoSoulShot(_itemId, 1, isSoulshot ? 0 : 1));
|
||||
|
||||
// Send message
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.THE_AUTOMATIC_USE_OF_S1_HAS_BEEN_ACTIVATED);
|
||||
sm.addItemName(item);
|
||||
activeChar.sendPacket(sm);
|
||||
|
||||
// Recharge player's shots
|
||||
activeChar.rechargeShots(isSoulshot, isSpiritshot);
|
||||
}
|
||||
}
|
||||
else if (_type == 0)
|
||||
{
|
||||
// Cancel auto shots
|
||||
activeChar.removeAutoSoulShot(_itemId);
|
||||
switch (item.getEtcItem().getDefaultAction())
|
||||
{
|
||||
case SOULSHOT:
|
||||
case FISHINGSHOT:
|
||||
{
|
||||
activeChar.sendPacket(new ExAutoSoulShot(_itemId, 0, 0));
|
||||
break;
|
||||
}
|
||||
case SPIRITSHOT:
|
||||
{
|
||||
activeChar.sendPacket(new ExAutoSoulShot(_itemId, 0, 1));
|
||||
break;
|
||||
}
|
||||
case SUMMON_SOULSHOT:
|
||||
{
|
||||
activeChar.sendPacket(new ExAutoSoulShot(_itemId, 0, 2));
|
||||
break;
|
||||
}
|
||||
case SUMMON_SPIRITSHOT:
|
||||
{
|
||||
activeChar.sendPacket(new ExAutoSoulShot(_itemId, 0, 3));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Send message
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.THE_AUTOMATIC_USE_OF_S1_HAS_BEEN_DEACTIVATED);
|
||||
sm.addItemName(item);
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isPlayerShot(L2Item item)
|
||||
{
|
||||
switch (item.getDefaultAction())
|
||||
{
|
||||
case SPIRITSHOT:
|
||||
case SOULSHOT:
|
||||
case FISHINGSHOT:
|
||||
{
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isSummonShot(L2Item item)
|
||||
{
|
||||
switch (item.getDefaultAction())
|
||||
{
|
||||
case SUMMON_SPIRITSHOT:
|
||||
case SUMMON_SOULSHOT:
|
||||
{
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.CommunityBoardHandler;
|
||||
|
||||
/**
|
||||
* RequestBBSwrite client packet implementation.
|
||||
* @author -Wooden-, Zoey76
|
||||
*/
|
||||
public final class RequestBBSwrite extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__24_REQUESTBBSWRITE = "[C] 24 RequestBBSwrite";
|
||||
private String _url;
|
||||
private String _arg1;
|
||||
private String _arg2;
|
||||
private String _arg3;
|
||||
private String _arg4;
|
||||
private String _arg5;
|
||||
|
||||
@Override
|
||||
protected final void readImpl()
|
||||
{
|
||||
_url = readS();
|
||||
_arg1 = readS();
|
||||
_arg2 = readS();
|
||||
_arg3 = readS();
|
||||
_arg4 = readS();
|
||||
_arg5 = readS();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void runImpl()
|
||||
{
|
||||
CommunityBoardHandler.getInstance().handleWriteCommand(getActiveChar(), _url, _arg1, _arg2, _arg3, _arg4, _arg5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getType()
|
||||
{
|
||||
return _C__24_REQUESTBBSWRITE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.instancemanager.ItemAuctionManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.itemauction.ItemAuction;
|
||||
import com.l2jmobius.gameserver.model.itemauction.ItemAuctionInstance;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
|
||||
/**
|
||||
* @author Forsaiken
|
||||
*/
|
||||
public final class RequestBidItemAuction extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_39_REQUESTBIDITEMAUCTION = "[C] D0:39 RequestBidItemAuction";
|
||||
|
||||
private int _instanceId;
|
||||
private long _bid;
|
||||
|
||||
@Override
|
||||
protected final void readImpl()
|
||||
{
|
||||
_instanceId = super.readD();
|
||||
_bid = super.readQ();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = super.getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// can't use auction fp here
|
||||
if (!getClient().getFloodProtectors().getTransaction().tryPerformAction("auction"))
|
||||
{
|
||||
activeChar.sendMessage("You are bidding too fast.");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_bid < 0) || (_bid > Inventory.MAX_ADENA))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final ItemAuctionInstance instance = ItemAuctionManager.getInstance().getManagerInstance(_instanceId);
|
||||
if (instance != null)
|
||||
{
|
||||
final ItemAuction auction = instance.getCurrentAuction();
|
||||
if (auction != null)
|
||||
{
|
||||
auction.registerBid(activeChar, _bid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getType()
|
||||
{
|
||||
return _C__D0_39_REQUESTBIDITEMAUCTION;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
|
||||
import com.l2jmobius.gameserver.model.BlockList;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.friend.BlockListPacket;
|
||||
|
||||
public final class RequestBlock extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__A9_REQUESTBLOCK = "[C] A9 RequestBlock";
|
||||
|
||||
private static final int BLOCK = 0;
|
||||
private static final int UNBLOCK = 1;
|
||||
private static final int BLOCKLIST = 2;
|
||||
private static final int ALLBLOCK = 3;
|
||||
private static final int ALLUNBLOCK = 4;
|
||||
|
||||
private String _name;
|
||||
private Integer _type;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_type = readD(); // 0x00 - block, 0x01 - unblock, 0x03 - allblock, 0x04 - allunblock
|
||||
|
||||
if ((_type == BLOCK) || (_type == UNBLOCK))
|
||||
{
|
||||
_name = readS();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
final int targetId = CharNameTable.getInstance().getIdByName(_name);
|
||||
final int targetAL = CharNameTable.getInstance().getAccessLevelById(targetId);
|
||||
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (_type)
|
||||
{
|
||||
case BLOCK:
|
||||
case UNBLOCK:
|
||||
{
|
||||
// can't use block/unblock for locating invisible characters
|
||||
if (targetId <= 0)
|
||||
{
|
||||
// Incorrect player name.
|
||||
activeChar.sendPacket(SystemMessageId.YOU_HAVE_FAILED_TO_REGISTER_THE_USER_TO_YOUR_IGNORE_LIST);
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetAL > 0)
|
||||
{
|
||||
// Cannot block a GM character.
|
||||
activeChar.sendPacket(SystemMessageId.YOU_MAY_NOT_IMPOSE_A_BLOCK_ON_A_GM);
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.getObjectId() == targetId)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_type == BLOCK)
|
||||
{
|
||||
BlockList.addToBlockList(activeChar, targetId);
|
||||
}
|
||||
else
|
||||
{
|
||||
BlockList.removeFromBlockList(activeChar, targetId);
|
||||
}
|
||||
activeChar.sendPacket(new BlockListPacket(activeChar));
|
||||
break;
|
||||
}
|
||||
case BLOCKLIST:
|
||||
{
|
||||
BlockList.sendListToOwner(activeChar);
|
||||
break;
|
||||
}
|
||||
case ALLBLOCK:
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.MESSAGE_REFUSAL_MODE);
|
||||
BlockList.setBlockAll(activeChar, true);
|
||||
break;
|
||||
}
|
||||
case ALLUNBLOCK:
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.MESSAGE_ACCEPTANCE_MODE);
|
||||
BlockList.setBlockAll(activeChar, false);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
_log.info("Unknown 0xA9 block type: " + _type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__A9_REQUESTBLOCK;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExGetBookMarkInfoPacket;
|
||||
|
||||
/**
|
||||
* @author ShanSoft Packets Structure: chddd
|
||||
*/
|
||||
public final class RequestBookMarkSlotInfo extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_51_00_REQUESTBOOKMARKSLOTINFO = "[C] D0:51:00 RequestBookMarkSlotInfo";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
// There is nothing to read.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance player = getClient().getActiveChar();
|
||||
player.sendPacket(new ExGetBookMarkInfoPacket(player));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_51_00_REQUESTBOOKMARKSLOTINFO;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import static com.l2jmobius.gameserver.model.actor.L2Npc.INTERACTION_DISTANCE;
|
||||
import static com.l2jmobius.gameserver.model.itemcontainer.Inventory.MAX_ADENA;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.BuyListData;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2MerchantInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.buylist.L2BuyList;
|
||||
import com.l2jmobius.gameserver.model.buylist.Product;
|
||||
import com.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExBuySellList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExUserInfoInvenWeight;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
public final class RequestBuyItem extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__40_REQUESTBUYITEM = "[C] 40 RequestBuyItem";
|
||||
|
||||
private static final int BATCH_LENGTH = 12;
|
||||
private static final int CUSTOM_CB_SELL_LIST = 423;
|
||||
|
||||
private int _listId;
|
||||
private List<ItemHolder> _items = null;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_listId = readD();
|
||||
final int size = readD();
|
||||
if ((size <= 0) || (size > Config.MAX_ITEM_IN_PACKET) || ((size * BATCH_LENGTH) != _buf.remaining()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_items = new ArrayList<>(size);
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
final int itemId = readD();
|
||||
final long count = readQ();
|
||||
if ((itemId < 1) || (count < 1))
|
||||
{
|
||||
_items = null;
|
||||
return;
|
||||
}
|
||||
_items.add(new ItemHolder(itemId, count));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance player = getClient().getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!getClient().getFloodProtectors().getTransaction().tryPerformAction("buy"))
|
||||
{
|
||||
player.sendMessage("You are buying too fast.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_items == null)
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Alt game - Karma punishment
|
||||
if (!Config.ALT_GAME_KARMA_PLAYER_CAN_SHOP && (player.getReputation() < 0))
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
final L2Object target = player.getTarget();
|
||||
L2Character merchant = null;
|
||||
if (!player.isGM() && (_listId != CUSTOM_CB_SELL_LIST))
|
||||
{
|
||||
if (!(target instanceof L2MerchantInstance) || (!player.isInsideRadius(target, INTERACTION_DISTANCE, true, false)) || (player.getInstanceId() != target.getInstanceId()))
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
merchant = (L2Character) target;
|
||||
}
|
||||
|
||||
double castleTaxRate = 0;
|
||||
double baseTaxRate = 0;
|
||||
|
||||
if ((merchant == null) && !player.isGM() && (_listId != CUSTOM_CB_SELL_LIST))
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
final L2BuyList buyList = BuyListData.getInstance().getBuyList(_listId);
|
||||
if (buyList == null)
|
||||
{
|
||||
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false BuyList list_id " + _listId, Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
|
||||
if (merchant != null)
|
||||
{
|
||||
if (!buyList.isNpcAllowed(merchant.getId()))
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if (merchant instanceof L2MerchantInstance)
|
||||
{
|
||||
castleTaxRate = ((L2MerchantInstance) merchant).getMpc().getCastleTaxRate();
|
||||
baseTaxRate = ((L2MerchantInstance) merchant).getMpc().getBaseTaxRate();
|
||||
}
|
||||
else
|
||||
{
|
||||
baseTaxRate = 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
long subTotal = 0;
|
||||
|
||||
// Check for buylist validity and calculates summary values
|
||||
long slots = 0;
|
||||
long weight = 0;
|
||||
for (ItemHolder i : _items)
|
||||
{
|
||||
long price = -1;
|
||||
|
||||
final Product product = buyList.getProductByItemId(i.getId());
|
||||
if (product == null)
|
||||
{
|
||||
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false BuyList list_id " + _listId + " and item_id " + i.getId(), Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!product.getItem().isStackable() && (i.getCount() > 1))
|
||||
{
|
||||
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " tried to purchase invalid quantity of items at the same time.", Config.DEFAULT_PUNISH);
|
||||
sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EXCEEDED_THE_QUANTITY_THAT_CAN_BE_INPUTTED));
|
||||
return;
|
||||
}
|
||||
|
||||
price = product.getPrice();
|
||||
if ((product.getItemId() >= 3960) && (product.getItemId() <= 4026))
|
||||
{
|
||||
price *= Config.RATE_SIEGE_GUARDS_PRICE;
|
||||
}
|
||||
|
||||
if (price < 0)
|
||||
{
|
||||
_log.warning("ERROR, no price found .. wrong buylist ??");
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((price == 0) && !player.isGM() && Config.ONLY_GM_ITEMS_FREE)
|
||||
{
|
||||
player.sendMessage("Ohh Cheat dont work? You have a problem now!");
|
||||
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " tried buy item for 0 adena.", Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
|
||||
if (product.hasLimitedStock())
|
||||
{
|
||||
// trying to buy more then available
|
||||
if (i.getCount() > product.getCount())
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ((MAX_ADENA / i.getCount()) < price)
|
||||
{
|
||||
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " tried to purchase over " + MAX_ADENA + " adena worth of goods.", Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
// first calculate price per item with tax, then multiply by count
|
||||
price = (long) (price * (1 + castleTaxRate + baseTaxRate));
|
||||
subTotal += i.getCount() * price;
|
||||
if (subTotal > MAX_ADENA)
|
||||
{
|
||||
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " tried to purchase over " + MAX_ADENA + " adena worth of goods.", Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
|
||||
weight += i.getCount() * product.getItem().getWeight();
|
||||
if (player.getInventory().getItemByItemId(product.getItemId()) == null)
|
||||
{
|
||||
slots++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!player.isGM() && ((weight > Integer.MAX_VALUE) || (weight < 0) || !player.getInventory().validateWeight((int) weight)))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_HAVE_EXCEEDED_THE_WEIGHT_LIMIT);
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.isGM() && ((slots > Integer.MAX_VALUE) || (slots < 0) || !player.getInventory().validateCapacity((int) slots)))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOUR_INVENTORY_IS_FULL);
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Charge buyer and add tax to castle treasury if not owned by npc clan
|
||||
if ((subTotal < 0) || !player.reduceAdena("Buy", subTotal, player.getLastFolkNPC(), false))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Proceed the purchase
|
||||
for (ItemHolder i : _items)
|
||||
{
|
||||
final Product product = buyList.getProductByItemId(i.getId());
|
||||
if (product == null)
|
||||
{
|
||||
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false BuyList list_id " + _listId + " and item_id " + i.getId(), Config.DEFAULT_PUNISH);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (product.hasLimitedStock())
|
||||
{
|
||||
if (product.decreaseCount(i.getCount()))
|
||||
{
|
||||
player.getInventory().addItem("Buy", i.getId(), i.getCount(), player, merchant);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.getInventory().addItem("Buy", i.getId(), i.getCount(), player, merchant);
|
||||
}
|
||||
}
|
||||
|
||||
// add to castle treasury
|
||||
if (merchant instanceof L2MerchantInstance)
|
||||
{
|
||||
((L2MerchantInstance) merchant).getCastle().addToTreasury((long) (subTotal * castleTaxRate));
|
||||
}
|
||||
|
||||
player.sendPacket(new ExUserInfoInvenWeight(player));
|
||||
player.sendPacket(new ExBuySellList(player, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__40_REQUESTBUYITEM;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import static com.l2jmobius.gameserver.model.itemcontainer.Inventory.MAX_ADENA;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.datatables.ItemTable;
|
||||
import com.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.CastleManorManager;
|
||||
import com.l2jmobius.gameserver.model.SeedProduction;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2MerchantInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.Castle;
|
||||
import com.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author l3x
|
||||
*/
|
||||
public class RequestBuySeed extends L2GameClientPacket
|
||||
{
|
||||
private static final int BATCH_LENGTH = 12; // length of the one item
|
||||
private int _manorId;
|
||||
private List<ItemHolder> _items = null;
|
||||
|
||||
@Override
|
||||
protected final void readImpl()
|
||||
{
|
||||
_manorId = readD();
|
||||
final int count = readD();
|
||||
if ((count <= 0) || (count > Config.MAX_ITEM_IN_PACKET) || ((count * BATCH_LENGTH) != _buf.remaining()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_items = new ArrayList<>(count);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
final int itemId = readD();
|
||||
final long cnt = readQ();
|
||||
if ((cnt < 1) || (itemId < 1))
|
||||
{
|
||||
_items = null;
|
||||
return;
|
||||
}
|
||||
_items.add(new ItemHolder(itemId, cnt));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void runImpl()
|
||||
{
|
||||
final L2PcInstance player = getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (!getClient().getFloodProtectors().getManor().tryPerformAction("BuySeed"))
|
||||
{
|
||||
player.sendMessage("You are buying seeds too fast!");
|
||||
return;
|
||||
}
|
||||
else if (_items == null)
|
||||
{
|
||||
sendActionFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
final CastleManorManager manor = CastleManorManager.getInstance();
|
||||
if (manor.isUnderMaintenance())
|
||||
{
|
||||
sendActionFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
final Castle castle = CastleManager.getInstance().getCastleById(_manorId);
|
||||
if (castle == null)
|
||||
{
|
||||
sendActionFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
final L2Npc manager = player.getLastFolkNPC();
|
||||
if (!(manager instanceof L2MerchantInstance) || !manager.canInteract(player) || (manager.getTemplate().getParameters().getInt("manor_id", -1) != _manorId))
|
||||
{
|
||||
sendActionFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
long totalPrice = 0;
|
||||
int slots = 0;
|
||||
int totalWeight = 0;
|
||||
|
||||
final Map<Integer, SeedProduction> _productInfo = new HashMap<>();
|
||||
for (ItemHolder ih : _items)
|
||||
{
|
||||
final SeedProduction sp = manor.getSeedProduct(_manorId, ih.getId(), false);
|
||||
if ((sp == null) || (sp.getPrice() <= 0) || (sp.getAmount() < ih.getCount()) || ((MAX_ADENA / ih.getCount()) < sp.getPrice()))
|
||||
{
|
||||
sendActionFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate price
|
||||
totalPrice += (sp.getPrice() * ih.getCount());
|
||||
if (totalPrice > MAX_ADENA)
|
||||
{
|
||||
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " tried to purchase over " + MAX_ADENA + " adena worth of goods.", Config.DEFAULT_PUNISH);
|
||||
sendActionFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate weight
|
||||
final L2Item template = ItemTable.getInstance().getTemplate(ih.getId());
|
||||
totalWeight += ih.getCount() * template.getWeight();
|
||||
|
||||
// Calculate slots
|
||||
if (!template.isStackable())
|
||||
{
|
||||
slots += ih.getCount();
|
||||
}
|
||||
else if (player.getInventory().getItemByItemId(ih.getId()) == null)
|
||||
{
|
||||
slots++;
|
||||
}
|
||||
_productInfo.put(ih.getId(), sp);
|
||||
}
|
||||
|
||||
if (!player.getInventory().validateWeight(totalWeight))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_HAVE_EXCEEDED_THE_WEIGHT_LIMIT);
|
||||
return;
|
||||
}
|
||||
else if (!player.getInventory().validateCapacity(slots))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOUR_INVENTORY_IS_FULL);
|
||||
return;
|
||||
}
|
||||
else if ((totalPrice < 0) || (player.getAdena() < totalPrice))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
|
||||
return;
|
||||
}
|
||||
|
||||
// Proceed the purchase
|
||||
for (ItemHolder i : _items)
|
||||
{
|
||||
final SeedProduction sp = _productInfo.get(i.getId());
|
||||
final long price = sp.getPrice() * i.getCount();
|
||||
|
||||
// Take Adena and decrease seed amount
|
||||
if (!sp.decreaseAmount(i.getCount()) || !player.reduceAdena("Buy", price, player, false))
|
||||
{
|
||||
// failed buy, reduce total price
|
||||
totalPrice -= price;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Add item to player's inventory
|
||||
player.addItem("Buy", i.getId(), i.getCount(), manager, true);
|
||||
}
|
||||
|
||||
// Adding to treasury for Manor Castle
|
||||
if (totalPrice > 0)
|
||||
{
|
||||
castle.addToTreasuryNoTax(totalPrice);
|
||||
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_ADENA_DISAPPEARED);
|
||||
sm.addLong(totalPrice);
|
||||
player.sendPacket(sm);
|
||||
|
||||
if (Config.ALT_MANOR_SAVE_ALL_ACTIONS)
|
||||
{
|
||||
manor.updateCurrentProduction(_manorId, _productInfo.values());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return "[C] C5 RequestBuySeed";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ItemList;
|
||||
|
||||
public class RequestBuySellUIClose extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_76_REQUESTBUYSELLUICLOSE = "[C] D0:76 RequestBuySellUIClose";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
// trigger
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if ((activeChar == null) || activeChar.isInventoryDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new ItemList(activeChar, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_76_REQUESTBUYSELLUICLOSE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,375 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.MultisellData;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.enums.PlayerAction;
|
||||
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.handler.BypassHandler;
|
||||
import com.l2jmobius.gameserver.handler.CommunityBoardHandler;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
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.Hero;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.npc.OnNpcManorBypass;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.npc.OnNpcMenuSelect;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerBypass;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ConfirmDlg;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.util.GMAudit;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* RequestBypassToServer client packet implementation.
|
||||
* @author HorridoJoho
|
||||
*/
|
||||
public final class RequestBypassToServer extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__23_REQUESTBYPASSTOSERVER = "[C] 23 RequestBypassToServer";
|
||||
// FIXME: This is for compatibility, will be changed when bypass functionality got an overhaul by NosBit
|
||||
private static final String[] _possibleNonHtmlCommands =
|
||||
{
|
||||
"_bbs",
|
||||
"bbs",
|
||||
"_mail",
|
||||
"_friend",
|
||||
"_match",
|
||||
"_diary",
|
||||
"_olympiad?command",
|
||||
"menu_select",
|
||||
"manor_menu_select",
|
||||
"pccafe"
|
||||
};
|
||||
|
||||
// S
|
||||
private String _command;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_command = readS();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_command.isEmpty())
|
||||
{
|
||||
_log.warning("Player " + activeChar.getName() + " sent empty bypass!");
|
||||
activeChar.logout();
|
||||
return;
|
||||
}
|
||||
|
||||
boolean requiresBypassValidation = true;
|
||||
for (String possibleNonHtmlCommand : _possibleNonHtmlCommands)
|
||||
{
|
||||
if (_command.startsWith(possibleNonHtmlCommand))
|
||||
{
|
||||
requiresBypassValidation = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int bypassOriginId = 0;
|
||||
if (requiresBypassValidation)
|
||||
{
|
||||
bypassOriginId = activeChar.validateHtmlAction(_command);
|
||||
if (bypassOriginId == -1)
|
||||
{
|
||||
_log.warning("Player " + activeChar.getName() + " sent non cached bypass: '" + _command + "'");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((bypassOriginId > 0) && !Util.isInsideRangeOfObjectId(activeChar, bypassOriginId, L2Npc.INTERACTION_DISTANCE))
|
||||
{
|
||||
// No logging here, this could be a common case where the player has the html still open and run too far away and then clicks a html action
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!getClient().getFloodProtectors().getServerBypass().tryPerformAction(_command))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (_command.startsWith("admin_"))
|
||||
{
|
||||
final String command = _command.split(" ")[0];
|
||||
|
||||
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(command);
|
||||
|
||||
if (ach == null)
|
||||
{
|
||||
if (activeChar.isGM())
|
||||
{
|
||||
activeChar.sendMessage("The command " + command.substring(6) + " does not exist!");
|
||||
}
|
||||
_log.warning(activeChar + " requested not registered admin command '" + command + "'");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!AdminData.getInstance().hasAccess(command, activeChar.getAccessLevel()))
|
||||
{
|
||||
activeChar.sendMessage("You don't have the access rights to use this command!");
|
||||
_log.warning("Character " + activeChar.getName() + " tried to use admin command " + command + ", without proper access level!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (AdminData.getInstance().requireConfirm(command))
|
||||
{
|
||||
activeChar.setAdminConfirmCmd(_command);
|
||||
final ConfirmDlg dlg = new ConfirmDlg(SystemMessageId.S13);
|
||||
dlg.addString("Are you sure you want execute command " + _command.substring(6) + " ?");
|
||||
activeChar.addAction(PlayerAction.ADMIN_COMMAND);
|
||||
activeChar.sendPacket(dlg);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Config.GMAUDIT)
|
||||
{
|
||||
GMAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", _command, (activeChar.getTarget() != null ? activeChar.getTarget().getName() : "no-target"));
|
||||
}
|
||||
|
||||
ach.useAdminCommand(_command, activeChar);
|
||||
}
|
||||
}
|
||||
else if (CommunityBoardHandler.getInstance().isCommunityBoardCommand(_command))
|
||||
{
|
||||
CommunityBoardHandler.getInstance().handleParseCommand(_command, activeChar);
|
||||
}
|
||||
else if (_command.equals("come_here") && activeChar.isGM())
|
||||
{
|
||||
comeHere(activeChar);
|
||||
}
|
||||
else if (_command.startsWith("npc_"))
|
||||
{
|
||||
final int endOfId = _command.indexOf('_', 5);
|
||||
String id;
|
||||
if (endOfId > 0)
|
||||
{
|
||||
id = _command.substring(4, endOfId);
|
||||
}
|
||||
else
|
||||
{
|
||||
id = _command.substring(4);
|
||||
}
|
||||
if (Util.isDigit(id))
|
||||
{
|
||||
final L2Object object = L2World.getInstance().findObject(Integer.parseInt(id));
|
||||
|
||||
if ((object != null) && object.isNpc() && (endOfId > 0) && activeChar.isInsideRadius(object, L2Npc.INTERACTION_DISTANCE, false, false))
|
||||
{
|
||||
((L2Npc) object).onBypassFeedback(activeChar, _command.substring(endOfId + 1));
|
||||
}
|
||||
}
|
||||
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
else if (_command.startsWith("item_"))
|
||||
{
|
||||
final int endOfId = _command.indexOf('_', 5);
|
||||
String id;
|
||||
if (endOfId > 0)
|
||||
{
|
||||
id = _command.substring(5, endOfId);
|
||||
}
|
||||
else
|
||||
{
|
||||
id = _command.substring(5);
|
||||
}
|
||||
try
|
||||
{
|
||||
final L2ItemInstance item = activeChar.getInventory().getItemByObjectId(Integer.parseInt(id));
|
||||
if ((item != null) && (endOfId > 0))
|
||||
{
|
||||
item.onBypassFeedback(activeChar, _command.substring(endOfId + 1));
|
||||
}
|
||||
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
catch (NumberFormatException nfe)
|
||||
{
|
||||
_log.log(Level.WARNING, "NFE for command [" + _command + "]", nfe);
|
||||
}
|
||||
}
|
||||
else if (_command.startsWith("_match"))
|
||||
{
|
||||
final String params = _command.substring(_command.indexOf("?") + 1);
|
||||
final StringTokenizer st = new StringTokenizer(params, "&");
|
||||
final int heroclass = Integer.parseInt(st.nextToken().split("=")[1]);
|
||||
final int heropage = Integer.parseInt(st.nextToken().split("=")[1]);
|
||||
final int heroid = Hero.getInstance().getHeroByClass(heroclass);
|
||||
if (heroid > 0)
|
||||
{
|
||||
Hero.getInstance().showHeroFights(activeChar, heroclass, heroid, heropage);
|
||||
}
|
||||
}
|
||||
else if (_command.startsWith("_diary"))
|
||||
{
|
||||
final String params = _command.substring(_command.indexOf("?") + 1);
|
||||
final StringTokenizer st = new StringTokenizer(params, "&");
|
||||
final int heroclass = Integer.parseInt(st.nextToken().split("=")[1]);
|
||||
final int heropage = Integer.parseInt(st.nextToken().split("=")[1]);
|
||||
final int heroid = Hero.getInstance().getHeroByClass(heroclass);
|
||||
if (heroid > 0)
|
||||
{
|
||||
Hero.getInstance().showHeroDiary(activeChar, heroclass, heroid, heropage);
|
||||
}
|
||||
}
|
||||
else if (_command.startsWith("_olympiad?command"))
|
||||
{
|
||||
final int arenaId = Integer.parseInt(_command.split("=")[2]);
|
||||
final IBypassHandler handler = BypassHandler.getInstance().getHandler("arenachange");
|
||||
if (handler != null)
|
||||
{
|
||||
handler.useBypass("arenachange " + (arenaId - 1), activeChar, null);
|
||||
}
|
||||
}
|
||||
else if (_command.startsWith("menu_select"))
|
||||
{
|
||||
final L2Npc lastNpc = activeChar.getLastFolkNPC();
|
||||
if ((lastNpc != null) && lastNpc.canInteract(activeChar))
|
||||
{
|
||||
final String[] split = _command.substring(_command.indexOf("?") + 1).split("&");
|
||||
final int ask = Integer.parseInt(split[0].split("=")[1]);
|
||||
final int reply = Integer.parseInt(split[1].split("=")[1]);
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcMenuSelect(activeChar, lastNpc, ask, reply), lastNpc);
|
||||
}
|
||||
}
|
||||
else if (_command.startsWith("manor_menu_select"))
|
||||
{
|
||||
final L2Npc lastNpc = activeChar.getLastFolkNPC();
|
||||
if (Config.ALLOW_MANOR && (lastNpc != null) && lastNpc.canInteract(activeChar))
|
||||
{
|
||||
final String[] split = _command.substring(_command.indexOf("?") + 1).split("&");
|
||||
final int ask = Integer.parseInt(split[0].split("=")[1]);
|
||||
final int state = Integer.parseInt(split[1].split("=")[1]);
|
||||
final boolean time = split[2].split("=")[1].equals("1");
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcManorBypass(activeChar, lastNpc, ask, state, time), lastNpc);
|
||||
}
|
||||
}
|
||||
else if (_command.startsWith("pccafe"))
|
||||
{
|
||||
final L2PcInstance player = getClient().getActiveChar();
|
||||
if ((player == null) || !Config.PC_BANG_ENABLED)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final int multisellId = Integer.parseInt(_command.substring(10).trim());
|
||||
MultisellData.getInstance().separateAndSend(multisellId, activeChar, null, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
final IBypassHandler handler = BypassHandler.getInstance().getHandler(_command);
|
||||
if (handler != null)
|
||||
{
|
||||
if (bypassOriginId > 0)
|
||||
{
|
||||
final L2Object bypassOrigin = activeChar.getKnownList().getKnownObjects().get(bypassOriginId);
|
||||
if ((bypassOrigin != null) && bypassOrigin.isInstanceTypes(InstanceType.L2Character))
|
||||
{
|
||||
handler.useBypass(_command, activeChar, (L2Character) bypassOrigin);
|
||||
}
|
||||
else
|
||||
{
|
||||
handler.useBypass(_command, activeChar, null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
handler.useBypass(_command, activeChar, null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.warning(getClient() + " sent not handled RequestBypassToServer: [" + _command + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Exception processing bypass from player " + activeChar.getName() + ": " + _command, e);
|
||||
|
||||
if (activeChar.isGM())
|
||||
{
|
||||
final StringBuilder sb = new StringBuilder(200);
|
||||
sb.append("<html><body>");
|
||||
sb.append("Bypass error: " + e + "<br1>");
|
||||
sb.append("Bypass command: " + _command + "<br1>");
|
||||
sb.append("StackTrace:<br1>");
|
||||
for (StackTraceElement ste : e.getStackTrace())
|
||||
{
|
||||
sb.append(ste.toString() + "<br1>");
|
||||
}
|
||||
sb.append("</body></html>");
|
||||
// item html
|
||||
final NpcHtmlMessage msg = new NpcHtmlMessage(0, 1, sb.toString());
|
||||
msg.disableValidation();
|
||||
activeChar.sendPacket(msg);
|
||||
}
|
||||
}
|
||||
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerBypass(activeChar, _command), activeChar);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
*/
|
||||
private static void comeHere(L2PcInstance activeChar)
|
||||
{
|
||||
final L2Object obj = activeChar.getTarget();
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (obj instanceof L2Npc)
|
||||
{
|
||||
final L2Npc temp = (L2Npc) obj;
|
||||
temp.setTarget(activeChar);
|
||||
temp.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, activeChar.getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__23_REQUESTBYPASSTOSERVER;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.enums.ItemLocation;
|
||||
import com.l2jmobius.gameserver.enums.PrivateStoreType;
|
||||
import com.l2jmobius.gameserver.instancemanager.MailManager;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.Message;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.ItemContainer;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExChangePostState;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExUserInfoInvenWeight;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ItemList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Migi, DS
|
||||
*/
|
||||
public final class RequestCancelPostAttachment extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_6F_REQUESTCANCELPOSTATTACHMENT = "[C] D0:6F RequestCancelPostAttachment";
|
||||
|
||||
private int _msgId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_msgId = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if ((activeChar == null) || !Config.ALLOW_MAIL || !Config.ALLOW_ATTACHMENTS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!getClient().getFloodProtectors().getTransaction().tryPerformAction("cancelpost"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Message msg = MailManager.getInstance().getMessage(_msgId);
|
||||
if (msg == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (msg.getSenderId() != activeChar.getObjectId())
|
||||
{
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " tried to cancel not own post!", Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!activeChar.isInsideZone(ZoneId.PEACE))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_CANCEL_IN_A_NON_PEACE_ZONE_LOCATION);
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.getActiveTradeList() != null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_CANCEL_DURING_AN_EXCHANGE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.hasItemRequest())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_CANCEL_DURING_AN_ITEM_ENHANCEMENT_OR_ATTRIBUTE_ENHANCEMENT);
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.getPrivateStoreType() != PrivateStoreType.NONE)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_CANCEL_BECAUSE_THE_PRIVATE_STORE_OR_WORKSHOP_IS_IN_PROGRESS);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!msg.hasAttachments())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_CANCEL_SENT_MAIL_SINCE_THE_RECIPIENT_RECEIVED_IT);
|
||||
return;
|
||||
}
|
||||
|
||||
final ItemContainer attachments = msg.getAttachments();
|
||||
if ((attachments == null) || (attachments.getSize() == 0))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_CANCEL_SENT_MAIL_SINCE_THE_RECIPIENT_RECEIVED_IT);
|
||||
return;
|
||||
}
|
||||
|
||||
int weight = 0;
|
||||
int slots = 0;
|
||||
|
||||
for (L2ItemInstance item : attachments.getItems())
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item.getOwnerId() != activeChar.getObjectId())
|
||||
{
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " tried to get not own item from cancelled attachment!", Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.getItemLocation() != ItemLocation.MAIL)
|
||||
{
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " tried to get items not from mail !", Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.getLocationSlot() != msg.getId())
|
||||
{
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " tried to get items from different attachment!", Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
|
||||
weight += item.getCount() * item.getItem().getWeight();
|
||||
if (!item.isStackable())
|
||||
{
|
||||
slots += item.getCount();
|
||||
}
|
||||
else if (activeChar.getInventory().getItemByItemId(item.getId()) == null)
|
||||
{
|
||||
slots++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!activeChar.getInventory().validateCapacity(slots))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_COULD_NOT_CANCEL_RECEIPT_BECAUSE_YOUR_INVENTORY_IS_FULL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!activeChar.getInventory().validateWeight(weight))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_COULD_NOT_CANCEL_RECEIPT_BECAUSE_YOUR_INVENTORY_IS_FULL);
|
||||
return;
|
||||
}
|
||||
|
||||
// Proceed to the transfer
|
||||
final InventoryUpdate playerIU = Config.FORCE_INVENTORY_UPDATE ? null : new InventoryUpdate();
|
||||
for (L2ItemInstance item : attachments.getItems())
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final long count = item.getCount();
|
||||
final L2ItemInstance newItem = attachments.transferItem(attachments.getName(), item.getObjectId(), count, activeChar.getInventory(), activeChar, null);
|
||||
if (newItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (playerIU != null)
|
||||
{
|
||||
if (newItem.getCount() > count)
|
||||
{
|
||||
playerIU.addModifiedItem(newItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
playerIU.addNewItem(newItem);
|
||||
}
|
||||
}
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_ACQUIRED_S2_S1);
|
||||
sm.addItemName(item.getId());
|
||||
sm.addLong(count);
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
|
||||
msg.removeAttachments();
|
||||
|
||||
// Send updated item list to the player
|
||||
if (playerIU != null)
|
||||
{
|
||||
activeChar.sendPacket(playerIU);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(new ItemList(activeChar, false));
|
||||
}
|
||||
|
||||
// Update current load status on player
|
||||
activeChar.sendPacket(new ExUserInfoInvenWeight(activeChar));
|
||||
|
||||
final L2PcInstance receiver = L2World.getInstance().getPlayer(msg.getReceiverId());
|
||||
if (receiver != null)
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_CANCELED_THE_SENT_MAIL);
|
||||
sm.addCharName(activeChar);
|
||||
receiver.sendPacket(sm);
|
||||
receiver.sendPacket(new ExChangePostState(true, _msgId, Message.DELETED));
|
||||
}
|
||||
|
||||
MailManager.getInstance().deleteMessageInDb(_msgId);
|
||||
|
||||
activeChar.sendPacket(new ExChangePostState(false, _msgId, Message.DELETED));
|
||||
activeChar.sendPacket(SystemMessageId.MAIL_SUCCESSFULLY_CANCELLED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_6F_REQUESTCANCELPOSTATTACHMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AbilityPointsData;
|
||||
import com.l2jmobius.gameserver.enums.UserInfoType;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExAcquireAPSkillList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.UserInfo;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class RequestChangeAbilityPoint extends L2GameClientPacket
|
||||
{
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
// Nothing to read
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((activeChar.getLevel() < 99) || !activeChar.isNoble())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.ABILITIES_CAN_BE_USED_BY_NOBLESSE_EXALTED_LV_99_OR_ABOVE);
|
||||
return;
|
||||
}
|
||||
|
||||
else if (activeChar.getAbilityPoints() >= Config.ABILITY_MAX_POINTS)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_ACQUIRE_ANY_MORE_ABILITY_POINTS);
|
||||
return;
|
||||
}
|
||||
|
||||
final long spRequired = AbilityPointsData.getInstance().getPrice(activeChar.getAbilityPoints());
|
||||
if (spRequired > activeChar.getSp())
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_NEED_S1_SP_TO_CONVERT_TO1_ABILITY_POINT);
|
||||
sm.addLong(spRequired);
|
||||
activeChar.sendPacket(sm);
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.getStat().removeSp(spRequired))
|
||||
{
|
||||
activeChar.setAbilityPoints(activeChar.getAbilityPoints() + 1);
|
||||
final UserInfo info = new UserInfo(activeChar, false);
|
||||
info.addComponentType(UserInfoType.SLOTS, UserInfoType.CURRENT_HPMPCP_EXP_SP);
|
||||
activeChar.sendPacket(info);
|
||||
activeChar.sendPacket(new ExAcquireAPSkillList(activeChar));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
}
|
||||
@@ -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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.request.EnchantItemAttributeRequest;
|
||||
|
||||
/**
|
||||
* @author Erlandys
|
||||
*/
|
||||
public class RequestChangeAttributeCancel extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_B7_SENDCHANGEATTRIBUTETARGETITEM = "[C] D0:B7 RequestChangeAttributeCancel";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance player = getClient().getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final EnchantItemAttributeRequest request = player.getRequest(EnchantItemAttributeRequest.class);
|
||||
if (request == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
player.removeRequest(request.getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_B7_SENDCHANGEATTRIBUTETARGETITEM;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.enums.PrivateStoreType;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.request.EnchantItemAttributeRequest;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExChangeAttributeFail;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExChangeAttributeItemList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExChangeAttributeOk;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExStorageMaxCount;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.UserInfo;
|
||||
import com.l2jmobius.util.Rnd;
|
||||
|
||||
/**
|
||||
* @author Erlandys
|
||||
*/
|
||||
public class RequestChangeAttributeItem extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_B7_SENDCHANGEATTRIBUTETARGETITEM = "[C] D0:B7 SendChangeAttributeTargetItem";
|
||||
|
||||
private int _attributeOID;
|
||||
private int _itemOID;
|
||||
private int _newAttributeID;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_attributeOID = readD();
|
||||
_itemOID = readD();
|
||||
_newAttributeID = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance player = getClient().getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final EnchantItemAttributeRequest request = player.getRequest(EnchantItemAttributeRequest.class);
|
||||
if (request == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
request.setProcessing(true);
|
||||
|
||||
final L2ItemInstance item = player.getInventory().getItemByObjectId(_itemOID);
|
||||
|
||||
if (player.getPrivateStoreType() != PrivateStoreType.NONE)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_CHANGE_AN_ATTRIBUTE_WHILE_USING_A_PRIVATE_STORE_OR_WORKSHOP);
|
||||
player.removeRequest(request.getClass());
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getActiveTradeList() != null)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_CHANGE_ATTRIBUTES_WHILE_EXCHANGING);
|
||||
player.removeRequest(request.getClass());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!item.isWeapon())
|
||||
{
|
||||
player.removeRequest(request.getClass());
|
||||
player.sendPacket(new ExChangeAttributeItemList(player, _attributeOID));
|
||||
return;
|
||||
}
|
||||
|
||||
if (_newAttributeID == -1)
|
||||
{
|
||||
player.removeRequest(request.getClass());
|
||||
player.sendPacket(new ExChangeAttributeItemList(player, _attributeOID));
|
||||
return;
|
||||
}
|
||||
final L2ItemInstance attribute = player.getInventory().getItemByObjectId(_attributeOID);
|
||||
player.getInventory().destroyItem("ChangingAttribute", _attributeOID, 1, player, null);
|
||||
|
||||
if (Rnd.get(100) < Config.CHANGE_CHANCE_ELEMENT)
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_S_S2_ATTRIBUTE_HAS_SUCCESSFULLY_CHANGED_TO_S3_ATTRIBUTE);
|
||||
sm.addItemName(item);
|
||||
sm.addElemental(item.getAttackElementType());
|
||||
sm.addElemental(_newAttributeID);
|
||||
|
||||
item.changeAttribute((byte) _newAttributeID, item.getAttackElementPower());
|
||||
if (item.isEquipped())
|
||||
{
|
||||
item.updateElementAttrBonus(player);
|
||||
}
|
||||
|
||||
player.sendPacket(sm);
|
||||
player.sendPacket(new ExChangeAttributeOk());
|
||||
player.sendPacket(new UserInfo(player));
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(new ExChangeAttributeFail());
|
||||
player.sendPacket(SystemMessageId.CHANGING_ATTRIBUTES_HAS_BEEN_FAILED);
|
||||
}
|
||||
|
||||
// send packets
|
||||
player.sendPacket(new ExStorageMaxCount(player));
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
iu.addModifiedItem(item);
|
||||
if (player.getInventory().getItemByObjectId(_attributeOID) == null)
|
||||
{
|
||||
iu.addRemovedItem(attribute);
|
||||
}
|
||||
else
|
||||
{
|
||||
iu.addModifiedItem(attribute);
|
||||
}
|
||||
player.sendPacket(iu);
|
||||
|
||||
player.removeRequest(request.getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_B7_SENDCHANGEATTRIBUTETARGETITEM;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
/**
|
||||
* @author ShanSoft Packets Structure: chddd
|
||||
*/
|
||||
public final class RequestChangeBookMarkSlot extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_51_05_REQUESCHANGEBOOKMARKSLOT = "[C] D0:51:05 RequestChangeBookMarkSlot";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
// There is nothing to read.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_51_05_REQUESCHANGEBOOKMARKSLOT;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
|
||||
/**
|
||||
* @author KenM, Gnacik
|
||||
*/
|
||||
public class RequestChangeNicknameColor extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_4F_REQUESTCHANGENICKNAMECOLOR = "[C] D0:4F RequestChangeNicknameColor";
|
||||
|
||||
private static final int COLORS[] =
|
||||
{
|
||||
0x9393FF, // Pink
|
||||
0x7C49FC, // Rose Pink
|
||||
0x97F8FC, // Lemon Yellow
|
||||
0xFA9AEE, // Lilac
|
||||
0xFF5D93, // Cobalt Violet
|
||||
0x00FCA0, // Mint Green
|
||||
0xA0A601, // Peacock Green
|
||||
0x7898AF, // Yellow Ochre
|
||||
0x486295, // Chocolate
|
||||
0x999999
|
||||
// Silver
|
||||
};
|
||||
|
||||
private int _colorNum, _itemObjectId;
|
||||
private String _title;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_colorNum = readD();
|
||||
_title = readS();
|
||||
_itemObjectId = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_colorNum < 0) || (_colorNum >= COLORS.length))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_itemObjectId);
|
||||
if ((item == null) || (item.getEtcItem() == null) || (item.getEtcItem().getHandlerName() == null) || !item.getEtcItem().getHandlerName().equalsIgnoreCase("NicknameColor"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.destroyItem("Consume", item, 1, null, true))
|
||||
{
|
||||
activeChar.setTitle(_title);
|
||||
activeChar.getAppearance().setTitleColor(COLORS[_colorNum]);
|
||||
activeChar.broadcastUserInfo();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_4F_REQUESTCHANGENICKNAMECOLOR;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Party;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* This packet is received from client when a party leader requests to change the leadership to another player in his party.
|
||||
*/
|
||||
public final class RequestChangePartyLeader extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_0C_REQUESTCHANGEPARTYLEADER = "[C] D0:0C RequestChangePartyLeader";
|
||||
|
||||
private String _name;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_name = readS();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2Party party = activeChar.getParty();
|
||||
if ((party != null) && party.isLeader(activeChar))
|
||||
{
|
||||
party.changePartyLeader(_name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_0C_REQUESTCHANGEPARTYLEADER;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.data.sql.impl.PetNameTable;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Summon;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.3.4.4 $ $Date: 2005/04/06 16:13:48 $
|
||||
*/
|
||||
public final class RequestChangePetName extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__93_REQUESTCHANGEPETNAME = "[C] 93 RequestChangePetName";
|
||||
|
||||
private String _name;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_name = readS();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2Summon pet = activeChar.getPet();
|
||||
if (pet == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!pet.isPet())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_A_PET);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pet.getName() != null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_SET_THE_NAME_OF_THE_PET);
|
||||
return;
|
||||
}
|
||||
|
||||
if (PetNameTable.getInstance().doesPetNameExist(_name, pet.getTemplate().getId()))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_IS_ALREADY_IN_USE_BY_ANOTHER_PET);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_name.length() < 3) || (_name.length() > 16))
|
||||
{
|
||||
// activeChar.sendPacket(SystemMessageId.YOUR_PET_S_NAME_CAN_BE_UP_TO_8_CHARACTERS_IN_LENGTH);
|
||||
activeChar.sendMessage("Your pet's name can be up to 16 characters in length.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PetNameTable.getInstance().isValidPetName(_name))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.AN_INVALID_CHARACTER_IS_INCLUDED_IN_THE_PET_S_NAME);
|
||||
return;
|
||||
}
|
||||
|
||||
pet.setName(_name);
|
||||
pet.updateAndBroadcastStatus(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__93_REQUESTCHANGEPETNAME;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerChangeToAwakenedClass;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class RequestChangeToAwakenedClass extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_A1_REQUESTCHANGETOAWAKENEDCLASS = "[C] D0;A2 RequestChangeToAwakenedClass";
|
||||
|
||||
private boolean _change;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_change = readD() == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance player = getClient().getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_change)
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerChangeToAwakenedClass(player), player);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_A1_REQUESTCHANGETOAWAKENEDCLASS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExIsCharNameCreatable;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class RequestCharacterNameCreatable extends L2GameClientPacket
|
||||
{
|
||||
private String _name;
|
||||
private int result;
|
||||
|
||||
public static int CHARACTER_CREATE_FAILED = 1;
|
||||
public static int NAME_ALREADY_EXISTS = 2;
|
||||
public static int INVALID_LENGTH = 3;
|
||||
public static int INVALID_NAME = 4;
|
||||
public static int CANNOT_CREATE_SERVER = 5;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_name = readS();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final int charId = CharNameTable.getInstance().getIdByName(_name);
|
||||
|
||||
if (!Util.isAlphaNumeric(_name) || !isValidName(_name))
|
||||
{
|
||||
result = INVALID_NAME;
|
||||
}
|
||||
else if (charId > 0)
|
||||
{
|
||||
result = NAME_ALREADY_EXISTS;
|
||||
}
|
||||
else if (_name.length() > 16)
|
||||
{
|
||||
result = INVALID_LENGTH;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = -1;
|
||||
}
|
||||
|
||||
sendPacket(new ExIsCharNameCreatable(result));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return "[C] D0:B0 RequestCharacterNameCreatable";
|
||||
}
|
||||
|
||||
private boolean isValidName(String text)
|
||||
{
|
||||
return Config.CHARNAME_TEMPLATE_PATTERN.matcher(text).matches();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExPutItemResultForVariationCancel;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* Format(ch) d
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public final class RequestConfirmCancelItem extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_42_REQUESTCONFIRMCANCELITEM = "[C] D0:42 RequestConfirmCancelItem";
|
||||
private int _objectId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_objectId = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.getOwnerId() != activeChar.getObjectId())
|
||||
{
|
||||
Util.handleIllegalPlayerAction(getClient().getActiveChar(), "Warning!! Character " + getClient().getActiveChar().getName() + " of account " + getClient().getActiveChar().getAccountName() + " tryied to destroy augment on item that doesn't own.", Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!item.isAugmented())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.AUGMENTATION_REMOVAL_CAN_ONLY_BE_DONE_ON_AN_AUGMENTED_ITEM);
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.isPvp() && !Config.ALT_ALLOW_AUGMENT_PVP_ITEMS)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_IS_NOT_A_SUITABLE_ITEM);
|
||||
return;
|
||||
}
|
||||
|
||||
int price = 0;
|
||||
switch (item.getItem().getCrystalType())
|
||||
{
|
||||
case C:
|
||||
{
|
||||
if (item.getCrystalCount() < 1720)
|
||||
{
|
||||
price = 95000;
|
||||
}
|
||||
else if (item.getCrystalCount() < 2452)
|
||||
{
|
||||
price = 150000;
|
||||
}
|
||||
else
|
||||
{
|
||||
price = 210000;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case B:
|
||||
{
|
||||
if (item.getCrystalCount() < 1746)
|
||||
{
|
||||
price = 240000;
|
||||
}
|
||||
else
|
||||
{
|
||||
price = 270000;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case A:
|
||||
{
|
||||
if (item.getCrystalCount() < 2160)
|
||||
{
|
||||
price = 330000;
|
||||
}
|
||||
else if (item.getCrystalCount() < 2824)
|
||||
{
|
||||
price = 390000;
|
||||
}
|
||||
else
|
||||
{
|
||||
price = 420000;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case S:
|
||||
{
|
||||
price = 480000;
|
||||
break;
|
||||
}
|
||||
case S80:
|
||||
case S84:
|
||||
{
|
||||
price = 920000;
|
||||
break;
|
||||
}
|
||||
case R:
|
||||
{
|
||||
price = 1840000;
|
||||
break;
|
||||
}
|
||||
case R95:
|
||||
{
|
||||
price = 3680000;
|
||||
break;
|
||||
}
|
||||
case R99:
|
||||
{
|
||||
price = 7360000;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new ExPutItemResultForVariationCancel(item, price));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_42_REQUESTCONFIRMCANCELITEM;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExPutCommissionResultForVariationMake;
|
||||
|
||||
/**
|
||||
* Format:(ch) dddd
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public final class RequestConfirmGemStone extends AbstractRefinePacket
|
||||
{
|
||||
private static final String _C__D0_28_REQUESTCONFIRMGEMSTONE = "[C] D0:28 RequestConfirmGemStone";
|
||||
private int _targetItemObjId;
|
||||
private int _refinerItemObjId;
|
||||
private int _gemstoneItemObjId;
|
||||
private long _gemStoneCount;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_targetItemObjId = readD();
|
||||
_refinerItemObjId = readD();
|
||||
_gemstoneItemObjId = readD();
|
||||
_gemStoneCount = readQ();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final L2ItemInstance targetItem = activeChar.getInventory().getItemByObjectId(_targetItemObjId);
|
||||
if (targetItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final L2ItemInstance refinerItem = activeChar.getInventory().getItemByObjectId(_refinerItemObjId);
|
||||
if (refinerItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final L2ItemInstance gemStoneItem = activeChar.getInventory().getItemByObjectId(_gemstoneItemObjId);
|
||||
if (gemStoneItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure the item is a gemstone
|
||||
if (!isValid(activeChar, targetItem, refinerItem, gemStoneItem))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_IS_NOT_A_SUITABLE_ITEM);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for gemstone count
|
||||
final LifeStone ls = getLifeStone(refinerItem.getId());
|
||||
if (ls == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_gemStoneCount != getGemStoneCount(targetItem.getItem().getCrystalType(), ls.getGrade()))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.GEMSTONE_QUANTITY_IS_INCORRECT);
|
||||
return;
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new ExPutCommissionResultForVariationMake(_gemstoneItemObjId, _gemStoneCount, gemStoneItem.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_28_REQUESTCONFIRMGEMSTONE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.items.type.CrystalType;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExPutIntensiveResultForVariationMake;
|
||||
|
||||
/**
|
||||
* Fromat(ch) dd
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class RequestConfirmRefinerItem extends AbstractRefinePacket
|
||||
{
|
||||
private static final String _C__D0_27_REQUESTCONFIRMREFINERITEM = "[C] D0:27 RequestConfirmRefinerItem";
|
||||
|
||||
private int _targetItemObjId;
|
||||
private int _refinerItemObjId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_targetItemObjId = readD();
|
||||
_refinerItemObjId = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2ItemInstance targetItem = activeChar.getInventory().getItemByObjectId(_targetItemObjId);
|
||||
if (targetItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2ItemInstance refinerItem = activeChar.getInventory().getItemByObjectId(_refinerItemObjId);
|
||||
if (refinerItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isValid(activeChar, targetItem, refinerItem))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_IS_NOT_A_SUITABLE_ITEM);
|
||||
return;
|
||||
}
|
||||
|
||||
final int refinerItemId = refinerItem.getItem().getId();
|
||||
final CrystalType grade = targetItem.getItem().getCrystalType();
|
||||
final LifeStone ls = getLifeStone(refinerItemId);
|
||||
final int gemStoneId = getGemStoneId(grade);
|
||||
final int gemStoneCount = getGemStoneCount(grade, ls.getGrade());
|
||||
|
||||
activeChar.sendPacket(new ExPutIntensiveResultForVariationMake(_refinerItemObjId, refinerItemId, gemStoneId, gemStoneCount));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_27_REQUESTCONFIRMREFINERITEM;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||
import com.l2jmobius.gameserver.model.L2Clan;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.Castle;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SiegeDefenderList;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.3.4.2 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public final class RequestConfirmSiegeWaitingList extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__AE_RequestConfirmSiegeWaitingList = "[C] AE RequestConfirmSiegeWaitingList";
|
||||
|
||||
private int _approved;
|
||||
private int _castleId;
|
||||
private int _clanId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_castleId = readD();
|
||||
_clanId = readD();
|
||||
_approved = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the player has a clan
|
||||
if (activeChar.getClan() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Castle castle = CastleManager.getInstance().getCastleById(_castleId);
|
||||
if (castle == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if leader of the clan who owns the castle?
|
||||
if ((castle.getOwnerId() != activeChar.getClanId()) || (!activeChar.isClanLeader()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2Clan clan = ClanTable.getInstance().getClan(_clanId);
|
||||
if (clan == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!castle.getSiege().getIsRegistrationOver())
|
||||
{
|
||||
if (_approved == 1)
|
||||
{
|
||||
if (castle.getSiege().checkIsDefenderWaiting(clan))
|
||||
{
|
||||
castle.getSiege().approveSiegeDefenderClan(_clanId);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((castle.getSiege().checkIsDefenderWaiting(clan)) || (castle.getSiege().checkIsDefender(clan)))
|
||||
{
|
||||
castle.getSiege().removeSiegeClan(_clanId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update the defender list
|
||||
activeChar.sendPacket(new SiegeDefenderList(castle));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__AE_RequestConfirmSiegeWaitingList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExPutItemResultForVariationMake;
|
||||
|
||||
/**
|
||||
* Format:(ch) d
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public final class RequestConfirmTargetItem extends AbstractRefinePacket
|
||||
{
|
||||
private static final String _C__D0_26_REQUESTCONFIRMTARGETITEM = "[C] D0:26 RequestConfirmTargetItem";
|
||||
private int _itemObjId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_itemObjId = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_itemObjId);
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isValid(activeChar, item))
|
||||
{
|
||||
// Different system message here
|
||||
if (item.isAugmented())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.ONCE_AN_ITEM_IS_AUGMENTED_IT_CANNOT_BE_AUGMENTED_AGAIN);
|
||||
return;
|
||||
}
|
||||
|
||||
activeChar.sendPacket(SystemMessageId.THIS_IS_NOT_A_SUITABLE_ITEM);
|
||||
return;
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new ExPutItemResultForVariationMake(_itemObjId, item.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_26_REQUESTCONFIRMTARGETITEM;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,279 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystalizationData;
|
||||
import com.l2jmobius.gameserver.enums.PrivateStoreType;
|
||||
import com.l2jmobius.gameserver.enums.Race;
|
||||
import com.l2jmobius.gameserver.model.CrystalizationData;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.PcInventory;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.items.type.CrystalType;
|
||||
import com.l2jmobius.gameserver.model.skills.CommonSkill;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
import com.l2jmobius.util.Rnd;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.2.2.3.2.5 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public final class RequestCrystallizeItem extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__2F_REQUESTDCRYSTALLIZEITEM = "[C] 2F RequestCrystallizeItem";
|
||||
|
||||
private int _objectId;
|
||||
private long _count;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_objectId = readD();
|
||||
_count = readQ();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
|
||||
if (activeChar == null)
|
||||
{
|
||||
_log.fine("RequestCrystalizeItem: activeChar was null");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!getClient().getFloodProtectors().getTransaction().tryPerformAction("crystallize"))
|
||||
{
|
||||
activeChar.sendMessage("You are crystallizing too fast.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_count <= 0)
|
||||
{
|
||||
Util.handleIllegalPlayerAction(activeChar, "[RequestCrystallizeItem] count <= 0! ban! oid: " + _objectId + " owner: " + activeChar.getName(), Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((activeChar.getPrivateStoreType() != PrivateStoreType.NONE) || !activeChar.isInCrystallize())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.WHILE_OPERATING_A_PRIVATE_STORE_OR_WORKSHOP_YOU_CANNOT_DISCARD_DESTROY_OR_TRADE_AN_ITEM);
|
||||
return;
|
||||
}
|
||||
|
||||
final int skillLevel = activeChar.getSkillLevel(CommonSkill.CRYSTALLIZE.getId());
|
||||
if (skillLevel <= 0)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_MAY_NOT_CRYSTALLIZE_THIS_ITEM_YOUR_CRYSTALLIZATION_SKILL_LEVEL_IS_TOO_LOW);
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
if ((activeChar.getRace() != Race.DWARF) && (activeChar.getClassId().ordinal() != 117) && (activeChar.getClassId().ordinal() != 55))
|
||||
{
|
||||
_log.info("Player " + activeChar.getClient() + " used crystalize with classid: " + activeChar.getClassId().ordinal());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
final PcInventory inventory = activeChar.getInventory();
|
||||
if (inventory != null)
|
||||
{
|
||||
final L2ItemInstance item = inventory.getItemByObjectId(_objectId);
|
||||
if (item == null)
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.isHeroItem())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_count > item.getCount())
|
||||
{
|
||||
_count = activeChar.getInventory().getItemByObjectId(_objectId).getCount();
|
||||
}
|
||||
}
|
||||
|
||||
final L2ItemInstance itemToRemove = activeChar.getInventory().getItemByObjectId(_objectId);
|
||||
if ((itemToRemove == null) || itemToRemove.isShadowItem() || itemToRemove.isTimeLimitedItem())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!itemToRemove.getItem().isCrystallizable() || (itemToRemove.getItem().getCrystalCount() <= 0) || (itemToRemove.getItem().getCrystalType() == CrystalType.NONE))
|
||||
{
|
||||
_log.warning(activeChar.getName() + " (" + activeChar.getObjectId() + ") tried to crystallize " + itemToRemove.getItem().getId());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!activeChar.getInventory().canManipulateWithItemId(itemToRemove.getId()))
|
||||
{
|
||||
activeChar.sendMessage("You cannot use this item.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the char can crystallize items and return if false;
|
||||
boolean canCrystallize = true;
|
||||
|
||||
switch (itemToRemove.getItem().getCrystalTypePlus())
|
||||
{
|
||||
case D:
|
||||
{
|
||||
if (skillLevel < 1)
|
||||
{
|
||||
canCrystallize = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case C:
|
||||
{
|
||||
if (skillLevel < 2)
|
||||
{
|
||||
canCrystallize = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case B:
|
||||
{
|
||||
if (skillLevel < 3)
|
||||
{
|
||||
canCrystallize = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case A:
|
||||
{
|
||||
if (skillLevel < 4)
|
||||
{
|
||||
canCrystallize = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case S:
|
||||
{
|
||||
if (skillLevel < 5)
|
||||
{
|
||||
canCrystallize = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case R:
|
||||
{
|
||||
if (skillLevel < 6)
|
||||
{
|
||||
canCrystallize = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!canCrystallize)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_MAY_NOT_CRYSTALLIZE_THIS_ITEM_YOUR_CRYSTALLIZATION_SKILL_LEVEL_IS_TOO_LOW);
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// activeChar.setInCrystallize(true);
|
||||
|
||||
// unequip if needed
|
||||
SystemMessage sm;
|
||||
if (itemToRemove.isEquipped())
|
||||
{
|
||||
final L2ItemInstance[] unequiped = activeChar.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot());
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
for (L2ItemInstance item : unequiped)
|
||||
{
|
||||
iu.addModifiedItem(item);
|
||||
}
|
||||
activeChar.sendPacket(iu);
|
||||
|
||||
if (itemToRemove.getEnchantLevel() > 0)
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.THE_EQUIPMENT_S1_S2_HAS_BEEN_REMOVED);
|
||||
sm.addInt(itemToRemove.getEnchantLevel());
|
||||
sm.addItemName(itemToRemove);
|
||||
}
|
||||
else
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED);
|
||||
sm.addItemName(itemToRemove);
|
||||
}
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
|
||||
// remove from inventory
|
||||
final L2ItemInstance removedItem = activeChar.getInventory().destroyItem("Crystalize", _objectId, _count, activeChar, null);
|
||||
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
iu.addRemovedItem(removedItem);
|
||||
activeChar.sendPacket(iu);
|
||||
|
||||
final int crystalId = itemToRemove.getItem().getCrystalItemId();
|
||||
final int crystalAmount = itemToRemove.getCrystalCount();
|
||||
|
||||
final List<ItemChanceHolder> items = new ArrayList<>();
|
||||
items.add(new ItemChanceHolder(crystalId, 100, crystalAmount));
|
||||
|
||||
final CrystalizationData data = ItemCrystalizationData.getInstance().getCrystalization(itemToRemove.getId());
|
||||
if (data != null)
|
||||
{
|
||||
data.getItems().stream().filter(holder -> (holder.getId() != crystalId)).forEach(items::add);
|
||||
}
|
||||
|
||||
for (ItemChanceHolder holder : items)
|
||||
{
|
||||
final double rand = Rnd.nextDouble() * 100;
|
||||
if (rand < holder.getChance())
|
||||
{
|
||||
// add crystals
|
||||
final L2ItemInstance createdItem = activeChar.getInventory().addItem("Crystalize", holder.getId(), holder.getCount(), activeChar, activeChar);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S2_S1_S);
|
||||
sm.addItemName(createdItem);
|
||||
sm.addLong(holder.getCount());
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
}
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_CRYSTALLIZED);
|
||||
sm.addItemName(removedItem);
|
||||
activeChar.sendPacket(sm);
|
||||
|
||||
activeChar.broadcastUserInfo();
|
||||
|
||||
L2World.getInstance().removeObject(removedItem);
|
||||
|
||||
activeChar.setInCrystallize(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__2F_REQUESTDCRYSTALLIZEITEM;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExCursedWeaponList;
|
||||
|
||||
/**
|
||||
* Format: (ch)
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class RequestCursedWeaponList extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_2A_REQUESTCURSEDWEAPONLIST = "[C] D0:2A RequestCursedWeaponList";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
// nothing to read it's just a trigger
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2Character activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// send a ExCursedWeaponList :p
|
||||
final List<Integer> list = new ArrayList<>();
|
||||
for (int id : CursedWeaponsManager.getInstance().getCursedWeaponsIds())
|
||||
{
|
||||
list.add(id);
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new ExCursedWeaponList(list));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_2A_REQUESTCURSEDWEAPONLIST;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
||||
import com.l2jmobius.gameserver.model.CursedWeapon;
|
||||
import com.l2jmobius.gameserver.model.Location;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExCursedWeaponLocation;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExCursedWeaponLocation.CursedWeaponInfo;
|
||||
|
||||
/**
|
||||
* Format: (ch)
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public final class RequestCursedWeaponLocation extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_2B_REQUESTCURSEDWEAPONLOCATION = "[C] D0:2B RequestCursedWeaponLocation";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
// nothing to read it's just a trigger
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2Character activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final List<CursedWeaponInfo> list = new ArrayList<>();
|
||||
for (CursedWeapon cw : CursedWeaponsManager.getInstance().getCursedWeapons())
|
||||
{
|
||||
if (!cw.isActive())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final Location pos = cw.getWorldPosition();
|
||||
if (pos != null)
|
||||
{
|
||||
list.add(new CursedWeaponInfo(pos, cw.getItemId(), cw.isActivated() ? 1 : 0));
|
||||
}
|
||||
}
|
||||
|
||||
// send the ExCursedWeaponLocation
|
||||
if (!list.isEmpty())
|
||||
{
|
||||
activeChar.sendPacket(new ExCursedWeaponLocation(list));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_2B_REQUESTCURSEDWEAPONLOCATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* @author ShanSoft
|
||||
* @structure: chdd
|
||||
*/
|
||||
public final class RequestDeleteBookMarkSlot extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_51_03_REQUESTDELETEBOOKMARKSLOT = "[C] D0:51:03 RequestDeleteBookMarkSlot";
|
||||
|
||||
private int id;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
id = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
activeChar.teleportBookmarkDelete(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_51_03_REQUESTDELETEBOOKMARKSLOT;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
public final class RequestDeleteMacro extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__CE_REQUESTDELETEMACRO = "[C] CE RequestDeleteMacro";
|
||||
|
||||
private int _id;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_id = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
if (getClient().getActiveChar() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
getClient().getActiveChar().deleteMacro(_id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__CE_REQUESTDELETEMACRO;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.instancemanager.MailManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.Message;
|
||||
import com.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExChangePostState;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Migi, DS
|
||||
*/
|
||||
public final class RequestDeleteReceivedPost extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_68_REQUESTDELETERECEIVEDPOST = "[C] D0:68 RequestDeleteReceivedPost";
|
||||
|
||||
private static final int BATCH_LENGTH = 4; // length of the one item
|
||||
|
||||
int[] _msgIds = null;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
final int count = readD();
|
||||
if ((count <= 0) || (count > Config.MAX_ITEM_IN_PACKET) || ((count * BATCH_LENGTH) != _buf.remaining()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_msgIds = new int[count];
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
_msgIds[i] = readD();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if ((activeChar == null) || (_msgIds == null) || !Config.ALLOW_MAIL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!activeChar.isInsideZone(ZoneId.PEACE))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_RECEIVE_OR_SEND_MAIL_WITH_ATTACHED_ITEMS_IN_NON_PEACE_ZONE_REGIONS);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int msgId : _msgIds)
|
||||
{
|
||||
final Message msg = MailManager.getInstance().getMessage(msgId);
|
||||
if (msg == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (msg.getReceiverId() != activeChar.getObjectId())
|
||||
{
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " tried to delete not own post!", Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.hasAttachments() || msg.isDeletedByReceiver())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
msg.setDeletedByReceiver();
|
||||
}
|
||||
activeChar.sendPacket(new ExChangePostState(true, _msgIds, Message.DELETED));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_68_REQUESTDELETERECEIVEDPOST;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.instancemanager.MailManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.Message;
|
||||
import com.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExChangePostState;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Migi, DS
|
||||
*/
|
||||
public final class RequestDeleteSentPost extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_6D_REQUESTDELETESENTPOST = "[C] D0:6D RequestDeleteSentPost";
|
||||
|
||||
private static final int BATCH_LENGTH = 4; // length of the one item
|
||||
|
||||
int[] _msgIds = null;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
final int count = readD();
|
||||
if ((count <= 0) || (count > Config.MAX_ITEM_IN_PACKET) || ((count * BATCH_LENGTH) != _buf.remaining()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_msgIds = new int[count];
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
_msgIds[i] = readD();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if ((activeChar == null) || (_msgIds == null) || !Config.ALLOW_MAIL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!activeChar.isInsideZone(ZoneId.PEACE))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_RECEIVE_OR_SEND_MAIL_WITH_ATTACHED_ITEMS_IN_NON_PEACE_ZONE_REGIONS);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int msgId : _msgIds)
|
||||
{
|
||||
final Message msg = MailManager.getInstance().getMessage(msgId);
|
||||
if (msg == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (msg.getSenderId() != activeChar.getObjectId())
|
||||
{
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " tried to delete not own post!", Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.hasAttachments() || msg.isDeletedBySender())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
msg.setDeletedBySender();
|
||||
}
|
||||
activeChar.sendPacket(new ExChangePostState(false, _msgIds, Message.DELETED));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_6D_REQUESTDELETESENTPOST;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jmobius.gameserver.enums.PrivateStoreType;
|
||||
import com.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
||||
import com.l2jmobius.gameserver.model.PcCondOverride;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Summon;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExUserInfoInvenWeight;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ItemList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.7.2.4.2.6 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public final class RequestDestroyItem extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__60_REQUESTDESTROYITEM = "[C] 60 RequestDestroyItem";
|
||||
|
||||
private int _objectId;
|
||||
private long _count;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_objectId = readD();
|
||||
_count = readQ();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_count <= 0)
|
||||
{
|
||||
if (_count < 0)
|
||||
{
|
||||
Util.handleIllegalPlayerAction(activeChar, "[RequestDestroyItem] Character " + activeChar.getName() + " of account " + activeChar.getAccountName() + " tried to destroy item with oid " + _objectId + " but has count < 0!", Config.DEFAULT_PUNISH);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!getClient().getFloodProtectors().getTransaction().tryPerformAction("destroy"))
|
||||
{
|
||||
activeChar.sendMessage("You are destroying items too fast.");
|
||||
return;
|
||||
}
|
||||
|
||||
long count = _count;
|
||||
|
||||
if (activeChar.isProcessingTransaction() || (activeChar.getPrivateStoreType() != PrivateStoreType.NONE))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.WHILE_OPERATING_A_PRIVATE_STORE_OR_WORKSHOP_YOU_CANNOT_DISCARD_DESTROY_OR_TRADE_AN_ITEM);
|
||||
return;
|
||||
}
|
||||
|
||||
final L2ItemInstance itemToRemove = activeChar.getInventory().getItemByObjectId(_objectId);
|
||||
|
||||
// if we can't find the requested item, its actually a cheat
|
||||
if (itemToRemove == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_ITEM_CANNOT_BE_DESTROYED);
|
||||
return;
|
||||
}
|
||||
|
||||
// Cannot discard item that the skill is consuming
|
||||
if (activeChar.isCastingNow())
|
||||
{
|
||||
if ((activeChar.getCurrentSkill() != null) && (activeChar.getCurrentSkill().getSkill().getItemConsumeId() == itemToRemove.getId()))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_ITEM_CANNOT_BE_DESTROYED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Cannot discard item that the skill is consuming
|
||||
if (activeChar.isCastingSimultaneouslyNow())
|
||||
{
|
||||
if ((activeChar.getLastSimultaneousSkillCast() != null) && (activeChar.getLastSimultaneousSkillCast().getItemConsumeId() == itemToRemove.getId()))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_ITEM_CANNOT_BE_DESTROYED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final int itemId = itemToRemove.getId();
|
||||
|
||||
if ((!activeChar.canOverrideCond(PcCondOverride.DESTROY_ALL_ITEMS) && !itemToRemove.isDestroyable()) || CursedWeaponsManager.getInstance().isCursed(itemId))
|
||||
{
|
||||
if (itemToRemove.isHeroItem())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.HERO_WEAPONS_CANNOT_BE_DESTROYED);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_ITEM_CANNOT_BE_DESTROYED);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!itemToRemove.isStackable() && (count > 1))
|
||||
{
|
||||
Util.handleIllegalPlayerAction(activeChar, "[RequestDestroyItem] Character " + activeChar.getName() + " of account " + activeChar.getAccountName() + " tried to destroy a non-stackable item with oid " + _objectId + " but has count > 1!", Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!activeChar.getInventory().canManipulateWithItemId(itemToRemove.getId()))
|
||||
{
|
||||
activeChar.sendMessage("You cannot use this item.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_count > itemToRemove.getCount())
|
||||
{
|
||||
count = itemToRemove.getCount();
|
||||
}
|
||||
|
||||
if (itemToRemove.getItem().isPetItem())
|
||||
{
|
||||
final L2Summon pet = activeChar.getPet();
|
||||
if ((pet != null) && (pet.getControlObjectId() == _objectId))
|
||||
{
|
||||
pet.unSummon(activeChar);
|
||||
}
|
||||
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("DELETE FROM pets WHERE item_obj_id=?"))
|
||||
{
|
||||
statement.setInt(1, _objectId);
|
||||
statement.execute();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "could not delete pet objectid: ", e);
|
||||
}
|
||||
}
|
||||
if (itemToRemove.isTimeLimitedItem())
|
||||
{
|
||||
itemToRemove.endOfLife();
|
||||
}
|
||||
|
||||
if (itemToRemove.isEquipped())
|
||||
{
|
||||
if (itemToRemove.getEnchantLevel() > 0)
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.THE_EQUIPMENT_S1_S2_HAS_BEEN_REMOVED);
|
||||
sm.addInt(itemToRemove.getEnchantLevel());
|
||||
sm.addItemName(itemToRemove);
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
else
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED);
|
||||
sm.addItemName(itemToRemove);
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
|
||||
final L2ItemInstance[] unequiped = activeChar.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot());
|
||||
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
for (L2ItemInstance itm : unequiped)
|
||||
{
|
||||
iu.addModifiedItem(itm);
|
||||
}
|
||||
activeChar.sendPacket(iu);
|
||||
}
|
||||
|
||||
final L2ItemInstance removedItem = activeChar.getInventory().destroyItem("Destroy", itemToRemove, count, activeChar, null);
|
||||
|
||||
if (removedItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Config.FORCE_INVENTORY_UPDATE)
|
||||
{
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
if (removedItem.getCount() == 0)
|
||||
{
|
||||
iu.addRemovedItem(removedItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
iu.addModifiedItem(removedItem);
|
||||
}
|
||||
activeChar.sendPacket(iu);
|
||||
}
|
||||
else
|
||||
{
|
||||
sendPacket(new ItemList(activeChar, true));
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new ExUserInfoInvenWeight(activeChar));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__60_REQUESTDESTROYITEM;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.3.2.1.2.3 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public final class RequestDismissAlly extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__90_REQUESTDISMISSALLY = "[C] 90 RequestDismissAlly";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
// trigger packet
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!activeChar.isClanLeader())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_FEATURE_IS_ONLY_AVAILABLE_TO_ALLIANCE_LEADERS);
|
||||
return;
|
||||
}
|
||||
activeChar.getClan().dissolveAlly(activeChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__90_REQUESTDISMISSALLY;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.gameserver.model.PartyMatchRoom;
|
||||
import com.l2jmobius.gameserver.model.PartyMatchRoomList;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* @author Gnacik
|
||||
*/
|
||||
public class RequestDismissPartyRoom extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_0A_REQUESTDISMISSPARTYROOM = "[C] D0:0A RequestDismissPartyRoom";
|
||||
|
||||
private int _roomid;
|
||||
@SuppressWarnings("unused")
|
||||
private int _data2;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_roomid = readD();
|
||||
_data2 = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance _activeChar = getClient().getActiveChar();
|
||||
|
||||
if (_activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final PartyMatchRoom _room = PartyMatchRoomList.getInstance().getRoom(_roomid);
|
||||
|
||||
if (_room == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PartyMatchRoomList.getInstance().deleteRoom(_roomid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_0A_REQUESTDISMISSPARTYROOM;
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user