Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/L2JHellasC/java/com/l2jhellas/gameserver/ai/L2AttackableAI.java b/L2JHellasC/java/com/l2jhellas/gameserver/ai/L2AttackableAI.java
- index 1260c75..fd8dca1 100644
- --- a/L2JHellasC/java/com/l2jhellas/gameserver/ai/L2AttackableAI.java
- +++ b/L2JHellasC/java/com/l2jhellas/gameserver/ai/L2AttackableAI.java
- @@ -84,7 +84,7 @@
- if (player.isGM() && !player.getAccessLevel().canTakeAggro())
- return false;
- - if (player.isRecentFakeDeath())
- + if (player.isRecentFakeDeath() || player.isDead())
- return false;
- if (!(me.isRaid()) && !(me.canSeeThroughSilentMove()) && player.isSilentMoving())
- diff --git a/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/BeastSoulShot.java b/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/BeastSoulShot.java
- index 0eb22ae..ced9b61 100644
- --- a/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/BeastSoulShot.java
- +++ b/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/BeastSoulShot.java
- @@ -83,7 +83,7 @@
- }
- activeOwner.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.PET_USES_S1).addItemName(itemId));
- - Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(activePet, activePet, 2033, 1, 0, 0), 800);
- + Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(activePet, activePet, 2033, 1, 0, 0), 700);
- }
- @Override
- diff --git a/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/BeastSpice.java b/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/BeastSpice.java
- index d0505ad..849dc6a 100644
- --- a/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/BeastSpice.java
- +++ b/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/BeastSpice.java
- @@ -31,18 +31,9 @@
- activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
- return;
- }
- -
- - int skillId = 0;
- - switch (item.getItemId())
- - {
- - case 6643:
- - skillId = 2188;
- - break;
- - case 6644:
- - skillId = 2189;
- - break;
- - }
- -
- +
- + int skillId = item.getItemId() == 6643 ? 2188 : item.getItemId() == 6644 ? 2189 : 0;
- +
- final L2Skill skill = SkillTable.getInstance().getInfo(skillId, 1);
- if (skill != null)
- activeChar.useMagic(skill, false, false);
- diff --git a/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/BeastSpiritShot.java b/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/BeastSpiritShot.java
- index 7a3f1c0..52150a2 100644
- --- a/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/BeastSpiritShot.java
- +++ b/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/BeastSpiritShot.java
- @@ -89,7 +89,7 @@
- }
- activeOwner.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.PET_USES_S1).addItemName(itemId));
- - Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(activePet, activePet, ((itemId == 6646) ? 2008 : 2009), 1, 0, 0), 800);
- + Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(activePet, activePet, ((itemId == 6646) ? 2008 : 2009), 1, 0, 0), 700);
- }
- @Override
- diff --git a/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/BlessedSpiritShot.java b/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/BlessedSpiritShot.java
- index 8e0d26c..4ac9554 100644
- --- a/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/BlessedSpiritShot.java
- +++ b/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/BlessedSpiritShot.java
- @@ -105,7 +105,7 @@
- // Send message to client
- activeChar.sendPacket(SystemMessageId.ENABLED_SPIRITSHOT);
- - Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, SKILL_IDS[weaponGrade.getId()], 1, 0, 0), 600);
- + Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, SKILL_IDS[weaponGrade.getId()], 1, 0, 0), 500);
- }
- @Override
- diff --git a/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/CharChangePotions.java b/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/CharChangePotions.java
- index ffd5f3a..4608515 100644
- --- a/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/CharChangePotions.java
- +++ b/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/CharChangePotions.java
- @@ -50,6 +50,9 @@
- return;
- }
- + if (!activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false))
- + return;
- +
- switch (itemId)
- {
- case 5235:
- @@ -96,19 +99,9 @@
- break;
- }
- - // Create a summon effect!
- - MagicSkillUse MSU = new MagicSkillUse(playable, activeChar, 2003, 1, 1, 0);
- - activeChar.broadcastPacket(MSU, 1500);
- -
- - // Update the changed stat for the character in the DB.
- activeChar.store();
- -
- - // Remove the item from inventory.
- - activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false);
- -
- - // Broadcast the changes to the char and all those nearby.
- - UserInfo ui = new UserInfo(activeChar);
- - activeChar.broadcastPacket(ui, 1500);
- + activeChar.broadcastPacket(new MagicSkillUse(playable, activeChar, 2003, 1, 1, 0), 1500);
- + activeChar.broadcastPacket(new UserInfo(activeChar), 1500);
- }
- @Override
- diff --git a/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/MapForestOfTheDead.java b/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/MapForestOfTheDead.java
- index 20dd899..21bc9a4 100644
- --- a/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/MapForestOfTheDead.java
- +++ b/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/MapForestOfTheDead.java
- @@ -21,12 +21,9 @@
- public void useItem(L2Playable playable, L2ItemInstance item)
- {
- if (!(playable instanceof L2PcInstance))
- - {
- return;
- - }
- - int itemId = item.getItemId();
- - if (itemId == 7063)
- + if (item.getItemId() == 7063)
- {
- NpcHtmlMessage html = new NpcHtmlMessage(5);
- StringBuilder map = new StringBuilder("<html><title>Map - Forest of the Dead</title>");
- diff --git a/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/Potions.java b/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/Potions.java
- index 03581ed..017b4dc 100644
- --- a/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/Potions.java
- +++ b/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/Potions.java
- @@ -10,7 +10,6 @@
- import com.l2jhellas.gameserver.model.actor.instance.L2PetInstance;
- import com.l2jhellas.gameserver.model.actor.item.L2ItemInstance;
- import com.l2jhellas.gameserver.network.SystemMessageId;
- -import com.l2jhellas.gameserver.network.serverpackets.ActionFailed;
- import com.l2jhellas.gameserver.network.serverpackets.SystemMessage;
- import com.l2jhellas.gameserver.skills.SkillTable;
- @@ -138,13 +137,7 @@
- activeChar.sendPacket(SystemMessageId.THIS_ITEM_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT);
- return;
- }
- -
- - if (activeChar.isAllSkillsDisabled())
- - {
- - activeChar.sendPacket(ActionFailed.STATIC_PACKET);
- - return;
- - }
- -
- +
- if (!Config.ALLOW_POTS_IN_PVP)
- {
- if (activeChar.getPvpFlag() != 0)
- @@ -449,9 +442,7 @@
- // custom pot durations...
- if (e.getTaskTime() > (e.getSkill().getBuffDuration() * 67) / 100000)
- return true;
- - SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_PREPARED_FOR_REUSE);
- - sm.addItemName(itemId);
- - activeChar.sendPacket(sm);
- + activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_PREPARED_FOR_REUSE).addItemName(itemId));
- return false;
- }
- }
- diff --git a/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/Primeval.java b/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/Primeval.java
- index 13ba377..77d3dcd 100644
- --- a/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/Primeval.java
- +++ b/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/Primeval.java
- @@ -29,17 +29,11 @@
- L2PcInstance activeChar;
- if (playable instanceof L2PcInstance)
- - {
- activeChar = (L2PcInstance) playable;
- - }
- else if (playable instanceof L2PetInstance)
- - {
- activeChar = ((L2PetInstance) playable).getOwner();
- - }
- else
- - {
- return;
- - }
- if (activeChar.isInOlympiadMode())
- {
- @@ -53,26 +47,17 @@
- return;
- }
- + if (!activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false))
- + return;
- +
- int itemId = item.getItemId();
- - L2Skill skill = null;
- - switch (itemId)
- - {
- - case 8786:
- - skill = SkillTable.getInstance().getInfo(2305, 1);
- - break;
- - // Springant's Fruit need correct skill id (effect primeval potions is a temp fix).
- - case 8787:
- - skill = SkillTable.getInstance().getInfo(2305, 1);
- - break;
- - default:
- - }
- -
- + L2Skill skill = itemId == 8786 ? SkillTable.getInstance().getInfo(2305, 1)
- + // Springant's Fruit need correct skill id (effect primeval potions is a temp fix).
- + : itemId == 8787 ? SkillTable.getInstance().getInfo(2305, 1) : null;
- +
- if (skill != null)
- - {
- activeChar.doCast(skill);
- - playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
- - }
- }
- @Override
- diff --git a/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/SoulShots.java b/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/SoulShots.java
- index 31923bc..01ff8f7 100644
- --- a/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/SoulShots.java
- +++ b/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/SoulShots.java
- @@ -98,7 +98,7 @@
- // Send message to client
- activeChar.sendPacket(SystemMessageId.ENABLED_SOULSHOT);
- - Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, SKILL_IDS[weaponGrade.getId()], 1, 0, 0), 600);
- + Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, SKILL_IDS[weaponGrade.getId()], 1, 0, 0), 500);
- }
- @Override
- diff --git a/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/SpiritShot.java b/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/SpiritShot.java
- index 716a812..589404e 100644
- --- a/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/SpiritShot.java
- +++ b/L2JHellasC/java/com/l2jhellas/gameserver/handlers/itemhandlers/SpiritShot.java
- @@ -94,7 +94,7 @@
- // Send message to client
- activeChar.sendPacket(SystemMessageId.ENABLED_SPIRITSHOT);
- - Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, SKILL_IDS[weaponGrade.getId()], 1, 0, 0), 600);
- + Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, SKILL_IDS[weaponGrade.getId()], 1, 0, 0), 500);
- }
- @Override
- diff --git a/L2JHellasC/java/com/l2jhellas/gameserver/instancemanager/ItemsOnGroundManager.java b/L2JHellasC/java/com/l2jhellas/gameserver/instancemanager/ItemsOnGroundManager.java
- index 5ca11d8..59a6c6a 100644
- --- a/L2JHellasC/java/com/l2jhellas/gameserver/instancemanager/ItemsOnGroundManager.java
- +++ b/L2JHellasC/java/com/l2jhellas/gameserver/instancemanager/ItemsOnGroundManager.java
- @@ -29,7 +29,7 @@
- return;
- _items = new ArrayList<>();
- if (Config.SAVE_DROPPED_ITEM_INTERVAL > 0)
- - ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new storeInDb(), Config.SAVE_DROPPED_ITEM_INTERVAL, Config.SAVE_DROPPED_ITEM_INTERVAL);
- + ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new saveTask(), Config.SAVE_DROPPED_ITEM_INTERVAL, Config.SAVE_DROPPED_ITEM_INTERVAL);
- }
- public static final ItemsOnGroundManager getInstance()
- @@ -56,79 +56,72 @@
- if (!Config.SAVE_DROPPED_ITEM)
- return;
- + _items.clear();
- +
- // if DestroyPlayerDroppedItem was previously false, items curently protected will be added to ItemsAutoDestroy
- if (Config.DESTROY_DROPPED_PLAYER_ITEM)
- {
- - try (Connection con = L2DatabaseFactory.getInstance().getConnection())
- + String str = null;
- + if (!Config.DESTROY_EQUIPABLE_PLAYER_ITEM) // Recycle Misc
- + str = "UPDATE itemsonground SET drop_time=? WHERE drop_time=-1 AND equipable=0";
- + else if (Config.DESTROY_EQUIPABLE_PLAYER_ITEM) // Recycle All
- + str = "UPDATE itemsonground SET drop_time=? WHERE drop_time=-1";
- +
- + try (Connection con = L2DatabaseFactory.getInstance().getConnection();
- + PreparedStatement ps = con.prepareStatement(str))
- {
- - String str = null;
- - if (!Config.DESTROY_EQUIPABLE_PLAYER_ITEM) // Recycle Misc
- - str = "UPDATE itemsonground SET drop_time=? WHERE drop_time=-1 AND equipable=0";
- - else if (Config.DESTROY_EQUIPABLE_PLAYER_ITEM) // Recycle All
- - str = "UPDATE itemsonground SET drop_time=? WHERE drop_time=-1";
- -
- - PreparedStatement statement = con.prepareStatement(str);
- - statement.setLong(1, System.currentTimeMillis());
- - statement.execute();
- - statement.close();
- + ps.setLong(1, System.currentTimeMillis());
- + ps.execute();
- }
- catch (SQLException e)
- {
- _log.warning(ItemsOnGroundManager.class.getName() + ": error while updating table ItemsOnGround ");
- if (Config.DEVELOPER)
- e.printStackTrace();
- - }
- + }
- }
- // Add items to world
- - try (Connection con = L2DatabaseFactory.getInstance().getConnection())
- + try (Connection con = L2DatabaseFactory.getInstance().getConnection();
- + PreparedStatement ps = con.prepareStatement("SELECT object_id,item_id,count,enchant_level,x,y,z,drop_time,equipable FROM itemsonground"))
- {
- - Statement s = con.createStatement();
- - ResultSet result;
- - int count = 0;
- - result = s.executeQuery("SELECT object_id,item_id,count,enchant_level,x,y,z,drop_time,equipable FROM itemsonground");
- - while (result.next())
- + try (ResultSet rs = ps.executeQuery())
- {
- - L2ItemInstance item = new L2ItemInstance(result.getInt(1), result.getInt(2));
- - L2World.getInstance().storeObject(item);
- - if (item.isStackable() && result.getInt(3) > 1) // this check and..
- - item.setCount(result.getInt(3));
- - if (result.getInt(4) > 0) // this, are really necessary?
- - item.setEnchantLevel(result.getInt(4));
- - item.getPosition().setWorldPosition(result.getInt(5), result.getInt(6), result.getInt(7));
- - item.getPosition().setWorldRegion(L2World.getInstance().getRegion(item.getPosition().getWorldPosition()));
- - item.getWorldRegion().addVisibleObject(item);
- - item.setDropTime(result.getLong(8));
- - if (result.getLong(8) == -1)
- - item.setProtected(true);
- - else
- - item.setProtected(false);
- - item.setIsVisible(true);
- - L2World.getInstance().addVisibleObject(item, item.getWorldRegion());
- - _items.add(item);
- - count++;
- - // add to ItemsAutoDestroy only items not protected
- - if (!Config.LIST_PROTECTED_ITEMS.contains(item.getItemId()))
- + while (rs.next())
- {
- - if (result.getLong(8) > -1)
- + L2ItemInstance item = new L2ItemInstance(rs.getInt(1), rs.getInt(2));
- +
- + L2World.getInstance().storeObject(item);
- +
- + if (item.isStackable() && rs.getInt(3) > 1) // this check and..
- + item.setCount(rs.getInt(3));
- + if (rs.getInt(4) > 0) // this, are really necessary?
- + item.setEnchantLevel(rs.getInt(4));
- +
- + item.getPosition().setWorldPosition(rs.getInt(5),rs.getInt(6),rs.getInt(7));
- + item.getPosition().setWorldRegion(L2World.getInstance().getRegion(item.getPosition().getWorldPosition()));
- + item.getWorldRegion().addVisibleObject(item);
- + item.setDropTime(rs.getLong(8));
- + item.setProtected(rs.getLong(8) == -1 ? true : false);
- + item.setIsVisible(true);
- + L2World.getInstance().addVisibleObject(item, item.getWorldRegion());
- + _items.add(item);
- +
- + // add to ItemsAutoDestroy only items not protected
- + if (!Config.LIST_PROTECTED_ITEMS.contains(item.getItemId()))
- {
- - if (Config.AUTODESTROY_ITEM_AFTER > 0)
- - ItemsAutoDestroy.getInstance().addItem(item);
- + if (rs.getLong(8) > -1 && Config.AUTODESTROY_ITEM_AFTER > 0)
- + ItemsAutoDestroy.getInstance().addItem(item);
- }
- }
- }
- - result.close();
- - s.close();
- - if (count > 0)
- - _log.info(ItemsOnGroundManager.class.getSimpleName() + ": restored " + count + " items.");
- - else
- - _log.info(ItemsOnGroundManager.class.getSimpleName() + ": Initializing ItemsOnGroundManager.");
- +
- + _log.info(ItemsOnGroundManager.class.getSimpleName() + ": Initializing ItemsOnGroundManager.");
- }
- - catch (SQLException e)
- + catch (Exception e)
- {
- _log.warning(ItemsOnGroundManager.class.getName() + ": error while loading ItemsOnGround ");
- - if (Config.DEVELOPER)
- - e.printStackTrace();
- + e.printStackTrace();
- }
- if (Config.EMPTY_DROPPED_ITEM_TABLE_AFTER_LOAD)
- @@ -149,7 +142,7 @@
- public void saveInDb()
- {
- - new storeInDb().run();
- + storeInDb();
- }
- public void cleanUp()
- @@ -159,41 +152,49 @@
- public void emptyTable()
- {
- - try (Connection con = L2DatabaseFactory.getInstance().getConnection())
- + try (Connection con = L2DatabaseFactory.getInstance().getConnection();
- + Statement s = con.createStatement())
- {
- - PreparedStatement del = con.prepareStatement("DELETE FROM itemsonground");
- - del.execute();
- - del.close();
- + s.executeUpdate("DELETE FROM itemsonground");
- }
- - catch (SQLException e)
- + catch (Exception e)
- {
- _log.warning(ItemsOnGroundManager.class.getName() + ": error while cleaning table ItemsOnGround ");
- - if (Config.DEVELOPER)
- - e.printStackTrace();
- }
- }
- -
- - protected class storeInDb extends Thread
- +
- + protected class saveTask implements Runnable
- {
- @Override
- public void run()
- {
- - if (!Config.SAVE_DROPPED_ITEM)
- - return;
- -
- - emptyTable();
- -
- - if (_items.isEmpty())
- - return;
- -
- + storeInDb();
- + }
- + }
- +
- + private synchronized void storeInDb()
- + {
- + if (!Config.SAVE_DROPPED_ITEM)
- + return;
- +
- + emptyTable();
- +
- + if (_items.isEmpty())
- + return;
- +
- + try (Connection con = L2DatabaseFactory.getInstance().getConnection();
- + PreparedStatement statement = con.prepareStatement("INSERT INTO itemsonground(object_id,item_id,count,enchant_level,x,y,z,drop_time,equipable) VALUES (?,?,?,?,?,?,?,?,?)"))
- + {
- for (L2ItemInstance item : _items)
- {
- + if (item == null)
- + continue;
- +
- if (CursedWeaponsManager.getInstance().isCursed(item.getItemId()))
- - continue; // Cursed Items not saved to ground, prevent double save
- -
- - try (Connection con = L2DatabaseFactory.getInstance().getConnection())
- + continue;
- +
- + try
- {
- - PreparedStatement statement = con.prepareStatement("INSERT INTO itemsonground(object_id,item_id,count,enchant_level,x,y,z,drop_time,equipable) VALUES (?,?,?,?,?,?,?,?,?)");
- statement.setInt(1, item.getObjectId());
- statement.setInt(2, item.getItemId());
- statement.setInt(3, item.getCount());
- @@ -201,27 +202,20 @@
- statement.setInt(5, item.getX());
- statement.setInt(6, item.getY());
- statement.setInt(7, item.getZ());
- -
- - if (item.isProtected())
- - statement.setLong(8, -1); // item will be protected
- - else
- - statement.setLong(8, item.getDropTime()); // item will be added to ItemsAutoDestroy
- - if (item.isEquipable())
- - statement.setLong(9, 1); // set equipable
- - else
- - statement.setLong(9, 0);
- - statement.execute();
- - statement.close();
- + statement.setLong(8, item.isProtected() ? -1 : item.getDropTime());
- + statement.setLong(9, item.isEquipable() ? 1 : 0);
- }
- - catch (SQLException e)
- - {
- + catch (Exception e)
- + {
- _log.warning(ItemsOnGroundManager.class.getName() + ": error while inserting into table ItemsOnGround ");
- - if (Config.DEVELOPER)
- - e.printStackTrace();
- + e.printStackTrace();
- }
- }
- - if (Config.DEBUG)
- - _log.config(ItemsOnGroundManager.class.getName() + ": " + _items.size() + " items on ground saved.");
- + }
- + catch (SQLException e)
- + {
- + _log.warning(ItemsOnGroundManager.class.getName() + ": error while storing items on groun ");
- + e.printStackTrace();
- }
- }
- }
- \ No newline at end of file
- diff --git a/L2JHellasC/java/com/l2jhellas/gameserver/instancemanager/MercTicketManager.java b/L2JHellasC/java/com/l2jhellas/gameserver/instancemanager/MercTicketManager.java
- index d95afc7..0f2177b 100644
- --- a/L2JHellasC/java/com/l2jhellas/gameserver/instancemanager/MercTicketManager.java
- +++ b/L2JHellasC/java/com/l2jhellas/gameserver/instancemanager/MercTicketManager.java
- @@ -40,192 +40,28 @@
- private List<L2ItemInstance> _droppedTickets; // to keep track of items on the ground
- - // TODO move all these values into siege.ini
- // max tickets per merc type = 10 + (castleid * 2)?
- // max ticker per castle = 40 + (castleid * 20)?
- private static final int[] MAX_MERC_PER_TYPE =
- - {
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10, // Gludio
- - 15,
- - 15,
- - 15,
- - 15,
- - 15,
- - 15,
- - 15,
- - 15,
- - 15,
- - 15,
- - 15,
- - 15,
- - 15,
- - 15,
- - 15,
- - 15,
- - 15,
- - 15,
- - 15,
- - 15, // Dion
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10, // Giran
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10,
- - 10, // Oren
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20, // Aden
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20, // Innadril
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20, // Goddard
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20, // Rune
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20,
- - 20
- - // Schuttgart
- + {10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- + 10, // Gludio
- + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- + 15, 15, 15, // Dion
- + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- + 10, 10, 10, // Giran
- + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- + 10, 10, 10, // Oren
- + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- + 20, 20, 20, // Aden
- + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- + 20, 20, 20, // Innadril
- + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- + 20, 20, 20, // Goddard
- + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- + 20, 20, 20, // Rune
- + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- + 20, 20, 20
- + // Schuttgart
- };
- private static final int[] MERCS_MAX_PER_CASTLE =
- {
- diff --git a/L2JHellasC/java/com/l2jhellas/gameserver/model/L2Skill.java b/L2JHellasC/java/com/l2jhellas/gameserver/model/L2Skill.java
- index c0fa064..efd3328 100644
- --- a/L2JHellasC/java/com/l2jhellas/gameserver/model/L2Skill.java
- +++ b/L2JHellasC/java/com/l2jhellas/gameserver/model/L2Skill.java
- @@ -10,6 +10,7 @@
- import com.l2jhellas.gameserver.enums.ZoneId;
- import com.l2jhellas.gameserver.enums.items.L2ArmorType;
- import com.l2jhellas.gameserver.enums.player.ClassId;
- +import com.l2jhellas.gameserver.enums.player.Position;
- import com.l2jhellas.gameserver.enums.skills.HeroSkills;
- import com.l2jhellas.gameserver.enums.skills.L2SkillTargetType;
- import com.l2jhellas.gameserver.enums.skills.L2SkillType;
- @@ -1379,14 +1380,18 @@
- };
- int radius = getSkillRadius();
- - for (L2Object obj : L2World.getInstance().getVisibleObjects(activeChar, L2Object.class, radius))
- + for (L2Character obj : L2World.getInstance().getVisibleObjects(activeChar, L2Character.class, radius))
- {
- if (obj == null)
- continue;
- +
- if (!Util.checkIfInRange(radius, activeChar, obj, true))
- continue;
- - if (obj instanceof L2Attackable && obj != target)
- + final Position position = Position.getPosition(activeChar,obj);
- + final boolean isFront = position != Position.BACK;
- +
- + if (isFront && obj instanceof L2Attackable && obj != target)
- targetList.add((L2Character) obj);
- if (targetList.size() == 0)
- @@ -1396,8 +1401,6 @@
- }
- }
- return targetList.toArray(new L2Character[targetList.size()]);
- - // TODO multiface targets all around right now. need it to just get targets
- - // the character is facing.
- }
- case TARGET_PARTY:
- {
- @@ -1532,23 +1535,26 @@
- {
- // Get all visible objects in a spheric area near the L2Character
- // Get Clan Members
- - for (L2Object newTarget : L2World.getInstance().getVisibleObjects(activeChar, L2Object.class, radius))
- + for (L2PcInstance newTarget : L2World.getInstance().getVisibleObjects(activeChar, L2PcInstance.class, radius))
- {
- - if (newTarget == null || !(newTarget instanceof L2PcInstance))
- + if (newTarget == null)
- continue;
- - if ((((L2PcInstance) newTarget).getAllyId() == 0 || ((L2PcInstance) newTarget).getAllyId() != player.getAllyId()) && (((L2PcInstance) newTarget).getClan() == null || ((L2PcInstance) newTarget).getClanId() != player.getClanId()))
- +
- + if ((newTarget.getAllyId() == 0 || (newTarget.getAllyId() != player.getAllyId()) && newTarget.getClan() == null || newTarget.getClanId() != player.getClanId()))
- continue;
- +
- if (player.isInDuel() && (player.getDuelId() != ((L2PcInstance) newTarget).getDuelId() || (player.getParty() != null && !player.getParty().getPartyMembers().contains(newTarget))))
- continue;
- if (targetType == L2SkillTargetType.TARGET_CORPSE_ALLY)
- {
- - if (!((L2PcInstance) newTarget).isDead())
- + if (!newTarget.isDead())
- continue;
- +
- if (getSkillType() == L2SkillType.RESURRECT)
- {
- // check target is not in a active siege zone
- - if (((L2PcInstance) newTarget).isInsideZone(ZoneId.SIEGE))
- + if (newTarget.isInsideZone(ZoneId.SIEGE))
- continue;
- }
- }
- diff --git a/L2JHellasC/java/com/l2jhellas/gameserver/model/actor/L2Character.java b/L2JHellasC/java/com/l2jhellas/gameserver/model/actor/L2Character.java
- index a02fcfa..5b20c6d 100644
- --- a/L2JHellasC/java/com/l2jhellas/gameserver/model/actor/L2Character.java
- +++ b/L2JHellasC/java/com/l2jhellas/gameserver/model/actor/L2Character.java
- @@ -436,6 +436,12 @@
- if (TargetPlayer != null)
- {
- + if(TargetPlayer.getAppearance().getInvisible())
- + {
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- +
- if(player.isInFunEvent() && TargetPlayer.isInFunEvent() && !EventManager.getInstance().canAttack(player,TargetPlayer))
- {
- player.sendPacket(ActionFailed.STATIC_PACKET);
- @@ -471,7 +477,7 @@
- }
- if(player != null && stopMov)
- - stopMove(null);
- + player.stopMove(null);
- // Get the active weapon instance (always equipped in the right hand)
- L2ItemInstance weaponInst = getActiveWeaponInstance();
- @@ -878,53 +884,51 @@
- }
- public void doCast(L2Skill skill)
- - {
- + {
- if (skill == null)
- {
- getAI().notifyEvent(CtrlEvent.EVT_CANCEL);
- return;
- }
- - if (isSkillDisabled(skill.getId()))
- + if(!skill.isPotion())
- {
- - if (this instanceof L2PcInstance)
- + if (isSkillDisabled(skill.getId()))
- {
- - SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_PREPARED_FOR_REUSE);
- - sm.addSkillName(skill.getId(), skill.getLevel());
- - sendPacket(sm);
- + if (isPlayer())
- + sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_PREPARED_FOR_REUSE).addSkillName(skill.getId(), skill.getLevel()));
- +
- + return;
- }
- - return;
- + // Check if the skill is a magic spell and if the L2Character is not muted
- + if (skill.isMagic() && isMuted())
- + {
- + getAI().notifyEvent(CtrlEvent.EVT_CANCEL);
- + return;
- + }
- +
- + // Check if the skill is psychical and if the L2Character is not psychical_muted
- + if (!skill.isMagic() && isPsychicalMuted())
- + {
- + getAI().notifyEvent(CtrlEvent.EVT_CANCEL);
- + return;
- + }
- }
- - // Check if the skill is a magic spell and if the L2Character is not muted
- - if (skill.isMagic() && isMuted() && !skill.isPotion())
- - {
- - getAI().notifyEvent(CtrlEvent.EVT_CANCEL);
- - return;
- - }
- -
- - // Check if the skill is psychical and if the L2Character is not psychical_muted
- - if (!skill.isMagic() && isPsychicalMuted() && !skill.isPotion())
- - {
- - getAI().notifyEvent(CtrlEvent.EVT_CANCEL);
- - return;
- - }
- -
- - if (this instanceof L2PcInstance)
- + if (isPlayer())
- {
- L2PcInstance player = (L2PcInstance) this;
- if (player.getTarget() != null && player.getTarget() == player && skill.getSkillType() == L2SkillType.CHARGEDAM)
- return;
- - }
- -
- - // Can't use Hero and resurrect skills during Olympiad
- - if (this instanceof L2PcInstance && ((L2PcInstance) this).isInOlympiadMode() && (skill.isHeroSkill() || skill.getSkillType() == L2SkillType.RESURRECT))
- - {
- - SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.THIS_SKILL_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT);
- - sendPacket(sm);
- - return;
- +
- + // Can't use Hero and resurrect skills during Olympiad
- + if (player.isInOlympiadMode() && (skill.isHeroSkill() || skill.getSkillType() == L2SkillType.RESURRECT))
- + {
- + player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THIS_SKILL_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT));
- + return;
- + }
- }
- // prevent casting signets to peace zone
- @@ -945,9 +949,7 @@
- canCast = false;
- if (!canCast)
- {
- - SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED);
- - sm.addSkillName(skill);
- - sendPacket(sm);
- + sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED).addSkillName(skill));
- return;
- }
- }
- @@ -961,7 +963,7 @@
- {
- target = (L2Character) targets[0];
- - if (this instanceof L2PcInstance && target instanceof L2PcInstance && target.getAI().getIntention() == CtrlIntention.AI_INTENTION_ATTACK)
- + if (isPlayer() && target.isPlayer() && target.getAI().getIntention() == CtrlIntention.AI_INTENTION_ATTACK)
- {
- if (skill.getSkillType() == L2SkillType.BUFF || skill.getSkillType() == L2SkillType.HOT || skill.getSkillType() == L2SkillType.HEAL || skill.getSkillType() == L2SkillType.HEAL_PERCENT || skill.getSkillType() == L2SkillType.MANAHEAL || skill.getSkillType() == L2SkillType.MANAHEAL_PERCENT || skill.getSkillType() == L2SkillType.BALANCE_LIFE)
- target.setLastBuffer(this);
- @@ -1081,13 +1083,9 @@
- broadcastPacket(!skill.isPotion() ? new MagicSkillUse(this, target, displayId, level, hitTime, reuseDelay, false) : new MagicSkillUse(this, target, displayId, level, 0, 0));
- // Send a system message USE_S1 to the L2Character
- - if (this instanceof L2PcInstance && magicId != 1312)
- - {
- - SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.USE_S1);
- - sm.addSkillName(magicId, skill.getLevel());
- - sendPacket(sm);
- - }
- -
- + if (isPlayer() && magicId != 1312)
- + sendPacket(SystemMessage.getSystemMessage(SystemMessageId.USE_S1).addSkillName(magicId, skill.getLevel()));
- +
- // Skill reuse check
- if (reuseDelay > 30000 && !skillMastery)
- addTimeStamp(skill.getId(), reuseDelay);
- @@ -1393,7 +1391,7 @@
- {
- return _allSkillsDisabled || isImmobileUntilAttacked() || isStunned() || isSleeping() || isParalyzed();
- }
- -
- +
- public boolean isAttackingDisabled()
- {
- return isImmobileUntilAttacked() || isStunned() || isSleeping() || _attackEndTime > GameTimeController.getInstance().getGameTicks() || isFakeDeath() || isParalyzed();
- @@ -2682,7 +2680,7 @@
- // cancels the skill hit scheduled task
- enableAllSkills(); // re-enables the skills
- - if (this instanceof L2PcInstance)
- + if (isPlayer())
- getAI().notifyEvent(CtrlEvent.EVT_FINISH_CASTING); // setting
- // back
- // previous
- @@ -3986,10 +3984,7 @@
- }
- targets = targetList.toArray(new L2Character[targetList.size()]);
- }
- -
- - // Ensure that a cast is in progress
- - // Check if player is using fake death.
- - // Potions can be used while faking death.
- +
- if (!isCastingNow() || (isAlikeDead() && !skill.isPotion()))
- {
- _skillCast = null;
- @@ -4180,11 +4175,11 @@
- {
- getAI().clientStartAutoAttack();
- - if (target instanceof L2PcInstance)
- + if (target.isPlayer())
- {
- ((L2PcInstance) target).getAI().clientStartAutoAttack();
- - player = null;
- + L2PcInstance player = null;
- if (this instanceof L2PcInstance)
- player = (L2PcInstance) this;
- @@ -4333,7 +4328,7 @@
- default: // Launch weapon Special ability skill effect if available
- if (getActiveWeaponItem() != null && !target.isDead())
- {
- - if (this instanceof L2PcInstance && getActiveWeaponItem().getSkillEffects(this, target, skill).length > 0)
- + if (isPlayer() && getActiveWeaponItem().getSkillEffects(this, target, skill).length > 0)
- sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_ACTIVATED).addSkillName(skill));
- }
- @@ -4400,7 +4395,7 @@
- }
- else
- {
- - if (target instanceof L2PcInstance)
- + if (target.isPlayer())
- {
- // Casting non offensive skill on player with pvp flag set or with karma
- if (!(target.equals(this) || target.equals(player)) && (((L2PcInstance) target).getPvpFlag() > 0 || ((L2PcInstance) target).getKarma() > 0))
- @@ -5081,7 +5076,6 @@
- getAI().stopAITask();
- }
- - private L2PcInstance player;
- public final void stopEffectsOnDamage(boolean awake)
- {
- diff --git a/L2JHellasC/java/com/l2jhellas/gameserver/model/actor/instance/L2EventBossInstance.java b/L2JHellasC/java/com/l2jhellas/gameserver/model/actor/instance/L2EventBossInstance.java
- index bcd2800..92453e4 100644
- --- a/L2JHellasC/java/com/l2jhellas/gameserver/model/actor/instance/L2EventBossInstance.java
- +++ b/L2JHellasC/java/com/l2jhellas/gameserver/model/actor/instance/L2EventBossInstance.java
- @@ -34,22 +34,10 @@
- @Override
- public void reduceCurrentHp(double damage, L2Character attacker, boolean awake)
- {
- - if (IsInSocialAction() || isInvul())
- + if (isInvul())
- return;
- super.reduceCurrentHp(damage, attacker, awake);
- - }
- -
- - protected boolean _isInSocialAction = false;
- -
- - public boolean IsInSocialAction()
- - {
- - return _isInSocialAction;
- - }
- -
- - public void setIsInSocialAction(boolean value)
- - {
- - _isInSocialAction = value;
- }
- @Override
- @@ -79,22 +67,10 @@
- }
- return true;
- }
- -
- - @Override
- - public void doAttack(L2Character target,boolean stopMov)
- - {
- - if (_isInSocialAction)
- - return;
- - super.doAttack(target,true);
- - }
- -
- @Override
- public void doCast(L2Skill skill)
- {
- - if (_isInSocialAction)
- - return;
- -
- super.doCast(skill);
- }
- diff --git a/L2JHellasC/java/com/l2jhellas/gameserver/model/actor/item/Inventory.java b/L2JHellasC/java/com/l2jhellas/gameserver/model/actor/item/Inventory.java
- index e52d351..0aebe93 100644
- --- a/L2JHellasC/java/com/l2jhellas/gameserver/model/actor/item/Inventory.java
- +++ b/L2JHellasC/java/com/l2jhellas/gameserver/model/actor/item/Inventory.java
- @@ -3,7 +3,6 @@
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- -import java.sql.SQLException;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Objects;
- @@ -1152,71 +1151,66 @@
- return getItemByItemId(arrowsId);
- }
- +
- @Override
- public void restore()
- {
- - try (Connection con = L2DatabaseFactory.getInstance().getConnection())
- + try (Connection con = L2DatabaseFactory.getInstance().getConnection();
- + PreparedStatement ps = con.prepareStatement("SELECT object_id, item_id, count, enchant_level, loc, loc_data, price_sell, price_buy, custom_type1, custom_type2, mana_left FROM items WHERE owner_id=? AND (loc=? OR loc=?) ORDER BY loc_data"))
- {
- - PreparedStatement statement = con.prepareStatement("SELECT object_id FROM items WHERE owner_id=? AND (loc=? OR loc=?) " + "ORDER BY object_id DESC");
- - statement.setInt(1, getOwner().getObjectId());
- - statement.setString(2, getBaseLocation().name());
- - statement.setString(3, getEquipLocation().name());
- - ResultSet inv = statement.executeQuery();
- + ps.setInt(1, getOwnerId());
- + ps.setString(2, getBaseLocation().name());
- + ps.setString(3, getEquipLocation().name());
- - L2ItemInstance item;
- - while (inv.next())
- + try (ResultSet rs = ps.executeQuery())
- {
- - int objectId = inv.getInt(1);
- - item = L2ItemInstance.restoreFromDb(objectId);
- - if (item == null)
- - continue;
- -
- - if (L2World.getInstance().findObject(inv.getInt("object_id")) != null)
- + while (rs.next())
- {
- - _log.warning(Inventory.class.getSimpleName() + ": Item: " + item.getObjectId() + " Has duplied on world and cannot be load");
- - L2World.getInstance().removeObject(item);
- - if (getOwner() instanceof L2PcInstance)
- + // Restore the item.
- + int objectId = rs.getInt(1);
- + final L2ItemInstance item = L2ItemInstance.restoreFromDb(getOwnerId(), rs);
- +
- + if (item == null)
- + continue;
- +
- + if (L2World.getInstance().findObject(objectId) != null)
- + {
- + _log.warning(Inventory.class.getSimpleName() + ": Item: " + item.getObjectId() + " Has duplied on world and cannot be load");
- + L2World.getInstance().removeObject(item);
- + if (getOwner() instanceof L2PcInstance)
- + {
- + final L2PcInstance player = (L2PcInstance) getOwner();
- + player.closeNetConnection(false);
- + }
- + continue;
- + }
- +
- + if (getOwner().isPlayer())
- {
- final L2PcInstance player = (L2PcInstance) getOwner();
- - player.closeNetConnection(false);
- - }
- - continue;
- - }
- -
- - if (getOwner() instanceof L2PcInstance)
- - {
- - final L2PcInstance player = (L2PcInstance) getOwner();
- -
- - if (!player.isGM())
- - {
- - if (!player.isHero())
- +
- + if (!player.isGM())
- {
- - int itemId = item.getItemId();
- - if ((itemId >= 6611 && itemId <= 6621) || itemId == 6842)
- + if (!player.isHero() && item.isHeroItem())
- item.setLocation(ItemLocation.INVENTORY);
- }
- }
- +
- + L2World.getInstance().storeObject(item);
- +
- + // If stackable item is found in inventory just add to current quantity
- + if (item.isStackable() && getItemByItemId(item.getItemId()) != null)
- + addItem("Restore", item, null, getOwner());
- + else
- + addItem(item);
- }
- -
- - L2World.getInstance().storeObject(item);
- -
- - // If stackable item is found in inventory just add to current quantity
- - if (item.isStackable() && getItemByItemId(item.getItemId()) != null)
- - addItem("Restore", item, null, getOwner());
- - else
- - addItem(item);
- }
- -
- - inv.close();
- - statement.close();
- - refreshWeight();
- }
- - catch (SQLException e)
- + catch (Exception e)
- {
- - _log.warning(Inventory.class.getName() + ": Could not restore inventory : ");
- - if (Config.DEVELOPER)
- - e.printStackTrace();
- + _log.warning("Owner id : " + getOwnerId() + ", Could not restore inventory : " + e);
- }
- + refreshWeight();
- }
- public void reloadEquippedItems()
- diff --git a/L2JHellasC/java/com/l2jhellas/gameserver/model/actor/item/ItemContainer.java b/L2JHellasC/java/com/l2jhellas/gameserver/model/actor/item/ItemContainer.java
- index 755d7dd..e606d81 100644
- --- a/L2JHellasC/java/com/l2jhellas/gameserver/model/actor/item/ItemContainer.java
- +++ b/L2JHellasC/java/com/l2jhellas/gameserver/model/actor/item/ItemContainer.java
- @@ -3,7 +3,6 @@
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- -import java.sql.SQLException;
- import java.util.Collection;
- import java.util.LinkedList;
- import java.util.Map;
- @@ -408,41 +407,38 @@
- }
- public void restore()
- - {
- - try (Connection con = L2DatabaseFactory.getInstance().getConnection())
- + {
- + try (Connection con = L2DatabaseFactory.getInstance().getConnection();
- + PreparedStatement ps = con.prepareStatement("SELECT object_id, item_id, count, enchant_level, loc, loc_data, price_sell, price_buy, custom_type1, custom_type2, mana_left FROM items WHERE owner_id=? AND (loc=? OR loc=?) ORDER BY loc_data"))
- {
- - PreparedStatement statement = con.prepareStatement("SELECT object_id FROM items WHERE owner_id=? AND (loc=?) " + "ORDER BY object_id DESC");
- - statement.setInt(1, getOwnerId());
- - statement.setString(2, getBaseLocation().name());
- - ResultSet inv = statement.executeQuery();
- + ps.setInt(1, getOwnerId());
- + ps.setString(2, getBaseLocation().name());
- - L2ItemInstance item;
- - while (inv.next())
- + try (ResultSet rs = ps.executeQuery())
- {
- - int objectId = inv.getInt(1);
- - item = L2ItemInstance.restoreFromDb(objectId);
- - if (item == null)
- - continue;
- -
- - L2World.getInstance().storeObject(item);
- -
- - // If stackable item is found in inventory just add to current quantity
- - if (item.isStackable() && getItemByItemId(item.getItemId()) != null)
- - addItem("Restore", item, null, getOwner());
- - else
- - addItem(item);
- + while (rs.next())
- + {
- + // Restore the item.
- + final L2ItemInstance item = L2ItemInstance.restoreFromDb(getOwnerId(), rs);
- + if (item == null)
- + continue;
- +
- + // Add the item to world objects list.
- + L2World.getInstance().storeObject(item);
- +
- + // If stackable item is found in inventory just add to current quantity
- + if (item.isStackable() && getItemByItemId(item.getItemId()) != null)
- + addItem("Restore", item, null, getOwner());
- + else
- + addItem(item);
- + }
- }
- -
- - inv.close();
- - statement.close();
- - refreshWeight();
- }
- - catch (SQLException e)
- + catch (Exception e)
- {
- - _log.warning(ItemContainer.class.getName() + ": could not restore container");
- - if (Config.DEVELOPER)
- - e.printStackTrace();
- - }
- + _log.warning(ItemContainer.class.getName() + ": could not restore container: "+e);
- + }
- + refreshWeight();
- }
- public boolean validateCapacity(int slots)
- diff --git a/L2JHellasC/java/com/l2jhellas/gameserver/model/actor/item/L2ItemInstance.java b/L2JHellasC/java/com/l2jhellas/gameserver/model/actor/item/L2ItemInstance.java
- index 9cc7f67..23a6560 100644
- --- a/L2JHellasC/java/com/l2jhellas/gameserver/model/actor/item/L2ItemInstance.java
- +++ b/L2JHellasC/java/com/l2jhellas/gameserver/model/actor/item/L2ItemInstance.java
- @@ -369,7 +369,7 @@
- {
- return ((!isEquipped()) // Not equipped
- && (getItem().getType2() != 3) // Not Quest Item
- - && (getItem().getType2() != 4 || getItem().getType1() != 1) // TODO: what does this mean?
- + && (getItem().getType2() != 4 || getItem().getType1() != 1) // what does this mean?
- && (player.getPet() == null || getObjectId() != player.getPet().getControlItemId()) // Not Control item of currently summoned pet
- && (player.getActiveEnchantItem() != this) // Not momentarily used enchant scroll
- && (allowAdena || getItemId() != 57) && (player.getCurrentSkill() == null || player.getCurrentSkill().getSkill().getItemConsumeId() != getItemId()) && (isTradeable()));
- @@ -666,99 +666,82 @@
- }
- }
- - public static L2ItemInstance restoreFromDb(int objectId)
- + public static L2ItemInstance restoreFromDb(int ownerId, ResultSet rs)
- {
- L2ItemInstance inst = null;
- -
- - try (Connection con = L2DatabaseFactory.getInstance().getConnection())
- + int objectId = 0;
- + try
- {
- - PreparedStatement statement = con.prepareStatement("SELECT owner_id, object_id, item_id, count, enchant_level, loc, loc_data, price_sell, price_buy, custom_type1, custom_type2, mana_left FROM items WHERE object_id = ?");
- - statement.setInt(1, objectId);
- - ResultSet rs = statement.executeQuery();
- - if (rs.next())
- + objectId = rs.getInt(1);
- + int item_id = rs.getInt("item_id");
- + int count = rs.getInt("count");
- + ItemLocation loc = ItemLocation.valueOf(rs.getString("loc"));
- + int loc_data = rs.getInt("loc_data");
- + int enchant_level = rs.getInt("enchant_level");
- + int custom_type1 = rs.getInt("custom_type1");
- + int custom_type2 = rs.getInt("custom_type2");
- + int price_sell = rs.getInt("price_sell");
- + int price_buy = rs.getInt("price_buy");
- + int manaLeft = rs.getInt("mana_left");
- +
- + L2Item item = ItemTable.getInstance().getTemplate(item_id);
- +
- + if (item == null)
- + return null;
- +
- + inst = new L2ItemInstance(objectId, item);
- + inst._existsInDb = true;
- + inst._storedInDb = true;
- + inst._ownerId = ownerId;
- + inst._count = count;
- + inst._enchantLevel = enchant_level;
- + inst._type1 = custom_type1;
- + inst._type2 = custom_type2;
- + inst._loc = loc;
- + inst._locData = loc_data;
- + inst._priceSell = price_sell;
- + inst._priceBuy = price_buy;
- +
- + // Setup life time for shadow weapons
- + inst._mana = manaLeft;
- +
- + // consume 1 mana
- + if (inst._mana > 0 && inst.getLocation() == ItemLocation.PAPERDOLL)
- + inst.decreaseMana(false);
- +
- + // if mana left is 0 delete this item
- + if (inst._mana == 0)
- {
- - int owner_id = rs.getInt("owner_id");
- - int item_id = rs.getInt("item_id");
- - int count = rs.getInt("count");
- - ItemLocation loc = ItemLocation.valueOf(rs.getString("loc"));
- - int loc_data = rs.getInt("loc_data");
- - int enchant_level = rs.getInt("enchant_level");
- - int custom_type1 = rs.getInt("custom_type1");
- - int custom_type2 = rs.getInt("custom_type2");
- - int price_sell = rs.getInt("price_sell");
- - int price_buy = rs.getInt("price_buy");
- - int manaLeft = rs.getInt("mana_left");
- - L2Item item = ItemTable.getInstance().getTemplate(item_id);
- - if (item == null)
- - {
- - _log.severe("Item item_id=" + item_id + " not known, object_id=" + objectId);
- - rs.close();
- - statement.close();
- - return null;
- - }
- - inst = new L2ItemInstance(objectId, item);
- - inst._existsInDb = true;
- - inst._storedInDb = true;
- - inst._ownerId = owner_id;
- - inst._count = count;
- - inst._enchantLevel = enchant_level;
- - inst._type1 = custom_type1;
- - inst._type2 = custom_type2;
- - inst._loc = loc;
- - inst._locData = loc_data;
- - inst._priceSell = price_sell;
- - inst._priceBuy = price_buy;
- -
- - // Setup life time for shadow weapons
- - inst._mana = manaLeft;
- -
- - // consume 1 mana
- - if (inst._mana > 0 && inst.getLocation() == ItemLocation.PAPERDOLL)
- - inst.decreaseMana(false);
- -
- - // if mana left is 0 delete this item
- - if (inst._mana == 0)
- - {
- - inst.removeFromDb();
- - rs.close();
- - statement.close();
- - return null;
- - }
- - else if (inst._mana > 0 && inst.getLocation() == ItemLocation.PAPERDOLL)
- - inst.scheduleConsumeManaTask();
- -
- - rs.close();
- - statement.close();
- - }
- - else
- - {
- - _log.severe("Item object_id=" + objectId + " not found");
- - rs.close();
- - statement.close();
- + inst.removeFromDb();
- return null;
- }
- - rs.close();
- - statement.close();
- -
- - // load augmentation
- - statement = con.prepareStatement("SELECT attributes,skill,level FROM augmentations WHERE item_id=?");
- - statement.setInt(1, objectId);
- - rs = statement.executeQuery();
- - if (rs.next())
- + else if (inst._mana > 0 && inst.getLocation() == ItemLocation.PAPERDOLL)
- + inst.scheduleConsumeManaTask();
- +
- + // load weapon augmentation
- + if (inst.isWeapon() && inst.isEquipable())
- {
- - inst._augmentation = new L2Augmentation(inst, rs.getInt("attributes"), rs.getInt("skill"), rs.getInt("level"), false);
- + try (Connection con = L2DatabaseFactory.getInstance().getConnection();
- + PreparedStatement ps = con.prepareStatement("SELECT attributes,skill,level FROM augmentations WHERE item_id=?"))
- + {
- + ps.setInt(1, inst.getObjectId());
- +
- + try (ResultSet rsa = ps.executeQuery())
- + {
- + if (rsa.next())
- + inst._augmentation = new L2Augmentation(inst, rsa.getInt("attributes"), rsa.getInt("skill"), rsa.getInt("level"), false);
- + }
- + }
- + catch (Exception e)
- + {
- + _log.severe(L2ItemInstance.class.getName() + ": Couldn't restore augmentation for " + objectId + " from DB:" + e);
- + }
- }
- -
- - rs.close();
- - statement.close();
- -
- +
- }
- catch (Exception e)
- - {
- -
- - _log.severe(L2ItemInstance.class.getName() + ": Could not restore item " + objectId + " from DB:");
- - if (Config.DEVELOPER)
- - e.printStackTrace();
- + {
- + _log.severe(L2ItemInstance.class.getName() + ": Could not restore item " + objectId + " from DB:" +e);
- }
- return inst;
- }
- diff --git a/L2JHellasC/java/com/l2jhellas/gameserver/network/clientpackets/FinishRotating.java b/L2JHellasC/java/com/l2jhellas/gameserver/network/clientpackets/FinishRotating.java
- index e8cd5e4..2c2007d 100644
- --- a/L2JHellasC/java/com/l2jhellas/gameserver/network/clientpackets/FinishRotating.java
- +++ b/L2JHellasC/java/com/l2jhellas/gameserver/network/clientpackets/FinishRotating.java
- @@ -1,5 +1,6 @@
- package com.l2jhellas.gameserver.network.clientpackets;
- +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
- import com.l2jhellas.gameserver.network.serverpackets.StopRotation;
- public final class FinishRotating extends L2GameClientPacket
- @@ -20,10 +21,10 @@
- @Override
- protected void runImpl()
- {
- - if (getClient().getActiveChar() == null)
- - return;
- - StopRotation sr = new StopRotation(getClient().getActiveChar().getObjectId(), _degree, 0);
- - getClient().getActiveChar().broadcastPacket(sr);
- + final L2PcInstance player = getClient().getActiveChar();
- +
- + if (player != null)
- + player.broadcastPacket(new StopRotation(player.getObjectId(), _degree, 0));
- }
- @Override
- diff --git a/L2JHellasC/java/com/l2jhellas/gameserver/network/serverpackets/Attack.java b/L2JHellasC/java/com/l2jhellas/gameserver/network/serverpackets/Attack.java
- index c22cdc3..9e276fa 100644
- --- a/L2JHellasC/java/com/l2jhellas/gameserver/network/serverpackets/Attack.java
- +++ b/L2JHellasC/java/com/l2jhellas/gameserver/network/serverpackets/Attack.java
- @@ -16,7 +16,6 @@
- private final boolean _soulshot;
- private final int _ssGrade;
- private final Location _attackerLoc;
- - private final Location _targetLoc;
- private final List<Hit> _hits = new ArrayList<>();
- public Attack(L2Character attacker, L2Character target, boolean useShots, int ssGrade)
- @@ -25,7 +24,6 @@
- _soulshot = useShots;
- _ssGrade = ssGrade;
- _attackerLoc = new Location(attacker.getX(), attacker.getY(), attacker.getZ());
- - _targetLoc = new Location(target.getX(), target.getY(), target.getZ());
- }
- public void addHit(L2Character target, int damage, boolean miss, boolean crit, byte shld)
- @@ -63,14 +61,13 @@
- writeD(_attackerLoc.getZ());
- writeH(_hits.size() - 1);
- - while (it.hasNext())
- + if(_hits.size() > 1)
- {
- - writeHit(it.next());
- + while (it.hasNext())
- + {
- + writeHit(it.next());
- + }
- }
- -
- - writeD(_targetLoc.getX());
- - writeD(_targetLoc.getY());
- - writeD(_targetLoc.getZ());
- }
- @Override
- diff --git a/L2JHellasC/java/com/l2jhellas/gameserver/scrips/quests/ai/group/L2AttackableAIScript.java b/L2JHellasC/java/com/l2jhellas/gameserver/scrips/quests/ai/group/L2AttackableAIScript.java
- index 3313b46..7fe2f51 100644
- --- a/L2JHellasC/java/com/l2jhellas/gameserver/scrips/quests/ai/group/L2AttackableAIScript.java
- +++ b/L2JHellasC/java/com/l2jhellas/gameserver/scrips/quests/ai/group/L2AttackableAIScript.java
- @@ -56,7 +56,7 @@
- if (skillAggroPoints > 0)
- {
- - if (attackable.hasAI() && (attackable.getAI().getIntention() == CtrlIntention.AI_INTENTION_ATTACK))
- + if (!attackable.isDead() && attackable.hasAI() && (attackable.getAI().getIntention() == CtrlIntention.AI_INTENTION_ATTACK))
- {
- L2Object npcTarget = attackable.getTarget();
- for (L2Object skillTarget : targets)
- diff --git a/L2JHellasC/java/com/l2jhellas/gameserver/skills/effects/EffectCharge.java b/L2JHellasC/java/com/l2jhellas/gameserver/skills/effects/EffectCharge.java
- index f1c15c4..9811a1c 100644
- --- a/L2JHellasC/java/com/l2jhellas/gameserver/skills/effects/EffectCharge.java
- +++ b/L2JHellasC/java/com/l2jhellas/gameserver/skills/effects/EffectCharge.java
- @@ -15,12 +15,10 @@
- {
- super(env, template);
- numCharges = 1;
- - if (env.target instanceof L2PcInstance)
- + if (env.target.isPlayer())
- {
- env.target.sendPacket(new EtcStatusUpdate((L2PcInstance) env.target));
- - SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.FORCE_INCREASED_TO_S1);
- - sm.addNumber(numCharges);
- - getEffected().sendPacket(sm);
- + getEffected().sendPacket(SystemMessage.getSystemMessage(SystemMessageId.FORCE_INCREASED_TO_S1).addNumber(numCharges));
- }
- }
- diff --git a/L2JHellasC/java/com/l2jhellas/gameserver/templates/L2Weapon.java b/L2JHellasC/java/com/l2jhellas/gameserver/templates/L2Weapon.java
- index 2603c64..fecd3f8 100644
- --- a/L2JHellasC/java/com/l2jhellas/gameserver/templates/L2Weapon.java
- +++ b/L2JHellasC/java/com/l2jhellas/gameserver/templates/L2Weapon.java
- @@ -2,7 +2,6 @@
- import java.io.IOException;
- import java.util.ArrayList;
- -import java.util.Collection;
- import java.util.List;
- import com.l2jhellas.gameserver.enums.items.L2WeaponType;
- @@ -10,7 +9,6 @@
- import com.l2jhellas.gameserver.handler.ISkillHandler;
- import com.l2jhellas.gameserver.handler.SkillHandler;
- import com.l2jhellas.gameserver.model.L2Effect;
- -import com.l2jhellas.gameserver.model.L2Object;
- import com.l2jhellas.gameserver.model.L2Skill;
- import com.l2jhellas.gameserver.model.L2World;
- import com.l2jhellas.gameserver.model.actor.L2Character;
- @@ -264,25 +262,15 @@
- skill.useSkill(caster, targets);
- // notify quests of a skill use
- - if (caster instanceof L2PcInstance)
- + if (caster.isPlayer())
- {
- // Mobs in range 1000 see spell
- -
- - final Collection<L2Object> objs = L2World.getInstance().getVisibleObjects(caster, L2Object.class, 1000);
- - // synchronized (caster.getKnownList().getKnownObjects())
- + L2World.getInstance().forEachVisibleObjectInRange(caster, L2Npc.class, 1000, npcMob ->
- {
- - for (L2Object spMob : objs)
- - {
- - if (spMob instanceof L2Npc)
- - {
- - L2Npc npcMob = (L2Npc) spMob;
- -
- - if (npcMob.getTemplate().getEventQuests(QuestEventType.ON_SKILL_SEE) != null)
- - for (Quest quest : npcMob.getTemplate().getEventQuests(QuestEventType.ON_SKILL_SEE))
- - quest.notifySkillSee(npcMob, (L2PcInstance) caster, _skillsOnCast[0], targets, false);// XXX not sure of this
- - }
- - }
- - }
- + if (npcMob != null && npcMob.getTemplate().getEventQuests(QuestEventType.ON_SKILL_SEE) != null)
- + for (Quest quest : npcMob.getTemplate().getEventQuests(QuestEventType.ON_SKILL_SEE))
- + quest.notifySkillSee(npcMob, (L2PcInstance) caster, _skillsOnCast[0], targets, false);
- + });
- }
- }
- catch (IOException e)
- diff --git a/L2JHellasC/java/com/l2jhellas/util/Broadcast.java b/L2JHellasC/java/com/l2jhellas/util/Broadcast.java
- index 1f17137..0c26fdb 100644
- --- a/L2JHellasC/java/com/l2jhellas/util/Broadcast.java
- +++ b/L2JHellasC/java/com/l2jhellas/util/Broadcast.java
- @@ -44,7 +44,7 @@
- public static void toSelfAndKnownPlayers(L2Character character, L2GameServerPacket mov)
- {
- - if (character instanceof L2PcInstance)
- + if (character.isPlayer())
- character.sendPacket(mov);
- toKnownPlayers(character, mov);
- @@ -55,7 +55,7 @@
- if (radius < 0)
- radius = 600;
- - if (character instanceof L2PcInstance)
- + if (character.isPlayer())
- character.sendPacket(mov);
- L2World.getInstance().forEachVisibleObjectInRange(character, L2PcInstance.class, radius, player ->
- @@ -70,7 +70,7 @@
- if (radiusSq < 0)
- radiusSq = 360000;
- - if (character instanceof L2PcInstance)
- + if (character.isPlayer())
- character.sendPacket(mov);
- for (L2PcInstance player : L2World.getInstance().getVisibleObjects(character, L2PcInstance.class))
- @@ -93,7 +93,7 @@
- {
- for (L2Object object : region.getVisibleObjects().values())
- {
- - if (object instanceof L2PcInstance)
- + if (object.isPlayer())
- {
- final L2PcInstance player = (L2PcInstance) object;
- diff --git a/L2JHellasD/data/stats/skills/0400-0499.xml b/L2JHellasD/data/stats/skills/0400-0499.xml
- index 8f2a840..ea4ccc6 100644
- --- a/L2JHellasD/data/stats/skills/0400-0499.xml
- +++ b/L2JHellasD/data/stats/skills/0400-0499.xml
- @@ -871,25 +871,21 @@
- </for>
- </skill>
- <skill id="441" levels="1" name="Force Meditation">
- - <!-- Guess ... notdone ... needs core -->
- - <table name="#pDef"> 0.2 </table>
- - <table name="#hhot"> 60 </table>
- - <table name="#mhot"> 10 </table>
- - <set name="operateType" val="OP_ACTIVE" />
- - <set name="skillType" val="BUFF" />
- - <set name="target" val="TARGET_SELF" />
- - <set name="hitTime" val="2000" />
- - <set name="reuseDelay" val="1200000" />
- - <set name="castRange" val="-1" />
- - <set name="effectRange" val="-1" />
- - <set name="negateId" val="441" />
- - <set name="needCharges" val="3" />
- + <set name="mpConsume" val="0"/>
- + <set name="target" val="TARGET_SELF"/>
- + <set name="reuseDelay" val="300000"/>
- + <set name="hitTime" val="2000"/>
- + <set name="skillType" val="CHARGE_EFFECT"/>
- + <set name="isMagic" val="true"/>
- + <set name="operateType" val="OP_ACTIVE"/>
- + <set name="num_charges" val="3"/>
- + <set name="charge_skill_id" val="50"/> <!-- Focused Force -->
- <for>
- - <effect count="1" name="ImmobileUntilAttacked" time="120" val="0">
- - <mul order="0x30" stat="pDef" val="#pDef" />
- + <effect count="1" name="ImmobileUntilAttacked" time="30" val="0">
- + <mul order="0x30" stat="pDef" val="0.2"/>
- + <mul order="0x30" stat="regMp" val="10"/>
- + <mul order="0x30" stat="regHp" val="15"/>
- </effect>
- - <effect count="40" name="HealOverTime" time="3" noicon="1" val="#hhot" />
- - <effect count="40" name="ManaHealOverTime" time="3" noicon="1" val="#mhot" />
- </for>
- </skill>
- <skill id="442" levels="1" name="Sonic Barrier">
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement