actual freya branch

This commit is contained in:
2026-09-12 15:41:31 +00:00
parent 8049e0a882
commit 68c1cd27d4
3510 changed files with 336689 additions and 302906 deletions
@@ -0,0 +1,67 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network;
import com.l2jserver.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)];
}
}
@@ -0,0 +1,243 @@
/*
* 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.l2jserver.gameserver.network;
import com.l2jserver.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;
}
/**
* Returns true if incoming packet need to be dropped
*/
protected final boolean dropPacket()
{
final boolean result = _floodDetected || _queueOverflowDetected;
if (result)
{
droppedPackets++;
}
return result;
}
/**
* Returns true if flood detected first and ActionFailed packet need to be sent. Later during flood returns true (and send ActionFailed) once per second.
*/
protected final boolean countPacket(int queueSize)
{
processedPackets++;
totalQueueSize += queueSize;
if (maxQueueSize < queueSize)
{
maxQueueSize = queueSize;
}
if (_queueOverflowDetected && (queueSize < 2))
{
_queueOverflowDetected = false;
}
return countPacket();
}
/**
* 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;
}
/**
* Counts burst length and return true if execution of the queue need to be aborted.
* @param count - current number of processed packets in burst
*/
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;
}
/**
* 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;
}
/**
* 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;
}
/**
* Returns 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;
}
/**
* Returns true if flood detected first and ActionFailed packet need to be sent. Later during flood returns true (and send ActionFailed) once per second.
*/
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,88 @@
/*
* 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.l2jserver.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++)
{
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++)
{
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);
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,406 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import gnu.trove.TIntObjectHashMap;
import java.util.Arrays;
import com.l2jserver.Config;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.templates.item.L2Item;
import com.l2jserver.gameserver.templates.item.L2WeaponType;
public abstract class AbstractEnchantPacket extends L2GameClientPacket
{
public static final TIntObjectHashMap<EnchantScroll> _scrolls = new TIntObjectHashMap<>();
public static final TIntObjectHashMap<EnchantItem> _supports = new TIntObjectHashMap<>();
public static class EnchantItem
{
protected final boolean _isWeapon;
protected final int _grade;
protected final int _maxEnchantLevel;
protected final int _chanceAdd;
protected final int[] _itemIds;
public EnchantItem(boolean wep, int type, int level, int chance, int[] items)
{
_isWeapon = wep;
_grade = type;
_maxEnchantLevel = level;
_chanceAdd = chance;
_itemIds = items;
}
/*
* Return true if support item can be used for this item
*/
public final boolean isValid(L2ItemInstance enchantItem)
{
if (enchantItem == null)
{
return false;
}
int type2 = enchantItem.getItem().getType2();
// checking scroll type and configured maximum enchant level
switch (type2)
{
// weapon scrolls can enchant only weapons
case L2Item.TYPE2_WEAPON:
if (!_isWeapon || ((Config.ENCHANT_MAX_WEAPON > 0) && (enchantItem.getEnchantLevel() >= Config.ENCHANT_MAX_WEAPON)))
{
return false;
}
break;
// armor scrolls can enchant only accessory and armors
case L2Item.TYPE2_SHIELD_ARMOR:
if (_isWeapon || ((Config.ENCHANT_MAX_ARMOR > 0) && (enchantItem.getEnchantLevel() >= Config.ENCHANT_MAX_ARMOR)))
{
return false;
}
break;
case L2Item.TYPE2_ACCESSORY:
if (_isWeapon || ((Config.ENCHANT_MAX_JEWELRY > 0) && (enchantItem.getEnchantLevel() >= Config.ENCHANT_MAX_JEWELRY)))
{
return false;
}
break;
default:
return false;
}
// check for crystal types
if (_grade != enchantItem.getItem().getItemGradeSPlus())
{
return false;
}
// check for maximum enchant level
if ((_maxEnchantLevel != 0) && (enchantItem.getEnchantLevel() >= _maxEnchantLevel))
{
return false;
}
if ((_itemIds != null) && (Arrays.binarySearch(_itemIds, enchantItem.getItemId()) < 0))
{
return false;
}
return true;
}
/*
* return chance increase
*/
public final int getChanceAdd()
{
return _chanceAdd;
}
}
public static final class EnchantScroll extends EnchantItem
{
private final boolean _isBlessed;
private final boolean _isCrystal;
private final boolean _isSafe;
public EnchantScroll(boolean wep, boolean bless, boolean crystal, boolean safe, int type, int level, int chance, int[] items)
{
super(wep, type, level, chance, items);
_isBlessed = bless;
_isCrystal = crystal;
_isSafe = safe;
}
/*
* Return true for blessed scrolls
*/
public final boolean isBlessed()
{
return _isBlessed;
}
/*
* Return true for crystal scrolls
*/
public final boolean isCrystal()
{
return _isCrystal;
}
/*
* Return true for safe-enchant scrolls (enchant level will remain on failure)
*/
public final boolean isSafe()
{
return _isSafe;
}
public final boolean isValid(L2ItemInstance enchantItem, EnchantItem supportItem)
{
// blessed scrolls can't use support items
if ((supportItem != null) && (!supportItem.isValid(enchantItem) || isBlessed()))
{
return false;
}
return isValid(enchantItem);
}
public final int getChance(L2ItemInstance enchantItem, EnchantItem supportItem)
{
if (!isValid(enchantItem, supportItem))
{
return -1;
}
boolean fullBody = enchantItem.getItem().getBodyPart() == L2Item.SLOT_FULL_ARMOR;
if ((enchantItem.getEnchantLevel() < Config.ENCHANT_SAFE_MAX) || (fullBody && (enchantItem.getEnchantLevel() < Config.ENCHANT_SAFE_MAX_FULL)))
{
return 100;
}
boolean isAccessory = enchantItem.getItem().getType2() == L2Item.TYPE2_ACCESSORY;
int chance = 0;
if (_isBlessed)
{
// blessed scrolls does not use support items
if (supportItem != null)
{
return -1;
}
if (_isWeapon)
{
chance = Config.BLESSED_ENCHANT_CHANCE_WEAPON;
}
else if (isAccessory)
{
chance = Config.BLESSED_ENCHANT_CHANCE_JEWELRY;
}
else
{
chance = Config.BLESSED_ENCHANT_CHANCE_ARMOR;
}
}
else
{
if (_isWeapon)
{
chance = Config.ENCHANT_CHANCE_WEAPON;
}
else if (isAccessory)
{
chance = Config.ENCHANT_CHANCE_JEWELRY;
}
else
{
chance = Config.ENCHANT_CHANCE_ARMOR;
}
}
chance += _chanceAdd;
if (supportItem != null)
{
chance += supportItem.getChanceAdd();
}
return chance;
}
}
static
{
// itemId, (isWeapon, isBlessed, isCrystal, isSafe, grade, max enchant level, chance increase, allowed item IDs)
// allowed items IDs must be sorted by ascending order
// Scrolls: Enchant Weapon
_scrolls.put(729, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_A, 0, 0, null));
_scrolls.put(947, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_B, 0, 0, null));
_scrolls.put(951, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_C, 0, 0, null));
_scrolls.put(955, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_D, 0, 0, null));
_scrolls.put(959, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_S, 0, 0, null));
// Scrolls: Enchant Armor
_scrolls.put(730, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_A, 0, 0, null));
_scrolls.put(948, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_B, 0, 0, null));
_scrolls.put(952, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_C, 0, 0, null));
_scrolls.put(956, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_D, 0, 0, null));
_scrolls.put(960, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_S, 0, 0, null));
// Blessed Scrolls: Enchant Weapon
_scrolls.put(6569, new EnchantScroll(true, true, false, false, L2Item.CRYSTAL_A, 0, 0, null));
_scrolls.put(6571, new EnchantScroll(true, true, false, false, L2Item.CRYSTAL_B, 0, 0, null));
_scrolls.put(6573, new EnchantScroll(true, true, false, false, L2Item.CRYSTAL_C, 0, 0, null));
_scrolls.put(6575, new EnchantScroll(true, true, false, false, L2Item.CRYSTAL_D, 0, 0, null));
_scrolls.put(6577, new EnchantScroll(true, true, false, false, L2Item.CRYSTAL_S, 0, 0, null));
// Blessed Scrolls: Enchant Armor
_scrolls.put(6570, new EnchantScroll(false, true, false, false, L2Item.CRYSTAL_A, 0, 0, null));
_scrolls.put(6572, new EnchantScroll(false, true, false, false, L2Item.CRYSTAL_B, 0, 0, null));
_scrolls.put(6574, new EnchantScroll(false, true, false, false, L2Item.CRYSTAL_C, 0, 0, null));
_scrolls.put(6576, new EnchantScroll(false, true, false, false, L2Item.CRYSTAL_D, 0, 0, null));
_scrolls.put(6578, new EnchantScroll(false, true, false, false, L2Item.CRYSTAL_S, 0, 0, null));
// Crystal Scrolls: Enchant Weapon
_scrolls.put(731, new EnchantScroll(true, false, true, false, L2Item.CRYSTAL_A, 0, 0, null));
_scrolls.put(949, new EnchantScroll(true, false, true, false, L2Item.CRYSTAL_B, 0, 0, null));
_scrolls.put(953, new EnchantScroll(true, false, true, false, L2Item.CRYSTAL_C, 0, 0, null));
_scrolls.put(957, new EnchantScroll(true, false, true, false, L2Item.CRYSTAL_D, 0, 0, null));
_scrolls.put(961, new EnchantScroll(true, false, true, false, L2Item.CRYSTAL_S, 0, 0, null));
// Crystal Scrolls: Enchant Armor
_scrolls.put(732, new EnchantScroll(false, false, true, false, L2Item.CRYSTAL_A, 0, 0, null));
_scrolls.put(950, new EnchantScroll(false, false, true, false, L2Item.CRYSTAL_B, 0, 0, null));
_scrolls.put(954, new EnchantScroll(false, false, true, false, L2Item.CRYSTAL_C, 0, 0, null));
_scrolls.put(958, new EnchantScroll(false, false, true, false, L2Item.CRYSTAL_D, 0, 0, null));
_scrolls.put(962, new EnchantScroll(false, false, true, false, L2Item.CRYSTAL_S, 0, 0, null));
// Weapon Enchant Scrolls
_scrolls.put(20517, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_S, 0, 10, null));
_scrolls.put(22006, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_D, 0, 10, null));
_scrolls.put(22007, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_C, 0, 10, null));
_scrolls.put(22008, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_B, 0, 10, null));
_scrolls.put(22009, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_A, 0, 10, null));
// Armor Enchant Scrolls
_scrolls.put(20518, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_S, 0, 10, null));
_scrolls.put(22010, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_D, 0, 10, null));
_scrolls.put(22011, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_C, 0, 10, null));
_scrolls.put(22012, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_B, 0, 10, null));
_scrolls.put(22013, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_A, 0, 10, null));
// Ancient Weapon Enchant Crystal
_scrolls.put(20519, new EnchantScroll(true, false, false, true, L2Item.CRYSTAL_S, 16, 10, null));
_scrolls.put(22014, new EnchantScroll(true, false, false, true, L2Item.CRYSTAL_B, 16, 10, null));
_scrolls.put(22015, new EnchantScroll(true, false, false, true, L2Item.CRYSTAL_A, 16, 10, null));
// Ancient Armor Enchant Crystal
_scrolls.put(20520, new EnchantScroll(false, false, false, true, L2Item.CRYSTAL_S, 16, 10, null));
_scrolls.put(22016, new EnchantScroll(false, false, false, true, L2Item.CRYSTAL_B, 16, 10, null));
_scrolls.put(22017, new EnchantScroll(false, false, false, true, L2Item.CRYSTAL_A, 16, 10, null));
// Divine Weapon Enchant Crystal
_scrolls.put(20521, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_S, 0, 100, null));
_scrolls.put(22018, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_B, 0, 100, null));
_scrolls.put(22019, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_A, 0, 100, null));
// Divine Armor Enchant Crystal
_scrolls.put(20522, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_S, 0, 100, null));
_scrolls.put(22020, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_B, 0, 100, null));
_scrolls.put(22021, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_A, 0, 100, null));
// Master Yogi's Scroll Enchant Weapon (event)
_scrolls.put(13540, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_NONE, 0, 0, new int[]
{
13539
}));
// itemId, (isWeapon, grade, max enchant level, chance increase)
_supports.put(12362, new EnchantItem(true, L2Item.CRYSTAL_D, 9, 20, null));
_supports.put(12363, new EnchantItem(true, L2Item.CRYSTAL_C, 9, 18, null));
_supports.put(12364, new EnchantItem(true, L2Item.CRYSTAL_B, 9, 15, null));
_supports.put(12365, new EnchantItem(true, L2Item.CRYSTAL_A, 9, 12, null));
_supports.put(12366, new EnchantItem(true, L2Item.CRYSTAL_S, 9, 10, null));
_supports.put(12367, new EnchantItem(false, L2Item.CRYSTAL_D, 9, 35, null));
_supports.put(12368, new EnchantItem(false, L2Item.CRYSTAL_C, 9, 27, null));
_supports.put(12369, new EnchantItem(false, L2Item.CRYSTAL_B, 9, 23, null));
_supports.put(12370, new EnchantItem(false, L2Item.CRYSTAL_A, 9, 18, null));
_supports.put(12371, new EnchantItem(false, L2Item.CRYSTAL_S, 9, 15, null));
_supports.put(14702, new EnchantItem(true, L2Item.CRYSTAL_D, 9, 20, null));
_supports.put(14703, new EnchantItem(true, L2Item.CRYSTAL_C, 9, 18, null));
_supports.put(14704, new EnchantItem(true, L2Item.CRYSTAL_B, 9, 15, null));
_supports.put(14705, new EnchantItem(true, L2Item.CRYSTAL_A, 9, 12, null));
_supports.put(14706, new EnchantItem(true, L2Item.CRYSTAL_S, 9, 10, null));
_supports.put(14707, new EnchantItem(false, L2Item.CRYSTAL_D, 9, 35, null));
_supports.put(14708, new EnchantItem(false, L2Item.CRYSTAL_C, 9, 27, null));
_supports.put(14709, new EnchantItem(false, L2Item.CRYSTAL_B, 9, 23, null));
_supports.put(14710, new EnchantItem(false, L2Item.CRYSTAL_A, 9, 18, null));
_supports.put(14711, new EnchantItem(false, L2Item.CRYSTAL_S, 9, 15, null));
}
/**
* Return enchant template for scroll
*/
protected static final EnchantScroll getEnchantScroll(L2ItemInstance scroll)
{
return _scrolls.get(scroll.getItemId());
}
/**
* Return enchant template for support item
*/
protected static final EnchantItem getSupportItem(L2ItemInstance item)
{
return _supports.get(item.getItemId());
}
/**
* Return true if item can be enchanted
*/
protected static final boolean isEnchantable(L2ItemInstance item)
{
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;
}
// rods
if (item.getItem().getItemType() == L2WeaponType.FISHINGROD)
{
return false;
}
// bracelets
if (item.getItem().getBodyPart() == L2Item.SLOT_L_BRACELET)
{
return false;
}
if (item.getItem().getBodyPart() == L2Item.SLOT_R_BRACELET)
{
return false;
}
if (item.getItem().getBodyPart() == L2Item.SLOT_BACK)
{
return false;
}
// blacklist check
if (Arrays.binarySearch(Config.ENCHANT_BLACKLIST, item.getItemId()) >= 0)
{
return false;
}
// only items in inventory and equipped can be enchanted
if ((item.getLocation() != L2ItemInstance.ItemLocation.INVENTORY) && (item.getLocation() != L2ItemInstance.ItemLocation.PAPERDOLL))
{
return false;
}
return true;
}
}
@@ -0,0 +1,490 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.util.Arrays;
import java.util.Map;
import javolution.util.FastMap;
import com.l2jserver.Config;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.templates.item.L2Armor;
import com.l2jserver.gameserver.templates.item.L2Item;
import com.l2jserver.gameserver.templates.item.L2Weapon;
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;
private static final Map<Integer, LifeStone> _lifeStones = new FastMap<>();
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
};
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));
}
protected static final LifeStone getLifeStone(int itemId)
{
return _lifeStones.get(itemId);
}
/*
* Checks player, source item, lifestone and gemstone validity for augmentation process
*/
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.getLocation() != L2ItemInstance.ItemLocation.INVENTORY)
{
return false;
}
final int grade = item.getItem().getItemGrade();
final LifeStone ls = getLifeStone(refinerItem.getItemId());
// Check for item id
if (getGemStoneId(grade) != gemStones.getItemId())
{
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
*/
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.getLocation() != L2ItemInstance.ItemLocation.INVENTORY)
{
return false;
}
final LifeStone ls = getLifeStone(refinerItem.getItemId());
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
*/
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())
{
return false;
}
if (item.getItem().getCrystalType() < L2Item.CRYSTAL_C)
{
return false;
}
// Source item can be equipped or in inventory
switch (item.getLocation())
{
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.getItemId()) >= 0)
{
return false;
}
return true;
}
/*
* Check if player's conditions valid for augmentation process
*/
protected static final boolean isValid(L2PcInstance player)
{
if (player.getPrivateStoreType() != L2PcInstance.STORE_PRIVATE_NONE)
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_CANNOT_AUGMENT_ITEMS_WHILE_A_PRIVATE_STORE_OR_PRIVATE_WORKSHOP_IS_IN_OPERATION));
return false;
}
if (player.getActiveTradeList() != null)
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_CANNOT_AUGMENT_ITEMS_WHILE_TRADING));
return false;
}
if (player.isDead())
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_CANNOT_AUGMENT_ITEMS_WHILE_DEAD));
return false;
}
if (player.isParalyzed())
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_CANNOT_AUGMENT_ITEMS_WHILE_PARALYZED));
return false;
}
if (player.isFishing())
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_CANNOT_AUGMENT_ITEMS_WHILE_FISHING));
return false;
}
if (player.isSitting())
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_CANNOT_AUGMENT_ITEMS_WHILE_SITTING_DOWN));
return false;
}
if (player.isCursedWeaponEquipped())
{
return false;
}
if (player.isEnchanting() || player.isProcessingTransaction())
{
return false;
}
return true;
}
/*
* Returns GemStone itemId based on item grade
*/
protected static final int getGemStoneId(int itemGrade)
{
switch (itemGrade)
{
case L2Item.CRYSTAL_C:
case L2Item.CRYSTAL_B:
return GEMSTONE_D;
case L2Item.CRYSTAL_A:
case L2Item.CRYSTAL_S:
return GEMSTONE_C;
case L2Item.CRYSTAL_S80:
case L2Item.CRYSTAL_S84:
return GEMSTONE_B;
default:
return 0;
}
}
/*
* Returns GemStone count based on item grade and lifestone grade (different for weapon and accessory augmentation)
*/
protected static final int getGemStoneCount(int itemGrade, int lifeStoneGrade)
{
switch (lifeStoneGrade)
{
case GRADE_ACC:
switch (itemGrade)
{
case L2Item.CRYSTAL_C:
return 200;
case L2Item.CRYSTAL_B:
return 300;
case L2Item.CRYSTAL_A:
return 200;
case L2Item.CRYSTAL_S:
return 250;
case L2Item.CRYSTAL_S80:
return 360;
case L2Item.CRYSTAL_S84:
return 480;
default:
return 0;
}
default:
switch (itemGrade)
{
case L2Item.CRYSTAL_C:
return 20;
case L2Item.CRYSTAL_B:
return 30;
case L2Item.CRYSTAL_A:
return 20;
case L2Item.CRYSTAL_S:
return 25;
case L2Item.CRYSTAL_S80:
case L2Item.CRYSTAL_S84:
return 36;
default:
return 0;
}
}
}
}
@@ -0,0 +1,164 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* This class ...
* @version $Revision: 1.7.4.4 $ $Date: 2005/03/27 18:46:19 $
*/
public final class Action extends L2GameClientPacket
{
private static final String ACTION__C__04 = "[C] 04 Action";
private static final Logger _log = Logger.getLogger(Action.class.getName());
// cddddc
private int _objectId;
@SuppressWarnings("unused")
private int _originX;
@SuppressWarnings("unused")
private int _originY;
@SuppressWarnings("unused")
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.fine("Action:" + _actionId);
}
if (Config.DEBUG)
{
_log.fine("oid:" + _objectId);
}
// Get the current L2PcInstance of the player
final L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
if (activeChar.inObserverMode())
{
getClient().sendPacket(SystemMessage.getSystemMessage(SystemMessageId.OBSERVERS_CANNOT_PARTICIPATE));
getClient().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
// _log.warning("Character: " + activeChar.getName() + " request action with non existent ObjectID:" + _objectId);
getClient().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))
{
getClient().sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Only GMs can directly interact with invisible characters
if ((obj instanceof L2PcInstance) && (((L2PcInstance) obj).getAppearance().getInvisible()) && !activeChar.isGM())
{
getClient().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)
{
switch (_actionId)
{
case 0:
obj.onAction(activeChar);
break;
case 1:
if (!activeChar.isGM() && !((obj instanceof L2Npc) && Config.ALT_GAME_VIEWNPC))
{
obj.onAction(activeChar, false);
}
else
{
obj.onActionShift(activeChar);
}
break;
default:
// Ivalid action detected (probably client cheating), log this
_log.warning("Character: " + activeChar.getName() + " requested invalid action: " + _actionId);
getClient().sendPacket(ActionFailed.STATIC_PACKET);
break;
}
}
else
{
// Actions prohibited when in trade
getClient().sendPacket(ActionFailed.STATIC_PACKET);
}
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return ACTION__C__04;
}
}
@@ -0,0 +1,118 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.util.logging.Logger;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.TradeList;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.network.serverpackets.TradeOtherAdd;
import com.l2jserver.gameserver.network.serverpackets.TradeOwnAdd;
/**
* 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__16_ADDTRADEITEM = "[C] 16 AddTradeItem";
private static final Logger _log = Logger.getLogger(AddTradeItem.class.getName());
private int _tradeId;
private int _objectId;
private long _count;
public AddTradeItem()
{
}
@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);
}
SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.TARGET_IS_NOT_FOUND_IN_THE_GAME);
player.sendPacket(msg);
player.cancelActiveTrade();
return;
}
if (trade.isConfirmed() || partner.getActiveTradeList().isConfirmed())
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_ADJUST_ITEMS_AFTER_TRADE_CONFIRMED));
return;
}
if (!player.getAccessLevel().allowTransaction())
{
player.sendMessage("Transactions are disable for your Access Level");
player.cancelActiveTrade();
return;
}
if (!player.validateItemManipulation(_objectId, "trade"))
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOTHING_HAPPENED));
return;
}
final TradeList.TradeItem item = trade.addItem(_objectId, _count);
if (item != null)
{
player.sendPacket(new TradeOwnAdd(item));
trade.getPartner().sendPacket(new TradeOtherAdd(item));
}
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__16_ADDTRADEITEM;
}
}
@@ -0,0 +1,103 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.ClanTable;
import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.communityserver.CommunityServerThread;
import com.l2jserver.gameserver.network.communityserver.writepackets.WorldInfo;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
public final class AllyDismiss extends L2GameClientPacket
{
private static final String _C__85_ALLYDISMISS = "[C] 85 AllyDismiss";
private String _clanName;
@Override
protected void readImpl()
{
_clanName = readS();
}
@Override
protected void runImpl()
{
if (_clanName == null)
{
return;
}
L2PcInstance player = getClient().getActiveChar();
if (player == null)
{
return;
}
if (player.getClan() == null)
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_ARE_NOT_A_CLAN_MEMBER));
return;
}
L2Clan leaderClan = player.getClan();
if (leaderClan.getAllyId() == 0)
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NO_CURRENT_ALLIANCES));
return;
}
if (!player.isClanLeader() || (leaderClan.getClanId() != leaderClan.getAllyId()))
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.FEATURE_ONLY_FOR_ALLIANCE_LEADER));
return;
}
L2Clan clan = ClanTable.getInstance().getClanByName(_clanName);
if (clan == null)
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CLAN_DOESNT_EXISTS));
return;
}
if (clan.getClanId() == leaderClan.getClanId())
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ALLIANCE_LEADER_CANT_WITHDRAW));
return;
}
if (clan.getAllyId() != leaderClan.getAllyId())
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.DIFFERENT_ALLIANCE));
return;
}
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();
// notify CB server about the change
CommunityServerThread.getInstance().sendPacket(new WorldInfo(null, clan, WorldInfo.TYPE_UPDATE_CLAN_DATA));
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EXPELED_A_CLAN));
}
@Override
public String getType()
{
return _C__85_ALLYDISMISS;
}
}
@@ -0,0 +1,83 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.Config;
import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.communityserver.CommunityServerThread;
import com.l2jserver.gameserver.network.communityserver.writepackets.WorldInfo;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
public final class AllyLeave extends L2GameClientPacket
{
private static final String _C__84_ALLYLEAVE = "[C] 84 AllyLeave";
// private static Logger _log = Logger.getLogger(AllyLeave.class.getName());
@Override
protected void readImpl()
{
}
@Override
protected void runImpl()
{
L2PcInstance player = getClient().getActiveChar();
if (player == null)
{
return;
}
if (player.getClan() == null)
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_ARE_NOT_A_CLAN_MEMBER));
return;
}
if (!player.isClanLeader())
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ONLY_CLAN_LEADER_WITHDRAW_ALLY));
return;
}
L2Clan clan = player.getClan();
if (clan.getAllyId() == 0)
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NO_CURRENT_ALLIANCES));
return;
}
if (clan.getClanId() == clan.getAllyId())
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ALLIANCE_LEADER_CANT_WITHDRAW));
return;
}
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();
// notify CB server about the change
CommunityServerThread.getInstance().sendPacket(new WorldInfo(null, clan, WorldInfo.TYPE_UPDATE_CLAN_DATA));
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_WITHDRAWN_FROM_ALLIANCE));
}
@Override
public String getType()
{
return _C__84_ALLYLEAVE;
}
}
@@ -0,0 +1,94 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ExRotation;
import com.l2jserver.gameserver.network.serverpackets.SocialAction;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.util.Util;
/**
* @author JIV
*/
public class AnswerCoupleAction extends L2GameClientPacket
{
private static final String _S__3D_SOCIALACTION = "[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()
{
L2PcInstance activeChar = getClient().getActiveChar();
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.setMultiSocialAction(0, 0);
target.sendPacket(SystemMessageId.COUPLE_ACTION_DENIED);
}
else if (_answer == 1) // approve
{
double distance = activeChar.getPlanDistanceSq(target);
if ((distance > 2000) || (distance < 70))
{
activeChar.sendPacket(SystemMessageId.TARGET_DO_NOT_MEET_LOC_REQUIREMENTS);
target.sendPacket(SystemMessageId.TARGET_DO_NOT_MEET_LOC_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, _actionId));
target.broadcastPacket(new SocialAction(target, _actionId));
}
else if (_answer == -1) // refused
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_SET_TO_REFUSE_COUPLE_ACTIONS);
sm.addPcName(activeChar);
target.sendPacket(sm);
}
}
@Override
public String getType()
{
return _S__3D_SOCIALACTION;
}
}
@@ -0,0 +1,52 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
/**
* Format: (ch) d
* @author -Wooden-
*/
public final class AnswerJoinPartyRoom extends L2GameClientPacket
{
private static final String _C__D0_15_ANSWERJOINPARTYROOM = "[C] D0:15 AnswerJoinPartyRoom";
@SuppressWarnings("unused")
private int _requesterID; // not tested, just guessed
@Override
protected void readImpl()
{
_requesterID = readD();
}
/**
* @see com.l2jserver.util.network.BaseRecievePacket.ClientBasePacket#runImpl()
*/
@Override
protected void runImpl()
{
// TODO
// _log.info("C5:AnswerJoinPartyRoom: d: "+_requesterID);
}
/**
* @see com.l2jserver.gameserver.BasePacket#getType()
*/
@Override
public String getType()
{
return _C__D0_15_ANSWERJOINPARTYROOM;
}
}
@@ -0,0 +1,56 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.model.L2Party;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
/**
* @author JIV
*/
public class AnswerPartyLootModification extends L2GameClientPacket
{
private static final String TYPE = "[C] D0:79 AnswerPartyLootModification";
public int _answer;
@Override
protected void readImpl()
{
_answer = readD();
}
@Override
protected void runImpl()
{
L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
L2Party party = activeChar.getParty();
if (party != null)
{
party.answerLootChangeRequest(activeChar, _answer == 1);
}
}
@Override
public String getType()
{
return TYPE;
}
}
@@ -0,0 +1,105 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.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__40_ANSWERTRADEREQUEST = "[C] 40 AnswerTradeRequest";
// private static Logger _log = Logger.getLogger(AnswerTradeRequest.class.getName());
private int _response;
@Override
protected void readImpl()
{
_response = readD();
}
@Override
protected void runImpl()
{
L2PcInstance player = getClient().getActiveChar();
if (player == null)
{
return;
}
if (!player.getAccessLevel().allowTransaction())
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT));
sendPacket(ActionFailed.STATIC_PACKET);
return;
}
L2PcInstance partner = player.getActiveRequester();
if (partner == null)
{
// Trade partner not found, cancel trade
player.sendPacket(new TradeDone(0));
SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.TARGET_IS_NOT_FOUND_IN_THE_GAME);
player.sendPacket(msg);
player.setActiveRequester(null);
msg = null;
return;
}
else if (L2World.getInstance().getPlayer(partner.getObjectId()) == null)
{
// Trade partner not found, cancel trade
player.sendPacket(new TradeDone(0));
SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.TARGET_IS_NOT_FOUND_IN_THE_GAME);
player.sendPacket(msg);
player.setActiveRequester(null);
msg = null;
return;
}
if ((_response == 1) && !partner.isRequestExpired())
{
player.startTrade(partner);
}
else
{
SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.C1_DENIED_TRADE_REQUEST);
msg.addString(player.getName());
partner.sendPacket(msg);
msg = null;
}
// Clears requesting status
player.setActiveRequester(null);
partner.onTransactionResponse();
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__40_ANSWERTRADEREQUEST;
}
}
@@ -0,0 +1,72 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.ExBrExtraUserInfo;
import com.l2jserver.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__30_APPEARING = "[C] 30 Appearing";
@Override
protected void readImpl()
{
}
@Override
protected void runImpl()
{
L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
if (activeChar.isTeleporting())
{
activeChar.onTeleported();
}
sendPacket(new UserInfo(activeChar));
sendPacket(new ExBrExtraUserInfo(activeChar));
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__30_APPEARING;
}
@Override
protected boolean triggersOnActionRequest()
{
return false;
}
}
@@ -0,0 +1,115 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
/**
* This class ...
* @version $Revision: 1.7.2.1.2.2 $ $Date: 2005/03/27 15:29:30 $
*/
public final class AttackRequest extends L2GameClientPacket
{
// cddddc
private int _objectId;
@SuppressWarnings("unused")
private int _originX;
@SuppressWarnings("unused")
private int _originY;
@SuppressWarnings("unused")
private int _originZ;
@SuppressWarnings("unused")
private int _attackId;
private static final String _C__0A_ATTACKREQUEST = "[C] 0A AttackRequest";
@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 = getClient().getActiveChar();
if (activeChar == null)
{
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;
}
// Players can't attack objects in the other instances
// except from multiverse
if ((target.getInstanceId() != activeChar.getInstanceId()) && (activeChar.getInstanceId() != -1))
{
return;
}
// Only GMs can directly attack invisible characters
if ((target instanceof L2PcInstance) && ((L2PcInstance) target).getAppearance().getInvisible() && !activeChar.isGM())
{
return;
}
if (activeChar.getTarget() != target)
{
target.onAction(activeChar);
}
else
{
if ((target.getObjectId() != activeChar.getObjectId()) && (activeChar.getPrivateStoreType() == 0) && (activeChar.getActiveRequester() == null))
{
// _log.debug("Starting ForcedAttack");
target.onForcedAttack(activeChar);
// _log.debug("Ending ForcedAttack");
}
else
{
sendPacket(ActionFailed.STATIC_PACKET);
}
}
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__0A_ATTACKREQUEST;
}
}
@@ -0,0 +1,91 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.LoginServerThread;
import com.l2jserver.gameserver.LoginServerThread.SessionKey;
import com.l2jserver.gameserver.network.L2GameClient;
import com.l2jserver.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__08_AUTHLOGIN = "[C] 08 AuthLogin";
private static Logger _log = Logger.getLogger(AuthLogin.class.getName());
// 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;
/**
* @param decrypt
*/
@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.length() == 0) || !client.isProtocolOk())
{
client.close((L2GameServerPacket) null);
return;
}
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)
{
client.setAccountName(_loginName);
LoginServerThread.getInstance().addGameServerLogin(_loginName, client);
LoginServerThread.getInstance().addWaitingClientAndSendRequest(_loginName, client, key);
}
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__08_AUTHLOGIN;
}
}
@@ -0,0 +1,65 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.network.serverpackets.ExBrLoadEventTopRankers;
/**
* Halloween rank list client packet. Format: (ch)ddd
*/
public class BrEventRankerList extends L2GameClientPacket
{
private int _eventId;
private int _day;
@SuppressWarnings("unused")
private int _ranking;
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#getType()
*/
@Override
public String getType()
{
return "[C] D0:7D BrEventRankerList";
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#readImpl()
*/
@Override
protected void readImpl()
{
_eventId = readD();
_day = readD(); // 0 - current, 1 - previous
_ranking = readD();
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#runImpl()
*/
@Override
protected void runImpl()
{
// TODO count, bestScore, myScore
int count = 0;
int bestScore = 0;
int myScore = 0;
getClient().sendPacket(new ExBrLoadEventTopRankers(_eventId, _day, count, bestScore, myScore));
}
}
@@ -0,0 +1,73 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.util.logging.Logger;
import com.l2jserver.gameserver.handler.IUserCommandHandler;
import com.l2jserver.gameserver.handler.UserCommandHandler;
import com.l2jserver.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";
static Logger _log = Logger.getLogger(BypassUserCmd.class.getName());
private int _command;
@Override
protected void readImpl()
{
_command = readD();
}
@Override
protected void runImpl()
{
L2PcInstance player = getClient().getActiveChar();
if (player == null)
{
return;
}
IUserCommandHandler handler = UserCommandHandler.getInstance().getUserCommandHandler(_command);
if (handler == null)
{
if (player.isGM())
{
player.sendMessage("User commandID " + _command + " not implemented yet.");
}
}
else
{
handler.useUserCommand(_command, getClient().getActiveChar());
}
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__B3_BYPASSUSERCMD;
}
}
@@ -0,0 +1,93 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.ai.CtrlEvent;
import com.l2jserver.gameserver.model.L2CharPosition;
import com.l2jserver.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__36_STOPMOVE = "[C] 36 CannotMoveAnymore";
private static Logger _log = Logger.getLogger(CannotMoveAnymore.class.getName());
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()
{
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 L2CharPosition(_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);
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__36_STOPMOVE;
}
}
@@ -0,0 +1,68 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.StopMoveInVehicle;
import com.l2jserver.util.Point3D;
/**
* @author Maktakien
*/
public final class CannotMoveAnymoreInVehicle extends L2GameClientPacket
{
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()
{
L2PcInstance player = getClient().getActiveChar();
if (player == null)
{
return;
}
if (player.isInBoat())
{
if (player.getBoat().getObjectId() == _boatId)
{
player.setInVehiclePosition(new Point3D(_x, _y, _z));
player.getPosition().setHeading(_heading);
StopMoveInVehicle msg = new StopMoveInVehicle(player, _boatId);
player.broadcastPacket(msg);
}
}
}
@Override
public String getType()
{
return "[C] 5D CannotMoveAnymoreInVehicle";
}
}
@@ -0,0 +1,358 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.CharNameTable;
import com.l2jserver.gameserver.datatables.CharTemplateTable;
import com.l2jserver.gameserver.datatables.SkillTable;
import com.l2jserver.gameserver.datatables.SkillTreesData;
import com.l2jserver.gameserver.idfactory.IdFactory;
import com.l2jserver.gameserver.instancemanager.QuestManager;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2ShortCut;
import com.l2jserver.gameserver.model.L2SkillLearn;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.actor.stat.PcStat;
import com.l2jserver.gameserver.model.quest.Quest;
import com.l2jserver.gameserver.model.quest.QuestState;
import com.l2jserver.gameserver.model.quest.State;
import com.l2jserver.gameserver.network.L2GameClient;
import com.l2jserver.gameserver.network.serverpackets.CharCreateFail;
import com.l2jserver.gameserver.network.serverpackets.CharCreateOk;
import com.l2jserver.gameserver.network.serverpackets.CharSelectionInfo;
import com.l2jserver.gameserver.templates.chars.L2PcTemplate;
import com.l2jserver.gameserver.templates.chars.L2PcTemplate.PcTemplateItem;
import com.l2jserver.gameserver.util.Util;
@SuppressWarnings("unused")
public final class CharacterCreate extends L2GameClientPacket
{
private static final String _C__0B_CHARACTERCREATE = "[C] 0B CharacterCreate";
private static final Logger _log = Logger.getLogger(CharacterCreate.class.getName());
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().accountCharNumber(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 = CharTemplateTable.getInstance().getTemplate(_classId);
if ((template == null) || (template.classBaseLevel > 1))
{
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;
}
int objectId = IdFactory.getInstance().getNextId();
newChar = L2PcInstance.create(objectId, template, getClient().getAccountName(), _name, _hairStyle, _hairColor, _face, _sex != 0);
}
newChar.setCurrentHp(template.baseHpMax);
newChar.setCurrentCp(template.baseCpMax);
newChar.setCurrentMp(template.baseMpMax);
// newChar.setMaxLoad(template.baseLoad);
CharCreateOk cco = new CharCreateOk();
sendPacket(cco);
initNewChar(getClient(), newChar);
LogRecord record = new LogRecord(Level.INFO, "Created new character");
record.setParameters(new Object[]
{
newChar,
getClient()
});
_logAccounting.log(record);
}
private boolean isValidName(String text)
{
boolean result = true;
String test = text;
Pattern pattern;
try
{
pattern = Pattern.compile(Config.CNAME_TEMPLATE);
}
catch (PatternSyntaxException e) // case of illegal pattern
{
_log.warning("ERROR : Character name pattern of config is wrong!");
pattern = Pattern.compile(".*");
}
Matcher regexp = pattern.matcher(test);
if (!regexp.matches())
{
result = false;
}
return result;
}
private void initNewChar(L2GameClient client, L2PcInstance newChar)
{
if (Config.DEBUG)
{
_log.fine("Character init start");
}
L2World.getInstance().storeObject(newChar);
L2PcTemplate template = newChar.getTemplate();
newChar.addAdena("Init", Config.STARTING_ADENA, null, false);
newChar.setXYZInvisible(template.spawnX, template.spawnY, template.spawnZ);
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);
}
L2ShortCut shortcut;
// add attack shortcut
shortcut = new L2ShortCut(0, 0, 3, 2, 0, 1);
newChar.registerShortCut(shortcut);
// add take shortcut
shortcut = new L2ShortCut(3, 0, 3, 5, 0, 1);
newChar.registerShortCut(shortcut);
// add sit shortcut
shortcut = new L2ShortCut(10, 0, 3, 0, 0, 1);
newChar.registerShortCut(shortcut);
for (PcTemplateItem ia : template.getItems())
{
L2ItemInstance item = newChar.getInventory().addItem("Init", ia.getItemId(), ia.getAmount(), newChar, null);
if (item == null)
{
_log.warning("Could not create item during char creation: itemId " + ia.getItemId() + ", amount " + ia.getAmount() + ".");
continue;
}
// add tutbook shortcut
if (item.getItemId() == 5588)
{
shortcut = new L2ShortCut(11, 0, 1, item.getObjectId(), 0, 1);
newChar.registerShortCut(shortcut);
}
if (item.isEquipable() && ia.isEquipped())
{
newChar.getInventory().equipItem(item);
}
}
for (L2SkillLearn skill : SkillTreesData.getInstance().getAvailableSkills(newChar, newChar.getClassId(), false, true))
{
newChar.addSkill(SkillTable.getInstance().getInfo(skill.getSkillId(), skill.getSkillLevel()), true);
if ((skill.getSkillId() == 1001) || (skill.getSkillId() == 1177))
{
shortcut = new L2ShortCut(1, 0, 2, skill.getSkillId(), skill.getSkillLevel(), 1);
newChar.registerShortCut(shortcut);
}
if (skill.getSkillId() == 1216)
{
shortcut = new L2ShortCut(10, 0, 2, skill.getSkillId(), skill.getSkillLevel(), 1);
newChar.registerShortCut(shortcut);
}
if (Config.DEBUG)
{
_log.fine("Adding starter skill:" + skill.getSkillId() + " / " + skill.getSkillLevel());
}
}
if (!Config.DISABLE_TUTORIAL)
{
startTutorialQuest(newChar);
}
newChar.setOnlineStatus(true, false);
newChar.deleteMe();
CharSelectionInfo cl = new CharSelectionInfo(client.getAccountName(), client.getSessionId().playOkID1);
client.getConnection().sendPacket(cl);
client.setCharSelection(cl.getCharInfo());
if (Config.DEBUG)
{
_log.fine("Character init end");
}
}
public void startTutorialQuest(L2PcInstance player)
{
QuestState qs = player.getQuestState("255_Tutorial");
Quest q = null;
if (qs == null)
{
q = QuestManager.getInstance().getQuest("255_Tutorial");
}
if (q != null)
{
q.newQuestState(player).setState(State.STARTED);
}
}
@Override
public String getType()
{
return _C__0B_CHARACTERCREATE;
}
}
@@ -0,0 +1,96 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.network.serverpackets.CharDeleteFail;
import com.l2jserver.gameserver.network.serverpackets.CharDeleteSuccess;
import com.l2jserver.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";
private static Logger _log = Logger.getLogger(CharacterDelete.class.getName());
// 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
{
byte answer = getClient().markToDeleteChar(_charSlot);
switch (answer)
{
default:
case -1: // Error
break;
case 0: // Success!
sendPacket(new CharDeleteSuccess());
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);
}
CharSelectionInfo cl = new CharSelectionInfo(getClient().getAccountName(), getClient().getSessionId().playOkID1, 0);
sendPacket(cl);
getClient().setCharSelection(cl.getCharInfo());
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__0C_CHARACTERDELETE;
}
}
@@ -0,0 +1,66 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.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__62_CHARACTERRESTORE = "[C] 62 CharacterRestore";
// private static Logger _log = Logger.getLogger(CharacterRestore.class.getName());
// cd
private int _charSlot;
@Override
protected void readImpl()
{
_charSlot = readD();
}
@Override
protected void runImpl()
{
if (!getClient().getFloodProtectors().getCharacterSelect().tryPerformAction("CharacterRestore"))
{
return;
}
try
{
getClient().markRestoredChar(_charSlot);
}
catch (Exception e)
{
}
CharSelectionInfo cl = new CharSelectionInfo(getClient().getAccountName(), getClient().getSessionId().playOkID1, 0);
sendPacket(cl);
getClient().setCharSelection(cl.getCharInfo());
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__62_CHARACTERRESTORE;
}
}
@@ -0,0 +1,153 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.clientpackets;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.CharNameTable;
import com.l2jserver.gameserver.instancemanager.AntiFeedManager;
import com.l2jserver.gameserver.model.CharSelectInfoPackage;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.L2GameClient;
import com.l2jserver.gameserver.network.L2GameClient.GameClientState;
import com.l2jserver.gameserver.network.serverpackets.CharSelected;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jserver.gameserver.network.serverpackets.SSQInfo;
import com.l2jserver.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__0D_CHARACTERSELECT = "[C] 0D CharacterSelect";
private static final Logger _log = Logger.getLogger(CharacterSelect.class.getName());
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;
}
// 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;
}
// Selected character is banned.
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(0);
msg.setFile(info.getHtmlPrefix(), "data/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;
}
// 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
}
CharNameTable.getInstance().addName(cha);
cha.setClient(client);
client.setActiveChar(cha);
cha.setOnlineStatus(true, true);
sendPacket(new SSQInfo());
client.setState(GameClientState.IN_GAME);
CharSelected cs = new CharSelected(cha, client.getSessionId().playOkID1);
sendPacket(cs);
}
}
finally
{
client.getActiveCharLock().unlock();
}
LogRecord record = new LogRecord(Level.INFO, "Logged in");
record.setParameters(new Object[]
{
client
});
_logAccounting.log(record);
}
}
/**
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__0D_CHARACTERSELECT;
}
}
@@ -0,0 +1,112 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.clientpackets;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.AdminCommandAccessRights;
import com.l2jserver.gameserver.handler.AdminCommandHandler;
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.util.GMAudit;
/**
* @author Dezmond_snz Format: cddd
*/
public final class DlgAnswer extends L2GameClientPacket
{
private static final String _C__C5_DLGANSWER = "[C] C5 DlgAnswer";
private static Logger _log = Logger.getLogger(DlgAnswer.class.getName());
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;
}
if (Config.DEBUG)
{
_log.fine(getType() + ": Answer accepted. Message ID " + _messageId + ", answer " + _answer + ", Requester ID " + _requesterId);
}
if ((_messageId == SystemMessageId.RESSURECTION_REQUEST_BY_C1_FOR_S2_XP.getId()) || (_messageId == SystemMessageId.RESURRECT_USING_CHARM_OF_COURAGE.getId()))
{
activeChar.reviveAnswer(_answer);
}
else if (_messageId == SystemMessageId.C1_WISHES_TO_SUMMON_YOU_FROM_S2_DO_YOU_ACCEPT.getId())
{
activeChar.teleportAnswer(_answer, _requesterId);
}
else if (_messageId == SystemMessageId.S1.getId())
{
String _command = activeChar.getAdminConfirmCmd();
if (_command == null)
{
if (Config.L2JMOD_ALLOW_WEDDING)
{
activeChar.engageAnswer(_answer);
}
}
else
{
activeChar.setAdminConfirmCmd(null);
if (_answer == 0)
{
return;
}
String command = _command.split(" ")[0];
IAdminCommandHandler ach = AdminCommandHandler.getInstance().getAdminCommandHandler(command);
if (AdminCommandAccessRights.getInstance().hasAccess(command, activeChar.getAccessLevel()))
{
if (Config.GMAUDIT)
{
GMAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", _command, (activeChar.getTarget() != null ? activeChar.getTarget().getName() : "no-target"));
}
ach.useAdminCommand(_command, activeChar);
}
}
}
else if (_messageId == SystemMessageId.WOULD_YOU_LIKE_TO_OPEN_THE_GATE.getId())
{
activeChar.gatesAnswer(_answer, 1);
}
else if (_messageId == SystemMessageId.WOULD_YOU_LIKE_TO_CLOSE_THE_GATE.getId())
{
activeChar.gatesAnswer(_answer, 0);
}
}
@Override
public String getType()
{
return _C__C5_DLGANSWER;
}
}
@@ -0,0 +1,41 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
/**
* @author zabbix Lets drink to code!
*/
public final class DummyPacket extends L2GameClientPacket
{
// private static Logger _log = Logger.getLogger(DummyPacket.class.getName());
@Override
protected void readImpl()
{
}
@Override
public void runImpl()
{
}
@Override
public String getType()
{
return "DummyPacket";
}
}
@@ -0,0 +1,70 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.util.logging.Logger;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
/**
* @author JIV
*/
public final class EndScenePlayer extends L2GameClientPacket
{
private static final String _C__d05b_EndScenePlayer = "[C] d0:5b EndScenePlayer";
private static Logger _log = Logger.getLogger(EndScenePlayer.class.getName());
private int _movieId;
@Override
protected void readImpl()
{
_movieId = readD();
}
@Override
protected void runImpl()
{
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.getPosition().getX(), activeChar.getPosition().getY(), activeChar.getPosition().getZ());
activeChar.setIsTeleporting(false, false);
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__d05b_EndScenePlayer;
}
}
@@ -0,0 +1,702 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.util.Base64;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.Announcements;
import com.l2jserver.gameserver.GmListTable;
import com.l2jserver.gameserver.LoginServerThread;
import com.l2jserver.gameserver.SevenSigns;
import com.l2jserver.gameserver.TaskPriority;
import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.communitybbs.Manager.RegionBBSManager;
import com.l2jserver.gameserver.datatables.AdminCommandAccessRights;
import com.l2jserver.gameserver.datatables.GMSkillTable;
import com.l2jserver.gameserver.datatables.MapRegionTable;
import com.l2jserver.gameserver.datatables.SkillTable;
import com.l2jserver.gameserver.instancemanager.CastleManager;
import com.l2jserver.gameserver.instancemanager.ClanHallManager;
import com.l2jserver.gameserver.instancemanager.CoupleManager;
import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
import com.l2jserver.gameserver.instancemanager.DimensionalRiftManager;
import com.l2jserver.gameserver.instancemanager.FortManager;
import com.l2jserver.gameserver.instancemanager.FortSiegeManager;
import com.l2jserver.gameserver.instancemanager.InstanceManager;
import com.l2jserver.gameserver.instancemanager.MailManager;
import com.l2jserver.gameserver.instancemanager.PetitionManager;
import com.l2jserver.gameserver.instancemanager.QuestManager;
import com.l2jserver.gameserver.instancemanager.SiegeManager;
import com.l2jserver.gameserver.instancemanager.TerritoryWarManager;
import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2ClassMasterInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.ClanHall;
import com.l2jserver.gameserver.model.entity.Couple;
import com.l2jserver.gameserver.model.entity.Fort;
import com.l2jserver.gameserver.model.entity.FortSiege;
import com.l2jserver.gameserver.model.entity.L2Event;
import com.l2jserver.gameserver.model.entity.Siege;
import com.l2jserver.gameserver.model.entity.TvTEvent;
import com.l2jserver.gameserver.model.quest.Quest;
import com.l2jserver.gameserver.model.quest.QuestState;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.communityserver.CommunityServerThread;
import com.l2jserver.gameserver.network.communityserver.writepackets.WorldInfo;
import com.l2jserver.gameserver.network.serverpackets.Die;
import com.l2jserver.gameserver.network.serverpackets.EtcStatusUpdate;
import com.l2jserver.gameserver.network.serverpackets.ExBasicActionList;
import com.l2jserver.gameserver.network.serverpackets.ExBirthdayPopup;
import com.l2jserver.gameserver.network.serverpackets.ExGetBookMarkInfoPacket;
import com.l2jserver.gameserver.network.serverpackets.ExNoticePostArrived;
import com.l2jserver.gameserver.network.serverpackets.ExNotifyPremiumItem;
import com.l2jserver.gameserver.network.serverpackets.ExShowScreenMessage;
import com.l2jserver.gameserver.network.serverpackets.ExStorageMaxCount;
import com.l2jserver.gameserver.network.serverpackets.ExVoteSystemInfo;
import com.l2jserver.gameserver.network.serverpackets.FriendList;
import com.l2jserver.gameserver.network.serverpackets.HennaInfo;
import com.l2jserver.gameserver.network.serverpackets.ItemList;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jserver.gameserver.network.serverpackets.PledgeShowMemberListAll;
import com.l2jserver.gameserver.network.serverpackets.PledgeShowMemberListUpdate;
import com.l2jserver.gameserver.network.serverpackets.PledgeSkillList;
import com.l2jserver.gameserver.network.serverpackets.PledgeStatusChanged;
import com.l2jserver.gameserver.network.serverpackets.QuestList;
import com.l2jserver.gameserver.network.serverpackets.ShortCutInit;
import com.l2jserver.gameserver.network.serverpackets.SkillCoolTime;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* Enter World Packet Handler
* <p>
* <p>
* 0000: 03
* <p>
* packet format rev87 bddddbdcccccccccccccccccccc
* <p>
*/
public class EnterWorld extends L2GameClientPacket
{
private static final String _C__03_ENTERWORLD = "[C] 03 EnterWorld";
private static Logger _log = Logger.getLogger(EnterWorld.class.getName());
private final int[][] tracert = new int[5][4];
public TaskPriority getPriority()
{
return TaskPriority.PR_URGENT;
}
@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()
{
L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
_log.warning("EnterWorld failed! activeChar returned 'null'.");
getClient().closeNow();
return;
}
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
{
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 && AdminCommandAccessRights.getInstance().hasAccess("admin_invul", activeChar.getAccessLevel()))
{
activeChar.setIsInvul(true);
}
if (Config.GM_STARTUP_INVISIBLE && AdminCommandAccessRights.getInstance().hasAccess("admin_invisible", activeChar.getAccessLevel()))
{
activeChar.getAppearance().setInvisible();
}
if (Config.GM_STARTUP_SILENCE && AdminCommandAccessRights.getInstance().hasAccess("admin_silence", activeChar.getAccessLevel()))
{
activeChar.setSilenceMode(true);
}
if (Config.GM_STARTUP_DIET_MODE && AdminCommandAccessRights.getInstance().hasAccess("admin_diet", activeChar.getAccessLevel()))
{
activeChar.setDietMode(true);
activeChar.refreshOverloaded();
}
if (Config.GM_STARTUP_AUTO_LIST && AdminCommandAccessRights.getInstance().hasAccess("admin_gmliston", activeChar.getAccessLevel()))
{
GmListTable.getInstance().addGm(activeChar, false);
}
else
{
GmListTable.getInstance().addGm(activeChar, true);
}
if (Config.GM_GIVE_SPECIAL_SKILLS)
{
GMSkillTable.getInstance().addSkills(activeChar);
}
}
// Set dead status if applies
if (activeChar.getCurrentHp() < 0.5)
{
activeChar.setIsDead(true);
}
boolean showClanNotice = false;
// Clan related checks are here
if (activeChar.getClan() != null)
{
activeChar.sendPacket(new PledgeSkillList(activeChar.getClan()));
notifyClanMembers(activeChar);
notifySponsorOrApprentice(activeChar);
ClanHall clanHall = ClanHallManager.getInstance().getClanHallByOwner(activeChar.getClan());
if (clanHall != null)
{
if (!clanHall.getPaid())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(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.getIsInProgress())
{
continue;
}
if (siege.checkIsAttacker(activeChar.getClan()))
{
activeChar.setSiegeState((byte) 1);
activeChar.setSiegeSide(siege.getCastle().getCastleId());
}
else if (siege.checkIsDefender(activeChar.getClan()))
{
activeChar.setSiegeState((byte) 2);
activeChar.setSiegeSide(siege.getCastle().getCastleId());
}
}
for (FortSiege siege : FortSiegeManager.getInstance().getSieges())
{
if (!siege.getIsInProgress())
{
continue;
}
if (siege.checkIsAttacker(activeChar.getClan()))
{
activeChar.setSiegeState((byte) 1);
activeChar.setSiegeSide(siege.getFort().getFortId());
}
else if (siege.checkIsDefender(activeChar.getClan()))
{
activeChar.setSiegeState((byte) 2);
activeChar.setSiegeSide(siege.getFort().getFortId());
}
}
sendPacket(new PledgeShowMemberListAll(activeChar.getClan(), activeChar));
sendPacket(new PledgeStatusChanged(activeChar.getClan()));
// Residential skills support
if (activeChar.getClan().getHasCastle() > 0)
{
CastleManager.getInstance().getCastleByOwner(activeChar.getClan()).giveResidentialSkills(activeChar);
}
if (activeChar.getClan().getHasFort() > 0)
{
FortManager.getInstance().getFortByOwner(activeChar.getClan()).giveResidentialSkills(activeChar);
}
showClanNotice = activeChar.getClan().isNoticeEnabled();
}
if (TerritoryWarManager.getInstance().getRegisteredTerritoryId(activeChar) > 0)
{
if (TerritoryWarManager.getInstance().isTWInProgress())
{
activeChar.setSiegeState((byte) 1);
}
activeChar.setSiegeSide(TerritoryWarManager.getInstance().getRegisteredTerritoryId(activeChar));
}
// Updating Seal of Strife Buff/Debuff
if (SevenSigns.getInstance().isSealValidationPeriod() && (SevenSigns.getInstance().getSealOwner(SevenSigns.SEAL_STRIFE) != SevenSigns.CABAL_NULL))
{
int cabal = SevenSigns.getInstance().getPlayerCabal(activeChar.getObjectId());
if (cabal != SevenSigns.CABAL_NULL)
{
if (cabal == SevenSigns.getInstance().getSealOwner(SevenSigns.SEAL_STRIFE))
{
activeChar.addSkill(SkillTable.FrequentSkill.THE_VICTOR_OF_WAR.getSkill());
}
else
{
activeChar.addSkill(SkillTable.FrequentSkill.THE_VANQUISHED_OF_WAR.getSkill());
}
}
}
else
{
activeChar.removeSkill(SkillTable.FrequentSkill.THE_VICTOR_OF_WAR.getSkill());
activeChar.removeSkill(SkillTable.FrequentSkill.THE_VANQUISHED_OF_WAR.getSkill());
}
if (Config.ENABLE_VITALITY && Config.RECOVER_VITALITY_ON_RECONNECT)
{
float points = (Config.RATE_RECOVERY_ON_RECONNECT * (System.currentTimeMillis() - activeChar.getLastAccess())) / 60000;
if (points > 0)
{
activeChar.updateVitalityPoints(points, false, true);
}
}
activeChar.checkRecoBonusTask();
activeChar.broadcastUserInfo();
// Send Macro List
activeChar.getMacroses().sendUpdate();
// Send Item List
sendPacket(new ItemList(activeChar, false));
// Send GG check
activeChar.queryGameGuard();
// Send Teleport Bookmark List
sendPacket(new ExGetBookMarkInfoPacket(activeChar));
// Send Shortcuts
sendPacket(new ShortCutInit(activeChar));
// Send Action list
activeChar.sendPacket(ExBasicActionList.getStaticPacket(activeChar));
// Send Skill list
activeChar.sendSkillList();
// Send Dye Information
activeChar.sendPacket(new HennaInfo(activeChar));
Quest.playerEnter(activeChar);
if (!Config.DISABLE_TUTORIAL)
{
loadTutorial(activeChar);
}
for (Quest quest : QuestManager.getInstance().getAllManagedScripts())
{
if ((quest != null) && quest.getOnEnterWorld())
{
quest.notifyEnterWorld(activeChar);
}
}
activeChar.sendPacket(new QuestList());
if (Config.PLAYER_SPAWN_PROTECTION > 0)
{
activeChar.setProtection(true);
}
activeChar.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());
if (L2Event.active && L2Event.connectionLossData.containsKey(activeChar.getName()) && L2Event.isOnEvent(activeChar))
{
L2Event.restoreChar(activeChar);
}
else if (L2Event.connectionLossData.containsKey(activeChar.getName()))
{
L2Event.restoreAndTeleChar(activeChar);
}
// Wedding Checks
if (Config.L2JMOD_ALLOW_WEDDING)
{
engage(activeChar);
notifyPartner(activeChar, activeChar.getPartnerId());
}
if (activeChar.isCursedWeaponEquipped())
{
CursedWeaponsManager.getInstance().getCursedWeapon(activeChar.getCursedWeaponEquippedId()).cursedOnLogin();
}
activeChar.updateEffectIcons();
activeChar.sendPacket(new EtcStatusUpdate(activeChar));
// Expand Skill
activeChar.sendPacket(new ExStorageMaxCount(activeChar));
sendPacket(new FriendList(activeChar));
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.FRIEND_S1_HAS_LOGGED_IN);
sm.addString(activeChar.getName());
for (int id : activeChar.getFriendList())
{
L2Object obj = L2World.getInstance().findObject(id);
if (obj != null)
{
obj.sendPacket(sm);
}
}
sendPacket(SystemMessage.getSystemMessage(SystemMessageId.WELCOME_TO_LINEAGE));
activeChar.sendMessage(getText("VGhpcyBzZXJ2ZXIgdXNlcyBMMkosIGEgcHJvamVjdCBmb3VuZGVkIGJ5IEwyQ2hlZg=="));
activeChar.sendMessage(getText("YW5kIGRldmVsb3BlZCBieSB0aGUgTDJKIERldiBUZWFtIGF0IGwyanNlcnZlci5jb20="));
activeChar.sendMessage(getText("Q29weXJpZ2h0IDIwMDQtMjAxMQ=="));
SevenSigns.getInstance().sendCurrentPeriodMsg(activeChar);
Announcements.getInstance().showAnnouncements(activeChar);
if (showClanNotice)
{
NpcHtmlMessage notice = new NpcHtmlMessage(1);
notice.setFile(activeChar.getHtmlPrefix(), "data/html/clanNotice.htm");
notice.replace("%clan_name%", activeChar.getClan().getName());
notice.replace("%notice_text%", activeChar.getClan().getNotice().replaceAll("\r\n", "<br>"));
notice.disableValidation();
sendPacket(notice);
}
else if (Config.SERVER_NEWS)
{
String serverNews = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/servnews.htm");
if (serverNews != null)
{
sendPacket(new NpcHtmlMessage(1, 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 (DimensionalRiftManager.getInstance().checkIfInRiftZone(activeChar.getX(), activeChar.getY(), activeChar.getZ(), false))
{
DimensionalRiftManager.getInstance().teleportToWaitingRoom(activeChar);
}
if (activeChar.getClanJoinExpiryTime() > System.currentTimeMillis())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CLAN_MEMBERSHIP_TERMINATED));
}
// remove combat flag before teleporting
if (activeChar.getInventory().getItemByItemId(9819) != null)
{
Fort fort = FortManager.getInstance().getFort(activeChar);
if (fort != null)
{
FortSiegeManager.getInstance().dropCombatFlag(activeChar, fort.getFortId());
}
else
{
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.isGM()
// inside siege zone
&& activeChar.isInsideZone(L2Character.ZONE_SIEGE)
// but non-participant or attacker
&& (!activeChar.isInSiege() || (activeChar.getSiegeState() < 2)))
{
activeChar.teleToLocation(MapRegionTable.TeleportWhereType.Town);
}
if (Config.ALLOW_MAIL)
{
if (MailManager.getInstance().hasUnreadPost(activeChar))
{
sendPacket(ExNoticePostArrived.valueOf(false));
}
}
RegionBBSManager.getInstance().changeCommunityBoard();
CommunityServerThread.getInstance().sendPacket(new WorldInfo(activeChar, null, WorldInfo.TYPE_UPDATE_PLAYER_STATUS));
TvTEvent.onLogin(activeChar);
if (Config.WELCOME_MESSAGE_ENABLED)
{
activeChar.sendPacket(new ExShowScreenMessage(Config.WELCOME_MESSAGE_TEXT, Config.WELCOME_MESSAGE_TIME));
}
L2ClassMasterInstance.showQuestionMark(activeChar);
int birthday = activeChar.checkBirthDay();
if (birthday == 0)
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOUR_BIRTHDAY_GIFT_HAS_ARRIVED));
activeChar.sendPacket(new ExBirthdayPopup());
}
else if (birthday != -1)
{
sm = SystemMessage.getSystemMessage(SystemMessageId.THERE_ARE_S1_DAYS_UNTIL_YOUR_CHARACTERS_BIRTHDAY);
sm.addString(Integer.toString(birthday));
activeChar.sendPacket(sm);
}
if (!activeChar.getPremiumItemList().isEmpty())
{
activeChar.sendPacket(new ExNotifyPremiumItem());
}
}
/**
* @param activeChar
*/
private void engage(L2PcInstance cha)
{
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 activeChar partnerid
*/
private void notifyPartner(L2PcInstance cha, int partnerId)
{
if (cha.getPartnerId() != 0)
{
int objId = cha.getPartnerId();
try
{
L2PcInstance partner = L2World.getInstance().getPlayer(objId);
if (partner != null)
{
partner.sendMessage("Your Partner has logged in.");
}
partner = null;
}
catch (ClassCastException cce)
{
_log.warning("Wedding Error: ID " + objId + " is now owned by a(n) " + L2World.getInstance().findObject(objId).getClass().getSimpleName());
}
}
}
/**
* @param activeChar
*/
private void notifyClanMembers(L2PcInstance activeChar)
{
L2Clan clan = activeChar.getClan();
// This null check may not be needed anymore since notifyClanMembers is called from within a null check already. Please remove if we're certain it's ok to do so.
if (clan != null)
{
clan.getClanMember(activeChar.getObjectId()).setPlayerInstance(activeChar);
SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.CLAN_MEMBER_S1_LOGGED_IN);
msg.addString(activeChar.getName());
clan.broadcastToOtherOnlineMembers(msg, activeChar);
msg = null;
clan.broadcastToOtherOnlineMembers(new PledgeShowMemberListUpdate(activeChar), activeChar);
}
}
/**
* @param activeChar
*/
private void notifySponsorOrApprentice(L2PcInstance activeChar)
{
if (activeChar.getSponsor() != 0)
{
L2PcInstance sponsor = L2World.getInstance().getPlayer(activeChar.getSponsor());
if (sponsor != null)
{
SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.YOUR_APPRENTICE_S1_HAS_LOGGED_IN);
msg.addString(activeChar.getName());
sponsor.sendPacket(msg);
}
}
else if (activeChar.getApprentice() != 0)
{
L2PcInstance apprentice = L2World.getInstance().getPlayer(activeChar.getApprentice());
if (apprentice != null)
{
SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.YOUR_SPONSOR_C1_HAS_LOGGED_IN);
msg.addString(activeChar.getName());
apprentice.sendPacket(msg);
}
}
}
/**
* Gets the decoded string.
* @param string the string to decode
* @return the decoded string
*/
private String getText(String string)
{
return new String(Base64.getDecoder().decode(string));
}
private void loadTutorial(L2PcInstance player)
{
QuestState qs = player.getQuestState("255_Tutorial");
if (qs != null)
{
qs.getQuest().notifyEvent("UC", null, player);
}
}
@Override
public String getType()
{
return _C__03_ENTERWORLD;
}
@Override
protected boolean triggersOnActionRequest()
{
return false;
}
}
@@ -0,0 +1,55 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.clientpackets;
import java.util.logging.Logger;
/**
* Format: (c) dddd d: dx d: dy d: dz d: AirShip id ??
* @author -Wooden-
*/
public class ExGetOnAirShip extends L2GameClientPacket
{
protected static final Logger _log = Logger.getLogger(ExGetOnAirShip.class.getName());
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] 0xD0:0x36 ExGetOnAirShip";
}
}
@@ -0,0 +1,71 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.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__4B_FINISHROTATING = "[C] 4B 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);
}
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__4B_FINISHROTATING;
}
}
@@ -0,0 +1,98 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.gameserver.network.L2GameClient;
/**
* Format: c dddd
* @author KenM
*/
public class GameGuardReply extends L2GameClientPacket
{
protected static final Logger _log = Logger.getLogger(GameGuardReply.class.getName());
private static final String _C__CA_GAMEGUARDREPLY = "[C] CA 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()
{
L2GameClient client = getClient();
try
{
MessageDigest md = MessageDigest.getInstance("SHA");
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__CA_GAMEGUARDREPLY;
}
@Override
protected boolean triggersOnActionRequest()
{
return false;
}
}
@@ -0,0 +1,118 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.nio.BufferUnderflowException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.mmocore.network.ReceivablePacket;
import com.l2jserver.Config;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.L2GameClient;
import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
/**
* 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()
{
// _log.info(this.getType());
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());
}
}
}
cleanUp();
}
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();
protected final void sendPacket(L2GameServerPacket gsp)
{
getClient().sendPacket(gsp);
}
/**
* @return A String with this packet name for debuging purposes
*/
public abstract String getType();
/**
* Overriden with true value on some packets that should disable spawn protection (RequestItemList and UseItem only)
*/
protected boolean triggersOnActionRequest()
{
return true;
}
protected void cleanUp()
{
}
}
@@ -0,0 +1,130 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.SevenSignsFestival;
import com.l2jserver.gameserver.model.L2Party;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.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__09_LOGOUT = "[C] 09 Logout";
private static final Logger _log = Logger.getLogger(Logout.class.getName());
protected static final Logger _logAccounting = Logger.getLogger("accounting");
@Override
protected void readImpl()
{
}
@Override
protected void runImpl()
{
// Dont allow leaving if player is fighting
final L2PcInstance player = getClient().getActiveChar();
if (player == null)
{
return;
}
if ((player.getActiveEnchantItem() != null) || (player.getActiveEnchantAttrItem() != null))
{
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;
}
if (AttackStanceTaskManager.getInstance().getAttackStanceTask(player) && !(player.isGM() && Config.GM_RESTART_FIGHTING))
{
if (Config.DEBUG)
{
_log.fine("Player " + player.getName() + " tried to logout while fighting");
}
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANT_LOGOUT_WHILE_FIGHTING));
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if (player.atEvent)
{
player.sendMessage("A superior power doesn't allow you to leave the event");
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Prevent player from logging out if they are a festival participant
// and it is in progress, otherwise notify party members that the player
// is not longer a participant.
if (player.isFestivalParticipant())
{
if (SevenSignsFestival.getInstance().isFestivalInitialized())
{
player.sendMessage("You cannot log out while you are a participant in a festival.");
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
final L2Party playerParty = player.getParty();
if (playerParty != null)
{
player.getParty().broadcastToPartyMembers(SystemMessage.sendString(player.getName() + " has been removed from the upcoming festival."));
}
}
// Remove player from Boss Zone
player.removeFromBossZone();
LogRecord record = new LogRecord(Level.INFO, "Disconnected");
record.setParameters(new Object[]
{
getClient()
});
_logAccounting.log(record);
player.logout();
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__09_LOGOUT;
}
}
@@ -0,0 +1,149 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.nio.BufferUnderflowException;
import com.l2jserver.Config;
import com.l2jserver.gameserver.TaskPriority;
import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.model.L2CharPosition;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.StopMove;
import com.l2jserver.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 Logger _log = Logger.getLogger(MoveBackwardToLocation.class.getName());
// cdddddd
private int _targetX;
private int _targetY;
private int _targetZ;
private int _originX;
private int _originY;
private int _originZ;
private int _moveMovement;
// For geodata
private int _curX;
private int _curY;
@SuppressWarnings("unused")
private int _curZ;
public TaskPriority getPriority()
{
return TaskPriority.PR_HIGH;
}
private static final String _C__01_MOVEBACKWARDTOLOC = "[C] 01 MoveBackwardToLoc";
@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)
{
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()
{
L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
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().collisionHeight;
_curX = activeChar.getX();
_curY = activeChar.getY();
_curZ = activeChar.getZ();
if (activeChar.getTeleMode() > 0)
{
if (activeChar.getTeleMode() == 1)
{
activeChar.setTeleMode(0);
}
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
activeChar.teleToLocation(_targetX, _targetY, _targetZ, false);
return;
}
if ((_moveMovement == 0) && (Config.GEODATA < 1)) // cursor movement without geodata is disabled
{
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
}
else
{
double dx = _targetX - _curX;
double dy = _targetY - _curY;
// 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 L2CharPosition(_targetX, _targetY, _targetZ, 0));
/*
* if (activeChar.getParty() != null) activeChar.getParty().broadcastToPartyMembers(activeChar, new PartyMemberPosition(activeChar));
*/
}
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__01_MOVEBACKWARDTOLOC;
}
}
@@ -0,0 +1,157 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.TaskPriority;
import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.instancemanager.AirShipManager;
import com.l2jserver.gameserver.model.L2CharPosition;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.VehiclePathPoint;
import com.l2jserver.gameserver.model.actor.instance.L2AirShipInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
public class MoveToLocationAirShip extends L2GameClientPacket
{
public static final int MIN_Z = -895;
public static final int MAX_Z = 6105;
public static final int STEP = 300;
private static final String _C__D0_38_MOVETOLOCATIONAIRSHIP = "[C] D0:38 MoveToLocationAirShip";
private int _command;
private int _param1;
private int _param2 = 0;
public TaskPriority getPriority()
{
return TaskPriority.PR_HIGH;
}
@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 L2CharPosition(_param1, _param2, z, 0));
}
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 L2CharPosition(ship.getX(), ship.getY(), z, 0));
}
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 L2CharPosition(ship.getX(), ship.getY(), z, 0));
}
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(SystemMessage.getSystemMessage(SystemMessageId.THE_AIRSHIP_CANNOT_TELEPORT));
return;
}
ship.setFuel(ship.getFuel() - fuelConsumption);
}
ship.executePath(dst);
break;
}
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__D0_38_MOVETOLOCATIONAIRSHIP;
}
}
@@ -0,0 +1,112 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.TaskPriority;
import com.l2jserver.gameserver.model.actor.instance.L2AirShipInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.ExMoveToLocationInAirShip;
import com.l2jserver.gameserver.network.serverpackets.StopMoveInVehicle;
import com.l2jserver.gameserver.templates.item.L2WeaponType;
import com.l2jserver.util.Point3D;
/**
* 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;
public TaskPriority getPriority()
{
return TaskPriority.PR_HIGH;
}
@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() == L2WeaponType.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 Point3D(_targetX, _targetY, _targetZ));
activeChar.broadcastPacket(new ExMoveToLocationInAirShip(activeChar));
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__D0_20_MOVETOLOCATIONINAIRSHIP;
}
}
@@ -0,0 +1,50 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
/**
* Format: (c) ddd d: dx d: dy d: dz
* @author -Wooden-
*/
public class MoveWithDelta extends L2GameClientPacket
{
@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] 0x41 MoveWithDelta";
}
}
@@ -0,0 +1,443 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.util.ArrayList;
import java.util.logging.Logger;
import javolution.util.FastList;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.MultiSell;
import com.l2jserver.gameserver.model.Elementals;
import com.l2jserver.gameserver.model.L2Augmentation;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.itemcontainer.PcInventory;
import com.l2jserver.gameserver.model.multisell.Entry;
import com.l2jserver.gameserver.model.multisell.Ingredient;
import com.l2jserver.gameserver.model.multisell.PreparedListContainer;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ItemList;
import com.l2jserver.gameserver.network.serverpackets.StatusUpdate;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* The Class MultiSellChoose.
*/
public class MultiSellChoose extends L2GameClientPacket
{
private static final String _C__A7_MULTISELLCHOOSE = "[C] A7 MultiSellChoose";
private static Logger _log = Logger.getLogger(MultiSellChoose.class.getName());
private int _listId;
private int _entryId;
private long _amount;
/*
* @SuppressWarnings("unused") private int _unk1;
* @SuppressWarnings("unused") private int _unk2;
* @SuppressWarnings("unused") private int _unk3;
* @SuppressWarnings("unused") private int _unk7;
* @SuppressWarnings("unused") private int _unk4;
* @SuppressWarnings("unused") private int _unk5;
* @SuppressWarnings("unused") private int _unk6;
* @SuppressWarnings("unused") private int _unk8;
* @SuppressWarnings("unused") private int _unk9;
* @SuppressWarnings("unused") private int _unk10;
* @SuppressWarnings("unused") private int _unk11;
*/
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#readImpl()
*/
@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
*/
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#runImpl()
*/
@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;
}
PreparedListContainer list = player.getMultiSell();
if ((list == null) || (list.getListId() != _listId))
{
player.setMultiSell(null);
return;
}
L2Npc target = player.getLastFolkNPC();
if (!player.isGM() && ((target == null) || !list.checkNpcObjectId(target.getObjectId()) || !target.canInteract(player)))
{
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(SystemMessage.getSystemMessage(SystemMessageId.WEIGHT_LIMIT_EXCEEDED));
return;
}
if (!inv.validateCapacity(slots))
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.SLOTS_FULL));
return;
}
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;)
{
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(SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EXCEEDED_QUANTITY_THAT_CAN_BE_INPUTTED));
return;
}
// two same ingredients, merge into one and replace old
final Ingredient ing = ex.clone();
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(SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EXCEEDED_QUANTITY_THAT_CAN_BE_INPUTTED));
return;
}
if (e.getItemId() < 0)
{
if (!MultiSell.checkSpecialIngredient(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() : -1, false) < required)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S2_UNIT_OF_THE_ITEM_S1_REQUIRED);
sm.addItemName(e.getTemplate());
sm.addNumber((int) required);
player.sendPacket(sm);
return;
}
}
}
FastList<L2Augmentation> augmentation = FastList.newInstance();
Elementals[] elemental = null;
/** All ok, remove items and add final product */
try
{
for (Ingredient e : entry.getIngredients())
{
if (e.getItemId() < 0)
{
if (!MultiSell.getSpecialIngredient(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())
{
// loop through this list and remove (one by one) each item until the required amount is taken.
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++)
{
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;
}
}
}
}
}
}
}
// Generate the appropriate items
for (Ingredient e : entry.getProducts())
{
if (e.getItemId() < 0)
{
MultiSell.addSpecialProduct(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 (list.getMaintainEnchantment())
{
if (i < augmentation.size())
{
product.setAugmentation(new L2Augmentation(augmentation.get(i).getAugmentationId(), augmentation.get(i).getSkill()));
}
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.EARNED_S2_S1_S);
sm.addItemName(e.getItemId());
sm.addItemNumber(e.getItemCount() * _amount);
player.sendPacket(sm);
sm = null;
}
else
{
if (list.getMaintainEnchantment() && (e.getEnchantLevel() > 0))
{
sm = SystemMessage.getSystemMessage(SystemMessageId.ACQUIRED_S1_S2);
sm.addItemNumber(e.getEnchantLevel());
sm.addItemName(e.getItemId());
}
else
{
sm = SystemMessage.getSystemMessage(SystemMessageId.EARNED_ITEM_S1);
sm.addItemName(e.getItemId());
}
player.sendPacket(sm);
sm = null;
}
}
}
player.sendPacket(new ItemList(player, false));
StatusUpdate su = new StatusUpdate(player);
su.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad());
player.sendPacket(su);
su = null;
}
finally
{
FastList.recycle(augmentation);
}
// finally, give the tax to the castle...
if (entry.getTaxAmount() > 0)
{
target.getCastle().addToTreasury(entry.getTaxAmount() * _amount);
}
break;
}
}
}
@Override
public String getType()
{
return _C__A7_MULTISELLCHOOSE;
}
}
@@ -0,0 +1,98 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.CharTemplateTable;
import com.l2jserver.gameserver.model.base.ClassId;
import com.l2jserver.gameserver.network.serverpackets.NewCharacterSuccess;
import com.l2jserver.gameserver.templates.chars.L2PcTemplate;
/**
* This class ...
* @version $Revision: 1.3.4.5 $ $Date: 2005/03/27 15:29:30 $
*/
public final class NewCharacter extends L2GameClientPacket
{
private static final String _C__0E_NEWCHARACTER = "[C] 0E NewCharacter";
private static Logger _log = Logger.getLogger(NewCharacter.class.getName());
@Override
protected void readImpl()
{
}
@Override
protected void runImpl()
{
if (Config.DEBUG)
{
_log.fine("CreateNewChar");
}
NewCharacterSuccess ct = new NewCharacterSuccess();
L2PcTemplate template = CharTemplateTable.getInstance().getTemplate(0);
ct.addChar(template);
template = CharTemplateTable.getInstance().getTemplate(ClassId.fighter); // human fighter
ct.addChar(template);
template = CharTemplateTable.getInstance().getTemplate(ClassId.mage); // human mage
ct.addChar(template);
template = CharTemplateTable.getInstance().getTemplate(ClassId.elvenFighter); // elf fighter
ct.addChar(template);
template = CharTemplateTable.getInstance().getTemplate(ClassId.elvenMage); // elf mage
ct.addChar(template);
template = CharTemplateTable.getInstance().getTemplate(ClassId.darkFighter); // dark elf fighter
ct.addChar(template);
template = CharTemplateTable.getInstance().getTemplate(ClassId.darkMage); // dark elf mage
ct.addChar(template);
template = CharTemplateTable.getInstance().getTemplate(ClassId.orcFighter); // orc fighter
ct.addChar(template);
template = CharTemplateTable.getInstance().getTemplate(ClassId.orcMage); // orc mage
ct.addChar(template);
template = CharTemplateTable.getInstance().getTemplate(ClassId.dwarvenFighter); // dwarf fighter
ct.addChar(template);
template = CharTemplateTable.getInstance().getTemplate(ClassId.maleSoldier); // kamael male soldier
ct.addChar(template);
template = CharTemplateTable.getInstance().getTemplate(ClassId.femaleSoldier); // kamael female soldier
ct.addChar(template);
sendPacket(ct);
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__0E_NEWCHARACTER;
}
}
@@ -0,0 +1,58 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.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 OBSRETURN__C__04 = "[C] b8 ObserverReturn";
// private static Logger _log = Logger.getLogger(Action.class.getName());
@Override
protected void readImpl()
{
}
@Override
protected void runImpl()
{
L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
if (activeChar.inObserverMode())
{
activeChar.leaveObserverMode();
// activeChar.teleToLocation(activeChar.getObsX(), activeChar.getObsY(), activeChar.getObsZ());
}
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return OBSRETURN__C__04;
}
}
@@ -0,0 +1,91 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.network.serverpackets.KeyPacket;
import com.l2jserver.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__00_PROTOCOLVERSION = "[C] 00 ProtocolVersion";
private static final Logger _log = Logger.getLogger(ProtocolVersion.class.getName());
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))
{
LogRecord record = new LogRecord(Level.WARNING, "Wrong protocol");
record.setParameters(new Object[]
{
_version,
getClient()
});
_logAccounting.log(record);
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);
}
KeyPacket pk = new KeyPacket(getClient().enableCrypt(), 1);
getClient().sendPacket(pk);
getClient().setProtocolOk(true);
}
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__00_PROTOCOLVERSION;
}
}
@@ -0,0 +1,562 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.SkillTable;
import com.l2jserver.gameserver.datatables.SkillTreesData;
import com.l2jserver.gameserver.instancemanager.QuestManager;
import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2ShortCut;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.L2SkillLearn;
import com.l2jserver.gameserver.model.L2SquadTrainer;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2FishermanInstance;
import com.l2jserver.gameserver.model.actor.instance.L2NpcInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.actor.instance.L2TrainerHealersInstance;
import com.l2jserver.gameserver.model.actor.instance.L2TransformManagerInstance;
import com.l2jserver.gameserver.model.actor.instance.L2VillageMasterInstance;
import com.l2jserver.gameserver.model.quest.Quest;
import com.l2jserver.gameserver.model.quest.QuestState;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.AcquireSkillDone;
import com.l2jserver.gameserver.network.serverpackets.AcquireSkillList.SkillType;
import com.l2jserver.gameserver.network.serverpackets.ExStorageMaxCount;
import com.l2jserver.gameserver.network.serverpackets.PledgeSkillList;
import com.l2jserver.gameserver.network.serverpackets.ShortCutRegister;
import com.l2jserver.gameserver.network.serverpackets.StatusUpdate;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.util.Util;
/**
* @author Zoey76
*/
public final class RequestAcquireSkill extends L2GameClientPacket
{
private static final String _C__7C_REQUESTACQUIRESKILL = "[C] 7C RequestAcquireSkill";
private static Logger _log = Logger.getLogger(RequestAcquireSkill.class.getName());
private int _id;
private int _level;
private int _skillType;
private int _subType;
@Override
protected void readImpl()
{
_id = readD();
_level = readD();
_skillType = readD();
if (_skillType == SkillType.SubPledge.ordinal())
{
_subType = readD();
}
}
@Override
protected void runImpl()
{
final L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
if ((_level < 1) || (_level > 1000) || (_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))
{
return;
}
if (!trainer.canInteract(activeChar) && !activeChar.isGM())
{
return;
}
final SkillType skillType = SkillType.values()[_skillType];
if ((activeChar.getSkillLevel(_id) >= _level) && (skillType != SkillType.SubPledge))
{
// Already knows the skill with this level
return;
}
final L2Skill skill = SkillTable.getInstance().getInfo(_id, _level);
if (skill == null)
{
_log.warning("Player " + activeChar.getName() + " is trying to learn a null skill id: " + _id + " level: " + _level + "!");
return;
}
// Hack check. Doesn't apply to all Skill Types
if (((skillType != SkillType.Transfer) && ((_level > 1) && (activeChar.getKnownSkill(_id) == null))) || ((activeChar.getKnownSkill(_id) != null) && (activeChar.getKnownSkill(_id).getLevel() != (_level - 1))))
{
// The previous level skill has not been learned.
activeChar.sendPacket(SystemMessageId.PREVIOUS_LEVEL_SKILL_NOT_LEARNED);
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " is requesting skill Id: " + _id + " level " + _level + " without knowing it's previous level!", 0);
return;
}
switch (skillType)
{
case ClassTransform:
{
// If players is learning transformations:
if (trainer instanceof L2TransformManagerInstance)
{
// Hack check.
if (!L2TransformManagerInstance.canTransform(activeChar))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_COMPLETED_QUEST_FOR_SKILL_ACQUISITION));
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " is requesting skill Id: " + _id + " level " + _level + " without required quests!", 0);
return;
}
// Required skills:
final L2SkillLearn s = SkillTreesData.getInstance().getTransformSkill(_id, _level);
if ((s != null) && (s.getPreReqSkillIdLvl() != null) && (activeChar.getKnownSkill(s.getPreReqSkillIdLvl()[0]) == null))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_MUST_LEARN_ONYX_BEAST_SKILL));
return;
}
if (checkPlayerSkill(activeChar, trainer, s))
{
giveSkill(activeChar, trainer, skill);
}
break;
}
final L2SkillLearn s = SkillTreesData.getInstance().getClassSkill(_id, _level, activeChar.getLearningClass());
if (checkPlayerSkill(activeChar, trainer, s))
{
giveSkill(activeChar, trainer, skill);
}
break;
}
case Fishing:
{
final L2SkillLearn s = SkillTreesData.getInstance().getFishingSkill(_id, _level);
if (checkPlayerSkill(activeChar, trainer, s))
{
giveSkill(activeChar, trainer, skill);
}
break;
}
case Pledge:
{
if (!activeChar.isClanLeader())
{
return;
}
final L2Clan clan = activeChar.getClan();
int itemId = -1;
int itemCount = -1;
int repCost = 100000000;
final L2SkillLearn s = SkillTreesData.getInstance().getPledgeSkill(_id, _level);
if (s != null)
{
repCost = s.getLevelUpSp();
if (clan.getReputationScore() >= repCost)
{
if (Config.LIFE_CRYSTAL_NEEDED && (s.getItemsIdCount() != null))
{
for (int[] itemIdCount : s.getItemsIdCount())
{
itemId = itemIdCount[0];
itemCount = itemIdCount[1];
if ((itemId > 0) && (itemCount > 0))
{
if (!activeChar.destroyItemByItemId("Consume", itemId, itemCount, trainer, false))
{
// Doesn't have required item.
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ITEM_MISSING_TO_LEARN_SKILL));
L2VillageMasterInstance.showPledgeSkillList(activeChar);
return;
}
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S2_S1_DISAPPEARED);
sm.addItemName(itemId);
sm.addItemNumber(itemCount);
activeChar.sendPacket(sm);
}
}
}
clan.takeReputationScore(repCost, true);
final SystemMessage cr = SystemMessage.getSystemMessage(SystemMessageId.S1_DEDUCTED_FROM_CLAN_REP);
cr.addNumber(repCost);
activeChar.sendPacket(cr);
clan.addNewSkill(skill);
clan.broadcastToOnlineMembers(new PledgeSkillList(clan));
activeChar.sendPacket(new AcquireSkillDone());
L2VillageMasterInstance.showPledgeSkillList(activeChar);
}
else
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ACQUIRE_SKILL_FAILED_BAD_CLAN_REP_SCORE));
L2VillageMasterInstance.showPledgeSkillList(activeChar);
}
return;
}
break;
}
case SubPledge:
{
if (!activeChar.isClanLeader())
{
return;
}
final L2Clan clan = activeChar.getClan();
if ((clan.getHasFort() == 0) && (clan.getHasCastle() == 0))
{
return;
}
if (trainer instanceof L2SquadTrainer)
{
int itemId = -1;
int itemCount = -1;
int rep = 100000000;
final L2SkillLearn s = SkillTreesData.getInstance().getSubPledgeSkill(_id, _level);
if (s != null)
{
// Hack check. Check if SubPledge can accept the new skill:
if (!clan.isLearnableSubPledgeSkill(skill, _subType))
{
activeChar.sendPacket(SystemMessageId.SQUAD_SKILL_ALREADY_ACQUIRED);
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " is requesting skill Id: " + _id + " level " + _level + " without knowing it's previous level!", 0);
return;
}
rep = s.getLevelUpSp();
if (clan.getReputationScore() < rep)
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ACQUIRE_SKILL_FAILED_BAD_CLAN_REP_SCORE));
return;
}
for (int[] itemIdCount : s.getItemsIdCount())
{
itemId = itemIdCount[0];
itemCount = itemIdCount[1];
if (!activeChar.destroyItemByItemId("SubSkills", itemId, itemCount, trainer, false))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ITEM_MISSING_TO_LEARN_SKILL));
return;
}
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S2_S1_DISAPPEARED);
sm.addItemName(itemId);
sm.addItemNumber(itemCount);
activeChar.sendPacket(sm);
}
if (rep > 0)
{
clan.takeReputationScore(rep, true);
final SystemMessage cr = SystemMessage.getSystemMessage(SystemMessageId.S1_DEDUCTED_FROM_CLAN_REP);
cr.addNumber(rep);
activeChar.sendPacket(cr);
}
clan.addNewSkill(skill, _subType);
clan.broadcastToOnlineMembers(new PledgeSkillList(clan));
activeChar.sendPacket(new AcquireSkillDone());
((L2SquadTrainer) trainer).showSubUnitSkillList(activeChar);
return;
}
}
break;
}
case Transfer:
{
final L2SkillLearn s = SkillTreesData.getInstance().getTransferSkill(_id, _level, activeChar.getClassId());
if (checkPlayerSkill(activeChar, trainer, s))
{
giveSkill(activeChar, trainer, skill);
}
break;
}
case SubClass:
{
// Hack check.
if (activeChar.isSubClassActive())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.SKILL_NOT_FOR_SUBCLASS));
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " is requesting skill Id: " + _id + " level " + _level + " while Sub-Class is active!", 0);
return;
}
final L2SkillLearn s = SkillTreesData.getInstance().getSubClassSkill(_id, _level);
QuestState st = activeChar.getQuestState("SubClassSkills");
if (st == null)
{
final Quest subClassSkilllsQuest = QuestManager.getInstance().getQuest("SubClassSkills");
if (subClassSkilllsQuest != null)
{
st = subClassSkilllsQuest.newQuestState(activeChar);
}
else
{
_log.warning("Null SubClassSkills quest, for Sub-Class skill Id: " + _id + " level: " + _level + " for player " + activeChar.getName() + "!");
return;
}
}
for (String varName : L2TransformManagerInstance._questVarNames)
{
for (int i = 1; i <= Config.MAX_SUBCLASS; i++)
{
final String itemOID = st.getGlobalQuestVar(varName + i);
if (!itemOID.isEmpty() && !itemOID.endsWith(";") && !itemOID.equals("0"))
{
if (Util.isDigit(itemOID))
{
final int itemObjId = Integer.parseInt(itemOID);
final L2ItemInstance item = activeChar.getInventory().getItemByObjectId(itemObjId);
if (item != null)
{
if (Util.contains(s.getItemsIdCount()[0], item.getItemId()))
{
if (checkPlayerSkill(activeChar, trainer, s))
{
giveSkill(activeChar, trainer, skill);
// Logging the given skill.
st.saveGlobalQuestVar(varName + i, skill.getId() + ";");
}
return;
}
}
else
{
_log.warning("Inexistent item for object Id " + itemObjId + ", for Sub-Class skill Id: " + _id + " level: " + _level + " for player " + activeChar.getName() + "!");
}
}
else
{
_log.warning("Invalid item object Id " + itemOID + ", for Sub-Class skill Id: " + _id + " level: " + _level + " for player " + activeChar.getName() + "!");
}
}
}
}
// Player doesn't have required item.
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ITEM_MISSING_TO_LEARN_SKILL));
showSkillList(trainer, activeChar);
break;
}
case Collect:
{
final L2SkillLearn s = SkillTreesData.getInstance().getCollectSkill(_id, _level);
if (checkPlayerSkill(activeChar, trainer, s))
{
giveSkill(activeChar, trainer, skill);
}
break;
}
default:
{
_log.warning("Recived Wrong Packet Data in Aquired Skill, unknown skill type:" + _skillType);
}
}
}
/**
* 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_DONT_MEET_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() + "!", 0);
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.NOT_ENOUGH_SP_TO_LEARN_SKILL);
showSkillList(trainer, player);
return false;
}
if (!Config.DIVINE_SP_BOOK_NEEDED && (_id == L2Skill.SKILL_DIVINE_INSPIRATION))
{
return true;
}
if (s.getItemsIdCount() != null)
{
// Then checks that the player has all the items
long reqItemCount = 0;
for (int[] itemIdCount : s.getItemsIdCount())
{
reqItemCount = player.getInventory().getInventoryItemCount(itemIdCount[0], -1);
if (reqItemCount < itemIdCount[1])
{
// Player doesn't have required item.
player.sendPacket(SystemMessageId.ITEM_MISSING_TO_LEARN_SKILL);
showSkillList(trainer, player);
return false;
}
}
// If the player has all required items, they are consumed.
for (int[] itemIdCount : s.getItemsIdCount())
{
if (!player.destroyItemByItemId("SkillLearn", itemIdCount[0], itemIdCount[1], trainer, true))
{
Util.handleIllegalPlayerAction(player, "Somehow player " + player.getName() + ", level " + player.getLevel() + " lose required item Id: " + itemIdCount[0] + " to learn skill while learning skill Id: " + _id + " level " + _level + "!", 0);
}
}
}
// If the player has SP and all required items then consume SP.
if (levelUpSp > 0)
{
player.setSp(player.getSp() - levelUpSp);
final StatusUpdate su = new StatusUpdate(player);
su.addAttribute(StatusUpdate.SP, player.getSp());
player.sendPacket(su);
}
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, L2Skill skill)
{
// Send message.
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.LEARNED_SKILL_S1);
sm.addSkillName(skill);
player.sendPacket(sm);
player.sendPacket(new AcquireSkillDone());
player.addSkill(skill, true);
player.sendSkillList();
updateShortCuts(player);
showSkillList(trainer, player);
// If skill is expand type then sends packet:
if ((_id >= 1368) && (_id <= 1372))
{
player.sendPacket(new ExStorageMaxCount(player));
}
}
/**
* Updates the shortcut bars with the new acquired skill.
* @param player the player that needs a shortcut update.
*/
private void updateShortCuts(L2PcInstance player)
{
// Update all the shortcuts for this skill
if (_level > 1)
{
final L2ShortCut[] allShortCuts = player.getAllShortCuts();
for (L2ShortCut sc : allShortCuts)
{
if ((sc.getId() == _id) && (sc.getType() == L2ShortCut.TYPE_SKILL))
{
L2ShortCut newsc = new L2ShortCut(sc.getSlot(), sc.getPage(), sc.getType(), sc.getId(), _level, 1);
player.sendPacket(new ShortCutRegister(newsc));
player.registerShortCut(newsc);
}
}
}
}
/**
* 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 ((trainer instanceof L2TrainerHealersInstance) && (_skillType == SkillType.Transfer.ordinal()))
{
L2TrainerHealersInstance.showTransferSkillList(player);
}
else if (trainer instanceof L2FishermanInstance)
{
L2FishermanInstance.showFishSkillList(player);
}
else if ((trainer instanceof L2TransformManagerInstance) && (_skillType == SkillType.ClassTransform.ordinal()))
{
L2TransformManagerInstance.showTransformSkillList(player);
}
else if ((trainer instanceof L2TransformManagerInstance) && (_skillType == SkillType.SubClass.ordinal()))
{
L2TransformManagerInstance.showSubClassSkillList(player);
}
else
{
L2NpcInstance.showSkillList(player, trainer, player.getLearningClass());
}
}
@Override
public String getType()
{
return _C__7C_REQUESTACQUIRESKILL;
}
}
@@ -0,0 +1,333 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.SkillTable;
import com.l2jserver.gameserver.datatables.SkillTreesData;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.L2SkillLearn;
import com.l2jserver.gameserver.model.L2SquadTrainer;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2NpcInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.actor.instance.L2TransformManagerInstance;
import com.l2jserver.gameserver.network.serverpackets.AcquireSkillInfo;
import com.l2jserver.gameserver.network.serverpackets.AcquireSkillList.SkillType;
/**
* @author Zoey76
*/
public final class RequestAcquireSkillInfo extends L2GameClientPacket
{
private static final String _C__6B_REQUESTACQUIRESKILLINFO = "[C] 6B RequestAcquireSkillInfo";
private static final Logger _log = Logger.getLogger(RequestAcquireSkillInfo.class.getName());
private int _id;
private int _level;
private int _skillType;
@Override
protected void readImpl()
{
_id = readD();
_level = readD();
_skillType = readD();
}
@Override
protected void runImpl()
{
if ((_id <= 0) || (_level <= 0))
{
return;
}
final L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
final L2Npc trainer = activeChar.getLastFolkNPC();
if (!(trainer instanceof L2NpcInstance))
{
return;
}
if (!trainer.canInteract(activeChar) && !activeChar.isGM())
{
return;
}
final L2Skill skill = SkillTable.getInstance().getInfo(_id, _level);
if (skill == null)
{
_log.warning(RequestAcquireSkillInfo.class.getSimpleName() + ": Skill Id: " + _id + " level: " + _level + " is undefined. " + RequestAcquireSkillInfo.class.getName() + " failed.");
return;
}
final SkillType skillType = SkillType.values()[_skillType];
// Doesn't apply to all Skill Types
if (((skillType != SkillType.Transfer) && ((_level > 1) && (activeChar.getKnownSkill(_id) == null))) || ((activeChar.getKnownSkill(_id) != null) && (activeChar.getKnownSkill(_id).getLevel() != (_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!");
}
switch (skillType)
{
case ClassTransform:
{
if (trainer instanceof L2TransformManagerInstance)
{
final L2SkillLearn s = SkillTreesData.getInstance().getTransformSkill(_id, _level);
if (s != null)
{
int itemId = -1;
int itemCount = -1;
final int levelUpSp = s.getLevelUpSp();
final AcquireSkillInfo asi = new AcquireSkillInfo(_id, _level, levelUpSp, SkillType.ClassTransform);
if (s.getItemsIdCount() != null)
{
for (int[] itemIdCount : s.getItemsIdCount())
{
itemId = itemIdCount[0];
itemCount = itemIdCount[1];
if ((itemId > 0) && (itemCount > 0))
{
asi.addRequirement(99, itemId, itemCount, 50);
}
}
}
sendPacket(asi);
}
return;
}
else if (trainer.getTemplate().canTeach(activeChar.getLearningClass()))
{
final L2SkillLearn s = SkillTreesData.getInstance().getClassSkill(_id, _level, activeChar.getLearningClass());
if (s != null)
{
int itemId = -1;
int itemCount = -1;
final int levelUpSp = s.getCalculatedLevelUpSp(activeChar.getClassId(), activeChar.getLearningClass());
final AcquireSkillInfo asi = new AcquireSkillInfo(_id, _level, levelUpSp, SkillType.ClassTransform);
if (s.getItemsIdCount() != null)
{
for (int[] itemIdCount : s.getItemsIdCount())
{
if (!Config.DIVINE_SP_BOOK_NEEDED && (_id == L2Skill.SKILL_DIVINE_INSPIRATION))
{
continue;
}
itemId = itemIdCount[0];
itemCount = itemIdCount[1];
if ((itemId > 0) && (itemCount > 0))
{
asi.addRequirement(99, itemId, itemCount, 50);
}
}
}
sendPacket(asi);
}
}
break;
}
case Fishing:
{
final L2SkillLearn s = SkillTreesData.getInstance().getFishingSkill(_id, _level);
if (s != null)
{
int itemId = -1;
int itemCount = -1;
final int levelUpSp = s.getLevelUpSp();
final AcquireSkillInfo asi = new AcquireSkillInfo(_id, _level, levelUpSp, SkillType.Fishing);
for (int[] itemIdCount : s.getItemsIdCount())
{
itemId = itemIdCount[0];
itemCount = itemIdCount[1];
if ((itemId > 0) && (itemCount > 0))
{
asi.addRequirement(4, itemId, itemCount, 0);
}
}
sendPacket(asi);
}
break;
}
case Pledge:
{
if (!activeChar.isClanLeader())
{
return;
}
final L2SkillLearn s = SkillTreesData.getInstance().getPledgeSkill(_id, _level);
if (s != null)
{
int itemId = -1;
int itemCount = -1;
final int requiredRep = s.getLevelUpSp();
final AcquireSkillInfo asi = new AcquireSkillInfo(_id, _level, requiredRep, SkillType.Pledge);
if (Config.LIFE_CRYSTAL_NEEDED)
{
for (int[] itemIdCount : s.getItemsIdCount())
{
itemId = itemIdCount[0];
itemCount = itemIdCount[1];
if ((itemId > 0) && (itemCount > 0))
{
asi.addRequirement(1, itemId, itemCount, 0);
}
}
}
sendPacket(asi);
}
break;
}
case SubPledge:
{
if (!activeChar.isClanLeader())
{
return;
}
if (trainer instanceof L2SquadTrainer)
{
final L2SkillLearn s = SkillTreesData.getInstance().getSubPledgeSkill(_id, _level);
if (s != null)
{
int itemId = -1;
int itemCount = -1;
final int levelUpSp = s.getLevelUpSp();
final AcquireSkillInfo asi = new AcquireSkillInfo(_id, _level, levelUpSp, SkillType.SubPledge);
for (int[] itemIdCount : s.getItemsIdCount())
{
itemId = itemIdCount[0];
itemCount = itemIdCount[1];
if ((itemId > 0) && (itemCount > 0))
{
asi.addRequirement(0, itemId, itemCount, 0);
}
}
sendPacket(asi);
}
}
break;
}
case SubClass:
{
final L2SkillLearn s = SkillTreesData.getInstance().getSubClassSkill(_id, _level);
if (s != null)
{
int itemId = -1;
int itemCount = -1;
final int levelUpSp = s.getLevelUpSp();
final AcquireSkillInfo asi = new AcquireSkillInfo(_id, _level, levelUpSp, SkillType.SubClass);
for (int[] itemIdCount : s.getItemsIdCount())
{
itemId = itemIdCount[0];
itemCount = itemIdCount[1];
if ((itemId > 0) && (itemCount > 0))
{
asi.addRequirement(99, itemId, itemCount, 50);
}
}
sendPacket(asi);
}
break;
}
case Collect:
{
final L2SkillLearn s = SkillTreesData.getInstance().getCollectSkill(_id, _level);
if (s != null)
{
int itemId = -1;
int itemCount = -1;
final int levelUpSp = s.getLevelUpSp();
final AcquireSkillInfo asi = new AcquireSkillInfo(_id, _level, levelUpSp, SkillType.Collect);
for (int[] itemIdCount : s.getItemsIdCount())
{
itemId = itemIdCount[0];
itemCount = itemIdCount[1];
if ((itemId > 0) && (itemCount > 0))
{
asi.addRequirement(6, itemId, itemCount, 0);
}
}
sendPacket(asi);
}
break;
}
case Transfer:
{
final L2SkillLearn s = SkillTreesData.getInstance().getTransferSkill(_id, _level, activeChar.getClassId());
if (s != null)
{
int itemId = -1;
int itemCount = -1;
final int levelUpSp = s.getLevelUpSp();
final AcquireSkillInfo asi = new AcquireSkillInfo(_id, _level, levelUpSp, SkillType.Transfer);
for (int[] itemIdCount : s.getItemsIdCount())
{
itemId = itemIdCount[0];
itemCount = itemIdCount[1];
if ((itemId > 0) && (itemCount > 0))
{
asi.addRequirement(4, itemId, itemCount, 0);
}
}
sendPacket(asi);
}
else
{
_log.warning(RequestAcquireSkillInfo.class.getSimpleName() + ": Null L2SkillLearn for id: " + _id + " and level " + _level + " in Transfer Skill Tree for skill learning class " + activeChar.getClassId() + "!");
}
break;
}
}
}
@Override
public String getType()
{
return _C__6B_REQUESTACQUIRESKILLINFO;
}
}
@@ -0,0 +1,989 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.util.Arrays;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.GameTimeController;
import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.ai.L2SummonAI;
import com.l2jserver.gameserver.datatables.PetDataTable;
import com.l2jserver.gameserver.datatables.SkillTable;
import com.l2jserver.gameserver.datatables.SummonSkillsTable;
import com.l2jserver.gameserver.instancemanager.AirShipManager;
import com.l2jserver.gameserver.instancemanager.CastleManager;
import com.l2jserver.gameserver.instancemanager.TerritoryWarManager;
import com.l2jserver.gameserver.model.L2CharPosition;
import com.l2jserver.gameserver.model.L2ManufactureList;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Summon;
import com.l2jserver.gameserver.model.actor.instance.L2BabyPetInstance;
import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PetInstance;
import com.l2jserver.gameserver.model.actor.instance.L2SiegeFlagInstance;
import com.l2jserver.gameserver.model.actor.instance.L2SiegeSummonInstance;
import com.l2jserver.gameserver.model.actor.instance.L2StaticObjectInstance;
import com.l2jserver.gameserver.model.actor.instance.L2SummonInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.ChairSit;
import com.l2jserver.gameserver.network.serverpackets.ExAskCoupleAction;
import com.l2jserver.gameserver.network.serverpackets.ExBasicActionList;
import com.l2jserver.gameserver.network.serverpackets.RecipeShopManageList;
import com.l2jserver.gameserver.network.serverpackets.SocialAction;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* This class ...
* @version $Revision: 1.11.2.7.2.9 $ $Date: 2005/04/06 16:13:48 $
*/
public final class RequestActionUse extends L2GameClientPacket
{
private static final String _C__45_REQUESTACTIONUSE = "[C] 45 RequestActionUse";
private static Logger _log = Logger.getLogger(RequestActionUse.class.getName());
private int _actionId;
private boolean _ctrlPressed;
private boolean _shiftPressed;
@Override
protected void readImpl()
{
_actionId = readD();
_ctrlPressed = (readD() == 1);
_shiftPressed = (readC() == 1);
}
@Override
protected void runImpl()
{
L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
if (Config.DEBUG)
{
_log.finest(activeChar.getName() + " request Action use: id " + _actionId + " 2:" + _ctrlPressed + " 3:" + _shiftPressed);
}
// dont do anything if player is dead
if (activeChar.isAlikeDead() || activeChar.isDead())
{
getClient().sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// don't do anything if player is confused
if (activeChar.isOutOfControl())
{
getClient().sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// don't allow to do some action if player is transformed
if (activeChar.isTransformed())
{
int[] allowedActions = activeChar.isTransformed() ? ExBasicActionList._actionsOnTransform : ExBasicActionList._defaultActionList;
if (!(Arrays.binarySearch(allowedActions, _actionId) >= 0))
{
getClient().sendPacket(ActionFailed.STATIC_PACKET);
_log.info("Player " + activeChar + " used action which he does not have! id = " + _actionId + " transform: " + activeChar.getTransformation());
return;
}
}
L2Summon pet = activeChar.getPet();
L2Object target = activeChar.getTarget();
if (Config.DEBUG)
{
_log.info("Requested Action ID: " + String.valueOf(_actionId));
}
switch (_actionId)
{
case 0: // Sit/Stand
if (activeChar.getMountType() != 0)
{
break;
}
if ((target != null) && !activeChar.isSitting() && (target instanceof L2StaticObjectInstance) && (((L2StaticObjectInstance) target).getType() == 1) && (CastleManager.getInstance().getCastle(target) != null) && activeChar.isInsideRadius(target, L2StaticObjectInstance.INTERACTION_DISTANCE, false, false))
{
ChairSit cs = new ChairSit(activeChar, ((L2StaticObjectInstance) target).getStaticObjectId());
activeChar.sendPacket(cs);
activeChar.sitDown();
activeChar.broadcastPacket(cs);
break;
}
if (activeChar.isSitting())
{
activeChar.standUp();
}
else
{
activeChar.sitDown();
}
if (Config.DEBUG)
{
_log.fine("new wait type: " + (activeChar.isSitting() ? "SITTING" : "STANDING"));
}
break;
case 1: // Walk/Run
if (activeChar.isRunning())
{
activeChar.setWalking();
}
else
{
activeChar.setRunning();
}
if (Config.DEBUG)
{
_log.fine("new move type: " + (activeChar.isRunning() ? "RUNNING" : "WALKIN"));
}
break;
case 10: // Private Store - Sell
activeChar.tryOpenPrivateSellStore(false);
break;
case 28: // Private Store - Buy
activeChar.tryOpenPrivateBuyStore();
break;
case 15:
case 21: // Change Movement Mode (pet follow/stop)
if ((pet != null) && !activeChar.isBetrayed())
{
((L2SummonAI) pet.getAI()).notifyFollowStatusChange();
}
break;
case 16:
case 22: // Attack (pet attack)
if ((target != null) && (pet != null) && (pet != target) && (activeChar != target) && !pet.isBetrayed())
{
if (pet.isAttackingDisabled())
{
if (pet.getAttackEndTime() > GameTimeController.getGameTicks())
{
pet.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
}
else
{
return;
}
}
if ((pet instanceof L2PetInstance) && ((pet.getLevel() - activeChar.getLevel()) > 20))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.PET_TOO_HIGH_TO_CONTROL));
return;
}
if (activeChar.isInOlympiadMode() && !activeChar.isOlympiadStart())
{
// if L2PcInstance is in Olympia and the match isn't already start, send a Server->Client packet ActionFailed
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if ((target.getActingPlayer() != null) && (pet.getOwner().getSiegeState() > 0) && pet.getOwner().isInsideZone(L2Character.ZONE_SIEGE) && (target.getActingPlayer().getSiegeState() == pet.getOwner().getSiegeState()) && (target.getActingPlayer() != pet.getOwner()) && (target.getActingPlayer().getSiegeSide() == pet.getOwner().getSiegeSide()))
{
//
if (TerritoryWarManager.getInstance().isTWInProgress())
{
sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_CANNOT_ATTACK_A_MEMBER_OF_THE_SAME_TERRITORY));
}
else
{
sendPacket(SystemMessage.getSystemMessage(SystemMessageId.FORCED_ATTACK_IS_IMPOSSIBLE_AGAINST_SIEGE_SIDE_TEMPORARY_ALLIED_MEMBERS));
}
sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if (!activeChar.getAccessLevel().allowPeaceAttack() && activeChar.isInsidePeaceZone(pet, target))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.TARGET_IN_PEACEZONE));
return;
}
if ((pet.getNpcId() == 12564) || (pet.getNpcId() == 12621))
{
// sin eater and wyvern can't attack with attack button
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if (pet.isLockedTarget())
{
pet.getOwner().sendPacket(SystemMessage.getSystemMessage(SystemMessageId.FAILED_CHANGE_TARGET));
return;
}
pet.setTarget(target);
if (target.isAutoAttackable(activeChar) || _ctrlPressed)
{
if (target instanceof L2DoorInstance)
{
if (((L2DoorInstance) target).isAttackable(activeChar) && (pet.getNpcId() != L2SiegeSummonInstance.SWOOP_CANNON_ID))
{
pet.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
}
}
// siege golem AI doesn't support attacking other than doors at the moment
else if (pet.getNpcId() != L2SiegeSummonInstance.SIEGE_GOLEM_ID)
{
pet.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
}
}
else
{
pet.setFollowStatus(false);
pet.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, target);
}
}
break;
case 17:
case 23: // Stop (pet - cancel action)
if ((pet != null) && !pet.isMovementDisabled() && !pet.isBetrayed())
{
pet.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE, null);
}
break;
case 19: // Unsummon Pet
if (pet != null)
{
// returns pet to control item
if (pet.isDead())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.DEAD_PET_CANNOT_BE_RETURNED));
}
else if (pet.isAttackingNow() || pet.isInCombat() || pet.isMovementDisabled() || pet.isBetrayed())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.PET_CANNOT_SENT_BACK_DURING_BATTLE));
}
else
{
// if it is a pet and not a summon
if (pet instanceof L2PetInstance)
{
if (!pet.isHungry())
{
pet.unSummon(activeChar);
}
else if (((L2PetInstance) pet).getPetData().getFood().length > 0)
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_CANNOT_RESTORE_HUNGRY_PETS));
}
else
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THE_HELPER_PET_CANNOT_BE_RETURNED));
}
}
}
}
break;
case 38: // Mount/Dismount
activeChar.mountPlayer(pet);
break;
case 32: // Wild Hog Cannon - Switch Mode
// useSkill(4230);
break;
case 36: // Soulless - Toxic Smoke
useSkill(4259);
break;
case 37: // Dwarven Manufacture
if (activeChar.isAlikeDead())
{
getClient().sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if (activeChar.getPrivateStoreType() != 0)
{
activeChar.setPrivateStoreType(L2PcInstance.STORE_PRIVATE_NONE);
activeChar.broadcastUserInfo();
}
if (activeChar.isSitting())
{
activeChar.standUp();
}
if (activeChar.getCreateList() == null)
{
activeChar.setCreateList(new L2ManufactureList());
}
activeChar.sendPacket(new RecipeShopManageList(activeChar, true));
break;
case 39: // Soulless - Parasite Burst
useSkill(4138);
break;
case 41: // Wild Hog Cannon - Attack
if ((target != null) && ((target instanceof L2DoorInstance) || (target instanceof L2SiegeFlagInstance)))
{
useSkill(4230);
}
else
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
}
break;
case 42: // Kai the Cat - Self Damage Shield
useSkill(4378, activeChar);
break;
case 43: // Unicorn Merrow - Hydro Screw
useSkill(4137);
break;
case 44: // Big Boom - Boom Attack
useSkill(4139);
break;
case 45: // Unicorn Boxer - Master Recharge
useSkill(4025, activeChar);
break;
case 46: // Mew the Cat - Mega Storm Strike
useSkill(4261);
break;
case 47: // Silhouette - Steal Blood
useSkill(4260);
break;
case 48: // Mechanic Golem - Mech. Cannon
useSkill(4068);
break;
case 51: // General Manufacture
// Player shouldn't be able to set stores if he/she is alike dead (dead or fake death)
if (activeChar.isAlikeDead())
{
getClient().sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if (activeChar.getPrivateStoreType() != 0)
{
activeChar.setPrivateStoreType(L2PcInstance.STORE_PRIVATE_NONE);
activeChar.broadcastUserInfo();
}
if (activeChar.isSitting())
{
activeChar.standUp();
}
if (activeChar.getCreateList() == null)
{
activeChar.setCreateList(new L2ManufactureList());
}
activeChar.sendPacket(new RecipeShopManageList(activeChar, false));
break;
case 52: // Unsummon
if ((pet != null) && (pet instanceof L2SummonInstance))
{
if (pet.isBetrayed())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.PET_REFUSING_ORDER));
}
else if (pet.isAttackingNow() || pet.isInCombat())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.PET_CANNOT_SENT_BACK_DURING_BATTLE));
}
else
{
pet.unSummon(activeChar);
}
}
break;
case 53: // Move to target
if ((target != null) && (pet != null) && (pet != target) && !pet.isMovementDisabled() && !pet.isBetrayed())
{
pet.setFollowStatus(false);
pet.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(target.getX(), target.getY(), target.getZ(), 0));
}
break;
case 54: // Move to target hatch/strider
if ((target != null) && (pet != null) && (pet != target) && !pet.isMovementDisabled() && !pet.isBetrayed())
{
pet.setFollowStatus(false);
pet.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(target.getX(), target.getY(), target.getZ(), 0));
}
break;
case 61: // Private Store Package Sell
activeChar.tryOpenPrivateSellStore(true);
break;
case 65: // Bot Report Button
activeChar.sendMessage("Action not handled yet.");
break;
case 67: // Steer
if (activeChar.isInAirShip())
{
if (activeChar.getAirShip().setCaptain(activeChar))
{
activeChar.broadcastUserInfo();
}
}
break;
case 68: // Cancel Control
if (activeChar.isInAirShip() && activeChar.getAirShip().isCaptain(activeChar))
{
if (activeChar.getAirShip().setCaptain(null))
{
activeChar.broadcastUserInfo();
}
}
break;
case 69: // Destination Map
AirShipManager.getInstance().sendAirShipTeleportList(activeChar);
break;
case 70: // Exit Airship
if (activeChar.isInAirShip())
{
if (activeChar.getAirShip().isCaptain(activeChar))
{
if (activeChar.getAirShip().setCaptain(null))
{
activeChar.broadcastUserInfo();
}
}
else if (activeChar.getAirShip().isInDock())
{
activeChar.getAirShip().oustPlayer(activeChar);
}
}
break;
case 71:
case 72:
case 73:
useCoupleSocial(_actionId - 55);
break;
case 1000: // Siege Golem - Siege Hammer
if (target instanceof L2DoorInstance)
{
useSkill(4079);
}
break;
case 1001: // TODO Sin Eater - Ultimate Bombastic Buster
break;
case 1003: // Wind Hatchling/Strider - Wild Stun
useSkill(4710);
break;
case 1004: // Wind Hatchling/Strider - Wild Defense
useSkill(4711, activeChar);
break;
case 1005: // Star Hatchling/Strider - Bright Burst
useSkill(4712);
break;
case 1006: // Star Hatchling/Strider - Bright Heal
useSkill(4713, activeChar);
break;
case 1007: // Cat Queen - Blessing of Queen
useSkill(4699, activeChar);
break;
case 1008: // Cat Queen - Gift of Queen
useSkill(4700, activeChar);
break;
case 1009: // Cat Queen - Cure of Queen
useSkill(4701);
break;
case 1010: // Unicorn Seraphim - Blessing of Seraphim
useSkill(4702, activeChar);
break;
case 1011: // Unicorn Seraphim - Gift of Seraphim
useSkill(4703, activeChar);
break;
case 1012: // Unicorn Seraphim - Cure of Seraphim
useSkill(4704);
break;
case 1013: // Nightshade - Curse of Shade
useSkill(4705);
break;
case 1014: // Nightshade - Mass Curse of Shade
useSkill(4706);
break;
case 1015: // Nightshade - Shade Sacrifice
useSkill(4707);
break;
case 1016: // Cursed Man - Cursed Blow
useSkill(4709);
break;
case 1017: // Cursed Man - Cursed Strike/Stun
useSkill(4708);
break;
case 1031: // Feline King - Slash
useSkill(5135);
break;
case 1032: // Feline King - Spinning Slash
useSkill(5136);
break;
case 1033: // Feline King - Grip of the Cat
useSkill(5137);
break;
case 1034: // Magnus the Unicorn - Whiplash
useSkill(5138);
break;
case 1035: // Magnus the Unicorn - Tridal Wave
useSkill(5139);
break;
case 1036: // Spectral Lord - Corpse Kaboom
useSkill(5142);
break;
case 1037: // Spectral Lord - Dicing Death
useSkill(5141);
break;
case 1038: // Spectral Lord - Force Curse
useSkill(5140);
break;
case 1039: // Swoop Cannon - Cannon Fodder
if (!(target instanceof L2DoorInstance))
{
useSkill(5110);
}
break;
case 1040: // Swoop Cannon - Big Bang
if (!(target instanceof L2DoorInstance))
{
useSkill(5111);
}
break;
case 1041: // Great Wolf - Bite Attack
useSkill(5442);
break;
case 1042: // Great Wolf - Maul
useSkill(5444);
break;
case 1043: // Great Wolf - Cry of the Wolf
useSkill(5443);
break;
case 1044: // Great Wolf - Awakening
useSkill(5445);
break;
case 1045: // Great Wolf - Howl
useSkill(5584);
break;
case 1046: // Strider - Roar
useSkill(5585);
break;
case 1047: // Divine Beast - Bite
useSkill(5580);
break;
case 1048: // Divine Beast - Stun Attack
useSkill(5581);
break;
case 1049: // Divine Beast - Fire Breath
useSkill(5582);
break;
case 1050: // Divine Beast - Roar
useSkill(5583);
break;
case 1051: // Feline Queen - Bless The Body
useSkill(5638);
break;
case 1052: // Feline Queen - Bless The Soul
useSkill(5639);
break;
case 1053: // Feline Queen - Haste
useSkill(5640);
break;
case 1054: // Unicorn Seraphim - Acumen
useSkill(5643);
break;
case 1055: // Unicorn Seraphim - Clarity
useSkill(5647);
break;
case 1056: // Unicorn Seraphim - Empower
useSkill(5648);
break;
case 1057: // Unicorn Seraphim - Wild Magic
useSkill(5646);
break;
case 1058: // Nightshade - Death Whisper
useSkill(5652);
break;
case 1059: // Nightshade - Focus
useSkill(5653);
break;
case 1060: // Nightshade - Guidance
useSkill(5654);
break;
case 1061: // Wild Beast Fighter, White Weasel - Death blow
useSkill(5745);
break;
case 1062: // Wild Beast Fighter - Double attack
useSkill(5746);
break;
case 1063: // Wild Beast Fighter - Spin attack
useSkill(5747);
break;
case 1064: // Wild Beast Fighter - Meteor Shower
useSkill(5748);
break;
case 1065: // Fox Shaman, Wild Beast Fighter, White Weasel, Fairy Princess - Awakening
useSkill(5753);
break;
case 1066: // Fox Shaman, Spirit Shaman - Thunder Bolt
useSkill(5749);
break;
case 1067: // Fox Shaman, Spirit Shaman - Flash
useSkill(5750);
break;
case 1068: // Fox Shaman, Spirit Shaman - Lightning Wave
useSkill(5751);
break;
case 1069: // Fox Shaman, Fairy Princess - Flare
useSkill(5752);
break;
case 1070: // White Weasel, Fairy Princess, Improved Baby Buffalo, Improved Baby Kookaburra, Improved Baby Cougar, Spirit Shaman, Toy Knight, Turtle Ascetic - Buff control
useSkill(5771);
break;
case 1071: // Tigress - Power Strike
useSkill(5761);
break;
case 1072: // Toy Knight - Piercing attack
useSkill(6046);
break;
case 1073: // Toy Knight - Whirlwind
useSkill(6047);
break;
case 1074: // Toy Knight - Lance Smash
useSkill(6048);
break;
case 1075: // Toy Knight - Battle Cry
useSkill(6049);
break;
case 1076: // Turtle Ascetic - Power Smash
useSkill(6050);
break;
case 1077: // Turtle Ascetic - Energy Burst
useSkill(6051);
break;
case 1078: // Turtle Ascetic - Shockwave
useSkill(6052);
break;
case 1079: // Turtle Ascetic - Howl
useSkill(6053);
break;
case 1080: // Phoenix Rush
useSkill(6041);
break;
case 1081: // Phoenix Cleanse
useSkill(6042);
break;
case 1082: // Phoenix Flame Feather
useSkill(6043);
break;
case 1083: // Phoenix Flame Beak
useSkill(6044);
break;
case 1084: // Switch State
// useSkill(6054);
if ((pet != null) && (pet instanceof L2BabyPetInstance))
{
((L2BabyPetInstance) pet).switchMode();
}
break;
case 1086: // Panther Cancel
useSkill(6094);
break;
case 1087: // Panther Dark Claw
useSkill(6095);
break;
case 1088: // Panther Fatal Claw
useSkill(6096);
break;
case 1089: // Deinonychus - Tail Strike
useSkill(6199);
break;
case 1090: // Guardian's Strider - Strider Bite
useSkill(6205);
break;
case 1091: // Guardian's Strider - Strider Fear
useSkill(6206);
break;
case 1092: // Guardian's Strider - Strider Dash
useSkill(6207);
break;
case 1093: // Maguen - Maguen Strike
useSkill(6618);
break;
case 1094: // Maguen - Maguen Wind Walk
useSkill(6681);
break;
case 1095: // Elite Maguen - Maguen Power Strike
useSkill(6619);
break;
case 1096: // Elite Maguen - Elite Maguen Wind Walk
useSkill(6682);
break;
case 1097: // Maguen - Maguen Return
useSkill(6683);
break;
case 1098: // Elite Maguen - Maguen Party Return
useSkill(6684);
break;
case 5000: // Baby Rudolph - Reindeer Scratch
useSkill(23155);
break;
case 5001: // Deseloph, Hyum, Rekang, Lilias, Lapham, Mafum - Rosy Seduction
useSkill(23167);
break;
case 5002: // Deseloph, Hyum, Rekang, Lilias, Lapham, Mafum - Critical Seduction
useSkill(23168);
break;
case 5003: // Hyum, Lapham, Hyum, Lapham - Thunder Bolt
useSkill(5749);
break;
case 5004: // Hyum, Lapham, Hyum, Lapham - Flash
useSkill(5750);
break;
case 5005: // Hyum, Lapham, Hyum, Lapham - Lightning Wave
useSkill(5751);
break;
case 5006: // Deseloph, Hyum, Rekang, Lilias, Lapham, Mafum, Deseloph, Hyum, Rekang, Lilias, Lapham, Mafum - Buff Control
useSkill(5771);
break;
case 5007: // Deseloph, Lilias, Deseloph, Lilias - Piercing Attack
useSkill(6046);
break;
case 5008: // Deseloph, Lilias, Deseloph, Lilias - Spin Attack
useSkill(6047);
break;
case 5009: // Deseloph, Lilias, Deseloph, Lilias - Smash
useSkill(6048);
break;
case 5010: // Deseloph, Lilias, Deseloph, Lilias - Ignite
useSkill(6049);
break;
case 5011: // Rekang, Mafum, Rekang, Mafum - Power Smash
useSkill(6050);
break;
case 5012: // Rekang, Mafum, Rekang, Mafum - Energy Burst
useSkill(6051);
break;
case 5013: // Rekang, Mafum, Rekang, Mafum - Shockwave
useSkill(6052);
break;
case 5014: // Rekang, Mafum, Rekang, Mafum - Ignite
useSkill(6053);
break;
case 5015: // Deseloph, Hyum, Rekang, Lilias, Lapham, Mafum, Deseloph, Hyum, Rekang, Lilias, Lapham, Mafum - Switch Stance
useSkill(6054);
break;
// Social Packets
case 12: // Greeting
tryBroadcastSocial(2);
break;
case 13: // Victory
tryBroadcastSocial(3);
break;
case 14: // Advance
tryBroadcastSocial(4);
break;
case 24: // Yes
tryBroadcastSocial(6);
break;
case 25: // No
tryBroadcastSocial(5);
break;
case 26: // Bow
tryBroadcastSocial(7);
break;
case 29: // Unaware
tryBroadcastSocial(8);
break;
case 30: // Social Waiting
tryBroadcastSocial(9);
break;
case 31: // Laugh
tryBroadcastSocial(10);
break;
case 33: // Applaud
tryBroadcastSocial(11);
break;
case 34: // Dance
tryBroadcastSocial(12);
break;
case 35: // Sorrow
tryBroadcastSocial(13);
break;
case 62: // Charm
tryBroadcastSocial(14);
break;
case 66: // Shyness
tryBroadcastSocial(15);
break;
default:
_log.warning(activeChar.getName() + ": unhandled action type " + _actionId);
}
}
/*
* Cast a skill for active pet/servitor. Target is specified as a parameter but can be overwrited or ignored depending on skill type.
*/
private void useSkill(int skillId, L2Object target)
{
L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
L2Summon activeSummon = activeChar.getPet();
if (activeChar.getPrivateStoreType() != 0)
{
activeChar.sendMessage("Cannot use skills while trading");
return;
}
if ((activeSummon != null) && !activeSummon.isBetrayed())
{
int lvl = 0;
if (activeSummon instanceof L2PetInstance)
{
if ((activeSummon.getLevel() - activeChar.getLevel()) > 20)
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.PET_TOO_HIGH_TO_CONTROL));
return;
}
lvl = PetDataTable.getInstance().getPetData(activeSummon.getNpcId()).getAvailableLevel(skillId, activeSummon.getLevel());
}
else
{
lvl = SummonSkillsTable.getInstance().getAvailableLevel(activeSummon, skillId);
}
if (lvl == 0)
{
_log.warning("Pet " + activeSummon + " does not have the skill id " + skillId + " assigned.");
return;
}
L2Skill skill = SkillTable.getInstance().getInfo(skillId, lvl);
if (skill == null)
{
return;
}
if (skill.isOffensive() && (activeChar == target))
{
return;
}
activeSummon.setTarget(target);
activeSummon.useMagic(skill, _ctrlPressed, _shiftPressed);
}
}
/*
* Cast a skill for active pet/servitor. Target is retrieved from owner' target, then validated by overloaded method useSkill(int, L2Character).
*/
private void useSkill(int skillId)
{
L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
useSkill(skillId, activeChar.getTarget());
}
/*
* Check if player can broadcast SocialAction packet
*/
private void tryBroadcastSocial(int id)
{
L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
if (Config.DEBUG)
{
_log.fine("Social Action:" + id);
}
if (activeChar.isFishing())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_DO_WHILE_FISHING_3));
return;
}
if (activeChar.canMakeSocialAction())
{
activeChar.broadcastPacket(new SocialAction(activeChar, id));
}
}
private void useCoupleSocial(int id)
{
L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
L2Object target = activeChar.getTarget();
if (!(target instanceof L2PcInstance))
{
activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
return;
}
L2PcInstance player = (L2PcInstance) target;
if (activeChar.isFishing() || player.isFishing())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_DO_WHILE_FISHING_3));
return;
}
double distance = activeChar.getPlanDistanceSq(player);
if ((distance > 2000) || (distance < 70))
{
activeChar.sendPacket(SystemMessageId.TARGET_DO_NOT_MEET_LOC_REQUIREMENTS);
return;
}
if (activeChar.canMakeSocialAction() && player.canMakeSocialAction())
{
activeChar.setMultiSocialAction(id, player.getObjectId());
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_REQUESTED_COUPLE_ACTION_C1);
sm.addPcName(player);
activeChar.sendPacket(sm);
player.sendPacket(new ExAskCoupleAction(activeChar.getObjectId(), id));
}
else
{
// TODO appropriate message
activeChar.sendPacket(SystemMessageId.COUPLE_ACTION_CANCELED);
}
}
@Override
public String getType()
{
return _C__45_REQUESTACTIONUSE;
}
@Override
protected boolean triggersOnActionRequest()
{
return (_actionId != 10) && (_actionId != 28);
}
}
@@ -0,0 +1,57 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.network.L2GameClient;
import com.l2jserver.gameserver.network.serverpackets.ExShowAgitInfo;
/**
* @author KenM
*/
public class RequestAllAgitInfo extends L2GameClientPacket
{
/**
* @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#getType()
*/
@Override
public String getType()
{
return "[C] D0:41 RequestAllAgitInfo";
}
/**
* @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#readImpl()
*/
@Override
protected void readImpl()
{
}
/**
* @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#runImpl()
*/
@Override
protected void runImpl()
{
L2GameClient client = getClient();
if (client != null)
{
client.sendPacket(new ExShowAgitInfo());
}
}
}
@@ -0,0 +1,62 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.network.L2GameClient;
import com.l2jserver.gameserver.network.serverpackets.ExShowCastleInfo;
/**
* @author KenM
*/
public class RequestAllCastleInfo extends L2GameClientPacket
{
/**
* @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#getType()
*/
@Override
public String getType()
{
return "[C] D0:3F RequestAllCastleInfo";
}
/**
* @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#readImpl()
*/
@Override
protected void readImpl()
{
// trigger
}
/**
* @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#runImpl()
*/
@Override
protected void runImpl()
{
L2GameClient client = getClient();
if (client != null)
{
client.sendPacket(new ExShowCastleInfo());
}
}
@Override
protected boolean triggersOnActionRequest()
{
return false;
}
}
@@ -0,0 +1,62 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.network.L2GameClient;
import com.l2jserver.gameserver.network.serverpackets.ExShowFortressInfo;
/**
* @author KenM
*/
public class RequestAllFortressInfo extends L2GameClientPacket
{
/**
* @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#getType()
*/
@Override
public String getType()
{
return "[C] D0:3D RequestAllFortressInfo";
}
/**
* @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#readImpl()
*/
@Override
protected void readImpl()
{
// trigger packet
}
/**
* @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#runImpl()
*/
@Override
protected void runImpl()
{
L2GameClient client = getClient();
if (client != null)
{
client.sendPacket(new ExShowFortressInfo());
}
}
@Override
protected boolean triggersOnActionRequest()
{
return false;
}
}
@@ -0,0 +1,60 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.network.serverpackets.AllyCrest;
/**
* This class ...
* @version $Revision: 1.3.4.4 $ $Date: 2005/03/27 15:29:30 $
*/
public final class RequestAllyCrest extends L2GameClientPacket
{
private static final String _C__88_REQUESTALLYCREST = "[C] 88 RequestAllyCrest";
private int _crestId;
/**
* packet type id 0x88 format: cd
* @param rawPacket
*/
@Override
protected void readImpl()
{
_crestId = readD();
}
@Override
protected void runImpl()
{
sendPacket(new AllyCrest(_crestId));
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__88_REQUESTALLYCREST;
}
@Override
protected boolean triggersOnActionRequest()
{
return false;
}
}
@@ -0,0 +1,122 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.datatables.ClanTable;
import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.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__8E_REQUESTALLYINFO = "[C] 8E RequestAllyInfo";
@Override
public void readImpl()
{
}
@Override
protected void runImpl()
{
final L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
SystemMessage sm;
if (activeChar.getAllyId() == 0)
{
sm = SystemMessage.getSystemMessage(SystemMessageId.NO_CURRENT_ALLIANCES);
sendPacket(sm);
return;
}
sm = SystemMessage.getSystemMessage(SystemMessageId.ALLIANCE_INFO_HEAD);
sendPacket(sm);
sm = SystemMessage.getSystemMessage(SystemMessageId.ALLIANCE_NAME_S1);
sm.addString(activeChar.getClan().getAllyName());
sendPacket(sm);
int clanCount = 0;
int totalMembers = 0;
int onlineMembers = 0;
for (L2Clan clan : ClanTable.getInstance().getClans())
{
if (clan.getAllyId() != activeChar.getAllyId())
{
continue;
}
clanCount++;
totalMembers += clan.getMembersCount();
onlineMembers += clan.getOnlineMembersCount();
}
sm = SystemMessage.getSystemMessage(SystemMessageId.CONNECTION_S1_TOTAL_S2);
sm.addNumber(onlineMembers);
sm.addNumber(totalMembers);
sendPacket(sm);
final L2Clan leaderClan = ClanTable.getInstance().getClan(activeChar.getAllyId());
sm = SystemMessage.getSystemMessage(SystemMessageId.ALLIANCE_LEADER_S2_OF_S1);
sm.addString(leaderClan.getName());
sm.addString(leaderClan.getLeaderName());
sendPacket(sm);
sm = SystemMessage.getSystemMessage(SystemMessageId.ALLIANCE_CLAN_TOTAL_S1);
sm.addNumber(clanCount);
sendPacket(sm);
sm = SystemMessage.getSystemMessage(SystemMessageId.CLAN_INFO_HEAD);
for (L2Clan clan : ClanTable.getInstance().getClans())
{
if (clan.getAllyId() != activeChar.getAllyId())
{
continue;
}
sendPacket(sm); // send head or separator
sm = SystemMessage.getSystemMessage(SystemMessageId.CLAN_INFO_NAME_S1);
sm.addString(clan.getName());
sendPacket(sm);
sm = SystemMessage.getSystemMessage(SystemMessageId.CLAN_INFO_LEADER_S1);
sm.addString(clan.getLeaderName());
sendPacket(sm);
sm = SystemMessage.getSystemMessage(SystemMessageId.CLAN_INFO_LEVEL_S1);
sm.addNumber(clan.getLevel());
sendPacket(sm);
sm = SystemMessage.getSystemMessage(SystemMessageId.CLAN_INFO_SEPARATOR);
}
sm = SystemMessage.getSystemMessage(SystemMessageId.CLAN_INFO_FOOT);
sendPacket(sm);
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__8E_REQUESTALLYINFO;
}
}
@@ -0,0 +1,118 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.FriendPacket;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* sample 5F 01 00 00 00 format cdd
* @version $Revision: 1.7.4.2 $ $Date: 2005/03/27 15:29:30 $
*/
public final class RequestAnswerFriendInvite extends L2GameClientPacket
{
private static final String _C__5F_REQUESTANSWERFRIENDINVITE = "[C] 5F RequestAnswerFriendInvite";
private static Logger _log = Logger.getLogger(RequestAnswerFriendInvite.class.getName());
private int _response;
@Override
protected void readImpl()
{
_response = readD();
}
@Override
protected void runImpl()
{
L2PcInstance player = getClient().getActiveChar();
if (player != null)
{
L2PcInstance requestor = player.getActiveRequester();
if (requestor == null)
{
return;
}
if (_response == 1)
{
Connection con = null;
try
{
con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO character_friends (charId, friendId) VALUES (?, ?), (?, ?)");
statement.setInt(1, requestor.getObjectId());
statement.setInt(2, player.getObjectId());
statement.setInt(3, player.getObjectId());
statement.setInt(4, requestor.getObjectId());
statement.execute();
statement.close();
SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_SUCCEEDED_INVITING_FRIEND);
requestor.sendPacket(msg);
// Player added to your friendlist
msg = SystemMessage.getSystemMessage(SystemMessageId.S1_ADDED_TO_FRIENDS);
msg.addString(player.getName());
requestor.sendPacket(msg);
requestor.getFriendList().add(player.getObjectId());
// has joined as friend.
msg = SystemMessage.getSystemMessage(SystemMessageId.S1_JOINED_AS_FRIEND);
msg.addString(requestor.getName());
player.sendPacket(msg);
player.getFriendList().add(requestor.getObjectId());
// Send notificacions for both player in order to show them online
player.sendPacket(new FriendPacket(true, requestor.getObjectId()));
requestor.sendPacket(new FriendPacket(true, player.getObjectId()));
}
catch (Exception e)
{
_log.log(Level.WARNING, "Could not add friend objectid: " + e.getMessage(), e);
}
finally
{
L2DatabaseFactory.close(con);
}
}
else
{
SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.FAILED_TO_INVITE_A_FRIEND);
requestor.sendPacket(msg);
}
player.setActiveRequester(null);
requestor.onTransactionResponse();
}
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__5F_REQUESTANSWERFRIENDINVITE;
}
}
@@ -0,0 +1,106 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.datatables.ClanTable;
import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.communityserver.CommunityServerThread;
import com.l2jserver.gameserver.network.communityserver.writepackets.WorldInfo;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* sample 5F 01 00 00 00 format cdd
* @version $Revision: 1.7.4.2 $ $Date: 2005/03/27 15:29:30 $
*/
public final class RequestAnswerJoinAlly extends L2GameClientPacket
{
private static final String _C__83_REQUESTANSWERJOINALLY = "[C] 83 RequestAnswerJoinAlly";
// private static Logger _log = Logger.getLogger(RequestAnswerJoinAlly.class.getName());
private int _response;
@Override
protected void readImpl()
{
_response = readD();
}
@Override
protected void runImpl()
{
L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
L2PcInstance requestor = activeChar.getRequest().getPartner();
if (requestor == null)
{
return;
}
if (_response == 0)
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_DID_NOT_RESPOND_TO_ALLY_INVITATION));
requestor.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NO_RESPONSE_TO_ALLY_INVITATION));
}
else
{
if (!(requestor.getRequest().getRequestPacket() instanceof RequestJoinAlly))
{
return; // hax
}
L2Clan clan = requestor.getClan();
// we must double check this cause of hack
if (clan.checkAllyJoinCondition(requestor, activeChar))
{
// TODO: Need correct message id
requestor.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_SUCCEEDED_INVITING_FRIEND));
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_ACCEPTED_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();
for (L2Clan c : ClanTable.getInstance().getClans())
{
if (c.getAllyId() == clan.getAllyId())
{
// notify CB server about the change
CommunityServerThread.getInstance().sendPacket(new WorldInfo(null, c, WorldInfo.TYPE_UPDATE_CLAN_DATA));
}
}
}
}
activeChar.getRequest().onRequestResponse();
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__83_REQUESTANSWERJOINALLY;
}
}
@@ -0,0 +1,158 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.model.PartyMatchRoom;
import com.l2jserver.gameserver.model.PartyMatchRoomList;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ExManagePartyRoomMember;
import com.l2jserver.gameserver.network.serverpackets.JoinParty;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* sample 2a 01 00 00 00 format cdd
* @version $Revision: 1.7.4.2 $ $Date: 2005/03/27 15:29:30 $
*/
public final class RequestAnswerJoinParty extends L2GameClientPacket
{
private static final String _C__2A_REQUESTANSWERPARTY = "[C] 2A RequestAnswerJoinParty";
// private static Logger _log = Logger.getLogger(RequestAnswerJoinParty.class.getName());
private int _response;
@Override
protected void readImpl()
{
_response = readD();
}
@Override
protected void runImpl()
{
final L2PcInstance player = getClient().getActiveChar();
if (player == null)
{
return;
}
final L2PcInstance requestor = player.getActiveRequester();
if (requestor == null)
{
return;
}
requestor.sendPacket(new JoinParty(_response));
if (_response == 1)
{
if (requestor.isInParty())// Update by rocknow-Start
{
if (requestor.getParty().getMemberCount() >= 9)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.PARTY_FULL);
player.sendPacket(sm);
requestor.sendPacket(sm);
return;
}
}// Update by rocknow-End
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);
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();
}
}
}
}
else if (_response == -1)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_SET_TO_REFUSE_PARTY_REQUEST);
sm.addPcName(player);
requestor.sendPacket(sm);
// activate garbage collection if there are no other members in party (happens when we were creating new one)
if (requestor.isInParty() && (requestor.getParty().getMemberCount() == 1))
{
requestor.getParty().removePartyMember(requestor, false);
}
}
else
// 0
{
requestor.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.PLAYER_DECLINED));
// activate garbage collection if there are no other members in party (happens when we were creating new one)
if (requestor.isInParty() && (requestor.getParty().getMemberCount() == 1))
{
requestor.getParty().removePartyMember(requestor, false);
}
}
if (requestor.isInParty())
{
requestor.getParty().setPendingInvitation(false); // if party is null, there is no need of decreasing
}
player.setActiveRequester(null);
requestor.onTransactionResponse();
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__2A_REQUESTANSWERPARTY;
}
}
@@ -0,0 +1,137 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.instancemanager.CastleManager;
import com.l2jserver.gameserver.instancemanager.FortManager;
import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.JoinPledge;
import com.l2jserver.gameserver.network.serverpackets.PledgeShowInfoUpdate;
import com.l2jserver.gameserver.network.serverpackets.PledgeShowMemberListAdd;
import com.l2jserver.gameserver.network.serverpackets.PledgeShowMemberListAll;
import com.l2jserver.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__25_REQUESTANSWERJOINPLEDGE = "[C] 25 RequestAnswerJoinPledge";
private int _answer;
@Override
protected void readImpl()
{
_answer = readD();
}
@Override
protected void runImpl()
{
L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
L2PcInstance requestor = activeChar.getRequest().getPartner();
if (requestor == null)
{
return;
}
if (_answer == 0)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_DID_NOT_RESPOND_TO_S1_CLAN_INVITATION);
sm.addString(requestor.getName());
activeChar.sendPacket(sm);
sm = null;
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_DID_NOT_RESPOND_TO_CLAN_INVITATION);
sm.addString(activeChar.getName());
requestor.sendPacket(sm);
sm = null;
}
else
{
if (!(requestor.getRequest().getRequestPacket() instanceof RequestJoinPledge))
{
return; // hax
}
RequestJoinPledge requestPacket = (RequestJoinPledge) requestor.getRequest().getRequestPacket();
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); // adademy
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(SystemMessage.getSystemMessage(SystemMessageId.ENTERED_THE_CLAN));
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_JOINED_CLAN);
sm.addString(activeChar.getName());
clan.broadcastToOnlineMembers(sm);
sm = null;
if (activeChar.getClan().getHasCastle() > 0)
{
CastleManager.getInstance().getCastleByOwner(activeChar.getClan()).giveResidentialSkills(activeChar);
}
if (activeChar.getClan().getHasFort() > 0)
{
FortManager.getInstance().getFortByOwner(activeChar.getClan()).giveResidentialSkills(activeChar);
}
activeChar.sendSkillList();
clan.broadcastToOtherOnlineMembers(new PledgeShowMemberListAdd(activeChar), activeChar);
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
// this activates the clan tab on the new member
activeChar.sendPacket(new PledgeShowMemberListAll(clan, activeChar));
activeChar.setClanJoinExpiryTime(0);
activeChar.broadcastUserInfo();
}
}
activeChar.getRequest().onRequestResponse();
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__25_REQUESTANSWERJOINPLEDGE;
}
}
@@ -0,0 +1,48 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.util.logging.Logger;
/**
* Format: (ch) S
* @author -Wooden-
*/
public class RequestAskJoinPartyRoom extends L2GameClientPacket
{
protected static final Logger _log = Logger.getLogger(RequestAskJoinPartyRoom.class.getName());
private static final String _C__D0_14_REQUESTASKJOINPARTYROOM = "[C] D0:14 RequestAskJoinPartyRoom";
private String _player; // not tested, just guessed
@Override
protected void readImpl()
{
_player = readS();
}
@Override
protected void runImpl()
{
// TODO
_log.info("C5:RequestAskJoinPartyRoom: S: " + _player);
}
@Override
public String getType()
{
return _C__D0_14_REQUESTASKJOINPARTYROOM;
}
}
@@ -0,0 +1,174 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ExAutoSoulShot;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* This class ...
* @version $Revision: 1.0.0.0 $ $Date: 2005/07/11 15:29:30 $
*/
public final class RequestAutoSoulShot extends L2GameClientPacket
{
private static final String _C__CF_REQUESTAUTOSOULSHOT = "[C] D0:0D RequestAutoSoulShot";
private static Logger _log = Logger.getLogger(RequestAutoSoulShot.class.getName());
// format cd
private int _itemId;
private int _type; // 1 = on : 0 = off;
@Override
protected void readImpl()
{
_itemId = readD();
_type = readD();
}
@Override
protected void runImpl()
{
L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
if ((activeChar.getPrivateStoreType() == 0) && (activeChar.getActiveRequester() == null) && !activeChar.isDead())
{
if (Config.DEBUG)
{
_log.fine("AutoSoulShot:" + _itemId);
}
L2ItemInstance item = activeChar.getInventory().getItemByItemId(_itemId);
if (item == null)
{
return;
}
if (_type == 1)
{
if (!activeChar.getInventory().canManipulateWithItemId(item.getItemId()))
{
activeChar.sendMessage("Cannot use this item.");
return;
}
// Fishingshots are not automatic on retail
if ((_itemId < 6535) || (_itemId > 6540))
{
// Attempt to charge first shot on activation
if ((_itemId == 6645) || (_itemId == 6646) || (_itemId == 6647) || (_itemId == 20332) || (_itemId == 20333) || (_itemId == 20334))
{
if (activeChar.getPet() != null)
{
if (item.getEtcItem().getHandlerName().equals("BeastSoulShot"))
{
if (activeChar.getPet().getSoulShotsPerHit() > item.getCount())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_SOULSHOTS_FOR_PET));
return;
}
}
else
{
if (activeChar.getPet().getSpiritShotsPerHit() > item.getCount())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_SOULSHOTS_FOR_PET));
return;
}
}
activeChar.addAutoSoulShot(_itemId);
activeChar.sendPacket(new ExAutoSoulShot(_itemId, _type));
// start the auto soulshot use
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.USE_OF_S1_WILL_BE_AUTO);
sm.addItemName(item);// Update Message by rocknow
activeChar.sendPacket(sm);
activeChar.rechargeAutoSoulShot(true, true, true);
}
else
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NO_SERVITOR_CANNOT_AUTOMATE_USE));
}
}
else
{
if ((activeChar.getActiveWeaponItem() != activeChar.getFistsWeaponItem()) && (item.getItem().getCrystalType() == activeChar.getActiveWeaponItem().getItemGradeSPlus()))
{
activeChar.addAutoSoulShot(_itemId);
activeChar.sendPacket(new ExAutoSoulShot(_itemId, _type));
}
else
{
if (((_itemId >= 2509) && (_itemId <= 2514)) || ((_itemId >= 3947) && (_itemId <= 3952)) || (_itemId == 5790) || ((_itemId >= 22072) && (_itemId <= 22081)))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.SPIRITSHOTS_GRADE_MISMATCH));
}
else
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.SOULSHOTS_GRADE_MISMATCH));
}
activeChar.addAutoSoulShot(_itemId);
activeChar.sendPacket(new ExAutoSoulShot(_itemId, _type));
}
// start the auto soulshot use
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.USE_OF_S1_WILL_BE_AUTO);
sm.addItemName(item);// Update Message by rocknow
activeChar.sendPacket(sm);
activeChar.rechargeAutoSoulShot(true, true, false);
}
}
}
else if (_type == 0)
{
activeChar.removeAutoSoulShot(_itemId);
activeChar.sendPacket(new ExAutoSoulShot(_itemId, _type));
// cancel the auto soulshot use
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.AUTO_USE_OF_S1_CANCELLED);
sm.addItemName(item);// Update Message by rocknow
activeChar.sendPacket(sm);
}
}
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__CF_REQUESTAUTOSOULSHOT;
}
@Override
protected boolean triggersOnActionRequest()
{
return false;
}
}
@@ -0,0 +1,78 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.Config;
import com.l2jserver.gameserver.communitybbs.CommunityBoard;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.communityserver.CommunityServerThread;
import com.l2jserver.gameserver.network.communityserver.writepackets.RequestCommunityBoardWrite;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* Format SSSSSS
* @author -Wooden-
*/
public final class RequestBBSwrite extends L2GameClientPacket
{
private static final String _C__22_REQUESTBBSWRITE = "[C] 22 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()
{
if (Config.ENABLE_COMMUNITY_BOARD)
{
L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
if (!CommunityServerThread.getInstance().sendPacket(new RequestCommunityBoardWrite(activeChar.getObjectId(), _url, _arg1, _arg2, _arg3, _arg4, _arg5)))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CB_OFFLINE));
}
}
else
{
CommunityBoard.getInstance().handleWriteCommands(getClient(), _url, _arg1, _arg2, _arg3, _arg4, _arg5);
}
}
@Override
public final String getType()
{
return _C__22_REQUESTBBSWRITE;
}
}
@@ -0,0 +1,75 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.instancemanager.ItemAuctionManager;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.itemauction.ItemAuction;
import com.l2jserver.gameserver.model.itemauction.ItemAuctionInstance;
import com.l2jserver.gameserver.model.itemcontainer.PcInventory;
/**
* @author Forsaiken
*/
public final class RequestBidItemAuction extends L2GameClientPacket
{
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 bidding too fast.");
return;
}
if ((_bid < 0) || (_bid > PcInventory.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,116 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.util.logging.Logger;
import com.l2jserver.gameserver.datatables.CharNameTable;
import com.l2jserver.gameserver.model.BlockList;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
public final class RequestBlock extends L2GameClientPacket
{
private static final String _C__A0_REQUESTBLOCK = "[C] A0 RequestBlock";
private static Logger _log = Logger.getLogger(L2PcInstance.class.getName());
private final static int BLOCK = 0;
private final static int UNBLOCK = 1;
private final static int BLOCKLIST = 2;
private final static int ALLBLOCK = 3;
private final static 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(SystemMessage.getSystemMessage(SystemMessageId.FAILED_TO_REGISTER_TO_IGNORE_LIST));
return;
}
if (targetAL > 0)
{
// Cannot block a GM character.
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_MAY_NOT_IMPOSE_A_BLOCK_ON_GM));
return;
}
if (activeChar.getObjectId() == targetId)
{
return;
}
if (_type == BLOCK)
{
BlockList.addToBlockList(activeChar, targetId);
}
else
{
BlockList.removeFromBlockList(activeChar, targetId);
}
break;
case BLOCKLIST:
BlockList.sendListToOwner(activeChar);
break;
case ALLBLOCK:
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.MESSAGE_REFUSAL_MODE));// Update by rocknow
BlockList.setBlockAll(activeChar, true);
break;
case ALLUNBLOCK:
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.MESSAGE_ACCEPTANCE_MODE));// Update by rocknow
BlockList.setBlockAll(activeChar, false);
break;
default:
_log.info("Unknown 0x0a block type: " + _type);
}
}
@Override
public String getType()
{
return _C__A0_REQUESTBLOCK;
}
}
@@ -0,0 +1,45 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.ExGetBookMarkInfoPacket;
/**
* @author ShanSoft Packets Structure: chddd
*/
public final class RequestBookMarkSlotInfo extends L2GameClientPacket
{
private static final String _C__51_REQUESTBOOKMARKSLOTINFO = "[C] 51 RequestBookMarkSlotInfo";
@Override
protected void readImpl()
{
// There is nothing to read.
}
@Override
protected void runImpl()
{
L2PcInstance player = getClient().getActiveChar();
player.sendPacket(new ExGetBookMarkInfoPacket(player));
}
@Override
public String getType()
{
return _C__51_REQUESTBOOKMARKSLOTINFO;
}
}
@@ -0,0 +1,353 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import static com.l2jserver.gameserver.model.actor.L2Npc.INTERACTION_DISTANCE;
import static com.l2jserver.gameserver.model.itemcontainer.PcInventory.MAX_ADENA;
import java.util.List;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.TradeController;
import com.l2jserver.gameserver.datatables.ItemTable;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2TradeList;
import com.l2jserver.gameserver.model.L2TradeList.L2TradeItem;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2MerchantInstance;
import com.l2jserver.gameserver.model.actor.instance.L2MerchantSummonInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.ExBuySellListPacket;
import com.l2jserver.gameserver.network.serverpackets.StatusUpdate;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.templates.item.L2Item;
import com.l2jserver.gameserver.util.Util;
/**
* RequestBuyItem client packet class.
*/
public final class RequestBuyItem extends L2GameClientPacket
{
private static final String _C__1F_REQUESTBUYITEM = "[C] 1F RequestBuyItem";
private static Logger _log = Logger.getLogger(RequestBuyItem.class.getName());
private static final int BATCH_LENGTH = 12; // length of the one item
private int _listId;
private Item[] _items = null;
@Override
protected void readImpl()
{
_listId = readD();
int count = readD();
if ((count <= 0) || (count > Config.MAX_ITEM_IN_PACKET) || ((count * BATCH_LENGTH) != _buf.remaining()))
{
return;
}
_items = new Item[count];
for (int i = 0; i < count; i++)
{
int itemId = readD();
long cnt = readQ();
if ((itemId < 1) || (cnt < 1))
{
_items = null;
return;
}
_items[i] = new Item(itemId, cnt);
}
}
@Override
protected void runImpl()
{
L2PcInstance player = getClient().getActiveChar();
if (player == null)
{
return;
}
if (!getClient().getFloodProtectors().getTransaction().tryPerformAction("buy"))
{
player.sendMessage("You 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.getKarma() > 0))
{
sendPacket(ActionFailed.STATIC_PACKET);
return;
}
L2Object target = player.getTarget();
L2Character merchant = null;
if (!player.isGM())
{
if ((target == null) || (!player.isInsideRadius(target, INTERACTION_DISTANCE, true, false)) // Distance is too far)
|| (player.getInstanceId() != target.getInstanceId()))
{
sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if ((target instanceof L2MerchantInstance) || (target instanceof L2MerchantSummonInstance))
{
merchant = (L2Character) target;
}
else
{
sendPacket(ActionFailed.STATIC_PACKET);
return;
}
}
L2TradeList list = null;
double castleTaxRate = 0;
double baseTaxRate = 0;
if (merchant != null)
{
List<L2TradeList> lists;
if (merchant instanceof L2MerchantInstance)
{
lists = TradeController.getInstance().getBuyListByNpcId(((L2MerchantInstance) merchant).getNpcId());
castleTaxRate = ((L2MerchantInstance) merchant).getMpc().getCastleTaxRate();
baseTaxRate = ((L2MerchantInstance) merchant).getMpc().getBaseTaxRate();
}
else
{
lists = TradeController.getInstance().getBuyListByNpcId(((L2MerchantSummonInstance) merchant).getNpcId());
baseTaxRate = 50;
}
if (!player.isGM())
{
if (lists == null)
{
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false BuyList list_id " + _listId, Config.DEFAULT_PUNISH);
return;
}
for (L2TradeList tradeList : lists)
{
if (tradeList.getListId() == _listId)
{
list = tradeList;
}
}
}
else
{
list = TradeController.getInstance().getBuyList(_listId);
}
}
else
{
list = TradeController.getInstance().getBuyList(_listId);
}
if (list == null)
{
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false BuyList list_id " + _listId, Config.DEFAULT_PUNISH);
return;
}
_listId = list.getListId();
long subTotal = 0;
// Check for buylist validity and calculates summary values
long slots = 0;
long weight = 0;
for (Item i : _items)
{
long price = -1;
L2TradeItem tradeItem = list.getItemById(i.getItemId());
if (tradeItem == null)
{
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false BuyList list_id " + _listId + " and item_id " + i.getItemId(), Config.DEFAULT_PUNISH);
return;
}
L2Item template = ItemTable.getInstance().getTemplate(i.getItemId());
if (template == null)
{
continue;
}
if (!template.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);
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EXCEEDED_QUANTITY_THAT_CAN_BE_INPUTTED);
sendPacket(sm);
sm = null;
return;
}
price = list.getPriceForItemId(i.getItemId());
if ((i.getItemId() >= 3960) && (i.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 (tradeItem.hasLimitedStock())
{
// trying to buy more then available
if (i.getCount() > tradeItem.getCurrentCount())
{
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() * template.getWeight();
if (!template.isStackable())
{
slots += i.getCount();
}
else if (player.getInventory().getItemByItemId(i.getItemId()) == null)
{
slots++;
}
}
if (!player.isGM() && ((weight > Integer.MAX_VALUE) || (weight < 0) || !player.getInventory().validateWeight((int) weight)))
{
sendPacket(SystemMessage.getSystemMessage(SystemMessageId.WEIGHT_LIMIT_EXCEEDED));
sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if (!player.isGM() && ((slots > Integer.MAX_VALUE) || (slots < 0) || !player.getInventory().validateCapacity((int) slots)))
{
sendPacket(SystemMessage.getSystemMessage(SystemMessageId.SLOTS_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))
{
sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_NOT_ENOUGH_ADENA));
sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Proceed the purchase
for (Item i : _items)
{
L2TradeItem tradeItem = list.getItemById(i.getItemId());
if (tradeItem == null)
{
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false BuyList list_id " + _listId + " and item_id " + i.getItemId(), Config.DEFAULT_PUNISH);
continue;
}
if (tradeItem.hasLimitedStock())
{
if (tradeItem.decreaseCount(i.getCount()))
{
player.getInventory().addItem("Buy", i.getItemId(), i.getCount(), player, merchant);
}
}
else
{
player.getInventory().addItem("Buy", i.getItemId(), i.getCount(), player, merchant);
}
}
// add to castle treasury
if (merchant instanceof L2MerchantInstance)
{
((L2MerchantInstance) merchant).getCastle().addToTreasury((long) (subTotal * castleTaxRate));
}
StatusUpdate su = new StatusUpdate(player);
su.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad());
player.sendPacket(su);
player.sendPacket(new ExBuySellListPacket(player, list, castleTaxRate + baseTaxRate, true));
}
private static class Item
{
private final int _itemId;
private final long _count;
public Item(int id, long num)
{
_itemId = id;
_count = num;
}
public int getItemId()
{
return _itemId;
}
public long getCount()
{
return _count;
}
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__1F_REQUESTBUYITEM;
}
}
@@ -0,0 +1,238 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import static com.l2jserver.gameserver.model.actor.L2Npc.INTERACTION_DISTANCE;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.ItemTable;
import com.l2jserver.gameserver.instancemanager.CastleManorManager;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Manor;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.instance.L2ManorManagerInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.Castle;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jserver.gameserver.network.serverpackets.StatusUpdate;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.templates.item.L2Item;
@Deprecated
public class RequestBuyProcure extends L2GameClientPacket
{
private static final String _C__C3_REQUESTBUYPROCURE = "[C] C3 RequestBuyProcure";
private static final int BATCH_LENGTH = 12; // length of the one item
@SuppressWarnings("unused")
private int _listId;
private Procure[] _items = null;
@Override
protected void readImpl()
{
_listId = readD();
int count = readD();
if ((count <= 0) || (count > Config.MAX_ITEM_IN_PACKET) || ((count * BATCH_LENGTH) != _buf.remaining()))
{
return;
}
_items = new Procure[count];
for (int i = 0; i < count; i++)
{
readD(); // service
int itemId = readD();
long cnt = readQ();
if ((itemId < 1) || (cnt < 1))
{
_items = null;
return;
}
_items[i] = new Procure(itemId, cnt);
}
}
@Override
protected void runImpl()
{
L2PcInstance player = getClient().getActiveChar();
if (player == null)
{
return;
}
if (!getClient().getFloodProtectors().getManor().tryPerformAction("BuyProcure"))
{
return;
}
if (_items == null)
{
sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Alt game - Karma punishment
if (!Config.ALT_GAME_KARMA_PLAYER_CAN_SHOP && (player.getKarma() > 0))
{
return;
}
L2Object manager = player.getTarget();
if (!(manager instanceof L2ManorManagerInstance))
{
manager = player.getLastFolkNPC();
}
if (!(manager instanceof L2ManorManagerInstance))
{
return;
}
if (!player.isInsideRadius(manager, INTERACTION_DISTANCE, true, false))
{
return;
}
Castle castle = ((L2ManorManagerInstance) manager).getCastle();
int slots = 0;
int weight = 0;
for (Procure i : _items)
{
i.setReward(castle);
L2Item template = ItemTable.getInstance().getTemplate(i.getReward());
weight += i.getCount() * template.getWeight();
if (!template.isStackable())
{
slots += i.getCount();
}
else if (player.getInventory().getItemByItemId(i.getItemId()) == null)
{
slots++;
}
}
if (!player.getInventory().validateWeight(weight))
{
sendPacket(SystemMessage.getSystemMessage(SystemMessageId.WEIGHT_LIMIT_EXCEEDED));
return;
}
if (!player.getInventory().validateCapacity(slots))
{
sendPacket(SystemMessage.getSystemMessage(SystemMessageId.SLOTS_FULL));
return;
}
// Proceed the purchase
InventoryUpdate playerIU = new InventoryUpdate();
for (Procure i : _items)
{
// check if player have correct items count
L2ItemInstance item = player.getInventory().getItemByItemId(i.getItemId());
if ((item == null) || (item.getCount() < i.getCount()))
{
continue;
}
L2ItemInstance iteme = player.getInventory().destroyItemByItemId("Manor", i.getItemId(), i.getCount(), player, manager);
if (iteme == null)
{
continue;
}
// Add item to Inventory and adjust update packet
item = player.getInventory().addItem("Manor", i.getReward(), i.getCount(), player, manager);
if (item == null)
{
continue;
}
playerIU.addRemovedItem(iteme);
if (item.getCount() > i.getCount())
{
playerIU.addModifiedItem(item);
}
else
{
playerIU.addNewItem(item);
}
// Send Char Buy Messages
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);
sm.addItemName(item);
sm.addItemNumber(i.getCount());
player.sendPacket(sm);
sm = null;
// manor.getCastle().setCropAmount(itemId, manor.getCastle().getCrop(itemId, CastleManorManager.PERIOD_CURRENT).getAmount() - count);
}
// Send update packets
player.sendPacket(playerIU);
StatusUpdate su = new StatusUpdate(player);
su.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad());
player.sendPacket(su);
}
private static class Procure
{
private final int _itemId;
private final long _count;
private int _reward;
public Procure(int id, long num)
{
_itemId = id;
_count = num;
}
public int getItemId()
{
return _itemId;
}
public long getCount()
{
return _count;
}
public int getReward()
{
return _reward;
}
public void setReward(Castle c)
{
_reward = L2Manor.getInstance().getRewardItem(_itemId, c.getCrop(_itemId, CastleManorManager.PERIOD_CURRENT).getReward());
}
}
@Override
public String getType()
{
return _C__C3_REQUESTBUYPROCURE;
}
}
@@ -0,0 +1,263 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import static com.l2jserver.gameserver.model.actor.L2Npc.INTERACTION_DISTANCE;
import static com.l2jserver.gameserver.model.itemcontainer.PcInventory.MAX_ADENA;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.ItemTable;
import com.l2jserver.gameserver.instancemanager.CastleManager;
import com.l2jserver.gameserver.instancemanager.CastleManorManager;
import com.l2jserver.gameserver.instancemanager.CastleManorManager.SeedProduction;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.instance.L2ManorManagerInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.Castle;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.templates.item.L2Item;
import com.l2jserver.gameserver.util.Util;
/**
* Format: cdd[dd] c // id (0xC4) d // manor id d // seeds to buy [ d // seed id q // count ]
* @param decrypt
* @author l3x
*/
public class RequestBuySeed extends L2GameClientPacket
{
private static final String _C__C4_REQUESTBUYSEED = "[C] C4 RequestBuySeed";
private static final int BATCH_LENGTH = 12; // length of the one item
private int _manorId;
private Seed[] _seeds = null;
@Override
protected void readImpl()
{
_manorId = readD();
int count = readD();
if ((count <= 0) || (count > Config.MAX_ITEM_IN_PACKET) || ((count * BATCH_LENGTH) != _buf.remaining()))
{
return;
}
_seeds = new Seed[count];
for (int i = 0; i < count; i++)
{
int itemId = readD();
long cnt = readQ();
if (cnt < 1)
{
_seeds = null;
return;
}
_seeds[i] = new Seed(itemId, cnt);
}
}
@Override
protected void runImpl()
{
L2PcInstance player = getClient().getActiveChar();
if (player == null)
{
return;
}
if (!getClient().getFloodProtectors().getManor().tryPerformAction("BuySeed"))
{
return;
}
if (_seeds == null)
{
sendPacket(ActionFailed.STATIC_PACKET);
return;
}
L2Object manager = player.getTarget();
if (!(manager instanceof L2ManorManagerInstance))
{
manager = player.getLastFolkNPC();
}
if (!(manager instanceof L2ManorManagerInstance))
{
return;
}
if (!player.isInsideRadius(manager, INTERACTION_DISTANCE, true, false))
{
return;
}
Castle castle = CastleManager.getInstance().getCastleById(_manorId);
long totalPrice = 0;
int slots = 0;
int totalWeight = 0;
for (Seed i : _seeds)
{
if (!i.setProduction(castle))
{
return;
}
totalPrice += i.getPrice();
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);
return;
}
L2Item template = ItemTable.getInstance().getTemplate(i.getSeedId());
totalWeight += i.getCount() * template.getWeight();
if (!template.isStackable())
{
slots += i.getCount();
}
else if (player.getInventory().getItemByItemId(i.getSeedId()) == null)
{
slots++;
}
}
if (!player.getInventory().validateWeight(totalWeight))
{
sendPacket(SystemMessage.getSystemMessage(SystemMessageId.WEIGHT_LIMIT_EXCEEDED));
return;
}
if (!player.getInventory().validateCapacity(slots))
{
sendPacket(SystemMessage.getSystemMessage(SystemMessageId.SLOTS_FULL));
return;
}
// test adena
if ((totalPrice < 0) || (player.getAdena() < totalPrice))
{
sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_NOT_ENOUGH_ADENA));
return;
}
// Proceed the purchase
for (Seed i : _seeds)
{
// take adena and check seed amount once again
if (!player.reduceAdena("Buy", i.getPrice(), player, false) || !i.updateProduction(castle))
{
// failed buy, reduce total price
totalPrice -= i.getPrice();
continue;
}
// Add item to Inventory and adjust update packet
player.addItem("Buy", i.getSeedId(), i.getCount(), manager, true);
}
// Adding to treasury for Manor Castle
if (totalPrice > 0)
{
castle.addToTreasuryNoTax(totalPrice);
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_DISAPPEARED_ADENA);
sm.addItemNumber(totalPrice);
player.sendPacket(sm);
}
}
private static class Seed
{
private final int _seedId;
private final long _count;
SeedProduction _seed;
public Seed(int id, long num)
{
_seedId = id;
_count = num;
}
public int getSeedId()
{
return _seedId;
}
public long getCount()
{
return _count;
}
public long getPrice()
{
return _seed.getPrice() * _count;
}
public boolean setProduction(Castle c)
{
_seed = c.getSeed(_seedId, CastleManorManager.PERIOD_CURRENT);
// invalid price - seed disabled
if (_seed.getPrice() <= 0)
{
return false;
}
// try to buy more than castle can produce
if (_seed.getCanProduce() < _count)
{
return false;
}
// check for overflow
if ((MAX_ADENA / _count) < _seed.getPrice())
{
return false;
}
return true;
}
public boolean updateProduction(Castle c)
{
synchronized (_seed)
{
long amount = _seed.getCanProduce();
if (_count > amount)
{
return false; // not enough seeds
}
_seed.setCanProduce(amount - _count);
}
// Update Castle Seeds Amount
if (Config.ALT_MANOR_SAVE_ALL_ACTIONS)
{
c.updateSeed(_seedId, _seed.getCanProduce(), CastleManorManager.PERIOD_CURRENT);
}
return true;
}
}
@Override
public String getType()
{
return _C__C4_REQUESTBUYSEED;
}
}
@@ -0,0 +1,51 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.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));
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__D0_76_REQUESTBUYSELLUICLOSE;
}
}
@@ -0,0 +1,361 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.communitybbs.CommunityBoard;
import com.l2jserver.gameserver.datatables.AdminCommandAccessRights;
import com.l2jserver.gameserver.handler.AdminCommandHandler;
import com.l2jserver.gameserver.handler.BypassHandler;
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.model.L2CharPosition;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2MerchantSummonInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.Hero;
import com.l2jserver.gameserver.model.entity.L2Event;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.communityserver.CommunityServerThread;
import com.l2jserver.gameserver.network.communityserver.writepackets.RequestShowCommunityBoard;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.ConfirmDlg;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.util.GMAudit;
/**
* This class ...
* @version $Revision: 1.12.4.5 $ $Date: 2005/04/11 10:06:11 $
*/
public final class RequestBypassToServer extends L2GameClientPacket
{
private static final String _C__23_REQUESTBYPASSTOSERVER = "[C] 23 RequestBypassToServer";
private static Logger _log = Logger.getLogger(RequestBypassToServer.class.getName());
// S
private String _command;
@Override
protected void readImpl()
{
_command = readS();
}
@Override
protected void runImpl()
{
final L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
if (!getClient().getFloodProtectors().getServerBypass().tryPerformAction(_command))
{
return;
}
if (_command.isEmpty())
{
_log.info(activeChar.getName() + " send empty requestbypass");
activeChar.logout();
return;
}
try
{
if (_command.startsWith("admin_")) // && activeChar.getAccessLevel() >= Config.GM_ACCESSLEVEL)
{
String command = _command.split(" ")[0];
IAdminCommandHandler ach = AdminCommandHandler.getInstance().getAdminCommandHandler(command);
if (ach == null)
{
if (activeChar.isGM())
{
activeChar.sendMessage("The command " + command.substring(6) + " does not exist!");
}
_log.warning("No handler registered for admin command '" + command + "'");
return;
}
if (!AdminCommandAccessRights.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 (AdminCommandAccessRights.getInstance().requireConfirm(command))
{
activeChar.setAdminConfirmCmd(_command);
ConfirmDlg dlg = new ConfirmDlg(SystemMessageId.S1);
dlg.addString("Are you sure you want execute command " + _command.substring(6) + " ?");
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 (_command.equals("come_here") && (activeChar.isGM()))
{
comeHere(activeChar);
}
else if (_command.startsWith("npc_"))
{
if (!activeChar.validateBypass(_command))
{
return;
}
int endOfId = _command.indexOf('_', 5);
String id;
if (endOfId > 0)
{
id = _command.substring(4, endOfId);
}
else
{
id = _command.substring(4);
}
try
{
L2Object object = L2World.getInstance().findObject(Integer.parseInt(id));
if (_command.substring(endOfId + 1).startsWith("event_participate"))
{
L2Event.inscribePlayer(activeChar);
}
else if ((object instanceof L2Npc) && (endOfId > 0) && activeChar.isInsideRadius(object, L2Npc.INTERACTION_DISTANCE, false, false))
{
((L2Npc) object).onBypassFeedback(activeChar, _command.substring(endOfId + 1));
}
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
}
catch (NumberFormatException nfe)
{
}
}
else if (_command.startsWith("summon_"))
{
if (!activeChar.validateBypass(_command))
{
return;
}
int endOfId = _command.indexOf('_', 8);
String id;
if (endOfId > 0)
{
id = _command.substring(7, endOfId);
}
else
{
id = _command.substring(7);
}
try
{
L2Object object = L2World.getInstance().findObject(Integer.parseInt(id));
if ((object instanceof L2MerchantSummonInstance) && (endOfId > 0) && activeChar.isInsideRadius(object, L2Npc.INTERACTION_DISTANCE, false, false))
{
((L2MerchantSummonInstance) object).onBypassFeedback(activeChar, _command.substring(endOfId + 1));
}
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
}
catch (NumberFormatException nfe)
{
}
}
// Navigate through Manor windows
else if (_command.startsWith("manor_menu_select"))
{
final IBypassHandler manor = BypassHandler.getInstance().getBypassHandler("manor_menu_select");
if (manor != null)
{
manor.useBypass(_command, activeChar, null);
}
}
else if (_command.startsWith("_bbs"))
{
if (Config.ENABLE_COMMUNITY_BOARD)
{
if (!CommunityServerThread.getInstance().sendPacket(new RequestShowCommunityBoard(activeChar.getObjectId(), _command)))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CB_OFFLINE));
}
}
else
{
CommunityBoard.getInstance().handleCommands(getClient(), _command);
}
}
else if (_command.startsWith("_mail"))
{
if (!CommunityServerThread.getInstance().sendPacket(new RequestShowCommunityBoard(activeChar.getObjectId(), "_bbsmail")))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CB_OFFLINE));
}
}
else if (_command.startsWith("_friend"))
{
if (!CommunityServerThread.getInstance().sendPacket(new RequestShowCommunityBoard(activeChar.getObjectId(), "_bbsfriend")))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CB_OFFLINE));
}
}
else if (_command.startsWith("Quest "))
{
if (!activeChar.validateBypass(_command))
{
return;
}
L2PcInstance player = getClient().getActiveChar();
if (player == null)
{
return;
}
String p = _command.substring(6).trim();
int idx = p.indexOf(' ');
if (idx < 0)
{
player.processQuestEvent(p, "");
}
else
{
player.processQuestEvent(p.substring(0, idx), p.substring(idx).trim());
}
}
else if (_command.startsWith("_match"))
{
L2PcInstance player = getClient().getActiveChar();
if (player == null)
{
return;
}
String params = _command.substring(_command.indexOf("?") + 1);
StringTokenizer st = new StringTokenizer(params, "&");
int heroclass = Integer.parseInt(st.nextToken().split("=")[1]);
int heropage = Integer.parseInt(st.nextToken().split("=")[1]);
int heroid = Hero.getInstance().getHeroByClass(heroclass);
if (heroid > 0)
{
Hero.getInstance().showHeroFights(player, heroclass, heroid, heropage);
}
}
else if (_command.startsWith("_diary"))
{
L2PcInstance player = getClient().getActiveChar();
if (player == null)
{
return;
}
String params = _command.substring(_command.indexOf("?") + 1);
StringTokenizer st = new StringTokenizer(params, "&");
int heroclass = Integer.parseInt(st.nextToken().split("=")[1]);
int heropage = Integer.parseInt(st.nextToken().split("=")[1]);
int heroid = Hero.getInstance().getHeroByClass(heroclass);
if (heroid > 0)
{
Hero.getInstance().showHeroDiary(player, heroclass, heroid, heropage);
}
}
else
{
final IBypassHandler handler = BypassHandler.getInstance().getBypassHandler(_command);
if (handler != null)
{
handler.useBypass(_command, activeChar, null);
}
else
{
_log.log(Level.WARNING, getClient() + " sent not handled RequestBypassToServer: [" + _command + "]");
}
}
}
catch (Exception e)
{
_log.log(Level.WARNING, getClient() + " sent bad RequestBypassToServer: \"" + _command + "\"", e);
if (activeChar.isGM())
{
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
NpcHtmlMessage msg = new NpcHtmlMessage(0, 12807);
msg.setHtml(sb.toString());
msg.disableValidation();
activeChar.sendPacket(msg);
}
}
}
/**
* @param client
*/
private static void comeHere(L2PcInstance activeChar)
{
L2Object obj = activeChar.getTarget();
if (obj == null)
{
return;
}
if (obj instanceof L2Npc)
{
L2Npc temp = (L2Npc) obj;
temp.setTarget(activeChar);
temp.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(activeChar.getX(), activeChar.getY(), activeChar.getZ(), 0));
}
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__23_REQUESTBYPASSTOSERVER;
}
}
@@ -0,0 +1,239 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import static com.l2jserver.gameserver.model.actor.L2Character.ZONE_PEACE;
import com.l2jserver.Config;
import com.l2jserver.gameserver.instancemanager.MailManager;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2ItemInstance.ItemLocation;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.Message;
import com.l2jserver.gameserver.model.itemcontainer.ItemContainer;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ExChangePostState;
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jserver.gameserver.network.serverpackets.ItemList;
import com.l2jserver.gameserver.network.serverpackets.StatusUpdate;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.util.Util;
/**
* @author Migi, DS
*/
public final class RequestCancelPost 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;
}
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(ZONE_PEACE))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANT_CANCEL_NOT_IN_PEACE_ZONE));
return;
}
if (activeChar.getActiveTradeList() != null)
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANT_CANCEL_DURING_EXCHANGE));
return;
}
if (activeChar.isEnchanting())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANT_CANCEL_DURING_ENCHANT));
return;
}
if (activeChar.getPrivateStoreType() > 0)
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANT_CANCEL_PRIVATE_STORE));
return;
}
if (!msg.hasAttachments())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_CANT_CANCEL_RECEIVED_MAIL));
return;
}
final ItemContainer attachments = msg.getAttachments();
if ((attachments == null) || (attachments.getSize() == 0))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_CANT_CANCEL_RECEIVED_MAIL));
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.getLocation().equals(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.getItemId()) == null)
{
slots++;
}
}
if (!activeChar.getInventory().validateCapacity(slots))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANT_CANCEL_INVENTORY_FULL));
return;
}
if (!activeChar.getInventory().validateWeight(weight))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANT_CANCEL_INVENTORY_FULL));
return;
}
// Proceed to the transfer
InventoryUpdate playerIU = Config.FORCE_INVENTORY_UPDATE ? null : new InventoryUpdate();
for (L2ItemInstance item : attachments.getItems())
{
if (item == null)
{
continue;
}
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);
}
}
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_ACQUIRED_S2_S1);
sm.addItemName(item.getItemId());
sm.addItemNumber(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
StatusUpdate su = new StatusUpdate(activeChar);
su.addAttribute(StatusUpdate.CUR_LOAD, activeChar.getCurrentLoad());
activeChar.sendPacket(su);
final L2PcInstance receiver = L2World.getInstance().getPlayer(msg.getReceiverId());
if (receiver != null)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_CANCELLED_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(SystemMessage.getSystemMessage(SystemMessageId.MAIL_SUCCESSFULLY_CANCELLED));
}
@Override
public String getType()
{
return _C__D0_6F_REQUESTCANCELPOSTATTACHMENT;
}
@Override
protected boolean triggersOnActionRequest()
{
return false;
}
}
@@ -0,0 +1,41 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
/**
* @author ShanSoft Packets Structure: chddd
*/
public final class RequestChangeBookMarkSlot extends L2GameClientPacket
{
private static final String _C__51_REQUESTCHANGEBOOKMARKSLOT = "[C] 51 RequestChangeBookMarkSlot";
@Override
protected void readImpl()
{
// There is nothing to read.
}
@Override
protected void runImpl()
{
}
@Override
public String getType()
{
return _C__51_REQUESTCHANGEBOOKMARKSLOT;
}
}
@@ -0,0 +1,93 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
/**
* @author KenM, Gnacik
*/
public class RequestChangeNicknameColor extends L2GameClientPacket
{
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;
/**
* @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#readImpl()
*/
@Override
protected void readImpl()
{
_colorNum = readD();
_title = readS();
_itemObjectId = readD();
}
/**
* @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#runImpl()
*/
@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();
}
}
/**
* @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#getType()
*/
@Override
public String getType()
{
return "[C] D0:4F RequestChangeNicknameColor";
}
}
@@ -0,0 +1,57 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
/**
* This class ...
* @version $Revision: 1.3.4.2 $ $Date: 2005/03/27 15:29:30 $
*/
public final class RequestChangePartyLeader extends L2GameClientPacket
{
private static final String _C__EE_REQUESTCHANGEPARTYLEADER = "[C] D0:0C RequestChangePartyLeader";
// private static Logger _log = Logger.getLogger(RequestJoinParty.class.getName());
private String _name;
@Override
protected void readImpl()
{
_name = readS();
}
@Override
protected void runImpl()
{
L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
if (activeChar.isInParty() && activeChar.getParty().isLeader(activeChar))
{
activeChar.getParty().changePartyLeader(_name);
}
}
@Override
public String getType()
{
return _C__EE_REQUESTCHANGEPARTYLEADER;
}
}
@@ -0,0 +1,86 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.datatables.PetNameTable;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Summon;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* 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 REQUESTCHANGEPETNAME__C__89 = "[C] 89 RequestChangePetName";
// private static Logger _log = Logger.getLogger(RequestChangePetName.class.getName());
private String _name;
@Override
protected void readImpl()
{
_name = readS();
}
@Override
protected void runImpl()
{
L2Character activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
final L2Summon pet = activeChar.getPet();
if (pet == null)
{
return;
}
if (pet.getName() != null)
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NAMING_YOU_CANNOT_SET_NAME_OF_THE_PET));
return;
}
else if (PetNameTable.getInstance().doesPetNameExist(_name, pet.getTemplate().npcId))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NAMING_ALREADY_IN_USE_BY_ANOTHER_PET));
return;
}
else if ((_name.length() < 3) || (_name.length() > 16))
{
// SystemMessage sm = SystemMessage.getSystemMessage(SystemMessage.NAMING_PETNAME_UP_TO_8CHARS);
activeChar.sendMessage("Your pet's name can be up to 16 characters.");
return;
}
else if (!PetNameTable.getInstance().isValidPetName(_name))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NAMING_PETNAME_CONTAINS_INVALID_CHARS));
return;
}
pet.setName(_name);
pet.updateAndBroadcastStatus(1);
}
@Override
public String getType()
{
return REQUESTCHANGEPETNAME__C__89;
}
}
@@ -0,0 +1,145 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.Config;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ExPutItemResultForVariationCancel;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.templates.item.L2Item;
import com.l2jserver.gameserver.util.Util;
/**
* Format(ch) d
* @author -Wooden-
*/
public final class RequestConfirmCancelItem extends L2GameClientPacket
{
private static final String _C__D0_2D_REQUESTCONFIRMCANCELITEM = "[C] D0:2D RequestConfirmCancelItem";
private int _objectId;
/**
* @param buf
* @param client
*/
@Override
protected void readImpl()
{
_objectId = readD();
}
/**
* @see com.l2jserver.util.network.BaseRecievePacket.ClientBasePacket#runImpl()
*/
@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(SystemMessage.getSystemMessage(SystemMessageId.AUGMENTATION_REMOVAL_CAN_ONLY_BE_DONE_ON_AN_AUGMENTED_ITEM));
return;
}
if (item.isPvp())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THIS_IS_NOT_A_SUITABLE_ITEM));
return;
}
int price = 0;
switch (item.getItem().getCrystalType())
{
case L2Item.CRYSTAL_C:
if (item.getCrystalCount() < 1720)
{
price = 95000;
}
else if (item.getCrystalCount() < 2452)
{
price = 150000;
}
else
{
price = 210000;
}
break;
case L2Item.CRYSTAL_B:
if (item.getCrystalCount() < 1746)
{
price = 240000;
}
else
{
price = 270000;
}
break;
case L2Item.CRYSTAL_A:
if (item.getCrystalCount() < 2160)
{
price = 330000;
}
else if (item.getCrystalCount() < 2824)
{
price = 390000;
}
else
{
price = 420000;
}
break;
case L2Item.CRYSTAL_S:
price = 480000;
break;
case L2Item.CRYSTAL_S80:
case L2Item.CRYSTAL_S84:
price = 920000;
break;
// TODO: S84 TOP price 3.2M
// any other item type is not augmentable
default:
return;
}
activeChar.sendPacket(new ExPutItemResultForVariationCancel(item, price));
}
/**
* @see com.l2jserver.gameserver.BasePacket#getType()
*/
@Override
public String getType()
{
return _C__D0_2D_REQUESTCONFIRMCANCELITEM;
}
}
@@ -0,0 +1,106 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ExPutCommissionResultForVariationMake;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* Format:(ch) dddd
* @author -Wooden-
*/
public final class RequestConfirmGemStone extends AbstractRefinePacket
{
private static final String _C__D0_2B_REQUESTCONFIRMGEMSTONE = "[C] D0:2B RequestConfirmGemStone";
private int _targetItemObjId;
private int _refinerItemObjId;
private int _gemstoneItemObjId;
private long _gemStoneCount;
/**
* @param buf
* @param client
*/
@Override
protected void readImpl()
{
_targetItemObjId = readD();
_refinerItemObjId = readD();
_gemstoneItemObjId = readD();
_gemStoneCount = readQ();
}
/**
* @see com.l2jserver.util.network.BaseRecievePacket.ClientBasePacket#runImpl()
*/
@Override
protected void runImpl()
{
final L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
L2ItemInstance targetItem = activeChar.getInventory().getItemByObjectId(_targetItemObjId);
if (targetItem == null)
{
return;
}
L2ItemInstance refinerItem = activeChar.getInventory().getItemByObjectId(_refinerItemObjId);
if (refinerItem == null)
{
return;
}
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(SystemMessage.getSystemMessage(SystemMessageId.THIS_IS_NOT_A_SUITABLE_ITEM));
return;
}
// Check for gemstone count
final LifeStone ls = getLifeStone(refinerItem.getItemId());
if (ls == null)
{
return;
}
if (_gemStoneCount != getGemStoneCount(targetItem.getItem().getItemGrade(), ls.getGrade()))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.GEMSTONE_QUANTITY_IS_INCORRECT));
return;
}
activeChar.sendPacket(new ExPutCommissionResultForVariationMake(_gemstoneItemObjId, _gemStoneCount, gemStoneItem.getItemId()));
}
/**
* @see com.l2jserver.gameserver.BasePacket#getType()
*/
@Override
public String getType()
{
return _C__D0_2B_REQUESTCONFIRMGEMSTONE;
}
}
@@ -0,0 +1,86 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ExPutIntensiveResultForVariationMake;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* Fromat(ch) dd
* @author -Wooden-
*/
public class RequestConfirmRefinerItem extends AbstractRefinePacket
{
private static final String _C__D0_2A_REQUESTCONFIRMREFINERITEM = "[C] D0:2A 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(SystemMessage.getSystemMessage(SystemMessageId.THIS_IS_NOT_A_SUITABLE_ITEM));
return;
}
final int refinerItemId = refinerItem.getItem().getItemId();
final int grade = targetItem.getItem().getItemGrade();
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));
}
/**
* @see com.l2jserver.gameserver.BasePacket#getType()
*/
@Override
public String getType()
{
return _C__D0_2A_REQUESTCONFIRMREFINERITEM;
}
}
@@ -0,0 +1,110 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.datatables.ClanTable;
import com.l2jserver.gameserver.instancemanager.CastleManager;
import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.Castle;
import com.l2jserver.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__A5_RequestConfirmSiegeWaitingList = "[C] a5 RequestConfirmSiegeWaitingList";
// private static Logger _log = Logger.getLogger(RequestConfirmSiegeWaitingList.class.getName());
private int _approved;
private int _castleId;
private int _clanId;
@Override
protected void readImpl()
{
_castleId = readD();
_clanId = readD();
_approved = readD();
}
@Override
protected void runImpl()
{
L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
// Check if the player has a clan
if (activeChar.getClan() == null)
{
return;
}
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;
}
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__A5_RequestConfirmSiegeWaitingList;
}
}
@@ -0,0 +1,77 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ExPutItemResultForVariationMake;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* 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(SystemMessage.getSystemMessage(SystemMessageId.ONCE_AN_ITEM_IS_AUGMENTED_IT_CANNOT_BE_AUGMENTED_AGAIN));
return;
}
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THIS_IS_NOT_A_SUITABLE_ITEM));
return;
}
activeChar.sendPacket(new ExPutItemResultForVariationMake(_itemObjId, item.getItemId()));
}
/**
* @see com.l2jserver.gameserver.BasePacket#getType()
*/
@Override
public String getType()
{
return _C__D0_26_REQUESTCONFIRMTARGETITEM;
}
}
@@ -0,0 +1,246 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.base.Race;
import com.l2jserver.gameserver.model.itemcontainer.PcInventory;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.templates.item.L2Item;
import com.l2jserver.gameserver.util.Util;
/**
* 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__72_REQUESTDCRYSTALLIZEITEM = "[C] 72 RequestCrystallizeItem";
private static Logger _log = Logger.getLogger(RequestCrystallizeItem.class.getName());
private int _objectId;
private long _count;
@Override
protected void readImpl()
{
_objectId = readD();
_count = readQ();
}
@Override
protected void runImpl()
{
L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
_log.fine("RequestCrystalizeItem: activeChar was null");
return;
}
if (!getClient().getFloodProtectors().getTransaction().tryPerformAction("crystallize"))
{
activeChar.sendMessage("You 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() != 0) || activeChar.isInCrystallize())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_TRADE_DISCARD_DROP_ITEM_WHILE_IN_SHOPMODE));
return;
}
int skillLevel = activeChar.getSkillLevel(L2Skill.SKILL_CRYSTALLIZE);
if (skillLevel <= 0)
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CRYSTALLIZE_LEVEL_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;
}
PcInventory inventory = activeChar.getInventory();
if (inventory != null)
{
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();
}
}
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() == L2Item.CRYSTAL_NONE))
{
_log.warning(activeChar.getName() + " (" + activeChar.getObjectId() + ") tried to crystallize " + itemToRemove.getItem().getItemId());
return;
}
if (!activeChar.getInventory().canManipulateWithItemId(itemToRemove.getItemId()))
{
activeChar.sendMessage("Cannot use this item.");
return;
}
// Check if the char can crystallize items and return if false;
boolean canCrystallize = true;
switch (itemToRemove.getItem().getItemGradeSPlus())
{
case L2Item.CRYSTAL_C:
{
if (skillLevel <= 1)
{
canCrystallize = false;
}
break;
}
case L2Item.CRYSTAL_B:
{
if (skillLevel <= 2)
{
canCrystallize = false;
}
break;
}
case L2Item.CRYSTAL_A:
{
if (skillLevel <= 3)
{
canCrystallize = false;
}
break;
}
case L2Item.CRYSTAL_S:
{
if (skillLevel <= 4)
{
canCrystallize = false;
}
break;
}
}
if (!canCrystallize)
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CRYSTALLIZE_LEVEL_TOO_LOW));
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
activeChar.setInCrystallize(true);
// unequip if needed
if (itemToRemove.isEquipped())
{
L2ItemInstance[] unequiped = activeChar.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot());
InventoryUpdate iu = new InventoryUpdate();
for (L2ItemInstance item : unequiped)
{
iu.addModifiedItem(item);
}
activeChar.sendPacket(iu);
SystemMessage msg;
if (itemToRemove.getEnchantLevel() > 0)
{
msg = SystemMessage.getSystemMessage(SystemMessageId.EQUIPMENT_S1_S2_REMOVED);
msg.addNumber(itemToRemove.getEnchantLevel());
msg.addItemName(itemToRemove);
}
else
{
msg = SystemMessage.getSystemMessage(SystemMessageId.S1_DISARMED);
msg.addItemName(itemToRemove);
}
activeChar.sendPacket(msg);
}
// remove from inventory
L2ItemInstance removedItem = activeChar.getInventory().destroyItem("Crystalize", _objectId, _count, activeChar, null);
InventoryUpdate iu = new InventoryUpdate();
iu.addRemovedItem(removedItem);
activeChar.sendPacket(iu);
// add crystals
int crystalId = itemToRemove.getItem().getCrystalItemId();
int crystalAmount = itemToRemove.getCrystalCount();
L2ItemInstance createditem = activeChar.getInventory().addItem("Crystalize", crystalId, crystalAmount, activeChar, activeChar);
SystemMessage sm;
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_CRYSTALLIZED);
sm.addItemName(removedItem);
activeChar.sendPacket(sm);
sm = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);
sm.addItemName(createditem);
sm.addItemNumber(crystalAmount);
activeChar.sendPacket(sm);
activeChar.broadcastUserInfo();
L2World world = L2World.getInstance();
world.removeObject(removedItem);
activeChar.setInCrystallize(false);
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__72_REQUESTDCRYSTALLIZEITEM;
}
}
@@ -0,0 +1,75 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.util.List;
import javolution.util.FastList;
import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.network.serverpackets.ExCursedWeaponList;
/**
* Format: (ch)
* @author -Wooden-
*/
public class RequestCursedWeaponList extends L2GameClientPacket
{
private static final String _C__D0_22_REQUESTCURSEDWEAPONLIST = "[C] D0:22 RequestCursedWeaponList";
@Override
protected void readImpl()
{
// nothing to read it's just a trigger
}
/**
* @see com.l2jserver.util.network.BaseRecievePacket.ClientBasePacket#runImpl()
*/
@Override
protected void runImpl()
{
L2Character activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
// send a ExCursedWeaponList :p
List<Integer> list = new FastList<>();
for (int id : CursedWeaponsManager.getInstance().getCursedWeaponsIds())
{
list.add(id);
}
activeChar.sendPacket(new ExCursedWeaponList(list));
}
/**
* @see com.l2jserver.gameserver.BasePacket#getType()
*/
@Override
public String getType()
{
return _C__D0_22_REQUESTCURSEDWEAPONLIST;
}
@Override
protected boolean triggersOnActionRequest()
{
return false;
}
}
@@ -0,0 +1,90 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.clientpackets;
import java.util.List;
import javolution.util.FastList;
import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
import com.l2jserver.gameserver.model.CursedWeapon;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.network.serverpackets.ExCursedWeaponLocation;
import com.l2jserver.gameserver.network.serverpackets.ExCursedWeaponLocation.CursedWeaponInfo;
import com.l2jserver.util.Point3D;
/**
* Format: (ch)
* @author -Wooden-
*/
public final class RequestCursedWeaponLocation extends L2GameClientPacket
{
private static final String _C__D0_23_REQUESTCURSEDWEAPONLOCATION = "[C] D0:23 RequestCursedWeaponLocation";
@Override
protected void readImpl()
{
// nothing to read it's just a trigger
}
/**
* @see com.l2jserver.util.network.BaseRecievePacket.ClientBasePacket#runImpl()
*/
@Override
protected void runImpl()
{
L2Character activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
List<CursedWeaponInfo> list = new FastList<>();
for (CursedWeapon cw : CursedWeaponsManager.getInstance().getCursedWeapons())
{
if (!cw.isActive())
{
continue;
}
Point3D 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));
}
}
/**
* @see com.l2jserver.gameserver.BasePacket#getType()
*/
@Override
public String getType()
{
return _C__D0_23_REQUESTCURSEDWEAPONLOCATION;
}
@Override
protected boolean triggersOnActionRequest()
{
return false;
}
}
@@ -0,0 +1,52 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
/**
* @author ShanSoft
* @structure: chdd
*/
public final class RequestDeleteBookMarkSlot extends L2GameClientPacket
{
private static final String _C__51_REQUESTDELETEBOOKMARKSLOT = "[C] 51 RequestDeleteBookMarkSlot";
private int id;
@Override
protected void readImpl()
{
id = readD();
}
@Override
protected void runImpl()
{
L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
activeChar.teleportBookmarkDelete(id);
}
@Override
public String getType()
{
return _C__51_REQUESTDELETEBOOKMARKSLOT;
}
}
@@ -0,0 +1,49 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
public final class RequestDeleteMacro extends L2GameClientPacket
{
private int _id;
private static final String _C__C2_REQUESTDELETEMACRO = "[C] C2 RequestDeleteMacro";
@Override
protected void readImpl()
{
_id = readD();
}
@Override
protected void runImpl()
{
if (getClient().getActiveChar() == null)
{
return;
}
getClient().getActiveChar().deleteMacro(_id);
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__C2_REQUESTDELETEMACRO;
}
}
@@ -0,0 +1,104 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import static com.l2jserver.gameserver.model.actor.L2Character.ZONE_PEACE;
import com.l2jserver.Config;
import com.l2jserver.gameserver.instancemanager.MailManager;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.Message;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ExChangePostState;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.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()
{
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(ZONE_PEACE))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANT_USE_MAIL_OUTSIDE_PEACE_ZONE));
return;
}
for (int msgId : _msgIds)
{
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 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.l2jserver.gameserver.network.clientpackets;
import static com.l2jserver.gameserver.model.actor.L2Character.ZONE_PEACE;
import com.l2jserver.Config;
import com.l2jserver.gameserver.instancemanager.MailManager;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.Message;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ExChangePostState;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.util.Util;
/**
* @author Migi, DS
*/
public final class RequestDeleteSentPost extends L2GameClientPacket
{
private static final String _C__D0_6C_REQUESTDELETESENTPOST = "[C] D0:6D RequestDeleteSentPost";
private static final int BATCH_LENGTH = 4; // length of the one item
int[] _msgIds = null;
@Override
protected void readImpl()
{
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(ZONE_PEACE))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANT_USE_MAIL_OUTSIDE_PEACE_ZONE));
return;
}
for (int msgId : _msgIds)
{
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_6C_REQUESTDELETESENTPOST;
}
@Override
protected boolean triggersOnActionRequest()
{
return false;
}
}
@@ -0,0 +1,230 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.gameserver.datatables.PetDataTable;
import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jserver.gameserver.network.serverpackets.ItemList;
import com.l2jserver.gameserver.network.serverpackets.StatusUpdate;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.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__59_REQUESTDESTROYITEM = "[C] 59 RequestDestroyItem";
private static Logger _log = Logger.getLogger(RequestDestroyItem.class.getName());
private int _objectId;
private long _count;
@Override
protected void readImpl()
{
_objectId = readD();
_count = readQ();
}
@Override
protected void runImpl()
{
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 destroying items too fast.");
return;
}
long count = _count;
if (activeChar.isProcessingTransaction() || (activeChar.getPrivateStoreType() != 0))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_TRADE_DISCARD_DROP_ITEM_WHILE_IN_SHOPMODE));
return;
}
L2ItemInstance itemToRemove = activeChar.getInventory().getItemByObjectId(_objectId);
// if we can't find the requested item, its actually a cheat
if (itemToRemove == null)
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_DISCARD_THIS_ITEM));
return;
}
// Cannot discard item that the skill is consuming
if (activeChar.isCastingNow())
{
if ((activeChar.getCurrentSkill() != null) && (activeChar.getCurrentSkill().getSkill().getItemConsumeId() == itemToRemove.getItemId()))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_DISCARD_THIS_ITEM));
return;
}
}
// Cannot discard item that the skill is consuming
if (activeChar.isCastingSimultaneouslyNow())
{
if ((activeChar.getLastSimultaneousSkillCast() != null) && (activeChar.getLastSimultaneousSkillCast().getItemConsumeId() == itemToRemove.getItemId()))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_DISCARD_THIS_ITEM));
return;
}
}
int itemId = itemToRemove.getItemId();
if ((!activeChar.isGM() && !itemToRemove.isDestroyable()) || CursedWeaponsManager.getInstance().isCursed(itemId))
{
if (itemToRemove.isHeroItem())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.HERO_WEAPONS_CANT_DESTROYED));
}
else
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_DISCARD_THIS_ITEM));
}
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.getItemId()))
{
activeChar.sendMessage("Cannot use this item.");
return;
}
if (_count > itemToRemove.getCount())
{
count = itemToRemove.getCount();
}
if (itemToRemove.isEquipped())
{
L2ItemInstance[] unequiped = activeChar.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot());
InventoryUpdate iu = new InventoryUpdate();
for (L2ItemInstance item : unequiped)
{
activeChar.checkSShotsMatch(null, item);
iu.addModifiedItem(item);
}
activeChar.sendPacket(iu);
activeChar.broadcastUserInfo();
}
if (PetDataTable.isPetItem(itemId))
{
Connection con = null;
try
{
if ((activeChar.getPet() != null) && (activeChar.getPet().getControlObjectId() == _objectId))
{
activeChar.getPet().unSummon(activeChar);
}
// if it's a pet control item, delete the pet
con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM pets WHERE item_obj_id=?");
statement.setInt(1, _objectId);
statement.execute();
statement.close();
}
catch (Exception e)
{
_log.log(Level.WARNING, "could not delete pet objectid: ", e);
}
finally
{
L2DatabaseFactory.close(con);
}
}
if (itemToRemove.isTimeLimitedItem())
{
itemToRemove.endOfLife();
}
L2ItemInstance removedItem = activeChar.getInventory().destroyItem("Destroy", _objectId, count, activeChar, null);
if (removedItem == null)
{
return;
}
if (!Config.FORCE_INVENTORY_UPDATE)
{
InventoryUpdate iu = new InventoryUpdate();
if (removedItem.getCount() == 0)
{
iu.addRemovedItem(removedItem);
}
else
{
iu.addModifiedItem(removedItem);
}
// client.getConnection().sendPacket(iu);
activeChar.sendPacket(iu);
}
else
{
sendPacket(new ItemList(activeChar, true));
}
StatusUpdate su = new StatusUpdate(activeChar);
su.addAttribute(StatusUpdate.CUR_LOAD, activeChar.getCurrentLoad());
activeChar.sendPacket(su);
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__59_REQUESTDESTROYITEM;
}
}
@@ -0,0 +1,62 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* 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__86_REQUESTDISMISSALLY = "[C] 86 RequestDismissAlly";
// static Logger _log = Logger.getLogger(RequestDismissAlly.class.getName());
@Override
protected void readImpl()
{
// trigger packet
}
@Override
protected void runImpl()
{
L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
if (!activeChar.isClanLeader())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.FEATURE_ONLY_FOR_ALLIANCE_LEADER));
return;
}
activeChar.getClan().dissolveAlly(activeChar);
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__86_REQUESTDISMISSALLY;
}
}
@@ -0,0 +1,65 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.model.PartyMatchRoom;
import com.l2jserver.gameserver.model.PartyMatchRoomList;
import com.l2jserver.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;
}
PartyMatchRoom _room = PartyMatchRoomList.getInstance().getRoom(_roomid);
if (_room == null)
{
return;
}
PartyMatchRoomList.getInstance().deleteRoom(_roomid);
}
@Override
public String getType()
{
return _C__D0_0A_REQUESTDISMISSPARTYROOM;
}
}
@@ -0,0 +1,99 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.SkillTable;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Summon;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
/**
* @author KenM
*/
public class RequestDispel extends L2GameClientPacket
{
private int _objectId;
private int _skillId;
private int _skillLevel;
/**
* @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#readImpl()
*/
@Override
protected void readImpl()
{
_objectId = readD();
_skillId = readD();
_skillLevel = readD();
}
/**
* @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#runImpl()
*/
@Override
protected void runImpl()
{
if ((_skillId <= 0) || (_skillLevel <= 0))
{
return;
}
final L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
L2Skill skill = SkillTable.getInstance().getInfo(_skillId, _skillLevel);
if (skill == null)
{
return;
}
if (!skill.canBeDispeled() || skill.isStayAfterDeath() || skill.isDebuff())
{
return;
}
if (skill.getTransformId() > 0)
{
return;
}
if (skill.isDance() && !Config.DANCE_CANCEL_BUFF)
{
return;
}
if (activeChar.getObjectId() == _objectId)
{
activeChar.stopSkillEffects(_skillId);
}
else
{
final L2Summon pet = activeChar.getPet();
if ((pet != null) && (pet.getObjectId() == _objectId))
{
pet.stopSkillEffects(_skillId);
}
}
}
/**
* @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#getType()
*/
@Override
public String getType()
{
return "[C] D0:4E RequestDispel";
}
}
@@ -0,0 +1,58 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.network.serverpackets.ExReplyDominionInfo;
import com.l2jserver.gameserver.network.serverpackets.ExShowOwnthingPos;
/**
* @author JIV
*/
public class RequestDominionInfo extends L2GameClientPacket
{
/**
* @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#getType()
*/
@Override
public String getType()
{
return "[C] D0:58 RequestDominionInfo";
}
/**
* @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#readImpl()
*/
@Override
protected void readImpl()
{
// nothing
}
/**
* @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#runImpl()
*/
@Override
protected void runImpl()
{
sendPacket(new ExReplyDominionInfo());
sendPacket(new ExShowOwnthingPos());
}
@Override
protected boolean triggersOnActionRequest()
{
return false;
}
}
@@ -0,0 +1,243 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.GmListTable;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jserver.gameserver.network.serverpackets.ItemList;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.templates.item.L2EtcItemType;
import com.l2jserver.gameserver.templates.item.L2Item;
import com.l2jserver.gameserver.util.GMAudit;
import com.l2jserver.gameserver.util.Util;
/**
* This class ...
* @version $Revision: 1.11.2.1.2.7 $ $Date: 2005/04/02 21:25:21 $
*/
public final class RequestDropItem extends L2GameClientPacket
{
private static final String _C__12_REQUESTDROPITEM = "[C] 12 RequestDropItem";
private static Logger _log = Logger.getLogger(RequestDropItem.class.getName());
private int _objectId;
private long _count;
private int _x;
private int _y;
private int _z;
@Override
protected void readImpl()
{
_objectId = readD();
_count = readQ();
_x = readD();
_y = readD();
_z = readD();
}
@Override
protected void runImpl()
{
L2PcInstance activeChar = getClient().getActiveChar();
if ((activeChar == null) || activeChar.isDead())
{
return;
}
// Flood protect drop to avoid packet lag
if (!getClient().getFloodProtectors().getDropItem().tryPerformAction("drop item"))
{
return;
}
L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);
if ((item == null) || (_count == 0) || !activeChar.validateItemManipulation(_objectId, "drop") || (!Config.ALLOW_DISCARDITEM && !activeChar.isGM()) || (!item.isDropable() && !(activeChar.isGM() && Config.GM_TRADE_RESTRICTED_ITEMS)) || ((item.getItemType() == L2EtcItemType.PET_COLLAR) && activeChar.havePetInvItems()) || activeChar.isInsideZone(L2Character.ZONE_NOITEMDROP))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_DISCARD_THIS_ITEM));
return;
}
if (item.isQuestItem() && !(activeChar.isGM() && Config.GM_TRADE_RESTRICTED_ITEMS))
{
return;
}
if (_count > item.getCount())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_DISCARD_THIS_ITEM));
return;
}
if ((Config.PLAYER_SPAWN_PROTECTION > 0) && activeChar.isInvul() && !activeChar.isGM())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_DISCARD_THIS_ITEM));
return;
}
if (_count < 0)
{
Util.handleIllegalPlayerAction(activeChar, "[RequestDropItem] Character " + activeChar.getName() + " of account " + activeChar.getAccountName() + " tried to drop item with oid " + _objectId + " but has count < 0!", Config.DEFAULT_PUNISH);
return;
}
if (!item.isStackable() && (_count > 1))
{
Util.handleIllegalPlayerAction(activeChar, "[RequestDropItem] Character " + activeChar.getName() + " of account " + activeChar.getAccountName() + " tried to drop non-stackable item with oid " + _objectId + " but has count > 1!", Config.DEFAULT_PUNISH);
return;
}
if (Config.JAIL_DISABLE_TRANSACTION && activeChar.isInJail())
{
activeChar.sendMessage("You cannot drop items in Jail.");
return;
}
if (!activeChar.getAccessLevel().allowTransaction())
{
activeChar.sendMessage("Transactions are disable for your Access Level");
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOTHING_HAPPENED));
return;
}
if (activeChar.isProcessingTransaction() || (activeChar.getPrivateStoreType() != 0))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_TRADE_DISCARD_DROP_ITEM_WHILE_IN_SHOPMODE));
return;
}
if (activeChar.isFishing())
{
// You can't mount, dismount, break and drop items while fishing
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_DO_WHILE_FISHING_2));
return;
}
if (activeChar.isFlying())
{
return;
}
// Cannot discard item that the skill is consuming
if (activeChar.isCastingNow())
{
if ((activeChar.getCurrentSkill() != null) && (activeChar.getCurrentSkill().getSkill().getItemConsumeId() == item.getItemId()))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_DISCARD_THIS_ITEM));
return;
}
}
// Cannot discard item that the skill is consuming
if (activeChar.isCastingSimultaneouslyNow())
{
if ((activeChar.getLastSimultaneousSkillCast() != null) && (activeChar.getLastSimultaneousSkillCast().getItemConsumeId() == item.getItemId()))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_DISCARD_THIS_ITEM));
return;
}
}
if ((L2Item.TYPE2_QUEST == item.getItem().getType2()) && !activeChar.isGM())
{
if (Config.DEBUG)
{
_log.finest(activeChar.getObjectId() + ":player tried to drop quest item");
}
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_DISCARD_EXCHANGE_ITEM));
return;
}
if (!activeChar.isInsideRadius(_x, _y, 150, false) || (Math.abs(_z - activeChar.getZ()) > 50))
{
if (Config.DEBUG)
{
_log.finest(activeChar.getObjectId() + ": trying to drop too far away");
}
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_DISCARD_DISTANCE_TOO_FAR));
return;
}
if (!activeChar.getInventory().canManipulateWithItemId(item.getItemId()))
{
activeChar.sendMessage("Cannot use this item.");
return;
}
if (Config.DEBUG)
{
_log.fine("requested drop item " + _objectId + "(" + item.getCount() + ") at " + _x + "/" + _y + "/" + _z);
}
if (item.isEquipped())
{
L2ItemInstance[] unequiped = activeChar.getInventory().unEquipItemInSlotAndRecord(item.getLocationSlot());
InventoryUpdate iu = new InventoryUpdate();
for (L2ItemInstance itm : unequiped)
{
activeChar.checkSShotsMatch(null, itm);
iu.addModifiedItem(itm);
}
activeChar.sendPacket(iu);
activeChar.broadcastUserInfo();
ItemList il = new ItemList(activeChar, true);
activeChar.sendPacket(il);
}
L2ItemInstance dropedItem = activeChar.dropItem("Drop", _objectId, _count, _x, _y, _z, null, false, true);
if (Config.DEBUG)
{
_log.fine("dropping " + _objectId + " item(" + _count + ") at: " + _x + " " + _y + " " + _z);
}
// activeChar.broadcastUserInfo();
if (activeChar.isGM())
{
String target = (activeChar.getTarget() != null ? activeChar.getTarget().getName() : "no-target");
GMAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", "Drop", target, "(id: " + dropedItem.getItemId() + " name: " + dropedItem.getItemName() + " objId: " + dropedItem.getObjectId() + " x: " + activeChar.getX() + " y: " + activeChar.getY() + " z: " + activeChar.getZ() + ")");
}
if ((dropedItem != null) && (dropedItem.getItemId() == 57) && (dropedItem.getCount() >= 1000000))
{
String msg = "Character (" + activeChar.getName() + ") has dropped (" + dropedItem.getCount() + ")adena at (" + _x + "," + _y + "," + _z + ")";
_log.warning(msg);
GmListTable.broadcastMessageToGMs(msg);
}
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__12_REQUESTDROPITEM;
}
@Override
protected boolean triggersOnActionRequest()
{
return false;
}
}
@@ -0,0 +1,132 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.instancemanager.DuelManager;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* Format:(ch) ddd
* @author -Wooden-
*/
public final class RequestDuelAnswerStart extends L2GameClientPacket
{
private static final String _C__D0_28_REQUESTDUELANSWERSTART = "[C] D0:28 RequestDuelAnswerStart";
private int _partyDuel;
@SuppressWarnings("unused")
private int _unk1;
private int _response;
@Override
protected void readImpl()
{
_partyDuel = readD();
_unk1 = readD();
_response = readD();
}
/**
* @see com.l2jserver.util.network.BaseRecievePacket.ClientBasePacket#runImpl()
*/
@Override
protected void runImpl()
{
L2PcInstance player = getClient().getActiveChar();
if (player == null)
{
return;
}
L2PcInstance requestor = player.getActiveRequester();
if (requestor == null)
{
return;
}
if (_response == 1)
{
SystemMessage msg1 = null, msg2 = null;
if (requestor.isInDuel())
{
msg1 = SystemMessage.getSystemMessage(SystemMessageId.C1_CANNOT_DUEL_BECAUSE_C1_IS_ALREADY_ENGAGED_IN_A_DUEL);
msg1.addString(requestor.getName());
player.sendPacket(msg1);
return;
}
else if (player.isInDuel())
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_ARE_UNABLE_TO_REQUEST_A_DUEL_AT_THIS_TIME));
return;
}
if (_partyDuel == 1)
{
msg1 = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_ACCEPTED_C1_CHALLENGE_TO_A_PARTY_DUEL_THE_DUEL_WILL_BEGIN_IN_A_FEW_MOMENTS);
msg1.addString(requestor.getName());
msg2 = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_ACCEPTED_YOUR_CHALLENGE_TO_DUEL_AGAINST_THEIR_PARTY_THE_DUEL_WILL_BEGIN_IN_A_FEW_MOMENTS);
msg2.addString(player.getName());
}
else
{
msg1 = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_ACCEPTED_C1_CHALLENGE_TO_A_DUEL_THE_DUEL_WILL_BEGIN_IN_A_FEW_MOMENTS);
msg1.addString(requestor.getName());
msg2 = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_ACCEPTED_YOUR_CHALLENGE_TO_A_DUEL_THE_DUEL_WILL_BEGIN_IN_A_FEW_MOMENTS);
msg2.addString(player.getName());
}
player.sendPacket(msg1);
requestor.sendPacket(msg2);
DuelManager.getInstance().addDuel(requestor, player, _partyDuel);
}
else if (_response == -1)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_SET_TO_REFUSE_DUEL_REQUEST);
sm.addPcName(player);
requestor.sendPacket(sm);
}
else
{
SystemMessage msg = null;
if (_partyDuel == 1)
{
msg = SystemMessage.getSystemMessage(SystemMessageId.THE_OPPOSING_PARTY_HAS_DECLINED_YOUR_CHALLENGE_TO_A_DUEL);
}
else
{
msg = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_DECLINED_YOUR_CHALLENGE_TO_A_DUEL);
msg.addPcName(player);
}
requestor.sendPacket(msg);
}
player.setActiveRequester(null);
requestor.onTransactionResponse();
}
/**
* @see com.l2jserver.gameserver.BasePacket#getType()
*/
@Override
public String getType()
{
return _C__D0_28_REQUESTDUELANSWERSTART;
}
}
@@ -0,0 +1,197 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ExDuelAskStart;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* Format:(ch) Sd
* @author -Wooden-
*/
public final class RequestDuelStart extends L2GameClientPacket
{
private static final String _C__D0_27_REQUESTDUELSTART = "[C] D0:27 RequestDuelStart";
private static Logger _log = Logger.getLogger(RequestDuelStart.class.getName());
private String _player;
private int _partyDuel;
@Override
protected void readImpl()
{
_player = readS();
_partyDuel = readD();
}
/**
* @see com.l2jserver.util.network.BaseRecievePacket.ClientBasePacket#runImpl()
*/
@Override
protected void runImpl()
{
L2PcInstance activeChar = getClient().getActiveChar();
L2PcInstance targetChar = L2World.getInstance().getPlayer(_player);
if (activeChar == null)
{
return;
}
if (targetChar == null)
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THERE_IS_NO_OPPONENT_TO_RECEIVE_YOUR_CHALLENGE_FOR_A_DUEL));
return;
}
if (activeChar == targetChar)
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THERE_IS_NO_OPPONENT_TO_RECEIVE_YOUR_CHALLENGE_FOR_A_DUEL));
return;
}
// Check if duel is possible
if (!activeChar.canDuel())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_ARE_UNABLE_TO_REQUEST_A_DUEL_AT_THIS_TIME));
return;
}
else if (!targetChar.canDuel())
{
activeChar.sendPacket(targetChar.getNoDuelReason());
return;
}
// Players may not be too far apart
else if (!activeChar.isInsideRadius(targetChar, 250, false, false))
{
SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.C1_CANNOT_RECEIVE_A_DUEL_CHALLENGE_BECAUSE_C1_IS_TOO_FAR_AWAY);
msg.addString(targetChar.getName());
activeChar.sendPacket(msg);
return;
}
// Duel is a party duel
if (_partyDuel == 1)
{
// Player must be in a party & the party leader
if (!activeChar.isInParty() || !(activeChar.isInParty() && activeChar.getParty().isLeader(activeChar)))
{
activeChar.sendMessage("You have to be the leader of a party in order to request a party duel.");
return;
}
// Target must be in a party
else if (!targetChar.isInParty())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.SINCE_THE_PERSON_YOU_CHALLENGED_IS_NOT_CURRENTLY_IN_A_PARTY_THEY_CANNOT_DUEL_AGAINST_YOUR_PARTY));
return;
}
// Target may not be of the same party
else if (activeChar.getParty().getPartyMembers().contains(targetChar))
{
activeChar.sendMessage("This player is a member of your own party.");
return;
}
// Check if every player is ready for a duel
for (L2PcInstance temp : activeChar.getParty().getPartyMembers())
{
if (!temp.canDuel())
{
activeChar.sendMessage("Not all the members of your party are ready for a duel.");
return;
}
}
L2PcInstance partyLeader = null; // snatch party leader of targetChar's party
for (L2PcInstance temp : targetChar.getParty().getPartyMembers())
{
if (partyLeader == null)
{
partyLeader = temp;
}
if (!temp.canDuel())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THE_OPPOSING_PARTY_IS_CURRENTLY_UNABLE_TO_ACCEPT_A_CHALLENGE_TO_A_DUEL));
return;
}
}
// Send request to targetChar's party leader
if (!partyLeader.isProcessingRequest())
{
activeChar.onTransactionRequest(partyLeader);
partyLeader.sendPacket(new ExDuelAskStart(activeChar.getName(), _partyDuel));
if (Config.DEBUG)
{
_log.fine(activeChar.getName() + " requested a duel with " + partyLeader.getName());
}
SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.C1_PARTY_HAS_BEEN_CHALLENGED_TO_A_DUEL);
msg.addString(partyLeader.getName());
activeChar.sendPacket(msg);
msg = SystemMessage.getSystemMessage(SystemMessageId.C1_PARTY_HAS_CHALLENGED_YOUR_PARTY_TO_A_DUEL);
msg.addString(activeChar.getName());
targetChar.sendPacket(msg);
}
else
{
SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_BUSY_TRY_LATER);
msg.addString(partyLeader.getName());
activeChar.sendPacket(msg);
}
}
else
// 1vs1 duel
{
if (!targetChar.isProcessingRequest())
{
activeChar.onTransactionRequest(targetChar);
targetChar.sendPacket(new ExDuelAskStart(activeChar.getName(), _partyDuel));
if (Config.DEBUG)
{
_log.fine(activeChar.getName() + " requested a duel with " + targetChar.getName());
}
SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_BEEN_CHALLENGED_TO_A_DUEL);
msg.addString(targetChar.getName());
activeChar.sendPacket(msg);
msg = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_CHALLENGED_YOU_TO_A_DUEL);
msg.addString(activeChar.getName());
targetChar.sendPacket(msg);
}
else
{
SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_BUSY_TRY_LATER);
msg.addString(targetChar.getName());
activeChar.sendPacket(msg);
}
}
}
/**
* @see com.l2jserver.gameserver.BasePacket#getType()
*/
@Override
public String getType()
{
return _C__D0_27_REQUESTDUELSTART;
}
}
@@ -0,0 +1,51 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.instancemanager.DuelManager;
/**
* Format:(ch) just a trigger
* @author -Wooden-
*/
public final class RequestDuelSurrender extends L2GameClientPacket
{
private static final String _C__D0_30_REQUESTDUELSURRENDER = "[C] D0:30 RequestDuelSurrender";
@Override
protected void readImpl()
{
// trigger
}
/**
* @see com.l2jserver.util.network.BaseRecievePacket.ClientBasePacket#runImpl()
*/
@Override
protected void runImpl()
{
DuelManager.getInstance().doSurrender(getClient().getActiveChar());
}
/**
* @see com.l2jserver.gameserver.BasePacket#getType()
*/
@Override
public String getType()
{
return _C__D0_30_REQUESTDUELSURRENDER;
}
}
@@ -0,0 +1,415 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.SkillTable;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.EnchantResult;
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jserver.gameserver.network.serverpackets.ItemList;
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jserver.gameserver.network.serverpackets.StatusUpdate;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.templates.item.L2Armor;
import com.l2jserver.gameserver.templates.item.L2Item;
import com.l2jserver.gameserver.util.Util;
import com.l2jserver.util.Rnd;
public final class RequestEnchantItem extends AbstractEnchantPacket
{
protected static final Logger _log = Logger.getLogger(RequestEnchantItem.class.getName());
protected static final Logger _logEnchant = Logger.getLogger("enchant");
private static final String _C__58_REQUESTENCHANTITEM = "[C] 58 RequestEnchantItem";
private int _objectId = 0;
private int _supportId;
@Override
protected void readImpl()
{
_objectId = readD();
_supportId = readD();
}
@Override
protected void runImpl()
{
L2PcInstance activeChar = getClient().getActiveChar();
if ((activeChar == null) || (_objectId == 0))
{
return;
}
if (!activeChar.isOnline() || getClient().isDetached())
{
activeChar.setActiveEnchantItem(null);
return;
}
if (activeChar.isProcessingTransaction() || activeChar.isInStoreMode())
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_ENCHANT_WHILE_STORE));
activeChar.setActiveEnchantItem(null);
return;
}
L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);
L2ItemInstance scroll = activeChar.getActiveEnchantItem();
L2ItemInstance support = activeChar.getActiveEnchantSupportItem();
if ((item == null) || (scroll == null))
{
activeChar.setActiveEnchantItem(null);
return;
}
// template for scroll
EnchantScroll scrollTemplate = getEnchantScroll(scroll);
// scroll not found in list
if (scrollTemplate == null)
{
return;
}
// template for support item, if exist
EnchantItem supportTemplate = null;
if (support != null)
{
if (support.getObjectId() != _supportId)
{
activeChar.setActiveEnchantItem(null);
return;
}
supportTemplate = getSupportItem(support);
}
// first validation check
if (!scrollTemplate.isValid(item, supportTemplate) || !isEnchantable(item))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITION));
activeChar.setActiveEnchantItem(null);
activeChar.sendPacket(new EnchantResult(2, 0, 0));
return;
}
// fast auto-enchant cheat check
if ((activeChar.getActiveEnchantTimestamp() == 0) || ((System.currentTimeMillis() - activeChar.getActiveEnchantTimestamp()) < 2000))
{
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " use autoenchant program ", Config.DEFAULT_PUNISH);
activeChar.setActiveEnchantItem(null);
activeChar.sendPacket(new EnchantResult(2, 0, 0));
return;
}
// attempting to destroy scroll
scroll = activeChar.getInventory().destroyItem("Enchant", scroll.getObjectId(), 1, activeChar, item);
if (scroll == null)
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_ITEMS));
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " tried to enchant with a scroll he doesn't have", Config.DEFAULT_PUNISH);
activeChar.setActiveEnchantItem(null);
activeChar.sendPacket(new EnchantResult(2, 0, 0));
return;
}
// attempting to destroy support if exist
if (support != null)
{
support = activeChar.getInventory().destroyItem("Enchant", support.getObjectId(), 1, activeChar, item);
if (support == null)
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_ITEMS));
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " tried to enchant with a support item he doesn't have", Config.DEFAULT_PUNISH);
activeChar.setActiveEnchantItem(null);
activeChar.sendPacket(new EnchantResult(2, 0, 0));
return;
}
}
synchronized (item)
{
int chance = scrollTemplate.getChance(item, supportTemplate);
L2Skill enchant4Skill = null;
L2Item it = item.getItem();
// last validation check
if ((item.getOwnerId() != activeChar.getObjectId()) || !isEnchantable(item) || (chance < 0))
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITION));
activeChar.setActiveEnchantItem(null);
activeChar.sendPacket(new EnchantResult(2, 0, 0));
return;
}
if (Rnd.get(100) < chance)
{
// success
item.setEnchantLevel(item.getEnchantLevel() + 1);
item.updateDatabase();
activeChar.sendPacket(new EnchantResult(0, 0, 0));
if (Config.LOG_ITEM_ENCHANTS)
{
LogRecord record = new LogRecord(Level.INFO, "Success");
record.setParameters(new Object[]
{
activeChar,
item,
scroll,
support,
chance
});
record.setLoggerName("item");
_logEnchant.log(record);
}
// announce the success
int minEnchantAnnounce = item.isArmor() ? 6 : 7;
int maxEnchantAnnounce = item.isArmor() ? 0 : 15;
if ((item.getEnchantLevel() == minEnchantAnnounce) || (item.getEnchantLevel() == maxEnchantAnnounce))
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_SUCCESSFULY_ENCHANTED_A_S2_S3);
sm.addCharName(activeChar);
sm.addNumber(item.getEnchantLevel());
sm.addItemName(item);
activeChar.broadcastPacket(sm);
L2Skill skill = SkillTable.FrequentSkill.FIREWORK.getSkill();
if (skill != null)
{
activeChar.broadcastPacket(new MagicSkillUse(activeChar, activeChar, skill.getId(), skill.getLevel(), skill.getHitTime(), skill.getReuseDelay()));
}
}
if ((it instanceof L2Armor) && (item.getEnchantLevel() == 4) && activeChar.getInventory().getItemByObjectId(item.getObjectId()).isEquipped())
{
enchant4Skill = ((L2Armor) it).getEnchant4Skill();
if (enchant4Skill != null)
{
// add skills bestowed from +4 armor
activeChar.addSkill(enchant4Skill, false);
activeChar.sendSkillList();
}
}
}
else
{
if (scrollTemplate.isSafe())
{
// safe enchant - remain old value
// need retail message
activeChar.sendPacket(new EnchantResult(5, 0, 0));
if (Config.LOG_ITEM_ENCHANTS)
{
LogRecord record = new LogRecord(Level.INFO, "Safe Fail");
record.setParameters(new Object[]
{
activeChar,
item,
scroll,
support,
chance
});
record.setLoggerName("item");
_logEnchant.log(record);
}
}
else
{
// unequip item on enchant failure to avoid item skills stack
if (item.isEquipped())
{
if (item.getEnchantLevel() > 0)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.EQUIPMENT_S1_S2_REMOVED);
sm.addNumber(item.getEnchantLevel());
sm.addItemName(item);
activeChar.sendPacket(sm);
}
else
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_DISARMED);
sm.addItemName(item);
activeChar.sendPacket(sm);
}
L2ItemInstance[] unequiped = activeChar.getInventory().unEquipItemInSlotAndRecord(item.getLocationSlot());
InventoryUpdate iu = new InventoryUpdate();
for (L2ItemInstance itm : unequiped)
{
iu.addModifiedItem(itm);
}
activeChar.sendPacket(iu);
activeChar.broadcastUserInfo();
}
if (scrollTemplate.isBlessed())
{
// blessed enchant - clear enchant value
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.BLESSED_ENCHANT_FAILED));
item.setEnchantLevel(0);
item.updateDatabase();
activeChar.sendPacket(new EnchantResult(3, 0, 0));
if (Config.LOG_ITEM_ENCHANTS)
{
LogRecord record = new LogRecord(Level.INFO, "Blessed Fail");
record.setParameters(new Object[]
{
activeChar,
item,
scroll,
support,
chance
});
record.setLoggerName("item");
_logEnchant.log(record);
}
}
else
{
// enchant failed, destroy item
int crystalId = item.getItem().getCrystalItemId();
int count = item.getCrystalCount() - ((item.getItem().getCrystalCount() + 1) / 2);
if (count < 1)
{
count = 1;
}
L2ItemInstance destroyItem = activeChar.getInventory().destroyItem("Enchant", item, activeChar, null);
if (destroyItem == null)
{
// unable to destroy item, cheater ?
Util.handleIllegalPlayerAction(activeChar, "Unable to delete item on enchant failure from player " + activeChar.getName() + ", possible cheater !", Config.DEFAULT_PUNISH);
activeChar.setActiveEnchantItem(null);
activeChar.sendPacket(new EnchantResult(2, 0, 0));
if (Config.LOG_ITEM_ENCHANTS)
{
LogRecord record = new LogRecord(Level.INFO, "Unable to destroy");
record.setParameters(new Object[]
{
activeChar,
item,
scroll,
support,
chance
});
record.setLoggerName("item");
_logEnchant.log(record);
}
return;
}
L2ItemInstance crystals = null;
if (crystalId != 0)
{
crystals = activeChar.getInventory().addItem("Enchant", crystalId, count, activeChar, destroyItem);
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);
sm.addItemName(crystals);
sm.addItemNumber(count);
activeChar.sendPacket(sm);
}
if (!Config.FORCE_INVENTORY_UPDATE)
{
InventoryUpdate iu = new InventoryUpdate();
if (destroyItem.getCount() == 0)
{
iu.addRemovedItem(destroyItem);
}
else
{
iu.addModifiedItem(destroyItem);
}
if (crystals != null)
{
iu.addItem(crystals);
}
activeChar.sendPacket(iu);
}
else
{
activeChar.sendPacket(new ItemList(activeChar, true));
}
L2World world = L2World.getInstance();
world.removeObject(destroyItem);
if (crystalId == 0)
{
activeChar.sendPacket(new EnchantResult(4, 0, 0));
}
else
{
activeChar.sendPacket(new EnchantResult(1, crystalId, count));
}
if (Config.LOG_ITEM_ENCHANTS)
{
LogRecord record = new LogRecord(Level.INFO, "Fail");
record.setParameters(new Object[]
{
activeChar,
item,
scroll,
support,
chance
});
record.setLoggerName("item");
_logEnchant.log(record);
}
}
}
}
StatusUpdate su = new StatusUpdate(activeChar);
su.addAttribute(StatusUpdate.CUR_LOAD, activeChar.getCurrentLoad());
activeChar.sendPacket(su);
activeChar.sendPacket(new ItemList(activeChar, false));
activeChar.broadcastUserInfo();
activeChar.setActiveEnchantItem(null);
}
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__58_REQUESTENCHANTITEM;
}
}
@@ -0,0 +1,96 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.model.L2CommandChannel;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* format: (ch) d
* @author -Wooden-
*/
public final class RequestExAcceptJoinMPCC extends L2GameClientPacket
{
private static final String _C__D0_0E_REQUESTEXASKJOINMPCC = "[C] D0:0E RequestExAcceptJoinMPCC";
private int _response;
/**
* @param buf
* @param client
*/
@Override
protected void readImpl()
{
_response = readD();
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#runImpl()
*/
@Override
protected void runImpl()
{
L2PcInstance player = getClient().getActiveChar();
if (player != null)
{
L2PcInstance requestor = player.getActiveRequester();
SystemMessage sm;
if (requestor == null)
{
return;
}
if (_response == 1)
{
boolean newCc = false;
if (!requestor.getParty().isInCommandChannel())
{
new L2CommandChannel(requestor); // Create new CC
sm = SystemMessage.getSystemMessage(SystemMessageId.COMMAND_CHANNEL_FORMED);
requestor.sendPacket(sm);
newCc = true;
}
requestor.getParty().getCommandChannel().addParty(player.getParty());
if (!newCc)
{
sm = SystemMessage.getSystemMessage(SystemMessageId.JOINED_COMMAND_CHANNEL);
player.sendPacket(sm);
}
}
else
{
requestor.sendMessage("The player declined to join your Command Channel.");
}
player.setActiveRequester(null);
requestor.onTransactionResponse();
}
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.BasePacket#getType()
*/
@Override
public String getType()
{
return _C__D0_0E_REQUESTEXASKJOINMPCC;
}
}
@@ -0,0 +1,194 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.model.L2Party;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ExAskJoinMPCC;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* Format: (ch) S
* @author chris_00 D0 0D 00 5A 00 77 00 65 00 72 00 67 00 00 00
*/
public final class RequestExAskJoinMPCC extends L2GameClientPacket
{
// private static Logger _log = Logger.getLogger(RequestExAskJoinMPCC.class.getName());
private static final String _C__D0_0D_REQUESTEXASKJOINMPCC = "[C] D0:0D RequestExAskJoinMPCC";
private String _name;
@Override
protected void readImpl()
{
_name = readS();
}
@Override
protected void runImpl()
{
L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
L2PcInstance player = L2World.getInstance().getPlayer(_name);
if (player == null)
{
return;
}
// invite yourself? ;)
if (activeChar.isInParty() && player.isInParty() && activeChar.getParty().equals(player.getParty()))
{
return;
}
SystemMessage sm;
// activeChar is in a Party?
if (activeChar.isInParty())
{
L2Party activeParty = activeChar.getParty();
// activeChar is PartyLeader? && activeChars Party is already in a CommandChannel?
if (activeParty.getLeader().equals(activeChar))
{
// if activeChars Party is in CC, is activeChar CCLeader?
if (activeParty.isInCommandChannel() && activeParty.getCommandChannel().getChannelLeader().equals(activeChar))
{
// in CC and the CCLeader
// target in a party?
if (player.isInParty())
{
// targets party already in a CChannel?
if (player.getParty().isInCommandChannel())
{
sm = SystemMessage.getSystemMessage(SystemMessageId.C1_ALREADY_MEMBER_OF_COMMAND_CHANNEL);
sm.addString(player.getName());
activeChar.sendPacket(sm);
}
else
{
// ready to open a new CC
// send request to targets Party's PartyLeader
askJoinMPCC(activeChar, player);
}
}
else
{
activeChar.sendMessage("Your target has no Party.");
}
}
else if (activeParty.isInCommandChannel() && !activeParty.getCommandChannel().getChannelLeader().equals(activeChar))
{
// in CC, but not the CCLeader
sm = SystemMessage.getSystemMessage(SystemMessageId.CANNOT_INVITE_TO_COMMAND_CHANNEL);
activeChar.sendPacket(sm);
}
else
{
// target in a party?
if (player.isInParty())
{
// targets party already in a CChannel?
if (player.getParty().isInCommandChannel())
{
sm = SystemMessage.getSystemMessage(SystemMessageId.C1_ALREADY_MEMBER_OF_COMMAND_CHANNEL);
sm.addString(player.getName());
activeChar.sendPacket(sm);
}
else
{
// ready to open a new CC
// send request to targets Party's PartyLeader
askJoinMPCC(activeChar, player);
}
}
else
{
activeChar.sendMessage("Your target has no Party.");
}
}
}
else
{
sm = SystemMessage.getSystemMessage(SystemMessageId.CANNOT_INVITE_TO_COMMAND_CHANNEL);
activeChar.sendPacket(sm);
}
}
}
private void askJoinMPCC(L2PcInstance requestor, L2PcInstance target)
{
boolean hasRight = false;
if ((requestor.getClan() != null) && (requestor.getClan().getLeaderId() == requestor.getObjectId()) && (requestor.getClan().getLevel() >= 5))
{
hasRight = true;
}
else if (requestor.getInventory().getItemByItemId(8871) != null)
{
hasRight = true;
}
else if (requestor.getPledgeClass() >= 5) // At least Baron or higher and the skill Clan Imperium
{
for (L2Skill skill : requestor.getAllSkills())
{
// Skill Clan Imperium
if (skill.getId() == 391)
{
hasRight = true;
break;
}
}
}
if (!hasRight)
{
requestor.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.COMMAND_CHANNEL_ONLY_BY_LEVEL_5_CLAN_LEADER_PARTY_LEADER));
return;
}
if (!target.isProcessingRequest())
{
requestor.onTransactionRequest(target);
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.COMMAND_CHANNEL_CONFIRM_FROM_C1);
sm.addString(requestor.getName());
target.getParty().getLeader().sendPacket(sm);
target.getParty().getLeader().sendPacket(new ExAskJoinMPCC(requestor.getName()));
requestor.sendMessage("You invited " + target.getName() + " to your Command Channel.");
}
else
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_BUSY_TRY_LATER);
sm.addString(target.getName());
requestor.sendPacket(sm);
}
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.BasePacket#getType()
*/
@Override
public String getType()
{
return _C__D0_0D_REQUESTEXASKJOINMPCC;
}
}
@@ -0,0 +1,56 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.EnchantResult;
/**
* @author KenM
*/
public class RequestExCancelEnchantItem extends L2GameClientPacket
{
/**
* @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#getType()
*/
@Override
public String getType()
{
return "[C] D0:4E RequestExCancelEnchantItem";
}
/**
* @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#readImpl()
*/
@Override
protected void readImpl()
{
// nothing (trigger)
}
/**
* @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#runImpl()
*/
@Override
protected void runImpl()
{
L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar != null)
{
activeChar.sendPacket(new EnchantResult(2, 0, 0));
activeChar.setActiveEnchantItem(null);
}
}
}
@@ -0,0 +1,62 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.network.serverpackets.ExNeedToChangeName;
/**
* Reply for {@link ExNeedToChangeName}
* @author JIV
*/
public class RequestExChangeName extends L2GameClientPacket
{
private String _newName;
private int _type;
private int _charSlot;
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#readImpl()
*/
@Override
protected void readImpl()
{
_type = readD();
_newName = readS();
_charSlot = readD();
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#runImpl()
*/
@Override
protected void runImpl()
{
_log.info("Recieved " + getType() + " name: " + _newName + " type: " + _type + " CharSlot: " + _charSlot);
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#getType()
*/
@Override
public String getType()
{
return "[C] D0:3B RequestExChangeName".intern();
}
}
@@ -0,0 +1,82 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.util.logging.Logger;
import com.l2jserver.gameserver.instancemanager.HandysBlockCheckerManager;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
/**
* Format: chdd d: Arena d: Team
* @author mrTJO
*/
public final class RequestExCubeGameChangeTeam extends L2GameClientPacket
{
private static final String _C__D0_5A_REQUESTEXCUBEGAMECHANGETEAM = "[C] D0:5A RequestExCubeGameChangeTeam";
private static Logger _log = Logger.getLogger(RequestExCubeGameChangeTeam.class.getName());
int _arena;
int _team;
@Override
protected void readImpl()
{
// client sends -1,0,1,2 for arena parameter
_arena = readD() + 1;
_team = readD();
}
@Override
public void runImpl()
{
// do not remove players after start
if (HandysBlockCheckerManager.getInstance().arenaIsBeingUsed(_arena))
{
return;
}
L2PcInstance player = getClient().getActiveChar();
switch (_team)
{
case 0:
case 1:
// Change Player Team
HandysBlockCheckerManager.getInstance().changePlayerToTeam(player, _arena, _team);
break;
case -1:
// Remove Player (me)
{
int team = HandysBlockCheckerManager.getInstance().getHolder(_arena).getPlayerTeam(player);
// client sends two times this packet if click on exit
// client did not send this packet on restart
if (team > -1)
{
HandysBlockCheckerManager.getInstance().removePlayer(player, _arena, team);
}
break;
}
default:
_log.warning("Wrong Cube Game Team ID: " + _team);
break;
}
}
@Override
public String getType()
{
return _C__D0_5A_REQUESTEXCUBEGAMECHANGETEAM;
}
}
@@ -0,0 +1,72 @@
/*
* 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.l2jserver.gameserver.network.clientpackets;
import java.util.logging.Logger;
import com.l2jserver.gameserver.instancemanager.HandysBlockCheckerManager;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
/**
* @author mrTJO Format: chddd d: Arena d: Answer
*/
public final class RequestExCubeGameReadyAnswer extends L2GameClientPacket
{
private static final String _C__D0_5C_REQUESTEXCUBEGAMEREADYANSWER = "[C] D0:5C RequestExCubeGameReadyAnswer";
private static Logger _log = Logger.getLogger(RequestExCubeGameReadyAnswer.class.getName());
int _arena;
int _answer;
@Override
protected void readImpl()
{
// client sends -1,0,1,2 for arena parameter
_arena = readD() + 1;
// client sends 1 if clicked confirm on not clicked, 0 if clicked cancel
_answer = readD();
}
@Override
public void runImpl()
{
L2PcInstance player = getClient().getActiveChar();
if (player == null)
{
return;
}
switch (_answer)
{
case 0:
// Cancel - Answer No
break;
case 1:
// OK or Time Over
HandysBlockCheckerManager.getInstance().increaseArenaVotes(_arena);
break;
default:
_log.warning("Unknown Cube Game Answer ID: " + _answer);
break;
}
}
@Override
public String getType()
{
return _C__D0_5C_REQUESTEXCUBEGAMEREADYANSWER;
}
}

Some files were not shown because too many files have changed in this diff Show More