This commit is contained in:
79
trunk/java/com/l2jserver/gameserver/model/AbsorberInfo.java
Normal file
79
trunk/java/com/l2jserver/gameserver/model/AbsorberInfo.java
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import com.l2jserver.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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
|
||||
import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.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 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;
|
||||
}
|
||||
}
|
||||
120
trunk/java/com/l2jserver/gameserver/model/ActionKey.java
Normal file
120
trunk/java/com/l2jserver/gameserver/model/ActionKey.java
Normal file
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.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 + ")";
|
||||
}
|
||||
}
|
||||
98
trunk/java/com/l2jserver/gameserver/model/AggroInfo.java
Normal file
98
trunk/java/com/l2jserver/gameserver/model/AggroInfo.java
Normal file
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import com.l2jserver.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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jserver.gameserver.instancemanager.HandysBlockCheckerManager;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.entity.BlockCheckerEngine;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jserver.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()
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
768
trunk/java/com/l2jserver/gameserver/model/AutoSpawnHandler.java
Normal file
768
trunk/java/com/l2jserver/gameserver/model/AutoSpawnHandler.java
Normal file
@@ -0,0 +1,768 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javolution.util.FastList;
|
||||
import javolution.util.FastMap;
|
||||
|
||||
import com.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.gameserver.ThreadPoolManager;
|
||||
import com.l2jserver.gameserver.datatables.NpcData;
|
||||
import com.l2jserver.gameserver.datatables.SpawnTable;
|
||||
import com.l2jserver.gameserver.idfactory.IdFactory;
|
||||
import com.l2jserver.gameserver.instancemanager.MapRegionManager;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
import com.l2jserver.gameserver.model.interfaces.IIdentifiable;
|
||||
import com.l2jserver.gameserver.util.Broadcast;
|
||||
import com.l2jserver.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;
|
||||
protected Map<Integer, ScheduledFuture<?>> _runningSpawns;
|
||||
|
||||
protected boolean _activeState = true;
|
||||
|
||||
protected AutoSpawnHandler()
|
||||
{
|
||||
_registeredSpawns = new FastMap<>();
|
||||
_runningSpawns = new FastMap<>();
|
||||
|
||||
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 = new FastMap<>();
|
||||
_runningSpawns = new FastMap<>();
|
||||
|
||||
// load
|
||||
restoreSpawnData();
|
||||
}
|
||||
|
||||
private void restoreSpawnData()
|
||||
{
|
||||
try (Connection con = L2DatabaseFactory.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.
|
||||
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;
|
||||
}
|
||||
|
||||
AutoSpawnInstance newSpawn = new AutoSpawnInstance(npcId, initialDelay, respawnDelay, despawnDelay);
|
||||
|
||||
if (spawnPoints != null)
|
||||
{
|
||||
for (int[] spawnPoint : spawnPoints)
|
||||
{
|
||||
newSpawn.addSpawnLocation(spawnPoint);
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
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;
|
||||
}
|
||||
|
||||
int objectId = spawnInst._objectId;
|
||||
|
||||
if (isSpawnRegistered(objectId))
|
||||
{
|
||||
ScheduledFuture<?> spawnTask = null;
|
||||
|
||||
if (isActive)
|
||||
{
|
||||
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
|
||||
{
|
||||
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)
|
||||
{
|
||||
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 Map<Integer, AutoSpawnInstance> getAutoSpawnInstances(int npcId)
|
||||
{
|
||||
Map<Integer, AutoSpawnInstance> spawnInstList = new FastMap<>();
|
||||
|
||||
for (AutoSpawnInstance spawnInst : _registeredSpawns.values())
|
||||
{
|
||||
if (spawnInst.getId() == npcId)
|
||||
{
|
||||
spawnInstList.put(spawnInst.getObjectId(), spawnInst);
|
||||
}
|
||||
}
|
||||
|
||||
return spawnInstList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
AutoSpawnInstance spawnInst = _registeredSpawns.get(_objectId);
|
||||
|
||||
// If the spawn is not scheduled to be active, cancel the spawn
|
||||
// task.
|
||||
if (!spawnInst.isSpawnActive())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
// Fetch the template for this NPC ID and create a new spawn.
|
||||
L2NpcTemplate npcTemp = NpcData.getInstance().getTemplate(spawnInst.getId());
|
||||
if (npcTemp == null)
|
||||
{
|
||||
_log.warning("Couldnt find NPC id" + spawnInst.getId() + " Try to update your DP");
|
||||
return;
|
||||
}
|
||||
|
||||
L2Spawn newSpawn = new L2Spawn(npcTemp);
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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
|
||||
{
|
||||
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 FastList<>();
|
||||
|
||||
private final List<Location> _locList = new FastList<>();
|
||||
|
||||
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 L2Spawn[] getSpawns()
|
||||
{
|
||||
List<L2Spawn> npcSpawns = new FastList<>();
|
||||
|
||||
for (L2Npc npcInst : _npcList)
|
||||
{
|
||||
npcSpawns.add(npcInst.getSpawn());
|
||||
}
|
||||
|
||||
return npcSpawns.toArray(new L2Spawn[npcSpawns.size()]);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
275
trunk/java/com/l2jserver/gameserver/model/BlockList.java
Normal file
275
trunk/java/com/l2jserver/gameserver/model/BlockList.java
Normal file
@@ -0,0 +1,275 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javolution.util.FastMap;
|
||||
|
||||
import com.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.gameserver.datatables.CharNameTable;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.BlockListPacket;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.2 $ $Date: 2004/06/27 08:12:59 $
|
||||
*/
|
||||
public class BlockList
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(BlockList.class.getName());
|
||||
private static Map<Integer, List<Integer>> _offlineList = new FastMap<Integer, List<Integer>>().shared();
|
||||
|
||||
private final L2PcInstance _owner;
|
||||
private List<Integer> _blockList;
|
||||
|
||||
public BlockList(L2PcInstance owner)
|
||||
{
|
||||
_owner = owner;
|
||||
_blockList = _offlineList.get(owner.getObjectId());
|
||||
if (_blockList == null)
|
||||
{
|
||||
_blockList = loadList(_owner.getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
private void addToBlockList(int target)
|
||||
{
|
||||
_blockList.add(target);
|
||||
updateInDB(target, true);
|
||||
}
|
||||
|
||||
private void removeFromBlockList(int target)
|
||||
{
|
||||
_blockList.remove(Integer.valueOf(target));
|
||||
updateInDB(target, false);
|
||||
}
|
||||
|
||||
public void playerLogout()
|
||||
{
|
||||
_offlineList.put(_owner.getObjectId(), _blockList);
|
||||
}
|
||||
|
||||
private static List<Integer> loadList(int ObjId)
|
||||
{
|
||||
List<Integer> list = new ArrayList<>();
|
||||
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1"))
|
||||
{
|
||||
statement.setInt(1, ObjId);
|
||||
try (ResultSet rset = statement.executeQuery())
|
||||
{
|
||||
int friendId;
|
||||
while (rset.next())
|
||||
{
|
||||
friendId = rset.getInt("friendId");
|
||||
if (friendId == ObjId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
list.add(friendId);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Error found in " + ObjId + " FriendList while loading BlockList: " + e.getMessage(), e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private void updateInDB(int targetId, boolean state)
|
||||
{
|
||||
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
|
||||
{
|
||||
if (state) // add
|
||||
{
|
||||
try (PreparedStatement statement = con.prepareStatement("INSERT INTO character_friends (charId, friendId, relation) VALUES (?, ?, 1)"))
|
||||
{
|
||||
statement.setInt(1, _owner.getObjectId());
|
||||
statement.setInt(2, targetId);
|
||||
statement.execute();
|
||||
}
|
||||
}
|
||||
else
|
||||
// remove
|
||||
{
|
||||
try (PreparedStatement statement = con.prepareStatement("DELETE FROM character_friends WHERE charId=? AND friendId=? AND relation=1"))
|
||||
{
|
||||
statement.setInt(1, _owner.getObjectId());
|
||||
statement.setInt(2, targetId);
|
||||
statement.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Could not add block player: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInBlockList(L2PcInstance target)
|
||||
{
|
||||
return _blockList.contains(target.getObjectId());
|
||||
}
|
||||
|
||||
public boolean isInBlockList(int targetId)
|
||||
{
|
||||
return _blockList.contains(targetId);
|
||||
}
|
||||
|
||||
private boolean isBlockAll()
|
||||
{
|
||||
return _owner.getMessageRefusal();
|
||||
}
|
||||
|
||||
public static boolean isBlocked(L2PcInstance listOwner, L2PcInstance target)
|
||||
{
|
||||
BlockList blockList = listOwner.getBlockList();
|
||||
return blockList.isBlockAll() || blockList.isInBlockList(target);
|
||||
}
|
||||
|
||||
public static boolean isBlocked(L2PcInstance listOwner, int targetId)
|
||||
{
|
||||
BlockList blockList = listOwner.getBlockList();
|
||||
return blockList.isBlockAll() || blockList.isInBlockList(targetId);
|
||||
}
|
||||
|
||||
private void setBlockAll(boolean state)
|
||||
{
|
||||
_owner.setMessageRefusal(state);
|
||||
}
|
||||
|
||||
private List<Integer> getBlockList()
|
||||
{
|
||||
return _blockList;
|
||||
}
|
||||
|
||||
public static void addToBlockList(L2PcInstance listOwner, int targetId)
|
||||
{
|
||||
if (listOwner == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
String charName = CharNameTable.getInstance().getNameById(targetId);
|
||||
|
||||
if (listOwner.getFriendList().contains(targetId))
|
||||
{
|
||||
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().contains(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);
|
||||
|
||||
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;
|
||||
|
||||
String charName = CharNameTable.getInstance().getNameById(targetId);
|
||||
|
||||
if (!listOwner.getBlockList().getBlockList().contains(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.getBlockList().getBlockList()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
L2PcInstance player = L2World.getInstance().getPlayer(ownerId);
|
||||
if (player != null)
|
||||
{
|
||||
return BlockList.isBlocked(player, targetId);
|
||||
}
|
||||
if (!_offlineList.containsKey(ownerId))
|
||||
{
|
||||
_offlineList.put(ownerId, loadList(ownerId));
|
||||
}
|
||||
return _offlineList.get(ownerId).contains(targetId);
|
||||
}
|
||||
}
|
||||
1751
trunk/java/com/l2jserver/gameserver/model/CharEffectList.java
Normal file
1751
trunk/java/com/l2jserver/gameserver/model/CharEffectList.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,400 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import com.l2jserver.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jserver.gameserver.model.itemcontainer.PcInventory;
|
||||
import com.l2jserver.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 _karma = 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 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 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 getEnchantEffect()
|
||||
{
|
||||
return _paperdoll[Inventory.PAPERDOLL_RHAND][2];
|
||||
}
|
||||
|
||||
public void setKarma(int k)
|
||||
{
|
||||
_karma = k;
|
||||
}
|
||||
|
||||
public int getKarma()
|
||||
{
|
||||
return _karma;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
51
trunk/java/com/l2jserver/gameserver/model/ClanInfo.java
Normal file
51
trunk/java/com/l2jserver/gameserver/model/ClanInfo.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.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;
|
||||
}
|
||||
}
|
||||
64
trunk/java/com/l2jserver/gameserver/model/ClanPrivilege.java
Normal file
64
trunk/java/com/l2jserver/gameserver/model/ClanPrivilege.java
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (C) - LJ Server
|
||||
*
|
||||
* This file is part of LJ Server.
|
||||
*
|
||||
* LJ Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* LJ Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.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();
|
||||
}
|
||||
}
|
||||
128
trunk/java/com/l2jserver/gameserver/model/CombatFlag.java
Normal file
128
trunk/java/com/l2jserver/gameserver/model/CombatFlag.java
Normal file
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.datatables.ItemTable;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ItemList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
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);
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EQUIPPED_YOUR_S1);
|
||||
sm.addItemName(_item);
|
||||
_player.sendPacket(sm);
|
||||
|
||||
// Refresh inventory
|
||||
if (!Config.FORCE_INVENTORY_UPDATE)
|
||||
{
|
||||
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);
|
||||
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;
|
||||
}
|
||||
}
|
||||
38
trunk/java/com/l2jserver/gameserver/model/CropProcure.java
Normal file
38
trunk/java/com/l2jserver/gameserver/model/CropProcure.java
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jserver.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;
|
||||
}
|
||||
}
|
||||
748
trunk/java/com/l2jserver/gameserver/model/CursedWeapon.java
Normal file
748
trunk/java/com/l2jserver/gameserver/model/CursedWeapon.java
Normal file
@@ -0,0 +1,748 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.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.l2jserver.Config;
|
||||
import com.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.gameserver.ThreadPoolManager;
|
||||
import com.l2jserver.gameserver.datatables.SkillData;
|
||||
import com.l2jserver.gameserver.datatables.TransformData;
|
||||
import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
|
||||
import com.l2jserver.gameserver.model.L2Party.messageType;
|
||||
import com.l2jserver.gameserver.model.actor.L2Attackable;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.interfaces.INamable;
|
||||
import com.l2jserver.gameserver.model.items.L2Item;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.model.skills.CommonSkill;
|
||||
import com.l2jserver.gameserver.model.skills.Skill;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.Earthquake;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExRedSky;
|
||||
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ItemList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SocialAction;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.UserInfo;
|
||||
import com.l2jserver.gameserver.util.Broadcast;
|
||||
import com.l2jserver.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 _playerKarma = 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.setKarma(_playerKarma);
|
||||
_player.setPkKills(_playerPkKills);
|
||||
_player.setCursedWeaponEquippedId(0);
|
||||
removeSkill();
|
||||
|
||||
// Remove
|
||||
_player.getInventory().unEquipItemInBodySlot(L2Item.SLOT_LR_HAND);
|
||||
_player.storeMe();
|
||||
|
||||
// Destroy
|
||||
L2ItemInstance removedItem = _player.getInventory().destroyItemByItemId("", _itemId, 1, _player, null);
|
||||
if (!Config.FORCE_INVENTORY_UPDATE)
|
||||
{
|
||||
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 = L2DatabaseFactory.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, _playerKarma);
|
||||
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
|
||||
L2ItemInstance removedItem = _player.getInventory().destroyItemByItemId("", _itemId, 1, _player, null);
|
||||
if (!Config.FORCE_INVENTORY_UPDATE)
|
||||
{
|
||||
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);
|
||||
|
||||
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;
|
||||
_playerKarma = 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
|
||||
ExRedSky packet = new ExRedSky(10);
|
||||
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.setKarma(_playerKarma);
|
||||
_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;
|
||||
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();
|
||||
|
||||
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);
|
||||
|
||||
CursedWeapon cw = CursedWeaponsManager.getInstance().getCursedWeapon(_player.getCursedWeaponEquippedId());
|
||||
SystemMessage msg2 = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_S2_MINUTE_S_OF_USAGE_TIME_REMAINING);
|
||||
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.getId());
|
||||
_player.addSkill(CommonSkill.VOID_FLOW.getSkill(), false);
|
||||
_player.addTransformSkill(CommonSkill.VOID_FLOW.getId());
|
||||
_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();
|
||||
_playerKarma = _player.getKarma();
|
||||
_playerPkKills = _player.getPkKills();
|
||||
saveData();
|
||||
|
||||
// Change player stats
|
||||
_player.setCursedWeaponEquippedId(_itemId);
|
||||
_player.setKarma(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)
|
||||
{
|
||||
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();
|
||||
|
||||
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 = L2DatabaseFactory.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, _playerKarma);
|
||||
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.setKarma(_playerKarma);
|
||||
_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)
|
||||
{
|
||||
_playerKarma = 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 _playerKarma;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* @author xban1x
|
||||
*/
|
||||
public final class DamageDoneInfo
|
||||
{
|
||||
private final L2PcInstance _attacker;
|
||||
private int _damage = 0;
|
||||
|
||||
public DamageDoneInfo(L2PcInstance attacker, int damage)
|
||||
{
|
||||
_attacker = attacker;
|
||||
_damage = damage;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.awt.Polygon;
|
||||
import java.awt.Shape;
|
||||
|
||||
import javolution.util.FastList;
|
||||
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.util.Rnd;
|
||||
|
||||
/**
|
||||
* Dimensional Rift Room.
|
||||
* @author xban1x
|
||||
*/
|
||||
public final class DimensionalRiftRoom
|
||||
{
|
||||
private final byte _type;
|
||||
private final byte _room;
|
||||
private final int _xMin;
|
||||
private final int _xMax;
|
||||
private final int _yMin;
|
||||
private final int _yMax;
|
||||
private final int _zMin;
|
||||
private final int _zMax;
|
||||
private final Location _teleportCoords;
|
||||
private final Shape _s;
|
||||
private final boolean _isBossRoom;
|
||||
private final FastList<L2Spawn> _roomSpawns;
|
||||
protected final FastList<L2Npc> _roomMobs;
|
||||
private boolean _partyInside = false;
|
||||
|
||||
public DimensionalRiftRoom(byte type, byte room, int xMin, int xMax, int yMin, int yMax, int zMin, int zMax, int xT, int yT, int zT, boolean isBossRoom)
|
||||
{
|
||||
_type = type;
|
||||
_room = room;
|
||||
_xMin = (xMin + 128);
|
||||
_xMax = (xMax - 128);
|
||||
_yMin = (yMin + 128);
|
||||
_yMax = (yMax - 128);
|
||||
_zMin = zMin;
|
||||
_zMax = zMax;
|
||||
_teleportCoords = new Location(xT, yT, zT);
|
||||
_isBossRoom = isBossRoom;
|
||||
_roomSpawns = new FastList<>();
|
||||
_roomMobs = new FastList<>();
|
||||
_s = new Polygon(new int[]
|
||||
{
|
||||
xMin,
|
||||
xMax,
|
||||
xMax,
|
||||
xMin
|
||||
}, new int[]
|
||||
{
|
||||
yMin,
|
||||
yMin,
|
||||
yMax,
|
||||
yMax
|
||||
}, 4);
|
||||
}
|
||||
|
||||
public byte getType()
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
public byte getRoom()
|
||||
{
|
||||
return _room;
|
||||
}
|
||||
|
||||
public int getRandomX()
|
||||
{
|
||||
return Rnd.get(_xMin, _xMax);
|
||||
}
|
||||
|
||||
public int getRandomY()
|
||||
{
|
||||
return Rnd.get(_yMin, _yMax);
|
||||
}
|
||||
|
||||
public Location getTeleportCoorinates()
|
||||
{
|
||||
return _teleportCoords;
|
||||
}
|
||||
|
||||
public boolean checkIfInZone(int x, int y, int z)
|
||||
{
|
||||
return _s.contains(x, y) && (z >= _zMin) && (z <= _zMax);
|
||||
}
|
||||
|
||||
public boolean isBossRoom()
|
||||
{
|
||||
return _isBossRoom;
|
||||
}
|
||||
|
||||
public FastList<L2Spawn> getSpawns()
|
||||
{
|
||||
return _roomSpawns;
|
||||
}
|
||||
|
||||
public void spawn()
|
||||
{
|
||||
for (L2Spawn spawn : _roomSpawns)
|
||||
{
|
||||
spawn.doSpawn();
|
||||
spawn.startRespawn();
|
||||
}
|
||||
}
|
||||
|
||||
public DimensionalRiftRoom unspawn()
|
||||
{
|
||||
for (L2Spawn spawn : _roomSpawns)
|
||||
{
|
||||
spawn.stopRespawn();
|
||||
if (spawn.getLastSpawn() != null)
|
||||
{
|
||||
spawn.getLastSpawn().deleteMe();
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if party is inside the room.
|
||||
* @return {@code true} if there is a party inside, {@code false} otherwise
|
||||
*/
|
||||
public boolean isPartyInside()
|
||||
{
|
||||
return _partyInside;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the party inside.
|
||||
* @param partyInside
|
||||
*/
|
||||
public void setPartyInside(boolean partyInside)
|
||||
{
|
||||
_partyInside = partyInside;
|
||||
}
|
||||
}
|
||||
110
trunk/java/com/l2jserver/gameserver/model/DropProtection.java
Normal file
110
trunk/java/com/l2jserver/gameserver/model/DropProtection.java
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import com.l2jserver.gameserver.ThreadPoolManager;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.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);
|
||||
}
|
||||
}
|
||||
361
trunk/java/com/l2jserver/gameserver/model/Elementals.java
Normal file
361
trunk/java/com/l2jserver/gameserver/model/Elementals.java
Normal file
@@ -0,0 +1,361 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.stats.Stats;
|
||||
import com.l2jserver.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),
|
||||
Crystal(6),
|
||||
Jewel(9),
|
||||
Energy(12);
|
||||
|
||||
public int _maxLevel;
|
||||
|
||||
private ElementalItemType(int maxLvl)
|
||||
{
|
||||
_maxLevel = maxLvl;
|
||||
}
|
||||
}
|
||||
|
||||
public static enum ElementalItems
|
||||
{
|
||||
fireStone(FIRE, 9546, ElementalItemType.Stone),
|
||||
waterStone(WATER, 9547, ElementalItemType.Stone),
|
||||
windStone(WIND, 9549, ElementalItemType.Stone),
|
||||
earthStone(EARTH, 9548, ElementalItemType.Stone),
|
||||
divineStone(HOLY, 9551, ElementalItemType.Stone),
|
||||
darkStone(DARK, 9550, ElementalItemType.Stone),
|
||||
|
||||
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),
|
||||
|
||||
fireCrystal(FIRE, 9552, ElementalItemType.Crystal),
|
||||
waterCrystal(WATER, 9553, ElementalItemType.Crystal),
|
||||
windCrystal(WIND, 9555, ElementalItemType.Crystal),
|
||||
earthCrystal(EARTH, 9554, ElementalItemType.Crystal),
|
||||
divineCrystal(HOLY, 9557, ElementalItemType.Crystal),
|
||||
darkCrystal(DARK, 9556, ElementalItemType.Crystal),
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import com.l2jserver.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;
|
||||
}
|
||||
}
|
||||
85
trunk/java/com/l2jserver/gameserver/model/Hit.java
Normal file
85
trunk/java/com/l2jserver/gameserver/model/Hit.java
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import com.l2jserver.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;
|
||||
}
|
||||
else if (target.isInvul() || (shld > 0))
|
||||
{
|
||||
addMask(AttackType.BLOCKED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (crit)
|
||||
{
|
||||
addMask(AttackType.CRITICAL);
|
||||
}
|
||||
|
||||
if (soulshot)
|
||||
{
|
||||
addMask(AttackType.SHOT_USED);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
380
trunk/java/com/l2jserver/gameserver/model/ItemInfo.java
Normal file
380
trunk/java/com/l2jserver/gameserver/model/ItemInfo.java
Normal file
@@ -0,0 +1,380 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import com.l2jserver.gameserver.model.buylist.Product;
|
||||
import com.l2jserver.gameserver.model.items.L2Item;
|
||||
import com.l2jserver.gameserver.model.items.L2WarehouseItem;
|
||||
import com.l2jserver.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;
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
|
||||
public ItemInfo(L2ItemInstance item, int change)
|
||||
{
|
||||
this(item);
|
||||
_change = change;
|
||||
}
|
||||
|
||||
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
|
||||
_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();
|
||||
}
|
||||
|
||||
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 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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
90
trunk/java/com/l2jserver/gameserver/model/ItemRequest.java
Normal file
90
trunk/java/com/l2jserver/gameserver/model/ItemRequest.java
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.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);
|
||||
}
|
||||
}
|
||||
229
trunk/java/com/l2jserver/gameserver/model/L2AccessLevel.java
Normal file
229
trunk/java/com/l2jserver/gameserver/model/L2AccessLevel.java
Normal file
@@ -0,0 +1,229 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import com.l2jserver.gameserver.datatables.AdminTable;
|
||||
|
||||
/**
|
||||
* @author HorridoJoho
|
||||
*/
|
||||
public class L2AccessLevel
|
||||
{
|
||||
/** The access level<br> */
|
||||
private int _accessLevel = 0;
|
||||
/** The access level name<br> */
|
||||
private String _name = null;
|
||||
/** Child access levels */
|
||||
L2AccessLevel _childsAccessLevel = null;
|
||||
/** Child access levels */
|
||||
private int _child = 0;
|
||||
/** The name color for the access level<br> */
|
||||
private int _nameColor = 0;
|
||||
/** The title color for the access level<br> */
|
||||
private int _titleColor = 0;
|
||||
/** Flag to determine if the access level has gm access<br> */
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the access level<br>
|
||||
* <br>
|
||||
* @return int: access level<br>
|
||||
*/
|
||||
public int getLevel()
|
||||
{
|
||||
return _accessLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the access level name<br>
|
||||
* <br>
|
||||
* @return String: access level name<br>
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name color of the access level<br>
|
||||
* <br>
|
||||
* @return int: the name color for the access level<br>
|
||||
*/
|
||||
public int getNameColor()
|
||||
{
|
||||
return _nameColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the title color color of the access level<br>
|
||||
* <br>
|
||||
* @return int: the title color for the access level<br>
|
||||
*/
|
||||
public int getTitleColor()
|
||||
{
|
||||
return _titleColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retuns if the access level has gm access or not<br>
|
||||
* <br>
|
||||
* @return boolean: true if access level have gm access, otherwise false<br>
|
||||
*/
|
||||
public boolean isGm()
|
||||
{
|
||||
return _isGm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the access level is allowed to attack in peace zone or not<br>
|
||||
* <br>
|
||||
* @return boolean: true if the access level is allowed to attack in peace zone, otherwise false<br>
|
||||
*/
|
||||
public boolean allowPeaceAttack()
|
||||
{
|
||||
return _allowPeaceAttack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retruns if the access level is allowed to use fixed res or not<br>
|
||||
* <br>
|
||||
* @return true if the access level is allowed to use fixed res, otherwise false<br>
|
||||
*/
|
||||
public boolean allowFixedRes()
|
||||
{
|
||||
return _allowFixedRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the access level is allowed to perform transactions or not<br>
|
||||
* <br>
|
||||
* @return boolean: true if access level is allowed to perform transactions, otherwise false<br>
|
||||
*/
|
||||
public boolean allowTransaction()
|
||||
{
|
||||
return _allowTransaction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the access level is allowed to use AltG commands or not<br>
|
||||
* <br>
|
||||
* @return boolean: true if access level is allowed to use AltG commands, otherwise false<br>
|
||||
*/
|
||||
public boolean allowAltG()
|
||||
{
|
||||
return _allowAltG;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the access level can give damage or not<br>
|
||||
* <br>
|
||||
* @return boolean: true if the access level can give damage, otherwise false<br>
|
||||
*/
|
||||
public boolean canGiveDamage()
|
||||
{
|
||||
return _giveDamage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the access level can take aggro or not<br>
|
||||
* <br>
|
||||
* @return boolean: true if the access level can take aggro, otherwise false<br>
|
||||
*/
|
||||
public boolean canTakeAggro()
|
||||
{
|
||||
return _takeAggro;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the access level can gain exp or not<br>
|
||||
* <br>
|
||||
* @return boolean: true if the access level can gain exp, otherwise false<br>
|
||||
*/
|
||||
public boolean canGainExp()
|
||||
{
|
||||
return _gainExp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the access level contains allowedAccess as child<br>
|
||||
* @param accessLevel as AccessLevel<br>
|
||||
* @return boolean: true if a child access level is equals to allowedAccess, otherwise false<br>
|
||||
*/
|
||||
public boolean hasChildAccess(L2AccessLevel accessLevel)
|
||||
{
|
||||
if (_childsAccessLevel == null)
|
||||
{
|
||||
if (_child <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_childsAccessLevel = AdminTable.getInstance().getAccessLevel(_child);
|
||||
}
|
||||
return ((_childsAccessLevel.getLevel() == accessLevel.getLevel()) || _childsAccessLevel.hasChildAccess(accessLevel));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import com.l2jserver.gameserver.datatables.AdminTable;
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
L2AccessLevel accessLevel = AdminTable.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;
|
||||
}
|
||||
}
|
||||
361
trunk/java/com/l2jserver/gameserver/model/L2ArmorSet.java
Normal file
361
trunk/java/com/l2jserver/gameserver/model/L2ArmorSet.java
Normal file
@@ -0,0 +1,361 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.holders.ArmorsetSkillHolder;
|
||||
import com.l2jserver.gameserver.model.holders.SkillHolder;
|
||||
import com.l2jserver.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jserver.gameserver.model.itemcontainer.PcInventory;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
|
||||
/**
|
||||
* @author Luno
|
||||
*/
|
||||
public final class L2ArmorSet
|
||||
{
|
||||
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 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<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 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)
|
||||
{
|
||||
Inventory inv = player.getInventory();
|
||||
|
||||
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 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;
|
||||
}
|
||||
}
|
||||
136
trunk/java/com/l2jserver/gameserver/model/L2Augmentation.java
Normal file
136
trunk/java/com/l2jserver/gameserver/model/L2Augmentation.java
Normal file
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.gameserver.datatables.OptionsData;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.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;
|
||||
int[] stats = new int[2];
|
||||
stats[0] = 0x0000FFFF & augmentationId;
|
||||
stats[1] = (augmentationId >> 16);
|
||||
|
||||
for (int stat : stats)
|
||||
{
|
||||
Options op = OptionsData.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);
|
||||
}
|
||||
}
|
||||
3057
trunk/java/com/l2jserver/gameserver/model/L2Clan.java
Normal file
3057
trunk/java/com/l2jserver/gameserver/model/L2Clan.java
Normal file
File diff suppressed because it is too large
Load Diff
764
trunk/java/com/l2jserver/gameserver/model/L2ClanMember.java
Normal file
764
trunk/java/com/l2jserver/gameserver/model/L2ClanMember.java
Normal file
@@ -0,0 +1,764 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.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.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.gameserver.instancemanager.SiegeManager;
|
||||
import com.l2jserver.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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is online.
|
||||
* @return true, if is online
|
||||
*/
|
||||
public boolean isOnline()
|
||||
{
|
||||
if ((_player == null) || !_player.isOnline())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_player.getClient() == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_player.getClient().isDetached())
|
||||
{
|
||||
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 = L2DatabaseFactory.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 = L2DatabaseFactory.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)
|
||||
{
|
||||
L2ClanMember apprentice = _clan.getClanMember(_apprentice);
|
||||
if (apprentice != null)
|
||||
{
|
||||
return apprentice.getName();
|
||||
}
|
||||
return "Error";
|
||||
}
|
||||
if (_sponsor != 0)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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 = L2DatabaseFactory.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
267
trunk/java/com/l2jserver/gameserver/model/L2CommandChannel.java
Normal file
267
trunk/java/com/l2jserver/gameserver/model/L2CommandChannel.java
Normal file
@@ -0,0 +1,267 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javolution.util.FastList;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExCloseMPCC;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExMPCCPartyInfoUpdate;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExOpenMPCC;
|
||||
import com.l2jserver.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;
|
||||
private L2PcInstance _commandLeader = null;
|
||||
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;
|
||||
L2Party party = leader.getParty();
|
||||
_parties = new FastList<L2Party>().shared();
|
||||
_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()
|
||||
{
|
||||
List<L2PcInstance> members = new FastList<L2PcInstance>().shared();
|
||||
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.l2jserver.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());
|
||||
}
|
||||
}
|
||||
188
trunk/java/com/l2jserver/gameserver/model/L2ContactList.java
Normal file
188
trunk/java/com/l2jserver/gameserver/model/L2ContactList.java
Normal file
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javolution.util.FastList;
|
||||
|
||||
import com.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.gameserver.datatables.CharNameTable;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.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;
|
||||
|
||||
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;
|
||||
_contacts = new FastList<String>().shared();
|
||||
restore();
|
||||
}
|
||||
|
||||
public void restore()
|
||||
{
|
||||
_contacts.clear();
|
||||
|
||||
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(QUERY_LOAD))
|
||||
{
|
||||
statement.setInt(1, activeChar.getObjectId());
|
||||
try (ResultSet rset = statement.executeQuery())
|
||||
{
|
||||
int contactId;
|
||||
String contactName;
|
||||
while (rset.next())
|
||||
{
|
||||
contactId = rset.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;
|
||||
|
||||
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 = L2DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(QUERY_ADD))
|
||||
{
|
||||
statement.setInt(1, activeChar.getObjectId());
|
||||
statement.setInt(2, contactId);
|
||||
statement.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)
|
||||
{
|
||||
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 = L2DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(QUERY_REMOVE))
|
||||
{
|
||||
statement.setInt(1, activeChar.getObjectId());
|
||||
statement.setInt(2, contactId);
|
||||
statement.execute();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
122
trunk/java/com/l2jserver/gameserver/model/L2Crest.java
Normal file
122
trunk/java/com/l2jserver/gameserver/model/L2Crest.java
Normal file
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.interfaces.IIdentifiable;
|
||||
import com.l2jserver.gameserver.network.serverpackets.AllyCrest;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExPledgeCrestLarge;
|
||||
import com.l2jserver.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(), getData()));
|
||||
path = "Crest.crest_" + Config.SERVER_ID + "_" + getId();
|
||||
break;
|
||||
}
|
||||
case PLEDGE_LARGE:
|
||||
{
|
||||
activeChar.sendPacket(new ExPledgeCrestLarge(getId(), getData()));
|
||||
path = "Crest.crest_" + Config.SERVER_ID + "_" + getId() + "_l";
|
||||
break;
|
||||
}
|
||||
case ALLY:
|
||||
{
|
||||
activeChar.sendPacket(new AllyCrest(getId(), getData()));
|
||||
path = "Crest.crest_" + Config.SERVER_ID + "_" + getId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return path;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jserver.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[24];
|
||||
for (int i = 0; i < 24; 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];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import com.l2jserver.gameserver.datatables.EnchantSkillGroupsData;
|
||||
import com.l2jserver.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 / 100);
|
||||
}
|
||||
|
||||
public static int getEnchantIndex(int level)
|
||||
{
|
||||
return (level % 100) - 1;
|
||||
}
|
||||
|
||||
public static int getEnchantType(int level)
|
||||
{
|
||||
return ((level - 1) / 100) - 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 % 100) == 1)
|
||||
{
|
||||
return _baseLvl;
|
||||
}
|
||||
return level - 1;
|
||||
}
|
||||
|
||||
public boolean isMaxEnchant(int level)
|
||||
{
|
||||
int enchantType = getEnchantRoute(level);
|
||||
if ((enchantType < 1) || !_enchantRoutes.containsKey(enchantType))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int index = getEnchantIndex(level);
|
||||
|
||||
if ((index + 1) >= EnchantSkillGroupsData.getInstance().getEnchantSkillGroupById(_enchantRoutes.get(enchantType)).getEnchantGroupDetails().size())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public EnchantSkillHolder getEnchantSkillHolder(int level)
|
||||
{
|
||||
int enchantType = getEnchantRoute(level);
|
||||
if ((enchantType < 1) || !_enchantRoutes.containsKey(enchantType))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
int index = getEnchantIndex(level);
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
/**
|
||||
* @author JIV
|
||||
*/
|
||||
public class L2ExtractableProduct
|
||||
{
|
||||
private final int _id;
|
||||
private final int _min;
|
||||
private final int _max;
|
||||
private final int _chance;
|
||||
|
||||
/**
|
||||
* Create Extractable product
|
||||
* @param id crete item id
|
||||
* @param min item count max
|
||||
* @param max item count min
|
||||
* @param chance chance for creating
|
||||
*/
|
||||
public L2ExtractableProduct(int id, int min, int max, double chance)
|
||||
{
|
||||
_id = id;
|
||||
_min = min;
|
||||
_max = max;
|
||||
_chance = (int) (chance * 1000);
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public int getMin()
|
||||
{
|
||||
return _min;
|
||||
}
|
||||
|
||||
public int getMax()
|
||||
{
|
||||
return _max;
|
||||
}
|
||||
|
||||
public int getChance()
|
||||
{
|
||||
return _chance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jserver.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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.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;
|
||||
}
|
||||
}
|
||||
110
trunk/java/com/l2jserver/gameserver/model/L2GroupSpawn.java
Normal file
110
trunk/java/com/l2jserver/gameserver/model/L2GroupSpawn.java
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.datatables.TerritoryTable;
|
||||
import com.l2jserver.gameserver.idfactory.IdFactory;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2ControllableMobInstance;
|
||||
import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
import com.l2jserver.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(IdFactory.getInstance().getNextId(), _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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import com.l2jserver.gameserver.datatables.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;
|
||||
}
|
||||
}
|
||||
222
trunk/java/com/l2jserver/gameserver/model/L2MapRegion.java
Normal file
222
trunk/java/com/l2jserver/gameserver/model/L2MapRegion.java
Normal file
@@ -0,0 +1,222 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.enums.Race;
|
||||
import com.l2jserver.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;
|
||||
}
|
||||
}
|
||||
133
trunk/java/com/l2jserver/gameserver/model/L2Mentee.java
Normal file
133
trunk/java/com/l2jserver/gameserver/model/L2Mentee.java
Normal file
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.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.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.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()
|
||||
{
|
||||
L2PcInstance player = getPlayerInstance();
|
||||
if (player == null) // Only if player is offline
|
||||
{
|
||||
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("SELECT char_name, level, base_class FROM characters WHERE charId = ?"))
|
||||
{
|
||||
statement.setInt(1, getObjectId());
|
||||
try (ResultSet rset = statement.executeQuery())
|
||||
{
|
||||
if (rset.next())
|
||||
{
|
||||
_name = rset.getString("char_name");
|
||||
_classId = rset.getInt("base_class");
|
||||
_currentLevel = rset.getInt("level");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_name = player.getName();
|
||||
_classId = player.getBaseClass();
|
||||
_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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import com.l2jserver.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;
|
||||
}
|
||||
}
|
||||
1020
trunk/java/com/l2jserver/gameserver/model/L2Object.java
Normal file
1020
trunk/java/com/l2jserver/gameserver/model/L2Object.java
Normal file
File diff suppressed because it is too large
Load Diff
1129
trunk/java/com/l2jserver/gameserver/model/L2Party.java
Normal file
1129
trunk/java/com/l2jserver/gameserver/model/L2Party.java
Normal file
File diff suppressed because it is too large
Load Diff
254
trunk/java/com/l2jserver/gameserver/model/L2PetData.java
Normal file
254
trunk/java/com/l2jserver/gameserver/model/L2PetData.java
Normal file
@@ -0,0 +1,254 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.l2jserver.gameserver.datatables.SkillData;
|
||||
import com.l2jserver.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
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
220
trunk/java/com/l2jserver/gameserver/model/L2PetLevelData.java
Normal file
220
trunk/java/com/l2jserver/gameserver/model/L2PetLevelData.java
Normal file
@@ -0,0 +1,220 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import com.l2jserver.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;
|
||||
}
|
||||
}
|
||||
56
trunk/java/com/l2jserver/gameserver/model/L2PremiumItem.java
Normal file
56
trunk/java/com/l2jserver/gameserver/model/L2PremiumItem.java
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.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;
|
||||
}
|
||||
}
|
||||
130
trunk/java/com/l2jserver/gameserver/model/L2Radar.java
Normal file
130
trunk/java/com/l2jserver/gameserver/model/L2Radar.java
Normal file
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import javolution.util.FastList;
|
||||
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.RadarControl;
|
||||
|
||||
/**
|
||||
* @author dalrond
|
||||
*/
|
||||
public final class L2Radar
|
||||
{
|
||||
private final L2PcInstance _player;
|
||||
private final FastList<RadarMarker> _markers;
|
||||
|
||||
public L2Radar(L2PcInstance player)
|
||||
{
|
||||
_player = player;
|
||||
_markers = new FastList<>();
|
||||
}
|
||||
|
||||
// Add a marker to player's radar
|
||||
public void addMarker(int x, int y, int z)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.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;
|
||||
}
|
||||
|
||||
}
|
||||
244
trunk/java/com/l2jserver/gameserver/model/L2RecipeList.java
Normal file
244
trunk/java/com/l2jserver/gameserver/model/L2RecipeList.java
Normal file
@@ -0,0 +1,244 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.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)
|
||||
{
|
||||
int len = _recipes.length;
|
||||
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)
|
||||
{
|
||||
int len = _statUse.length;
|
||||
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)
|
||||
{
|
||||
int len = _altStatChange.length;
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import com.l2jserver.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;
|
||||
}
|
||||
|
||||
}
|
||||
150
trunk/java/com/l2jserver/gameserver/model/L2Request.java
Normal file
150
trunk/java/com/l2jserver/gameserver/model/L2Request.java
Normal file
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import com.l2jserver.gameserver.ThreadPoolManager;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket;
|
||||
import com.l2jserver.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())
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
139
trunk/java/com/l2jserver/gameserver/model/L2Seed.java
Normal file
139
trunk/java/com/l2jserver/gameserver/model/L2Seed.java
Normal file
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.datatables.ItemTable;
|
||||
import com.l2jserver.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 + "]";
|
||||
}
|
||||
}
|
||||
112
trunk/java/com/l2jserver/gameserver/model/L2SiegeClan.java
Normal file
112
trunk/java/com/l2jserver/gameserver/model/L2SiegeClan.java
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javolution.util.FastList;
|
||||
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
|
||||
public class L2SiegeClan
|
||||
{
|
||||
private int _clanId = 0;
|
||||
private List<L2Npc> _flag = new FastList<>();
|
||||
private int _numFlagsAdded = 0;
|
||||
private SiegeClanType _type;
|
||||
|
||||
public enum SiegeClanType
|
||||
{
|
||||
OWNER,
|
||||
DEFENDER,
|
||||
ATTACKER,
|
||||
DEFENDER_PENDING
|
||||
}
|
||||
|
||||
public L2SiegeClan(int clanId, SiegeClanType type)
|
||||
{
|
||||
_clanId = clanId;
|
||||
_type = type;
|
||||
}
|
||||
|
||||
public int getNumFlags()
|
||||
{
|
||||
return _numFlagsAdded;
|
||||
}
|
||||
|
||||
public void addFlag(L2Npc flag)
|
||||
{
|
||||
_numFlagsAdded++;
|
||||
getFlag().add(flag);
|
||||
}
|
||||
|
||||
public boolean removeFlag(L2Npc flag)
|
||||
{
|
||||
if (flag == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
boolean ret = getFlag().remove(flag);
|
||||
// check if null objects or duplicates remain in the list.
|
||||
// for some reason, this might be happening sometimes...
|
||||
// delete false duplicates: if this flag got deleted, delete its copies too.
|
||||
if (ret)
|
||||
{
|
||||
while (getFlag().remove(flag))
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
flag.deleteMe();
|
||||
_numFlagsAdded--;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void removeFlags()
|
||||
{
|
||||
for (L2Npc flag : getFlag())
|
||||
{
|
||||
removeFlag(flag);
|
||||
}
|
||||
}
|
||||
|
||||
public final int getClanId()
|
||||
{
|
||||
return _clanId;
|
||||
}
|
||||
|
||||
public final List<L2Npc> getFlag()
|
||||
{
|
||||
if (_flag == null)
|
||||
{
|
||||
_flag = new FastList<>();
|
||||
}
|
||||
return _flag;
|
||||
}
|
||||
|
||||
public SiegeClanType getType()
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
public void setType(SiegeClanType setType)
|
||||
{
|
||||
_type = setType;
|
||||
}
|
||||
}
|
||||
306
trunk/java/com/l2jserver/gameserver/model/L2SkillLearn.java
Normal file
306
trunk/java/com/l2jserver/gameserver/model/L2SkillLearn.java
Normal file
@@ -0,0 +1,306 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.enums.Race;
|
||||
import com.l2jserver.gameserver.model.base.ClassId;
|
||||
import com.l2jserver.gameserver.model.base.SocialClass;
|
||||
import com.l2jserver.gameserver.model.holders.ItemHolder;
|
||||
import com.l2jserver.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 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 List<SubClassData> _subClassLvlNumber = new ArrayList<>();
|
||||
private final boolean _learnedByNpc;
|
||||
private final boolean _learnedByFS;
|
||||
|
||||
public class SubClassData
|
||||
{
|
||||
private final int slot;
|
||||
private final int lvl;
|
||||
|
||||
public SubClassData(int pSlot, int pLvl)
|
||||
{
|
||||
slot = pSlot;
|
||||
lvl = pLvl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the sub-class slot.
|
||||
*/
|
||||
public int getSlot()
|
||||
{
|
||||
return slot;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the required sub-class level.
|
||||
*/
|
||||
public int getLvl()
|
||||
{
|
||||
return lvl;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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");
|
||||
_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 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 a list with Sub-Class conditions, amount of subclasses and level.
|
||||
*/
|
||||
public List<SubClassData> getSubClassConditions()
|
||||
{
|
||||
return _subClassLvlNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a required residence Id.
|
||||
* @param slot the sub-class slot.
|
||||
* @param lvl the required sub-class level.
|
||||
*/
|
||||
public void addSubclassConditions(int slot, int lvl)
|
||||
{
|
||||
_subClassLvlNumber.add(new SubClassData(slot, lvl));
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
818
trunk/java/com/l2jserver/gameserver/model/L2Spawn.java
Normal file
818
trunk/java/com/l2jserver/gameserver/model/L2Spawn.java
Normal file
@@ -0,0 +1,818 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javolution.util.FastList;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.GeoData;
|
||||
import com.l2jserver.gameserver.ThreadPoolManager;
|
||||
import com.l2jserver.gameserver.datatables.NpcPersonalAIData;
|
||||
import com.l2jserver.gameserver.datatables.TerritoryTable;
|
||||
import com.l2jserver.gameserver.idfactory.IdFactory;
|
||||
import com.l2jserver.gameserver.model.actor.L2Attackable;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
import com.l2jserver.gameserver.model.interfaces.IIdentifiable;
|
||||
import com.l2jserver.gameserver.model.interfaces.ILocational;
|
||||
import com.l2jserver.gameserver.model.interfaces.INamable;
|
||||
import com.l2jserver.gameserver.model.interfaces.IPositionable;
|
||||
import com.l2jserver.gameserver.model.zone.type.NpcSpawnTerritory;
|
||||
import com.l2jserver.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 FastList<>();
|
||||
private final FastList<L2Npc> _spawnedNpcs = new FastList<>();
|
||||
private Map<Integer, Location> _lastSpawnPoints;
|
||||
private boolean _isNoRndWalk = false; // Is no random walk
|
||||
|
||||
/** 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;
|
||||
}
|
||||
|
||||
String className = "com.l2jserver.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(int.class, L2NpcTemplate.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
L2Npc npc = _constructor.newInstance(IdFactory.getInstance().getNextId(), _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())
|
||||
{
|
||||
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 the exact position (Lox, Locy, Locz)
|
||||
newlocx = getX();
|
||||
newlocy = getY();
|
||||
newlocz = getZ();
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
synchronized (_spawnListeners)
|
||||
{
|
||||
_spawnListeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeSpawnListener(SpawnListener listener)
|
||||
{
|
||||
synchronized (_spawnListeners)
|
||||
{
|
||||
_spawnListeners.remove(listener);
|
||||
}
|
||||
}
|
||||
|
||||
public static void notifyNpcSpawned(L2Npc npc)
|
||||
{
|
||||
synchronized (_spawnListeners)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
int minDelay = delay - randomInterval;
|
||||
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()
|
||||
{
|
||||
if (!_spawnedNpcs.isEmpty())
|
||||
{
|
||||
return _spawnedNpcs.getLast();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public final FastList<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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "L2Spawn ID: " + getId() + " " + getLocation();
|
||||
}
|
||||
|
||||
public final boolean isNoRndWalk()
|
||||
{
|
||||
return _isNoRndWalk;
|
||||
}
|
||||
|
||||
public final void setIsNoRndWalk(boolean value)
|
||||
{
|
||||
_isNoRndWalk = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.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;
|
||||
}
|
||||
}
|
||||
202
trunk/java/com/l2jserver/gameserver/model/L2Territory.java
Normal file
202
trunk/java/com/l2jserver/gameserver/model/L2Territory.java
Normal file
@@ -0,0 +1,202 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javolution.util.FastList;
|
||||
|
||||
import com.l2jserver.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;
|
||||
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)
|
||||
{
|
||||
_points = new FastList<>();
|
||||
_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 void print()
|
||||
{
|
||||
for (Point p : _points)
|
||||
{
|
||||
_log.info("(" + p._x + "," + p._y + ")");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isIntersect(int x, int y, Point p1, Point p2)
|
||||
{
|
||||
double dy1 = p1._y - y;
|
||||
double dy2 = p2._y - y;
|
||||
|
||||
if (Math.abs(Math.signum(dy1) - Math.signum(dy2)) <= 1e-6)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
double dx1 = p1._x - x;
|
||||
double dx2 = p2._x - x;
|
||||
|
||||
if ((dx1 >= 0) && (dx2 >= 0))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((dx1 < 0) && (dx2 < 0))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
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++)
|
||||
{
|
||||
Point p1 = _points.get(i > 0 ? i - 1 : _points.size() - 1);
|
||||
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;
|
||||
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++)
|
||||
{
|
||||
int x = Rnd.get(_xMin, _xMax);
|
||||
int y = Rnd.get(_yMin, _yMax);
|
||||
if (isInside(x, y))
|
||||
{
|
||||
double curdistance = 0;
|
||||
int zmin = _zMin;
|
||||
for (Point p1 : _points)
|
||||
{
|
||||
double dx = p1._x - x;
|
||||
double dy = p1._y - y;
|
||||
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;
|
||||
}
|
||||
}
|
||||
77
trunk/java/com/l2jserver/gameserver/model/L2WalkRoute.java
Normal file
77
trunk/java/com/l2jserver/gameserver/model/L2WalkRoute.java
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.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();
|
||||
}
|
||||
}
|
||||
645
trunk/java/com/l2jserver/gameserver/model/L2World.java
Normal file
645
trunk/java/com/l2jserver/gameserver/model/L2World.java
Normal file
@@ -0,0 +1,645 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
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.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.datatables.AdminTable;
|
||||
import com.l2jserver.gameserver.datatables.CharNameTable;
|
||||
import com.l2jserver.gameserver.model.actor.L2Playable;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PetInstance;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
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 = 26;
|
||||
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 visible objects. */
|
||||
private final Map<Integer, L2Object> _allObjects = new ConcurrentHashMap<>();
|
||||
/** Map used for debug. */
|
||||
private final Map<Integer, String> _allObjectsDebug = 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, StringUtil.getTraceString(Thread.currentThread().getStackTrace()));
|
||||
_log.log(Level.WARNING, getClass().getSimpleName() + ": Previous object: " + _allObjects.get(object.getObjectId()) + " already exist in OID map!");
|
||||
_log.log(Level.WARNING, _allObjectsDebug.get(object.getObjectId()));
|
||||
_log.log(Level.WARNING, "---------------------- End ---------------------");
|
||||
return;
|
||||
}
|
||||
|
||||
_allObjects.put(object.getObjectId(), object);
|
||||
_allObjectsDebug.put(object.getObjectId(), StringUtil.getTraceString(Thread.currentThread().getStackTrace()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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());
|
||||
_allObjectsDebug.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 AdminTable.getInstance().getAllGms(true);
|
||||
}
|
||||
|
||||
public Collection<L2PcInstance> getPlayers()
|
||||
{
|
||||
return _allPlayers.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();
|
||||
}
|
||||
|
||||
/**
|
||||
* <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)
|
||||
{
|
||||
// TODO: this code should be obsoleted by protection in putObject func...
|
||||
if (object.isPlayer())
|
||||
{
|
||||
L2PcInstance player = object.getActingPlayer();
|
||||
if (!player.isTeleporting())
|
||||
{
|
||||
final L2PcInstance old = getPlayer(player.getObjectId());
|
||||
if (old != null)
|
||||
{
|
||||
_log.warning("Duplicate character!? Closing both characters (" + player.getName() + ")");
|
||||
player.logout();
|
||||
old.logout();
|
||||
return;
|
||||
}
|
||||
addPlayerToWorld(player);
|
||||
}
|
||||
}
|
||||
|
||||
if (!newRegion.isActive())
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Get all visible objects contained in the _visibleObjects of L2WorldRegions
|
||||
// in a circular area of 2000 units
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the player from the world.
|
||||
* @param player the player to remove
|
||||
*/
|
||||
public void removeFromAllPlayers(L2PcInstance player)
|
||||
{
|
||||
_allPlayers.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();
|
||||
|
||||
// If selected L2Object is a L2PcIntance, remove it from L2ObjectHashSet(L2PcInstance) _allPlayers of L2World
|
||||
if (object.isPlayer())
|
||||
{
|
||||
final L2PcInstance player = object.getActingPlayer();
|
||||
if (!player.isTeleporting())
|
||||
{
|
||||
removeFromAllPlayers(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
L2WorldRegion reg = object.getWorldRegion();
|
||||
|
||||
if (reg == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Create an FastList in order to contain all visible L2Object
|
||||
List<L2Object> result = new ArrayList<>();
|
||||
|
||||
// Go through the FastList of region
|
||||
for (L2WorldRegion regi : reg.getSurroundingRegions())
|
||||
{
|
||||
// Go through visible objects of the selected region
|
||||
Collection<L2Object> vObj = regi.getVisibleObjects().values();
|
||||
for (L2Object _object : vObj)
|
||||
{
|
||||
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 an FastList in order to contain all visible L2Object
|
||||
List<L2Object> result = new ArrayList<>();
|
||||
|
||||
// Go through the FastList of region
|
||||
for (L2WorldRegion regi : object.getWorldRegion().getSurroundingRegions())
|
||||
{
|
||||
// Go through visible objects of the selected region
|
||||
Collection<L2Object> vObj = regi.getVisibleObjects().values();
|
||||
for (L2Object _object : vObj)
|
||||
{
|
||||
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 an FastList in order to contain all visible L2Object
|
||||
List<L2Object> result = new ArrayList<>();
|
||||
|
||||
// Go through visible object of the selected region
|
||||
for (L2WorldRegion regi : object.getWorldRegion().getSurroundingRegions())
|
||||
{
|
||||
Collection<L2Object> vObj = regi.getVisibleObjects().values();
|
||||
for (L2Object _object : vObj)
|
||||
{
|
||||
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)
|
||||
{
|
||||
L2WorldRegion reg = object.getWorldRegion();
|
||||
if (reg == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Create an FastList in order to contain all visible L2Object
|
||||
List<L2Playable> result = new ArrayList<>();
|
||||
|
||||
// Go through the FastList of region
|
||||
for (L2WorldRegion regi : reg.getSurroundingRegions())
|
||||
{
|
||||
// Create an Iterator to go through the visible L2Object of the L2WorldRegion
|
||||
Map<Integer, L2Playable> _allpls = regi.getVisiblePlayable();
|
||||
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();
|
||||
}
|
||||
}
|
||||
505
trunk/java/com/l2jserver/gameserver/model/L2WorldRegion.java
Normal file
505
trunk/java/com/l2jserver/gameserver/model/L2WorldRegion.java
Normal file
@@ -0,0 +1,505 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javolution.util.FastList;
|
||||
import javolution.util.FastMap;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.ThreadPoolManager;
|
||||
import com.l2jserver.gameserver.datatables.SpawnTable;
|
||||
import com.l2jserver.gameserver.model.actor.L2Attackable;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.model.actor.L2Playable;
|
||||
import com.l2jserver.gameserver.model.actor.L2Vehicle;
|
||||
import com.l2jserver.gameserver.model.skills.Skill;
|
||||
import com.l2jserver.gameserver.model.zone.L2ZoneType;
|
||||
import com.l2jserver.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 FastMap<Integer, L2Playable>().shared();
|
||||
_visibleObjects = new FastMap<Integer, L2Object>().shared();
|
||||
_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 FastList<>();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
Collection<L2Object> vObj = _visibleObjects.values();
|
||||
for (L2Object o : vObj)
|
||||
{
|
||||
if (o instanceof L2Attackable)
|
||||
{
|
||||
c++;
|
||||
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.l2jserver.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
|
||||
{
|
||||
Collection<L2Object> vObj = _visibleObjects.values();
|
||||
|
||||
for (L2Object o : vObj)
|
||||
{
|
||||
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 FastList _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());
|
||||
Collection<L2Object> vNPC = _visibleObjects.values();
|
||||
for (L2Object obj : vNPC)
|
||||
{
|
||||
if (obj instanceof L2Npc)
|
||||
{
|
||||
L2Npc target = (L2Npc) obj;
|
||||
target.deleteMe();
|
||||
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());
|
||||
}
|
||||
}
|
||||
225
trunk/java/com/l2jserver/gameserver/model/Location.java
Normal file
225
trunk/java/com/l2jserver/gameserver/model/Location.java
Normal file
@@ -0,0 +1,225 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import com.l2jserver.gameserver.model.interfaces.ILocational;
|
||||
import com.l2jserver.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;
|
||||
}
|
||||
}
|
||||
118
trunk/java/com/l2jserver/gameserver/model/Macro.java
Normal file
118
trunk/java/com/l2jserver/gameserver/model/Macro.java
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jserver.gameserver.model.interfaces.IIdentifiable;
|
||||
import com.l2jserver.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;
|
||||
}
|
||||
}
|
||||
88
trunk/java/com/l2jserver/gameserver/model/MacroCmd.java
Normal file
88
trunk/java/com/l2jserver/gameserver/model/MacroCmd.java
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import com.l2jserver.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;
|
||||
}
|
||||
}
|
||||
226
trunk/java/com/l2jserver/gameserver/model/MacroList.java
Normal file
226
trunk/java/com/l2jserver/gameserver/model/MacroList.java
Normal file
@@ -0,0 +1,226 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.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.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.gameserver.enums.MacroType;
|
||||
import com.l2jserver.gameserver.enums.MacroUpdateType;
|
||||
import com.l2jserver.gameserver.enums.ShortcutType;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.interfaces.IRestorable;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SendMacroList;
|
||||
import com.l2jserver.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 = L2DatabaseFactory.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 = L2DatabaseFactory.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 = L2DatabaseFactory.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())
|
||||
{
|
||||
int id = rset.getInt("id");
|
||||
int icon = rset.getInt("icon");
|
||||
String name = rset.getString("name");
|
||||
String descr = rset.getString("descr");
|
||||
String acronym = rset.getString("acronym");
|
||||
List<MacroCmd> commands = new ArrayList<>();
|
||||
StringTokenizer st1 = new StringTokenizer(rset.getString("commands"), ";");
|
||||
while (st1.hasMoreTokens())
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(st1.nextToken(), ",");
|
||||
if (st.countTokens() < 3)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
MacroType type = MacroType.values()[Integer.parseInt(st.nextToken())];
|
||||
int d1 = Integer.parseInt(st.nextToken());
|
||||
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;
|
||||
}
|
||||
}
|
||||
415
trunk/java/com/l2jserver/gameserver/model/MobGroup.java
Normal file
415
trunk/java/com/l2jserver/gameserver/model/MobGroup.java
Normal file
@@ -0,0 +1,415 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javolution.util.FastList;
|
||||
|
||||
import com.l2jserver.gameserver.ai.CtrlIntention;
|
||||
import com.l2jserver.gameserver.ai.L2ControllableMobAI;
|
||||
import com.l2jserver.gameserver.datatables.SpawnTable;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2ControllableMobInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
import com.l2jserver.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 FastList<>();
|
||||
}
|
||||
|
||||
return _mobs;
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
try
|
||||
{
|
||||
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++)
|
||||
{
|
||||
L2GroupSpawn spawn = new L2GroupSpawn(getTemplate());
|
||||
|
||||
int signX = (Rnd.nextInt(2) == 0) ? -1 : 1;
|
||||
int signY = (Rnd.nextInt(2) == 0) ? -1 : 1;
|
||||
int randX = Rnd.nextInt(MobGroupTable.RANDOM_RANGE);
|
||||
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())
|
||||
{
|
||||
int x = player.getX() + Rnd.nextInt(50);
|
||||
int y = player.getY() + Rnd.nextInt(50);
|
||||
|
||||
mobInst.teleToLocation(new Location(x, y, player.getZ()), true);
|
||||
L2ControllableMobAI ai = (L2ControllableMobAI) mobInst.getAI();
|
||||
ai.follow(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public L2ControllableMobInstance getRandomMob()
|
||||
{
|
||||
removeDead();
|
||||
|
||||
if (getActiveMobCount() == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
L2ControllableMobAI ai = (L2ControllableMobAI) mobInst.getAI();
|
||||
ai.forceAttack(target);
|
||||
}
|
||||
}
|
||||
|
||||
public void setIdleMode()
|
||||
{
|
||||
removeDead();
|
||||
|
||||
for (L2ControllableMobInstance mobInst : getMobs())
|
||||
{
|
||||
if (mobInst == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
L2ControllableMobAI ai = (L2ControllableMobAI) mobInst.getAI();
|
||||
ai.stop();
|
||||
}
|
||||
}
|
||||
|
||||
public void returnGroup(L2Character activeChar)
|
||||
{
|
||||
setIdleMode();
|
||||
|
||||
for (L2ControllableMobInstance mobInst : getMobs())
|
||||
{
|
||||
if (mobInst == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int signX = (Rnd.nextInt(2) == 0) ? -1 : 1;
|
||||
int signY = (Rnd.nextInt(2) == 0) ? -1 : 1;
|
||||
int randX = Rnd.nextInt(MobGroupTable.RANDOM_RANGE);
|
||||
int randY = Rnd.nextInt(MobGroupTable.RANDOM_RANGE);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
L2ControllableMobAI ai = (L2ControllableMobAI) mobInst.getAI();
|
||||
ai.follow(character);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCastMode()
|
||||
{
|
||||
removeDead();
|
||||
|
||||
for (L2ControllableMobInstance mobInst : getMobs())
|
||||
{
|
||||
if (mobInst == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
L2ControllableMobAI ai = (L2ControllableMobAI) mobInst.getAI();
|
||||
ai.setAlternateAI(L2ControllableMobAI.AI_CAST);
|
||||
}
|
||||
}
|
||||
|
||||
public void setNoMoveMode(boolean enabled)
|
||||
{
|
||||
removeDead();
|
||||
|
||||
for (L2ControllableMobInstance mobInst : getMobs())
|
||||
{
|
||||
if (mobInst == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
L2ControllableMobAI ai = (L2ControllableMobAI) mobInst.getAI();
|
||||
ai.setNotMoving(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
protected void removeDead()
|
||||
{
|
||||
List<L2ControllableMobInstance> deadMobs = new FastList<>();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
L2ControllableMobAI ai = (L2ControllableMobAI) mobInst.getAI();
|
||||
ai.forceAttackGroup(otherGrp);
|
||||
ai.setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
|
||||
}
|
||||
}
|
||||
}
|
||||
89
trunk/java/com/l2jserver/gameserver/model/MobGroupTable.java
Normal file
89
trunk/java/com/l2jserver/gameserver/model/MobGroupTable.java
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javolution.util.FastMap;
|
||||
|
||||
import com.l2jserver.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 FastMap<>();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
51
trunk/java/com/l2jserver/gameserver/model/PageResult.java
Normal file
51
trunk/java/com/l2jserver/gameserver/model/PageResult.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.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;
|
||||
}
|
||||
}
|
||||
191
trunk/java/com/l2jserver/gameserver/model/PartyMatchRoom.java
Normal file
191
trunk/java/com/l2jserver/gameserver/model/PartyMatchRoom.java
Normal file
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.interfaces.IIdentifiable;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExManagePartyRoomMember;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* @author Gnacik
|
||||
*/
|
||||
public class PartyMatchRoom implements IIdentifiable
|
||||
{
|
||||
private final int _id;
|
||||
private String _title;
|
||||
private int _loot;
|
||||
private int _location;
|
||||
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;
|
||||
_location = 0; // TODO: Closes town
|
||||
_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)
|
||||
{
|
||||
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
|
||||
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;
|
||||
}
|
||||
|
||||
public int getLocation()
|
||||
{
|
||||
return _location;
|
||||
}
|
||||
|
||||
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 setLocation(int loc)
|
||||
{
|
||||
_location = loc;
|
||||
}
|
||||
|
||||
public void setLootType(int loot)
|
||||
{
|
||||
_loot = loot;
|
||||
}
|
||||
|
||||
public void setMaxMembers(int maxmem)
|
||||
{
|
||||
_maxmem = maxmem;
|
||||
}
|
||||
|
||||
public void setTitle(String title)
|
||||
{
|
||||
_title = title;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javolution.util.FastMap;
|
||||
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExClosePartyRoom;
|
||||
|
||||
/**
|
||||
* @author Gnacik
|
||||
*/
|
||||
public class PartyMatchRoomList
|
||||
{
|
||||
private int _maxid = 1;
|
||||
private final Map<Integer, PartyMatchRoom> _rooms;
|
||||
|
||||
protected PartyMatchRoomList()
|
||||
{
|
||||
_rooms = new FastMap<>();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javolution.util.FastList;
|
||||
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* @author Gnacik
|
||||
*/
|
||||
public class PartyMatchWaitingList
|
||||
{
|
||||
private final List<L2PcInstance> _members;
|
||||
|
||||
protected PartyMatchWaitingList()
|
||||
{
|
||||
_members = new FastList<>();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.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");
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
181
trunk/java/com/l2jserver/gameserver/model/Petition.java
Normal file
181
trunk/java/com/l2jserver/gameserver/model/Petition.java
Normal file
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javolution.util.FastList;
|
||||
|
||||
import com.l2jserver.gameserver.enums.PetitionState;
|
||||
import com.l2jserver.gameserver.enums.PetitionType;
|
||||
import com.l2jserver.gameserver.idfactory.IdFactory;
|
||||
import com.l2jserver.gameserver.instancemanager.PetitionManager;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
|
||||
import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jserver.gameserver.network.serverpackets.PetitionVotePacket;
|
||||
import com.l2jserver.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 FastList<>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.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;
|
||||
}
|
||||
}
|
||||
245
trunk/java/com/l2jserver/gameserver/model/ShortCuts.java
Normal file
245
trunk/java/com/l2jserver/gameserver/model/ShortCuts.java
Normal file
@@ -0,0 +1,245 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.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.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.gameserver.enums.ShortcutType;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.interfaces.IRestorable;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.model.items.type.EtcItemType;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExAutoSoulShot;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ShortCutInit;
|
||||
import com.l2jserver.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 = L2DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("REPLACE INTO character_shortcuts (charId,slot,page,type,shortcut_id,level,class_index) values(?,?,?,?,?,?,?)"))
|
||||
{
|
||||
statement.setInt(1, _owner.getObjectId());
|
||||
statement.setInt(2, shortcut.getSlot());
|
||||
statement.setInt(3, shortcut.getPage());
|
||||
statement.setInt(4, shortcut.getType().ordinal());
|
||||
statement.setInt(5, shortcut.getId());
|
||||
statement.setInt(6, shortcut.getLevel());
|
||||
statement.setInt(7, _owner.getClassIndex());
|
||||
statement.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)
|
||||
{
|
||||
L2ItemInstance item = _owner.getInventory().getItemByObjectId(old.getId());
|
||||
|
||||
if ((item != null) && (item.getItemType() == EtcItemType.SHOT))
|
||||
{
|
||||
if (_owner.removeAutoSoulShot(item.getId()))
|
||||
{
|
||||
_owner.sendPacket(new ExAutoSoulShot(item.getId(), 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_owner.sendPacket(new ShortCutInit(_owner));
|
||||
|
||||
for (int shotId : _owner.getAutoSoulShot())
|
||||
{
|
||||
_owner.sendPacket(new ExAutoSoulShot(shotId, 1));
|
||||
}
|
||||
}
|
||||
|
||||
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 = L2DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("DELETE FROM character_shortcuts WHERE charId=? AND slot=? AND page=? AND class_index=?"))
|
||||
{
|
||||
statement.setInt(1, _owner.getObjectId());
|
||||
statement.setInt(2, shortcut.getSlot());
|
||||
statement.setInt(3, shortcut.getPage());
|
||||
statement.setInt(4, _owner.getClassIndex());
|
||||
statement.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 = L2DatabaseFactory.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())
|
||||
{
|
||||
int slot = rset.getInt("slot");
|
||||
int page = rset.getInt("page");
|
||||
int type = rset.getInt("type");
|
||||
int id = rset.getInt("shortcut_id");
|
||||
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)
|
||||
{
|
||||
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))
|
||||
{
|
||||
Shortcut newsc = new Shortcut(sc.getSlot(), sc.getPage(), sc.getType(), sc.getId(), skillLevel, 1);
|
||||
_owner.sendPacket(new ShortCutRegister(newsc));
|
||||
_owner.registerShortCut(newsc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
125
trunk/java/com/l2jserver/gameserver/model/Shortcut.java
Normal file
125
trunk/java/com/l2jserver/gameserver/model/Shortcut.java
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import com.l2jserver.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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.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;
|
||||
}
|
||||
}
|
||||
31
trunk/java/com/l2jserver/gameserver/model/SpawnListener.java
Normal file
31
trunk/java/com/l2jserver/gameserver/model/SpawnListener.java
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import com.l2jserver.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);
|
||||
}
|
||||
653
trunk/java/com/l2jserver/gameserver/model/StatsSet.java
Normal file
653
trunk/java/com/l2jserver/gameserver/model/StatsSet.java
Normal file
@@ -0,0 +1,653 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javolution.util.FastMap;
|
||||
|
||||
import com.l2jserver.gameserver.model.holders.MinionHolder;
|
||||
import com.l2jserver.gameserver.model.holders.SkillHolder;
|
||||
import com.l2jserver.gameserver.model.interfaces.IParserAdvUtils;
|
||||
|
||||
/**
|
||||
* 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 FastMap<String, Object>());
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
Object val = _set.get(key);
|
||||
if (val == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Byte value required, but not specified");
|
||||
}
|
||||
if (val instanceof Number)
|
||||
{
|
||||
byte[] result =
|
||||
{
|
||||
((Number) val).byteValue()
|
||||
};
|
||||
return result;
|
||||
}
|
||||
int c = 0;
|
||||
String[] vals = ((String) val).split(splitOn);
|
||||
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)
|
||||
{
|
||||
List<Byte> result = new ArrayList<>();
|
||||
for (Byte i : getByteArray(key, splitOn))
|
||||
{
|
||||
result.add(i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getShort(String key)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
Object val = _set.get(key);
|
||||
if (val == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Integer value required, but not specified");
|
||||
}
|
||||
if (val instanceof Number)
|
||||
{
|
||||
int[] result =
|
||||
{
|
||||
((Number) val).intValue()
|
||||
};
|
||||
return result;
|
||||
}
|
||||
int c = 0;
|
||||
String[] vals = ((String) val).split(splitOn);
|
||||
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)
|
||||
{
|
||||
List<Integer> result = new ArrayList<>();
|
||||
for (int i : getIntArray(key, splitOn))
|
||||
{
|
||||
result.add(i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong(String key)
|
||||
{
|
||||
Object val = _set.get(key);
|
||||
if (val == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Integer 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("Integer value required, but found: " + val);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong(String key, long defaultValue)
|
||||
{
|
||||
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("Integer value required, but found: " + val);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloat(String key)
|
||||
{
|
||||
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) Double.parseDouble((String) val);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new IllegalArgumentException("Float value required, but found: " + val);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloat(String key, float defaultValue)
|
||||
{
|
||||
Object val = _set.get(key);
|
||||
if (val == null)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
if (val instanceof Number)
|
||||
{
|
||||
return ((Number) val).floatValue();
|
||||
}
|
||||
try
|
||||
{
|
||||
return (float) Double.parseDouble((String) val);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new IllegalArgumentException("Float value required, but found: " + val);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(String key)
|
||||
{
|
||||
Object val = _set.get(key);
|
||||
if (val == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Float 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("Float value required, but found: " + val);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(String key, double defaultValue)
|
||||
{
|
||||
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("Float value required, but found: " + val);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(String key)
|
||||
{
|
||||
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)
|
||||
{
|
||||
Object val = _set.get(key);
|
||||
if (val == null)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
return String.valueOf(val);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Enum<T>> T getEnum(String key, Class<T> enumClass)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
Object obj = _set.get(name);
|
||||
if ((obj == null) || !type.isAssignableFrom(obj.getClass()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return (A) obj;
|
||||
}
|
||||
|
||||
public SkillHolder getSkillHolder(String key)
|
||||
{
|
||||
Object obj = _set.get(key);
|
||||
if ((obj == null) || !(obj instanceof SkillHolder))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return (SkillHolder) obj;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<MinionHolder> getMinionList(String key)
|
||||
{
|
||||
Object obj = _set.get(key);
|
||||
if ((obj == null) || !(obj instanceof List<?>))
|
||||
{
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
/**
|
||||
* All teleport types.
|
||||
* @author xban1x
|
||||
*/
|
||||
public enum TeleportWhereType
|
||||
{
|
||||
CASTLE,
|
||||
CLANHALL,
|
||||
SIEGEFLAG,
|
||||
TOWN,
|
||||
FORTRESS
|
||||
}
|
||||
85
trunk/java/com/l2jserver/gameserver/model/TempItem.java
Normal file
85
trunk/java/com/l2jserver/gameserver/model/TempItem.java
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import com.l2jserver.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;
|
||||
}
|
||||
}
|
||||
154
trunk/java/com/l2jserver/gameserver/model/TimeStamp.java
Normal file
154
trunk/java/com/l2jserver/gameserver/model/TimeStamp.java
Normal file
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.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;
|
||||
}
|
||||
}
|
||||
77
trunk/java/com/l2jserver/gameserver/model/TowerSpawn.java
Normal file
77
trunk/java/com/l2jserver/gameserver/model/TowerSpawn.java
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jserver.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;
|
||||
}
|
||||
}
|
||||
187
trunk/java/com/l2jserver/gameserver/model/TradeItem.java
Normal file
187
trunk/java/com/l2jserver/gameserver/model/TradeItem.java
Normal file
@@ -0,0 +1,187 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import com.l2jserver.gameserver.model.items.L2Item;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
|
||||
public class TradeItem
|
||||
{
|
||||
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;
|
||||
|
||||
public TradeItem(L2ItemInstance item, long count, long price)
|
||||
{
|
||||
_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();
|
||||
}
|
||||
|
||||
public TradeItem(L2Item item, long count, long price)
|
||||
{
|
||||
_objectId = 0;
|
||||
_item = item;
|
||||
_location = 0;
|
||||
_enchant = 0;
|
||||
_type1 = 0;
|
||||
_type2 = 0;
|
||||
_count = count;
|
||||
_storeCount = count;
|
||||
_price = price;
|
||||
_elemAtkType = Elementals.NONE;
|
||||
_elemAtkPower = 0;
|
||||
_enchantOptions = L2ItemInstance.DEFAULT_ENCHANT_OPTIONS;
|
||||
}
|
||||
|
||||
public TradeItem(TradeItem item, long count, long price)
|
||||
{
|
||||
_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();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
1083
trunk/java/com/l2jserver/gameserver/model/TradeList.java
Normal file
1083
trunk/java/com/l2jserver/gameserver/model/TradeList.java
Normal file
File diff suppressed because it is too large
Load Diff
215
trunk/java/com/l2jserver/gameserver/model/UIKeysSettings.java
Normal file
215
trunk/java/com/l2jserver/gameserver/model/UIKeysSettings.java
Normal file
@@ -0,0 +1,215 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.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.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.gameserver.datatables.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;
|
||||
}
|
||||
|
||||
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 = L2DatabaseFactory.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 = L2DatabaseFactory.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 = L2DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement stmt = con.prepareStatement("SELECT * FROM character_ui_categories WHERE `charId` = ? ORDER BY `catId`, `order`"))
|
||||
{
|
||||
stmt.setInt(1, _playerObjId);
|
||||
try (ResultSet rs = stmt.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 = L2DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement stmt = con.prepareStatement("SELECT * FROM character_ui_actions WHERE `charId` = ? ORDER BY `cat`, `order`"))
|
||||
{
|
||||
stmt.setInt(1, _playerObjId);
|
||||
try (ResultSet rs = stmt.executeQuery())
|
||||
{
|
||||
while (rs.next())
|
||||
{
|
||||
int cat = rs.getInt("cat");
|
||||
int cmd = rs.getInt("cmd");
|
||||
int key = rs.getInt("key");
|
||||
int tgKey1 = rs.getInt("tgKey1");
|
||||
int tgKey2 = rs.getInt("tgKey2");
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.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;
|
||||
}
|
||||
}
|
||||
225
trunk/java/com/l2jserver/gameserver/model/WalkInfo.java
Normal file
225
trunk/java/com/l2jserver/gameserver/model/WalkInfo.java
Normal file
@@ -0,0 +1,225 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model;
|
||||
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import com.l2jserver.gameserver.instancemanager.WalkingManager;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jserver.gameserver.model.events.impl.character.npc.OnNpcMoveRouteFinished;
|
||||
import com.l2jserver.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;
|
||||
}
|
||||
}
|
||||
1736
trunk/java/com/l2jserver/gameserver/model/actor/L2Attackable.java
Normal file
1736
trunk/java/com/l2jserver/gameserver/model/actor/L2Attackable.java
Normal file
File diff suppressed because it is too large
Load Diff
7069
trunk/java/com/l2jserver/gameserver/model/actor/L2Character.java
Normal file
7069
trunk/java/com/l2jserver/gameserver/model/actor/L2Character.java
Normal file
File diff suppressed because it is too large
Load Diff
183
trunk/java/com/l2jserver/gameserver/model/actor/L2Decoy.java
Normal file
183
trunk/java/com/l2jserver/gameserver/model/actor/L2Decoy.java
Normal file
@@ -0,0 +1,183 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model.actor;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.l2jserver.gameserver.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.actor.templates.L2CharTemplate;
|
||||
import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
import com.l2jserver.gameserver.model.items.L2Weapon;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.CharInfo;
|
||||
import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jserver.gameserver.taskmanager.DecayTaskManager;
|
||||
|
||||
public abstract class L2Decoy extends L2Character
|
||||
{
|
||||
private final L2PcInstance _owner;
|
||||
|
||||
public L2Decoy(int objectId, L2CharTemplate template, L2PcInstance owner)
|
||||
{
|
||||
super(objectId, 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 updateAbnormalEffect()
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
1942
trunk/java/com/l2jserver/gameserver/model/actor/L2Npc.java
Normal file
1942
trunk/java/com/l2jserver/gameserver/model/actor/L2Npc.java
Normal file
File diff suppressed because it is too large
Load Diff
360
trunk/java/com/l2jserver/gameserver/model/actor/L2Playable.java
Normal file
360
trunk/java/com/l2jserver/gameserver/model/actor/L2Playable.java
Normal file
@@ -0,0 +1,360 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model.actor;
|
||||
|
||||
import com.l2jserver.gameserver.ai.CtrlEvent;
|
||||
import com.l2jserver.gameserver.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.instancemanager.InstanceManager;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.actor.knownlist.PlayableKnownList;
|
||||
import com.l2jserver.gameserver.model.actor.stat.PlayableStat;
|
||||
import com.l2jserver.gameserver.model.actor.status.PlayableStatus;
|
||||
import com.l2jserver.gameserver.model.actor.templates.L2CharTemplate;
|
||||
import com.l2jserver.gameserver.model.effects.EffectFlag;
|
||||
import com.l2jserver.gameserver.model.effects.L2EffectType;
|
||||
import com.l2jserver.gameserver.model.entity.Instance;
|
||||
import com.l2jserver.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jserver.gameserver.model.events.impl.character.OnCreatureKill;
|
||||
import com.l2jserver.gameserver.model.events.returns.TerminateReturn;
|
||||
import com.l2jserver.gameserver.model.quest.QuestState;
|
||||
import com.l2jserver.gameserver.model.skills.Skill;
|
||||
import com.l2jserver.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;
|
||||
|
||||
/**
|
||||
* Constructor of L2Playable.<br>
|
||||
* <B><U> Actions</U> :</B>
|
||||
* <ul>
|
||||
* <li>Call the L2Character constructor to create an empty _skills slot and link copy basic Calculator set to this L2Playable</li>
|
||||
* </ul>
|
||||
* @param objectId Identifier of the object to initialized
|
||||
* @param template The L2CharTemplate to apply to the L2Playable
|
||||
*/
|
||||
public L2Playable(int objectId, L2CharTemplate template)
|
||||
{
|
||||
super(objectId, 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())
|
||||
{
|
||||
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
|
||||
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)
|
||||
{
|
||||
L2PcInstance player = killer.getActingPlayer();
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
player.onKillUpdatePvPKarma(this);
|
||||
}
|
||||
}
|
||||
|
||||
// Notify L2Character AI
|
||||
getAI().notifyEvent(CtrlEvent.EVT_DEAD);
|
||||
super.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.getKarma() != 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.getKarma() != 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 int getKarma();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
1232
trunk/java/com/l2jserver/gameserver/model/actor/L2Summon.java
Normal file
1232
trunk/java/com/l2jserver/gameserver/model/actor/L2Summon.java
Normal file
File diff suppressed because it is too large
Load Diff
83
trunk/java/com/l2jserver/gameserver/model/actor/L2Tower.java
Normal file
83
trunk/java/com/l2jserver/gameserver/model/actor/L2Tower.java
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model.actor;
|
||||
|
||||
import com.l2jserver.gameserver.GeoData;
|
||||
import com.l2jserver.gameserver.ai.CtrlIntention;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
|
||||
|
||||
/**
|
||||
* This class is a super-class for L2ControlTowerInstance and L2FlameTowerInstance.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public abstract class L2Tower extends L2Npc
|
||||
{
|
||||
public L2Tower(int objectId, L2NpcTemplate template)
|
||||
{
|
||||
super(objectId, 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);
|
||||
}
|
||||
}
|
||||
522
trunk/java/com/l2jserver/gameserver/model/actor/L2Vehicle.java
Normal file
522
trunk/java/com/l2jserver/gameserver/model/actor/L2Vehicle.java
Normal file
@@ -0,0 +1,522 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model.actor;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javolution.util.FastList;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.GameTimeController;
|
||||
import com.l2jserver.gameserver.ThreadPoolManager;
|
||||
import com.l2jserver.gameserver.ai.CtrlIntention;
|
||||
import com.l2jserver.gameserver.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.instancemanager.MapRegionManager;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.L2WorldRegion;
|
||||
import com.l2jserver.gameserver.model.Location;
|
||||
import com.l2jserver.gameserver.model.TeleportWhereType;
|
||||
import com.l2jserver.gameserver.model.VehiclePathPoint;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.actor.knownlist.VehicleKnownList;
|
||||
import com.l2jserver.gameserver.model.actor.stat.VehicleStat;
|
||||
import com.l2jserver.gameserver.model.actor.templates.L2CharTemplate;
|
||||
import com.l2jserver.gameserver.model.interfaces.ILocational;
|
||||
import com.l2jserver.gameserver.model.items.L2Weapon;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author DS
|
||||
*/
|
||||
public abstract class L2Vehicle extends L2Character
|
||||
{
|
||||
protected int _dockId = 0;
|
||||
protected final FastList<L2PcInstance> _passengers = new FastList<>();
|
||||
protected Location _oustLoc = null;
|
||||
private Runnable _engine = null;
|
||||
|
||||
protected VehiclePathPoint[] _currentPath = null;
|
||||
protected int _runState = 0;
|
||||
|
||||
public L2Vehicle(int objectId, L2CharTemplate template)
|
||||
{
|
||||
super(objectId, 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());
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
L2PcInstance player;
|
||||
|
||||
// Use iterator because oustPlayer will try to remove player from _passengers
|
||||
final Iterator<L2PcInstance> iter = _passengers.iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
player = iter.next();
|
||||
iter.remove();
|
||||
if (player != null)
|
||||
{
|
||||
oustPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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(int gameTicks)
|
||||
{
|
||||
final boolean result = super.updatePosition(gameTicks);
|
||||
|
||||
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 updateAbnormalEffect()
|
||||
{
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
public class AIAccessor extends L2Character.AIAccessor
|
||||
{
|
||||
@Override
|
||||
public void detachAI()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVehicle()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,229 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model.actor.appearance;
|
||||
|
||||
import com.l2jserver.gameserver.enums.Sex;
|
||||
import com.l2jserver.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()
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.model.actor.instance;
|
||||
|
||||
import com.l2jserver.gameserver.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: $ $Date: $
|
||||
* @author LBaldi
|
||||
*/
|
||||
public class L2AdventurerInstance extends L2NpcInstance
|
||||
{
|
||||
public L2AdventurerInstance(int objectId, L2NpcTemplate template)
|
||||
{
|
||||
super(objectId, template);
|
||||
setInstanceType(InstanceType.L2AdventurerInstance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHtmlPath(int npcId, int val)
|
||||
{
|
||||
String pom = "";
|
||||
|
||||
if (val == 0)
|
||||
{
|
||||
pom = "" + npcId;
|
||||
}
|
||||
else
|
||||
{
|
||||
pom = npcId + "-" + val;
|
||||
}
|
||||
|
||||
return "data/html/adventurer_guildsman/" + pom + ".htm";
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user