10-16-2011, 08:02 PM
Сборка: NextGen 4466
Эвент: Death Match
Проблема возникла в том что я поменял место проведения эвента вместа колизея другую локацию.
При старте эвента все идет нормально телепортирует в данную локацию, но после того как сходит паралич с персонажа вылетает табличка.
Вы проиграли. Дождитесь окончания эвента.
Не могу понять в чем проблема.
Вот сам скрипт:
Эвент: Death Match
Проблема возникла в том что я поменял место проведения эвента вместа колизея другую локацию.
При старте эвента все идет нормально телепортирует в данную локацию, но после того как сходит паралич с персонажа вылетает табличка.
Вы проиграли. Дождитесь окончания эвента.
Не могу понять в чем проблема.
Вот сам скрипт:
package events.deathmatch;
import static l2n.game.model.L2Zone.ZoneType.OlympiadStadia;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Comparator;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import java.util.logging.Logger;
import l2n.Config;
import l2n.Config.EventInterval;
import l2n.extensions.listeners.L2ZoneEnterLeaveListener;
import l2n.extensions.multilang.CustomMessage;
import l2n.extensions.scripts.Functions;
import l2n.extensions.scripts.ScriptFile;
import l2n.game.Announcements;
import l2n.game.ThreadPoolManager;
import l2n.game.instancemanager.CastleManager;
import l2n.game.instancemanager.ServerVariables;
import l2n.game.instancemanager.ZoneManager;
import l2n.game.model.L2Character;
import l2n.game.model.L2Object;
import l2n.game.model.L2ObjectsStorage;
import l2n.game.model.L2Player;
import l2n.game.model.L2Skill;
import l2n.game.model.L2Zone;
import l2n.game.model.L2Zone.ZoneType;
import l2n.game.model.Reflection;
import l2n.game.model.entity.residence.Castle;
import l2n.game.model.entity.siege.territory.TerritorySiege;
import l2n.game.model.eventmanager.AutoEventManager.EventType;
import l2n.game.model.eventmanager.IAutoEvent;
import l2n.game.network.clientpackets.Say2C;
import l2n.game.network.serverpackets.Revive;
import l2n.game.network.serverpackets.SkillList;
import l2n.game.network.serverpackets.SocialAction;
import l2n.game.tables.DoorTable;
import l2n.game.tables.HeroSkillTable;
import l2n.game.tables.ReflectionTable;
import l2n.game.tables.SkillTable;
import l2n.util.Files;
import l2n.util.GArray;
import l2n.util.GCSArray;
import l2n.util.Location;
import l2n.util.Rnd;
import l2n.util.Util;
public class DeathMatch extends Functions implements ScriptFile, IAutoEvent
{
private static Logger _log = Logger.getLogger(DeathMatch.class.getName());
private static class ScoreComparator implements Comparator<Player>
{
public static final int LESS = -1;
public static final int EQUALS = 0;
public static final int GREATER = 1;
@Override
public int compare(Player o1, Player o2)
{
if(o1 == null || o2 == null)
return EQUALS;
if(o1.storeId == o2.storeId)
return EQUALS;
if(o1.score == o2.score)
return EQUALS;
if(o1.score.get() < o2.score.get())
return GREATER;
if(o1.score.get() > o2.score.get())
return LESS;
return LESS;
}
}
private static class Player
{
public long storeId;
private AtomicInteger score;
public Player(long storeId)
{
this.storeId = storeId;
this.score = new AtomicInteger(0);
}
public int increment()
{
return score.incrementAndGet();
}
public int getScore()
{
return score.get();
}
}
public class StartTask implements Runnable
{
private String _category;
private String _autocontinue;
public StartTask(int category, int autocontinue)
{
_category = "" + category;
_autocontinue = "" + autocontinue;
}
public StartTask()
{
_category = "1";
_autocontinue = "1";
}
@Override
public void run()
{
if(!_active)
return;
if(TerritorySiege.isInProgress())
{
_log.info("" + _type + " not started: TerritorySiege in progress");
return;
}
for(Castle c : CastleManager.getInstance().getCastles().values())
if(c.getSiege() != null && c.getSiege().isInProgress())
{
_log.info("" + _type + " not started: CastleSiege in progress");
return;
}
start(new String[] { _category, _autocontinue });
}
}
private static ScheduledFuture<StartTask> _startTask;
private static ScheduledFuture<?> _endTask;
private static GCSArray<Long> players_list = new GCSArray<Long>();
private static GCSArray<Long> live_list = new GCSArray<Long>();
private static ScoreComparator comparator = new ScoreComparator();
/** очки участников ивента */
private static ConcurrentHashMap<Long, Player> score = new ConcurrentHashMap<Long, Player>();
private static boolean _isRegistrationActive = false;
private static int _status = 0;
private static int _time_to_start;
private static int _category;
private static int _minLevel;
private static int _maxLevel;
private static int _autoContinue = 0;
private static L2Zone _zone = ZoneManager.getInstance().getZoneByIndex(ZoneType.battle_zone, 4, true);
private ZoneListener _zoneListener = new ZoneListener();
private static final Reflection _reflection = new Reflection(ReflectionTable.EVENT_DEATHMATCH);
private static final int[] _doors = new int[] { 24190001, 24190002, 24190003, 24190004 };
private static final EventType _type = EventType.DEATHMATCH;
@Override
public void onLoad()
{
_zone.getListenerEngine().addMethodInvokedListener(_zoneListener);
_active = ServerVariables.getString("DeathMatch", "off").equalsIgnoreCase("on");
// Если ивент активен, но пробуем зашедулить
if(isActive())
scheduleEventStart(true);
_log.info("Loaded Event: " + _type + "[" + _active + "]");
// дверьки добавляем)
for(int doorId : _doors)
_reflection.addDoor(DoorTable.getInstance().getDoor(doorId).clone());
}
@Override
public void onReload()
{
_zone.getListenerEngine().removeMethodInvokedListener(_zoneListener);
if(_startTask != null)
_startTask.cancel(true);
}
@Override
public void onShutdown()
{
onReload();
}
private static boolean _active = false;
private static boolean isActive()
{
return _active;
}
public void activateEvent()
{
L2Player player = (L2Player) getSelf();
if(!player.getPlayerAccess().IsEventGm)
return;
if(!isActive())
{
// при активации ивента, если он не был активирован, то пробуем стартовать. Так как как таск стартует только при загрузке
if(_startTask == null)
scheduleEventStart(false);
ServerVariables.set("DeathMatch", "on");
_log.info("Event '" + _type + "' activated.");
Announcements.getInstance().announceByCustomMessage("scripts.events.AnnounceEventStarted", new String[] { _type.getName(false) });
}
else
player.sendMessage("Event '" + _type + "' already active.");
_active = true;
show(Files.read("data/html/admin/events.htm", player), player);
}
public void deactivateEvent()
{
L2Player player = (L2Player) getSelf();
if(!player.getPlayerAccess().IsEventGm)
return;
if(isActive())
{
if(_startTask != null)
{
_startTask.cancel(true);
_startTask = null;
}
ServerVariables.unset("DeathMatch");
_log.info("Event '" + _type + "' deactivated.");
Announcements.getInstance().announceByCustomMessage("scripts.events.AnnounceEventStoped", new String[] { _type.getName(false) });
}
else
player.sendMessage("Event '" + _type + "' not active.");
_active = false;
show(Files.read("data/html/admin/events.htm", player), player);
}
@Override
public boolean isRunned()
{
return _isRegistrationActive || _status > 0;
}
public String DialogAppend_31225(Integer val)
{
if(val == 0)
{
L2Player player = (L2Player) getSelf();
return Files.read("data/scripts/events/deathmatch/31225.html", player);
}
return "";
}
public static int getMinLevelForCategory(int category)
{
switch (category)
{
case 1:
return 20;
case 2:
return 30;
case 3:
return 40;
case 4:
return 52;
case 5:
return 62;
case 6:
return 76;
}
return 0;
}
public static int getMaxLevelForCategory(int category)
{
switch (category)
{
case 1:
return 29;
case 2:
return 39;
case 3:
return 51;
case 4:
return 61;
case 5:
return 75;
case 6:
return 85;
}
return 0;
}
public static int getCategory(int level)
{
if(level >= 20 && level <= 29)
return 1;
else if(level >= 30 && level <= 39)
return 2;
else if(level >= 40 && level <= 51)
return 3;
else if(level >= 52 && level <= 61)
return 4;
else if(level >= 62 && level <= 75)
return 5;
else if(level >= 76)
return 6;
return 0;
}
@Override
public void start(String[] var)
{
if(isRunned())
{
_log.info("DeathMatch: start task already running!");
return;
}
L2Player player = (L2Player) getSelf();
if(var.length != 2)
{
show(new CustomMessage("common.Error", player), player);
return;
}
Integer category;
Integer autoContinue;
try
{
category = Integer.valueOf(var[0]);
autoContinue = Integer.valueOf(var[1]);
}
catch(Exception e)
{
show(new CustomMessage("common.Error", player), player);
return;
}
_category = category;
_autoContinue = autoContinue;
if(_category == -1)
{
_minLevel = 1;
_maxLevel = 85;
}
else
{
_minLevel = getMinLevelForCategory(_category);
_maxLevel = getMaxLevelForCategory(_category);
}
if(_endTask != null)
{
show(new CustomMessage("common.TryLater", player), player);
return;
}
_status = 0;
_isRegistrationActive = true;
_time_to_start = Config.EVENT_DEATHMATCH_TIME_TO_START;
players_list = new GCSArray<Long>();
live_list = new GCSArray<Long>();
String[] param = { String.valueOf(_time_to_start), String.valueOf(_minLevel), String.valueOf(_maxLevel) };
sayToAll("scripts.events.deathmatch.AnnouncePreStart", param);
executeTask("events.deathmatch.DeathMatch", "question", new Object[0], 10000);
executeTask("events.deathmatch.DeathMatch", "announce", new Object[0], 60000);
_log.info("DeathMatch: start event [" + _category + "-" + _autoContinue + "]");
}
public static void sayToAll(String address, String[] replacements)
{
Announcements.getInstance().announceByCustomMessage(address, replacements, Say2C.CRITICAL_ANNOUNCEMENT);
}
public static void question()
{
for(L2Player player : L2ObjectsStorage.getAllPlayersForIterate())
if(player != null && player.getLevel() >= _minLevel && player.getLevel() <= _maxLevel && player.isAllowEventQuestion())
player.scriptRequest(new CustomMessage("scripts.events.deathmatch.AskPlayer", player).toString(), "events.deathmatch.DeathMatch:addPlayer", new Object[0]);
}
public static void announce()
{
if(players_list.size() < Config.EVENT_DEATHMATCH_MIN_PLAYER_COUNT)
{
sayToAll("scripts.events.deathmatch.AnnounceEventCancelled", null);
_isRegistrationActive = false;
_status = 0;
executeTask("events.deathmatch.DeathMatch", "autoContinue", new Object[0], 10000);
return;
}
if(_time_to_start > 1)
{
_time_to_start--;
String[] param = { String.valueOf(_time_to_start), String.valueOf(_minLevel), String.valueOf(_maxLevel) };
sayToAll("scripts.events.deathmatch.AnnouncePreStart", param);
executeTask("events.deathmatch.DeathMatch", "announce", new Object[0], 60000);
}
else
{
_status = 1;
_isRegistrationActive = false;
sayToAll("scripts.events.deathmatch.AnnounceEventStarting", null);
executeTask("events.deathmatch.DeathMatch", "prepare", new Object[0], 5000);
}
}
public void addPlayer()
{
L2Player player = (L2Player) getSelf();
if(player == null || !checkPlayer(player, true))
return;
players_list.add(player.getStoredId());
live_list.add(player.getStoredId());
show(new CustomMessage("scripts.events.deathmatch.Registered", player), player);
}
public static boolean checkPlayer(L2Player player, boolean first)
{
if(first && !_isRegistrationActive)
{
show(new CustomMessage("scripts.events.Late", player), player);
return false;
}
if(first && player.isDead())
return false;
if(first && players_list.contains(player))
{
show(new CustomMessage("scripts.events.deathmatch.Cancelled", player), player);
return false;
}
if(player.getLevel() < _minLevel || player.getLevel() > _maxLevel)
{
show(new CustomMessage("scripts.events.deathmatch.CancelledLevel", player), player);
return false;
}
if(player.getDuel() != null)
{
show(new CustomMessage("scripts.events.deathmatch.CancelledDuel", player), player);
return false;
}
if(player.getTeam() != 0)
{
show(new CustomMessage("scripts.events.deathmatch.CancelledOtherEvent", player), player);
return false;
}
if(player.isInZone(OlympiadStadia))
{
show(new CustomMessage("scripts.events.deathmatch.CancelledOlympiad", player), player);
return false;
}
if(player.isInParty() && player.getParty().isInDimensionalRift())
{
show(new CustomMessage("scripts.events.deathmatch.CancelledOtherEvent", player), player);
return false;
}
if(player.isTeleporting())
{
show(new CustomMessage("scripts.events.deathmatch.CancelledTeleport", player), player);
return false;
}
return true;
}
public static void prepare()
{
cleanPlayers();
clearArena();
executeTask("events.deathmatch.DeathMatch", "ressurectPlayers", new Object[0], 1000);
executeTask("events.deathmatch.DeathMatch", "healPlayers", new Object[0], 2000);
executeTask("events.deathmatch.DeathMatch", "saveBackCoords", new Object[0], 3000);
executeTask("events.deathmatch.DeathMatch", "teleportPlayersToColiseum", new Object[0], 4000);
executeTask("events.deathmatch.DeathMatch", "paralyzePlayers", new Object[0], 5000);
executeTask("events.deathmatch.DeathMatch", "go", new Object[0], 60000);
sayToAll("scripts.events.deathmatch.AnnounceFinalCountdown", null);
}
public static void go()
{
score = new ConcurrentHashMap<Long, Player>();
_status = 2;
upParalyzePlayers();
checkLive();
clearArena();
sayToAll("scripts.events.deathmatch.AnnounceFight", null);
_endTask = executeTask("events.deathmatch.DeathMatch", "endBattle", new Object[0], Config.EVENT_DEATHMATCH_TIME_FOR_FIGHT * 60 * 1000);
}
public static void endBattle()
{
_status = 0;
removeAura();
// Остался только один)
if(live_list.size() == 1)
{
for(L2Player player : getPlayers(live_list))
if(player != null)
{
player.broadcastPacket(new SocialAction(player.getObjectId(), SocialAction.VICTORY));
sayToAll("scripts.events.deathmatch.AnnounceWiner", new String[] { player.getName() });
if(Config.EVENT_DEATHMATCH_GIVE_HERO)
player.setHero(true, 1);
if(Config.EVENT_DEATHMATCH_REWARD_ITEM_ID > 0 && Config.EVENT_DEATHMATCH_REWARD_ITEM_COUNT > 0)
addItem(player, Config.EVENT_DEATHMATCH_REWARD_ITEM_ID, Config.EVENT_DEATHMATCH_REWARD_ITEM_COUNT);
break;
}
}
// иначе считаем количество убийств(
else
{
Player[] players = score.values().toArray(new Player[score.size()]);
Arrays.sort(players, comparator);
Player el = null;
try
{
el = players[0];
}
catch(ArrayIndexOutOfBoundsException e)
{}
if(el != null && el.getScore() > 0)
{
L2Player player = null;
if((player = L2ObjectsStorage.getAsPlayer(el.storeId)) != null)
{
player.broadcastPacket(new SocialAction(player.getObjectId(), SocialAction.VICTORY));
sayToAll("scripts.events.deathmatch.AnnounceWiner", new String[] { player.getName() });
if(Config.EVENT_DEATHMATCH_GIVE_HERO)
player.setHero(true, 1);
if(Config.EVENT_DEATHMATCH_REWARD_ITEM_ID > 0 && Config.EVENT_DEATHMATCH_REWARD_ITEM_COUNT > 0)
addItem(player, Config.EVENT_DEATHMATCH_REWARD_ITEM_ID, Config.EVENT_DEATHMATCH_REWARD_ITEM_COUNT);
}
}
}
sayToAll("scripts.events.deathmatch.AnnounceEnd", null);
executeTask("events.deathmatch.DeathMatch", "end", new Object[0], 60000);
_isRegistrationActive = false;
if(_endTask != null)
{
_endTask.cancel(false);
_endTask = null;
}
}
public static void end()
{
openColiseumDoors();
executeTask("events.deathmatch.DeathMatch", "ressurectPlayers", new Object[0], 1000);
executeTask("events.deathmatch.DeathMatch", "healPlayers", new Object[0], 2000);
executeTask("events.deathmatch.DeathMatch", "teleportPlayersToSavedCoords", new Object[0], 3000);
executeTask("events.deathmatch.DeathMatch", "autoContinue", new Object[0], 10000);
}
public void autoContinue()
{
players_list.clear();
live_list.clear();
score.clear();
if(_autoContinue > 0)
{
if(_autoContinue >= 6)
{
_autoContinue = 0;
return;
}
start(new String[] { "" + (_autoContinue + 1), "" + (_autoContinue + 1) });
}
else
// если нет, то пробуем зашедулить по времени из конфигов
scheduleEventStart(true);
}
/**
* проверяет возможность запуска ивента и стартует такс в указанное в конфигах время
*
* @param check
* - проверять активирован ли ивент
*/
public void scheduleEventStart(boolean check)
{
// ивент должен быть активированным для автоматического запуска
if(check && !isActive())
return;
try
{
Calendar currentTime = Calendar.getInstance();
int nextCategory = -1;
Calendar testStartTime = null;
Calendar nextStartTime = null;
// перебираем всё варианты старта... находим оптимальный вариант
for(EventInterval interval : Config.EVENT_DEATHMATCH_INTERVAL)
{
// Creating a Calendar object from the specified interval value
testStartTime = Calendar.getInstance();
testStartTime.setLenient(true); // чтоб выдало исключение если время задано не верно в конфигах
// устанавливаем время предположительно след запуска
testStartTime.set(Calendar.HOUR_OF_DAY, interval.hour);
testStartTime.set(Calendar.MINUTE, interval.minute);
// If the date is in the past, make it the next day (Example: Checking for "1:00", when the time is 23:57.)
if(testStartTime.getTimeInMillis() < currentTime.getTimeInMillis())
testStartTime.add(Calendar.DAY_OF_MONTH, 1);
// сравниваем, если подходит то устанавливаем
if(nextStartTime == null || testStartTime.getTimeInMillis() < nextStartTime.getTimeInMillis())
{
nextStartTime = testStartTime;
nextCategory = interval.category;
}
}
_log.info("DeatMatch: next start event will be at " + Util.datetimeFormatter.format(nextStartTime.getTime()));
// запускаем ивент с указанной катерорией и без автопродолжения
if(_startTask != null)
{
_startTask.cancel(false);
_startTask = null;
}
_startTask = ThreadPoolManager.getInstance().scheduleGeneral(new StartTask(nextCategory, 0), nextStartTime.getTimeInMillis() - System.currentTimeMillis());
}
catch(Exception e)
{
_log.log(Level.WARNING, "DeatMatch.scheduleEventStart(): error figuring out a start time. Check config file.", e);
}
}
public static void saveBackCoords()
{
for(L2Player player : getPlayers(players_list))
player.setVar("DeatMatch_backCoords", player.getBackCoords());
}
public static void teleportPlayersToColiseum()
{
closeColiseumDoors();
for(L2Player player : getPlayers(players_list))
if(player != null)
{
unRide(player);
if(!Config.EVENT_DEATHMATCH_ALLOW_SUMMONS)
unSummonPet(player);
// Remove Buffs
if(!Config.EVENT_DEATHMATCH_ALLOW_BUFFS)
{
player.stopAllEffects();
if(player.getPet() != null)
player.getPet().stopAllEffects();
}
// Remove Clan Skills
if(!Config.EVENT_DEATHMATCH_ALLOW_CLAN_SKILL)
if(player.getClan() != null)
for(L2Skill skill : player.getClan().getAllSkills())
player.removeSkill(skill, false);
if(!Config.EVENT_DEATHMATCH_ALLOW_HERO_SKILL)
// Remove Hero Skills
if(player.isHero())
for(L2Skill sk : HeroSkillTable.getHeroSkills())
player.removeSkillById(sk.getId());
// Force the character to be mortal
if(player.isInvul())
player.setInvul(false);
// Force the character to be visible
if(player.isInvisible())
player.setInvisible(false);
Location pos = Rnd.coordsRandomize(176424, 20376, -3275, 0, 0, 500);
player.teleToLocation(pos, ReflectionTable.EVENT_DEATHMATCH);
}
}
public static void teleportPlayersToSavedCoords()
{
for(L2Player player : getPlayers(players_list))
try
{
String var = player.getVar("DeatMatch_backCoords");
if(var == null || var.equals(""))
continue;
String[] coords = var.split(" ");
if(coords.length != 4)
continue;
// Add clan skill
if(player.getClan() != null)
for(L2Skill skill : player.getClan().getAllSkills())
if(skill.getMinPledgeClass() <= player.getPledgeClass())
player.addSkill(skill, false);
// Add Hero Skills
if(player.isHero())
for(L2Skill sk : HeroSkillTable.getHeroSkills())
player.addSkill(sk);
// Обновляем скилл лист, после добавления скилов
player.sendPacket(new SkillList(player));
player.teleToLocation(Integer.parseInt(coords[0]), Integer.parseInt(coords[1]), Integer.parseInt(coords[2]), Long.parseLong(coords[3]));
player.unsetVar("DeatMatch_backCoords");
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void teleportToColiseumSpawn(L2Character cha)
{
if(cha != null)
cha.teleToLocation(147451, 46728, -3410);
}
public static void paralyzePlayers()
{
L2Skill revengeSkill = SkillTable.FrequentSkill.RAID_CURSE2.getSkill();
for(L2Player player : getPlayers(players_list))
if(player != null)
{
player.getEffectList().stopEffect(L2Skill.SKILL_MYSTIC_IMMUNITY);
player.getEffectList().stopEffect(L2Skill.SKILL_RAID_CURSE);
revengeSkill.getEffects(player, player, false, false);
if(player.getPet() != null)
revengeSkill.getEffects(player, player.getPet(), false, false);
}
}
public static void upParalyzePlayers()
{
for(L2Player player : getPlayers(players_list))
{
score.put(player.getStoredId(), new Player(player.getStoredId()));
player.getEffectList().stopEffect(L2Skill.SKILL_RAID_CURSE);
if(player.getPet() != null)
player.getPet().getEffectList().stopEffect(L2Skill.SKILL_RAID_CURSE);
if(player.getParty() != null)
player.getParty().oustPartyMember(player);
}
}
public static void ressurectPlayers()
{
for(L2Player player : getPlayers(players_list))
if(player != null && player.isDead())
{
player.restoreExp();
player.setCurrentCp(player.getMaxCp());
player.setCurrentHp(player.getMaxHp(), true);
player.setCurrentMp(player.getMaxMp());
player.broadcastPacket(new Revive(player));
}
}
public static void healPlayers()
{
for(L2Player player : getPlayers(players_list))
if(player != null)
{
player.setCurrentHpMp(player.getMaxHp(), player.getMaxMp());
player.setCurrentCp(player.getMaxCp());
}
}
public static void cleanPlayers()
{
for(L2Player player : getPlayers(players_list))
if(!checkPlayer(player, false))
removePlayer(player);
}
public static void checkLive()
{
GCSArray<Long> new_live_list = new GCSArray<Long>();
for(Long storeId : live_list)
{
L2Player player = L2ObjectsStorage.getAsPlayer(storeId);
if(player != null)
new_live_list.add(storeId);
}
live_list = new_live_list;
for(L2Player player : getPlayers(live_list))
if(player.isInZone(_zone) && player.isConnected() && !player.isLogoutStarted())
player.setTeam(2, false);
else
loosePlayer(player, false);
if(live_list.size() <= 1)
endBattle();
}
public static void removeAura()
{
for(L2Player player : getPlayers(live_list))
if(player != null)
player.setTeam(0, false);
}
/**
* чистим арену от чужих)
*/
public static void clearArena()
{
for(L2Object obj : _zone.getObjects())
if(obj != null && obj.getReflectionId() == ReflectionTable.EVENT_DEATHMATCH)
{
L2Player player = obj.getPlayer();
if(player != null && !live_list.contains(player.getStoredId()))
teleportToColiseumSpawn(player);
}
}
public void OnDie(L2Character self, L2Character killer)
{
if(_status > 1 && self != null && self.isPlayer() && self.getTeam() > 0 && live_list.contains(self.getStoredId()))
{
L2Player player = self.getPlayer();
loosePlayer(player, true);
checkLive();
// Выдаём очки убийце и выдаём награду
if(killer != null && killer.isPlayer())
if(score.containsKey(killer.getStoredId()))
{
// Выдаём очки
score.get(killer.getStoredId()).increment();
if(Config.EVENT_DEATHMATCH_RATE)
addItem((L2Player) killer, Config.EVENT_DEATHMATCH_ITEM_ID, ((L2Player) getSelf()).getLevel() * Config.EVENT_DEATHMATCH_ITEM_COUNT);
else
addItem((L2Player) killer, Config.EVENT_DEATHMATCH_ITEM_ID, Config.EVENT_DEATHMATCH_ITEM_COUNT);
}
}
}
public static Location OnEscape(L2Player player)
{
if(_status > 1 && player != null && player.getTeam() > 0 && live_list.contains(player.getStoredId()))
{
removePlayer(player);
checkLive();
}
return null;
}
public static void OnPlayerExit(L2Player player)
{
if(player == null || player.getTeam() < 1)
return;
// Вышел или вылетел во время регистрации
if(_status == 0 && _isRegistrationActive && live_list.contains(player.getStoredId()))
{
removePlayer(player);
return;
}
// Вышел или вылетел во время телепортации
if(_status == 1 && live_list.contains(player.getStoredId()))
{
removePlayer(player);
try
{
String var = player.getVar("DeatMatch_backCoords");
if(var == null || var.equals(""))
return;
String[] coords = var.split(" ");
if(coords.length != 4)
return;
player.teleToLocation(Integer.parseInt(coords[0]), Integer.parseInt(coords[1]), Integer.parseInt(coords[2]), Integer.parseInt(coords[3]));
player.unsetVar("DeatMatch_backCoords");
}
catch(Exception e)
{
e.printStackTrace();
}
return;
}
// Вышел или вылетел во время эвента
OnEscape(player);
}
private class ZoneListener extends L2ZoneEnterLeaveListener
{
@Override
public void objectEntered(L2Zone zone, L2Object object)
{
if(object == null)
return;
L2Player player = object.getPlayer();
if(_status > 0 && player != null && !live_list.contains(player.getStoredId()) && player.getReflectionId() == ReflectionTable.EVENT_DEATHMATCH)
teleportToColiseumSpawn((L2Character) object);
}
@Override
public void objectLeaved(L2Zone zone, L2Object object)
{
if(object == null)
return;
L2Player player = object.getPlayer();
if(_status > 1 && player != null && player.getTeam() > 0 && live_list.contains(player.getStoredId()) && player.getReflectionId() == ReflectionTable.EVENT_DEATHMATCH)
{
double angle = Util.convertHeadingToDegree(player.getHeading()); // угол в градусах
double radian = Math.toRadians(angle - 90); // угол в радианах
int x = (int) (object.getX() + 50 * Math.sin(radian));
int y = (int) (object.getY() - 50 * Math.cos(radian));
int z = object.getZ();
player.teleToLocation(x, y, z);
}
}
}
private static void loosePlayer(L2Player player, boolean inc)
{
if(player != null)
if(inc && player.getTeam() > 0)
{
show(new CustomMessage("scripts.events.Revive", player).addNumber(Config.EVENT_DEATHMATCH_REVIVE_DELAY), player);
executeTask("events.deathmatch.DeathMatch", "resurrect", new Object[] { player }, Config.EVENT_DEATHMATCH_REVIVE_DELAY * 1000);
}
else
{
live_list.remove(player.getStoredId());
player.setTeam(0, false);
show(new CustomMessage("scripts.events.deathmatch.YouLose", player), player);
}
}
public static void resurrect(L2Player player)
{
if(player.getTeam() <= 0)
return;
if(player.isDead())
{
player.setCurrentHp(player.getMaxHp(), true);
player.setCurrentCp(player.getMaxCp());
player.setCurrentMp(player.getMaxMp());
player.broadcastPacket(new Revive(player));
}
Location pos = Rnd.coordsRandomize(176424, 20376, -3275, 0, 0, 500);
player.teleToLocation(pos, ReflectionTable.EVENT_DEATHMATCH);
}
private static void removePlayer(L2Player player)
{
if(player != null)
{
live_list.remove(player.getStoredId());
players_list.remove(player.getStoredId());
player.setTeam(0, false);
}
}
private static GArray<L2Player> getPlayers(GCSArray<Long> list)
{
GArray<L2Player> result = new GArray<L2Player>();
for(Long storeId : list)
{
L2Player player = L2ObjectsStorage.getAsPlayer(storeId);
if(player != null)
result.add(player);
}
return result;
}
private static void openColiseumDoors()
{
_reflection.openDoors(_doors);
}
private static void closeColiseumDoors()
{
_reflection.closeDoors(_doors);
}
@Override
public EventType getEventType()
{
return EventType.DEATHMATCH;
}
}