Project update.

This commit is contained in:
MobiusDev
2015-12-31 23:53:41 +00:00
parent e0d681a17e
commit ad2bcd79be
4084 changed files with 83696 additions and 86998 deletions

View File

@@ -0,0 +1,77 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import com.l2jmobius.gameserver.model.interfaces.IUniqueId;
/**
* @author xban1x
*/
public final class AbsorberInfo implements IUniqueId
{
private int _objectId;
private double _absorbedHp;
public AbsorberInfo(int objectId, double pAbsorbedHp)
{
_objectId = objectId;
_absorbedHp = pAbsorbedHp;
}
public double getAbsorbedHp()
{
return _absorbedHp;
}
public void setAbsorbedHp(double absorbedHp)
{
_absorbedHp = absorbedHp;
}
@Override
public int getObjectId()
{
return _objectId;
}
public void setObjectId(int objectId)
{
_objectId = objectId;
}
@Override
public final boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (obj instanceof AbsorberInfo)
{
return (((AbsorberInfo) obj).getObjectId() == _objectId);
}
return false;
}
@Override
public final int hashCode()
{
return _objectId;
}
}

View File

@@ -0,0 +1,194 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import com.l2jmobius.gameserver.enums.Race;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.util.Rnd;
/**
* @author Battlecruiser
*/
public abstract class AbstractPlayerGroup
{
/**
* @return a list of all members of this group
*/
public abstract List<L2PcInstance> getMembers();
/**
* @return a list of object IDs of the members of this group
*/
public List<Integer> getMembersObjectId()
{
final List<Integer> ids = new ArrayList<>();
forEachMember(m ->
{
ids.add(m.getObjectId());
return true;
});
return ids;
}
/**
* @return the leader of this group
*/
public abstract L2PcInstance getLeader();
/**
* Change the leader of this group to the specified player.
* @param leader the player to set as the new leader of this group
*/
public abstract void setLeader(L2PcInstance leader);
/**
* @return the leader's object ID
*/
public int getLeaderObjectId()
{
return getLeader().getObjectId();
}
/**
* Check if a given player is the leader of this group.
* @param player the player to check
* @return {@code true} if the specified player is the leader of this group, {@code false} otherwise
*/
public boolean isLeader(L2PcInstance player)
{
return (getLeaderObjectId() == player.getObjectId());
}
/**
* @return the count of all players in this group
*/
public int getMemberCount()
{
return getMembers().size();
}
/**
* @return the count of all player races in this group
*/
public int getRaceCount()
{
final List<Race> partyRaces = new ArrayList<>();
for (L2PcInstance member : getMembers())
{
if (!partyRaces.contains(member.getRace()))
{
partyRaces.add(member.getRace());
}
}
return partyRaces.size();
}
/**
* @return the level of this group
*/
public abstract int getLevel();
/**
* Broadcast a packet to every member of this group.
* @param packet the packet to broadcast
*/
public void broadcastPacket(final L2GameServerPacket packet)
{
forEachMember(m ->
{
if (m != null)
{
m.sendPacket(packet);
}
return true;
});
}
/**
* Broadcast a system message to this group.
* @param message the system message to broadcast
*/
public void broadcastMessage(SystemMessageId message)
{
broadcastPacket(SystemMessage.getSystemMessage(message));
}
/**
* Broadcast a text message to this group.
* @param text to broadcast
*/
public void broadcastString(String text)
{
broadcastPacket(SystemMessage.sendString(text));
}
public void broadcastCreatureSay(final CreatureSay msg, final L2PcInstance broadcaster)
{
forEachMember(m ->
{
if ((m != null) && !BlockList.isBlocked(m, broadcaster))
{
m.sendPacket(msg);
}
return true;
});
}
/**
* Check if this group contains a given player.
* @param player the player to check
* @return {@code true} if this group contains the specified player, {@code false} otherwise
*/
public boolean containsPlayer(L2PcInstance player)
{
return getMembers().contains(player);
}
/**
* @return a random member of this group
*/
public L2PcInstance getRandomPlayer()
{
return getMembers().get(Rnd.get(getMemberCount()));
}
/**
* Iterates over the group and executes procedure on each member
* @param procedure the prodecure to be executed on each member.<br>
* If executing the procedure on a member returns {@code true}, the loop continues to the next member, otherwise it breaks the loop
* @return {@code true} if the procedure executed correctly, {@code false} if the loop was broken prematurely
*/
public boolean forEachMember(Function<L2PcInstance, Boolean> procedure)
{
for (L2PcInstance player : getMembers())
{
if (!procedure.apply(player))
{
return false;
}
}
return true;
}
}

View File

@@ -0,0 +1,118 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
/**
* Action Key DTO.
* @author mrTJO, Zoey76
*/
public class ActionKey
{
private final int _cat;
private int _cmd = 0;
private int _key = 0;
private int _tgKey1 = 0;
private int _tgKey2 = 0;
private int _show = 1;
/**
* @param cat category Id
*/
public ActionKey(int cat)
{
_cat = cat;
}
/**
* L2ActionKey Initialization
* @param cat Category ID
* @param cmd Command ID
* @param key User Defined Primary Key
* @param tgKey1 1st Toggled Key (eg. Alt, Ctrl or Shift)
* @param tgKey2 2nd Toggled Key (eg. Alt, Ctrl or Shift)
* @param show Show Action in UI
*/
public ActionKey(int cat, int cmd, int key, int tgKey1, int tgKey2, int show)
{
_cat = cat;
_cmd = cmd;
_key = key;
_tgKey1 = tgKey1;
_tgKey2 = tgKey2;
_show = show;
}
public int getCategory()
{
return _cat;
}
public int getCommandId()
{
return _cmd;
}
public void setCommandId(int cmd)
{
_cmd = cmd;
}
public int getKeyId()
{
return _key;
}
public void setKeyId(int key)
{
_key = key;
}
public int getToogleKey1()
{
return _tgKey1;
}
public void setToogleKey1(int tKey1)
{
_tgKey1 = tKey1;
}
public int getToogleKey2()
{
return _tgKey2;
}
public void setToogleKey2(int tKey2)
{
_tgKey2 = tKey2;
}
public int getShowStatus()
{
return _show;
}
public void setShowStatus(int show)
{
_show = show;
}
public String getSqlSaveString(int playerId, int order)
{
return "(" + playerId + ", " + _cat + ", " + order + ", " + _cmd + "," + _key + ", " + _tgKey1 + ", " + _tgKey2 + ", " + _show + ")";
}
}

View File

@@ -0,0 +1,102 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import com.l2jmobius.gameserver.model.actor.L2Character;
/**
* @author xban1x
*/
public final class AggroInfo
{
private final L2Character _attacker;
private int _hate = 0;
private int _damage = 0;
public AggroInfo(L2Character pAttacker)
{
_attacker = pAttacker;
}
public L2Character getAttacker()
{
return _attacker;
}
public int getHate()
{
return _hate;
}
public int checkHate(L2Character owner)
{
if (_attacker.isAlikeDead() || !_attacker.isVisible() || !owner.getKnownList().knowsObject(_attacker))
{
_hate = 0;
}
return _hate;
}
public void addHate(int value)
{
_hate = (int) Math.min(_hate + (long) value, 999999999);
}
public void stopHate()
{
_hate = 0;
}
public int getDamage()
{
return _damage;
}
public void addDamage(int value)
{
_damage = (int) Math.min(_damage + (long) value, 999999999);
}
@Override
public final boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (obj instanceof AggroInfo)
{
return (((AggroInfo) obj).getAttacker() == _attacker);
}
return false;
}
@Override
public final int hashCode()
{
return _attacker.getObjectId();
}
@Override
public String toString()
{
return "AggroInfo [attacker=" + _attacker + ", hate=" + _hate + ", damage=" + _damage + "]";
}
}

View File

@@ -0,0 +1,50 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
/**
* Holds a list of all AirShip teleports.
* @author xban1x
*/
public final class AirShipTeleportList
{
private final int _location;
private final int[] _fuel;
private final VehiclePathPoint[][] _routes;
public AirShipTeleportList(int loc, int[] f, VehiclePathPoint[][] r)
{
_location = loc;
_fuel = f;
_routes = r;
}
public int getLocation()
{
return _location;
}
public int[] getFuel()
{
return _fuel;
}
public VehiclePathPoint[][] getRoute()
{
return _routes;
}
}

View File

@@ -0,0 +1,176 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.gameserver.instancemanager.HandysBlockCheckerManager;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.entity.BlockCheckerEngine;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* @author xban1x
*/
public final class ArenaParticipantsHolder
{
private final int _arena;
private final List<L2PcInstance> _redPlayers;
private final List<L2PcInstance> _bluePlayers;
private final BlockCheckerEngine _engine;
public ArenaParticipantsHolder(int arena)
{
_arena = arena;
_redPlayers = new ArrayList<>(6);
_bluePlayers = new ArrayList<>(6);
_engine = new BlockCheckerEngine(this, _arena);
}
public List<L2PcInstance> getRedPlayers()
{
return _redPlayers;
}
public List<L2PcInstance> getBluePlayers()
{
return _bluePlayers;
}
public List<L2PcInstance> getAllPlayers()
{
final List<L2PcInstance> all = new ArrayList<>(12);
all.addAll(_redPlayers);
all.addAll(_bluePlayers);
return all;
}
public void addPlayer(L2PcInstance player, int team)
{
if (team == 0)
{
_redPlayers.add(player);
}
else
{
_bluePlayers.add(player);
}
}
public void removePlayer(L2PcInstance player, int team)
{
if (team == 0)
{
_redPlayers.remove(player);
}
else
{
_bluePlayers.remove(player);
}
}
public int getPlayerTeam(L2PcInstance player)
{
if (_redPlayers.contains(player))
{
return 0;
}
else if (_bluePlayers.contains(player))
{
return 1;
}
else
{
return -1;
}
}
public int getRedTeamSize()
{
return _redPlayers.size();
}
public int getBlueTeamSize()
{
return _bluePlayers.size();
}
public void broadCastPacketToTeam(L2GameServerPacket packet)
{
for (L2PcInstance p : _redPlayers)
{
p.sendPacket(packet);
}
for (L2PcInstance p : _bluePlayers)
{
p.sendPacket(packet);
}
}
public void clearPlayers()
{
_redPlayers.clear();
_bluePlayers.clear();
}
public BlockCheckerEngine getEvent()
{
return _engine;
}
public void updateEvent()
{
_engine.updatePlayersOnStart(this);
}
public void checkAndShuffle()
{
final int redSize = _redPlayers.size();
final int blueSize = _bluePlayers.size();
if (redSize > (blueSize + 1))
{
broadCastPacketToTeam(SystemMessage.getSystemMessage(SystemMessageId.TEAM_MEMBERS_WERE_MODIFIED_BECAUSE_THE_TEAMS_WERE_UNBALANCED));
final int needed = redSize - (blueSize + 1);
for (int i = 0; i < (needed + 1); i++)
{
final L2PcInstance plr = _redPlayers.get(i);
if (plr == null)
{
continue;
}
HandysBlockCheckerManager.getInstance().changePlayerToTeam(plr, _arena, 1);
}
}
else if (blueSize > (redSize + 1))
{
broadCastPacketToTeam(SystemMessage.getSystemMessage(SystemMessageId.TEAM_MEMBERS_WERE_MODIFIED_BECAUSE_THE_TEAMS_WERE_UNBALANCED));
final int needed = blueSize - (redSize + 1);
for (int i = 0; i < (needed + 1); i++)
{
final L2PcInstance plr = _bluePlayers.get(i);
if (plr == null)
{
continue;
}
HandysBlockCheckerManager.getInstance().changePlayerToTeam(plr, _arena, 0);
}
}
}
}

View File

@@ -0,0 +1,750 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.datatables.SpawnTable;
import com.l2jmobius.gameserver.idfactory.IdFactory;
import com.l2jmobius.gameserver.instancemanager.MapRegionManager;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.interfaces.IIdentifiable;
import com.l2jmobius.gameserver.util.Broadcast;
import com.l2jmobius.util.Rnd;
/**
* Auto Spawn handler.<br>
* Allows spawning of a NPC object based on a timer.<br>
* (From the official idea used for the Merchant and Blacksmith of Mammon)<br>
* General Usage: - Call registerSpawn() with the parameters listed below.<br>
* int npcId int[][] spawnPoints or specify NULL to add points later.<br>
* int initialDelay (If < 0 = default value) int respawnDelay (If < 0 = default value)<br>
* int despawnDelay (If < 0 = default value or if = 0, function disabled)<br>
* spawnPoints is a standard two-dimensional int array containing X,Y and Z coordinates.<br>
* The default respawn/despawn delays are currently every hour (as for Mammon on official servers).<br>
* The resulting AutoSpawnInstance object represents the newly added spawn index.<br>
* The internal methods of this object can be used to adjust random spawning, for instance a call to setRandomSpawn(1, true); would set the spawn at index 1 to be randomly rather than sequentially-based.<br>
* Also they can be used to specify the number of NPC instances to spawn using setSpawnCount(), and broadcast a message to all users using setBroadcast().<br>
* Random Spawning = OFF by default Broadcasting = OFF by default
* @author Tempy
*/
public class AutoSpawnHandler
{
protected static final Logger _log = Logger.getLogger(AutoSpawnHandler.class.getName());
private static final int DEFAULT_INITIAL_SPAWN = 30000; // 30 seconds after registration
private static final int DEFAULT_RESPAWN = 3600000; // 1 hour in millisecs
private static final int DEFAULT_DESPAWN = 3600000; // 1 hour in millisecs
protected Map<Integer, AutoSpawnInstance> _registeredSpawns = new ConcurrentHashMap<>();
protected Map<Integer, ScheduledFuture<?>> _runningSpawns = new ConcurrentHashMap<>();
protected boolean _activeState = true;
protected AutoSpawnHandler()
{
restoreSpawnData();
}
public static AutoSpawnHandler getInstance()
{
return SingletonHolder._instance;
}
public final int size()
{
return _registeredSpawns.size();
}
public void reload()
{
// stop all timers
for (ScheduledFuture<?> sf : _runningSpawns.values())
{
if (sf != null)
{
sf.cancel(true);
}
}
// unregister all registered spawns
for (AutoSpawnInstance asi : _registeredSpawns.values())
{
if (asi != null)
{
this.removeSpawn(asi);
}
}
// create clean list
_registeredSpawns.clear();
_runningSpawns.clear();
// load
restoreSpawnData();
}
private void restoreSpawnData()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT * FROM random_spawn ORDER BY groupId ASC");
PreparedStatement ps = con.prepareStatement("SELECT * FROM random_spawn_loc WHERE groupId=?"))
{
// Restore spawn group data, then the location data.
while (rs.next())
{
// Register random spawn group, set various options on the
// created spawn instance.
final AutoSpawnInstance spawnInst = registerSpawn(rs.getInt("npcId"), rs.getInt("initialDelay"), rs.getInt("respawnDelay"), rs.getInt("despawnDelay"));
spawnInst.setSpawnCount(rs.getInt("count"));
spawnInst.setBroadcast(rs.getBoolean("broadcastSpawn"));
spawnInst.setRandomSpawn(rs.getBoolean("randomSpawn"));
// Restore the spawn locations for this spawn group/instance.
ps.setInt(1, rs.getInt("groupId"));
try (ResultSet rs2 = ps.executeQuery())
{
ps.clearParameters();
while (rs2.next())
{
// Add each location to the spawn group/instance.
spawnInst.addSpawnLocation(rs2.getInt("x"), rs2.getInt("y"), rs2.getInt("z"), rs2.getInt("heading"));
}
}
}
}
catch (Exception e)
{
_log.log(Level.WARNING, "AutoSpawnHandler: Could not restore spawn data: " + e.getMessage(), e);
}
}
/**
* Registers a spawn with the given parameters with the spawner, and marks it as active.<br>
* Returns a AutoSpawnInstance containing info about the spawn.
* @param npcId
* @param spawnPoints
* @param initialDelay (If < 0 = default value)
* @param respawnDelay (If < 0 = default value)
* @param despawnDelay (If < 0 = default value or if = 0, function disabled)
* @return AutoSpawnInstance spawnInst
*/
public AutoSpawnInstance registerSpawn(int npcId, int[][] spawnPoints, int initialDelay, int respawnDelay, int despawnDelay)
{
if (initialDelay < 0)
{
initialDelay = DEFAULT_INITIAL_SPAWN;
}
if (respawnDelay < 0)
{
respawnDelay = DEFAULT_RESPAWN;
}
if (despawnDelay < 0)
{
despawnDelay = DEFAULT_DESPAWN;
}
final AutoSpawnInstance newSpawn = new AutoSpawnInstance(npcId, initialDelay, respawnDelay, despawnDelay);
if (spawnPoints != null)
{
for (int[] spawnPoint : spawnPoints)
{
newSpawn.addSpawnLocation(spawnPoint);
}
}
final int newId = IdFactory.getInstance().getNextId();
newSpawn._objectId = newId;
_registeredSpawns.put(newId, newSpawn);
setSpawnActive(newSpawn, true);
return newSpawn;
}
/**
* Registers a spawn with the given parameters with the spawner, and marks it as active.<br>
* Returns a AutoSpawnInstance containing info about the spawn.<br>
* <B>Warning:</B> Spawn locations must be specified separately using addSpawnLocation().
* @param npcId
* @param initialDelay (If < 0 = default value)
* @param respawnDelay (If < 0 = default value)
* @param despawnDelay (If < 0 = default value or if = 0, function disabled)
* @return AutoSpawnInstance spawnInst
*/
public AutoSpawnInstance registerSpawn(int npcId, int initialDelay, int respawnDelay, int despawnDelay)
{
return registerSpawn(npcId, null, initialDelay, respawnDelay, despawnDelay);
}
/**
* Remove a registered spawn from the list, specified by the given spawn instance.
* @param spawnInst
* @return boolean removedSuccessfully
*/
public boolean removeSpawn(AutoSpawnInstance spawnInst)
{
if (!isSpawnRegistered(spawnInst))
{
return false;
}
try
{
// Try to remove from the list of registered spawns if it exists.
_registeredSpawns.remove(spawnInst.getId());
// Cancel the currently associated running scheduled task.
final ScheduledFuture<?> respawnTask = _runningSpawns.remove(spawnInst._objectId);
respawnTask.cancel(false);
}
catch (Exception e)
{
_log.log(Level.WARNING, "AutoSpawnHandler: Could not auto spawn for NPC ID " + spawnInst._npcId + " (Object ID = " + spawnInst._objectId + "): " + e.getMessage(), e);
return false;
}
return true;
}
/**
* Remove a registered spawn from the list, specified by the given spawn object ID.
* @param objectId
*/
public void removeSpawn(int objectId)
{
removeSpawn(_registeredSpawns.get(objectId));
}
/**
* Sets the active state of the specified spawn.
* @param spawnInst
* @param isActive
*/
public void setSpawnActive(AutoSpawnInstance spawnInst, boolean isActive)
{
if (spawnInst == null)
{
return;
}
final int objectId = spawnInst._objectId;
if (isSpawnRegistered(objectId))
{
ScheduledFuture<?> spawnTask = null;
if (isActive)
{
final AutoSpawner rs = new AutoSpawner(objectId);
if (spawnInst._desDelay > 0)
{
spawnTask = ThreadPoolManager.getInstance().scheduleEffectAtFixedRate(rs, spawnInst._initDelay, spawnInst._resDelay);
}
else
{
spawnTask = ThreadPoolManager.getInstance().scheduleEffect(rs, spawnInst._initDelay);
}
_runningSpawns.put(objectId, spawnTask);
}
else
{
final AutoDespawner rd = new AutoDespawner(objectId);
spawnTask = _runningSpawns.remove(objectId);
if (spawnTask != null)
{
spawnTask.cancel(false);
}
ThreadPoolManager.getInstance().scheduleEffect(rd, 0);
}
spawnInst.setSpawnActive(isActive);
}
}
/**
* Sets the active state of all auto spawn instances to that specified, and cancels the scheduled spawn task if necessary.
* @param isActive
*/
public void setAllActive(boolean isActive)
{
if (_activeState == isActive)
{
return;
}
for (AutoSpawnInstance spawnInst : _registeredSpawns.values())
{
setSpawnActive(spawnInst, isActive);
}
_activeState = isActive;
}
/**
* Returns the number of milliseconds until the next occurrence of the given spawn.
* @param spawnInst
* @return
*/
public final long getTimeToNextSpawn(AutoSpawnInstance spawnInst)
{
final int objectId = spawnInst.getObjectId();
if (!isSpawnRegistered(objectId))
{
return -1;
}
return (_runningSpawns.containsKey(objectId)) ? _runningSpawns.get(objectId).getDelay(TimeUnit.MILLISECONDS) : 0;
}
/**
* Attempts to return the AutoSpawnInstance associated with the given NPC or Object ID type.<br>
* Note: If isObjectId == false, returns first instance for the specified NPC ID.
* @param id
* @param isObjectId
* @return AutoSpawnInstance spawnInst
*/
public final AutoSpawnInstance getAutoSpawnInstance(int id, boolean isObjectId)
{
if (isObjectId)
{
if (isSpawnRegistered(id))
{
return _registeredSpawns.get(id);
}
}
else
{
for (AutoSpawnInstance spawnInst : _registeredSpawns.values())
{
if (spawnInst.getId() == id)
{
return spawnInst;
}
}
}
return null;
}
public List<AutoSpawnInstance> getAutoSpawnInstances(int npcId)
{
final List<AutoSpawnInstance> result = new LinkedList<>();
for (AutoSpawnInstance spawnInst : _registeredSpawns.values())
{
if (spawnInst.getId() == npcId)
{
result.add(spawnInst);
}
}
return result;
}
/**
* Tests if the specified object ID is assigned to an auto spawn.
* @param objectId
* @return isAssigned
*/
public final boolean isSpawnRegistered(int objectId)
{
return _registeredSpawns.containsKey(objectId);
}
/**
* Tests if the specified spawn instance is assigned to an auto spawn.
* @param spawnInst
* @return boolean isAssigned
*/
public final boolean isSpawnRegistered(AutoSpawnInstance spawnInst)
{
return _registeredSpawns.containsValue(spawnInst);
}
/**
* AutoSpawner class<br>
* This handles the main spawn task for an auto spawn instance, and initializes a despawner if required.
* @author Tempy
*/
private class AutoSpawner implements Runnable
{
private final int _objectId;
protected AutoSpawner(int objectId)
{
_objectId = objectId;
}
@Override
public void run()
{
try
{
// Retrieve the required spawn instance for this spawn task.
final AutoSpawnInstance spawnInst = _registeredSpawns.get(_objectId);
// If the spawn is not scheduled to be active, cancel the spawn
// task.
if (!spawnInst.isSpawnActive())
{
return;
}
final Location[] locationList = spawnInst.getLocationList();
// If there are no set co-ordinates, cancel the spawn task.
if (locationList.length == 0)
{
_log.info("AutoSpawnHandler: No location co-ords specified for spawn instance (Object ID = " + _objectId + ").");
return;
}
final int locationCount = locationList.length;
int locationIndex = Rnd.nextInt(locationCount);
// If random spawning is disabled, the spawn at the next set of co-ordinates after the last.
// If the index is greater than the number of possible spawns, reset the counter to zero.
if (!spawnInst.isRandomSpawn())
{
locationIndex = spawnInst._lastLocIndex + 1;
if (locationIndex == locationCount)
{
locationIndex = 0;
}
spawnInst._lastLocIndex = locationIndex;
}
// Set the X, Y and Z co-ordinates, where this spawn will take place.
final int x = locationList[locationIndex].getX();
final int y = locationList[locationIndex].getY();
final int z = locationList[locationIndex].getZ();
final int heading = locationList[locationIndex].getHeading();
final L2Spawn newSpawn = new L2Spawn(spawnInst.getId());
newSpawn.setX(x);
newSpawn.setY(y);
newSpawn.setZ(z);
if (heading != -1)
{
newSpawn.setHeading(heading);
}
newSpawn.setAmount(spawnInst.getSpawnCount());
if (spawnInst._desDelay == 0)
{
newSpawn.setRespawnDelay(spawnInst._resDelay);
}
// Add the new spawn information to the spawn table, but do not store it.
SpawnTable.getInstance().addNewSpawn(newSpawn, false);
L2Npc npcInst = null;
if (spawnInst._spawnCount == 1)
{
npcInst = newSpawn.doSpawn();
npcInst.setXYZ(npcInst.getX(), npcInst.getY(), npcInst.getZ());
spawnInst.addNpcInstance(npcInst);
}
else
{
for (int i = 0; i < spawnInst._spawnCount; i++)
{
npcInst = newSpawn.doSpawn();
// To prevent spawning of more than one NPC in the exact same spot, move it slightly by a small random offset.
npcInst.setXYZ(npcInst.getX() + Rnd.nextInt(50), npcInst.getY() + Rnd.nextInt(50), npcInst.getZ());
// Add the NPC instance to the list of managed instances.
spawnInst.addNpcInstance(npcInst);
}
}
if (npcInst != null)
{
final String nearestTown = MapRegionManager.getInstance().getClosestTownName(npcInst);
// Announce to all players that the spawn has taken place, with the nearest town location.
if (spawnInst.isBroadcasting())
{
Broadcast.toAllOnlinePlayers("The " + npcInst.getName() + " has spawned near " + nearestTown + "!");
}
}
// If there is no despawn time, do not create a despawn task.
if (spawnInst.getDespawnDelay() > 0)
{
final AutoDespawner rd = new AutoDespawner(_objectId);
ThreadPoolManager.getInstance().scheduleAi(rd, spawnInst.getDespawnDelay() - 1000);
}
}
catch (Exception e)
{
_log.log(Level.WARNING, "AutoSpawnHandler: An error occurred while initializing spawn instance (Object ID = " + _objectId + "): " + e.getMessage(), e);
}
}
}
/**
* AutoDespawner Class<br>
* Simply used as a secondary class for despawning an auto spawn instance.
* @author Tempy
*/
private class AutoDespawner implements Runnable
{
private final int _objectId;
protected AutoDespawner(int objectId)
{
_objectId = objectId;
}
@Override
public void run()
{
try
{
final AutoSpawnInstance spawnInst = _registeredSpawns.get(_objectId);
if (spawnInst == null)
{
_log.info("AutoSpawnHandler: No spawn registered for object ID = " + _objectId + ".");
return;
}
for (L2Npc npcInst : spawnInst.getNPCInstanceList())
{
if (npcInst == null)
{
continue;
}
npcInst.deleteMe();
SpawnTable.getInstance().deleteSpawn(npcInst.getSpawn(), false);
spawnInst.removeNpcInstance(npcInst);
}
}
catch (Exception e)
{
_log.log(Level.WARNING, "AutoSpawnHandler: An error occurred while despawning spawn (Object ID = " + _objectId + "): " + e.getMessage(), e);
}
}
}
/**
* AutoSpawnInstance Class<br>
* Stores information about a registered auto spawn.
* @author Tempy
*/
public static class AutoSpawnInstance implements IIdentifiable
{
protected int _objectId;
protected int _spawnIndex;
protected int _npcId;
protected int _initDelay;
protected int _resDelay;
protected int _desDelay;
protected int _spawnCount = 1;
protected int _lastLocIndex = -1;
private final List<L2Npc> _npcList = new CopyOnWriteArrayList<>();
private final List<Location> _locList = new CopyOnWriteArrayList<>();
private boolean _spawnActive;
private boolean _randomSpawn = false;
private boolean _broadcastAnnouncement = false;
protected AutoSpawnInstance(int npcId, int initDelay, int respawnDelay, int despawnDelay)
{
_npcId = npcId;
_initDelay = initDelay;
_resDelay = respawnDelay;
_desDelay = despawnDelay;
}
protected void setSpawnActive(boolean activeValue)
{
_spawnActive = activeValue;
}
protected boolean addNpcInstance(L2Npc npcInst)
{
return _npcList.add(npcInst);
}
protected boolean removeNpcInstance(L2Npc npcInst)
{
return _npcList.remove(npcInst);
}
public int getObjectId()
{
return _objectId;
}
public int getInitialDelay()
{
return _initDelay;
}
public int getRespawnDelay()
{
return _resDelay;
}
public int getDespawnDelay()
{
return _desDelay;
}
/**
* Gets the NPC ID.
* @return the NPC ID
*/
@Override
public int getId()
{
return _npcId;
}
public int getSpawnCount()
{
return _spawnCount;
}
public Location[] getLocationList()
{
return _locList.toArray(new Location[_locList.size()]);
}
public L2Npc[] getNPCInstanceList()
{
L2Npc[] ret;
synchronized (_npcList)
{
ret = new L2Npc[_npcList.size()];
_npcList.toArray(ret);
}
return ret;
}
public List<L2Spawn> getSpawns()
{
final List<L2Spawn> npcSpawns = new ArrayList<>();
for (L2Npc npcInst : _npcList)
{
npcSpawns.add(npcInst.getSpawn());
}
return npcSpawns;
}
public void setSpawnCount(int spawnCount)
{
_spawnCount = spawnCount;
}
public void setRandomSpawn(boolean randValue)
{
_randomSpawn = randValue;
}
public void setBroadcast(boolean broadcastValue)
{
_broadcastAnnouncement = broadcastValue;
}
public boolean isSpawnActive()
{
return _spawnActive;
}
public boolean isRandomSpawn()
{
return _randomSpawn;
}
public boolean isBroadcasting()
{
return _broadcastAnnouncement;
}
public boolean addSpawnLocation(int x, int y, int z, int heading)
{
return _locList.add(new Location(x, y, z, heading));
}
public boolean addSpawnLocation(int[] spawnLoc)
{
if (spawnLoc.length != 3)
{
return false;
}
return addSpawnLocation(spawnLoc[0], spawnLoc[1], spawnLoc[2], -1);
}
public Location removeSpawnLocation(int locIndex)
{
try
{
return _locList.remove(locIndex);
}
catch (IndexOutOfBoundsException e)
{
return null;
}
}
}
private static class SingletonHolder
{
protected static final AutoSpawnHandler _instance = new AutoSpawnHandler();
}
}

View File

@@ -0,0 +1,306 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.network.serverpackets.friend.BlockListPacket;
public class BlockList
{
private static Logger _log = Logger.getLogger(BlockList.class.getName());
private static Map<Integer, HashMap<Integer, String>> OFFLINE_LIST = new HashMap<>();
private final L2PcInstance _owner;
private HashMap<Integer, String> _blockList;
private final ArrayList<Integer> _updateMemos = new ArrayList<>();
public BlockList(L2PcInstance owner)
{
_owner = owner;
_blockList = OFFLINE_LIST.get(owner.getObjectId());
if (_blockList == null)
{
_blockList = loadList(_owner.getObjectId());
}
}
private void addToBlockList(int target)
{
_blockList.put(target, "");
persistInDB(target);
}
private void removeFromBlockList(int target)
{
_blockList.remove(Integer.valueOf(target));
if (_updateMemos.contains(target))
{
_updateMemos.remove(Integer.valueOf(target));
}
removeFromDB(target);
}
public void setBlockMemo(int target, String memo)
{
if (_blockList.containsKey(target))
{
_blockList.put(target, memo);
_updateMemos.add(target);
}
}
public void updateBlockMemos()
{
try (Connection con = ConnectionFactory.getInstance().getConnection())
{
for (int target : _updateMemos)
{
try (PreparedStatement ps = con.prepareStatement("UPDATE character_friends SET memo=? WHERE charId=? AND friendId=? AND relation=1"))
{
ps.setString(1, _blockList.get(target));
ps.setInt(2, _owner.getObjectId());
ps.setInt(3, target);
ps.execute();
}
}
}
catch (SQLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
_blockList.clear();
}
public void playerLogout()
{
OFFLINE_LIST.put(_owner.getObjectId(), _blockList);
}
private static HashMap<Integer, String> loadList(int ObjId)
{
final HashMap<Integer, String> list = new HashMap<>();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT friendId, memo FROM character_friends WHERE charId=? AND relation=1"))
{
ps.setInt(1, ObjId);
try (ResultSet rs = ps.executeQuery())
{
int friendId;
while (rs.next())
{
friendId = rs.getInt("friendId");
if (friendId == ObjId)
{
continue;
}
final String memo = rs.getString("memo");
list.put(friendId, memo);
}
}
}
catch (Exception e)
{
_log.log(Level.WARNING, "Error found in " + ObjId + " FriendList while loading BlockList: " + e.getMessage(), e);
}
return list;
}
private void removeFromDB(int targetId)
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_friends WHERE charId=? AND friendId=? AND relation=1"))
{
ps.setInt(1, _owner.getObjectId());
ps.setInt(2, targetId);
ps.execute();
}
catch (Exception e)
{
_log.log(Level.WARNING, "Could not remove blocked player: " + e.getMessage(), e);
}
}
private void persistInDB(int targetId)
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO character_friends (charId, friendId, relation) VALUES (?, ?, 1)"))
{
ps.setInt(1, _owner.getObjectId());
ps.setInt(2, targetId);
ps.execute();
}
catch (Exception e)
{
_log.log(Level.WARNING, "Could not add blocked player: " + e.getMessage(), e);
}
}
public boolean isInBlockList(L2PcInstance target)
{
return _blockList.containsKey(target.getObjectId());
}
public boolean isInBlockList(int targetId)
{
return _blockList.containsKey(targetId);
}
public boolean isBlockAll()
{
return _owner.getMessageRefusal();
}
public static boolean isBlocked(L2PcInstance listOwner, L2PcInstance target)
{
final BlockList blockList = listOwner.getBlockList();
return blockList.isBlockAll() || blockList.isInBlockList(target);
}
public static boolean isBlocked(L2PcInstance listOwner, int targetId)
{
final BlockList blockList = listOwner.getBlockList();
return blockList.isBlockAll() || blockList.isInBlockList(targetId);
}
private void setBlockAll(boolean state)
{
_owner.setMessageRefusal(state);
}
public HashMap<Integer, String> getBlockList()
{
return _blockList;
}
public static void addToBlockList(L2PcInstance listOwner, int targetId)
{
if (listOwner == null)
{
return;
}
final String charName = CharNameTable.getInstance().getNameById(targetId);
if (listOwner.getFriendList().containsKey(targetId))
{
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.THIS_PLAYER_IS_ALREADY_REGISTERED_ON_YOUR_FRIENDS_LIST);
sm.addString(charName);
listOwner.sendPacket(sm);
return;
}
if (listOwner.getBlockList().getBlockList().containsKey(targetId))
{
listOwner.sendMessage("Already in ignore list.");
return;
}
listOwner.getBlockList().addToBlockList(targetId);
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_ADDED_TO_YOUR_IGNORE_LIST);
sm.addString(charName);
listOwner.sendPacket(sm);
final L2PcInstance player = L2World.getInstance().getPlayer(targetId);
if (player != null)
{
sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_PLACED_YOU_ON_HIS_HER_IGNORE_LIST);
sm.addString(listOwner.getName());
player.sendPacket(sm);
}
}
public static void removeFromBlockList(L2PcInstance listOwner, int targetId)
{
if (listOwner == null)
{
return;
}
SystemMessage sm;
final String charName = CharNameTable.getInstance().getNameById(targetId);
if (!listOwner.getBlockList().getBlockList().containsKey(targetId))
{
sm = SystemMessage.getSystemMessage(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
listOwner.sendPacket(sm);
return;
}
listOwner.getBlockList().removeFromBlockList(targetId);
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_REMOVED_FROM_YOUR_IGNORE_LIST);
sm.addString(charName);
listOwner.sendPacket(sm);
}
public static boolean isInBlockList(L2PcInstance listOwner, L2PcInstance target)
{
return listOwner.getBlockList().isInBlockList(target);
}
public boolean isBlockAll(L2PcInstance listOwner)
{
return listOwner.getBlockList().isBlockAll();
}
public static void setBlockAll(L2PcInstance listOwner, boolean newValue)
{
listOwner.getBlockList().setBlockAll(newValue);
}
public static void sendListToOwner(L2PcInstance listOwner)
{
listOwner.sendPacket(new BlockListPacket(listOwner));
}
/**
* @param ownerId object id of owner block list
* @param targetId object id of potential blocked player
* @return true if blocked
*/
public static boolean isInBlockList(int ownerId, int targetId)
{
final L2PcInstance player = L2World.getInstance().getPlayer(ownerId);
if (player != null)
{
return BlockList.isBlocked(player, targetId);
}
if (!OFFLINE_LIST.containsKey(ownerId))
{
OFFLINE_LIST.put(ownerId, loadList(ownerId));
}
return OFFLINE_LIST.get(ownerId).containsKey(targetId);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,475 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import com.l2jmobius.gameserver.model.entity.Hero;
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
import com.l2jmobius.gameserver.model.itemcontainer.PcInventory;
import com.l2jmobius.gameserver.model.variables.PlayerVariables;
/**
* Used to Store data sent to Client for Character.<br>
* Selection screen.
* @version $Revision: 1.2.2.2.2.4 $ $Date: 2005/03/27 15:29:33 $
*/
public class CharSelectInfoPackage
{
private String _name;
private int _objectId = 0;
private long _exp = 0;
private long _sp = 0;
private int _clanId = 0;
private int _race = 0;
private int _classId = 0;
private int _baseClassId = 0;
private long _deleteTimer = 0L;
private long _lastAccess = 0L;
private int _face = 0;
private int _hairStyle = 0;
private int _hairColor = 0;
private int _sex = 0;
private int _level = 1;
private int _maxHp = 0;
private double _currentHp = 0;
private int _maxMp = 0;
private double _currentMp = 0;
private final int[][] _paperdoll;
private int _reputation = 0;
private int _pkKills = 0;
private int _pvpKills = 0;
private int _augmentationId = 0;
private int _x = 0;
private int _y = 0;
private int _z = 0;
private String _htmlPrefix = null;
private int _vitalityPoints = 0;
private int _accessLevel = 0;
private boolean _isGood = false;
private boolean _isEvil = false;
private final PlayerVariables _vars;
/**
* Constructor for CharSelectInfoPackage.
* @param objectId character object Id.
* @param name the character's name.
*/
public CharSelectInfoPackage(int objectId, String name)
{
setObjectId(objectId);
_name = name;
_paperdoll = PcInventory.restoreVisibleInventory(objectId);
_vars = new PlayerVariables(_objectId);
}
/**
* @return the character object Id.
*/
public int getObjectId()
{
return _objectId;
}
public void setObjectId(int objectId)
{
_objectId = objectId;
}
/**
* @return the character's access level.
*/
public int getAccessLevel()
{
return _accessLevel;
}
/**
* @param level the character's access level to be set.
*/
public void setAccessLevel(int level)
{
_accessLevel = level;
}
public boolean isGood()
{
return _isGood;
}
public void setGood()
{
_isGood = true;
_isEvil = false;
}
public boolean isEvil()
{
return _isEvil;
}
public void setEvil()
{
_isGood = false;
_isEvil = true;
}
public int getClanId()
{
return _clanId;
}
public void setClanId(int clanId)
{
_clanId = clanId;
}
public int getClassId()
{
return _classId;
}
public int getBaseClassId()
{
return _baseClassId;
}
public void setClassId(int classId)
{
_classId = classId;
}
public void setBaseClassId(int baseClassId)
{
_baseClassId = baseClassId;
}
public double getCurrentHp()
{
return _currentHp;
}
public void setCurrentHp(double currentHp)
{
_currentHp = currentHp;
}
public double getCurrentMp()
{
return _currentMp;
}
public void setCurrentMp(double currentMp)
{
_currentMp = currentMp;
}
public long getDeleteTimer()
{
return _deleteTimer;
}
public void setDeleteTimer(long deleteTimer)
{
_deleteTimer = deleteTimer;
}
public long getLastAccess()
{
return _lastAccess;
}
public void setLastAccess(long lastAccess)
{
_lastAccess = lastAccess;
}
public long getExp()
{
return _exp;
}
public void setExp(long exp)
{
_exp = exp;
}
public int getFace()
{
return _vars.getInt("visualFaceId", _face);
}
public void setFace(int face)
{
_face = face;
}
public int getHairColor()
{
return _vars.getInt("visualHairColorId", _hairColor);
}
public void setHairColor(int hairColor)
{
_hairColor = hairColor;
}
public int getHairStyle()
{
return _vars.getInt("visualHairId", _hairStyle);
}
public void setHairStyle(int hairStyle)
{
_hairStyle = hairStyle;
}
public int getPaperdollObjectId(int slot)
{
return _paperdoll[slot][0];
}
public int getPaperdollItemId(int slot)
{
return _paperdoll[slot][1];
}
public int getPaperdollItemVisualId(int slot)
{
return _paperdoll[slot][3];
}
public int getLevel()
{
return _level;
}
public void setLevel(int level)
{
_level = level;
}
public int getMaxHp()
{
return _maxHp;
}
public void setMaxHp(int maxHp)
{
_maxHp = maxHp;
}
public int getMaxMp()
{
return _maxMp;
}
public void setMaxMp(int maxMp)
{
_maxMp = maxMp;
}
public String getName()
{
return _name;
}
public void setName(String name)
{
_name = name;
}
public int getRace()
{
return _race;
}
public void setRace(int race)
{
_race = race;
}
public int getSex()
{
return _sex;
}
public void setSex(int sex)
{
_sex = sex;
}
public long getSp()
{
return _sp;
}
public void setSp(long sp)
{
_sp = sp;
}
public int getWeaponEnchantEffect()
{
return getEnchantEffect(Inventory.PAPERDOLL_RHAND);
}
public int getEnchantEffect(int slot)
{
return _paperdoll[slot][2];
}
public void setReputation(int reputation)
{
_reputation = reputation;
}
public int getReputation()
{
return _reputation;
}
public void setAugmentationId(int augmentationId)
{
_augmentationId = augmentationId;
}
public int getAugmentationId()
{
return _augmentationId;
}
public void setPkKills(int PkKills)
{
_pkKills = PkKills;
}
public int getPkKills()
{
return _pkKills;
}
public void setPvPKills(int PvPKills)
{
_pvpKills = PvPKills;
}
public int getPvPKills()
{
return _pvpKills;
}
public int getX()
{
return _x;
}
public int getY()
{
return _y;
}
public int getZ()
{
return _z;
}
public void setX(int x)
{
_x = x;
}
public void setY(int y)
{
_y = y;
}
public void setZ(int z)
{
_z = z;
}
public String getHtmlPrefix()
{
return _htmlPrefix;
}
public void setHtmlPrefix(String s)
{
_htmlPrefix = s;
}
public void setVitalityPoints(int points)
{
_vitalityPoints = points;
}
public int getVitalityPoints()
{
return _vitalityPoints;
}
public boolean isHairAccessoryEnabled()
{
return _vars.getBoolean("hairAccessoryEnabled", true);
}
public int getTransformationId()
{
final int weaponId = getPaperdollItemId(Inventory.PAPERDOLL_RHAND);
switch (weaponId)
{
case 8190:
{
return 301;
}
case 8689:
{
return 302;
}
}
return 0;
}
public int getVitalityPercent()
{
return 200; // TODO: Implement.
}
public int getVitalityItemCount()
{
return 5; // TODO: Implement.
}
public boolean isAvailable()
{
return getAccessLevel() > -100;
}
public boolean isHero()
{
return Hero.getInstance().isHero(getObjectId());
}
public int get1stAugmentationId()
{
return 0x0000FFFF & getAugmentationId();
}
public int get2ndAugmentationId()
{
return getAugmentationId() >> 16;
}
}

View File

@@ -0,0 +1,49 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
/**
* @author UnAfraid
*/
public class ClanInfo
{
private final L2Clan _clan;
private final int _total;
private final int _online;
public ClanInfo(final L2Clan clan)
{
_clan = clan;
_total = clan.getMembersCount();
_online = clan.getOnlineMembersCount();
}
public L2Clan getClan()
{
return _clan;
}
public int getTotal()
{
return _total;
}
public int getOnline()
{
return _online;
}
}

View File

@@ -0,0 +1,62 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
/**
* This enum is used for clan privileges.<br>
* The ordinal of each entry is the bit index in the privilege bitmask.
* @author HorridoJoho
*/
public enum ClanPrivilege
{
/** dummy entry */
DUMMY,
/** Privilege to join clan */
CL_JOIN_CLAN,
/** Privilege to give a title */
CL_GIVE_TITLE,
/** Privilege to view warehouse content */
CL_VIEW_WAREHOUSE,
/** Privilege to manage clan ranks */
CL_MANAGE_RANKS,
CL_PLEDGE_WAR,
CL_DISMISS,
/** Privilege to register clan crest */
CL_REGISTER_CREST,
CL_APPRENTICE,
CL_TROOPS_FAME,
CL_SUMMON_AIRSHIP,
/** Privilege to open a door */
CH_OPEN_DOOR,
CH_OTHER_RIGHTS,
CH_AUCTION,
CH_DISMISS,
CH_SET_FUNCTIONS,
CS_OPEN_DOOR,
CS_MANOR_ADMIN,
CS_MANAGE_SIEGE,
CS_USE_FUNCTIONS,
CS_DISMISS,
CS_TAXES,
CS_MERCENARIES,
CS_SET_FUNCTIONS;
public int getBitmask()
{
return 1 << ordinal();
}
}

View File

@@ -0,0 +1,126 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jmobius.gameserver.network.serverpackets.ItemList;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
public class CombatFlag
{
// private static final Logger _log = Logger.getLogger(CombatFlag.class.getName());
private L2PcInstance _player = null;
private int _playerId = 0;
private L2ItemInstance _item = null;
private L2ItemInstance _itemInstance;
private final Location _location;
private final int _itemId;
@SuppressWarnings("unused")
private final int _fortId;
public CombatFlag(int fort_id, int x, int y, int z, int heading, int item_id)
{
_fortId = fort_id;
_location = new Location(x, y, z, heading);
_itemId = item_id;
}
public synchronized void spawnMe()
{
// Init the dropped L2ItemInstance and add it in the world as a visible object at the position where mob was last
_itemInstance = ItemTable.getInstance().createItem("Combat", _itemId, 1, null, null);
_itemInstance.dropMe(null, _location.getX(), _location.getY(), _location.getZ());
}
public synchronized void unSpawnMe()
{
if (_player != null)
{
dropIt();
}
if (_itemInstance != null)
{
_itemInstance.decayMe();
}
}
public boolean activate(L2PcInstance player, L2ItemInstance item)
{
if (player.isMounted())
{
player.sendPacket(SystemMessageId.YOU_DO_NOT_MEET_THE_REQUIRED_CONDITION_TO_EQUIP_THAT_ITEM);
return false;
}
// Player holding it data
_player = player;
_playerId = _player.getObjectId();
_itemInstance = null;
// Equip with the weapon
_item = item;
_player.getInventory().equipItem(_item);
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EQUIPPED_YOUR_S1);
sm.addItemName(_item);
_player.sendPacket(sm);
// Refresh inventory
if (!Config.FORCE_INVENTORY_UPDATE)
{
final InventoryUpdate iu = new InventoryUpdate();
iu.addItem(_item);
_player.sendPacket(iu);
}
else
{
_player.sendPacket(new ItemList(_player, false));
}
// Refresh player stats
_player.broadcastUserInfo();
_player.setCombatFlagEquipped(true);
return true;
}
public void dropIt()
{
// Reset player stats
_player.setCombatFlagEquipped(false);
final int slot = _player.getInventory().getSlotFromItem(_item);
_player.getInventory().unEquipItemInBodySlot(slot);
_player.destroyItem("CombatFlag", _item, null, true);
_item = null;
_player.broadcastUserInfo();
_player = null;
_playerId = 0;
}
public int getPlayerObjectId()
{
return _playerId;
}
public L2ItemInstance getCombatFlagInstance()
{
return _itemInstance;
}
}

View File

@@ -0,0 +1,36 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
/**
* @author malyelfik
*/
public final class CropProcure extends SeedProduction
{
private final int _rewardType;
public CropProcure(int id, long amount, int type, long startAmount, long price)
{
super(id, amount, price, startAmount);
_rewardType = type;
}
public final int getReward()
{
return _rewardType;
}
}

View File

@@ -0,0 +1,51 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
/**
* @author UnAfraid
*/
public class CrystalizationData
{
private final int _id;
private final List<ItemChanceHolder> _items = new ArrayList<>();
public CrystalizationData(int id)
{
_id = id;
}
public int getId()
{
return _id;
}
public void addItem(ItemChanceHolder item)
{
_items.add(item);
}
public List<ItemChanceHolder> getItems()
{
return _items;
}
}

View File

@@ -0,0 +1,745 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.concurrent.ScheduledFuture;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.data.xml.impl.TransformData;
import com.l2jmobius.gameserver.datatables.SkillData;
import com.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
import com.l2jmobius.gameserver.model.L2Party.messageType;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.interfaces.INamable;
import com.l2jmobius.gameserver.model.items.L2Item;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.skills.CommonSkill;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.Earthquake;
import com.l2jmobius.gameserver.network.serverpackets.ExRedSky;
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jmobius.gameserver.network.serverpackets.ItemList;
import com.l2jmobius.gameserver.network.serverpackets.SocialAction;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.network.serverpackets.UserInfo;
import com.l2jmobius.gameserver.util.Broadcast;
import com.l2jmobius.util.Rnd;
public class CursedWeapon implements INamable
{
private static final Logger _log = Logger.getLogger(CursedWeapon.class.getName());
// _name is the name of the cursed weapon associated with its ID.
private final String _name;
// _itemId is the Item ID of the cursed weapon.
private final int _itemId;
// _skillId is the skills ID.
private final int _skillId;
private final int _skillMaxLevel;
private int _dropRate;
private int _duration;
private int _durationLost;
private int _disapearChance;
private int _stageKills;
// this should be false unless if the cursed weapon is dropped, in that case it would be true.
private boolean _isDropped = false;
// this sets the cursed weapon status to true only if a player has the cursed weapon, otherwise this should be false.
private boolean _isActivated = false;
private ScheduledFuture<?> _removeTask;
private int _nbKills = 0;
private long _endTime = 0;
private int _playerId = 0;
protected L2PcInstance _player = null;
private L2ItemInstance _item = null;
private int _playerReputation = 0;
private int _playerPkKills = 0;
protected int transformationId = 0;
public CursedWeapon(int itemId, int skillId, String name)
{
_name = name;
_itemId = itemId;
_skillId = skillId;
_skillMaxLevel = SkillData.getInstance().getMaxLevel(_skillId);
}
public void endOfLife()
{
if (_isActivated)
{
if ((_player != null) && _player.isOnline())
{
// Remove from player
_log.info(_name + " being removed online.");
_player.abortAttack();
_player.setReputation(_playerReputation);
_player.setPkKills(_playerPkKills);
_player.setCursedWeaponEquippedId(0);
removeSkill();
// Remove
_player.getInventory().unEquipItemInBodySlot(L2Item.SLOT_LR_HAND);
_player.storeMe();
// Destroy
final L2ItemInstance removedItem = _player.getInventory().destroyItemByItemId("", _itemId, 1, _player, null);
if (!Config.FORCE_INVENTORY_UPDATE)
{
final InventoryUpdate iu = new InventoryUpdate();
if (removedItem.getCount() == 0)
{
iu.addRemovedItem(removedItem);
}
else
{
iu.addModifiedItem(removedItem);
}
_player.sendPacket(iu);
}
else
{
_player.sendPacket(new ItemList(_player, true));
}
_player.broadcastUserInfo();
}
else
{
// Remove from Db
_log.info(_name + " being removed offline.");
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement del = con.prepareStatement("DELETE FROM items WHERE owner_id=? AND item_id=?");
PreparedStatement ps = con.prepareStatement("UPDATE characters SET karma=?, pkkills=? WHERE charId=?"))
{
// Delete the item
del.setInt(1, _playerId);
del.setInt(2, _itemId);
if (del.executeUpdate() != 1)
{
_log.warning("Error while deleting itemId " + _itemId + " from userId " + _playerId);
}
// Restore the karma
ps.setInt(1, _playerReputation);
ps.setInt(2, _playerPkKills);
ps.setInt(3, _playerId);
if (ps.executeUpdate() != 1)
{
_log.warning("Error while updating karma & pkkills for userId " + _playerId);
}
}
catch (Exception e)
{
_log.log(Level.WARNING, "Could not delete : " + e.getMessage(), e);
}
}
}
else
{
// either this cursed weapon is in the inventory of someone who has another cursed weapon equipped,
// OR this cursed weapon is on the ground.
if ((_player != null) && (_player.getInventory().getItemByItemId(_itemId) != null))
{
// Destroy
final L2ItemInstance removedItem = _player.getInventory().destroyItemByItemId("", _itemId, 1, _player, null);
if (!Config.FORCE_INVENTORY_UPDATE)
{
final InventoryUpdate iu = new InventoryUpdate();
if (removedItem.getCount() == 0)
{
iu.addRemovedItem(removedItem);
}
else
{
iu.addModifiedItem(removedItem);
}
_player.sendPacket(iu);
}
else
{
_player.sendPacket(new ItemList(_player, true));
}
_player.broadcastUserInfo();
}
// is dropped on the ground
else if (_item != null)
{
_item.decayMe();
L2World.getInstance().removeObject(_item);
_log.info(_name + " item has been removed from World.");
}
}
// Delete infos from table if any
CursedWeaponsManager.removeFromDb(_itemId);
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_DISAPPEARED);
sm.addItemName(_itemId);
CursedWeaponsManager.announce(sm);
// Reset state
cancelTask();
_isActivated = false;
_isDropped = false;
_endTime = 0;
_player = null;
_playerId = 0;
_playerReputation = 0;
_playerPkKills = 0;
_item = null;
_nbKills = 0;
}
private void cancelTask()
{
if (_removeTask != null)
{
_removeTask.cancel(true);
_removeTask = null;
}
}
private class RemoveTask implements Runnable
{
protected RemoveTask()
{
}
@Override
public void run()
{
if (System.currentTimeMillis() >= getEndTime())
{
endOfLife();
}
}
}
private void dropIt(L2Attackable attackable, L2PcInstance player)
{
dropIt(attackable, player, null, true);
}
private void dropIt(L2Attackable attackable, L2PcInstance player, L2Character killer, boolean fromMonster)
{
_isActivated = false;
if (fromMonster)
{
_item = attackable.dropItem(player, _itemId, 1);
_item.setDropTime(0); // Prevent item from being removed by ItemsAutoDestroy
// RedSky and Earthquake
final ExRedSky packet = new ExRedSky(10);
final Earthquake eq = new Earthquake(player.getX(), player.getY(), player.getZ(), 14, 3);
Broadcast.toAllOnlinePlayers(packet);
Broadcast.toAllOnlinePlayers(eq);
}
else
{
_item = _player.getInventory().getItemByItemId(_itemId);
_player.dropItem("DieDrop", _item, killer, true);
_player.setReputation(_playerReputation);
_player.setPkKills(_playerPkKills);
_player.setCursedWeaponEquippedId(0);
removeSkill();
_player.abortAttack();
// L2ItemInstance item = _player.getInventory().getItemByItemId(_itemId);
// _player.getInventory().dropItem("DieDrop", item, _player, null);
// _player.getInventory().getItemByItemId(_itemId).dropMe(_player, _player.getX(), _player.getY(), _player.getZ());
}
_isDropped = true;
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S2_WAS_DROPPED_IN_THE_S1_REGION);
if (player != null)
{
sm.addZoneName(player.getX(), player.getY(), player.getZ()); // Region Name
}
else if (_player != null)
{
sm.addZoneName(_player.getX(), _player.getY(), _player.getZ()); // Region Name
}
else
{
sm.addZoneName(killer.getX(), killer.getY(), killer.getZ()); // Region Name
}
sm.addItemName(_itemId);
CursedWeaponsManager.announce(sm); // in the Hot Spring region
}
public void cursedOnLogin()
{
doTransform();
giveSkill();
final SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.S2_S_OWNER_HAS_LOGGED_INTO_THE_S1_REGION);
msg.addZoneName(_player.getX(), _player.getY(), _player.getZ());
msg.addItemName(_player.getCursedWeaponEquippedId());
CursedWeaponsManager.announce(msg);
final CursedWeapon cw = CursedWeaponsManager.getInstance().getCursedWeapon(_player.getCursedWeaponEquippedId());
final SystemMessage msg2 = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_S2_MINUTE_S_OF_USAGE_TIME_REMAINING);
final int timeLeft = (int) (cw.getTimeLeft() / 60000);
msg2.addItemName(_player.getCursedWeaponEquippedId());
msg2.addInt(timeLeft);
_player.sendPacket(msg2);
}
/**
* Yesod:<br>
* Rebind the passive skill belonging to the CursedWeapon. Invoke this method if the weapon owner switches to a subclass.
*/
public void giveSkill()
{
int level = 1 + (_nbKills / _stageKills);
if (level > _skillMaxLevel)
{
level = _skillMaxLevel;
}
final Skill skill = SkillData.getInstance().getSkill(_skillId, level);
_player.addSkill(skill, false);
// Void Burst, Void Flow
_player.addSkill(CommonSkill.VOID_BURST.getSkill(), false);
_player.addTransformSkill(CommonSkill.VOID_BURST.getSkill());
_player.addSkill(CommonSkill.VOID_FLOW.getSkill(), false);
_player.addTransformSkill(CommonSkill.VOID_FLOW.getSkill());
_player.sendSkillList();
}
public void doTransform()
{
if (_itemId == 8689)
{
transformationId = 302;
}
else if (_itemId == 8190)
{
transformationId = 301;
}
if (_player.isTransformed() || _player.isInStance())
{
_player.stopTransformation(true);
ThreadPoolManager.getInstance().scheduleGeneral(() -> TransformData.getInstance().transformPlayer(transformationId, _player), 500);
}
else
{
TransformData.getInstance().transformPlayer(transformationId, _player);
}
}
public void removeSkill()
{
_player.removeSkill(_skillId);
_player.removeSkill(CommonSkill.VOID_BURST.getSkill().getId());
_player.removeSkill(CommonSkill.VOID_FLOW.getSkill().getId());
_player.untransform();
_player.sendSkillList();
}
public void reActivate()
{
_isActivated = true;
if ((_endTime - System.currentTimeMillis()) <= 0)
{
endOfLife();
}
else
{
_removeTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new RemoveTask(), _durationLost * 12000L, _durationLost * 12000L);
}
}
public boolean checkDrop(L2Attackable attackable, L2PcInstance player)
{
if (Rnd.get(100000) < _dropRate)
{
// Drop the item
dropIt(attackable, player);
// Start the Life Task
_endTime = System.currentTimeMillis() + (_duration * 60000L);
_removeTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new RemoveTask(), _durationLost * 12000L, _durationLost * 12000L);
return true;
}
return false;
}
public void activate(L2PcInstance player, L2ItemInstance item)
{
// If the player is mounted, attempt to unmount first.
// Only allow picking up the cursed weapon if unmounting is successful.
if (player.isMounted() && !player.dismount())
{
// TODO: Verify the following system message, may still be custom.
player.sendPacket(SystemMessageId.YOU_HAVE_FAILED_TO_PICK_UP_S1);
player.dropItem("InvDrop", item, null, true);
return;
}
_isActivated = true;
// Player holding it data
_player = player;
_playerId = _player.getObjectId();
_playerReputation = _player.getReputation();
_playerPkKills = _player.getPkKills();
saveData();
// Change player stats
_player.setCursedWeaponEquippedId(_itemId);
_player.setReputation(-9999999);
_player.setPkKills(0);
if (_player.isInParty())
{
_player.getParty().removePartyMember(_player, messageType.Expelled);
}
// Disable All Skills
// Do Transform
doTransform();
// Add skill
giveSkill();
// Equip with the weapon
_item = item;
// L2ItemInstance[] items =
_player.getInventory().equipItem(_item);
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EQUIPPED_YOUR_S1);
sm.addItemName(_item);
_player.sendPacket(sm);
// Fully heal player
_player.setCurrentHpMp(_player.getMaxHp(), _player.getMaxMp());
_player.setCurrentCp(_player.getMaxCp());
// Refresh inventory
if (!Config.FORCE_INVENTORY_UPDATE)
{
final InventoryUpdate iu = new InventoryUpdate();
iu.addItem(_item);
// iu.addItems(Arrays.asList(items));
_player.sendPacket(iu);
}
else
{
_player.sendPacket(new ItemList(_player, false));
}
// Refresh player stats
_player.broadcastUserInfo();
final SocialAction atk = new SocialAction(_player.getObjectId(), 17);
_player.broadcastPacket(atk);
sm = SystemMessage.getSystemMessage(SystemMessageId.THE_OWNER_OF_S2_HAS_APPEARED_IN_THE_S1_REGION);
sm.addZoneName(_player.getX(), _player.getY(), _player.getZ()); // Region Name
sm.addItemName(_item);
CursedWeaponsManager.announce(sm);
}
public void saveData()
{
if (Config.DEBUG)
{
_log.info("CursedWeapon: Saving data to disk.");
}
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement del = con.prepareStatement("DELETE FROM cursed_weapons WHERE itemId = ?");
PreparedStatement ps = con.prepareStatement("INSERT INTO cursed_weapons (itemId, charId, playerKarma, playerPkKills, nbKills, endTime) VALUES (?, ?, ?, ?, ?, ?)"))
{
// Delete previous datas
del.setInt(1, _itemId);
del.executeUpdate();
if (_isActivated)
{
ps.setInt(1, _itemId);
ps.setInt(2, _playerId);
ps.setInt(3, _playerReputation);
ps.setInt(4, _playerPkKills);
ps.setInt(5, _nbKills);
ps.setLong(6, _endTime);
ps.executeUpdate();
}
}
catch (SQLException e)
{
_log.log(Level.SEVERE, "CursedWeapon: Failed to save data.", e);
}
}
public void dropIt(L2Character killer)
{
if (Rnd.get(100) <= _disapearChance)
{
// Remove it
endOfLife();
}
else
{
// Unequip & Drop
dropIt(null, null, killer, false);
// Reset player stats
_player.setReputation(_playerReputation);
_player.setPkKills(_playerPkKills);
_player.setCursedWeaponEquippedId(0);
removeSkill();
_player.abortAttack();
_player.broadcastUserInfo();
}
}
public void increaseKills()
{
_nbKills++;
if ((_player != null) && _player.isOnline())
{
_player.setPkKills(_nbKills);
_player.sendPacket(new UserInfo(_player));
if (((_nbKills % _stageKills) == 0) && (_nbKills <= (_stageKills * (_skillMaxLevel - 1))))
{
giveSkill();
}
}
// Reduce time-to-live
_endTime -= _durationLost * 60000L;
saveData();
}
public void setDisapearChance(int disapearChance)
{
_disapearChance = disapearChance;
}
public void setDropRate(int dropRate)
{
_dropRate = dropRate;
}
public void setDuration(int duration)
{
_duration = duration;
}
public void setDurationLost(int durationLost)
{
_durationLost = durationLost;
}
public void setStageKills(int stageKills)
{
_stageKills = stageKills;
}
public void setNbKills(int nbKills)
{
_nbKills = nbKills;
}
public void setPlayerId(int playerId)
{
_playerId = playerId;
}
public void setPlayerKarma(int playerKarma)
{
_playerReputation = playerKarma;
}
public void setPlayerPkKills(int playerPkKills)
{
_playerPkKills = playerPkKills;
}
public void setActivated(boolean isActivated)
{
_isActivated = isActivated;
}
public void setDropped(boolean isDropped)
{
_isDropped = isDropped;
}
public void setEndTime(long endTime)
{
_endTime = endTime;
}
public void setPlayer(L2PcInstance player)
{
_player = player;
}
public void setItem(L2ItemInstance item)
{
_item = item;
}
public boolean isActivated()
{
return _isActivated;
}
public boolean isDropped()
{
return _isDropped;
}
public long getEndTime()
{
return _endTime;
}
@Override
public String getName()
{
return _name;
}
public int getItemId()
{
return _itemId;
}
public int getSkillId()
{
return _skillId;
}
public int getPlayerId()
{
return _playerId;
}
public L2PcInstance getPlayer()
{
return _player;
}
public int getPlayerKarma()
{
return _playerReputation;
}
public int getPlayerPkKills()
{
return _playerPkKills;
}
public int getNbKills()
{
return _nbKills;
}
public int getStageKills()
{
return _stageKills;
}
public boolean isActive()
{
return _isActivated || _isDropped;
}
public int getLevel()
{
if (_nbKills > (_stageKills * _skillMaxLevel))
{
return _skillMaxLevel;
}
return (_nbKills / _stageKills);
}
public long getTimeLeft()
{
return _endTime - System.currentTimeMillis();
}
public void goTo(L2PcInstance player)
{
if (player == null)
{
return;
}
if (_isActivated && (_player != null))
{
// Go to player holding the weapon
player.teleToLocation(_player.getLocation(), true);
}
else if (_isDropped && (_item != null))
{
// Go to item on the ground
player.teleToLocation(_item.getLocation(), true);
}
else
{
player.sendMessage(_name + " isn't in the World.");
}
}
public Location getWorldPosition()
{
if (_isActivated && (_player != null))
{
return _player.getLocation();
}
if (_isDropped && (_item != null))
{
return _item.getLocation();
}
return null;
}
public long getDuration()
{
return _duration;
}
}

View File

@@ -0,0 +1,70 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/**
* @author xban1x
*/
public final class DamageDoneInfo
{
private final L2PcInstance _attacker;
private int _damage = 0;
public DamageDoneInfo(L2PcInstance attacker)
{
_attacker = attacker;
}
public L2PcInstance getAttacker()
{
return _attacker;
}
public void addDamage(int damage)
{
_damage += damage;
}
public int getDamage()
{
return _damage;
}
@Override
public final boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (obj instanceof DamageDoneInfo)
{
return (((DamageDoneInfo) obj).getAttacker() == _attacker);
}
return false;
}
@Override
public final int hashCode()
{
return _attacker.getObjectId();
}
}

View File

@@ -0,0 +1,108 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.concurrent.ScheduledFuture;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance;
/**
* @author DrHouse
*/
public class DropProtection implements Runnable
{
private volatile boolean _isProtected = false;
private L2PcInstance _owner = null;
private ScheduledFuture<?> _task = null;
private static final long PROTECTED_MILLIS_TIME = 15000;
@Override
public synchronized void run()
{
_isProtected = false;
_owner = null;
_task = null;
}
public boolean isProtected()
{
return _isProtected;
}
public L2PcInstance getOwner()
{
return _owner;
}
public synchronized boolean tryPickUp(L2PcInstance actor)
{
if (!_isProtected)
{
return true;
}
if (_owner == actor)
{
return true;
}
if ((_owner.getParty() != null) && (_owner.getParty() == actor.getParty()))
{
return true;
}
/*
* if (_owner.getClan() != null && _owner.getClan() == actor.getClan()) return true;
*/
return false;
}
public boolean tryPickUp(L2PetInstance pet)
{
return tryPickUp(pet.getOwner());
}
public synchronized void unprotect()
{
if (_task != null)
{
_task.cancel(false);
}
_isProtected = false;
_owner = null;
_task = null;
}
public synchronized void protect(L2PcInstance player)
{
unprotect();
_isProtected = true;
_owner = player;
if (_owner == null)
{
throw new NullPointerException("Trying to protect dropped item to null owner");
}
_task = ThreadPoolManager.getInstance().scheduleGeneral(this, PROTECTED_MILLIS_TIME);
}
}

View File

@@ -0,0 +1,493 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.HashMap;
import java.util.Map;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.stats.Stats;
import com.l2jmobius.gameserver.model.stats.functions.FuncAdd;
public final class Elementals
{
private static final Map<Integer, ElementalItems> TABLE = new HashMap<>();
static
{
for (ElementalItems item : ElementalItems.values())
{
TABLE.put(item._itemId, item);
}
}
public static final byte NONE = -1;
public static final byte FIRE = 0;
public static final byte WATER = 1;
public static final byte WIND = 2;
public static final byte EARTH = 3;
public static final byte HOLY = 4;
public static final byte DARK = 5;
public static final int FIRST_WEAPON_BONUS = 20;
public static final int NEXT_WEAPON_BONUS = 5;
public static final int ARMOR_BONUS = 6;
public static final int[] WEAPON_VALUES =
{
0, // Level 1
25, // Level 2
75, // Level 3
150, // Level 4
175, // Level 5
225, // Level 6
300, // Level 7
325, // Level 8
375, // Level 9
450, // Level 10
475, // Level 11
525, // Level 12
600, // Level 13
Integer.MAX_VALUE
// TODO: Higher stones
};
public static final int[] ARMOR_VALUES =
{
0, // Level 1
12, // Level 2
30, // Level 3
60, // Level 4
72, // Level 5
90, // Level 6
120, // Level 7
132, // Level 8
150, // Level 9
180, // Level 10
192, // Level 11
210, // Level 12
240, // Level 13
Integer.MAX_VALUE
// TODO: Higher stones
};
public static enum ElementalItemType
{
Stone(3),
Roughore(3),
Stone60(3),
Stone150(3),
Crystal(6),
Crystal300(6),
Jewel(9),
Energy(12);
public int _maxLevel;
private ElementalItemType(int maxLvl)
{
_maxLevel = maxLvl;
}
}
public static enum ElementalItems
{
fireStone1(FIRE, 9546, ElementalItemType.Stone),
fireStone2(FIRE, 22635, ElementalItemType.Stone),
fireStone3(FIRE, 34790, ElementalItemType.Stone),
fireStone4(FIRE, 37499, ElementalItemType.Stone),
fireStone5(FIRE, 22919, ElementalItemType.Stone),
fireStone6(FIRE, 34661, ElementalItemType.Stone60),
fireStone7(FIRE, 36960, ElementalItemType.Stone60),
fireStone8(FIRE, 33863, ElementalItemType.Stone60),
fireStone9(FIRE, 35729, ElementalItemType.Stone60),
fireStone10(FIRE, 34667, ElementalItemType.Stone150),
fireStone11(FIRE, 36966, ElementalItemType.Stone150),
fireStone12(FIRE, 33869, ElementalItemType.Stone150),
fireStone13(FIRE, 35735, ElementalItemType.Stone150),
fireStone14(FIRE, 33481, ElementalItemType.Stone150),
waterStone1(WATER, 9547, ElementalItemType.Stone),
waterStone2(WATER, 34791, ElementalItemType.Stone),
waterStone3(WATER, 22636, ElementalItemType.Stone),
waterStone4(WATER, 37500, ElementalItemType.Stone),
waterStone5(WATER, 22920, ElementalItemType.Stone),
waterStone6(WATER, 34662, ElementalItemType.Stone60),
waterStone7(WATER, 36961, ElementalItemType.Stone60),
waterStone8(WATER, 33864, ElementalItemType.Stone60),
waterStone9(WATER, 35730, ElementalItemType.Stone60),
waterStone10(WATER, 34668, ElementalItemType.Stone150),
waterStone11(WATER, 36967, ElementalItemType.Stone150),
waterStone12(WATER, 33870, ElementalItemType.Stone150),
waterStone13(WATER, 35736, ElementalItemType.Stone150),
waterStone14(WATER, 33482, ElementalItemType.Stone150),
windStone1(WIND, 9549, ElementalItemType.Stone),
windStone2(WIND, 34793, ElementalItemType.Stone),
windStone3(WIND, 22638, ElementalItemType.Stone),
windStone4(WIND, 37502, ElementalItemType.Stone),
windStone5(WIND, 22922, ElementalItemType.Stone),
windStone6(WIND, 34664, ElementalItemType.Stone60),
windStone7(WIND, 36963, ElementalItemType.Stone60),
windStone8(WIND, 33866, ElementalItemType.Stone60),
windStone9(WIND, 35732, ElementalItemType.Stone60),
windStone10(WIND, 34670, ElementalItemType.Stone150),
windStone11(WIND, 36969, ElementalItemType.Stone150),
windStone12(WIND, 33872, ElementalItemType.Stone150),
windStone13(WIND, 35738, ElementalItemType.Stone150),
windStone14(WIND, 33484, ElementalItemType.Stone150),
earthStone1(EARTH, 9548, ElementalItemType.Stone),
earthStone2(EARTH, 34792, ElementalItemType.Stone),
earthStone3(EARTH, 22637, ElementalItemType.Stone),
earthStone4(EARTH, 37501, ElementalItemType.Stone),
earthStone5(EARTH, 22921, ElementalItemType.Stone),
earthStone6(EARTH, 34663, ElementalItemType.Stone60),
earthStone7(EARTH, 36962, ElementalItemType.Stone60),
earthStone8(EARTH, 33865, ElementalItemType.Stone60),
earthStone9(EARTH, 35731, ElementalItemType.Stone60),
earthStone10(EARTH, 34669, ElementalItemType.Stone150),
earthStone11(EARTH, 36968, ElementalItemType.Stone150),
earthStone12(EARTH, 33871, ElementalItemType.Stone150),
earthStone13(EARTH, 35737, ElementalItemType.Stone150),
earthStone14(EARTH, 33483, ElementalItemType.Stone150),
divineStone1(HOLY, 9551, ElementalItemType.Stone),
divineStone2(HOLY, 34795, ElementalItemType.Stone),
divineStone3(HOLY, 22640, ElementalItemType.Stone),
divineStone4(HOLY, 37504, ElementalItemType.Stone),
divineStone5(HOLY, 22924, ElementalItemType.Stone),
divineStone6(HOLY, 34666, ElementalItemType.Stone60),
divineStone7(HOLY, 36965, ElementalItemType.Stone60),
divineStone8(HOLY, 33868, ElementalItemType.Stone60),
divineStone9(HOLY, 35734, ElementalItemType.Stone60),
divineStone10(HOLY, 34672, ElementalItemType.Stone150),
divineStone11(HOLY, 36971, ElementalItemType.Stone150),
divineStone12(HOLY, 33874, ElementalItemType.Stone150),
divineStone13(HOLY, 35740, ElementalItemType.Stone150),
divineStone14(HOLY, 33486, ElementalItemType.Stone150),
darkStone1(DARK, 9550, ElementalItemType.Stone),
darkStone2(DARK, 34794, ElementalItemType.Stone),
darkStone3(DARK, 22639, ElementalItemType.Stone),
darkStone4(DARK, 37503, ElementalItemType.Stone),
darkStone5(DARK, 22923, ElementalItemType.Stone),
darkStone6(DARK, 34665, ElementalItemType.Stone60),
darkStone7(DARK, 36964, ElementalItemType.Stone60),
darkStone8(DARK, 33867, ElementalItemType.Stone60),
darkStone9(DARK, 35733, ElementalItemType.Stone60),
darkStone10(DARK, 34671, ElementalItemType.Stone150),
darkStone11(DARK, 36970, ElementalItemType.Stone150),
darkStone12(DARK, 33873, ElementalItemType.Stone150),
darkStone13(DARK, 35739, ElementalItemType.Stone150),
darkStone14(DARK, 33485, ElementalItemType.Stone150),
fireRoughtore(FIRE, 10521, ElementalItemType.Roughore),
waterRoughtore(WATER, 10522, ElementalItemType.Roughore),
windRoughtore(WIND, 10524, ElementalItemType.Roughore),
earthRoughtore(EARTH, 10523, ElementalItemType.Roughore),
divineRoughtore(HOLY, 10526, ElementalItemType.Roughore),
darkRoughtore(DARK, 10525, ElementalItemType.Roughore),
fireCrystal1(FIRE, 9552, ElementalItemType.Crystal),
fireCrystal2(FIRE, 34796, ElementalItemType.Crystal),
fireCrystal3(FIRE, 22925, ElementalItemType.Crystal),
fireCrystal4(FIRE, 22641, ElementalItemType.Crystal),
fireCrystal5(FIRE, 36972, ElementalItemType.Crystal300),
fireCrystal6(FIRE, 33487, ElementalItemType.Crystal300),
waterCrystal1(WATER, 9553, ElementalItemType.Crystal),
waterCrystal2(WATER, 34797, ElementalItemType.Crystal),
waterCrystal3(WATER, 22926, ElementalItemType.Crystal),
waterCrystal4(WATER, 22642, ElementalItemType.Crystal),
waterCrystal5(WATER, 36973, ElementalItemType.Crystal300),
waterCrystal6(WATER, 33488, ElementalItemType.Crystal300),
windCrystal1(WIND, 9555, ElementalItemType.Crystal),
windCrystal2(WIND, 34799, ElementalItemType.Crystal),
windCrystal3(WIND, 22928, ElementalItemType.Crystal),
windCrystal4(WIND, 22644, ElementalItemType.Crystal),
windCrystal5(WIND, 36975, ElementalItemType.Crystal300),
windCrystal6(WIND, 33490, ElementalItemType.Crystal300),
earthCrystal1(EARTH, 9554, ElementalItemType.Crystal),
earthCrystal2(EARTH, 34798, ElementalItemType.Crystal),
earthCrystal3(EARTH, 22927, ElementalItemType.Crystal),
earthCrystal4(EARTH, 22643, ElementalItemType.Crystal),
earthCrystal5(EARTH, 36974, ElementalItemType.Crystal300),
earthCrystal6(EARTH, 33489, ElementalItemType.Crystal300),
divineCrystal1(HOLY, 9557, ElementalItemType.Crystal),
divineCrystal2(HOLY, 34801, ElementalItemType.Crystal),
divineCrystal3(HOLY, 22930, ElementalItemType.Crystal),
divineCrystal4(HOLY, 22646, ElementalItemType.Crystal),
divineCrystal5(HOLY, 36977, ElementalItemType.Crystal300),
divineCrystal6(HOLY, 33492, ElementalItemType.Crystal300),
darkCrystal1(DARK, 9556, ElementalItemType.Crystal),
darkCrystal2(DARK, 34800, ElementalItemType.Crystal),
darkCrystal3(DARK, 22929, ElementalItemType.Crystal),
darkCrystal4(DARK, 22645, ElementalItemType.Crystal),
darkCrystal5(DARK, 36796, ElementalItemType.Crystal300),
darkCrystal6(DARK, 33491, ElementalItemType.Crystal300),
fireJewel(FIRE, 9558, ElementalItemType.Jewel),
waterJewel(WATER, 9559, ElementalItemType.Jewel),
windJewel(WIND, 9561, ElementalItemType.Jewel),
earthJewel(EARTH, 9560, ElementalItemType.Jewel),
divineJewel(HOLY, 9563, ElementalItemType.Jewel),
darkJewel(DARK, 9562, ElementalItemType.Jewel),
// not yet supported by client (Freya pts)
fireEnergy(FIRE, 9564, ElementalItemType.Energy),
waterEnergy(WATER, 9565, ElementalItemType.Energy),
windEnergy(WIND, 9567, ElementalItemType.Energy),
earthEnergy(EARTH, 9566, ElementalItemType.Energy),
divineEnergy(HOLY, 9569, ElementalItemType.Energy),
darkEnergy(DARK, 9568, ElementalItemType.Energy);
public byte _element;
public int _itemId;
public ElementalItemType _type;
private ElementalItems(byte element, int itemId, ElementalItemType type)
{
_element = element;
_itemId = itemId;
_type = type;
}
}
public static byte getItemElement(int itemId)
{
final ElementalItems item = TABLE.get(itemId);
if (item != null)
{
return item._element;
}
return NONE;
}
public static ElementalItems getItemElemental(int itemId)
{
return TABLE.get(itemId);
}
public static int getMaxElementLevel(int itemId)
{
final ElementalItems item = TABLE.get(itemId);
if (item != null)
{
return item._type._maxLevel;
}
return -1;
}
public static String getElementName(byte element)
{
switch (element)
{
case FIRE:
{
return "Fire";
}
case WATER:
{
return "Water";
}
case WIND:
{
return "Wind";
}
case EARTH:
{
return "Earth";
}
case DARK:
{
return "Dark";
}
case HOLY:
{
return "Holy";
}
}
return "None";
}
public static byte getElementId(String name)
{
final String tmp = name.toLowerCase();
if (tmp.equals("fire"))
{
return FIRE;
}
if (tmp.equals("water"))
{
return WATER;
}
if (tmp.equals("wind"))
{
return WIND;
}
if (tmp.equals("earth"))
{
return EARTH;
}
if (tmp.equals("dark"))
{
return DARK;
}
if (tmp.equals("holy"))
{
return HOLY;
}
return NONE;
}
public static byte getOppositeElement(byte element)
{
return (byte) (((element % 2) == 0) ? (element + 1) : (element - 1));
}
public static class ElementalStatBoni
{
private byte _elementalType;
private int _elementalValue;
private boolean _active;
public ElementalStatBoni(byte type, int value)
{
_elementalType = type;
_elementalValue = value;
_active = false;
}
public void applyBonus(L2PcInstance player, boolean isArmor)
{
// make sure the bonuses are not applied twice..
if (_active)
{
return;
}
switch (_elementalType)
{
case FIRE:
{
player.addStatFunc(new FuncAdd(isArmor ? Stats.FIRE_RES : Stats.FIRE_POWER, 0x40, this, _elementalValue, null));
break;
}
case WATER:
{
player.addStatFunc(new FuncAdd(isArmor ? Stats.WATER_RES : Stats.WATER_POWER, 0x40, this, _elementalValue, null));
break;
}
case WIND:
{
player.addStatFunc(new FuncAdd(isArmor ? Stats.WIND_RES : Stats.WIND_POWER, 0x40, this, _elementalValue, null));
break;
}
case EARTH:
{
player.addStatFunc(new FuncAdd(isArmor ? Stats.EARTH_RES : Stats.EARTH_POWER, 0x40, this, _elementalValue, null));
break;
}
case DARK:
{
player.addStatFunc(new FuncAdd(isArmor ? Stats.DARK_RES : Stats.DARK_POWER, 0x40, this, _elementalValue, null));
break;
}
case HOLY:
{
player.addStatFunc(new FuncAdd(isArmor ? Stats.HOLY_RES : Stats.HOLY_POWER, 0x40, this, _elementalValue, null));
break;
}
}
_active = true;
}
public void removeBonus(L2PcInstance player)
{
// make sure the bonuses are not removed twice
if (!_active)
{
return;
}
player.removeStatsOwner(this);
_active = false;
}
public void setValue(int val)
{
_elementalValue = val;
}
public void setElement(byte type)
{
_elementalType = type;
}
}
// non static:
private ElementalStatBoni _boni = null;
private byte _element = NONE;
private int _value = 0;
public byte getElement()
{
return _element;
}
public void setElement(byte type)
{
_element = type;
_boni.setElement(type);
}
public int getValue()
{
return _value;
}
public void setValue(int val)
{
_value = val;
_boni.setValue(val);
}
@Override
public String toString()
{
return getElementName(_element) + " +" + _value;
}
public Elementals(byte type, int value)
{
_element = type;
_value = value;
_boni = new ElementalStatBoni(_element, _value);
}
public void applyBonus(L2PcInstance player, boolean isArmor)
{
_boni.applyBonus(player, isArmor);
}
public void removeBonus(L2PcInstance player)
{
_boni.removeBonus(player);
}
public void updateBonus(L2PcInstance player, boolean isArmor)
{
_boni.removeBonus(player);
_boni.applyBonus(player, isArmor);
}
}

View File

@@ -0,0 +1,58 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import com.l2jmobius.gameserver.model.interfaces.IIdentifiable;
/**
* Fort Siege Spawn.
* @author xban1x
*/
public final class FortSiegeSpawn extends Location implements IIdentifiable
{
private final int _npcId;
private final int _fortId;
private final int _id;
public FortSiegeSpawn(int fort_id, int x, int y, int z, int heading, int npc_id, int id)
{
super(x, y, z, heading);
_fortId = fort_id;
_npcId = npc_id;
_id = id;
}
public int getFortId()
{
return _fortId;
}
/**
* Gets the NPC ID.
* @return the NPC ID
*/
@Override
public int getId()
{
return _npcId;
}
public int getMessageId()
{
return _id;
}
}

View File

@@ -0,0 +1,83 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import com.l2jmobius.gameserver.enums.AttackType;
/**
* @author UnAfraid
*/
public class Hit
{
private final int _targetId;
private final int _damage;
private final int _ssGrade;
private int _flags = 0;
public Hit(L2Object target, int damage, boolean miss, boolean crit, byte shld, boolean soulshot, int ssGrade)
{
_targetId = target.getObjectId();
_damage = damage;
_ssGrade = ssGrade;
if (miss)
{
addMask(AttackType.MISSED);
return;
}
if (crit)
{
addMask(AttackType.CRITICAL);
}
if (soulshot)
{
addMask(AttackType.SHOT_USED);
}
if (target.isInvul() || (shld > 0))
{
addMask(AttackType.BLOCKED);
}
}
private void addMask(AttackType type)
{
_flags |= type.getMask();
}
public int getTargetId()
{
return _targetId;
}
public int getDamage()
{
return _damage;
}
public int getFlags()
{
return _flags;
}
public int getGrade()
{
return _ssGrade;
}
}

View File

@@ -0,0 +1,410 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import com.l2jmobius.gameserver.model.buylist.Product;
import com.l2jmobius.gameserver.model.items.L2Item;
import com.l2jmobius.gameserver.model.items.L2WarehouseItem;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
/**
* Get all information from L2ItemInstance to generate ItemInfo.
*/
public class ItemInfo
{
/** Identifier of the L2ItemInstance */
private int _objectId;
/** The L2Item template of the L2ItemInstance */
private L2Item _item;
/** The level of enchant on the L2ItemInstance */
private int _enchant;
/** The augmentation of the item */
private int _augmentation;
/** The quantity of L2ItemInstance */
private long _count;
/** The price of the L2ItemInstance */
private int _price;
/** The custom L2ItemInstance types (used loto, race tickets) */
private int _type1;
private int _type2;
/** If True the L2ItemInstance is equipped */
private int _equipped;
/** The action to do clientside (1=ADD, 2=MODIFY, 3=REMOVE) */
private int _change;
/** The mana of this item */
private int _mana;
private int _time;
private int _location;
private int _elemAtkType = -2;
private int _elemAtkPower = 0;
private final int[] _elemDefAttr =
{
0,
0,
0,
0,
0,
0
};
private int[] _option;
private int _visualId;
private long _visualExpiration;
/**
* Get all information from L2ItemInstance to generate ItemInfo.
* @param item
*/
public ItemInfo(L2ItemInstance item)
{
if (item == null)
{
return;
}
// Get the Identifier of the L2ItemInstance
_objectId = item.getObjectId();
// Get the L2Item of the L2ItemInstance
_item = item.getItem();
// Get the enchant level of the L2ItemInstance
_enchant = item.getEnchantLevel();
// Get the augmentation boni
if (item.isAugmented())
{
_augmentation = item.getAugmentation().getAugmentationId();
}
else
{
_augmentation = 0;
}
// Get the quantity of the L2ItemInstance
_count = item.getCount();
// Get custom item types (used loto, race tickets)
_type1 = item.getCustomType1();
_type2 = item.getCustomType2();
// Verify if the L2ItemInstance is equipped
_equipped = item.isEquipped() ? 1 : 0;
// Get the action to do clientside
switch (item.getLastChange())
{
case (L2ItemInstance.ADDED):
{
_change = 1;
break;
}
case (L2ItemInstance.MODIFIED):
{
_change = 2;
break;
}
case (L2ItemInstance.REMOVED):
{
_change = 3;
break;
}
}
// Get shadow item mana
_mana = item.getMana();
_time = item.isTimeLimitedItem() ? (int) (item.getRemainingTime() / 1000) : -9999;
_location = item.getLocationSlot();
_elemAtkType = item.getAttackElementType();
_elemAtkPower = item.getAttackElementPower();
for (byte i = 0; i < 6; i++)
{
_elemDefAttr[i] = item.getElementDefAttr(i);
}
_option = item.getEnchantOptions();
_visualId = item.getVisualId();
}
public ItemInfo(L2ItemInstance item, int change)
{
this(item);
_change = change;
_visualExpiration = item.getVisualLifeTime() > 0 ? (item.getVisualLifeTime() - System.currentTimeMillis()) / 1000 : 0;
}
public ItemInfo(TradeItem item)
{
if (item == null)
{
return;
}
// Get the Identifier of the L2ItemInstance
_objectId = item.getObjectId();
// Get the L2Item of the L2ItemInstance
_item = item.getItem();
// Get the enchant level of the L2ItemInstance
_enchant = item.getEnchant();
// Get the augmentation boni
if (item.isAugmented())
{
_augmentation = item.getAugmentation().getAugmentationId();
}
else
{
_augmentation = 0;
}
// Get the quantity of the L2ItemInstance
_count = item.getCount();
// Get custom item types (used loto, race tickets)
_type1 = item.getCustomType1();
_type2 = item.getCustomType2();
// Verify if the L2ItemInstance is equipped
_equipped = 0;
// Get the action to do clientside
_change = 0;
// Get shadow item mana
_mana = -1;
_time = -9999;
_location = item.getLocationSlot();
_elemAtkType = item.getAttackElementType();
_elemAtkPower = item.getAttackElementPower();
for (byte i = 0; i < 6; i++)
{
_elemDefAttr[i] = item.getElementDefAttr(i);
}
_option = item.getEnchantOptions();
_visualId = item.getVisualId();
}
public ItemInfo(Product item)
{
if (item == null)
{
return;
}
// Get the Identifier of the L2ItemInstance
_objectId = 0;
// Get the L2Item of the L2ItemInstance
_item = item.getItem();
// Get the enchant level of the L2ItemInstance
_enchant = 0;
// Get the augmentation boni
_augmentation = 0;
// Get the quantity of the L2ItemInstance
_count = item.getCount();
// Get custom item types (used loto, race tickets)
_type1 = 0;
_type2 = 0;
// Verify if the L2ItemInstance is equipped
_equipped = 0;
// Get the action to do clientside
_change = 0;
// Get shadow item mana
_mana = -1;
_time = -9999;
_location = 0;
}
public ItemInfo(L2WarehouseItem item)
{
if (item == null)
{
return;
}
// Get the Identifier of the L2ItemInstance
_objectId = item.getObjectId();
// Get the L2Item of the L2ItemInstance
_item = item.getItem();
// Get the enchant level of the L2ItemInstance
_enchant = item.getEnchantLevel();
// Get the augmentation boni
if (item.isAugmented())
{
_augmentation = item.getAugmentationId();
}
else
{
_augmentation = 0;
}
// Get the quantity of the L2ItemInstance
_count = item.getCount();
// Get custom item types (used loto, race tickets)
_type1 = item.getCustomType1();
_type2 = item.getCustomType2();
// Verify if the L2ItemInstance is equipped
_equipped = 0;
// Get shadow item mana
_mana = item.getMana();
_time = item.getTime();
_location = item.getLocationSlot();
_elemAtkType = item.getAttackElementType();
_elemAtkPower = item.getAttackElementPower();
for (byte i = 0; i < 6; i++)
{
_elemDefAttr[i] = item.getElementDefAttr(i);
}
_option = item.getEnchantOptions();
}
public int getObjectId()
{
return _objectId;
}
public L2Item getItem()
{
return _item;
}
public int getEnchant()
{
return _enchant;
}
public int getAugmentationBonus()
{
return _augmentation;
}
public int get1stAugmentationId()
{
return 0x0000FFFF & getAugmentationBonus();
}
public int get2ndAugmentationId()
{
return getAugmentationBonus() >> 16;
}
public long getCount()
{
return _count;
}
public int getPrice()
{
return _price;
}
public int getCustomType1()
{
return _type1;
}
public int getCustomType2()
{
return _type2;
}
public int getEquipped()
{
return _equipped;
}
public int getChange()
{
return _change;
}
public int getMana()
{
return _mana;
}
public int getTime()
{
return _time > 0 ? _time : _visualExpiration > 0 ? (int) _visualExpiration : -9999;
}
public int getLocation()
{
return _location;
}
public int getAttackElementType()
{
return _elemAtkType;
}
public int getAttackElementPower()
{
return _elemAtkPower;
}
public int getElementDefAttr(byte i)
{
return _elemDefAttr[i];
}
public int[] getEnchantOptions()
{
return _option;
}
public int getVisualId()
{
return _visualId;
}
public long getVisualExpiration()
{
return _visualExpiration;
}
}

View File

@@ -0,0 +1,88 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
/**
*
*/
public class ItemRequest
{
int _objectId;
int _itemId;
long _count;
long _price;
public ItemRequest(int objectId, long count, long price)
{
_objectId = objectId;
_count = count;
_price = price;
}
public ItemRequest(int objectId, int itemId, long count, long price)
{
_objectId = objectId;
_itemId = itemId;
_count = count;
_price = price;
}
public int getObjectId()
{
return _objectId;
}
public int getItemId()
{
return _itemId;
}
public void setCount(long count)
{
_count = count;
}
public long getCount()
{
return _count;
}
public long getPrice()
{
return _price;
}
@Override
public int hashCode()
{
return _objectId;
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (!(obj instanceof ItemRequest))
{
return false;
}
return (_objectId != ((ItemRequest) obj)._objectId);
}
}

View File

@@ -0,0 +1,215 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
/**
* @author HorridoJoho
*/
public class L2AccessLevel
{
/** The access level. */
private int _accessLevel = 0;
/** The access level name. */
private String _name = null;
/** Child access levels. */
private L2AccessLevel _childsAccessLevel = null;
/** Child access levels. */
private int _child = 0;
/** The name color for the access level. */
private int _nameColor = 0;
/** The title color for the access level. */
private int _titleColor = 0;
/** Flag to determine if the access level has GM access. */
private boolean _isGm = false;
/** Flag for peace zone attack */
private boolean _allowPeaceAttack = false;
/** Flag for fixed res */
private boolean _allowFixedRes = false;
/** Flag for transactions */
private boolean _allowTransaction = false;
/** Flag for AltG commands */
private boolean _allowAltG = false;
/** Flag to give damage */
private boolean _giveDamage = false;
/** Flag to take aggro */
private boolean _takeAggro = false;
/** Flag to gain exp in party */
private boolean _gainExp = false;
public L2AccessLevel(StatsSet set)
{
_accessLevel = set.getInt("level");
_name = set.getString("name");
_nameColor = Integer.decode("0x" + set.getString("nameColor", "FFFFFF"));
_titleColor = Integer.decode("0x" + set.getString("titleColor", "FFFFFF"));
_child = set.getInt("childAccess", 0);
_isGm = set.getBoolean("isGM", false);
_allowPeaceAttack = set.getBoolean("allowPeaceAttack", false);
_allowFixedRes = set.getBoolean("allowFixedRes", false);
_allowTransaction = set.getBoolean("allowTransaction", true);
_allowAltG = set.getBoolean("allowAltg", false);
_giveDamage = set.getBoolean("giveDamage", true);
_takeAggro = set.getBoolean("takeAggro", true);
_gainExp = set.getBoolean("gainExp", true);
}
public L2AccessLevel()
{
_accessLevel = 0;
_name = "User";
_nameColor = Integer.decode("0xFFFFFF");
_titleColor = Integer.decode("0xFFFFFF");
_child = 0;
_isGm = false;
_allowPeaceAttack = false;
_allowFixedRes = false;
_allowTransaction = true;
_allowAltG = false;
_giveDamage = true;
_takeAggro = true;
_gainExp = true;
}
/**
* Gets the access level.
* @return the access level
*/
public int getLevel()
{
return _accessLevel;
}
/**
* Gets the access level name.
* @return the access level name
*/
public String getName()
{
return _name;
}
/**
* Gets the name color of the access level.
* @return the name color for the access level
*/
public int getNameColor()
{
return _nameColor;
}
/**
* Gets the title color color of the access level.
* @return the title color for the access level
*/
public int getTitleColor()
{
return _titleColor;
}
/**
* Verifies if the access level has GM access or not.
* @return {@code true} if access level have GM access, otherwise {@code false}
*/
public boolean isGm()
{
return _isGm;
}
/**
* Verifies if the access level is allowed to attack in peace zone or not.
* @return {@code true} if the access level is allowed to attack in peace zone, otherwise {@code false}
*/
public boolean allowPeaceAttack()
{
return _allowPeaceAttack;
}
/**
* Verifies if the access level is allowed to use fixed resurrection or not.
* @return {@ode true} if the access level is allowed to use fixed resurrection, otherwise {@code false}
*/
public boolean allowFixedRes()
{
return _allowFixedRes;
}
/**
* Verifies if the access level is allowed to perform transactions or not.
* @return {@ode true} if access level is allowed to perform transactions, otherwise {@code false}
*/
public boolean allowTransaction()
{
return _allowTransaction;
}
/**
* Verifies if the access level is allowed to use AltG commands or not.
* @return {@ode true} if access level is allowed to use AltG commands, otherwise {@code false}
*/
public boolean allowAltG()
{
return _allowAltG;
}
/**
* Verifies if the access level can give damage or not.
* @return {@ode true} if the access level can give damage, otherwise {@code false}
*/
public boolean canGiveDamage()
{
return _giveDamage;
}
/**
* Verifies if the access level can take aggro or not.
* @return {@ode true} if the access level can take aggro, otherwise {@code false}
*/
public boolean canTakeAggro()
{
return _takeAggro;
}
/**
* Verifies if the access level can gain exp or not.
* @return {@ode true} if the access level can gain exp, otherwise {@code false}
*/
public boolean canGainExp()
{
return _gainExp;
}
/**
* Returns if the access level contains allowedAccess as child.
* @param accessLevel the parent access level
* @return {@ode true} if a child access level is equals to allowedAccess, otherwise {@code false}
*/
public boolean hasChildAccess(L2AccessLevel accessLevel)
{
if (_childsAccessLevel == null)
{
if (_child <= 0)
{
return false;
}
_childsAccessLevel = AdminData.getInstance().getAccessLevel(_child);
}
return ((_childsAccessLevel.getLevel() == accessLevel.getLevel()) || _childsAccessLevel.hasChildAccess(accessLevel));
}
}

View File

@@ -0,0 +1,69 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
/**
* @author HorridoJoho
*/
public class L2AdminCommandAccessRight
{
private final String _adminCommand;
private final int _accessLevel;
private final boolean _requireConfirm;
public L2AdminCommandAccessRight(StatsSet set)
{
_adminCommand = set.getString("command");
_requireConfirm = set.getBoolean("confirmDlg", false);
_accessLevel = set.getInt("accessLevel", 7);
}
public L2AdminCommandAccessRight(String command, boolean confirm, int level)
{
_adminCommand = command;
_requireConfirm = confirm;
_accessLevel = level;
}
/**
* @return the admin command the access right belongs to
*/
public String getAdminCommand()
{
return _adminCommand;
}
/**
* @param characterAccessLevel
* @return {@code true} if characterAccessLevel is allowed to use the admin command which belongs to this access right, {@code false} otherwise
*/
public boolean hasAccess(L2AccessLevel characterAccessLevel)
{
final L2AccessLevel accessLevel = AdminData.getInstance().getAccessLevel(_accessLevel);
return ((accessLevel.getLevel() == characterAccessLevel.getLevel()) || characterAccessLevel.hasChildAccess(accessLevel));
}
/**
* @return {@code true} if admin command requires confirmation before execution, {@code false} otherwise.
*/
public boolean getRequireConfirm()
{
return _requireConfirm;
}
}

View File

@@ -0,0 +1,47 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.List;
import com.l2jmobius.gameserver.model.holders.ItemHolder;
/**
* Alchemy transmute skill DTO.
* @author Mobius
*/
public class L2AlchemySkill
{
private final List<ItemHolder> _ingredients;
private final ItemHolder _product;
public L2AlchemySkill(List<ItemHolder> ingredients, ItemHolder product)
{
_ingredients = ingredients;
_product = product;
}
public List<ItemHolder> getIngridientItems()
{
return _ingredients;
}
public ItemHolder getTransmutedItem()
{
return _product;
}
}

View File

@@ -0,0 +1,424 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.holders.ArmorsetSkillHolder;
import com.l2jmobius.gameserver.model.holders.SkillHolder;
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
import com.l2jmobius.gameserver.model.itemcontainer.PcInventory;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
/**
* @author Luno
*/
public final class L2ArmorSet
{
private boolean _isVisual;
private int _minimumPieces;
private final List<Integer> _chests;
private final List<Integer> _legs;
private final List<Integer> _head;
private final List<Integer> _gloves;
private final List<Integer> _feet;
private final List<Integer> _shield;
private final List<ArmorsetSkillHolder> _skills;
private final List<SkillHolder> _shieldSkills;
private final List<ArmorsetSkillHolder> _enchantSkills;
private int _con;
private int _dex;
private int _str;
private int _men;
private int _wit;
private int _int;
private int _luc;
private int _cha;
private static final int[] ARMORSET_SLOTS = new int[]
{
Inventory.PAPERDOLL_CHEST,
Inventory.PAPERDOLL_LEGS,
Inventory.PAPERDOLL_HEAD,
Inventory.PAPERDOLL_GLOVES,
Inventory.PAPERDOLL_FEET
};
public L2ArmorSet()
{
_chests = new ArrayList<>();
_legs = new ArrayList<>();
_head = new ArrayList<>();
_gloves = new ArrayList<>();
_feet = new ArrayList<>();
_shield = new ArrayList<>();
_skills = new ArrayList<>();
_shieldSkills = new ArrayList<>();
_enchantSkills = new ArrayList<>();
}
public boolean isVisual()
{
return _isVisual;
}
public void setIsVisual(boolean val)
{
_isVisual = val;
}
/**
* @return the minimum amount of pieces equipped to form a set.
*/
public int getMinimumPieces()
{
return _minimumPieces;
}
public void setMinimumPieces(int pieces)
{
_minimumPieces = pieces;
}
public void addChest(int id)
{
_chests.add(id);
}
public void addLegs(int id)
{
_legs.add(id);
}
public void addHead(int id)
{
_head.add(id);
}
public void addGloves(int id)
{
_gloves.add(id);
}
public void addFeet(int id)
{
_feet.add(id);
}
public void addShield(int id)
{
_shield.add(id);
}
public void addSkill(ArmorsetSkillHolder holder)
{
_skills.add(holder);
}
public void addShieldSkill(SkillHolder holder)
{
_shieldSkills.add(holder);
}
public void addEnchantSkill(ArmorsetSkillHolder holder)
{
_enchantSkills.add(holder);
}
public void addCon(int val)
{
_con = val;
}
public void addDex(int val)
{
_dex = val;
}
public void addStr(int val)
{
_str = val;
}
public void addMen(int val)
{
_men = val;
}
public void addWit(int val)
{
_wit = val;
}
public void addInt(int val)
{
_int = val;
}
public void addLuc(int val)
{
_luc = val;
}
public void addCha(int val)
{
_cha = val;
}
public int getPiecesCount(L2PcInstance player)
{
final Inventory inv = player.getInventory();
final L2ItemInstance legsItem = inv.getPaperdollItem(Inventory.PAPERDOLL_LEGS);
final L2ItemInstance headItem = inv.getPaperdollItem(Inventory.PAPERDOLL_HEAD);
final L2ItemInstance glovesItem = inv.getPaperdollItem(Inventory.PAPERDOLL_GLOVES);
final L2ItemInstance feetItem = inv.getPaperdollItem(Inventory.PAPERDOLL_FEET);
int legs = 0;
int head = 0;
int gloves = 0;
int feet = 0;
if (legsItem != null)
{
legs = legsItem.getId();
}
if (headItem != null)
{
head = headItem.getId();
}
if (glovesItem != null)
{
gloves = glovesItem.getId();
}
if (feetItem != null)
{
feet = feetItem.getId();
}
return getPiecesCount(legs, head, gloves, feet);
}
public int getPiecesCount(int legs, int head, int gloves, int feet)
{
int pieces = 1;
if (_legs.contains(legs))
{
pieces++;
}
if (_head.contains(head))
{
pieces++;
}
if (_gloves.contains(gloves))
{
pieces++;
}
if (_feet.contains(feet))
{
pieces++;
}
return pieces;
}
public boolean containItem(int slot, int itemId)
{
switch (slot)
{
case Inventory.PAPERDOLL_CHEST:
{
return _chests.contains(itemId);
}
case Inventory.PAPERDOLL_LEGS:
{
return _legs.contains(itemId);
}
case Inventory.PAPERDOLL_HEAD:
{
return _head.contains(itemId);
}
case Inventory.PAPERDOLL_GLOVES:
{
return _gloves.contains(itemId);
}
case Inventory.PAPERDOLL_FEET:
{
return _feet.contains(itemId);
}
default:
{
return false;
}
}
}
public List<Integer> getChests()
{
return _chests;
}
public List<ArmorsetSkillHolder> getSkills()
{
return _skills;
}
public boolean containShield(L2PcInstance player)
{
final Inventory inv = player.getInventory();
final L2ItemInstance shieldItem = inv.getPaperdollItem(Inventory.PAPERDOLL_LHAND);
return ((shieldItem != null) && _shield.contains(Integer.valueOf(shieldItem.getId())));
}
public boolean containShield(int shield_id)
{
if (_shield.isEmpty())
{
return false;
}
return _shield.contains(Integer.valueOf(shield_id));
}
public List<SkillHolder> getShieldSkills()
{
return _shieldSkills;
}
public List<ArmorsetSkillHolder> getEnchantSkills()
{
return _enchantSkills;
}
/**
* @param player
* @return true if all parts of set are enchanted to +6 or more
*/
public int getLowestSetEnchant(L2PcInstance player)
{
// Player don't have full set
if (getPiecesCount(player) < getMinimumPieces())
{
return 0;
}
final PcInventory inv = player.getInventory();
// No Chest - No Bonus
if (inv.getPaperdollItem(Inventory.PAPERDOLL_CHEST) == null)
{
return 0;
}
int enchantLevel = Byte.MAX_VALUE;
for (int armorSlot : ARMORSET_SLOTS)
{
final L2ItemInstance itemPart = inv.getPaperdollItem(armorSlot);
if (itemPart != null)
{
if (enchantLevel > itemPart.getEnchantLevel())
{
enchantLevel = itemPart.getEnchantLevel();
}
}
}
if (enchantLevel == Byte.MAX_VALUE)
{
enchantLevel = 0;
}
return enchantLevel;
}
public int getVisualPiecesCount(L2PcInstance player)
{
final Inventory inv = player.getInventory();
final L2ItemInstance legsItem = inv.getPaperdollItem(Inventory.PAPERDOLL_LEGS);
final L2ItemInstance headItem = inv.getPaperdollItem(Inventory.PAPERDOLL_HEAD);
final L2ItemInstance glovesItem = inv.getPaperdollItem(Inventory.PAPERDOLL_GLOVES);
final L2ItemInstance feetItem = inv.getPaperdollItem(Inventory.PAPERDOLL_FEET);
int legs = 0;
int head = 0;
int gloves = 0;
int feet = 0;
if (legsItem != null)
{
legs = legsItem.getVisualId();
}
if (headItem != null)
{
head = headItem.getVisualId();
}
if (glovesItem != null)
{
gloves = glovesItem.getVisualId();
}
if (feetItem != null)
{
feet = feetItem.getVisualId();
}
return getPiecesCount(legs, head, gloves, feet);
}
public int getCON()
{
return _con;
}
public int getDEX()
{
return _dex;
}
public int getSTR()
{
return _str;
}
public int getMEN()
{
return _men;
}
public int getWIT()
{
return _wit;
}
public int getINT()
{
return _int;
}
public int getLUC()
{
return _luc;
}
public int getCHA()
{
return _cha;
}
}

View File

@@ -0,0 +1,134 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.gameserver.data.xml.impl.OptionData;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.options.Options;
/**
* Used to store an augmentation and its bonuses.
* @author durgus, UnAfraid
*/
public final class L2Augmentation
{
private int _effectsId = 0;
private AugmentationStatBoni _boni = null;
public L2Augmentation(int effects)
{
_effectsId = effects;
_boni = new AugmentationStatBoni(_effectsId);
}
public static class AugmentationStatBoni
{
private static final Logger _log = Logger.getLogger(AugmentationStatBoni.class.getName());
private final List<Options> _options = new ArrayList<>();
private boolean _active;
public AugmentationStatBoni(int augmentationId)
{
_active = false;
final int[] stats = new int[2];
stats[0] = 0x0000FFFF & augmentationId;
stats[1] = (augmentationId >> 16);
for (int stat : stats)
{
final Options op = OptionData.getInstance().getOptions(stat);
if (op != null)
{
_options.add(op);
}
else
{
_log.log(Level.WARNING, getClass().getSimpleName() + ": Couldn't find option: " + stat);
}
}
}
public void applyBonus(L2PcInstance player)
{
// make sure the bonuses are not applied twice..
if (_active)
{
return;
}
for (Options op : _options)
{
op.apply(player);
}
_active = true;
}
public void removeBonus(L2PcInstance player)
{
// make sure the bonuses are not removed twice
if (!_active)
{
return;
}
for (Options op : _options)
{
op.remove(player);
}
_active = false;
}
}
public int getAttributes()
{
return _effectsId;
}
/**
* Get the augmentation "id" used in serverpackets.
* @return augmentationId
*/
public int getAugmentationId()
{
return _effectsId;
}
/**
* Applies the bonuses to the player.
* @param player
*/
public void applyBonus(L2PcInstance player)
{
_boni.applyBonus(player);
}
/**
* Removes the augmentation bonuses from the player.
* @param player
*/
public void removeBonus(L2PcInstance player)
{
_boni.removeBonus(player);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,856 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
import com.l2jmobius.gameserver.instancemanager.SiegeManager;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/**
* This class holds the clan members data.
*/
public class L2ClanMember
{
private static final Logger _log = Logger.getLogger(L2ClanMember.class.getName());
private final L2Clan _clan;
private int _objectId;
private String _name;
private String _title;
private int _powerGrade;
private int _level;
private int _classId;
private boolean _sex;
private int _raceOrdinal;
private L2PcInstance _player;
private int _pledgeType;
private int _apprentice;
private int _sponsor;
/**
* Used to restore a clan member from the database.
* @param clan the clan where the clan member belongs.
* @param clanMember the clan member result set
* @throws SQLException if the columnLabel is not valid or a database error occurs
*/
public L2ClanMember(L2Clan clan, ResultSet clanMember) throws SQLException
{
if (clan == null)
{
throw new IllegalArgumentException("Cannot create a Clan Member with a null clan.");
}
_clan = clan;
_name = clanMember.getString("char_name");
_level = clanMember.getInt("level");
_classId = clanMember.getInt("classid");
_objectId = clanMember.getInt("charId");
_pledgeType = clanMember.getInt("subpledge");
_title = clanMember.getString("title");
_powerGrade = clanMember.getInt("power_grade");
_apprentice = clanMember.getInt("apprentice");
_sponsor = clanMember.getInt("sponsor");
_sex = clanMember.getInt("sex") != 0;
_raceOrdinal = clanMember.getInt("race");
}
/**
* Creates a clan member from a player instance.
* @param clan the clan where the player belongs
* @param player the player from which the clan member will be created
*/
public L2ClanMember(L2Clan clan, L2PcInstance player)
{
if (clan == null)
{
throw new IllegalArgumentException("Cannot create a Clan Member if player has a null clan.");
}
_player = player;
_clan = clan;
_name = player.getName();
_level = player.getLevel();
_classId = player.getClassId().getId();
_objectId = player.getObjectId();
_pledgeType = player.getPledgeType();
_powerGrade = player.getPowerGrade();
_title = player.getTitle();
_sponsor = 0;
_apprentice = 0;
_sex = player.getAppearance().getSex();
_raceOrdinal = player.getRace().ordinal();
}
/**
* Sets the player instance.
* @param player the new player instance
*/
public void setPlayerInstance(L2PcInstance player)
{
if ((player == null) && (_player != null))
{
// this is here to keep the data when the player logs off
_name = _player.getName();
_level = _player.getLevel();
_classId = _player.getClassId().getId();
_objectId = _player.getObjectId();
_powerGrade = _player.getPowerGrade();
_pledgeType = _player.getPledgeType();
_title = _player.getTitle();
_apprentice = _player.getApprentice();
_sponsor = _player.getSponsor();
_sex = _player.getAppearance().getSex();
_raceOrdinal = _player.getRace().ordinal();
}
if (player != null)
{
_clan.addSkillEffects(player);
if ((_clan.getLevel() > 3) && player.isClanLeader())
{
SiegeManager.getInstance().addSiegeSkills(player);
}
if (player.isClanLeader())
{
_clan.setLeader(this);
}
}
_player = player;
}
/**
* Gets the player instance.
* @return the player instance
*/
public L2PcInstance getPlayerInstance()
{
return _player;
}
/**
* Verifies if the clan member is online.
* @return {@code true} if is online
*/
public boolean isOnline()
{
if ((_player == null) || !_player.isOnline())
{
return false;
}
if (_player.isInOfflineMode())
{
return false;
}
return true;
}
/**
* Gets the class id.
* @return the classId
*/
public int getClassId()
{
if (_player != null)
{
return _player.getClassId().getId();
}
return _classId;
}
/**
* Gets the level.
* @return the level
*/
public int getLevel()
{
if (_player != null)
{
return _player.getLevel();
}
return _level;
}
/**
* Gets the name.
* @return the name
*/
public String getName()
{
if (_player != null)
{
return _player.getName();
}
return _name;
}
/**
* Gets the object id.
* @return Returns the objectId.
*/
public int getObjectId()
{
if (_player != null)
{
return _player.getObjectId();
}
return _objectId;
}
/**
* Gets the title.
* @return the title
*/
public String getTitle()
{
if (_player != null)
{
return _player.getTitle();
}
return _title;
}
/**
* Gets the pledge type.
* @return the pledge type
*/
public int getPledgeType()
{
if (_player != null)
{
return _player.getPledgeType();
}
return _pledgeType;
}
/**
* Sets the pledge type.
* @param pledgeType the new pledge type
*/
public void setPledgeType(int pledgeType)
{
_pledgeType = pledgeType;
if (_player != null)
{
_player.setPledgeType(pledgeType);
}
else
{
// db save if char not logged in
updatePledgeType();
}
}
/**
* Update pledge type.
*/
public void updatePledgeType()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE characters SET subpledge=? WHERE charId=?"))
{
ps.setLong(1, _pledgeType);
ps.setInt(2, getObjectId());
ps.execute();
}
catch (Exception e)
{
_log.log(Level.WARNING, "Could not update pledge type: " + e.getMessage(), e);
}
}
/**
* Gets the power grade.
* @return the power grade
*/
public int getPowerGrade()
{
if (_player != null)
{
return _player.getPowerGrade();
}
return _powerGrade;
}
/**
* Sets the power grade.
* @param powerGrade the new power grade
*/
public void setPowerGrade(int powerGrade)
{
_powerGrade = powerGrade;
if (_player != null)
{
_player.setPowerGrade(powerGrade);
}
else
{
// db save if char not logged in
updatePowerGrade();
}
}
/**
* Update the characters table of the database with power grade.
*/
public void updatePowerGrade()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE characters SET power_grade=? WHERE charId=?"))
{
ps.setLong(1, _powerGrade);
ps.setInt(2, getObjectId());
ps.execute();
}
catch (Exception e)
{
_log.log(Level.WARNING, "Could not update power _grade: " + e.getMessage(), e);
}
}
/**
* Sets the apprentice and sponsor.
* @param apprenticeID the apprentice id
* @param sponsorID the sponsor id
*/
public void setApprenticeAndSponsor(int apprenticeID, int sponsorID)
{
_apprentice = apprenticeID;
_sponsor = sponsorID;
}
/**
* Gets the player's race ordinal.
* @return the race ordinal
*/
public int getRaceOrdinal()
{
if (_player != null)
{
return _player.getRace().ordinal();
}
return _raceOrdinal;
}
/**
* Gets the player's sex.
* @return the sex
*/
public boolean getSex()
{
if (_player != null)
{
return _player.getAppearance().getSex();
}
return _sex;
}
/**
* Gets the sponsor.
* @return the sponsor
*/
public int getSponsor()
{
if (_player != null)
{
return _player.getSponsor();
}
return _sponsor;
}
/**
* Gets the apprentice.
* @return the apprentice
*/
public int getApprentice()
{
if (_player != null)
{
return _player.getApprentice();
}
return _apprentice;
}
/**
* Gets the apprentice or sponsor name.
* @return the apprentice or sponsor name
*/
public String getApprenticeOrSponsorName()
{
if (_player != null)
{
_apprentice = _player.getApprentice();
_sponsor = _player.getSponsor();
}
if (_apprentice != 0)
{
final L2ClanMember apprentice = _clan.getClanMember(_apprentice);
if (apprentice != null)
{
return apprentice.getName();
}
return "Error";
}
if (_sponsor != 0)
{
final L2ClanMember sponsor = _clan.getClanMember(_sponsor);
if (sponsor != null)
{
return sponsor.getName();
}
return "Error";
}
return "";
}
/**
* Gets the clan.
* @return the clan
*/
public L2Clan getClan()
{
return _clan;
}
/**
* Calculate pledge class.
* @param player the player
* @return the int
*/
public static int calculatePledgeClass(L2PcInstance player)
{
int pledgeClass = 0;
if (player == null)
{
return pledgeClass;
}
final L2Clan clan = player.getClan();
if (clan != null)
{
switch (clan.getLevel())
{
case 4:
{
if (player.isClanLeader())
{
pledgeClass = 3;
}
break;
}
case 5:
{
if (player.isClanLeader())
{
pledgeClass = 4;
}
else
{
pledgeClass = 2;
}
break;
}
case 6:
{
switch (player.getPledgeType())
{
case -1:
{
pledgeClass = 1;
break;
}
case 100:
case 200:
{
pledgeClass = 2;
break;
}
case 0:
{
if (player.isClanLeader())
{
pledgeClass = 5;
}
else
{
switch (clan.getLeaderSubPledge(player.getObjectId()))
{
case 100:
case 200:
{
pledgeClass = 4;
break;
}
case -1:
default:
{
pledgeClass = 3;
break;
}
}
}
break;
}
}
break;
}
case 7:
{
switch (player.getPledgeType())
{
case -1:
{
pledgeClass = 1;
break;
}
case 100:
case 200:
{
pledgeClass = 3;
break;
}
case 1001:
case 1002:
case 2001:
case 2002:
{
pledgeClass = 2;
break;
}
case 0:
{
if (player.isClanLeader())
{
pledgeClass = 7;
}
else
{
switch (clan.getLeaderSubPledge(player.getObjectId()))
{
case 100:
case 200:
{
pledgeClass = 6;
break;
}
case 1001:
case 1002:
case 2001:
case 2002:
{
pledgeClass = 5;
break;
}
case -1:
default:
{
pledgeClass = 4;
break;
}
}
}
break;
}
}
break;
}
case 8:
{
switch (player.getPledgeType())
{
case -1:
{
pledgeClass = 1;
break;
}
case 100:
case 200:
{
pledgeClass = 4;
break;
}
case 1001:
case 1002:
case 2001:
case 2002:
{
pledgeClass = 3;
break;
}
case 0:
{
if (player.isClanLeader())
{
pledgeClass = 8;
}
else
{
switch (clan.getLeaderSubPledge(player.getObjectId()))
{
case 100:
case 200:
{
pledgeClass = 7;
break;
}
case 1001:
case 1002:
case 2001:
case 2002:
{
pledgeClass = 6;
break;
}
case -1:
default:
{
pledgeClass = 5;
break;
}
}
}
break;
}
}
break;
}
case 9:
{
switch (player.getPledgeType())
{
case -1:
{
pledgeClass = 1;
break;
}
case 100:
case 200:
{
pledgeClass = 5;
break;
}
case 1001:
case 1002:
case 2001:
case 2002:
{
pledgeClass = 4;
break;
}
case 0:
{
if (player.isClanLeader())
{
pledgeClass = 9;
}
else
{
switch (clan.getLeaderSubPledge(player.getObjectId()))
{
case 100:
case 200:
{
pledgeClass = 8;
break;
}
case 1001:
case 1002:
case 2001:
case 2002:
{
pledgeClass = 7;
break;
}
case -1:
default:
{
pledgeClass = 6;
break;
}
}
}
break;
}
}
break;
}
case 10:
{
switch (player.getPledgeType())
{
case -1:
{
pledgeClass = 1;
break;
}
case 100:
case 200:
{
pledgeClass = 6;
break;
}
case 1001:
case 1002:
case 2001:
case 2002:
{
pledgeClass = 5;
break;
}
case 0:
{
if (player.isClanLeader())
{
pledgeClass = 10;
}
else
{
switch (clan.getLeaderSubPledge(player.getObjectId()))
{
case 100:
case 200:
{
pledgeClass = 9;
break;
}
case 1001:
case 1002:
case 2001:
case 2002:
{
pledgeClass = 8;
break;
}
case -1:
default:
{
pledgeClass = 7;
break;
}
}
}
break;
}
}
break;
}
case 11:
{
switch (player.getPledgeType())
{
case -1:
{
pledgeClass = 1;
break;
}
case 100:
case 200:
{
pledgeClass = 7;
break;
}
case 1001:
case 1002:
case 2001:
case 2002:
{
pledgeClass = 6;
break;
}
case 0:
{
if (player.isClanLeader())
{
pledgeClass = 11;
}
else
{
switch (clan.getLeaderSubPledge(player.getObjectId()))
{
case 100:
case 200:
{
pledgeClass = 10;
break;
}
case 1001:
case 1002:
case 2001:
case 2002:
{
pledgeClass = 9;
break;
}
case -1:
default:
{
pledgeClass = 8;
break;
}
}
}
break;
}
}
break;
}
default:
{
pledgeClass = 1;
break;
}
}
}
if (player.isNoble() && (pledgeClass < 5))
{
pledgeClass = 5;
}
if (player.isHero() && (pledgeClass < 8))
{
pledgeClass = 8;
}
return pledgeClass;
}
/**
* Save apprentice and sponsor.
* @param apprentice the apprentice
* @param sponsor the sponsor
*/
public void saveApprenticeAndSponsor(int apprentice, int sponsor)
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE characters SET apprentice=?,sponsor=? WHERE charId=?"))
{
ps.setInt(1, apprentice);
ps.setInt(2, sponsor);
ps.setInt(3, getObjectId());
ps.execute();
}
catch (SQLException e)
{
_log.log(Level.WARNING, "Could not save apprentice/sponsor: " + e.getMessage(), e);
}
}
}

View File

@@ -0,0 +1,264 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Function;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.ExCloseMPCC;
import com.l2jmobius.gameserver.network.serverpackets.ExMPCCPartyInfoUpdate;
import com.l2jmobius.gameserver.network.serverpackets.ExOpenMPCC;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* This class serves as a container for command channels.
* @author chris_00
*/
public class L2CommandChannel extends AbstractPlayerGroup
{
private final List<L2Party> _parties = new CopyOnWriteArrayList<>();
private L2PcInstance _commandLeader;
private int _channelLvl;
/**
* Create a new command channel and add the leader's party to it.
* @param leader the leader of this command channel
*/
public L2CommandChannel(L2PcInstance leader)
{
_commandLeader = leader;
final L2Party party = leader.getParty();
_parties.add(party);
_channelLvl = party.getLevel();
party.setCommandChannel(this);
party.broadcastMessage(SystemMessageId.THE_COMMAND_CHANNEL_HAS_BEEN_FORMED);
party.broadcastPacket(ExOpenMPCC.STATIC_PACKET);
}
/**
* Add a party to this command channel.
* @param party the party to add
*/
public void addParty(L2Party party)
{
if (party == null)
{
return;
}
// Update the CCinfo for existing players
broadcastPacket(new ExMPCCPartyInfoUpdate(party, 1));
_parties.add(party);
if (party.getLevel() > _channelLvl)
{
_channelLvl = party.getLevel();
}
party.setCommandChannel(this);
party.broadcastPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_JOINED_THE_COMMAND_CHANNEL));
party.broadcastPacket(ExOpenMPCC.STATIC_PACKET);
}
/**
* Remove a party from this command channel.
* @param party the party to remove
*/
public void removeParty(L2Party party)
{
if (party == null)
{
return;
}
_parties.remove(party);
_channelLvl = 0;
for (L2Party pty : _parties)
{
if (pty.getLevel() > _channelLvl)
{
_channelLvl = pty.getLevel();
}
}
party.setCommandChannel(null);
party.broadcastPacket(new ExCloseMPCC());
if (_parties.size() < 2)
{
broadcastPacket(SystemMessage.getSystemMessage(SystemMessageId.THE_COMMAND_CHANNEL_HAS_BEEN_DISBANDED));
disbandChannel();
}
else
{
// Update the CCinfo for existing players
broadcastPacket(new ExMPCCPartyInfoUpdate(party, 0));
}
}
/**
* Disband this command channel.
*/
public void disbandChannel()
{
if (_parties != null)
{
for (L2Party party : _parties)
{
if (party != null)
{
removeParty(party);
}
}
_parties.clear();
}
}
/**
* @return the total count of all members of this command channel
*/
@Override
public int getMemberCount()
{
int count = 0;
for (L2Party party : _parties)
{
if (party != null)
{
count += party.getMemberCount();
}
}
return count;
}
/**
* @return a list of all parties in this command channel
*/
public List<L2Party> getPartys()
{
return _parties;
}
/**
* @return a list of all members in this command channel
*/
@Override
public List<L2PcInstance> getMembers()
{
final List<L2PcInstance> members = new LinkedList<>();
for (L2Party party : getPartys())
{
members.addAll(party.getMembers());
}
return members;
}
/**
* @return the level of this command channel (equals the level of the highest-leveled character in this command channel)
*/
@Override
public int getLevel()
{
return _channelLvl;
}
@Override
public void setLeader(L2PcInstance leader)
{
_commandLeader = leader;
if (leader.getLevel() > _channelLvl)
{
_channelLvl = leader.getLevel();
}
}
/**
* @param obj
* @return true if proper condition for RaidWar
*/
public boolean meetRaidWarCondition(L2Object obj)
{
if (!((obj instanceof L2Character) && ((L2Character) obj).isRaid()))
{
return false;
}
return (getMemberCount() >= Config.LOOT_RAIDS_PRIVILEGE_CC_SIZE);
}
/**
* @return the leader of this command channel
*/
@Override
public L2PcInstance getLeader()
{
return _commandLeader;
}
/**
* Check if a given player is in this command channel.
* @param player the player to check
* @return {@code true} if he does, {@code false} otherwise
*/
@Override
public boolean containsPlayer(L2PcInstance player)
{
if ((_parties != null) && !_parties.isEmpty())
{
for (L2Party party : _parties)
{
if (party.containsPlayer(player))
{
return true;
}
}
}
return false;
}
/**
* Iterates over all command channel members without the need to allocate a new list
* @see com.l2jmobius.gameserver.model.AbstractPlayerGroup#forEachMember(Function)
*/
@Override
public boolean forEachMember(Function<L2PcInstance, Boolean> function)
{
if ((_parties != null) && !_parties.isEmpty())
{
for (L2Party party : _parties)
{
if (!party.forEachMember(function))
{
return false;
}
}
}
return true;
}
/**
* Check whether the leader of this command channel is the same as the leader of the specified command channel<br>
* (which essentially means they're the same group).
* @param cc the other command channel to check against
* @return {@code true} if this command channel equals the specified command channel, {@code false} otherwise
*/
public boolean equals(L2CommandChannel cc)
{
return (cc != null) && (getLeaderObjectId() == cc.getLeaderObjectId());
}
}

View File

@@ -0,0 +1,184 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* TODO: System messages:<br>
* ADD: 3223: The previous name is being registered. Please try again later.<br>
* DEL 3219: $s1 was successfully deleted from your Contact List.<br>
* DEL 3217: The name is not currently registered.
* @author UnAfraid, mrTJO
*/
public class L2ContactList
{
private final Logger _log = Logger.getLogger(getClass().getName());
private final L2PcInstance activeChar;
private final List<String> _contacts = new CopyOnWriteArrayList<>();
private static final String QUERY_ADD = "INSERT INTO character_contacts (charId, contactId) VALUES (?, ?)";
private static final String QUERY_REMOVE = "DELETE FROM character_contacts WHERE charId = ? and contactId = ?";
private static final String QUERY_LOAD = "SELECT contactId FROM character_contacts WHERE charId = ?";
public L2ContactList(L2PcInstance player)
{
activeChar = player;
restore();
}
public void restore()
{
_contacts.clear();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(QUERY_LOAD))
{
ps.setInt(1, activeChar.getObjectId());
try (ResultSet rs = ps.executeQuery())
{
int contactId;
String contactName;
while (rs.next())
{
contactId = rs.getInt(1);
contactName = CharNameTable.getInstance().getNameById(contactId);
if ((contactName == null) || contactName.equals(activeChar.getName()) || (contactId == activeChar.getObjectId()))
{
continue;
}
_contacts.add(contactName);
}
}
}
catch (Exception e)
{
_log.log(Level.WARNING, "Error found in " + activeChar.getName() + "'s ContactsList: " + e.getMessage(), e);
}
}
public boolean add(String name)
{
SystemMessage sm;
final int contactId = CharNameTable.getInstance().getIdByName(name);
if (_contacts.contains(name))
{
activeChar.sendPacket(SystemMessageId.THE_NAME_ALREADY_EXISTS_ON_THE_ADDED_LIST);
return false;
}
else if (activeChar.getName().equals(name))
{
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_ADD_YOUR_OWN_NAME);
return false;
}
else if (_contacts.size() >= 100)
{
activeChar.sendPacket(SystemMessageId.THE_MAXIMUM_NUMBER_OF_NAMES_100_HAS_BEEN_REACHED_YOU_CANNOT_REGISTER_ANY_MORE);
return false;
}
else if (contactId < 1)
{
sm = SystemMessage.getSystemMessage(SystemMessageId.THE_NAME_S1_DOESN_T_EXIST_PLEASE_TRY_ANOTHER_NAME);
sm.addString(name);
activeChar.sendPacket(sm);
return false;
}
else
{
for (String contactName : _contacts)
{
if (contactName.equalsIgnoreCase(name))
{
activeChar.sendPacket(SystemMessageId.THE_NAME_ALREADY_EXISTS_ON_THE_ADDED_LIST);
return false;
}
}
}
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(QUERY_ADD))
{
ps.setInt(1, activeChar.getObjectId());
ps.setInt(2, contactId);
ps.execute();
_contacts.add(name);
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_WAS_SUCCESSFULLY_ADDED_TO_YOUR_CONTACT_LIST);
sm.addString(name);
activeChar.sendPacket(sm);
}
catch (Exception e)
{
_log.log(Level.WARNING, "Error found in " + activeChar.getName() + "'s ContactsList: " + e.getMessage(), e);
}
return true;
}
public void remove(String name)
{
final int contactId = CharNameTable.getInstance().getIdByName(name);
if (!_contacts.contains(name))
{
activeChar.sendPacket(SystemMessageId.THE_NAME_IS_NOT_CURRENTLY_REGISTERED);
return;
}
else if (contactId < 1)
{
// TODO: Message?
return;
}
_contacts.remove(name);
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(QUERY_REMOVE))
{
ps.setInt(1, activeChar.getObjectId());
ps.setInt(2, contactId);
ps.execute();
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_WAS_SUCCESSFULLY_DELETED_FROM_YOUR_CONTACT_LIST);
sm.addString(name);
activeChar.sendPacket(sm);
}
catch (Exception e)
{
_log.log(Level.WARNING, "Error found in " + activeChar.getName() + "'s ContactsList: " + e.getMessage(), e);
}
}
public List<String> getAllContacts()
{
return _contacts;
}
}

View File

@@ -0,0 +1,138 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.interfaces.IIdentifiable;
import com.l2jmobius.gameserver.network.serverpackets.AllyCrest;
import com.l2jmobius.gameserver.network.serverpackets.ExPledgeEmblem;
import com.l2jmobius.gameserver.network.serverpackets.PledgeCrest;
/**
* @author NosBit
*/
public final class L2Crest implements IIdentifiable
{
public enum CrestType
{
PLEDGE(1),
PLEDGE_LARGE(2),
ALLY(3);
private final int _id;
private CrestType(int id)
{
_id = id;
}
public int getId()
{
return _id;
}
public static CrestType getById(int id)
{
for (CrestType crestType : values())
{
if (crestType.getId() == id)
{
return crestType;
}
}
return null;
}
}
private final int _id;
private final byte[] _data;
private final CrestType _type;
public L2Crest(int id, byte[] data, CrestType type)
{
_id = id;
_data = data;
_type = type;
}
@Override
public int getId()
{
return _id;
}
public byte[] getData()
{
return _data;
}
public CrestType getType()
{
return _type;
}
/**
* Gets the client path to crest for use in html and sends the crest to {@code L2PcInstance}
* @param activeChar the @{code L2PcInstance} where html is send to.
* @return the client path to crest
*/
public String getClientPath(L2PcInstance activeChar)
{
String path = null;
switch (getType())
{
case PLEDGE:
{
activeChar.sendPacket(new PledgeCrest(getId()));
path = "Crest.crest_" + Config.SERVER_ID + "_" + getId();
break;
}
case PLEDGE_LARGE:
{
final byte[] data = getData();
if (data != null)
{
for (int i = 0; i <= 4; i++)
{
if (i < 4)
{
final byte[] fullChunk = new byte[14336];
System.arraycopy(data, (14336 * i), fullChunk, 0, 14336);
activeChar.sendPacket(new ExPledgeEmblem(getId(), fullChunk, 0, i));
}
else
{
final byte[] lastChunk = new byte[8320];
System.arraycopy(data, (14336 * i), lastChunk, 0, 8320);
activeChar.sendPacket(new ExPledgeEmblem(getId(), lastChunk, 0, i));
}
}
}
path = "Crest.crest_" + Config.SERVER_ID + "_" + getId() + "_l";
break;
}
case ALLY:
{
activeChar.sendPacket(new AllyCrest(getId()));
path = "Crest.crest_" + Config.SERVER_ID + "_" + getId();
break;
}
}
return path;
}
}

View File

@@ -0,0 +1,105 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
public final class L2EnchantSkillGroup
{
private final int _id;
private final List<EnchantSkillHolder> _enchantDetails = new ArrayList<>();
public L2EnchantSkillGroup(int id)
{
_id = id;
}
public void addEnchantDetail(EnchantSkillHolder detail)
{
_enchantDetails.add(detail);
}
public int getId()
{
return _id;
}
public List<EnchantSkillHolder> getEnchantGroupDetails()
{
return _enchantDetails;
}
public static class EnchantSkillHolder
{
private final int _level;
private final int _adenaCost;
private final int _expCost;
private final int _spCost;
private final byte[] _rate;
public EnchantSkillHolder(StatsSet set)
{
_level = set.getInt("level");
_adenaCost = set.getInt("adena", 0);
_expCost = set.getInt("exp", 0);
_spCost = set.getInt("sp", 0);
_rate = new byte[32];
for (int i = 0; i < 32; i++)
{
_rate[i] = set.getByte("chance" + (76 + i), (byte) 0);
}
}
/**
* @return Returns the level.
*/
public int getLevel()
{
return _level;
}
/**
* @return Returns the spCost.
*/
public int getSpCost()
{
return _spCost;
}
public int getExpCost()
{
return _expCost;
}
public int getAdenaCost()
{
return _adenaCost;
}
public byte getRate(L2PcInstance ply)
{
if (ply.getLevel() < 76)
{
return 0;
}
return _rate[ply.getLevel() - 76];
}
}
}

View File

@@ -0,0 +1,128 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.Set;
import java.util.TreeMap;
import com.l2jmobius.gameserver.data.xml.impl.EnchantSkillGroupsData;
import com.l2jmobius.gameserver.model.L2EnchantSkillGroup.EnchantSkillHolder;
public final class L2EnchantSkillLearn
{
private final int _id;
private final int _baseLvl;
private final TreeMap<Integer, Integer> _enchantRoutes = new TreeMap<>();
public L2EnchantSkillLearn(int id, int baseLvl)
{
_id = id;
_baseLvl = baseLvl;
}
public void addNewEnchantRoute(int route, int group)
{
_enchantRoutes.put(route, group);
}
/**
* @return Returns the id.
*/
public int getId()
{
return _id;
}
/**
* @return Returns the minLevel.
*/
public int getBaseLevel()
{
return _baseLvl;
}
public static int getEnchantRoute(int level)
{
return (int) Math.floor(level / 1000);
}
public static int getEnchantIndex(int level)
{
return (level % 1000) - 1;
}
public static int getEnchantType(int level)
{
return ((level - 1) / 1000) - 1;
}
public L2EnchantSkillGroup getFirstRouteGroup()
{
return EnchantSkillGroupsData.getInstance().getEnchantSkillGroupById(_enchantRoutes.firstEntry().getValue());
}
public Set<Integer> getAllRoutes()
{
return _enchantRoutes.keySet();
}
public int getMinSkillLevel(int level)
{
if ((level % 1000) == 1)
{
return _baseLvl;
}
return level - 1;
}
public boolean isMaxEnchant(int level)
{
final int enchantType = getEnchantRoute(level);
if ((enchantType < 1) || !_enchantRoutes.containsKey(enchantType))
{
return false;
}
final int index = getEnchantIndex(level);
if ((index + 1) >= EnchantSkillGroupsData.getInstance().getEnchantSkillGroupById(_enchantRoutes.get(enchantType)).getEnchantGroupDetails().size())
{
return true;
}
return false;
}
public EnchantSkillHolder getEnchantSkillHolder(int level)
{
final int enchantType = getEnchantRoute(level);
if ((enchantType < 1) || !_enchantRoutes.containsKey(enchantType))
{
return null;
}
final int index = getEnchantIndex(level);
final L2EnchantSkillGroup group = EnchantSkillGroupsData.getInstance().getEnchantSkillGroupById(_enchantRoutes.get(enchantType));
if (index < 0)
{
return group.getEnchantGroupDetails().get(0);
}
else if (index >= group.getEnchantGroupDetails().size())
{
return group.getEnchantGroupDetails().get(EnchantSkillGroupsData.getInstance().getEnchantSkillGroupById(_enchantRoutes.get(enchantType)).getEnchantGroupDetails().size() - 1);
}
return group.getEnchantGroupDetails().get(index);
}
}

View File

@@ -0,0 +1,79 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
/**
* @author JIV
*/
public class L2ExtractableProduct
{
private final int _id;
private final int _min;
private final int _max;
private final int _chance;
private final int _minEnchant;
private final int _maxEnchant;
/**
* Create Extractable product
* @param id create item id
* @param min item count max
* @param max item count min
* @param chance chance for creating
* @param minEnchant item min enchant
* @param maxEnchant item max enchant
*/
public L2ExtractableProduct(int id, int min, int max, double chance, int minEnchant, int maxEnchant)
{
_id = id;
_min = min;
_max = max;
_chance = (int) (chance * 1000);
_minEnchant = minEnchant;
_maxEnchant = maxEnchant;
}
public int getId()
{
return _id;
}
public int getMin()
{
return _min;
}
public int getMax()
{
return _max;
}
public int getChance()
{
return _chance;
}
public int getMinEnchant()
{
return _minEnchant;
}
public int getMaxEnchant()
{
return _maxEnchant;
}
}

View File

@@ -0,0 +1,52 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.List;
import com.l2jmobius.gameserver.model.holders.ItemHolder;
/**
* @author Zoey76
*/
public class L2ExtractableProductItem
{
private final List<ItemHolder> _items;
private final double _chance;
public L2ExtractableProductItem(List<ItemHolder> items, double chance)
{
_items = items;
_chance = chance;
}
/**
* @return the the production list.
*/
public List<ItemHolder> getItems()
{
return _items;
}
/**
* @return the chance of the production list.
*/
public double getChance()
{
return _chance;
}
}

View File

@@ -0,0 +1,58 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.List;
/**
* Extractable skill DTO.
* @author Zoey76
*/
public class L2ExtractableSkill
{
private final int _hash;
private final List<L2ExtractableProductItem> _product;
/**
* Instantiates a new extractable skill.
* @param hash the hash
* @param products the products
*/
public L2ExtractableSkill(int hash, List<L2ExtractableProductItem> products)
{
_hash = hash;
_product = products;
}
/**
* Gets the skill hash.
* @return the skill hash
*/
public int getSkillHash()
{
return _hash;
}
/**
* Gets the product items.
* @return the product items
*/
public List<L2ExtractableProductItem> getProductItems()
{
return _product;
}
}

View File

@@ -0,0 +1,106 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.logging.Level;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.data.sql.impl.TerritoryTable;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2ControllableMobInstance;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jmobius.util.Rnd;
/**
* @author littlecrow A special spawn implementation to spawn controllable mob
*/
public class L2GroupSpawn extends L2Spawn
{
private final L2NpcTemplate _template;
public L2GroupSpawn(L2NpcTemplate mobTemplate) throws SecurityException, ClassNotFoundException, NoSuchMethodException
{
super(mobTemplate);
_template = mobTemplate;
setAmount(1);
}
public L2Npc doGroupSpawn()
{
try
{
if (_template.isType("L2Pet") || _template.isType("L2Minion"))
{
return null;
}
int newlocx = 0;
int newlocy = 0;
int newlocz = 0;
if ((getX() == 0) && (getY() == 0))
{
if (getLocationId() == 0)
{
return null;
}
final Location location = TerritoryTable.getInstance().getRandomPoint(getLocationId());
if (location != null)
{
newlocx = location.getX();
newlocy = location.getY();
newlocz = location.getZ();
}
}
else
{
newlocx = getX();
newlocy = getY();
newlocz = getZ();
}
final L2Npc mob = new L2ControllableMobInstance(_template);
mob.setCurrentHpMp(mob.getMaxHp(), mob.getMaxMp());
if (getHeading() == -1)
{
mob.setHeading(Rnd.nextInt(61794));
}
else
{
mob.setHeading(getHeading());
}
mob.setSpawn(this);
mob.spawnMe(newlocx, newlocy, newlocz);
mob.onSpawn();
if (Config.DEBUG)
{
_log.finest("Spawned Mob Id: " + _template.getId() + " ,at: X: " + mob.getX() + " Y: " + mob.getY() + " Z: " + mob.getZ());
}
return mob;
}
catch (Exception e)
{
_log.log(Level.WARNING, "NPC class not found: " + e.getMessage(), e);
return null;
}
}
}

View File

@@ -0,0 +1,48 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import com.l2jmobius.gameserver.data.xml.impl.RecipeData;
public class L2ManufactureItem
{
private final int _recipeId;
private final long _cost;
private final boolean _isDwarven;
public L2ManufactureItem(int recipeId, long cost)
{
_recipeId = recipeId;
_cost = cost;
_isDwarven = RecipeData.getInstance().getRecipeList(_recipeId).isDwarvenRecipe();
}
public int getRecipeId()
{
return _recipeId;
}
public long getCost()
{
return _cost;
}
public boolean isDwarven()
{
return _isDwarven;
}
}

View File

@@ -0,0 +1,220 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.enums.Race;
import com.l2jmobius.util.Rnd;
/**
* @author Nyaran
*/
public class L2MapRegion
{
private final String _name;
private final String _town;
private final int _locId;
private final int _castle;
private final int _bbs;
private List<int[]> _maps = null;
private List<Location> _spawnLocs = null;
private List<Location> _otherSpawnLocs = null;
private List<Location> _chaoticSpawnLocs = null;
private List<Location> _banishSpawnLocs = null;
private final Map<Race, String> _bannedRace = new HashMap<>();
public L2MapRegion(String name, String town, int locId, int castle, int bbs)
{
_name = name;
_town = town;
_locId = locId;
_castle = castle;
_bbs = bbs;
}
public final String getName()
{
return _name;
}
public final String getTown()
{
return _town;
}
public final int getLocId()
{
return _locId;
}
public final int getCastle()
{
return _castle;
}
public final int getBbs()
{
return _bbs;
}
public final void addMap(int x, int y)
{
if (_maps == null)
{
_maps = new ArrayList<>();
}
_maps.add(new int[]
{
x,
y
});
}
public final List<int[]> getMaps()
{
return _maps;
}
public final boolean isZoneInRegion(int x, int y)
{
if (_maps == null)
{
return false;
}
for (int[] map : _maps)
{
if ((map[0] == x) && (map[1] == y))
{
return true;
}
}
return false;
}
// Respawn
public final void addSpawn(int x, int y, int z)
{
if (_spawnLocs == null)
{
_spawnLocs = new ArrayList<>();
}
_spawnLocs.add(new Location(x, y, z));
}
public final void addOtherSpawn(int x, int y, int z)
{
if (_otherSpawnLocs == null)
{
_otherSpawnLocs = new ArrayList<>();
}
_otherSpawnLocs.add(new Location(x, y, z));
}
public final void addChaoticSpawn(int x, int y, int z)
{
if (_chaoticSpawnLocs == null)
{
_chaoticSpawnLocs = new ArrayList<>();
}
_chaoticSpawnLocs.add(new Location(x, y, z));
}
public final void addBanishSpawn(int x, int y, int z)
{
if (_banishSpawnLocs == null)
{
_banishSpawnLocs = new ArrayList<>();
}
_banishSpawnLocs.add(new Location(x, y, z));
}
public final List<Location> getSpawns()
{
return _spawnLocs;
}
public final Location getSpawnLoc()
{
if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED)
{
return _spawnLocs.get(Rnd.get(_spawnLocs.size()));
}
return _spawnLocs.get(0);
}
public final Location getOtherSpawnLoc()
{
if (_otherSpawnLocs != null)
{
if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED)
{
return _otherSpawnLocs.get(Rnd.get(_otherSpawnLocs.size()));
}
return _otherSpawnLocs.get(0);
}
return getSpawnLoc();
}
public final Location getChaoticSpawnLoc()
{
if (_chaoticSpawnLocs != null)
{
if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED)
{
return _chaoticSpawnLocs.get(Rnd.get(_chaoticSpawnLocs.size()));
}
return _chaoticSpawnLocs.get(0);
}
return getSpawnLoc();
}
public final Location getBanishSpawnLoc()
{
if (_banishSpawnLocs != null)
{
if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED)
{
return _banishSpawnLocs.get(Rnd.get(_banishSpawnLocs.size()));
}
return _banishSpawnLocs.get(0);
}
return getSpawnLoc();
}
public final void addBannedRace(String race, String point)
{
_bannedRace.put(Race.valueOf(race), point);
}
public final Map<Race, String> getBannedRace()
{
return _bannedRace;
}
}

View File

@@ -0,0 +1,135 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
/**
* @author UnAfraid
*/
public class L2Mentee
{
private static final Logger _log = Logger.getLogger(L2Mentee.class.getName());
private final int _objectId;
private String _name;
private int _classId;
private int _currentLevel;
public L2Mentee(int objectId)
{
_objectId = objectId;
load();
}
public void load()
{
final L2PcInstance player = getPlayerInstance();
if (player == null) // Only if player is offline
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT char_name, level, base_class FROM characters WHERE charId = ?"))
{
ps.setInt(1, getObjectId());
try (ResultSet rs = ps.executeQuery())
{
if (rs.next())
{
_name = rs.getString("char_name");
_classId = rs.getInt("base_class");
_currentLevel = rs.getInt("level");
}
}
}
catch (Exception e)
{
_log.log(Level.WARNING, e.getMessage(), e);
}
}
else
{
_name = player.getName();
_classId = player.getBaseClassId();
_currentLevel = player.getLevel();
}
}
public int getObjectId()
{
return _objectId;
}
public String getName()
{
return _name;
}
public int getClassId()
{
if (isOnline())
{
if (getPlayerInstance().getClassId().getId() != _classId)
{
_classId = getPlayerInstance().getClassId().getId();
}
}
return _classId;
}
public int getLevel()
{
if (isOnline())
{
if (getPlayerInstance().getLevel() != _currentLevel)
{
_currentLevel = getPlayerInstance().getLevel();
}
}
return _currentLevel;
}
public L2PcInstance getPlayerInstance()
{
return L2World.getInstance().getPlayer(_objectId);
}
public boolean isOnline()
{
return (getPlayerInstance() != null) && (getPlayerInstance().isOnlineInt() > 0);
}
public int isOnlineInt()
{
return isOnline() ? getPlayerInstance().isOnlineInt() : 0;
}
public void sendPacket(L2GameServerPacket packet)
{
if (isOnline())
{
getPlayerInstance().sendPacket(packet);
}
}
}

View File

@@ -0,0 +1,64 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import com.l2jmobius.gameserver.network.NpcStringId;
/**
* @author Rayan RPG, JIV
* @since 927
*/
public class L2NpcWalkerNode extends Location
{
private final String _chatString;
private final NpcStringId _npcString;
private final int _delay;
private final boolean _runToLocation;
public L2NpcWalkerNode(int moveX, int moveY, int moveZ, int delay, boolean runToLocation, NpcStringId npcString, String chatText)
{
super(moveX, moveY, moveZ);
_delay = delay;
_runToLocation = runToLocation;
_npcString = npcString;
_chatString = ((chatText == null) ? "" : chatText);
}
public int getDelay()
{
return _delay;
}
public boolean runToLocation()
{
return _runToLocation;
}
public NpcStringId getNpcString()
{
return _npcString;
}
public String getChatText()
{
if (_npcString != null)
{
throw new IllegalStateException("npcString is defined for walker route!");
}
return _chatString;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,252 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.l2jmobius.gameserver.datatables.SkillData;
import com.l2jmobius.gameserver.model.holders.SkillHolder;
/**
* Class hold information about basic pet stats which are same on each level.
* @author JIV
*/
public class L2PetData
{
private final Map<Integer, L2PetLevelData> _levelStats = new HashMap<>();
private final List<L2PetSkillLearn> _skills = new ArrayList<>();
private final int _npcId;
private final int _itemId;
private int _load = 20000;
private int _hungryLimit = 1;
private int _minlvl = Byte.MAX_VALUE;
private boolean _syncLevel = false;
private final List<Integer> _food = new ArrayList<>();
public L2PetData(int npcId, int itemId)
{
_npcId = npcId;
_itemId = itemId;
}
/**
* @return the npc id representing this pet.
*/
public int getNpcId()
{
return _npcId;
}
/**
* @return the item id that could summon this pet.
*/
public int getItemId()
{
return _itemId;
}
/**
* @param level the pet's level.
* @param data the pet's data.
*/
public void addNewStat(int level, L2PetLevelData data)
{
if (_minlvl > level)
{
_minlvl = level;
}
_levelStats.put(level, data);
}
/**
* @param petLevel the pet's level.
* @return the pet data associated to that pet level.
*/
public L2PetLevelData getPetLevelData(int petLevel)
{
return _levelStats.get(petLevel);
}
/**
* @return the pet's weight load.
*/
public int getLoad()
{
return _load;
}
/**
* @return the pet's hunger limit.
*/
public int getHungryLimit()
{
return _hungryLimit;
}
/**
* @return {@code true} if pet synchronizes it's level with his master's
*/
public boolean isSynchLevel()
{
return _syncLevel;
}
/**
* @return the pet's minimum level.
*/
public int getMinLevel()
{
return _minlvl;
}
/**
* @return the pet's food list.
*/
public List<Integer> getFood()
{
return _food;
}
/**
* @param foodId the pet's food Id to add.
*/
public void addFood(Integer foodId)
{
_food.add(foodId);
}
/**
* @param load the weight load to set.
*/
public void setLoad(int load)
{
_load = load;
}
/**
* @param limit the hunger limit to set.
*/
public void setHungryLimit(int limit)
{
_hungryLimit = limit;
}
/**
* @param val synchronizes level with master or not.
*/
public void setSyncLevel(boolean val)
{
_syncLevel = val;
}
// SKILS
/**
* @param skillId the skill Id to add.
* @param skillLvl the skill level.
* @param petLvl the pet's level when this skill is available.
*/
public void addNewSkill(int skillId, int skillLvl, int petLvl)
{
_skills.add(new L2PetSkillLearn(skillId, skillLvl, petLvl));
}
/**
* TODO: Simplify this.
* @param skillId the skill Id.
* @param petLvl the pet level.
* @return the level of the skill for the given skill Id and pet level.
*/
public int getAvailableLevel(int skillId, int petLvl)
{
int lvl = 0;
for (L2PetSkillLearn temp : _skills)
{
if (temp.getSkillId() != skillId)
{
continue;
}
if (temp.getSkillLvl() == 0)
{
if (petLvl < 70)
{
lvl = (petLvl / 10);
if (lvl <= 0)
{
lvl = 1;
}
}
else
{
lvl = (7 + ((petLvl - 70) / 5));
}
// formula usable for skill that have 10 or more skill levels
final int maxLvl = SkillData.getInstance().getMaxLevel(temp.getSkillId());
if (lvl > maxLvl)
{
lvl = maxLvl;
}
break;
}
else if (temp.getMinLevel() <= petLvl)
{
if (temp.getSkillLvl() > lvl)
{
lvl = temp.getSkillLvl();
}
}
}
return lvl;
}
/**
* @return the list with the pet's skill data.
*/
public List<L2PetSkillLearn> getAvailableSkills()
{
return _skills;
}
public static final class L2PetSkillLearn extends SkillHolder
{
private final int _minLevel;
/**
* @param id the skill Id.
* @param lvl the skill level.
* @param minLvl the minimum level when this skill is available.
*/
public L2PetSkillLearn(int id, int lvl, int minLvl)
{
super(id, lvl);
_minLevel = minLvl;
}
/**
* @return the minimum level for the pet to get the skill.
*/
public int getMinLevel()
{
return _minLevel;
}
}
}

View File

@@ -0,0 +1,230 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import com.l2jmobius.gameserver.model.stats.MoveType;
/**
* Stats definition for each pet level.
* @author JIV, Zoey76
*/
public class L2PetLevelData
{
private final int _ownerExpTaken;
private final int _petFeedBattle;
private final int _petFeedNormal;
private final float _petMAtk;
private final long _petMaxExp;
private final int _petMaxFeed;
private final float _petMaxHP;
private final float _petMaxMP;
private final float _petMDef;
private final float _petPAtk;
private final float _petPDef;
private final float _petRegenHP;
private final float _petRegenMP;
private final short _petSoulShot;
private final short _petSpiritShot;
private final double _walkSpeedOnRide;
private final double _runSpeedOnRide;
private final double _slowSwimSpeedOnRide;
private final double _fastSwimSpeedOnRide;
private final double _slowFlySpeedOnRide;
private final double _fastFlySpeedOnRide;
public L2PetLevelData(StatsSet set)
{
_ownerExpTaken = set.getInt("get_exp_type");
_petMaxExp = set.getLong("exp");
_petMaxHP = set.getFloat("org_hp");
_petMaxMP = set.getFloat("org_mp");
_petPAtk = set.getFloat("org_pattack");
_petPDef = set.getFloat("org_pdefend");
_petMAtk = set.getFloat("org_mattack");
_petMDef = set.getFloat("org_mdefend");
_petMaxFeed = set.getInt("max_meal");
_petFeedBattle = set.getInt("consume_meal_in_battle");
_petFeedNormal = set.getInt("consume_meal_in_normal");
_petRegenHP = set.getFloat("org_hp_regen");
_petRegenMP = set.getFloat("org_mp_regen");
_petSoulShot = set.getShort("soulshot_count");
_petSpiritShot = set.getShort("spiritshot_count");
_walkSpeedOnRide = set.getDouble("walkSpeedOnRide", 0);
_runSpeedOnRide = set.getDouble("runSpeedOnRide", 0);
_slowSwimSpeedOnRide = set.getDouble("slowSwimSpeedOnRide", 0);
_fastSwimSpeedOnRide = set.getDouble("fastSwimSpeedOnRide", 0);
_slowFlySpeedOnRide = set.getDouble("slowFlySpeedOnRide", 0);
_fastFlySpeedOnRide = set.getDouble("fastFlySpeedOnRide", 0);
}
/**
* @return the owner's experience points consumed by the pet.
*/
public int getOwnerExpTaken()
{
return _ownerExpTaken;
}
/**
* @return the pet's food consume rate at battle state.
*/
public int getPetFeedBattle()
{
return _petFeedBattle;
}
/**
* @return the pet's food consume rate at normal state.
*/
public int getPetFeedNormal()
{
return _petFeedNormal;
}
/**
* @return the pet's Magical Attack.
*/
public float getPetMAtk()
{
return _petMAtk;
}
/**
* @return the pet's maximum experience points.
*/
public long getPetMaxExp()
{
return _petMaxExp;
}
/**
* @return the pet's maximum feed points.
*/
public int getPetMaxFeed()
{
return _petMaxFeed;
}
/**
* @return the pet's maximum HP.
*/
public float getPetMaxHP()
{
return _petMaxHP;
}
/**
* @return the pet's maximum MP.
*/
public float getPetMaxMP()
{
return _petMaxMP;
}
/**
* @return the pet's Magical Defense.
*/
public float getPetMDef()
{
return _petMDef;
}
/**
* @return the pet's Physical Attack.
*/
public float getPetPAtk()
{
return _petPAtk;
}
/**
* @return the pet's Physical Defense.
*/
public float getPetPDef()
{
return _petPDef;
}
/**
* @return the pet's HP regeneration rate.
*/
public float getPetRegenHP()
{
return _petRegenHP;
}
/**
* @return the pet's MP regeneration rate.
*/
public float getPetRegenMP()
{
return _petRegenMP;
}
/**
* @return the pet's soulshot use count.
*/
public short getPetSoulShot()
{
return _petSoulShot;
}
/**
* @return the pet's spiritshot use count.
*/
public short getPetSpiritShot()
{
return _petSpiritShot;
}
/**
* @param mt movement type
* @return the base riding speed of given movement type.
*/
public double getSpeedOnRide(MoveType mt)
{
switch (mt)
{
case WALK:
{
return _walkSpeedOnRide;
}
case RUN:
{
return _runSpeedOnRide;
}
case SLOW_SWIM:
{
return _slowSwimSpeedOnRide;
}
case FAST_SWIM:
{
return _fastSwimSpeedOnRide;
}
case SLOW_FLY:
{
return _slowFlySpeedOnRide;
}
case FAST_FLY:
{
return _fastFlySpeedOnRide;
}
}
return 0;
}
}

View File

@@ -0,0 +1,54 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
/**
** @author Gnacik
*/
public class L2PremiumItem
{
private final int _itemId;
private long _count;
private final String _sender;
public L2PremiumItem(int itemid, long count, String sender)
{
_itemId = itemid;
_count = count;
_sender = sender;
}
public void updateCount(long newcount)
{
_count = newcount;
}
public int getItemId()
{
return _itemId;
}
public long getCount()
{
return _count;
}
public String getSender()
{
return _sender;
}
}

View File

@@ -0,0 +1,128 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.RadarControl;
/**
* @author dalrond
*/
public final class L2Radar
{
private final L2PcInstance _player;
private final List<RadarMarker> _markers = new CopyOnWriteArrayList<>();
public L2Radar(L2PcInstance player)
{
_player = player;
}
// Add a marker to player's radar
public void addMarker(int x, int y, int z)
{
final RadarMarker newMarker = new RadarMarker(x, y, z);
_markers.add(newMarker);
_player.sendPacket(new RadarControl(2, 2, x, y, z));
_player.sendPacket(new RadarControl(0, 1, x, y, z));
}
// Remove a marker from player's radar
public void removeMarker(int x, int y, int z)
{
final RadarMarker newMarker = new RadarMarker(x, y, z);
_markers.remove(newMarker);
_player.sendPacket(new RadarControl(1, 1, x, y, z));
}
public void removeAllMarkers()
{
for (RadarMarker tempMarker : _markers)
{
_player.sendPacket(new RadarControl(2, 2, tempMarker._x, tempMarker._y, tempMarker._z));
}
_markers.clear();
}
public void loadMarkers()
{
_player.sendPacket(new RadarControl(2, 2, _player.getX(), _player.getY(), _player.getZ()));
for (RadarMarker tempMarker : _markers)
{
_player.sendPacket(new RadarControl(0, 1, tempMarker._x, tempMarker._y, tempMarker._z));
}
}
public static class RadarMarker
{
// Simple class to model radar points.
public int _type, _x, _y, _z;
public RadarMarker(int type, int x, int y, int z)
{
_type = type;
_x = x;
_y = y;
_z = z;
}
public RadarMarker(int x, int y, int z)
{
_type = 1;
_x = x;
_y = y;
_z = z;
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = (prime * result) + _type;
result = (prime * result) + _x;
result = (prime * result) + _y;
result = (prime * result) + _z;
return result;
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (!(obj instanceof RadarMarker))
{
return false;
}
final RadarMarker other = (RadarMarker) obj;
if ((_type != other._type) || (_x != other._x) || (_y != other._y) || (_z != other._z))
{
return false;
}
return true;
}
}
}

View File

@@ -0,0 +1,57 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
/**
* This class describes a RecipeList component (1 line of the recipe : Item-Quantity needed).
*/
public class L2RecipeInstance
{
/** The Identifier of the item needed in the L2RecipeInstance */
private final int _itemId;
/** The item quantity needed in the L2RecipeInstance */
private final int _quantity;
/**
* Constructor of L2RecipeInstance (create a new line in a RecipeList).
* @param itemId
* @param quantity
*/
public L2RecipeInstance(int itemId, int quantity)
{
_itemId = itemId;
_quantity = quantity;
}
/**
* @return the Identifier of the L2RecipeInstance Item needed.
*/
public int getItemId()
{
return _itemId;
}
/**
* @return the Item quantity needed of the L2RecipeInstance.
*/
public int getQuantity()
{
return _quantity;
}
}

View File

@@ -0,0 +1,242 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
/**
* This class describes a Recipe used by Dwarf to craft Item. All L2RecipeList are made of L2RecipeInstance (1 line of the recipe : Item-Quantity needed).
*/
public class L2RecipeList
{
/** The table containing all L2RecipeInstance (1 line of the recipe : Item-Quantity needed) of the L2RecipeList */
private L2RecipeInstance[] _recipes;
/** The table containing all L2RecipeStatInstance for the statUse parameter of the L2RecipeList */
private L2RecipeStatInstance[] _statUse;
/** The table containing all L2RecipeStatInstance for the altStatChange parameter of the L2RecipeList */
private L2RecipeStatInstance[] _altStatChange;
/** The Identifier of the Instance */
private final int _id;
/** The crafting level needed to use this L2RecipeList */
private final int _level;
/** The Identifier of the L2RecipeList */
private final int _recipeId;
/** The name of the L2RecipeList */
private final String _recipeName;
/** The crafting success rate when using the L2RecipeList */
private final int _successRate;
/** The Identifier of the Item crafted with this L2RecipeList */
private final int _itemId;
/** The quantity of Item crafted when using this L2RecipeList */
private final int _count;
/** The Identifier of the Rare Item crafted with this L2RecipeList */
private int _rareItemId;
/** The quantity of Rare Item crafted when using this L2RecipeList */
private int _rareCount;
/** The chance of Rare Item crafted when using this L2RecipeList */
private int _rarity;
/** If this a common or a dwarven recipe */
private final boolean _isDwarvenRecipe;
/**
* Constructor of L2RecipeList (create a new Recipe).
* @param set
* @param haveRare
*/
public L2RecipeList(StatsSet set, boolean haveRare)
{
_recipes = new L2RecipeInstance[0];
_statUse = new L2RecipeStatInstance[0];
_altStatChange = new L2RecipeStatInstance[0];
_id = set.getInt("id");
_level = set.getInt("craftLevel");
_recipeId = set.getInt("recipeId");
_recipeName = set.getString("recipeName");
_successRate = set.getInt("successRate");
_itemId = set.getInt("itemId");
_count = set.getInt("count");
if (haveRare)
{
_rareItemId = set.getInt("rareItemId");
_rareCount = set.getInt("rareCount");
_rarity = set.getInt("rarity");
}
_isDwarvenRecipe = set.getBoolean("isDwarvenRecipe");
}
/**
* Add a L2RecipeInstance to the L2RecipeList (add a line Item-Quantity needed to the Recipe).
* @param recipe
*/
public void addRecipe(L2RecipeInstance recipe)
{
final int len = _recipes.length;
final L2RecipeInstance[] tmp = new L2RecipeInstance[len + 1];
System.arraycopy(_recipes, 0, tmp, 0, len);
tmp[len] = recipe;
_recipes = tmp;
}
/**
* Add a L2RecipeStatInstance of the statUse parameter to the L2RecipeList.
* @param statUse
*/
public void addStatUse(L2RecipeStatInstance statUse)
{
final int len = _statUse.length;
final L2RecipeStatInstance[] tmp = new L2RecipeStatInstance[len + 1];
System.arraycopy(_statUse, 0, tmp, 0, len);
tmp[len] = statUse;
_statUse = tmp;
}
/**
* Add a L2RecipeStatInstance of the altStatChange parameter to the L2RecipeList.
* @param statChange
*/
public void addAltStatChange(L2RecipeStatInstance statChange)
{
final int len = _altStatChange.length;
final L2RecipeStatInstance[] tmp = new L2RecipeStatInstance[len + 1];
System.arraycopy(_altStatChange, 0, tmp, 0, len);
tmp[len] = statChange;
_altStatChange = tmp;
}
/**
* @return the Identifier of the Instance.
*/
public int getId()
{
return _id;
}
/**
* @return the crafting level needed to use this L2RecipeList.
*/
public int getLevel()
{
return _level;
}
/**
* @return the Identifier of the L2RecipeList.
*/
public int getRecipeId()
{
return _recipeId;
}
/**
* @return the name of the L2RecipeList.
*/
public String getRecipeName()
{
return _recipeName;
}
/**
* @return the crafting success rate when using the L2RecipeList.
*/
public int getSuccessRate()
{
return _successRate;
}
/**
* @return the Identifier of the Item crafted with this L2RecipeList.
*/
public int getItemId()
{
return _itemId;
}
/**
* @return the quantity of Item crafted when using this L2RecipeList.
*/
public int getCount()
{
return _count;
}
/**
* @return the Identifier of the Rare Item crafted with this L2RecipeList.
*/
public int getRareItemId()
{
return _rareItemId;
}
/**
* @return the quantity of Rare Item crafted when using this L2RecipeList.
*/
public int getRareCount()
{
return _rareCount;
}
/**
* @return the chance of Rare Item crafted when using this L2RecipeList.
*/
public int getRarity()
{
return _rarity;
}
/**
* @return {@code true} if this a Dwarven recipe or {@code false} if its a Common recipe
*/
public boolean isDwarvenRecipe()
{
return _isDwarvenRecipe;
}
/**
* @return the table containing all L2RecipeInstance (1 line of the recipe : Item-Quantity needed) of the L2RecipeList.
*/
public L2RecipeInstance[] getRecipes()
{
return _recipes;
}
/**
* @return the table containing all L2RecipeStatInstance of the statUse parameter of the L2RecipeList.
*/
public L2RecipeStatInstance[] getStatUse()
{
return _statUse;
}
/**
* @return the table containing all L2RecipeStatInstance of the AltStatChange parameter of the L2RecipeList.
*/
public L2RecipeStatInstance[] getAltStatChange()
{
return _altStatChange;
}
}

View File

@@ -0,0 +1,59 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import com.l2jmobius.gameserver.enums.StatType;
/**
* This class describes a RecipeList statUse and altStatChange component.
*/
public class L2RecipeStatInstance
{
/** The Identifier of the statType */
private final StatType _type;
/** The value of the statType */
private final int _value;
/**
* Constructor of L2RecipeStatInstance.
* @param type
* @param value
*/
public L2RecipeStatInstance(String type, int value)
{
_type = Enum.valueOf(StatType.class, type);
_value = value;
}
/**
* @return the the type of the L2RecipeStatInstance.
*/
public StatType getType()
{
return _type;
}
/**
* @return the value of the L2RecipeStatInstance.
*/
public int getValue()
{
return _value;
}
}

View File

@@ -0,0 +1,148 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.clientpackets.L2GameClientPacket;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* This class manages requests (transactions) between two L2PcInstance.
* @author kriau
*/
public class L2Request
{
private static final int REQUEST_TIMEOUT = 15; // in secs
protected L2PcInstance _player;
protected L2PcInstance _partner;
protected boolean _isRequestor;
protected boolean _isAnswerer;
protected L2GameClientPacket _requestPacket;
public L2Request(L2PcInstance player)
{
_player = player;
}
protected void clear()
{
_partner = null;
_requestPacket = null;
_isRequestor = false;
_isAnswerer = false;
}
/**
* Set the L2PcInstance member of a transaction (ex : FriendInvite, JoinAlly, JoinParty...).
* @param partner
*/
private synchronized void setPartner(L2PcInstance partner)
{
_partner = partner;
}
/**
* @return the L2PcInstance member of a transaction (ex : FriendInvite, JoinAlly, JoinParty...).
*/
public L2PcInstance getPartner()
{
return _partner;
}
/**
* Set the packet incomed from requester.
* @param packet
*/
private synchronized void setRequestPacket(L2GameClientPacket packet)
{
_requestPacket = packet;
}
/**
* Return the packet originally incomed from requester.
* @return
*/
public L2GameClientPacket getRequestPacket()
{
return _requestPacket;
}
/**
* Checks if request can be made and in success case puts both PC on request state.
* @param partner
* @param packet
* @return
*/
public synchronized boolean setRequest(L2PcInstance partner, L2GameClientPacket packet)
{
if (partner == null)
{
_player.sendPacket(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET);
return false;
}
if (partner.getRequest().isProcessingRequest())
{
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ON_ANOTHER_TASK_PLEASE_TRY_AGAIN_LATER);
sm.addString(partner.getName());
_player.sendPacket(sm);
return false;
}
if (isProcessingRequest())
{
_player.sendPacket(SystemMessageId.WAITING_FOR_ANOTHER_REPLY);
return false;
}
_partner = partner;
_requestPacket = packet;
setOnRequestTimer(true);
_partner.getRequest().setPartner(_player);
_partner.getRequest().setRequestPacket(packet);
_partner.getRequest().setOnRequestTimer(false);
return true;
}
private void setOnRequestTimer(boolean isRequestor)
{
_isRequestor = isRequestor ? true : false;
_isAnswerer = isRequestor ? false : true;
ThreadPoolManager.getInstance().scheduleGeneral(() -> clear(), REQUEST_TIMEOUT * 1000);
}
/**
* Clears PC request state. Should be called after answer packet receive.
*/
public void onRequestResponse()
{
if (_partner != null)
{
_partner.getRequest().clear();
}
clear();
}
/**
* @return {@code true} if a transaction is in progress.
*/
public boolean isProcessingRequest()
{
return _partner != null;
}
}

View File

@@ -0,0 +1,137 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.model.items.L2Item;
public final class L2Seed
{
private final int _seedId;
private final int _cropId; // crop type
private final int _level; // seed level
private final int _matureId; // mature crop type
private final int _reward1;
private final int _reward2;
private final int _castleId; // id of manor (castle id) where seed can be farmed
private final boolean _isAlternative;
private final int _limitSeeds;
private final int _limitCrops;
private final int _seedReferencePrice;
private final int _cropReferencePrice;
public L2Seed(StatsSet set)
{
_cropId = set.getInt("id");
_seedId = set.getInt("seedId");
_level = set.getInt("level");
_matureId = set.getInt("mature_Id");
_reward1 = set.getInt("reward1");
_reward2 = set.getInt("reward2");
_castleId = set.getInt("castleId");
_isAlternative = set.getBoolean("alternative");
_limitCrops = set.getInt("limit_crops");
_limitSeeds = set.getInt("limit_seed");
// Set prices
L2Item item = ItemTable.getInstance().getTemplate(_cropId);
_cropReferencePrice = (item != null) ? item.getReferencePrice() : 1;
item = ItemTable.getInstance().getTemplate(_seedId);
_seedReferencePrice = (item != null) ? item.getReferencePrice() : 1;
}
public final int getCastleId()
{
return _castleId;
}
public final int getSeedId()
{
return _seedId;
}
public final int getCropId()
{
return _cropId;
}
public final int getMatureId()
{
return _matureId;
}
public final int getReward(int type)
{
return (type == 1) ? _reward1 : _reward2;
}
public final int getLevel()
{
return _level;
}
public final boolean isAlternative()
{
return _isAlternative;
}
public final int getSeedLimit()
{
return _limitSeeds * Config.RATE_DROP_MANOR;
}
public final int getCropLimit()
{
return _limitCrops * Config.RATE_DROP_MANOR;
}
public final int getSeedReferencePrice()
{
return _seedReferencePrice;
}
public final int getSeedMaxPrice()
{
return _seedReferencePrice * 10;
}
public final int getSeedMinPrice()
{
return (int) (_seedReferencePrice * 0.6);
}
public final int getCropReferencePrice()
{
return _cropReferencePrice;
}
public final int getCropMaxPrice()
{
return _cropReferencePrice * 10;
}
public final int getCropMinPrice()
{
return (int) (_cropReferencePrice * 0.6);
}
@Override
public final String toString()
{
return "SeedData [_id=" + _seedId + ", _level=" + _level + ", _crop=" + _cropId + ", _mature=" + _matureId + ", _type1=" + _reward1 + ", _type2=" + _reward2 + ", _manorId=" + _castleId + ", _isAlternative=" + _isAlternative + ", _limitSeeds=" + _limitSeeds + ", _limitCrops=" + _limitCrops + "]";
}
}

View File

@@ -0,0 +1,79 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import com.l2jmobius.gameserver.enums.SiegeClanType;
import com.l2jmobius.gameserver.model.actor.L2Npc;
public class L2SiegeClan
{
private int _clanId = 0;
private final List<L2Npc> _flag = new CopyOnWriteArrayList<>();
private SiegeClanType _type;
public L2SiegeClan(int clanId, SiegeClanType type)
{
_clanId = clanId;
_type = type;
}
public int getNumFlags()
{
return _flag.size();
}
public void addFlag(L2Npc flag)
{
_flag.add(flag);
}
public boolean removeFlag(L2Npc flag)
{
final boolean ret = _flag.remove(flag);
flag.deleteMe();
return ret;
}
public void removeFlags()
{
_flag.forEach(f -> f.decayMe());
_flag.clear();
}
public final int getClanId()
{
return _clanId;
}
public final List<L2Npc> getFlag()
{
return _flag;
}
public SiegeClanType getType()
{
return _type;
}
public void setType(SiegeClanType setType)
{
_type = setType;
}
}

View File

@@ -0,0 +1,280 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.enums.Race;
import com.l2jmobius.gameserver.model.base.ClassId;
import com.l2jmobius.gameserver.model.base.SocialClass;
import com.l2jmobius.gameserver.model.holders.ItemHolder;
import com.l2jmobius.gameserver.model.holders.SkillHolder;
/**
* @author Zoey76
*/
public final class L2SkillLearn
{
private final String _skillName;
private final int _skillId;
private final int _skillLvl;
private final int _getLevel;
private final int _getDualClassLevel;
private final boolean _autoGet;
private final int _levelUpSp;
private final List<ItemHolder> _requiredItems = new ArrayList<>();
private final List<Race> _races = new ArrayList<>();
private final List<SkillHolder> _preReqSkills = new ArrayList<>();
private SocialClass _socialClass;
private final boolean _residenceSkill;
private final List<Integer> _residenceIds = new ArrayList<>();
private final boolean _learnedByNpc;
private final boolean _learnedByFS;
private final Set<Integer> _removeSkills = new HashSet<>(1);
/**
* Constructor for L2SkillLearn.
* @param set the set with the L2SkillLearn data.
*/
public L2SkillLearn(StatsSet set)
{
_skillName = set.getString("skillName");
_skillId = set.getInt("skillId");
_skillLvl = set.getInt("skillLvl");
_getLevel = set.getInt("getLevel");
_getDualClassLevel = set.getInt("getDualClassLevel", 0);
_autoGet = set.getBoolean("autoGet", false);
_levelUpSp = set.getInt("levelUpSp", 0);
_residenceSkill = set.getBoolean("residenceSkill", false);
_learnedByNpc = set.getBoolean("learnedByNpc", false);
_learnedByFS = set.getBoolean("learnedByFS", false);
}
/**
* @return the name of this skill.
*/
public String getName()
{
return _skillName;
}
/**
* @return the ID of this skill.
*/
public int getSkillId()
{
return _skillId;
}
/**
* @return the level of this skill.
*/
public int getSkillLevel()
{
return _skillLvl;
}
/**
* @return the minimum level required to acquire this skill.
*/
public int getGetLevel()
{
return _getLevel;
}
/**
* @return the minimum dual class level required to acquire this skill.
*/
public int getDualClassLevel()
{
return _getDualClassLevel;
}
/**
* @return the amount of SP/Clan Reputation to acquire this skill.
*/
public int getLevelUpSp()
{
return _levelUpSp;
}
/**
* @return {@code true} if the skill is auto-get, this skill is automatically delivered.
*/
public boolean isAutoGet()
{
return _autoGet;
}
/**
* @return the list with the item holders required to acquire this skill.
*/
public List<ItemHolder> getRequiredItems()
{
return _requiredItems;
}
/**
* Adds a required item holder to learn this skill.
* @param item the required item holder.
*/
public void addRequiredItem(ItemHolder item)
{
_requiredItems.add(item);
}
/**
* @return a list with the races that can acquire this skill.
*/
public List<Race> getRaces()
{
return _races;
}
/**
* Adds a required race to learn this skill.
* @param race the required race.
*/
public void addRace(Race race)
{
_races.add(race);
}
/**
* @return the list of skill holders required to acquire this skill.
*/
public List<SkillHolder> getPreReqSkills()
{
return _preReqSkills;
}
/**
* Adds a required skill holder to learn this skill.
* @param skill the required skill holder.
*/
public void addPreReqSkill(SkillHolder skill)
{
_preReqSkills.add(skill);
}
/**
* @return the social class required to get this skill.
*/
public SocialClass getSocialClass()
{
return _socialClass;
}
/**
* Sets the social class if hasn't been set before.
* @param socialClass the social class to set.
*/
public void setSocialClass(SocialClass socialClass)
{
if (_socialClass == null)
{
_socialClass = socialClass;
}
}
/**
* @return {@code true} if this skill is a Residence skill.
*/
public boolean isResidencialSkill()
{
return _residenceSkill;
}
/**
* @return a list with the Ids where this skill is available.
*/
public List<Integer> getResidenceIds()
{
return _residenceIds;
}
/**
* Adds a required residence Id.
* @param id the residence Id to add.
*/
public void addResidenceId(Integer id)
{
_residenceIds.add(id);
}
/**
* @return {@code true} if this skill is learned from Npc.
*/
public boolean isLearnedByNpc()
{
return _learnedByNpc;
}
/**
* @return {@code true} if this skill is learned by Forgotten Scroll.
*/
public boolean isLearnedByFS()
{
return _learnedByFS;
}
public void addRemoveSkills(int skillId)
{
_removeSkills.add(skillId);
}
public Set<Integer> getRemoveSkills()
{
return _removeSkills;
}
/**
* Used for AltGameSkillLearn mod.<br>
* If the alternative skill learn system is enabled and the player is learning a skill from a different class apply a fee.<br>
* If the player is learning a skill from other class type (mage learning warrior skills or vice versa) the fee is higher.
* @param playerClass the player class Id.
* @param learningClass the skill learning player class Id.
* @return the amount of SP required to acquire this skill, by calculating the cost for the alternative skill learn system.
*/
public int getCalculatedLevelUpSp(ClassId playerClass, ClassId learningClass)
{
if ((playerClass == null) || (learningClass == null))
{
return _levelUpSp;
}
int levelUpSp = _levelUpSp;
// If the alternative skill learn system is enabled and the player is learning a skill from a different class apply a fee.
if (Config.ALT_GAME_SKILL_LEARN && (playerClass != learningClass))
{
// If the player is learning a skill from other class type (mage learning warrior skills or vice versa) the fee is higher.
if (playerClass.isMage() != learningClass.isMage())
{
levelUpSp *= 3;
}
else
{
levelUpSp *= 2;
}
}
return levelUpSp;
}
}

View File

@@ -0,0 +1,869 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.lang.reflect.Constructor;
import java.util.Deque;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.GeoData;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.data.sql.impl.TerritoryTable;
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.datatables.NpcPersonalAIData;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jmobius.gameserver.model.interfaces.IIdentifiable;
import com.l2jmobius.gameserver.model.interfaces.ILocational;
import com.l2jmobius.gameserver.model.interfaces.INamable;
import com.l2jmobius.gameserver.model.interfaces.IPositionable;
import com.l2jmobius.gameserver.model.zone.ZoneId;
import com.l2jmobius.gameserver.model.zone.type.NpcSpawnTerritory;
import com.l2jmobius.util.Rnd;
/**
* This class manages the spawn and respawn of a group of L2NpcInstance that are in the same are and have the same type.<br>
* <B><U>Concept</U>:</B><br>
* L2NpcInstance can be spawned either in a random position into a location area (if Lox=0 and Locy=0), either at an exact position.<br>
* The heading of the L2NpcInstance can be a random heading if not defined (value= -1) or an exact heading (ex : merchant...).
* @author Nightmare
*/
public class L2Spawn implements IPositionable, IIdentifiable, INamable
{
protected static final Logger _log = Logger.getLogger(L2Spawn.class.getName());
/** String identifier of this spawn */
private String _name;
/** The link on the L2NpcTemplate object containing generic and static properties of this spawn (ex : RewardExp, RewardSP, AggroRange...) */
private L2NpcTemplate _template;
/** The maximum number of L2NpcInstance that can manage this L2Spawn */
private int _maximumCount;
/** The current number of L2NpcInstance managed by this L2Spawn */
private int _currentCount;
/** The current number of SpawnTask in progress or stand by of this L2Spawn */
protected int _scheduledCount;
/** The identifier of the location area where L2NpcInstance can be spwaned */
private int _locationId;
/** The Location of this NPC spawn. */
private Location _location = new Location(0, 0, 0, 0, 0);
/** Link to NPC spawn territory */
private NpcSpawnTerritory _spawnTerritory = null;
/** Minimum respawn delay */
private int _respawnMinDelay;
/** Maximum respawn delay */
private int _respawnMaxDelay;
/** The generic constructor of L2NpcInstance managed by this L2Spawn */
private Constructor<? extends L2Npc> _constructor;
/** If True a L2NpcInstance is respawned each time that another is killed */
private boolean _doRespawn;
/** If true then spawn is custom */
private boolean _customSpawn;
private static List<SpawnListener> _spawnListeners = new CopyOnWriteArrayList<>();
private final Deque<L2Npc> _spawnedNpcs = new ConcurrentLinkedDeque<>();
private Map<Integer, Location> _lastSpawnPoints;
private boolean _isNoRndWalk = false; // Is no random walk
private String _areaName;
private int _globalMapId;
/** The task launching the function doSpawn() */
class SpawnTask implements Runnable
{
private final L2Npc _oldNpc;
public SpawnTask(L2Npc pOldNpc)
{
_oldNpc = pOldNpc;
}
@Override
public void run()
{
try
{
// doSpawn();
respawnNpc(_oldNpc);
}
catch (Exception e)
{
_log.log(Level.WARNING, "", e);
}
_scheduledCount--;
}
}
/**
* Constructor of L2Spawn.<br>
* <B><U>Concept</U>:</B><br>
* Each L2Spawn owns generic and static properties (ex : RewardExp, RewardSP, AggroRange...).<br>
* All of those properties are stored in a different L2NpcTemplate for each type of L2Spawn. Each template is loaded once in the server cache memory (reduce memory use).<br>
* When a new instance of L2Spawn is created, server just create a link between the instance and the template.<br>
* This link is stored in <B>_template</B> Each L2NpcInstance is linked to a L2Spawn that manages its spawn and respawn (delay, location...).<br>
* This link is stored in <B>_spawn</B> of the L2NpcInstance.<br>
* <B><U> Actions</U>:</B><br>
* <ul>
* <li>Set the _template of the L2Spawn</li>
* <li>Calculate the implementationName used to generate the generic constructor of L2NpcInstance managed by this L2Spawn</li>
* <li>Create the generic constructor of L2NpcInstance managed by this L2Spawn</li>
* </ul>
* @param template The L2NpcTemplate to link to this L2Spawn
* @throws SecurityException
* @throws ClassNotFoundException
* @throws NoSuchMethodException
* @throws ClassCastException when template type is not subclass of L2Npc
*/
public L2Spawn(L2NpcTemplate template) throws SecurityException, ClassNotFoundException, NoSuchMethodException, ClassCastException
{
// Set the _template of the L2Spawn
_template = template;
if (_template == null)
{
return;
}
final String className = "com.l2jmobius.gameserver.model.actor.instance." + _template.getType() + "Instance";
// Create the generic constructor of L2Npc managed by this L2Spawn
_constructor = Class.forName(className).asSubclass(L2Npc.class).getConstructor(L2NpcTemplate.class);
}
/**
* Creates a spawn.
* @param npcId the NPC ID
* @throws ClassCastException
* @throws NoSuchMethodException
* @throws ClassNotFoundException
* @throws SecurityException
*/
public L2Spawn(int npcId) throws SecurityException, ClassNotFoundException, NoSuchMethodException, ClassCastException
{
this(NpcData.getInstance().getTemplate(npcId));
}
/**
* @return the maximum number of L2NpcInstance that this L2Spawn can manage.
*/
public int getAmount()
{
return _maximumCount;
}
/**
* @return the String Identifier of this spawn.
*/
@Override
public String getName()
{
return _name;
}
/**
* Set the String Identifier of this spawn.
* @param name
*/
public void setName(String name)
{
_name = name;
}
/**
* @return the Identifier of the location area where L2NpcInstance can be spwaned.
*/
public int getLocationId()
{
return _locationId;
}
@Override
public Location getLocation()
{
return _location;
}
public Location getLocation(L2Object obj)
{
return ((_lastSpawnPoints == null) || (obj == null) || !_lastSpawnPoints.containsKey(obj.getObjectId())) ? _location : _lastSpawnPoints.get(obj.getObjectId());
}
@Override
public int getX()
{
return _location.getX();
}
/**
* @param obj object to check
* @return the X position of the last spawn point of given NPC.
*/
public int getX(L2Object obj)
{
return getLocation(obj).getX();
}
/**
* Set the X position of the spawn point.
* @param x the x coordinate
*/
@Override
public void setX(int x)
{
_location.setX(x);
}
@Override
public int getY()
{
return _location.getY();
}
/**
* @param obj object to check
* @return the Y position of the last spawn point of given NPC.
*/
public int getY(L2Object obj)
{
return getLocation(obj).getY();
}
/**
* Set the Y position of the spawn point.
* @param y the y coordinate
*/
@Override
public void setY(int y)
{
_location.setY(y);
}
@Override
public int getZ()
{
return _location.getZ();
}
/**
* @param obj object to check
* @return the Z position of the last spawn point of given NPC.
*/
public int getZ(L2Object obj)
{
return getLocation(obj).getZ();
}
/**
* Set the Z position of the spawn point.
* @param z the z coordinate
*/
@Override
public void setZ(int z)
{
_location.setZ(z);
}
/**
* Set the x, y, z position of the spawn point.
* @param x The x coordinate.
* @param y The y coordinate.
* @param z The z coordinate.
*/
@Override
public void setXYZ(int x, int y, int z)
{
setX(x);
setY(y);
setZ(z);
}
/**
* Set the x, y, z position of the spawn point.
* @param loc The location.
*/
@Override
public void setXYZ(ILocational loc)
{
setXYZ(loc.getX(), loc.getY(), loc.getZ());
}
/**
* @return the heading of L2NpcInstance when they are spawned.
*/
@Override
public int getHeading()
{
return _location.getHeading();
}
/**
* Set the heading of L2NpcInstance when they are spawned.
* @param heading
*/
@Override
public void setHeading(int heading)
{
_location.setHeading(heading);
}
/**
* Set the XYZ position of the spawn point.
* @param loc
*/
@Override
public void setLocation(Location loc)
{
_location = loc;
}
/**
* Gets the NPC ID.
* @return the NPC ID
*/
@Override
public int getId()
{
return _template.getId();
}
/**
* @return min respawn delay.
*/
public int getRespawnMinDelay()
{
return _respawnMinDelay;
}
/**
* @return max respawn delay.
*/
public int getRespawnMaxDelay()
{
return _respawnMaxDelay;
}
/**
* Set the maximum number of L2NpcInstance that this L2Spawn can manage.
* @param amount
*/
public void setAmount(int amount)
{
_maximumCount = amount;
}
/**
* Set the Identifier of the location area where L2NpcInstance can be spawned.
* @param id
*/
public void setLocationId(int id)
{
_locationId = id;
}
/**
* Set Minimum Respawn Delay.
* @param date
*/
public void setRespawnMinDelay(int date)
{
_respawnMinDelay = date;
}
/**
* Set Maximum Respawn Delay.
* @param date
*/
public void setRespawnMaxDelay(int date)
{
_respawnMaxDelay = date;
}
/**
* Set the spawn as custom.<BR>
* @param custom
*/
public void setCustom(boolean custom)
{
_customSpawn = custom;
}
/**
* @return type of spawn.
*/
public boolean isCustom()
{
return _customSpawn;
}
/**
* Decrease the current number of L2NpcInstance of this L2Spawn and if necessary create a SpawnTask to launch after the respawn Delay. <B><U> Actions</U> :</B>
* <li>Decrease the current number of L2NpcInstance of this L2Spawn</li>
* <li>Check if respawn is possible to prevent multiple respawning caused by lag</li>
* <li>Update the current number of SpawnTask in progress or stand by of this L2Spawn</li>
* <li>Create a new SpawnTask to launch after the respawn Delay</li> <FONT COLOR=#FF0000><B> <U>Caution</U> : A respawn is possible ONLY if _doRespawn=True and _scheduledCount + _currentCount < _maximumCount</B></FONT>
* @param oldNpc
*/
public void decreaseCount(L2Npc oldNpc)
{
// sanity check
if (_currentCount <= 0)
{
return;
}
// Decrease the current number of L2NpcInstance of this L2Spawn
_currentCount--;
// Remove this NPC from list of spawned
_spawnedNpcs.remove(oldNpc);
// Remove spawn point for old NPC
if (_lastSpawnPoints != null)
{
_lastSpawnPoints.remove(oldNpc.getObjectId());
}
// Check if respawn is possible to prevent multiple respawning caused by lag
if (_doRespawn && ((_scheduledCount + _currentCount) < _maximumCount))
{
// Update the current number of SpawnTask in progress or stand by of this L2Spawn
_scheduledCount++;
// Create a new SpawnTask to launch after the respawn Delay
// ClientScheduler.getInstance().scheduleLow(new SpawnTask(npcId), _respawnDelay);
ThreadPoolManager.getInstance().scheduleGeneral(new SpawnTask(oldNpc), hasRespawnRandom() ? Rnd.get(_respawnMinDelay, _respawnMaxDelay) : _respawnMinDelay);
}
}
/**
* Create the initial spawning and set _doRespawn to False, if respawn time set to 0, or set it to True otherwise.
* @return The number of L2NpcInstance that were spawned
*/
public int init()
{
while (_currentCount < _maximumCount)
{
doSpawn();
}
_doRespawn = _respawnMinDelay != 0;
return _currentCount;
}
/**
* Create a L2NpcInstance in this L2Spawn.
* @param val
* @return
*/
public L2Npc spawnOne(boolean val)
{
return doSpawn(val);
}
/**
* @return true if respawn enabled
*/
public boolean isRespawnEnabled()
{
return _doRespawn;
}
/**
* Set _doRespawn to False to stop respawn in this L2Spawn.
*/
public void stopRespawn()
{
_doRespawn = false;
}
/**
* Set _doRespawn to True to start or restart respawn in this L2Spawn.
*/
public void startRespawn()
{
_doRespawn = true;
}
public L2Npc doSpawn()
{
return doSpawn(false);
}
/**
* Create the L2NpcInstance, add it to the world and lauch its OnSpawn action.<br>
* <B><U>Concept</U>:</B><br>
* L2NpcInstance can be spawned either in a random position into a location area (if Lox=0 and Locy=0), either at an exact position.<br>
* The heading of the L2NpcInstance can be a random heading if not defined (value= -1) or an exact heading (ex : merchant...).<br>
* <B><U>Actions for an random spawn into location area</U>:<I> (if Locx=0 and Locy=0)</I></B>
* <ul>
* <li>Get L2NpcInstance Init parameters and its generate an Identifier</li>
* <li>Call the constructor of the L2NpcInstance</li>
* <li>Calculate the random position in the location area (if Locx=0 and Locy=0) or get its exact position from the L2Spawn</li>
* <li>Set the position of the L2NpcInstance</li>
* <li>Set the HP and MP of the L2NpcInstance to the max</li>
* <li>Set the heading of the L2NpcInstance (random heading if not defined : value=-1)</li>
* <li>Link the L2NpcInstance to this L2Spawn</li>
* <li>Init other values of the L2NpcInstance (ex : from its L2CharTemplate for INT, STR, DEX...) and add it in the world</li>
* <li>Launch the action OnSpawn fo the L2NpcInstance</li>
* <li>Increase the current number of L2NpcInstance managed by this L2Spawn</li>
* </ul>
* @param isSummonSpawn
* @return
*/
public L2Npc doSpawn(boolean isSummonSpawn)
{
try
{
// Check if the L2Spawn is not a L2Pet or L2Minion or L2Decoy spawn
if (_template.isType("L2Pet") || _template.isType("L2Decoy") || _template.isType("L2Trap"))
{
_currentCount++;
return null;
}
// Call the constructor of the L2Npc
final L2Npc npc = _constructor.newInstance(_template);
npc.setInstanceId(getInstanceId()); // Must be done before object is spawned into visible world
if (isSummonSpawn)
{
npc.setShowSummonAnimation(isSummonSpawn);
}
// Check for certain AI data, overriden in spawnlist
if (_name != null)
{
NpcPersonalAIData.getInstance().initializeNpcParameters(npc, this, _name);
}
return initializeNpcInstance(npc);
}
catch (Exception e)
{
_log.log(Level.WARNING, "NPC " + _template.getId() + " class not found", e);
}
return null;
}
/**
* @param mob
* @return
*/
private L2Npc initializeNpcInstance(L2Npc mob)
{
int newlocx = 0;
int newlocy = 0;
int newlocz = 0;
// If Locx and Locy are not defined, the L2NpcInstance must be spawned in an area defined by location or spawn territory
// New method
if (isTerritoryBased())
{
final int[] p = _spawnTerritory.getRandomPoint();
newlocx = p[0];
newlocy = p[1];
newlocz = p[2];
}
// Old method (for backward compatibility)
else if ((getX() == 0) && (getY() == 0))
{
if (getLocationId() == 0)
{
return mob;
}
// Calculate the random position in the location area
final Location location = TerritoryTable.getInstance().getRandomPoint(getLocationId());
// Set the calculated position of the L2NpcInstance
if (location != null)
{
newlocx = location.getX();
newlocy = location.getY();
newlocz = location.getZ();
}
}
else
{
// The L2NpcInstance is spawned at a random position
newlocx = getX();
newlocy = getY();
newlocz = getZ();
// If random spawn system is enabled
if (Config.ENABLE_RANDOM_MONSTER_SPAWNS)
{
final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE);
final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE);
boolean isQuestMonster = false;
if ((mob.getTitle() != null) && mob.getTitle().contains("Quest"))
{
isQuestMonster = true;
}
if (mob.isMonster() && !isQuestMonster && !mob.isWalker() && !mob.isInsideZone(ZoneId.NO_BOOKMARK) && GeoData.getInstance().canSeeTarget(newlocx, newlocy, newlocz, randX, randY, newlocz) && (getInstanceId() == 0) && !getTemplate().isUndying() && !mob.isRaid() && !mob.isRaidMinion() && !Config.MOBS_LIST_NOT_RANDOM.contains(mob.getId()))
{
newlocx = randX;
newlocy = randY;
}
}
}
// don't correct z of flying npc's
if (!mob.isFlying())
{
newlocz = GeoData.getInstance().getSpawnHeight(newlocx, newlocy, newlocz);
}
mob.stopAllEffects();
mob.setIsDead(false);
// Reset decay info
mob.setDecayed(false);
// Set the HP and MP of the L2NpcInstance to the max
mob.setCurrentHpMp(mob.getMaxHp(), mob.getMaxMp());
// Clear script variables
if (mob.hasVariables())
{
mob.getVariables().getSet().clear();
}
// Set is not random walk default value
mob.setIsNoRndWalk(isNoRndWalk());
// Set the heading of the L2NpcInstance (random heading if not defined)
if (getHeading() == -1)
{
mob.setHeading(Rnd.nextInt(61794));
}
else
{
mob.setHeading(getHeading());
}
if (mob instanceof L2Attackable)
{
((L2Attackable) mob).setChampion(false);
}
if (Config.L2JMOD_CHAMPION_ENABLE)
{
// Set champion on next spawn
if (mob.isMonster() && !getTemplate().isUndying() && !mob.isRaid() && !mob.isRaidMinion() && (Config.L2JMOD_CHAMPION_FREQUENCY > 0) && (mob.getLevel() >= Config.L2JMOD_CHAMP_MIN_LVL) && (mob.getLevel() <= Config.L2JMOD_CHAMP_MAX_LVL) && (Config.L2JMOD_CHAMPION_ENABLE_IN_INSTANCES || (getInstanceId() == 0)))
{
if (Rnd.get(100) < Config.L2JMOD_CHAMPION_FREQUENCY)
{
((L2Attackable) mob).setChampion(true);
}
}
}
// Set custom Npc server side name and title
if (mob.getTemplate().isUsingServerSideName())
{
mob.setName(mob.getTemplate().getName());
}
if (mob.getTemplate().isUsingServerSideTitle())
{
mob.setTitle(mob.getTemplate().getTitle());
}
// Reset summoner
mob.setSummoner(null);
// Reset summoned list
mob.resetSummonedNpcs();
// Link the L2NpcInstance to this L2Spawn
mob.setSpawn(this);
// Spawn NPC
mob.spawnMe(newlocx, newlocy, newlocz);
notifyNpcSpawned(mob);
_spawnedNpcs.add(mob);
if (_lastSpawnPoints != null)
{
_lastSpawnPoints.put(mob.getObjectId(), new Location(newlocx, newlocy, newlocz));
}
if (Config.DEBUG)
{
_log.finest("Spawned Mob Id: " + _template.getId() + " , at: X: " + mob.getX() + " Y: " + mob.getY() + " Z: " + mob.getZ());
}
// Increase the current number of L2NpcInstance managed by this L2Spawn
_currentCount++;
return mob;
}
public static void addSpawnListener(SpawnListener listener)
{
_spawnListeners.add(listener);
}
public static void removeSpawnListener(SpawnListener listener)
{
_spawnListeners.remove(listener);
}
public static void notifyNpcSpawned(L2Npc npc)
{
for (SpawnListener listener : _spawnListeners)
{
listener.npcSpawned(npc);
}
}
/**
* Set bounds for random calculation and delay for respawn
* @param delay delay in seconds
* @param randomInterval random interval in seconds
*/
public void setRespawnDelay(int delay, int randomInterval)
{
if (delay != 0)
{
if (delay < 0)
{
_log.warning("respawn delay is negative for spawn:" + this);
}
final int minDelay = delay - randomInterval;
final int maxDelay = delay + randomInterval;
_respawnMinDelay = Math.max(10, minDelay) * 1000;
_respawnMaxDelay = Math.max(10, maxDelay) * 1000;
}
else
{
_respawnMinDelay = 0;
_respawnMaxDelay = 0;
}
}
public void setRespawnDelay(int delay)
{
setRespawnDelay(delay, 0);
}
public int getRespawnDelay()
{
return (_respawnMinDelay + _respawnMaxDelay) / 2;
}
public boolean hasRespawnRandom()
{
return _respawnMinDelay != _respawnMaxDelay;
}
public void setSpawnTerritory(NpcSpawnTerritory territory)
{
_spawnTerritory = territory;
_lastSpawnPoints = new ConcurrentHashMap<>();
}
public NpcSpawnTerritory getSpawnTerritory()
{
return _spawnTerritory;
}
public boolean isTerritoryBased()
{
return (_spawnTerritory != null) && (_location.getX() == 0) && (_location.getY() == 0);
}
public L2Npc getLastSpawn()
{
return _spawnedNpcs.peekLast();
}
public final Deque<L2Npc> getSpawnedNpcs()
{
return _spawnedNpcs;
}
/**
* @param oldNpc
*/
public void respawnNpc(L2Npc oldNpc)
{
if (_doRespawn)
{
oldNpc.refreshID();
initializeNpcInstance(oldNpc);
}
}
public L2NpcTemplate getTemplate()
{
return _template;
}
@Override
public int getInstanceId()
{
return _location.getInstanceId();
}
@Override
public void setInstanceId(int instanceId)
{
_location.setInstanceId(instanceId);
}
public final boolean isNoRndWalk()
{
return _isNoRndWalk;
}
public final void setIsNoRndWalk(boolean value)
{
_isNoRndWalk = value;
}
public String getAreaName()
{
return _areaName;
}
public void setAreaName(String areaName)
{
_areaName = areaName;
}
public int getGlobalMapId()
{
return _globalMapId;
}
public void setGlobalMapId(int globalMapId)
{
_globalMapId = globalMapId;
}
@Override
public String toString()
{
return "L2Spawn ID: " + getId() + " " + getLocation();
}
}

View File

@@ -0,0 +1,144 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
/**
* This class ...
* @version $Revision: 1.2.4.1 $ $Date: 2005/03/27 15:29:32 $
*/
public class L2TeleportLocation
{
private int _teleId;
private int _locX;
private int _locY;
private int _locZ;
private int _price;
private boolean _forNoble;
private int _itemId;
/**
* @param id
*/
public void setTeleId(int id)
{
_teleId = id;
}
/**
* @param locX
*/
public void setLocX(int locX)
{
_locX = locX;
}
/**
* @param locY
*/
public void setLocY(int locY)
{
_locY = locY;
}
/**
* @param locZ
*/
public void setLocZ(int locZ)
{
_locZ = locZ;
}
/**
* @param price
*/
public void setPrice(int price)
{
_price = price;
}
/**
* @param val
*/
public void setIsForNoble(boolean val)
{
_forNoble = val;
}
/**
* @param val
*/
public void setItemId(int val)
{
_itemId = val;
}
/**
* @return
*/
public int getTeleId()
{
return _teleId;
}
/**
* @return
*/
public int getLocX()
{
return _locX;
}
/**
* @return
*/
public int getLocY()
{
return _locY;
}
/**
* @return
*/
public int getLocZ()
{
return _locZ;
}
/**
* @return
*/
public int getPrice()
{
return _price;
}
/**
* @return
*/
public boolean getIsForNoble()
{
return _forNoble;
}
/**
* @return
*/
public int getItemId()
{
return _itemId;
}
}

View File

@@ -0,0 +1,189 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Logger;
import com.l2jmobius.util.Rnd;
/**
* @version 0.1, 2005-03-12
* @author Balancer
*/
public class L2Territory
{
private static Logger _log = Logger.getLogger(L2Territory.class.getName());
protected static class Point
{
protected int _x, _y, _zmin, _zmax, _proc;
Point(int x, int y, int zmin, int zmax, int proc)
{
_x = x;
_y = y;
_zmin = zmin;
_zmax = zmax;
_proc = proc;
}
}
private final List<Point> _points = new CopyOnWriteArrayList<>();
private final int _terr;
private int _xMin;
private int _xMax;
private int _yMin;
private int _yMax;
private int _zMin;
private int _zMax;
private int _procMax;
public L2Territory(int terr)
{
_terr = terr;
_xMin = 999999;
_xMax = -999999;
_yMin = 999999;
_yMax = -999999;
_zMin = 999999;
_zMax = -999999;
_procMax = 0;
}
public void add(int x, int y, int zmin, int zmax, int proc)
{
_points.add(new Point(x, y, zmin, zmax, proc));
if (x < _xMin)
{
_xMin = x;
}
if (y < _yMin)
{
_yMin = y;
}
if (x > _xMax)
{
_xMax = x;
}
if (y > _yMax)
{
_yMax = y;
}
if (zmin < _zMin)
{
_zMin = zmin;
}
if (zmax > _zMax)
{
_zMax = zmax;
}
_procMax += proc;
}
public boolean isIntersect(int x, int y, Point p1, Point p2)
{
final double dy1 = p1._y - y;
final double dy2 = p2._y - y;
if (Math.abs(Math.signum(dy1) - Math.signum(dy2)) <= 1e-6)
{
return false;
}
final double dx1 = p1._x - x;
final double dx2 = p2._x - x;
if ((dx1 >= 0) && (dx2 >= 0))
{
return true;
}
if ((dx1 < 0) && (dx2 < 0))
{
return false;
}
final double dx0 = (dy1 * (p1._x - p2._x)) / (p1._y - p2._y);
return dx0 <= dx1;
}
public boolean isInside(int x, int y)
{
int intersect_count = 0;
for (int i = 0; i < _points.size(); i++)
{
final Point p1 = _points.get(i > 0 ? i - 1 : _points.size() - 1);
final Point p2 = _points.get(i);
if (isIntersect(x, y, p1, p2))
{
intersect_count++;
}
}
return (intersect_count % 2) == 1;
}
public Location getRandomPoint()
{
if (_procMax > 0)
{
int pos = 0;
final int rnd = Rnd.nextInt(_procMax);
for (Point p1 : _points)
{
pos += p1._proc;
if (rnd <= pos)
{
return new Location(p1._x, p1._y, Rnd.get(p1._zmin, p1._zmax));
}
}
}
for (int i = 0; i < 100; i++)
{
final int x = Rnd.get(_xMin, _xMax);
final int y = Rnd.get(_yMin, _yMax);
if (isInside(x, y))
{
double curdistance = 0;
int zmin = _zMin;
for (Point p1 : _points)
{
final double dx = p1._x - x;
final double dy = p1._y - y;
final double distance = Math.sqrt((dx * dx) + (dy * dy));
if ((curdistance == 0) || (distance < curdistance))
{
curdistance = distance;
zmin = p1._zmin;
}
}
return new Location(x, y, Rnd.get(zmin, _zMax));
}
}
_log.warning("Can't make point for territory " + _terr);
return null;
}
public int getProcMax()
{
return _procMax;
}
}

View File

@@ -0,0 +1,74 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.List;
/**
* @author GKR
*/
public class L2WalkRoute
{
private final String _name;
private final List<L2NpcWalkerNode> _nodeList; // List of nodes
private final boolean _repeatWalk; // Does repeat walk, after arriving into last point in list, or not
private boolean _stopAfterCycle; // Make only one cycle or endlessly
private final byte _repeatType; // Repeat style: 0 - go back, 1 - go to first point (circle style), 2 - teleport to first point (conveyor style), 3 - random walking between points
public L2WalkRoute(String name, List<L2NpcWalkerNode> route, boolean repeat, boolean once, byte repeatType)
{
_name = name;
_nodeList = route;
_repeatType = repeatType;
_repeatWalk = ((_repeatType >= 0) && (_repeatType <= 2)) ? repeat : false;
}
public String getName()
{
return _name;
}
public List<L2NpcWalkerNode> getNodeList()
{
return _nodeList;
}
public L2NpcWalkerNode getLastNode()
{
return _nodeList.get(_nodeList.size() - 1);
}
public boolean repeatWalk()
{
return _repeatWalk;
}
public boolean doOnce()
{
return _stopAfterCycle;
}
public byte getRepeatType()
{
return _repeatType;
}
public int getNodesCount()
{
return _nodeList.size();
}
}

View File

@@ -0,0 +1,668 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
import com.l2jmobius.gameserver.model.actor.L2Playable;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance;
public final class L2World
{
private static final Logger _log = Logger.getLogger(L2World.class.getName());
/** Gracia border Flying objects not allowed to the east of it. */
public static final int GRACIA_MAX_X = -166168;
public static final int GRACIA_MAX_Z = 6105;
public static final int GRACIA_MIN_Z = -895;
/** Biteshift, defines number of regions note, shifting by 15 will result in regions corresponding to map tiles shifting by 12 divides one tile to 8x8 regions. */
public static final int SHIFT_BY = 12;
private static final int TILE_SIZE = 32768;
/** Map dimensions */
public static final int TILE_X_MIN = 11;
public static final int TILE_Y_MIN = 10;
public static final int TILE_X_MAX = 28;
public static final int TILE_Y_MAX = 26;
public static final int TILE_ZERO_COORD_X = 20;
public static final int TILE_ZERO_COORD_Y = 18;
public static final int MAP_MIN_X = (TILE_X_MIN - TILE_ZERO_COORD_X) * TILE_SIZE;
public static final int MAP_MIN_Y = (TILE_Y_MIN - TILE_ZERO_COORD_Y) * TILE_SIZE;
public static final int MAP_MAX_X = ((TILE_X_MAX - TILE_ZERO_COORD_X) + 1) * TILE_SIZE;
public static final int MAP_MAX_Y = ((TILE_Y_MAX - TILE_ZERO_COORD_Y) + 1) * TILE_SIZE;
/** calculated offset used so top left region is 0,0 */
public static final int OFFSET_X = Math.abs(MAP_MIN_X >> SHIFT_BY);
public static final int OFFSET_Y = Math.abs(MAP_MIN_Y >> SHIFT_BY);
/** number of regions */
private static final int REGIONS_X = (MAP_MAX_X >> SHIFT_BY) + OFFSET_X;
private static final int REGIONS_Y = (MAP_MAX_Y >> SHIFT_BY) + OFFSET_Y;
/** Map containing all the players in game. */
private final Map<Integer, L2PcInstance> _allPlayers = new ConcurrentHashMap<>();
/** Map containing all the Good players in game. */
private final static Map<Integer, L2PcInstance> _allGoodPlayers = new ConcurrentHashMap<>();
/** Map containing all the Evil players in game. */
private final static Map<Integer, L2PcInstance> _allEvilPlayers = new ConcurrentHashMap<>();
/** Map containing all visible objects. */
private final Map<Integer, L2Object> _allObjects = new ConcurrentHashMap<>();
/** Map with the pets instances and their owner ID. */
private final Map<Integer, L2PetInstance> _petsInstance = new ConcurrentHashMap<>();
private L2WorldRegion[][] _worldRegions;
/** Constructor of L2World. */
protected L2World()
{
initRegions();
}
/**
* Adds an object to the world.<br>
* <B><U>Example of use</U>:</B>
* <ul>
* <li>Withdraw an item from the warehouse, create an item</li>
* <li>Spawn a L2Character (PC, NPC, Pet)</li>
* </ul>
* @param object
*/
public void storeObject(L2Object object)
{
if (_allObjects.containsKey(object.getObjectId()))
{
_log.log(Level.WARNING, getClass().getSimpleName() + ": Current object: " + object + " already exist in OID map!");
_log.log(Level.WARNING, "---------------------- End ---------------------");
return;
}
_allObjects.put(object.getObjectId(), object);
}
/**
* Removes an object from the world.<br>
* <B><U>Example of use</U>:</B>
* <ul>
* <li>Delete item from inventory, transfer Item from inventory to warehouse</li>
* <li>Crystallize item</li>
* <li>Remove NPC/PC/Pet from the world</li>
* </ul>
* @param object the object to remove
*/
public void removeObject(L2Object object)
{
_allObjects.remove(object.getObjectId());
}
/**
* <B><U> Example of use</U>:</B>
* <ul>
* <li>Client packets : Action, AttackRequest, RequestJoinParty, RequestJoinPledge...</li>
* </ul>
* @param objectId Identifier of the L2Object
* @return the L2Object object that belongs to an ID or null if no object found.
*/
public L2Object findObject(int objectId)
{
return _allObjects.get(objectId);
}
public Collection<L2Object> getVisibleObjects()
{
return _allObjects.values();
}
/**
* Get the count of all visible objects in world.
* @return count off all L2World objects
*/
public int getVisibleObjectsCount()
{
return _allObjects.size();
}
public List<L2PcInstance> getAllGMs()
{
return AdminData.getInstance().getAllGms(true);
}
public Collection<L2PcInstance> getPlayers()
{
return _allPlayers.values();
}
public Collection<L2PcInstance> getAllGoodPlayers()
{
return _allGoodPlayers.values();
}
public Collection<L2PcInstance> getAllEvilPlayers()
{
return _allEvilPlayers.values();
}
/**
* Gets all players sorted by the given comparator.
* @param comparator the comparator
* @return the players sorted by the comparator
*/
public L2PcInstance[] getPlayersSortedBy(Comparator<L2PcInstance> comparator)
{
final L2PcInstance[] players = _allPlayers.values().toArray(new L2PcInstance[_allPlayers.values().size()]);
Arrays.sort(players, comparator);
return players;
}
/**
* Return how many players are online.
* @return number of online players.
*/
public int getAllPlayersCount()
{
return _allPlayers.size();
}
public int getAllGoodPlayersCount()
{
return _allGoodPlayers.size();
}
public int getAllEvilPlayersCount()
{
return _allEvilPlayers.size();
}
/**
* <B>If you have access to player objectId use {@link #getPlayer(int playerObjId)}</B>
* @param name Name of the player to get Instance
* @return the player instance corresponding to the given name.
*/
public L2PcInstance getPlayer(String name)
{
return getPlayer(CharNameTable.getInstance().getIdByName(name));
}
/**
* @param objectId of the player to get Instance
* @return the player instance corresponding to the given object ID.
*/
public L2PcInstance getPlayer(int objectId)
{
return _allPlayers.get(objectId);
}
/**
* @param ownerId ID of the owner
* @return the pet instance from the given ownerId.
*/
public L2PetInstance getPet(int ownerId)
{
return _petsInstance.get(ownerId);
}
/**
* Add the given pet instance from the given ownerId.
* @param ownerId ID of the owner
* @param pet L2PetInstance of the pet
* @return
*/
public L2PetInstance addPet(int ownerId, L2PetInstance pet)
{
return _petsInstance.put(ownerId, pet);
}
/**
* Remove the given pet instance.
* @param ownerId ID of the owner
*/
public void removePet(int ownerId)
{
_petsInstance.remove(ownerId);
}
/**
* Remove the given pet instance.
* @param pet the pet to remove
*/
public void removePet(L2PetInstance pet)
{
_petsInstance.remove(pet.getOwner().getObjectId());
}
/**
* Add a L2Object in the world. <B><U> Concept</U> :</B> L2Object (including L2PcInstance) are identified in <B>_visibleObjects</B> of his current L2WorldRegion and in <B>_knownObjects</B> of other surrounding L2Characters <BR>
* L2PcInstance are identified in <B>_allPlayers</B> of L2World, in <B>_allPlayers</B> of his current L2WorldRegion and in <B>_knownPlayer</B> of other surrounding L2Characters <B><U> Actions</U> :</B>
* <li>Add the L2Object object in _allPlayers* of L2World</li>
* <li>Add the L2Object object in _gmList** of GmListTable</li>
* <li>Add object in _knownObjects and _knownPlayer* of all surrounding L2WorldRegion L2Characters</li><BR>
* <li>If object is a L2Character, add all surrounding L2Object in its _knownObjects and all surrounding L2PcInstance in its _knownPlayer</li><BR>
* <I>* only if object is a L2PcInstance</I><BR>
* <I>** only if object is a GM L2PcInstance</I> <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T ADD the object in _visibleObjects and _allPlayers* of L2WorldRegion (need synchronisation)</B></FONT><BR>
* <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T ADD the object to _allObjects and _allPlayers* of L2World (need synchronisation)</B></FONT> <B><U> Example of use </U> :</B>
* <li>Drop an Item</li>
* <li>Spawn a L2Character</li>
* <li>Apply Death Penalty of a L2PcInstance</li>
* @param object L2object to add in the world
* @param newRegion L2WorldRegion in wich the object will be add (not used)
*/
public void addVisibleObject(L2Object object, L2WorldRegion newRegion)
{
if (!newRegion.isActive())
{
return;
}
// Get all visible objects contained in the _visibleObjects of L2WorldRegions
// in a circular area of 2000 units
final List<L2Object> visibles = getVisibleObjects(object, 2000);
if (Config.DEBUG)
{
_log.finest("objects in range:" + visibles.size());
}
// tell the player about the surroundings
// Go through the visible objects contained in the circular area
for (L2Object visible : visibles)
{
if (visible == null)
{
continue;
}
// Add the object in L2ObjectHashSet(L2Object) _knownObjects of the visible L2Character according to conditions :
// - L2Character is visible
// - object is not already known
// - object is in the watch distance
// If L2Object is a L2PcInstance, add L2Object in L2ObjectHashSet(L2PcInstance) _knownPlayer of the visible L2Character
visible.getKnownList().addKnownObject(object);
// Add the visible L2Object in L2ObjectHashSet(L2Object) _knownObjects of the object according to conditions
// If visible L2Object is a L2PcInstance, add visible L2Object in L2ObjectHashSet(L2PcInstance) _knownPlayer of the object
object.getKnownList().addKnownObject(visible);
}
}
/**
* Adds the player to the world.
* @param player the player to add
*/
public void addPlayerToWorld(L2PcInstance player)
{
_allPlayers.put(player.getObjectId(), player);
if (Config.FACTION_SYSTEM_ENABLED)
{
addFactionPlayerToWorld(player);
}
}
public static void addFactionPlayerToWorld(L2PcInstance player)
{
if (player.isGood())
{
_allGoodPlayers.put(player.getObjectId(), player);
}
else if (player.isEvil())
{
_allEvilPlayers.put(player.getObjectId(), player);
}
}
/**
* Remove the player from the world.
* @param player the player to remove
*/
public void removeFromAllPlayers(L2PcInstance player)
{
_allPlayers.remove(player.getObjectId());
if (Config.FACTION_SYSTEM_ENABLED)
{
if (player.isGood())
{
_allGoodPlayers.remove(player.getObjectId());
}
else if (player.isEvil())
{
_allEvilPlayers.remove(player.getObjectId());
}
}
}
/**
* Remove a L2Object from the world. <B><U> Concept</U> :</B> L2Object (including L2PcInstance) are identified in <B>_visibleObjects</B> of his current L2WorldRegion and in <B>_knownObjects</B> of other surrounding L2Characters <BR>
* L2PcInstance are identified in <B>_allPlayers</B> of L2World, in <B>_allPlayers</B> of his current L2WorldRegion and in <B>_knownPlayer</B> of other surrounding L2Characters <B><U> Actions</U> :</B>
* <li>Remove the L2Object object from _allPlayers* of L2World</li>
* <li>Remove the L2Object object from _visibleObjects and _allPlayers* of L2WorldRegion</li>
* <li>Remove the L2Object object from _gmList** of GmListTable</li>
* <li>Remove object from _knownObjects and _knownPlayer* of all surrounding L2WorldRegion L2Characters</li><BR>
* <li>If object is a L2Character, remove all L2Object from its _knownObjects and all L2PcInstance from its _knownPlayer</li> <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T REMOVE the object from _allObjects of L2World</B></FONT> <I>* only if object is a L2PcInstance</I><BR>
* <I>** only if object is a GM L2PcInstance</I> <B><U> Example of use </U> :</B>
* <li>Pickup an Item</li>
* <li>Decay a L2Character</li>
* @param object L2object to remove from the world
* @param oldRegion L2WorldRegion in which the object was before removing
*/
public void removeVisibleObject(L2Object object, L2WorldRegion oldRegion)
{
if (object == null)
{
return;
}
if (oldRegion != null)
{
// Remove the object from the L2ObjectHashSet(L2Object) _visibleObjects of L2WorldRegion
// If object is a L2PcInstance, remove it from the L2ObjectHashSet(L2PcInstance) _allPlayers of this L2WorldRegion
oldRegion.removeVisibleObject(object);
// Go through all surrounding L2WorldRegion L2Characters
for (L2WorldRegion reg : oldRegion.getSurroundingRegions())
{
final Collection<L2Object> vObj = reg.getVisibleObjects().values();
for (L2Object obj : vObj)
{
if (obj != null)
{
obj.getKnownList().removeKnownObject(object);
}
}
}
// If object is a L2Character :
// Remove all L2Object from L2ObjectHashSet(L2Object) containing all L2Object detected by the L2Character
// Remove all L2PcInstance from L2ObjectHashSet(L2PcInstance) containing all player ingame detected by the L2Character
object.getKnownList().removeAllKnownObjects();
}
}
/**
* Return all visible objects of the L2WorldRegion object's and of its surrounding L2WorldRegion. <B><U> Concept</U> :</B> All visible object are identified in <B>_visibleObjects</B> of their current L2WorldRegion <BR>
* All surrounding L2WorldRegion are identified in <B>_surroundingRegions</B> of the selected L2WorldRegion in order to scan a large area around a L2Object <B><U> Example of use </U> :</B>
* <li>Find Close Objects for L2Character</li><BR>
* @param object L2object that determine the current L2WorldRegion
* @return
*/
public List<L2Object> getVisibleObjects(L2Object object)
{
final L2WorldRegion reg = object.getWorldRegion();
if (reg == null)
{
return null;
}
// Create a list in order to contain all visible objects.
final List<L2Object> result = new LinkedList<>();
for (L2WorldRegion regi : reg.getSurroundingRegions())
{
// Go through visible objects of the selected region
for (L2Object _object : regi.getVisibleObjects().values())
{
if ((_object == null) || _object.equals(object))
{
continue; // skip our own character
}
else if (!_object.isVisible())
{
continue; // skip dying objects
}
result.add(_object);
}
}
return result;
}
/**
* Return all visible objects of the L2WorldRegions in the circular area (radius) centered on the object. <B><U> Concept</U> :</B> All visible object are identified in <B>_visibleObjects</B> of their current L2WorldRegion <BR>
* All surrounding L2WorldRegion are identified in <B>_surroundingRegions</B> of the selected L2WorldRegion in order to scan a large area around a L2Object <B><U> Example of use </U> :</B>
* <li>Define the aggrolist of monster</li>
* <li>Define visible objects of a L2Object</li>
* <li>Skill : Confusion...</li><BR>
* @param object L2object that determine the center of the circular area
* @param radius Radius of the circular area
* @return
*/
public List<L2Object> getVisibleObjects(L2Object object, int radius)
{
if ((object == null) || !object.isVisible())
{
return new ArrayList<>();
}
final int sqRadius = radius * radius;
// Create a list in order to contain all visible objects.
final List<L2Object> result = new LinkedList<>();
for (L2WorldRegion regi : object.getWorldRegion().getSurroundingRegions())
{
// Go through visible objects of the selected region
for (L2Object _object : regi.getVisibleObjects().values())
{
if ((_object == null) || _object.equals(object))
{
continue; // skip our own character
}
if (sqRadius > object.calculateDistance(_object, false, true))
{
result.add(_object);
}
}
}
return result;
}
/**
* Return all visible objects of the L2WorldRegions in the spheric area (radius) centered on the object. <B><U> Concept</U> :</B> All visible object are identified in <B>_visibleObjects</B> of their current L2WorldRegion <BR>
* All surrounding L2WorldRegion are identified in <B>_surroundingRegions</B> of the selected L2WorldRegion in order to scan a large area around a L2Object <B><U> Example of use </U> :</B>
* <li>Define the target list of a skill</li>
* <li>Define the target list of a polearme attack</li>
* @param object L2object that determine the center of the circular area
* @param radius Radius of the spheric area
* @return
*/
public List<L2Object> getVisibleObjects3D(L2Object object, int radius)
{
if ((object == null) || !object.isVisible())
{
return new ArrayList<>();
}
final int sqRadius = radius * radius;
// Create a list in order to contain all visible objects.
final List<L2Object> result = new LinkedList<>();
for (L2WorldRegion regi : object.getWorldRegion().getSurroundingRegions())
{
for (L2Object _object : regi.getVisibleObjects().values())
{
if ((_object == null) || _object.equals(object))
{
continue; // skip our own character
}
if (sqRadius > object.calculateDistance(_object, true, true))
{
result.add(_object);
}
}
}
return result;
}
/**
* <B><U> Concept</U> :</B> All visible object are identified in <B>_visibleObjects</B> of their current L2WorldRegion <BR>
* All surrounding L2WorldRegion are identified in <B>_surroundingRegions</B> of the selected L2WorldRegion in order to scan a large area around a L2Object <B><U> Example of use </U> :</B>
* <li>Find Close Objects for L2Character</li><BR>
* @param object L2object that determine the current L2WorldRegion
* @return all visible players of the L2WorldRegion object's and of its surrounding L2WorldRegion.
*/
public List<L2Playable> getVisiblePlayable(L2Object object)
{
final L2WorldRegion reg = object.getWorldRegion();
if (reg == null)
{
return null;
}
// Create a list in order to contain all visible objects.
final List<L2Playable> result = new LinkedList<>();
for (L2WorldRegion regi : reg.getSurroundingRegions())
{
// Create an Iterator to go through the visible L2Object of the L2WorldRegion
final Map<Integer, L2Playable> _allpls = regi.getVisiblePlayable();
final Collection<L2Playable> _playables = _allpls.values();
// Go through visible object of the selected region
for (L2Playable _object : _playables)
{
if ((_object == null) || _object.equals(object))
{
continue; // skip our own character
}
if (!_object.isVisible())
{
continue; // skip dying objects
}
result.add(_object);
}
}
return result;
}
/**
* Calculate the current L2WorldRegions of the object according to its position (x,y). <B><U> Example of use </U> :</B>
* <li>Set position of a new L2Object (drop, spawn...)</li>
* <li>Update position of a L2Object after a movement</li><BR>
* @param point position of the object
* @return
*/
public L2WorldRegion getRegion(Location point)
{
return _worldRegions[(point.getX() >> SHIFT_BY) + OFFSET_X][(point.getY() >> SHIFT_BY) + OFFSET_Y];
}
public L2WorldRegion getRegion(int x, int y)
{
return _worldRegions[(x >> SHIFT_BY) + OFFSET_X][(y >> SHIFT_BY) + OFFSET_Y];
}
/**
* Returns the whole 2d array containing the world regions used by ZoneData.java to setup zones inside the world regions
* @return
*/
public L2WorldRegion[][] getWorldRegions()
{
return _worldRegions;
}
/**
* Check if the current L2WorldRegions of the object is valid according to its position (x,y). <B><U> Example of use </U> :</B>
* <li>Init L2WorldRegions</li><BR>
* @param x X position of the object
* @param y Y position of the object
* @return True if the L2WorldRegion is valid
*/
private boolean validRegion(int x, int y)
{
return ((x >= 0) && (x <= REGIONS_X) && (y >= 0) && (y <= REGIONS_Y));
}
/**
* Initialize the world regions.
*/
private void initRegions()
{
_worldRegions = new L2WorldRegion[REGIONS_X + 1][REGIONS_Y + 1];
for (int i = 0; i <= REGIONS_X; i++)
{
for (int j = 0; j <= REGIONS_Y; j++)
{
_worldRegions[i][j] = new L2WorldRegion(i, j);
}
}
for (int x = 0; x <= REGIONS_X; x++)
{
for (int y = 0; y <= REGIONS_Y; y++)
{
for (int a = -1; a <= 1; a++)
{
for (int b = -1; b <= 1; b++)
{
if (validRegion(x + a, y + b))
{
_worldRegions[x + a][y + b].addSurroundingRegion(_worldRegions[x][y]);
}
}
}
}
}
_log.info("L2World: (" + REGIONS_X + " by " + REGIONS_Y + ") World Region Grid set up.");
}
/**
* Deleted all spawns in the world.
*/
public void deleteVisibleNpcSpawns()
{
_log.info("Deleting all visible NPC's.");
for (int i = 0; i <= REGIONS_X; i++)
{
for (int j = 0; j <= REGIONS_Y; j++)
{
_worldRegions[i][j].deleteVisibleNpcSpawns();
}
}
_log.info("All visible NPC's deleted.");
}
/**
* @return the current instance of L2World
*/
public static L2World getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final L2World _instance = new L2World();
}
}

View File

@@ -0,0 +1,494 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledFuture;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.datatables.SpawnTable;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.L2Playable;
import com.l2jmobius.gameserver.model.actor.L2Vehicle;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.zone.L2ZoneType;
import com.l2jmobius.gameserver.model.zone.type.L2PeaceZone;
public final class L2WorldRegion
{
private static final Logger _log = Logger.getLogger(L2WorldRegion.class.getName());
/** Map containing all playable characters in game in this world region. */
private final Map<Integer, L2Playable> _allPlayable;
/** Map containing visible objects in this world region. */
private final Map<Integer, L2Object> _visibleObjects;
private final List<L2WorldRegion> _surroundingRegions;
private final int _tileX, _tileY;
private boolean _active = false;
private ScheduledFuture<?> _neighborsTask = null;
private final List<L2ZoneType> _zones;
public L2WorldRegion(int pTileX, int pTileY)
{
_allPlayable = new ConcurrentHashMap<>();
_visibleObjects = new ConcurrentHashMap<>();
_surroundingRegions = new ArrayList<>();
_tileX = pTileX;
_tileY = pTileY;
// default a newly initialized region to inactive, unless always on is specified
_active = Config.GRIDS_ALWAYS_ON;
_zones = new ArrayList<>();
}
public List<L2ZoneType> getZones()
{
return _zones;
}
public void addZone(L2ZoneType zone)
{
_zones.add(zone);
}
public void removeZone(L2ZoneType zone)
{
_zones.remove(zone);
}
public void revalidateZones(L2Character character)
{
// do NOT update the world region while the character is still in the process of teleporting
// Once the teleport is COMPLETED, revalidation occurs safely, at that time.
if (character.isTeleporting())
{
return;
}
for (L2ZoneType z : getZones())
{
if (z != null)
{
z.revalidateInZone(character);
}
}
}
public void removeFromZones(L2Character character)
{
for (L2ZoneType z : getZones())
{
if (z != null)
{
z.removeCharacter(character);
}
}
}
public boolean containsZone(int zoneId)
{
for (L2ZoneType z : getZones())
{
if (z.getId() == zoneId)
{
return true;
}
}
return false;
}
public boolean checkEffectRangeInsidePeaceZone(Skill skill, final int x, final int y, final int z)
{
final int range = skill.getEffectRange();
final int up = y + range;
final int down = y - range;
final int left = x + range;
final int right = x - range;
for (L2ZoneType e : getZones())
{
if (e instanceof L2PeaceZone)
{
if (e.isInsideZone(x, up, z))
{
return false;
}
if (e.isInsideZone(x, down, z))
{
return false;
}
if (e.isInsideZone(left, y, z))
{
return false;
}
if (e.isInsideZone(right, y, z))
{
return false;
}
if (e.isInsideZone(x, y, z))
{
return false;
}
}
}
return true;
}
public void onDeath(L2Character character)
{
for (L2ZoneType z : getZones())
{
if (z != null)
{
z.onDieInside(character);
}
}
}
public void onRevive(L2Character character)
{
for (L2ZoneType z : getZones())
{
if (z != null)
{
z.onReviveInside(character);
}
}
}
/** Task of AI notification */
public class NeighborsTask implements Runnable
{
private final boolean _isActivating;
public NeighborsTask(boolean isActivating)
{
_isActivating = isActivating;
}
@Override
public void run()
{
if (_isActivating)
{
// for each neighbor, if it's not active, activate.
for (L2WorldRegion neighbor : getSurroundingRegions())
{
neighbor.setActive(true);
}
}
else
{
if (areNeighborsEmpty())
{
setActive(false);
}
// check and deactivate
for (L2WorldRegion neighbor : getSurroundingRegions())
{
if (neighbor.areNeighborsEmpty())
{
neighbor.setActive(false);
}
}
}
}
}
private void switchAI(boolean isOn)
{
int c = 0;
if (!isOn)
{
for (L2Object o : _visibleObjects.values())
{
if (o instanceof L2Attackable)
{
c++;
final L2Attackable mob = (L2Attackable) o;
// Set target to null and cancel Attack or Cast
mob.setTarget(null);
// Stop movement
mob.stopMove(null);
// Stop all active skills effects in progress on the L2Character
mob.stopAllEffects();
mob.clearAggroList();
mob.getAttackByList().clear();
mob.getKnownList().removeAllKnownObjects();
// stop the ai tasks
if (mob.hasAI())
{
mob.getAI().setIntention(com.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE);
mob.getAI().stopAITask();
}
}
else if (o instanceof L2Vehicle)
{
c++;
((L2Vehicle) o).getKnownList().removeAllKnownObjects();
}
}
_log.fine(c + " mobs were turned off");
}
else
{
for (L2Object o : _visibleObjects.values())
{
if (o instanceof L2Attackable)
{
c++;
// Start HP/MP/CP Regeneration task
((L2Attackable) o).getStatus().startHpMpRegeneration();
}
else if (o instanceof L2Npc)
{
((L2Npc) o).startRandomAnimationTimer();
}
}
_log.fine(c + " mobs were turned on");
}
}
public boolean isActive()
{
return _active;
}
// check if all 9 neighbors (including self) are inactive or active but with no players.
// returns true if the above condition is met.
public boolean areNeighborsEmpty()
{
// if this region is occupied, return false.
if (isActive() && !_allPlayable.isEmpty())
{
return false;
}
// if any one of the neighbors is occupied, return false
for (L2WorldRegion neighbor : _surroundingRegions)
{
if (neighbor.isActive() && !neighbor._allPlayable.isEmpty())
{
return false;
}
}
// in all other cases, return true.
return true;
}
/**
* this function turns this region's AI and geodata on or off
* @param value
*/
public void setActive(boolean value)
{
if (_active == value)
{
return;
}
_active = value;
// turn the AI on or off to match the region's activation.
switchAI(value);
// TODO
// turn the geodata on or off to match the region's activation.
if (value)
{
_log.fine("Starting Grid " + _tileX + "," + _tileY);
}
else
{
_log.fine("Stoping Grid " + _tileX + "," + _tileY);
}
}
/**
* Immediately sets self as active and starts a timer to set neighbors as active this timer is to avoid turning on neighbors in the case when a person just teleported into a region and then teleported out immediately...there is no reason to activate all the neighbors in that case.
*/
private void startActivation()
{
// first set self to active and do self-tasks...
setActive(true);
// if the timer to deactivate neighbors is running, cancel it.
synchronized (this)
{
if (_neighborsTask != null)
{
_neighborsTask.cancel(true);
_neighborsTask = null;
}
// then, set a timer to activate the neighbors
_neighborsTask = ThreadPoolManager.getInstance().scheduleGeneral(new NeighborsTask(true), 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
}
}
/**
* starts a timer to set neighbors (including self) as inactive this timer is to avoid turning off neighbors in the case when a person just moved out of a region that he may very soon return to. There is no reason to turn self & neighbors off in that case.
*/
private void startDeactivation()
{
// if the timer to activate neighbors is running, cancel it.
synchronized (this)
{
if (_neighborsTask != null)
{
_neighborsTask.cancel(true);
_neighborsTask = null;
}
// start a timer to "suggest" a deactivate to self and neighbors.
// suggest means: first check if a neighbor has L2PcInstances in it. If not, deactivate.
_neighborsTask = ThreadPoolManager.getInstance().scheduleGeneral(new NeighborsTask(false), 1000 * Config.GRID_NEIGHBOR_TURNOFF_TIME);
}
}
/**
* Add the L2Object in the L2ObjectHashSet(L2Object) _visibleObjects containing L2Object visible in this L2WorldRegion <BR>
* If L2Object is a L2PcInstance, Add the L2PcInstance in the L2ObjectHashSet(L2PcInstance) _allPlayable containing L2PcInstance of all player in game in this L2WorldRegion <BR>
* Assert : object.getCurrentWorldRegion() == this
* @param object
*/
public void addVisibleObject(L2Object object)
{
if (object == null)
{
return;
}
assert object.getWorldRegion() == this;
_visibleObjects.put(object.getObjectId(), object);
if (object instanceof L2Playable)
{
_allPlayable.put(object.getObjectId(), (L2Playable) object);
// if this is the first player to enter the region, activate self & neighbors
if ((_allPlayable.size() == 1) && (!Config.GRIDS_ALWAYS_ON))
{
startActivation();
}
}
}
/**
* Remove the L2Object from the L2ObjectHashSet(L2Object) _visibleObjects in this L2WorldRegion. If L2Object is a L2PcInstance, remove it from the L2ObjectHashSet(L2PcInstance) _allPlayable of this L2WorldRegion <BR>
* Assert : object.getCurrentWorldRegion() == this || object.getCurrentWorldRegion() == null
* @param object
*/
public void removeVisibleObject(L2Object object)
{
if (object == null)
{
return;
}
assert (object.getWorldRegion() == this) || (object.getWorldRegion() == null);
_visibleObjects.remove(object.getObjectId());
if (object instanceof L2Playable)
{
_allPlayable.remove(object.getObjectId());
if (_allPlayable.isEmpty() && !Config.GRIDS_ALWAYS_ON)
{
startDeactivation();
}
}
}
public void addSurroundingRegion(L2WorldRegion region)
{
_surroundingRegions.add(region);
}
/**
* @return the ArrayList _surroundingRegions containing all L2WorldRegion around the current L2WorldRegion
*/
public List<L2WorldRegion> getSurroundingRegions()
{
return _surroundingRegions;
}
public Map<Integer, L2Playable> getVisiblePlayable()
{
return _allPlayable;
}
public Map<Integer, L2Object> getVisibleObjects()
{
return _visibleObjects;
}
public String getName()
{
return "(" + _tileX + ", " + _tileY + ")";
}
/**
* Deleted all spawns in the world.
*/
public void deleteVisibleNpcSpawns()
{
_log.fine("Deleting all visible NPC's in Region: " + getName());
for (L2Object obj : _visibleObjects.values())
{
if (obj instanceof L2Npc)
{
final L2Npc target = (L2Npc) obj;
target.deleteMe();
final L2Spawn spawn = target.getSpawn();
if (spawn != null)
{
spawn.stopRespawn();
SpawnTable.getInstance().deleteSpawn(spawn, false);
}
_log.finest("Removed NPC " + target.getObjectId());
}
}
_log.info("All visible NPC's deleted in Region: " + getName());
}
}

View File

@@ -0,0 +1,223 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import com.l2jmobius.gameserver.model.interfaces.ILocational;
import com.l2jmobius.gameserver.model.interfaces.IPositionable;
/**
* Location data transfer object.<br>
* Contains coordinates data, heading and instance Id.
* @author Zoey76
*/
public class Location implements IPositionable
{
private int _x;
private int _y;
private int _z;
private int _heading;
private int _instanceId;
public Location(int x, int y, int z)
{
this(x, y, z, 0, -1);
}
public Location(int x, int y, int z, int heading)
{
this(x, y, z, heading, -1);
}
public Location(L2Object obj)
{
this(obj.getX(), obj.getY(), obj.getZ(), obj.getHeading(), obj.getInstanceId());
}
public Location(int x, int y, int z, int heading, int instanceId)
{
_x = x;
_y = y;
_z = z;
_heading = heading;
_instanceId = instanceId;
}
public Location(StatsSet set)
{
_x = set.getInt("x");
_y = set.getInt("y");
_z = set.getInt("z");
_heading = set.getInt("heading", 0);
}
/**
* Get the x coordinate.
* @return the x coordinate
*/
@Override
public int getX()
{
return _x;
}
/**
* Set the x coordinate.
* @param x the x coordinate
*/
@Override
public void setX(int x)
{
_x = x;
}
/**
* Get the y coordinate.
* @return the y coordinate
*/
@Override
public int getY()
{
return _y;
}
/**
* Set the y coordinate.
* @param y the x coordinate
*/
@Override
public void setY(int y)
{
_y = y;
}
/**
* Get the z coordinate.
* @return the z coordinate
*/
@Override
public int getZ()
{
return _z;
}
/**
* Set the z coordinate.
* @param z the z coordinate
*/
@Override
public void setZ(int z)
{
_z = z;
}
/**
* Set the x, y, z coordinates.
* @param x the x coordinate
* @param y the y coordinate
* @param z the z coordinate
*/
@Override
public void setXYZ(int x, int y, int z)
{
setX(x);
setY(y);
setZ(z);
}
/**
* Set the x, y, z coordinates.
* @param loc The location.
*/
@Override
public void setXYZ(ILocational loc)
{
setXYZ(loc.getX(), loc.getY(), loc.getZ());
}
/**
* Get the heading.
* @return the heading
*/
@Override
public int getHeading()
{
return _heading;
}
/**
* Set the heading.
* @param heading the heading
*/
@Override
public void setHeading(int heading)
{
_heading = heading;
}
/**
* Get the instance Id.
* @return the instance Id
*/
@Override
public int getInstanceId()
{
return _instanceId;
}
/**
* Set the instance Id.
* @param instanceId the instance Id to set
*/
@Override
public void setInstanceId(int instanceId)
{
_instanceId = instanceId;
}
@Override
public IPositionable getLocation()
{
return this;
}
@Override
public void setLocation(Location loc)
{
_x = loc.getX();
_y = loc.getY();
_z = loc.getZ();
_heading = loc.getHeading();
_instanceId = loc.getInstanceId();
}
@Override
public boolean equals(Object obj)
{
if ((obj != null) && (obj instanceof Location))
{
final Location loc = (Location) obj;
return (getX() == loc.getX()) && (getY() == loc.getY()) && (getZ() == loc.getZ()) && (getHeading() == loc.getHeading()) && (getInstanceId() == loc.getInstanceId());
}
return false;
}
@Override
public String toString()
{
return "[" + getClass().getSimpleName() + "] X: " + getX() + " Y: " + getY() + " Z: " + getZ() + " Heading: " + _heading + " InstanceId: " + _instanceId;
}
}

View File

@@ -0,0 +1,116 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.List;
import com.l2jmobius.gameserver.model.interfaces.IIdentifiable;
import com.l2jmobius.gameserver.model.interfaces.INamable;
public class Macro implements IIdentifiable, INamable
{
private int _id;
private final int _icon;
private final String _name;
private final String _descr;
private final String _acronym;
private final List<MacroCmd> _commands;
/**
* Constructor for macros.
* @param id the macro ID
* @param icon the icon ID
* @param name the macro name
* @param descr the macro description
* @param acronym the macro acronym
* @param list the macro command list
*/
public Macro(int id, int icon, String name, String descr, String acronym, List<MacroCmd> list)
{
_id = id;
_icon = icon;
_name = name;
_descr = descr;
_acronym = acronym;
_commands = list;
}
/**
* Gets the marco ID.
* @returns the marco ID
*/
@Override
public int getId()
{
return _id;
}
/**
* Sets the marco ID.
* @param id the marco ID
*/
public void setId(int id)
{
_id = id;
}
/**
* Gets the macro icon ID.
* @return the icon
*/
public int getIcon()
{
return _icon;
}
/**
* Gets the macro name.
* @return the name
*/
@Override
public String getName()
{
return _name;
}
/**
* Gets the macro description.
* @return the description
*/
public String getDescr()
{
return _descr;
}
/**
* Gets the macro acronym.
* @return the acronym
*/
public String getAcronym()
{
return _acronym;
}
/**
* Gets the macro command list.
* @return the macro command list
*/
public List<MacroCmd> getCommands()
{
return _commands;
}
}

View File

@@ -0,0 +1,86 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import com.l2jmobius.gameserver.enums.MacroType;
/**
* Macro Cmd DTO.
* @author Zoey76
*/
public class MacroCmd
{
private final int _entry;
private final MacroType _type;
private final int _d1; // skill_id or page for shortcuts
private final int _d2; // shortcut
private final String _cmd;
public MacroCmd(int entry, MacroType type, int d1, int d2, String cmd)
{
_entry = entry;
_type = type;
_d1 = d1;
_d2 = d2;
_cmd = cmd;
}
/**
* Gets the entry index.
* @return the entry index
*/
public int getEntry()
{
return _entry;
}
/**
* Gets the macro type.
* @return the macro type
*/
public MacroType getType()
{
return _type;
}
/**
* Gets the skill ID, item ID, page ID, depending on the marco use.
* @return the first value
*/
public int getD1()
{
return _d1;
}
/**
* Gets the skill level, shortcut ID, depending on the marco use.
* @return the second value
*/
public int getD2()
{
return _d2;
}
/**
* Gets the command.
* @return the command
*/
public String getCmd()
{
return _cmd;
}
}

View File

@@ -0,0 +1,224 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
import com.l2jmobius.gameserver.enums.MacroType;
import com.l2jmobius.gameserver.enums.MacroUpdateType;
import com.l2jmobius.gameserver.enums.ShortcutType;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.interfaces.IRestorable;
import com.l2jmobius.gameserver.network.serverpackets.SendMacroList;
import com.l2jmobius.util.StringUtil;
public class MacroList implements IRestorable
{
private static final Logger _log = Logger.getLogger(MacroList.class.getName());
private final L2PcInstance _owner;
private int _macroId;
private final Map<Integer, Macro> _macroses = Collections.synchronizedMap(new LinkedHashMap<Integer, Macro>());
public MacroList(L2PcInstance owner)
{
_owner = owner;
_macroId = 1000;
}
public Map<Integer, Macro> getAllMacroses()
{
return _macroses;
}
public void registerMacro(Macro macro)
{
MacroUpdateType updateType = MacroUpdateType.ADD;
if (macro.getId() == 0)
{
macro.setId(_macroId++);
while (_macroses.containsKey(macro.getId()))
{
macro.setId(_macroId++);
}
_macroses.put(macro.getId(), macro);
registerMacroInDb(macro);
}
else
{
updateType = MacroUpdateType.MODIFY;
final Macro old = _macroses.put(macro.getId(), macro);
if (old != null)
{
deleteMacroFromDb(old);
}
registerMacroInDb(macro);
}
_owner.sendPacket(new SendMacroList(1, macro, updateType));
}
public void deleteMacro(int id)
{
final Macro removed = _macroses.remove(id);
if (removed != null)
{
deleteMacroFromDb(removed);
}
final Shortcut[] allShortCuts = _owner.getAllShortCuts();
for (Shortcut sc : allShortCuts)
{
if ((sc.getId() == id) && (sc.getType() == ShortcutType.MACRO))
{
_owner.deleteShortCut(sc.getSlot(), sc.getPage());
}
}
_owner.sendPacket(new SendMacroList(0, removed, MacroUpdateType.DELETE));
}
public void sendAllMacros()
{
final Collection<Macro> allMacros = _macroses.values();
final int count = allMacros.size();
synchronized (_macroses)
{
if (allMacros.isEmpty())
{
_owner.sendPacket(new SendMacroList(0, null, MacroUpdateType.LIST));
}
else
{
for (Macro m : allMacros)
{
_owner.sendPacket(new SendMacroList(count, m, MacroUpdateType.LIST));
}
}
}
}
private void registerMacroInDb(Macro macro)
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO character_macroses (charId,id,icon,name,descr,acronym,commands) values(?,?,?,?,?,?,?)"))
{
ps.setInt(1, _owner.getObjectId());
ps.setInt(2, macro.getId());
ps.setInt(3, macro.getIcon());
ps.setString(4, macro.getName());
ps.setString(5, macro.getDescr());
ps.setString(6, macro.getAcronym());
final StringBuilder sb = new StringBuilder(300);
for (MacroCmd cmd : macro.getCommands())
{
StringUtil.append(sb, String.valueOf(cmd.getType().ordinal()), ",", String.valueOf(cmd.getD1()), ",", String.valueOf(cmd.getD2()));
if ((cmd.getCmd() != null) && (cmd.getCmd().length() > 0))
{
StringUtil.append(sb, ",", cmd.getCmd());
}
sb.append(';');
}
if (sb.length() > 255)
{
sb.setLength(255);
}
ps.setString(7, sb.toString());
ps.execute();
}
catch (Exception e)
{
_log.log(Level.WARNING, "could not store macro:", e);
}
}
private void deleteMacroFromDb(Macro macro)
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_macroses WHERE charId=? AND id=?"))
{
ps.setInt(1, _owner.getObjectId());
ps.setInt(2, macro.getId());
ps.execute();
}
catch (Exception e)
{
_log.log(Level.WARNING, "could not delete macro:", e);
}
}
@Override
public boolean restoreMe()
{
_macroses.clear();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT charId, id, icon, name, descr, acronym, commands FROM character_macroses WHERE charId=?"))
{
ps.setInt(1, _owner.getObjectId());
try (ResultSet rset = ps.executeQuery())
{
while (rset.next())
{
final int id = rset.getInt("id");
final int icon = rset.getInt("icon");
final String name = rset.getString("name");
final String descr = rset.getString("descr");
final String acronym = rset.getString("acronym");
final List<MacroCmd> commands = new ArrayList<>();
final StringTokenizer st1 = new StringTokenizer(rset.getString("commands"), ";");
while (st1.hasMoreTokens())
{
final StringTokenizer st = new StringTokenizer(st1.nextToken(), ",");
if (st.countTokens() < 3)
{
continue;
}
final MacroType type = MacroType.values()[Integer.parseInt(st.nextToken())];
final int d1 = Integer.parseInt(st.nextToken());
final int d2 = Integer.parseInt(st.nextToken());
String cmd = "";
if (st.hasMoreTokens())
{
cmd = st.nextToken();
}
commands.add(new MacroCmd(commands.size(), type, d1, d2, cmd));
}
_macroses.put(id, new Macro(id, icon, name, descr, acronym, commands));
}
}
}
catch (Exception e)
{
_log.log(Level.WARNING, "could not store shortcuts:", e);
return false;
}
return true;
}
}

View File

@@ -0,0 +1,424 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.ai.L2ControllableMobAI;
import com.l2jmobius.gameserver.datatables.SpawnTable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2ControllableMobInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jmobius.util.Rnd;
/**
* @author littlecrow
*/
public final class MobGroup
{
private final L2NpcTemplate _npcTemplate;
private final int _groupId;
private final int _maxMobCount;
private List<L2ControllableMobInstance> _mobs;
public MobGroup(int groupId, L2NpcTemplate npcTemplate, int maxMobCount)
{
_groupId = groupId;
_npcTemplate = npcTemplate;
_maxMobCount = maxMobCount;
}
public int getActiveMobCount()
{
return getMobs().size();
}
public int getGroupId()
{
return _groupId;
}
public int getMaxMobCount()
{
return _maxMobCount;
}
public List<L2ControllableMobInstance> getMobs()
{
if (_mobs == null)
{
_mobs = new CopyOnWriteArrayList<>();
}
return _mobs;
}
public String getStatus()
{
try
{
final L2ControllableMobAI mobGroupAI = (L2ControllableMobAI) getMobs().get(0).getAI();
switch (mobGroupAI.getAlternateAI())
{
case L2ControllableMobAI.AI_NORMAL:
{
return "Idle";
}
case L2ControllableMobAI.AI_FORCEATTACK:
{
return "Force Attacking";
}
case L2ControllableMobAI.AI_FOLLOW:
{
return "Following";
}
case L2ControllableMobAI.AI_CAST:
{
return "Casting";
}
case L2ControllableMobAI.AI_ATTACK_GROUP:
{
return "Attacking Group";
}
default:
{
return "Idle";
}
}
}
catch (Exception e)
{
return "Unspawned";
}
}
public L2NpcTemplate getTemplate()
{
return _npcTemplate;
}
public boolean isGroupMember(L2ControllableMobInstance mobInst)
{
for (L2ControllableMobInstance groupMember : getMobs())
{
if (groupMember == null)
{
continue;
}
if (groupMember.getObjectId() == mobInst.getObjectId())
{
return true;
}
}
return false;
}
public void spawnGroup(int x, int y, int z)
{
if (getActiveMobCount() > 0)
{
return;
}
try
{
for (int i = 0; i < getMaxMobCount(); i++)
{
final L2GroupSpawn spawn = new L2GroupSpawn(getTemplate());
final int signX = (Rnd.nextInt(2) == 0) ? -1 : 1;
final int signY = (Rnd.nextInt(2) == 0) ? -1 : 1;
final int randX = Rnd.nextInt(MobGroupTable.RANDOM_RANGE);
final int randY = Rnd.nextInt(MobGroupTable.RANDOM_RANGE);
spawn.setX(x + (signX * randX));
spawn.setY(y + (signY * randY));
spawn.setZ(z);
spawn.stopRespawn();
SpawnTable.getInstance().addNewSpawn(spawn, false);
getMobs().add((L2ControllableMobInstance) spawn.doGroupSpawn());
}
}
catch (ClassNotFoundException e)
{
}
catch (NoSuchMethodException e2)
{
}
}
public void spawnGroup(L2PcInstance activeChar)
{
spawnGroup(activeChar.getX(), activeChar.getY(), activeChar.getZ());
}
public void teleportGroup(L2PcInstance player)
{
removeDead();
for (L2ControllableMobInstance mobInst : getMobs())
{
if (mobInst == null)
{
continue;
}
if (!mobInst.isDead())
{
final int x = player.getX() + Rnd.nextInt(50);
final int y = player.getY() + Rnd.nextInt(50);
mobInst.teleToLocation(new Location(x, y, player.getZ()), true);
final L2ControllableMobAI ai = (L2ControllableMobAI) mobInst.getAI();
ai.follow(player);
}
}
}
public L2ControllableMobInstance getRandomMob()
{
removeDead();
if (getActiveMobCount() == 0)
{
return null;
}
final int choice = Rnd.nextInt(getActiveMobCount());
return getMobs().get(choice);
}
public void unspawnGroup()
{
removeDead();
if (getActiveMobCount() == 0)
{
return;
}
for (L2ControllableMobInstance mobInst : getMobs())
{
if (mobInst == null)
{
continue;
}
if (!mobInst.isDead())
{
mobInst.deleteMe();
}
SpawnTable.getInstance().deleteSpawn(mobInst.getSpawn(), false);
}
getMobs().clear();
}
public void killGroup(L2PcInstance activeChar)
{
removeDead();
for (L2ControllableMobInstance mobInst : getMobs())
{
if (mobInst == null)
{
continue;
}
if (!mobInst.isDead())
{
mobInst.reduceCurrentHp(mobInst.getMaxHp() + 1, activeChar, null);
}
SpawnTable.getInstance().deleteSpawn(mobInst.getSpawn(), false);
}
getMobs().clear();
}
public void setAttackRandom()
{
removeDead();
for (L2ControllableMobInstance mobInst : getMobs())
{
if (mobInst == null)
{
continue;
}
final L2ControllableMobAI ai = (L2ControllableMobAI) mobInst.getAI();
ai.setAlternateAI(L2ControllableMobAI.AI_NORMAL);
ai.setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
}
}
public void setAttackTarget(L2Character target)
{
removeDead();
for (L2ControllableMobInstance mobInst : getMobs())
{
if (mobInst == null)
{
continue;
}
final L2ControllableMobAI ai = (L2ControllableMobAI) mobInst.getAI();
ai.forceAttack(target);
}
}
public void setIdleMode()
{
removeDead();
for (L2ControllableMobInstance mobInst : getMobs())
{
if (mobInst == null)
{
continue;
}
final L2ControllableMobAI ai = (L2ControllableMobAI) mobInst.getAI();
ai.stop();
}
}
public void returnGroup(L2Character activeChar)
{
setIdleMode();
for (L2ControllableMobInstance mobInst : getMobs())
{
if (mobInst == null)
{
continue;
}
final int signX = (Rnd.nextInt(2) == 0) ? -1 : 1;
final int signY = (Rnd.nextInt(2) == 0) ? -1 : 1;
final int randX = Rnd.nextInt(MobGroupTable.RANDOM_RANGE);
final int randY = Rnd.nextInt(MobGroupTable.RANDOM_RANGE);
final L2ControllableMobAI ai = (L2ControllableMobAI) mobInst.getAI();
ai.move(activeChar.getX() + (signX * randX), activeChar.getY() + (signY * randY), activeChar.getZ());
}
}
public void setFollowMode(L2Character character)
{
removeDead();
for (L2ControllableMobInstance mobInst : getMobs())
{
if (mobInst == null)
{
continue;
}
final L2ControllableMobAI ai = (L2ControllableMobAI) mobInst.getAI();
ai.follow(character);
}
}
public void setCastMode()
{
removeDead();
for (L2ControllableMobInstance mobInst : getMobs())
{
if (mobInst == null)
{
continue;
}
final L2ControllableMobAI ai = (L2ControllableMobAI) mobInst.getAI();
ai.setAlternateAI(L2ControllableMobAI.AI_CAST);
}
}
public void setNoMoveMode(boolean enabled)
{
removeDead();
for (L2ControllableMobInstance mobInst : getMobs())
{
if (mobInst == null)
{
continue;
}
final L2ControllableMobAI ai = (L2ControllableMobAI) mobInst.getAI();
ai.setNotMoving(enabled);
}
}
protected void removeDead()
{
final List<L2ControllableMobInstance> deadMobs = new LinkedList<>();
for (L2ControllableMobInstance mobInst : getMobs())
{
if ((mobInst != null) && mobInst.isDead())
{
deadMobs.add(mobInst);
}
}
getMobs().removeAll(deadMobs);
}
public void setInvul(boolean invulState)
{
removeDead();
for (L2ControllableMobInstance mobInst : getMobs())
{
if (mobInst != null)
{
mobInst.setInvul(invulState);
}
}
}
public void setAttackGroup(MobGroup otherGrp)
{
removeDead();
for (L2ControllableMobInstance mobInst : getMobs())
{
if (mobInst == null)
{
continue;
}
final L2ControllableMobAI ai = (L2ControllableMobAI) mobInst.getAI();
ai.forceAttackGroup(otherGrp);
ai.setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
}
}
}

View File

@@ -0,0 +1,86 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import com.l2jmobius.gameserver.model.actor.instance.L2ControllableMobInstance;
/**
* @author littlecrow
*/
public class MobGroupTable
{
private final Map<Integer, MobGroup> _groupMap;
public static final int FOLLOW_RANGE = 300;
public static final int RANDOM_RANGE = 300;
protected MobGroupTable()
{
_groupMap = new ConcurrentHashMap<>();
}
public static MobGroupTable getInstance()
{
return SingletonHolder._instance;
}
public void addGroup(int groupKey, MobGroup group)
{
_groupMap.put(groupKey, group);
}
public MobGroup getGroup(int groupKey)
{
return _groupMap.get(groupKey);
}
public int getGroupCount()
{
return _groupMap.size();
}
public MobGroup getGroupForMob(L2ControllableMobInstance mobInst)
{
for (MobGroup mobGroup : _groupMap.values())
{
if (mobGroup.isGroupMember(mobInst))
{
return mobGroup;
}
}
return null;
}
public MobGroup[] getGroups()
{
return _groupMap.values().toArray(new MobGroup[getGroupCount()]);
}
public boolean removeGroup(int groupKey)
{
return (_groupMap.remove(groupKey) != null);
}
private static class SingletonHolder
{
protected static final MobGroupTable _instance = new MobGroupTable();
}
}

View File

@@ -0,0 +1,49 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
/**
* @author UnAfraid
*/
public class PageResult
{
private final int _pages;
private final StringBuilder _pagerTemplate;
private final StringBuilder _bodyTemplate;
public PageResult(int pages, StringBuilder pagerTemplate, StringBuilder bodyTemplate)
{
_pages = pages;
_pagerTemplate = pagerTemplate;
_bodyTemplate = bodyTemplate;
}
public int getPages()
{
return _pages;
}
public StringBuilder getPagerTemplate()
{
return _pagerTemplate;
}
public StringBuilder getBodyTemplate()
{
return _bodyTemplate;
}
}

View File

@@ -0,0 +1,203 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.gameserver.instancemanager.MapRegionManager;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.interfaces.IIdentifiable;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.ExManagePartyRoomMember;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* @author Gnacik
*/
public class PartyMatchRoom implements IIdentifiable
{
private final int _id;
private String _title;
private int _loot;
private int _minlvl;
private int _maxlvl;
private int _maxmem;
private final List<L2PcInstance> _members = new ArrayList<>();
public PartyMatchRoom(int id, String title, int loot, int minlvl, int maxlvl, int maxmem, L2PcInstance owner)
{
_id = id;
_title = title;
_loot = loot;
_minlvl = minlvl;
_maxlvl = maxlvl;
_maxmem = maxmem;
_members.add(owner);
}
public List<L2PcInstance> getPartyMembers()
{
return _members;
}
public void addMember(L2PcInstance player)
{
_members.add(player);
}
public void deleteMember(L2PcInstance player)
{
if (player != getOwner())
{
_members.remove(player);
notifyMembersAboutExit(player);
}
else if (_members.size() == 1)
{
PartyMatchRoomList.getInstance().deleteRoom(_id);
}
else
{
changeLeader(_members.get(1));
deleteMember(player);
}
}
public void notifyMembersAboutExit(L2PcInstance player)
{
for (L2PcInstance _member : _members)
{
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_LEFT_THE_PARTY_ROOM);
sm.addCharName(player);
_member.sendPacket(sm);
_member.sendPacket(new ExManagePartyRoomMember(player, this, 2));
}
}
public void changeLeader(L2PcInstance newLeader)
{
// Get current leader
final L2PcInstance oldLeader = _members.get(0);
// Remove new leader
_members.remove(newLeader);
// Move him to first position
_members.set(0, newLeader);
// Add old leader as normal member
_members.add(oldLeader);
// Broadcast change
for (L2PcInstance member : _members)
{
member.sendPacket(new ExManagePartyRoomMember(newLeader, this, 1));
member.sendPacket(new ExManagePartyRoomMember(oldLeader, this, 1));
member.sendPacket(SystemMessageId.THE_LEADER_OF_THE_PARTY_ROOM_HAS_CHANGED);
}
}
@Override
public int getId()
{
return _id;
}
public int getLootType()
{
return _loot;
}
public int getMinLvl()
{
return _minlvl;
}
public int getMaxLvl()
{
return _maxlvl;
}
/**
* <ul>
* <li>1 : Talking Island</li>
* <li>2 : Gludio</li>
* <li>3 : Dark Elven Ter.</li>
* <li>4 : Elven Territory</li>
* <li>5 : Dion</li>
* <li>6 : Giran</li>
* <li>7 : Neutral Zone</li>
* <li>8 : Lyonn</li>
* <li>9 : Schuttgart</li>
* <li>10 : Oren</li>
* <li>11 : Hunters Village</li>
* <li>12 : Innadril</li>
* <li>13 : Aden</li>
* <li>14 : Rune</li>
* <li>15 : Goddard</li>
* </ul>
* @return the id
*/
public int getLocation()
{
return MapRegionManager.getInstance().getMapRegion(_members.get(0)).getBbs();
}
public int getMembers()
{
return _members.size();
}
public int getMaxMembers()
{
return _maxmem;
}
public String getTitle()
{
return _title;
}
public L2PcInstance getOwner()
{
return _members.get(0);
}
/* SET */
public void setMinLvl(int minlvl)
{
_minlvl = minlvl;
}
public void setMaxLvl(int maxlvl)
{
_maxlvl = maxlvl;
}
public void setLootType(int loot)
{
_loot = loot;
}
public void setMaxMembers(int maxmem)
{
_maxmem = maxmem;
}
public void setTitle(String title)
{
_title = title;
}
}

View File

@@ -0,0 +1,123 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.ExClosePartyRoom;
/**
* @author Gnacik
*/
public class PartyMatchRoomList
{
private int _maxid = 1;
private final Map<Integer, PartyMatchRoom> _rooms;
protected PartyMatchRoomList()
{
_rooms = new ConcurrentHashMap<>();
}
public synchronized void addPartyMatchRoom(int id, PartyMatchRoom room)
{
_rooms.put(id, room);
_maxid++;
}
public void deleteRoom(int id)
{
for (L2PcInstance _member : getRoom(id).getPartyMembers())
{
if (_member == null)
{
continue;
}
_member.sendPacket(new ExClosePartyRoom());
_member.sendPacket(SystemMessageId.THE_PARTY_ROOM_HAS_BEEN_DISBANDED);
_member.setPartyRoom(0);
// _member.setPartyMatching(0);
_member.broadcastUserInfo();
}
_rooms.remove(id);
}
public PartyMatchRoom getRoom(int id)
{
return _rooms.get(id);
}
public PartyMatchRoom[] getRooms()
{
return _rooms.values().toArray(new PartyMatchRoom[_rooms.size()]);
}
public int getPartyMatchRoomCount()
{
return _rooms.size();
}
public int getMaxId()
{
return _maxid;
}
public PartyMatchRoom getPlayerRoom(L2PcInstance player)
{
for (PartyMatchRoom _room : _rooms.values())
{
for (L2PcInstance member : _room.getPartyMembers())
{
if (member.equals(player))
{
return _room;
}
}
}
return null;
}
public int getPlayerRoomId(L2PcInstance player)
{
for (PartyMatchRoom _room : _rooms.values())
{
for (L2PcInstance member : _room.getPartyMembers())
{
if (member.equals(player))
{
return _room.getId();
}
}
}
return -1;
}
public static PartyMatchRoomList getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final PartyMatchRoomList _instance = new PartyMatchRoomList();
}
}

View File

@@ -0,0 +1,68 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/**
* @author Gnacik
*/
public class PartyMatchWaitingList
{
private final List<L2PcInstance> _members;
protected PartyMatchWaitingList()
{
_members = new CopyOnWriteArrayList<>();
}
public void addPlayer(L2PcInstance player)
{
// player.setPartyWait(1);
if (!_members.contains(player))
{
_members.add(player);
}
}
public void removePlayer(L2PcInstance player)
{
// player.setPartyWait(0);
if (_members.contains(player))
{
_members.remove(player);
}
}
public List<L2PcInstance> getPlayers()
{
return _members;
}
public static PartyMatchWaitingList getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final PartyMatchWaitingList _instance = new PartyMatchWaitingList();
}
}

View File

@@ -0,0 +1,82 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
/**
* @author UnAfraid
*/
public enum PcCondOverride
{
MAX_STATS_VALUE(0, "Overrides maximum states conditions"),
ITEM_CONDITIONS(1, "Overrides item usage conditions"),
SKILL_CONDITIONS(2, "Overrides skill usage conditions"),
ZONE_CONDITIONS(3, "Overrides zone conditions"),
CASTLE_CONDITIONS(4, "Overrides castle conditions"),
FORTRESS_CONDITIONS(5, "Overrides fortress conditions"),
CLANHALL_CONDITIONS(6, "Overrides clan hall conditions"),
FLOOD_CONDITIONS(7, "Overrides floods conditions"),
CHAT_CONDITIONS(8, "Overrides chat conditions"),
INSTANCE_CONDITIONS(9, "Overrides instance conditions"),
QUEST_CONDITIONS(10, "Overrides quest conditions"),
DEATH_PENALTY(11, "Overrides death penalty conditions"),
DESTROY_ALL_ITEMS(12, "Overrides item destroy conditions"),
SEE_ALL_PLAYERS(13, "Overrides the conditions to see hidden players"),
TARGET_ALL(14, "Overrides target conditions"),
DROP_ALL_ITEMS(15, "Overrides item drop conditions"),
VULNERABLE_ALL_PLAYERS(16, "Overrides the conditions to invulnerable players");
private final int _mask;
private final String _descr;
private PcCondOverride(int id, String descr)
{
_mask = 1 << id;
_descr = descr;
}
public int getMask()
{
return _mask;
}
public String getDescription()
{
return _descr;
}
public static PcCondOverride getCondOverride(int ordinal)
{
try
{
return values()[ordinal];
}
catch (Exception e)
{
return null;
}
}
public static long getAllExceptionsMask()
{
long result = 0L;
for (PcCondOverride ex : values())
{
result |= ex.getMask();
}
return result;
}
}

View File

@@ -0,0 +1,178 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import com.l2jmobius.gameserver.enums.PetitionState;
import com.l2jmobius.gameserver.enums.PetitionType;
import com.l2jmobius.gameserver.idfactory.IdFactory;
import com.l2jmobius.gameserver.instancemanager.PetitionManager;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
import com.l2jmobius.gameserver.network.serverpackets.PetitionVotePacket;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* Petition
* @author xban1x
*/
public final class Petition
{
private final long _submitTime = System.currentTimeMillis();
private final int _id;
private final PetitionType _type;
private PetitionState _state = PetitionState.PENDING;
private final String _content;
private final List<CreatureSay> _messageLog = new CopyOnWriteArrayList<>();
private final L2PcInstance _petitioner;
private L2PcInstance _responder;
public Petition(L2PcInstance petitioner, String petitionText, int petitionType)
{
_id = IdFactory.getInstance().getNextId();
_type = PetitionType.values()[--petitionType];
_content = petitionText;
_petitioner = petitioner;
}
public boolean addLogMessage(CreatureSay cs)
{
return _messageLog.add(cs);
}
public List<CreatureSay> getLogMessages()
{
return _messageLog;
}
public boolean endPetitionConsultation(PetitionState endState)
{
setState(endState);
if ((getResponder() != null) && getResponder().isOnline())
{
if (endState == PetitionState.RESPONDER_REJECT)
{
getPetitioner().sendMessage("Your petition was rejected. Please try again later.");
}
else
{
// Ending petition consultation with <Player>.
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.PETITION_CONSULTATION_WITH_C1_HAS_ENDED);
sm.addString(getPetitioner().getName());
getResponder().sendPacket(sm);
if (endState == PetitionState.PETITIONER_CANCEL)
{
// Receipt No. <ID> petition cancelled.
sm = SystemMessage.getSystemMessage(SystemMessageId.RECEIPT_NO_S1_PETITION_CANCELLED);
sm.addInt(getId());
getResponder().sendPacket(sm);
}
}
}
// End petition consultation and inform them, if they are still online. And if petitioner is online, enable Evaluation button
if ((getPetitioner() != null) && getPetitioner().isOnline())
{
getPetitioner().sendPacket(SystemMessageId.THIS_ENDS_THE_GM_PETITION_CONSULTATION_NPLEASE_GIVE_US_FEEDBACK_ON_THE_PETITION_SERVICE);
getPetitioner().sendPacket(PetitionVotePacket.STATIC_PACKET);
}
PetitionManager.getInstance().getCompletedPetitions().put(getId(), this);
return (PetitionManager.getInstance().getPendingPetitions().remove(getId()) != null);
}
public String getContent()
{
return _content;
}
public int getId()
{
return _id;
}
public L2PcInstance getPetitioner()
{
return _petitioner;
}
public L2PcInstance getResponder()
{
return _responder;
}
public long getSubmitTime()
{
return _submitTime;
}
public PetitionState getState()
{
return _state;
}
public String getTypeAsString()
{
return _type.toString().replace("_", " ");
}
public void sendPetitionerPacket(L2GameServerPacket responsePacket)
{
if ((getPetitioner() == null) || !getPetitioner().isOnline())
{
// Allows petitioners to see the results of their petition when
// they log back into the game.
// endPetitionConsultation(PetitionState.Petitioner_Missing);
return;
}
getPetitioner().sendPacket(responsePacket);
}
public void sendResponderPacket(L2GameServerPacket responsePacket)
{
if ((getResponder() == null) || !getResponder().isOnline())
{
endPetitionConsultation(PetitionState.RESPONDER_MISSING);
return;
}
getResponder().sendPacket(responsePacket);
}
public void setState(PetitionState state)
{
_state = state;
}
public void setResponder(L2PcInstance respondingAdmin)
{
if (getResponder() != null)
{
return;
}
_responder = respondingAdmin;
}
}

View File

@@ -0,0 +1,79 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.concurrent.atomic.AtomicLong;
/**
* @author xban1x
*/
public class SeedProduction
{
private final int _seedId;
private final long _price;
private final long _startAmount;
private final AtomicLong _amount;
public SeedProduction(int id, long amount, long price, long startAmount)
{
_seedId = id;
_amount = new AtomicLong(amount);
_price = price;
_startAmount = startAmount;
}
public final int getId()
{
return _seedId;
}
public final long getAmount()
{
return _amount.get();
}
public final long getPrice()
{
return _price;
}
public final long getStartAmount()
{
return _startAmount;
}
public final void setAmount(long amount)
{
_amount.set(amount);
}
public final boolean decreaseAmount(long val)
{
long current, next;
do
{
current = _amount.get();
next = current - val;
if (next < 0)
{
return false;
}
}
while (!_amount.compareAndSet(current, next));
return true;
}
}

View File

@@ -0,0 +1,295 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Map;
import java.util.TreeMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
import com.l2jmobius.gameserver.enums.ShortcutType;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.interfaces.IRestorable;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.items.type.EtcItemType;
import com.l2jmobius.gameserver.network.serverpackets.ExAutoSoulShot;
import com.l2jmobius.gameserver.network.serverpackets.ShortCutInit;
import com.l2jmobius.gameserver.network.serverpackets.ShortCutRegister;
public class ShortCuts implements IRestorable
{
private static Logger _log = Logger.getLogger(ShortCuts.class.getName());
private static final int MAX_SHORTCUTS_PER_BAR = 12;
private final L2PcInstance _owner;
private final Map<Integer, Shortcut> _shortCuts = new TreeMap<>();
public ShortCuts(L2PcInstance owner)
{
_owner = owner;
}
public Shortcut[] getAllShortCuts()
{
return _shortCuts.values().toArray(new Shortcut[_shortCuts.values().size()]);
}
public Shortcut getShortCut(int slot, int page)
{
Shortcut sc = _shortCuts.get(slot + (page * MAX_SHORTCUTS_PER_BAR));
// Verify shortcut
if ((sc != null) && (sc.getType() == ShortcutType.ITEM))
{
if (_owner.getInventory().getItemByObjectId(sc.getId()) == null)
{
deleteShortCut(sc.getSlot(), sc.getPage());
sc = null;
}
}
return sc;
}
public synchronized void registerShortCut(Shortcut shortcut)
{
// Verify shortcut
if (shortcut.getType() == ShortcutType.ITEM)
{
final L2ItemInstance item = _owner.getInventory().getItemByObjectId(shortcut.getId());
if (item == null)
{
return;
}
shortcut.setSharedReuseGroup(item.getSharedReuseGroup());
}
final Shortcut oldShortCut = _shortCuts.put(shortcut.getSlot() + (shortcut.getPage() * MAX_SHORTCUTS_PER_BAR), shortcut);
registerShortCutInDb(shortcut, oldShortCut);
}
private void registerShortCutInDb(Shortcut shortcut, Shortcut oldShortCut)
{
if (oldShortCut != null)
{
deleteShortCutFromDb(oldShortCut);
}
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("REPLACE INTO character_shortcuts (charId,slot,page,type,shortcut_id,level,class_index) values(?,?,?,?,?,?,?)"))
{
ps.setInt(1, _owner.getObjectId());
ps.setInt(2, shortcut.getSlot());
ps.setInt(3, shortcut.getPage());
ps.setInt(4, shortcut.getType().ordinal());
ps.setInt(5, shortcut.getId());
ps.setInt(6, shortcut.getLevel());
ps.setInt(7, _owner.getClassIndex());
ps.execute();
}
catch (Exception e)
{
_log.log(Level.WARNING, "Could not store character shortcut: " + e.getMessage(), e);
}
}
/**
* @param slot
* @param page
*/
public synchronized void deleteShortCut(int slot, int page)
{
final Shortcut old = _shortCuts.remove(slot + (page * MAX_SHORTCUTS_PER_BAR));
if ((old == null) || (_owner == null))
{
return;
}
deleteShortCutFromDb(old);
if (old.getType() == ShortcutType.ITEM)
{
final L2ItemInstance item = _owner.getInventory().getItemByObjectId(old.getId());
if ((item != null) && (item.getItemType() == EtcItemType.SHOT))
{
if (_owner.removeAutoSoulShot(item.getId()))
{
switch (item.getEtcItem().getDefaultAction())
{
case SOULSHOT:
case FISHINGSHOT:
{
_owner.sendPacket(new ExAutoSoulShot(item.getId(), 0, 0));
break;
}
case SPIRITSHOT:
{
_owner.sendPacket(new ExAutoSoulShot(item.getId(), 0, 1));
break;
}
case SUMMON_SOULSHOT:
{
_owner.sendPacket(new ExAutoSoulShot(item.getId(), 0, 2));
break;
}
case SUMMON_SPIRITSHOT:
{
_owner.sendPacket(new ExAutoSoulShot(item.getId(), 0, 3));
break;
}
}
}
}
}
_owner.sendPacket(new ShortCutInit(_owner));
for (int shotId : _owner.getAutoSoulShot())
{
final L2ItemInstance item = _owner.getInventory().getItemByObjectId(shotId);
if ((item == null) || (item.getEtcItem() == null) || (item.getEtcItem().getDefaultAction() == null))
{
continue;
}
switch (item.getEtcItem().getDefaultAction())
{
case SOULSHOT:
case FISHINGSHOT:
{
_owner.sendPacket(new ExAutoSoulShot(shotId, 1, 0));
break;
}
case SPIRITSHOT:
{
_owner.sendPacket(new ExAutoSoulShot(shotId, 1, 1));
break;
}
case SUMMON_SOULSHOT:
{
_owner.sendPacket(new ExAutoSoulShot(shotId, 1, 2));
break;
}
case SUMMON_SPIRITSHOT:
{
_owner.sendPacket(new ExAutoSoulShot(shotId, 1, 3));
break;
}
}
}
}
public synchronized void deleteShortCutByObjectId(int objectId)
{
for (Shortcut shortcut : _shortCuts.values())
{
if ((shortcut.getType() == ShortcutType.ITEM) && (shortcut.getId() == objectId))
{
deleteShortCut(shortcut.getSlot(), shortcut.getPage());
break;
}
}
}
/**
* @param shortcut
*/
private void deleteShortCutFromDb(Shortcut shortcut)
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_shortcuts WHERE charId=? AND slot=? AND page=? AND class_index=?"))
{
ps.setInt(1, _owner.getObjectId());
ps.setInt(2, shortcut.getSlot());
ps.setInt(3, shortcut.getPage());
ps.setInt(4, _owner.getClassIndex());
ps.execute();
}
catch (Exception e)
{
_log.log(Level.WARNING, "Could not delete character shortcut: " + e.getMessage(), e);
}
}
@Override
public boolean restoreMe()
{
_shortCuts.clear();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("SELECT charId, slot, page, type, shortcut_id, level FROM character_shortcuts WHERE charId=? AND class_index=?"))
{
statement.setInt(1, _owner.getObjectId());
statement.setInt(2, _owner.getClassIndex());
try (ResultSet rset = statement.executeQuery())
{
while (rset.next())
{
final int slot = rset.getInt("slot");
final int page = rset.getInt("page");
final int type = rset.getInt("type");
final int id = rset.getInt("shortcut_id");
final int level = rset.getInt("level");
_shortCuts.put(slot + (page * MAX_SHORTCUTS_PER_BAR), new Shortcut(slot, page, ShortcutType.values()[type], id, level, 1));
}
}
}
catch (Exception e)
{
_log.log(Level.WARNING, "Could not restore character shortcuts: " + e.getMessage(), e);
return false;
}
// Verify shortcuts
for (Shortcut sc : getAllShortCuts())
{
if (sc.getType() == ShortcutType.ITEM)
{
final L2ItemInstance item = _owner.getInventory().getItemByObjectId(sc.getId());
if (item == null)
{
deleteShortCut(sc.getSlot(), sc.getPage());
}
else if (item.isEtcItem())
{
sc.setSharedReuseGroup(item.getEtcItem().getSharedReuseGroup());
}
}
}
return true;
}
/**
* Updates the shortcut bars with the new skill.
* @param skillId the skill Id to search and update.
* @param skillLevel the skill level to update.
*/
public synchronized void updateShortCuts(int skillId, int skillLevel)
{
// Update all the shortcuts for this skill
for (Shortcut sc : _shortCuts.values())
{
if ((sc.getId() == skillId) && (sc.getType() == ShortcutType.SKILL))
{
final Shortcut newsc = new Shortcut(sc.getSlot(), sc.getPage(), sc.getType(), sc.getId(), skillLevel, 1);
_owner.sendPacket(new ShortCutRegister(newsc));
_owner.registerShortCut(newsc);
}
}
}
}

View File

@@ -0,0 +1,123 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import com.l2jmobius.gameserver.enums.ShortcutType;
/**
* Shortcut DTO.
* @author Zoey76
*/
public class Shortcut
{
/** Slot from 0 to 11. */
private final int _slot;
/** Page from 0 to 9. */
private final int _page;
/** Type: item, skill, action, macro, recipe, bookmark. */
private final ShortcutType _type;
/** Shortcut ID. */
private final int _id;
/** Shortcut level (skills). */
private final int _level;
/** Character type: 1 player, 2 summon. */
private final int _characterType;
/** Shared reuse group. */
private int _sharedReuseGroup = -1;
public Shortcut(int slot, int page, ShortcutType type, int id, int level, int characterType)
{
_slot = slot;
_page = page;
_type = type;
_id = id;
_level = level;
_characterType = characterType;
}
/**
* Gets the shortcut ID.
* @return the ID
*/
public int getId()
{
return _id;
}
/**
* Gets the shortcut level.
* @return the level
*/
public int getLevel()
{
return _level;
}
/**
* Gets the shortcut page.
* @return the page
*/
public int getPage()
{
return _page;
}
/**
* Gets the shortcut slot.
* @return the slot
*/
public int getSlot()
{
return _slot;
}
/**
* Gets the shortcut type.
* @return the type
*/
public ShortcutType getType()
{
return _type;
}
/**
* Gets the shortcut character type.
* @return the character type
*/
public int getCharacterType()
{
return _characterType;
}
/**
* Gets the shared reuse group.
* @return the shared reuse group
*/
public int getSharedReuseGroup()
{
return _sharedReuseGroup;
}
/**
* Sets the shared reuse group.
* @param sharedReuseGroup the shared reuse group to set
*/
public void setSharedReuseGroup(int sharedReuseGroup)
{
_sharedReuseGroup = sharedReuseGroup;
}
}

View File

@@ -0,0 +1,51 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.Calendar;
/**
* @author UnAfraid
*/
public class SiegeScheduleDate
{
private final int _day;
private final int _hour;
private final int _maxConcurrent;
public SiegeScheduleDate(StatsSet set)
{
_day = set.getInt("day", Calendar.SUNDAY);
_hour = set.getInt("hour", 16);
_maxConcurrent = set.getInt("maxConcurrent", 5);
}
public int getDay()
{
return _day;
}
public int getHour()
{
return _hour;
}
public int getMaxConcurrent()
{
return _maxConcurrent;
}
}

View File

@@ -0,0 +1,29 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import com.l2jmobius.gameserver.model.actor.L2Npc;
/**
* This class ...
* @version $Revision: 1.2 $ $Date: 2004/06/27 08:12:59 $
*/
public interface SpawnListener
{
public void npcSpawned(L2Npc npc);
}

View File

@@ -0,0 +1,674 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.gameserver.model.holders.MinionHolder;
import com.l2jmobius.gameserver.model.holders.SkillHolder;
import com.l2jmobius.gameserver.model.interfaces.IParserAdvUtils;
import com.l2jmobius.util.TimeUtil;
/**
* This class is meant to hold a set of (key,value) pairs.<br>
* They are stored as object but can be retrieved in any type wanted. As long as cast is available.<br>
* @author mkizub
*/
public class StatsSet implements IParserAdvUtils
{
private static final Logger _log = Logger.getLogger(StatsSet.class.getName());
/** Static empty immutable map, used to avoid multiple null checks over the source. */
public static final StatsSet EMPTY_STATSET = new StatsSet(Collections.<String, Object> emptyMap());
private final Map<String, Object> _set;
public StatsSet()
{
this(new LinkedHashMap<>());
}
public StatsSet(Map<String, Object> map)
{
_set = map;
}
/**
* Returns the set of values
* @return HashMap
*/
public final Map<String, Object> getSet()
{
return _set;
}
/**
* Add a set of couple values in the current set
* @param newSet : StatsSet pointing out the list of couples to add in the current set
*/
public void add(StatsSet newSet)
{
_set.putAll(newSet.getSet());
}
/**
* Verifies if the stat set is empty.
* @return {@code true} if the stat set is empty, {@code false} otherwise
*/
public boolean isEmpty()
{
return _set.isEmpty();
}
/**
* Return the boolean value associated with key.
* @param key : String designating the key in the set
* @return boolean : value associated to the key
* @throws IllegalArgumentException : If value is not set or value is not boolean
*/
@Override
public boolean getBoolean(String key)
{
final Object val = _set.get(key);
if (val == null)
{
throw new IllegalArgumentException("Boolean value required, but not specified");
}
if (val instanceof Boolean)
{
return ((Boolean) val).booleanValue();
}
try
{
return Boolean.parseBoolean((String) val);
}
catch (Exception e)
{
throw new IllegalArgumentException("Boolean value required, but found: " + val);
}
}
/**
* Return the boolean value associated with key.<br>
* If no value is associated with key, or type of value is wrong, returns defaultValue.
* @param key : String designating the key in the entry set
* @return boolean : value associated to the key
*/
@Override
public boolean getBoolean(String key, boolean defaultValue)
{
final Object val = _set.get(key);
if (val == null)
{
return defaultValue;
}
if (val instanceof Boolean)
{
return ((Boolean) val).booleanValue();
}
try
{
return Boolean.parseBoolean((String) val);
}
catch (Exception e)
{
return defaultValue;
}
}
@Override
public byte getByte(String key)
{
final Object val = _set.get(key);
if (val == null)
{
throw new IllegalArgumentException("Byte value required, but not specified");
}
if (val instanceof Number)
{
return ((Number) val).byteValue();
}
try
{
return Byte.parseByte((String) val);
}
catch (Exception e)
{
throw new IllegalArgumentException("Byte value required, but found: " + val);
}
}
@Override
public byte getByte(String key, byte defaultValue)
{
final Object val = _set.get(key);
if (val == null)
{
return defaultValue;
}
if (val instanceof Number)
{
return ((Number) val).byteValue();
}
try
{
return Byte.parseByte((String) val);
}
catch (Exception e)
{
throw new IllegalArgumentException("Byte value required, but found: " + val);
}
}
public byte[] getByteArray(String key, String splitOn)
{
final Object val = _set.get(key);
if (val == null)
{
throw new IllegalArgumentException("Byte value required, but not specified");
}
if (val instanceof Number)
{
final byte[] result =
{
((Number) val).byteValue()
};
return result;
}
int c = 0;
final String[] vals = ((String) val).split(splitOn);
final byte[] result = new byte[vals.length];
for (String v : vals)
{
try
{
result[c++] = Byte.parseByte(v);
}
catch (Exception e)
{
throw new IllegalArgumentException("Byte value required, but found: " + val);
}
}
return result;
}
public List<Byte> getByteList(String key, String splitOn)
{
final List<Byte> result = new ArrayList<>();
for (Byte i : getByteArray(key, splitOn))
{
result.add(i);
}
return result;
}
@Override
public short getShort(String key)
{
final Object val = _set.get(key);
if (val == null)
{
throw new IllegalArgumentException("Short value required, but not specified");
}
if (val instanceof Number)
{
return ((Number) val).shortValue();
}
try
{
return Short.parseShort((String) val);
}
catch (Exception e)
{
throw new IllegalArgumentException("Short value required, but found: " + val);
}
}
@Override
public short getShort(String key, short defaultValue)
{
final Object val = _set.get(key);
if (val == null)
{
return defaultValue;
}
if (val instanceof Number)
{
return ((Number) val).shortValue();
}
try
{
return Short.parseShort((String) val);
}
catch (Exception e)
{
throw new IllegalArgumentException("Short value required, but found: " + val);
}
}
@Override
public int getInt(String key)
{
final Object val = _set.get(key);
if (val == null)
{
throw new IllegalArgumentException("Integer value required, but not specified: " + key + "!");
}
if (val instanceof Number)
{
return ((Number) val).intValue();
}
try
{
return Integer.parseInt((String) val);
}
catch (Exception e)
{
throw new IllegalArgumentException("Integer value required, but found: " + val + "!");
}
}
@Override
public int getInt(String key, int defaultValue)
{
final Object val = _set.get(key);
if (val == null)
{
return defaultValue;
}
if (val instanceof Number)
{
return ((Number) val).intValue();
}
try
{
return Integer.parseInt((String) val);
}
catch (Exception e)
{
throw new IllegalArgumentException("Integer value required, but found: " + val);
}
}
public int[] getIntArray(String key, String splitOn)
{
final Object val = _set.get(key);
if (val == null)
{
throw new IllegalArgumentException("Integer value required, but not specified");
}
if (val instanceof Number)
{
final int[] result =
{
((Number) val).intValue()
};
return result;
}
int c = 0;
final String[] vals = ((String) val).split(splitOn);
final int[] result = new int[vals.length];
for (String v : vals)
{
try
{
result[c++] = Integer.parseInt(v);
}
catch (Exception e)
{
throw new IllegalArgumentException("Integer value required, but found: " + val);
}
}
return result;
}
public List<Integer> getIntegerList(String key, String splitOn)
{
final List<Integer> result = new ArrayList<>();
for (int i : getIntArray(key, splitOn))
{
result.add(i);
}
return result;
}
@Override
public long getLong(String key)
{
final Object val = _set.get(key);
if (val == null)
{
throw new IllegalArgumentException("Long value required, but not specified");
}
if (val instanceof Number)
{
return ((Number) val).longValue();
}
try
{
return Long.parseLong((String) val);
}
catch (Exception e)
{
throw new IllegalArgumentException("Long value required, but found: " + val);
}
}
@Override
public long getLong(String key, long defaultValue)
{
final Object val = _set.get(key);
if (val == null)
{
return defaultValue;
}
if (val instanceof Number)
{
return ((Number) val).longValue();
}
try
{
return Long.parseLong((String) val);
}
catch (Exception e)
{
throw new IllegalArgumentException("Long value required, but found: " + val);
}
}
@Override
public float getFloat(String key)
{
final Object val = _set.get(key);
if (val == null)
{
throw new IllegalArgumentException("Float value required, but not specified");
}
if (val instanceof Number)
{
return ((Number) val).floatValue();
}
try
{
return Float.parseFloat((String) val);
}
catch (Exception e)
{
throw new IllegalArgumentException("Float value required, but found: " + val);
}
}
@Override
public float getFloat(String key, float defaultValue)
{
final Object val = _set.get(key);
if (val == null)
{
return defaultValue;
}
if (val instanceof Number)
{
return ((Number) val).floatValue();
}
try
{
return Float.parseFloat((String) val);
}
catch (Exception e)
{
throw new IllegalArgumentException("Float value required, but found: " + val);
}
}
@Override
public double getDouble(String key)
{
final Object val = _set.get(key);
if (val == null)
{
throw new IllegalArgumentException("Double value required, but not specified");
}
if (val instanceof Number)
{
return ((Number) val).doubleValue();
}
try
{
return Double.parseDouble((String) val);
}
catch (Exception e)
{
throw new IllegalArgumentException("Double value required, but found: " + val);
}
}
@Override
public double getDouble(String key, double defaultValue)
{
final Object val = _set.get(key);
if (val == null)
{
return defaultValue;
}
if (val instanceof Number)
{
return ((Number) val).doubleValue();
}
try
{
return Double.parseDouble((String) val);
}
catch (Exception e)
{
throw new IllegalArgumentException("Double value required, but found: " + val);
}
}
@Override
public String getString(String key)
{
final Object val = _set.get(key);
if (val == null)
{
throw new IllegalArgumentException("String value required, but not specified");
}
return String.valueOf(val);
}
@Override
public String getString(String key, String defaultValue)
{
final Object val = _set.get(key);
if (val == null)
{
return defaultValue;
}
return String.valueOf(val);
}
@Override
public Duration getDuration(String key)
{
final Object val = _set.get(key);
if (val == null)
{
throw new IllegalArgumentException("String value required, but not specified");
}
return TimeUtil.parseDuration(String.valueOf(val));
}
@Override
public Duration getDuration(String key, Duration defaultValue)
{
final Object val = _set.get(key);
if (val == null)
{
return defaultValue;
}
return TimeUtil.parseDuration(String.valueOf(val));
}
@Override
@SuppressWarnings("unchecked")
public <T extends Enum<T>> T getEnum(String key, Class<T> enumClass)
{
final Object val = _set.get(key);
if (val == null)
{
throw new IllegalArgumentException("Enum value of type " + enumClass.getName() + " required, but not specified");
}
if (enumClass.isInstance(val))
{
return (T) val;
}
try
{
return Enum.valueOf(enumClass, String.valueOf(val));
}
catch (Exception e)
{
throw new IllegalArgumentException("Enum value of type " + enumClass.getName() + " required, but found: " + val);
}
}
@Override
@SuppressWarnings("unchecked")
public <T extends Enum<T>> T getEnum(String key, Class<T> enumClass, T defaultValue)
{
final Object val = _set.get(key);
if (val == null)
{
return defaultValue;
}
if (enumClass.isInstance(val))
{
return (T) val;
}
try
{
return Enum.valueOf(enumClass, String.valueOf(val));
}
catch (Exception e)
{
throw new IllegalArgumentException("Enum value of type " + enumClass.getName() + " required, but found: " + val);
}
}
@SuppressWarnings("unchecked")
public final <A> A getObject(String name, Class<A> type)
{
final Object obj = _set.get(name);
if ((obj == null) || !type.isAssignableFrom(obj.getClass()))
{
return null;
}
return (A) obj;
}
public SkillHolder getSkillHolder(String key)
{
final Object obj = _set.get(key);
if ((obj == null) || !(obj instanceof SkillHolder))
{
return null;
}
return (SkillHolder) obj;
}
@SuppressWarnings("unchecked")
public List<MinionHolder> getMinionList(String key)
{
final Object obj = _set.get(key);
if ((obj == null) || !(obj instanceof List<?>))
{
return Collections.emptyList();
}
return (List<MinionHolder>) obj;
}
public void set(String name, Object value)
{
_set.put(name, value);
}
public void set(String key, boolean value)
{
_set.put(key, value);
}
public void set(String key, byte value)
{
_set.put(key, value);
}
public void set(String key, short value)
{
_set.put(key, value);
}
public void set(String key, int value)
{
_set.put(key, value);
}
public void set(String key, long value)
{
_set.put(key, value);
}
public void set(String key, float value)
{
_set.put(key, value);
}
public void set(String key, double value)
{
_set.put(key, value);
}
public void set(String key, String value)
{
_set.put(key, value);
}
public void set(String key, Enum<?> value)
{
_set.put(key, value);
}
public void safeSet(String key, int value, int min, int max, String reference)
{
assert !(((min <= max) && ((value < min) || (value >= max))));
if ((min <= max) && ((value < min) || (value >= max)))
{
_log.log(Level.SEVERE, "Incorrect value: " + value + "for: " + key + "Ref: " + reference);
}
set(key, value);
}
}

View File

@@ -0,0 +1,71 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
/**
* @author UnAfraid
*/
public class TeleportBookmark extends Location
{
private final int _id;
private int _icon;
private String _name, _tag;
public TeleportBookmark(int id, int x, int y, int z, int icon, String tag, String name)
{
super(x, y, z);
_id = id;
_icon = icon;
_name = name;
_tag = tag;
}
public String getName()
{
return _name;
}
public void setName(String name)
{
_name = name;
}
public int getId()
{
return _id;
}
public int getIcon()
{
return _icon;
}
public void setIcon(int icon)
{
_icon = icon;
}
public String getTag()
{
return _tag;
}
public void setTag(String tag)
{
_tag = tag;
}
}

View File

@@ -0,0 +1,30 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
/**
* All teleport types.
* @author xban1x
*/
public enum TeleportWhereType
{
CASTLE,
CLANHALL,
SIEGEFLAG,
TOWN,
FORTRESS
}

View File

@@ -0,0 +1,83 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
/**
* Class explanation:<br>
* For item counting or checking purposes. When you don't want to modify inventory<br>
* class contains itemId, quantity, ownerId, referencePrice, but not objectId<br>
* is stored, this will be only "list" of items with it's owner
*/
public final class TempItem
{
private final int _itemId;
private int _quantity;
private final int _referencePrice;
private final String _itemName;
/**
* @param item
* @param quantity of that item
*/
public TempItem(L2ItemInstance item, int quantity)
{
super();
_itemId = item.getId();
_quantity = quantity;
_itemName = item.getItem().getName();
_referencePrice = item.getReferencePrice();
}
/**
* @return the quantity.
*/
public int getQuantity()
{
return _quantity;
}
/**
* @param quantity The quantity to set.
*/
public void setQuantity(int quantity)
{
_quantity = quantity;
}
public int getReferencePrice()
{
return _referencePrice;
}
/**
* @return the itemId.
*/
public int getItemId()
{
return _itemId;
}
/**
* @return the itemName.
*/
public String getItemName()
{
return _itemName;
}
}

View File

@@ -0,0 +1,152 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
/**
* Simple class containing all necessary information to maintain<br>
* valid time stamps and reuse for skills and items reuse upon re-login.<br>
* <b>Filter this carefully as it becomes redundant to store reuse for small delays.</b>
* @author Yesod, Zoey76
*/
public class TimeStamp
{
/** Item or skill ID. */
private final int _id1;
/** Item object ID or skill level. */
private final int _id2;
/** Item or skill reuse time. */
private final long _reuse;
/** Time stamp. */
private final long _stamp;
/** Shared reuse group. */
private final int _group;
/**
* Skill time stamp constructor.
* @param skill the skill upon the stamp will be created.
* @param reuse the reuse time for this skill.
* @param systime overrides the system time with a customized one.
*/
public TimeStamp(Skill skill, long reuse, long systime)
{
_id1 = skill.getId();
_id2 = skill.getLevel();
_reuse = reuse;
_stamp = systime > 0 ? systime : System.currentTimeMillis() + reuse;
_group = -1;
}
/**
* Item time stamp constructor.
* @param item the item upon the stamp will be created.
* @param reuse the reuse time for this item.
* @param systime overrides the system time with a customized one.
*/
public TimeStamp(L2ItemInstance item, long reuse, long systime)
{
_id1 = item.getId();
_id2 = item.getObjectId();
_reuse = reuse;
_stamp = systime > 0 ? systime : System.currentTimeMillis() + reuse;
_group = item.getSharedReuseGroup();
}
/**
* Gets the time stamp.
* @return the time stamp, either the system time where this time stamp was created or the custom time assigned
*/
public long getStamp()
{
return _stamp;
}
/**
* Gets the item ID.
* @return the item ID
*/
public int getItemId()
{
return _id1;
}
/**
* Gets the item object ID.
* @return the item object ID
*/
public int getItemObjectId()
{
return _id2;
}
/**
* Gets the skill ID.
* @return the skill ID
*/
public int getSkillId()
{
return _id1;
}
/**
* Gets the skill level.
* @return the skill level
*/
public int getSkillLvl()
{
return _id2;
}
/**
* Gets the reuse.
* @return the reuse
*/
public long getReuse()
{
return _reuse;
}
/**
* Get the shared reuse group.<br>
* Only used on items.
* @return the shared reuse group
*/
public int getSharedReuseGroup()
{
return _group;
}
/**
* Gets the remaining time.
* @return the remaining time for this time stamp to expire
*/
public long getRemaining()
{
return Math.max(_stamp - System.currentTimeMillis(), 0);
}
/**
* Verifies if the reuse delay has passed.
* @return {@code true} if this time stamp has expired, {@code false} otherwise
*/
public boolean hasNotPassed()
{
return System.currentTimeMillis() < _stamp;
}
}

View File

@@ -0,0 +1,75 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.List;
import com.l2jmobius.gameserver.model.interfaces.IIdentifiable;
/**
* @author malyelfik
*/
public class TowerSpawn implements IIdentifiable
{
private final int _npcId;
private final Location _location;
private List<Integer> _zoneList = null;
private int _upgradeLevel = 0;
public TowerSpawn(int npcId, Location location)
{
_location = location;
_npcId = npcId;
}
public TowerSpawn(int npcId, Location location, List<Integer> zoneList)
{
_location = location;
_npcId = npcId;
_zoneList = zoneList;
}
/**
* Gets the NPC ID.
* @return the NPC ID
*/
@Override
public int getId()
{
return _npcId;
}
public Location getLocation()
{
return _location;
}
public List<Integer> getZoneList()
{
return _zoneList;
}
public void setUpgradeLevel(int level)
{
_upgradeLevel = level;
}
public int getUpgradeLevel()
{
return _upgradeLevel;
}
}

View File

@@ -0,0 +1,266 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import com.l2jmobius.gameserver.model.items.L2Item;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
public class TradeItem
{
private L2ItemInstance _itemInstance;
private int _objectId;
private final L2Item _item;
private final int _location;
private int _enchant;
private final int _type1;
private final int _type2;
private long _count;
private long _storeCount;
private long _price;
private final byte _elemAtkType;
private final int _elemAtkPower;
private final int[] _elemDefAttr =
{
0,
0,
0,
0,
0,
0
};
private final int[] _enchantOptions;
private final boolean _isAugmented;
private final L2Augmentation _augmentation;
private final int _mana;
private final boolean _isTimeLimited;
private final int _time;
private final int _visualId;
private final long _visualExpiration;
public TradeItem(L2ItemInstance item, long count, long price)
{
_itemInstance = item;
_objectId = item.getObjectId();
_item = item.getItem();
_location = item.getLocationSlot();
_enchant = item.getEnchantLevel();
_type1 = item.getCustomType1();
_type2 = item.getCustomType2();
_count = count;
_price = price;
_elemAtkType = item.getAttackElementType();
_elemAtkPower = item.getAttackElementPower();
for (byte i = 0; i < 6; i++)
{
_elemDefAttr[i] = item.getElementDefAttr(i);
}
_enchantOptions = item.getEnchantOptions();
_isAugmented = item.isAugmented();
_augmentation = item.getAugmentation();
_mana = item.getMana();
_isTimeLimited = item.isTimeLimitedItem();
_time = item.isTimeLimitedItem() ? (int) (item.getRemainingTime() / 1000) : -9999;
_visualId = item.getVisualId();
_visualExpiration = item.getTime();
}
public TradeItem(L2Item item, long count, long price, int enchantLevel, int attackAttribute, int attackAttributeValue, int defenseAttributes[], int appearanceId)
{
_itemInstance = null;
_objectId = 0;
_item = item;
_location = 0;
_enchant = 0;
_type1 = 0;
_type2 = 0;
_count = count;
_storeCount = count;
_price = price;
_elemAtkType = (byte) attackAttribute;
_elemAtkPower = attackAttributeValue;
for (byte i = 0; i < 6; i++)
{
_elemDefAttr[i] = defenseAttributes[i];
}
_enchantOptions = L2ItemInstance.DEFAULT_ENCHANT_OPTIONS;
_isAugmented = false;
_augmentation = null;
_mana = -1;
_isTimeLimited = false;
_time = -9999;
_visualId = appearanceId;
_visualExpiration = -1;
}
public TradeItem(TradeItem item, long count, long price, int enchantLevel, int attackAttribute, int attackAttributeValue, int defenseAttributes[], int appearanceId)
{
_itemInstance = item.getItemInstance();
_objectId = item.getObjectId();
_item = item.getItem();
_location = item.getLocationSlot();
_enchant = item.getEnchant();
_type1 = item.getCustomType1();
_type2 = item.getCustomType2();
_count = count;
_storeCount = count;
_price = price;
_elemAtkType = item.getAttackElementType();
_elemAtkPower = item.getAttackElementPower();
for (byte i = 0; i < 6; i++)
{
_elemDefAttr[i] = item.getElementDefAttr(i);
}
_enchantOptions = item.getEnchantOptions();
_isAugmented = item.isAugmented();
_augmentation = item.getAugmentation();
_mana = item.getMana();
_isTimeLimited = item.isTimeLimitedItem();
_time = item.isTimeLimitedItem() ? (int) (item.getRemainingTime() / 1000) : -9999;
_visualId = item.getVisualId();
_visualExpiration = item.getVisualExpiration();
}
public L2ItemInstance getItemInstance()
{
return _itemInstance;
}
public void setItemInstance(L2ItemInstance it)
{
_itemInstance = it;
}
public void setObjectId(int objectId)
{
_objectId = objectId;
}
public int getObjectId()
{
return _objectId;
}
public L2Item getItem()
{
return _item;
}
public int getLocationSlot()
{
return _location;
}
public void setEnchant(int enchant)
{
_enchant = enchant;
}
public int getEnchant()
{
return _enchant;
}
public int getCustomType1()
{
return _type1;
}
public int getCustomType2()
{
return _type2;
}
public void setCount(long count)
{
_count = count;
}
public long getCount()
{
return _count;
}
public long getStoreCount()
{
return _storeCount;
}
public void setPrice(long price)
{
_price = price;
}
public long getPrice()
{
return _price;
}
public byte getAttackElementType()
{
return _elemAtkType;
}
public int getAttackElementPower()
{
return _elemAtkPower;
}
public int getElementDefAttr(byte i)
{
return _elemDefAttr[i];
}
public int[] getEnchantOptions()
{
return _enchantOptions;
}
public boolean isAugmented()
{
return _isAugmented;
}
public L2Augmentation getAugmentation()
{
return _augmentation;
}
public int getMana()
{
return _mana;
}
public boolean isTimeLimitedItem()
{
return _isTimeLimited;
}
public int getVisualId()
{
return _visualId;
}
public long getVisualExpiration()
{
return _visualExpiration;
}
public int getRemainingTime()
{
return _time;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,214 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
import com.l2jmobius.gameserver.data.xml.impl.UIData;
/**
* UI Keys Settings class.
* @author mrTJO, Zoey76
*/
public class UIKeysSettings
{
private static final Logger _log = Logger.getLogger(UIKeysSettings.class.getName());
private final int _playerObjId;
private Map<Integer, List<ActionKey>> _storedKeys;
private Map<Integer, List<Integer>> _storedCategories;
private boolean _saved = true;
public UIKeysSettings(int playerObjId)
{
_playerObjId = playerObjId;
loadFromDB();
}
public void storeAll(Map<Integer, List<Integer>> catMap, Map<Integer, List<ActionKey>> keyMap)
{
_saved = false;
_storedCategories = catMap;
_storedKeys = keyMap;
}
public void storeCategories(Map<Integer, List<Integer>> catMap)
{
_saved = false;
_storedCategories = catMap;
}
public Map<Integer, List<Integer>> getCategories()
{
return _storedCategories;
}
public void storeKeys(Map<Integer, List<ActionKey>> keyMap)
{
_saved = false;
_storedKeys = keyMap;
}
public Map<Integer, List<ActionKey>> getKeys()
{
return _storedKeys;
}
public void loadFromDB()
{
getCatsFromDB();
getKeysFromDB();
}
/**
* Save Categories and Mapped Keys into GameServer DataBase
*/
public void saveInDB()
{
String query;
if (_saved)
{
return;
}
// TODO(Zoey76): Refactor this to use batch.
query = "REPLACE INTO character_ui_categories (`charId`, `catId`, `order`, `cmdId`) VALUES ";
for (int category : _storedCategories.keySet())
{
int order = 0;
for (int key : _storedCategories.get(category))
{
query += "(" + _playerObjId + ", " + category + ", " + (order++) + ", " + key + "),";
}
}
query = query.substring(0, query.length() - 1) + "; ";
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(query))
{
statement.execute();
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception: saveInDB(): " + e.getMessage(), e);
}
query = "REPLACE INTO character_ui_actions (`charId`, `cat`, `order`, `cmd`, `key`, `tgKey1`, `tgKey2`, `show`) VALUES";
for (List<ActionKey> keyLst : _storedKeys.values())
{
int order = 0;
for (ActionKey key : keyLst)
{
query += key.getSqlSaveString(_playerObjId, order++) + ",";
}
}
query = query.substring(0, query.length() - 1) + ";";
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(query))
{
statement.execute();
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception: saveInDB(): " + e.getMessage(), e);
}
_saved = true;
}
public void getCatsFromDB()
{
if (_storedCategories != null)
{
return;
}
_storedCategories = new HashMap<>();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM character_ui_categories WHERE `charId` = ? ORDER BY `catId`, `order`"))
{
ps.setInt(1, _playerObjId);
try (ResultSet rs = ps.executeQuery())
{
while (rs.next())
{
UIData.addCategory(_storedCategories, rs.getInt("catId"), rs.getInt("cmdId"));
}
}
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception: getCatsFromDB(): " + e.getMessage(), e);
}
if (_storedCategories.isEmpty())
{
_storedCategories = UIData.getInstance().getCategories();
}
}
public void getKeysFromDB()
{
if (_storedKeys != null)
{
return;
}
_storedKeys = new HashMap<>();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM character_ui_actions WHERE `charId` = ? ORDER BY `cat`, `order`"))
{
ps.setInt(1, _playerObjId);
try (ResultSet rs = ps.executeQuery())
{
while (rs.next())
{
final int cat = rs.getInt("cat");
final int cmd = rs.getInt("cmd");
final int key = rs.getInt("key");
final int tgKey1 = rs.getInt("tgKey1");
final int tgKey2 = rs.getInt("tgKey2");
final int show = rs.getInt("show");
UIData.addKey(_storedKeys, cat, new ActionKey(cat, cmd, key, tgKey1, tgKey2, show));
}
}
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception: getKeysFromDB(): " + e.getMessage(), e);
}
if (_storedKeys.isEmpty())
{
_storedKeys = UIData.getInstance().getKeys();
}
}
public boolean isSaved()
{
return _saved;
}
}

View File

@@ -0,0 +1,52 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
public final class VehiclePathPoint extends Location
{
private final int _moveSpeed;
private final int _rotationSpeed;
public VehiclePathPoint(Location loc)
{
this(loc.getX(), loc.getY(), loc.getZ());
}
public VehiclePathPoint(int x, int y, int z)
{
super(x, y, z);
_moveSpeed = 350;
_rotationSpeed = 4000;
}
public VehiclePathPoint(int x, int y, int z, int moveSpeed, int rotationSpeed)
{
super(x, y, z);
_moveSpeed = moveSpeed;
_rotationSpeed = rotationSpeed;
}
public int getMoveSpeed()
{
return _moveSpeed;
}
public int getRotationSpeed()
{
return _rotationSpeed;
}
}

View File

@@ -0,0 +1,222 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.concurrent.ScheduledFuture;
import com.l2jmobius.gameserver.instancemanager.WalkingManager;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.events.EventDispatcher;
import com.l2jmobius.gameserver.model.events.impl.character.npc.OnNpcMoveRouteFinished;
import com.l2jmobius.util.Rnd;
/**
* Holds info about current walk progress
* @author GKR, UnAfraid
*/
public class WalkInfo
{
private final String _routeName;
private ScheduledFuture<?> _walkCheckTask;
private boolean _blocked = false;
private boolean _suspended = false;
private boolean _stoppedByAttack = false;
private int _currentNode = 0;
private boolean _forward = true; // Determines first --> last or first <-- last direction
private long _lastActionTime; // Debug field
public WalkInfo(String routeName)
{
_routeName = routeName;
}
/**
* @return name of route of this WalkInfo.
*/
public L2WalkRoute getRoute()
{
return WalkingManager.getInstance().getRoute(_routeName);
}
/**
* @return current node of this WalkInfo.
*/
public L2NpcWalkerNode getCurrentNode()
{
return getRoute().getNodeList().get(_currentNode);
}
/**
* Calculate next node for this WalkInfo and send debug message from given npc
* @param npc NPC to debug message to be sent from
*/
public void calculateNextNode(L2Npc npc)
{
// Check this first, within the bounds of random moving, we have no conception of "first" or "last" node
if (getRoute().getRepeatType() == WalkingManager.REPEAT_RANDOM)
{
int newNode = _currentNode;
while (newNode == _currentNode)
{
newNode = Rnd.get(getRoute().getNodesCount());
}
_currentNode = newNode;
npc.sendDebugMessage("Route: " + getRoute().getName() + ", next random node is " + _currentNode);
}
else
{
if (_forward)
{
_currentNode++;
}
else
{
_currentNode--;
}
if (_currentNode == getRoute().getNodesCount()) // Last node arrived
{
// Notify quest
EventDispatcher.getInstance().notifyEventAsync(new OnNpcMoveRouteFinished(npc), npc);
npc.sendDebugMessage("Route: " + getRoute().getName() + ", last node arrived");
if (!getRoute().repeatWalk())
{
WalkingManager.getInstance().cancelMoving(npc);
return;
}
switch (getRoute().getRepeatType())
{
case WalkingManager.REPEAT_GO_BACK:
{
_forward = false;
_currentNode -= 2;
break;
}
case WalkingManager.REPEAT_GO_FIRST:
{
_currentNode = 0;
break;
}
case WalkingManager.REPEAT_TELE_FIRST:
{
npc.teleToLocation(npc.getSpawn().getLocation());
_currentNode = 0;
break;
}
}
}
else if (_currentNode == -1) // First node arrived, when direction is first <-- last
{
_currentNode = 1;
_forward = true;
}
}
}
/**
* @return {@code true} if walking task is blocked, {@code false} otherwise,
*/
public boolean isBlocked()
{
return _blocked;
}
/**
* @param val
*/
public void setBlocked(boolean val)
{
_blocked = val;
}
/**
* @return {@code true} if walking task is suspended, {@code false} otherwise,
*/
public boolean isSuspended()
{
return _suspended;
}
/**
* @param val
*/
public void setSuspended(boolean val)
{
_suspended = val;
}
/**
* @return {@code true} if walking task shall be stopped by attack, {@code false} otherwise,
*/
public boolean isStoppedByAttack()
{
return _stoppedByAttack;
}
/**
* @param val
*/
public void setStoppedByAttack(boolean val)
{
_stoppedByAttack = val;
}
/**
* @return the id of the current node in this walking task.
*/
public int getCurrentNodeId()
{
return _currentNode;
}
/**
* @return {@code long} last action time used only for debugging.
*/
public long getLastAction()
{
return _lastActionTime;
}
/**
* @param val
*/
public void setLastAction(long val)
{
_lastActionTime = val;
}
/**
* @return walking check task.
*/
public ScheduledFuture<?> getWalkCheckTask()
{
return _walkCheckTask;
}
/**
* @param val walking check task.
*/
public void setWalkCheckTask(ScheduledFuture<?> val)
{
_walkCheckTask = val;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,185 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.actor;
import java.util.Collection;
import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.templates.L2CharTemplate;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jmobius.gameserver.model.items.L2Weapon;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.CharInfo;
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
import com.l2jmobius.gameserver.taskmanager.DecayTaskManager;
public abstract class L2Decoy extends L2Character
{
private final L2PcInstance _owner;
/**
* Creates an abstract decoy.
* @param template the decoy template
* @param owner the owner
*/
public L2Decoy(L2CharTemplate template, L2PcInstance owner)
{
super(template);
setInstanceType(InstanceType.L2Decoy);
_owner = owner;
setXYZInvisible(owner.getX(), owner.getY(), owner.getZ());
setIsInvul(false);
}
@Override
public void onSpawn()
{
super.onSpawn();
sendPacket(new CharInfo(this));
}
@Override
public void updateAbnormalVisualEffects()
{
final Collection<L2PcInstance> plrs = getKnownList().getKnownPlayers().values();
for (L2PcInstance player : plrs)
{
if (player != null)
{
player.sendPacket(new CharInfo(this));
}
}
}
public void stopDecay()
{
DecayTaskManager.getInstance().cancel(this);
}
@Override
public void onDecay()
{
deleteMe(_owner);
}
@Override
public boolean isAutoAttackable(L2Character attacker)
{
return _owner.isAutoAttackable(attacker);
}
@Override
public L2ItemInstance getActiveWeaponInstance()
{
return null;
}
@Override
public L2Weapon getActiveWeaponItem()
{
return null;
}
@Override
public L2ItemInstance getSecondaryWeaponInstance()
{
return null;
}
@Override
public L2Weapon getSecondaryWeaponItem()
{
return null;
}
@Override
public final int getId()
{
return getTemplate().getId();
}
@Override
public int getLevel()
{
return getTemplate().getLevel();
}
public void deleteMe(L2PcInstance owner)
{
decayMe();
getKnownList().removeAllKnownObjects();
owner.setDecoy(null);
}
public synchronized void unSummon(L2PcInstance owner)
{
if (isVisible() && !isDead())
{
if (getWorldRegion() != null)
{
getWorldRegion().removeFromZones(this);
}
owner.setDecoy(null);
decayMe();
getKnownList().removeAllKnownObjects();
}
}
public final L2PcInstance getOwner()
{
return _owner;
}
@Override
public L2PcInstance getActingPlayer()
{
return _owner;
}
@Override
public L2NpcTemplate getTemplate()
{
return (L2NpcTemplate) super.getTemplate();
}
@Override
public void sendInfo(L2PcInstance activeChar)
{
activeChar.sendPacket(new CharInfo(this));
}
@Override
public void sendPacket(L2GameServerPacket mov)
{
if (getOwner() != null)
{
getOwner().sendPacket(mov);
}
}
@Override
public void sendPacket(SystemMessageId id)
{
if (getOwner() != null)
{
getOwner().sendPacket(id);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,364 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.actor;
import com.l2jmobius.gameserver.ai.CtrlEvent;
import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.knownlist.PlayableKnownList;
import com.l2jmobius.gameserver.model.actor.stat.PlayableStat;
import com.l2jmobius.gameserver.model.actor.status.PlayableStatus;
import com.l2jmobius.gameserver.model.actor.templates.L2CharTemplate;
import com.l2jmobius.gameserver.model.effects.EffectFlag;
import com.l2jmobius.gameserver.model.effects.L2EffectType;
import com.l2jmobius.gameserver.model.entity.Instance;
import com.l2jmobius.gameserver.model.events.EventDispatcher;
import com.l2jmobius.gameserver.model.events.impl.character.OnCreatureKill;
import com.l2jmobius.gameserver.model.events.returns.TerminateReturn;
import com.l2jmobius.gameserver.model.quest.QuestState;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
/**
* This class represents all Playable characters in the world.<br>
* L2Playable:
* <ul>
* <li>L2PcInstance</li>
* <li>L2Summon</li>
* </ul>
*/
public abstract class L2Playable extends L2Character
{
private L2Character _lockedTarget = null;
private L2PcInstance transferDmgTo = null;
/**
* Creates an abstract playable creature.
* @param objectId the playable object ID
* @param template the creature template
*/
public L2Playable(int objectId, L2CharTemplate template)
{
super(objectId, template);
setInstanceType(InstanceType.L2Playable);
setIsInvul(false);
}
public L2Playable(L2CharTemplate template)
{
super(template);
setInstanceType(InstanceType.L2Playable);
setIsInvul(false);
}
@Override
public PlayableKnownList getKnownList()
{
return (PlayableKnownList) super.getKnownList();
}
@Override
public void initKnownList()
{
setKnownList(new PlayableKnownList(this));
}
@Override
public PlayableStat getStat()
{
return (PlayableStat) super.getStat();
}
@Override
public void initCharStat()
{
setStat(new PlayableStat(this));
}
@Override
public PlayableStatus getStatus()
{
return (PlayableStatus) super.getStatus();
}
@Override
public void initCharStatus()
{
setStatus(new PlayableStatus(this));
}
@Override
public boolean doDie(L2Character killer)
{
final TerminateReturn returnBack = EventDispatcher.getInstance().notifyEvent(new OnCreatureKill(killer, this), this, TerminateReturn.class);
if ((returnBack != null) && returnBack.terminate())
{
return false;
}
// killing is only possible one time
synchronized (this)
{
if (isDead())
{
return false;
}
// now reset currentHp to zero
setCurrentHp(0);
setIsDead(true);
}
// Set target to null and cancel Attack or Cast
setTarget(null);
// Stop movement
stopMove(null);
// Stop HP/MP/CP Regeneration task
getStatus().stopHpMpRegeneration();
boolean deleteBuffs = true;
if (isNoblesseBlessedAffected())
{
stopEffects(L2EffectType.NOBLESSE_BLESSING);
deleteBuffs = false;
}
if (isResurrectSpecialAffected())
{
stopEffects(L2EffectType.RESURRECTION_SPECIAL);
deleteBuffs = false;
}
if (isPlayer())
{
final L2PcInstance activeChar = getActingPlayer();
if (activeChar.hasCharmOfCourage())
{
if (activeChar.isInSiege())
{
getActingPlayer().reviveRequest(getActingPlayer(), null, false, 0);
}
activeChar.setCharmOfCourage(false);
activeChar.sendPacket(new EtcStatusUpdate(activeChar));
}
}
if (deleteBuffs)
{
stopAllEffectsExceptThoseThatLastThroughDeath();
}
// Send the Server->Client packet StatusUpdate with current HP and MP to all other L2PcInstance to inform
broadcastStatusUpdate();
if (getWorldRegion() != null)
{
getWorldRegion().onDeath(this);
}
// Notify Quest of L2Playable's death
final L2PcInstance actingPlayer = getActingPlayer();
if (!actingPlayer.isNotifyQuestOfDeathEmpty())
{
for (QuestState qs : actingPlayer.getNotifyQuestOfDeath())
{
qs.getQuest().notifyDeath((killer == null ? this : killer), this, qs);
}
}
// Notify instance
if (getInstanceId() > 0)
{
final Instance instance = InstanceManager.getInstance().getInstance(getInstanceId());
if (instance != null)
{
instance.notifyDeath(killer, this);
}
}
if (killer != null)
{
final L2PcInstance player = killer.getActingPlayer();
if (player != null)
{
player.onKillUpdatePvPKarma(this);
}
}
// Notify L2Character AI
getAI().notifyEvent(CtrlEvent.EVT_DEAD);
updateEffectIcons();
return true;
}
public boolean checkIfPvP(L2Character target)
{
if (target == null)
{
return false; // Target is null
}
if (target == this)
{
return false; // Target is self
}
if (!target.isPlayable())
{
return false; // Target is not a L2Playable
}
final L2PcInstance player = getActingPlayer();
if (player == null)
{
return false; // Active player is null
}
if (player.getReputation() < 0)
{
return false; // Active player has karma
}
final L2PcInstance targetPlayer = target.getActingPlayer();
if (targetPlayer == null)
{
return false; // Target player is null
}
if (targetPlayer == this)
{
return false; // Target player is self
}
if (targetPlayer.getReputation() < 0)
{
return false; // Target player has karma
}
if (targetPlayer.getPvpFlag() == 0)
{
return false;
}
return true;
// Even at war, there should be PvP flag
// if(
// player.getClan() == null ||
// targetPlayer.getClan() == null ||
// (
// !targetPlayer.getClan().isAtWarWith(player.getClanId()) &&
// targetPlayer.getWantsPeace() == 0 &&
// player.getWantsPeace() == 0
// )
// )
// {
// return true;
// }
// return false;
}
/**
* Return True.
*/
@Override
public boolean canBeAttacked()
{
return true;
}
// Support for Noblesse Blessing skill, where buffs are retained after resurrect
public final boolean isNoblesseBlessedAffected()
{
return isAffected(EffectFlag.NOBLESS_BLESSING);
}
/**
* @return {@code true} if char can resurrect by himself, {@code false} otherwise
*/
public final boolean isResurrectSpecialAffected()
{
return isAffected(EffectFlag.RESURRECTION_SPECIAL);
}
/**
* @return {@code true} if the Silent Moving mode is active, {@code false} otherwise
*/
public boolean isSilentMovingAffected()
{
return isAffected(EffectFlag.SILENT_MOVE);
}
/**
* For Newbie Protection Blessing skill, keeps you safe from an attack by a chaotic character >= 10 levels apart from you.
* @return
*/
public final boolean isProtectionBlessingAffected()
{
return isAffected(EffectFlag.PROTECTION_BLESSING);
}
@Override
public void updateEffectIcons(boolean partyOnly)
{
getEffectList().updateEffectIcons(partyOnly);
}
public boolean isLockedTarget()
{
return _lockedTarget != null;
}
public L2Character getLockedTarget()
{
return _lockedTarget;
}
public void setLockedTarget(L2Character cha)
{
_lockedTarget = cha;
}
public void setTransferDamageTo(L2PcInstance val)
{
transferDmgTo = val;
}
public L2PcInstance getTransferingDamageTo()
{
return transferDmgTo;
}
public abstract void doPickupItem(L2Object object);
public abstract int getReputation();
public abstract byte getPvpFlag();
public abstract boolean useMagic(Skill skill, boolean forceUse, boolean dontMove);
public abstract void storeMe();
public abstract void storeEffect(boolean storeEffects);
public abstract void restoreEffects();
@Override
public boolean isPlayable()
{
return true;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,85 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.actor;
import com.l2jmobius.gameserver.GeoData;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
/**
* This class is a super-class for L2ControlTowerInstance and L2FlameTowerInstance.
* @author Zoey76
*/
public abstract class L2Tower extends L2Npc
{
/**
* Creates an abstract Tower.
* @param template the tower template
*/
public L2Tower(L2NpcTemplate template)
{
super(template);
setIsInvul(false);
}
@Override
public boolean canBeAttacked()
{
// Attackable during siege by attacker only
return ((getCastle() != null) && (getCastle().getResidenceId() > 0) && getCastle().getSiege().isInProgress());
}
@Override
public boolean isAutoAttackable(L2Character attacker)
{
// Attackable during siege by attacker only
return ((attacker != null) && attacker.isPlayer() && (getCastle() != null) && (getCastle().getResidenceId() > 0) && getCastle().getSiege().isInProgress() && getCastle().getSiege().checkIsAttacker(((L2PcInstance) attacker).getClan()));
}
@Override
public void onAction(L2PcInstance player, boolean interact)
{
if (!canTarget(player))
{
return;
}
if (this != player.getTarget())
{
// Set the target of the L2PcInstance player
player.setTarget(this);
}
else if (interact)
{
if (isAutoAttackable(player) && (Math.abs(player.getZ() - getZ()) < 100) && GeoData.getInstance().canSeeTarget(player, this))
{
// Notify the L2PcInstance AI with AI_INTENTION_INTERACT
player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, this);
}
}
// Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
player.sendPacket(ActionFailed.STATIC_PACKET);
}
@Override
public void onForcedAttack(L2PcInstance player)
{
onAction(player);
}
}

View File

@@ -0,0 +1,508 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.actor;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.GameTimeController;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.instancemanager.MapRegionManager;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.L2WorldRegion;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.TeleportWhereType;
import com.l2jmobius.gameserver.model.VehiclePathPoint;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.knownlist.VehicleKnownList;
import com.l2jmobius.gameserver.model.actor.stat.VehicleStat;
import com.l2jmobius.gameserver.model.actor.templates.L2CharTemplate;
import com.l2jmobius.gameserver.model.interfaces.ILocational;
import com.l2jmobius.gameserver.model.items.L2Weapon;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
import com.l2jmobius.gameserver.util.Util;
/**
* @author DS
*/
public abstract class L2Vehicle extends L2Character
{
protected int _dockId = 0;
protected final List<L2PcInstance> _passengers = new CopyOnWriteArrayList<>();
protected Location _oustLoc = null;
private Runnable _engine = null;
protected VehiclePathPoint[] _currentPath = null;
protected int _runState = 0;
/**
* Creates an abstract vehicle.
* @param template the vehicle template
*/
public L2Vehicle(L2CharTemplate template)
{
super(template);
setInstanceType(InstanceType.L2Vehicle);
setIsFlying(true);
}
public boolean isBoat()
{
return false;
}
public boolean isAirShip()
{
return false;
}
public boolean canBeControlled()
{
return _engine == null;
}
public void registerEngine(Runnable r)
{
_engine = r;
}
public void runEngine(int delay)
{
if (_engine != null)
{
ThreadPoolManager.getInstance().scheduleGeneral(_engine, delay);
}
}
public void executePath(VehiclePathPoint[] path)
{
_runState = 0;
_currentPath = path;
if ((_currentPath != null) && (_currentPath.length > 0))
{
final VehiclePathPoint point = _currentPath[0];
if (point.getMoveSpeed() > 0)
{
getStat().setMoveSpeed(point.getMoveSpeed());
}
if (point.getRotationSpeed() > 0)
{
getStat().setRotationSpeed(point.getRotationSpeed());
}
getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(point.getX(), point.getY(), point.getZ(), 0));
return;
}
getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
}
@Override
public boolean moveToNextRoutePoint()
{
_move = null;
if (_currentPath != null)
{
_runState++;
if (_runState < _currentPath.length)
{
final VehiclePathPoint point = _currentPath[_runState];
if (!isMovementDisabled())
{
if (point.getMoveSpeed() == 0)
{
point.setHeading(point.getRotationSpeed());
teleToLocation(point, false);
_currentPath = null;
}
else
{
if (point.getMoveSpeed() > 0)
{
getStat().setMoveSpeed(point.getMoveSpeed());
}
if (point.getRotationSpeed() > 0)
{
getStat().setRotationSpeed(point.getRotationSpeed());
}
final MoveData m = new MoveData();
m.disregardingGeodata = false;
m.onGeodataPathIndex = -1;
m._xDestination = point.getX();
m._yDestination = point.getY();
m._zDestination = point.getZ();
m._heading = 0;
final double dx = point.getX() - getX();
final double dy = point.getY() - getY();
final double distance = Math.sqrt((dx * dx) + (dy * dy));
if (distance > 1)
{
setHeading(Util.calculateHeadingFrom(getX(), getY(), point.getX(), point.getY()));
}
m._moveStartTime = GameTimeController.getInstance().getGameTicks();
_move = m;
GameTimeController.getInstance().registerMovingObject(this);
return true;
}
}
}
else
{
_currentPath = null;
}
}
runEngine(10);
return false;
}
@Override
public void initKnownList()
{
setKnownList(new VehicleKnownList(this));
}
@Override
public VehicleStat getStat()
{
return (VehicleStat) super.getStat();
}
@Override
public void initCharStat()
{
setStat(new VehicleStat(this));
}
public boolean isInDock()
{
return _dockId > 0;
}
public int getDockId()
{
return _dockId;
}
public void setInDock(int d)
{
_dockId = d;
}
public void setOustLoc(Location loc)
{
_oustLoc = loc;
}
public Location getOustLoc()
{
return _oustLoc != null ? _oustLoc : MapRegionManager.getInstance().getTeleToLocation(this, TeleportWhereType.TOWN);
}
public void oustPlayers()
{
_passengers.forEach(p -> oustPlayer(p));
_passengers.clear();
}
public void oustPlayer(L2PcInstance player)
{
player.setVehicle(null);
player.setInVehiclePosition(null);
removePassenger(player);
}
public boolean addPassenger(L2PcInstance player)
{
if ((player == null) || _passengers.contains(player))
{
return false;
}
// already in other vehicle
if ((player.getVehicle() != null) && (player.getVehicle() != this))
{
return false;
}
_passengers.add(player);
return true;
}
public void removePassenger(L2PcInstance player)
{
try
{
_passengers.remove(player);
}
catch (Exception e)
{
}
}
public boolean isEmpty()
{
return _passengers.isEmpty();
}
public List<L2PcInstance> getPassengers()
{
return _passengers;
}
public void broadcastToPassengers(L2GameServerPacket sm)
{
for (L2PcInstance player : _passengers)
{
if (player != null)
{
player.sendPacket(sm);
}
}
}
/**
* Consume ticket(s) and teleport player from boat if no correct ticket
* @param itemId Ticket itemId
* @param count Ticket count
* @param oustX
* @param oustY
* @param oustZ
*/
public void payForRide(int itemId, int count, int oustX, int oustY, int oustZ)
{
final Collection<L2PcInstance> passengers = getKnownList().getKnownPlayersInRadius(1000);
if ((passengers != null) && !passengers.isEmpty())
{
L2ItemInstance ticket;
InventoryUpdate iu;
for (L2PcInstance player : passengers)
{
if (player == null)
{
continue;
}
if (player.isInBoat() && (player.getBoat() == this))
{
if (itemId > 0)
{
ticket = player.getInventory().getItemByItemId(itemId);
if ((ticket == null) || (player.getInventory().destroyItem("Boat", ticket, count, player, this) == null))
{
player.sendPacket(SystemMessageId.YOU_DO_NOT_POSSESS_THE_CORRECT_TICKET_TO_BOARD_THE_BOAT);
player.teleToLocation(new Location(oustX, oustY, oustZ), true);
continue;
}
iu = new InventoryUpdate();
iu.addModifiedItem(ticket);
player.sendPacket(iu);
}
addPassenger(player);
}
}
}
}
@Override
public boolean updatePosition()
{
final boolean result = super.updatePosition();
for (L2PcInstance player : _passengers)
{
if ((player != null) && (player.getVehicle() == this))
{
player.setXYZ(getX(), getY(), getZ());
player.revalidateZone(false);
}
}
return result;
}
@Override
public void teleToLocation(ILocational loc, boolean allowRandomOffset)
{
if (isMoving())
{
stopMove(null, false);
}
setIsTeleporting(true);
getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
for (L2PcInstance player : _passengers)
{
if (player != null)
{
player.teleToLocation(loc, false);
}
}
decayMe();
setXYZ(loc.getX(), loc.getY(), loc.getZ());
// temporary fix for heading on teleports
if (loc.getHeading() != 0)
{
setHeading(loc.getHeading());
}
onTeleported();
revalidateZone(true);
}
@Override
public void stopMove(Location loc, boolean updateKnownObjects)
{
_move = null;
if (loc != null)
{
setXYZ(loc.getX(), loc.getY(), loc.getZ());
setHeading(loc.getHeading());
revalidateZone(true);
}
if (Config.MOVE_BASED_KNOWNLIST && updateKnownObjects)
{
getKnownList().findObjects();
}
}
@Override
public boolean deleteMe()
{
_engine = null;
try
{
if (isMoving())
{
stopMove(null);
}
}
catch (Exception e)
{
_log.log(Level.SEVERE, "Failed stopMove().", e);
}
try
{
oustPlayers();
}
catch (Exception e)
{
_log.log(Level.SEVERE, "Failed oustPlayers().", e);
}
final L2WorldRegion oldRegion = getWorldRegion();
try
{
decayMe();
}
catch (Exception e)
{
_log.log(Level.SEVERE, "Failed decayMe().", e);
}
if (oldRegion != null)
{
oldRegion.removeFromZones(this);
}
try
{
getKnownList().removeAllKnownObjects();
}
catch (Exception e)
{
_log.log(Level.SEVERE, "Failed cleaning knownlist.", e);
}
// Remove L2Object object from _allObjects of L2World
L2World.getInstance().removeObject(this);
return super.deleteMe();
}
@Override
public void updateAbnormalVisualEffects()
{
}
@Override
public L2ItemInstance getActiveWeaponInstance()
{
return null;
}
@Override
public L2Weapon getActiveWeaponItem()
{
return null;
}
@Override
public L2ItemInstance getSecondaryWeaponInstance()
{
return null;
}
@Override
public L2Weapon getSecondaryWeaponItem()
{
return null;
}
@Override
public int getLevel()
{
return 0;
}
@Override
public boolean isAutoAttackable(L2Character attacker)
{
return false;
}
@Override
public void detachAI()
{
}
@Override
public boolean isVehicle()
{
return true;
}
}

View File

@@ -0,0 +1,231 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.actor.appearance;
import com.l2jmobius.gameserver.enums.Sex;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
public class PcAppearance
{
public static final int DEFAULT_TITLE_COLOR = 0xECF9A2;
private L2PcInstance _owner;
private byte _face;
private byte _hairColor;
private byte _hairStyle;
private boolean _sex; // Female true(1)
/** true if the player is invisible */
private boolean _ghostmode = false;
/** The current visible name of this player, not necessarily the real one */
private String _visibleName;
/** The current visible title of this player, not necessarily the real one */
private String _visibleTitle;
/** The default name color is 0xFFFFFF. */
private int _nameColor = 0xFFFFFF;
/** The default title color is 0xECF9A2. */
private int _titleColor = DEFAULT_TITLE_COLOR;
public PcAppearance(byte face, byte hColor, byte hStyle, boolean sex)
{
_face = face;
_hairColor = hColor;
_hairStyle = hStyle;
_sex = sex;
}
/**
* @param visibleName The visibleName to set.
*/
public final void setVisibleName(String visibleName)
{
_visibleName = visibleName;
}
/**
* @return Returns the visibleName.
*/
public final String getVisibleName()
{
if (_visibleName == null)
{
return getOwner().getName();
}
return _visibleName;
}
/**
* @param visibleTitle The visibleTitle to set.
*/
public final void setVisibleTitle(String visibleTitle)
{
_visibleTitle = visibleTitle;
}
/**
* @return Returns the visibleTitle.
*/
public final String getVisibleTitle()
{
if (_visibleTitle == null)
{
return getOwner().getTitle();
}
return _visibleTitle;
}
public final byte getFace()
{
return _face;
}
/**
* @param value
*/
public final void setFace(int value)
{
_face = (byte) value;
}
public final byte getHairColor()
{
return _hairColor;
}
/**
* @param value
*/
public final void setHairColor(int value)
{
_hairColor = (byte) value;
}
public final byte getHairStyle()
{
return _hairStyle;
}
/**
* @param value
*/
public final void setHairStyle(int value)
{
_hairStyle = (byte) value;
}
/**
* @return true if char is female
*/
public final boolean getSex()
{
return _sex;
}
/**
* @return Sex of the char
*/
public Sex getSexType()
{
return _sex ? Sex.FEMALE : Sex.MALE;
}
/**
* @param isfemale
*/
public final void setSex(boolean isfemale)
{
_sex = isfemale;
}
public void setGhostMode(boolean b)
{
_ghostmode = b;
}
public boolean isGhost()
{
return _ghostmode;
}
public int getNameColor()
{
if (_owner.getReputation() != 0)
{
return 0xFFFFFF; // Using 0xFFFFFF value in case _nameColor has changed.
}
return _nameColor;
}
public void setNameColor(int nameColor)
{
if (nameColor < 0)
{
return;
}
_nameColor = nameColor;
}
public void setNameColor(int red, int green, int blue)
{
_nameColor = (red & 0xFF) + ((green & 0xFF) << 8) + ((blue & 0xFF) << 16);
}
public int getTitleColor()
{
return _titleColor;
}
public void setTitleColor(int titleColor)
{
if (titleColor < 0)
{
return;
}
_titleColor = titleColor;
}
public void setTitleColor(int red, int green, int blue)
{
_titleColor = (red & 0xFF) + ((green & 0xFF) << 8) + ((blue & 0xFF) << 16);
}
/**
* @param owner The owner to set.
*/
public void setOwner(L2PcInstance owner)
{
_owner = owner;
}
/**
* @return Returns the owner.
*/
public L2PcInstance getOwner()
{
return _owner;
}
}

View File

@@ -0,0 +1,47 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.actor.instance;
import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jmobius.gameserver.network.serverpackets.commission.ExShowCommission;
/**
* @author NosBit
*/
public class CommissionManagerInstance extends L2Npc
{
public CommissionManagerInstance(L2NpcTemplate template)
{
super(template);
setInstanceType(InstanceType.CommissionManagerInstance);
}
@Override
public void onBypassFeedback(L2PcInstance player, String command)
{
if (command.equalsIgnoreCase("show_commission"))
{
player.sendPacket(ExShowCommission.STATIC_PACKET);
}
else
{
super.onBypassFeedback(player, command);
}
}
}

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