Перейти к содержанию
Авторизация  
rootroot

Tvt Arena

Рекомендуемые сообщения

всем привет. если есть знающие люди прощу помочь

 

Ситуация следующая. евент твт арена. запускается норм, регистрация и старт битвы норм.

После того как одна команда убивает другую один из персов виснет, и назад его не телепортирует. также после отключения евента через админку не удаляется нпц

 

Ошибка в консоли такая

 

 

java.lang.ArithmeticException: / by zero

at events.TvTArena.TvTTemplate.payItemToTeam(TvTTemplate.java:738)

at events.TvTArena.TvTTemplate.teamHasLost(TvTTemplate.java:697)

at events.TvTArena.TvTTemplate.checkTeams(TvTTemplate.java:395)

at events.TvTArena.TvTTemplate.onPlayerExit(TvTTemplate.java:819)

at events.TvTArena.TvTTemplate.onTeleport(TvTTemplate.java:827)

at events.TvTArena.TvTArena2.onTeleport(TvTArena2.java:141)

at l2r.gameserver.model.actor.listener.PlayerListenerList.onTeleport(Pla

yerListenerList.java:60)

at l2r.gameserver.model.Creature.teleToLocation(Creature.java:4432)

at l2r.gameserver.model.Creature.teleToLocation(Creature.java:4395)

at l2r.gameserver.model.Player.teleToLocation(Player.java:5975)

at events.TvTArena.TvTTemplate.teleportPlayersToSavedCoords(TvTTemplate.

java:425)

at events.TvTArena.TvTTemplate.teamHasLost(TvTTemplate.java:706)

at events.TvTArena.TvTTemplate.checkTeams(TvTTemplate.java:395)

at events.TvTArena.TvTTemplate.playerHasLost(TvTTemplate.java:689)

at events.TvTArena.TvTTemplate.onDeath(TvTTemplate.java:775)

at events.TvTArena.TvTArena2.onDeath(TvTArena2.java:129)

at l2r.gameserver.model.actor.listener.CharListenerList.onDeath(CharList

enerList.java:121)

at l2r.gameserver.model.Creature.onDeath(Creature.java:1661)

at l2r.gameserver.model.Player.onDeath(Player.java:3657)

at l2r.gameserver.model.Creature.doDie(Creature.java:1612)

at l2r.gameserver.model.Creature.onReduceCurrentHp(Creature.java:3208)

at l2r.gameserver.model.Player.onReduceCurrentHp(Player.java:3389)

at l2r.gameserver.model.Creature.reduceCurrentHp(Creature.java:3177)

at l2r.gameserver.model.Playable.reduceCurrentHp(Playable.java:322)

at l2r.gameserver.model.Player.reduceCurrentHp(Player.java:3322)

at l2r.gameserver.skills.skillclasses.MDam.useSkill(MDam.java:36)

at l2r.gameserver.model.Creature.callSkill(Creature.java:1125)

at l2r.gameserver.model.Playable.callSkill(Playable.java:511)

at l2r.gameserver.model.Creature.onMagicUseTimer(Creature.java:3072)

at l2r.gameserver.model.GameObjectTasks$MagicUseTask.runImpl(GameObjectT

asks.java:349)

at l2r.commons.threading.RunnableImpl.run(RunnableImpl.java:21)

at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)

at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)

at java.util.concurrent.FutureTask.run(Unknown Source)

at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.

access$201(Unknown Source)

at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.

run(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

 

 

 

package events.TvTArena;

 

import java.util.ArrayList;

import java.util.List;

 

import l2r.commons.threading.RunnableImpl;

import l2r.commons.util.Rnd;

import l2r.gameserver.Announcements;

import l2r.gameserver.ThreadPoolManager;

import l2r.gameserver.instancemanager.ReflectionManager;

import l2r.gameserver.listener.zone.OnZoneEnterLeaveListener;

import l2r.gameserver.model.Creature;

import l2r.gameserver.model.GameObject;

import l2r.gameserver.model.GameObjectsStorage;

import l2r.gameserver.model.Playable;

import l2r.gameserver.model.Player;

import l2r.gameserver.model.Skill;

import l2r.gameserver.model.Summon;

import l2r.gameserver.model.Zone;

import l2r.gameserver.model.base.TeamType;

import l2r.gameserver.model.entity.Hero;

import l2r.gameserver.model.instances.NpcInstance;

import l2r.gameserver.network.serverpackets.components.ChatType;

import l2r.gameserver.network.serverpackets.components.SystemMsg;

import l2r.gameserver.network.serverpackets.Revive;

import l2r.gameserver.network.serverpackets.SkillList;

import l2r.gameserver.scripts.Functions;

import l2r.gameserver.tables.SkillTable;

import l2r.gameserver.utils.Location;

import l2r.gameserver.utils.PositionUtils;

 

 

public abstract class TvTTemplate extends Functions

{

private static int ITEM_ID = 4357;

private static String ITEM_NAME = "Silver Shilen";

private static int LENGTH_TEAM = 12;

private static boolean ALLOW_BUFFS = false;

private static boolean ALLOW_CLAN_SKILL = true;

private static boolean ALLOW_HERO_SKILL = false;

 

/*

Config.EVENT_TVT_ARENA_ITEM_ID;

Config.EVENT_TVT_ARENA_ITEM_NAME;

Config.EVENT_TVT_ARENA_MAX_LENGTH_TEAM;

Config.EVENT_TVT_ARENA_ALLOW_BUFFS;

Config.EVENT_TVT_ARENA_ALLOW_CLAN_SKILL;

Config.EVENT_TVT_ARENA_ALLOW_HERO_SKILL;

*/

 

protected int _managerId;

protected String _className;

 

protected Long _creatorId;

protected NpcInstance _manager;

protected int _status = 0;

protected int _CharacterFound = 0;

protected int _price = 10000;

protected int _team1count = 1;

protected int _team2count = 1;

protected int _team1min = 1;

protected int _team1max = 85;

protected int _team2min = 1;

protected int _team2max = 85;

protected int _timeToStart = 10;

protected boolean _timeOutTask;

 

protected List _team1points;

protected List _team2points;

 

protected List _team1list;

protected List _team2list;

protected List _team1live;

protected List _team2live;

 

protected Zone _zone;

protected ZoneListener _zoneListener;

 

protected abstract void onLoad();

 

protected abstract void onReload();

 

public void template_stop()

{

if(_status <= 0)

return;

 

sayToAll("Бой прерван по техническим причинам, ставки возвращены");

 

unParalyzeTeams();

ressurectPlayers();

returnItemToTeams();

healPlayers();

removeBuff();

teleportPlayersToSavedCoords();

clearTeams();

_status = 0;

_timeOutTask = false;

}

 

public void template_create1(Player player)

{

if(_status > 0)

{

show("Дождитесь окончания боя", player);

return;

}

 

if(player.getTeam() != TeamType.NONE)

{

show("Вы уже зарегистрированы", player);

return;

}

show("scripts/events/TvTArena/" + _managerId + "-1.htm", player);

}

 

public void template_register(Player player)

{

if(_status == 0)

{

show("Бой на данный момент не создан", player);

return;

}

 

if(_status > 1)

{

show("Дождитесь окончания боя", player);

return;

}

 

if(player.getTeam() != TeamType.NONE)

{

show("Вы уже зарегистрированы", player);

return;

}

show("scripts/events/TvTArena/" + _managerId + "-3.htm", player);

}

 

public void template_check1(Player player, NpcInstance manager, String[] var)

{

if(var.length != 8)

{

show("Некорректные данные", player);

return;

}

 

if(_status > 0)

{

show("Дождитесь окончания боя", player);

return;

}

if(manager == null || !manager.isNpc())

{

show("Hacker? :) " + manager, player);

return;

}

_manager = manager;

try

{

_price = Integer.valueOf(var[0]);

_team1count = Integer.valueOf(var[1]);

_team2count = Integer.valueOf(var[2]);

_team1min = Integer.valueOf(var[3]);

_team1max = Integer.valueOf(var[4]);

_team2min = Integer.valueOf(var[5]);

_team2max = Integer.valueOf(var[6]);

_timeToStart = Integer.valueOf(var[7]);

}

catch(Exception e)

{

show("Некорректные данные", player);

return;

}

if(_price < 1 || _price > 500)

{

show("Неправильная ставка", player);

return;

}

if(_team1count < 1 || _team1count > LENGTH_TEAM || _team2count < 1 || _team2count > LENGTH_TEAM)

{

show("Неправильный размер команды", player);

return;

}

if(_team1min < 1 || _team1min > 86 || _team2min < 1 || _team2min > 86 || _team1max < 1 || _team1max > 86 || _team2max < 1 || _team2max > 86 || _team1min > _team1max || _team2min > _team2max)

{

show("Неправильный уровень", player);

return;

}

if(player.getLevel() < _team1min || player.getLevel() > _team1max)

{

show("Неправильный уровень", player);

return;

}

if(_timeToStart < 1 || _timeToStart > 10)

{

show("Неправильное время", player);

return;

}

if(getItemCount(player, ITEM_ID) < _price)

{

player.sendPacket(SystemMsg.INCORRECT_ITEM_COUNT);

return;

}

_creatorId = player.getStoredId();

removeItem(player, ITEM_ID, _price);

player.setTeam(TeamType.BLUE);

_status = 1;

_team1list.clear();

_team2list.clear();

_team1live.clear();

_team2live.clear();

_team1list.add(player.getStoredId());

sayToAll(player.getName() + " создал бой " + _team1count + "х" + _team2count + ", " + _team1min + "-" + _team1max + "lv vs " + _team2min + "-" + _team2max + "lv, ставка " + _price + " " + ITEM_NAME + ", начало через " + _timeToStart + " мин");

executeTask("events.TvTArena." + _className, "announce", new Object[0], 60000);

}

 

public void template_register_check(Player player)

{

if(_status == 0)

{

show("Бой на данный момент не создан", player);

return;

}

 

if(_status > 1)

{

show("Дождитесь окончания боя", player);

return;

}

 

if(_team1list.contains(player.getStoredId()) || _team2list.contains(player.getStoredId()))

{

show("Вы уже зарегистрированы", player);

return;

}

 

if(player.getTeam() != TeamType.NONE)

{

show("Вы уже зарегистрированы", player);

return;

}

 

if(getItemCount(player, ITEM_ID) < _price)

{

player.sendPacket(SystemMsg.INCORRECT_ITEM_COUNT);

return;

}

 

int size1 = _team1list.size(), size2 = _team2list.size();

 

if(size1 > size2)

{

String t = null;

if(tryRegister(2, player) != null)

if((t = tryRegister(1, player)) != null)

show(t, player);

}

else if(size1 < size2)

{

String t = null;

if(tryRegister(1, player) != null)

if((t = tryRegister(2, player)) != null)

show(t, player);

}

else

{

int team = Rnd.get(1, 2);

String t = null;

if(tryRegister(team, player) != null)

if((t = tryRegister(team == 1 ? 2 : 1, player)) != null)

show(t, player);

}

}

 

private String tryRegister(int team, Player player)

{

if(team == 1)

{

if(player.getLevel() < _team1min || player.getLevel() > _team1max)

return "Вы не подходите по уровню";

if(_team1list.size() >= _team1count)

return "Команда 1 переполнена";

doRegister(1, player);

return null;

}

if(player.getLevel() < _team2min || player.getLevel() > _team2max)

return "Вы не подходите по уровню";

if(_team2list.size() >= _team2count)

return "Команда 2 переполнена";

doRegister(2, player);

return null;

}

 

private void doRegister(int team, Player player)

{

removeItem(player, ITEM_ID, _price);

 

if(team == 1)

{

_team1list.add(player.getStoredId());

player.setTeam(TeamType.BLUE);

sayToAll(player.getName() + " зарегистрировался за 1 команду");

}

else

{

_team2list.add(player.getStoredId());

player.setTeam(TeamType.RED);

sayToAll(player.getName() + " зарегистрировался за 2 команду");

}

 

if(_team1list.size() >= _team1count && _team2list.size() >= _team2count)

{

sayToAll("Команды готовы, старт через 1 минуту.");

_timeToStart = 1;

}

}

 

public void template_announce()

{

Player creator = GameObjectsStorage.getAsPlayer(_creatorId);

 

if(_status != 1 || creator == null)

return;

 

if(_timeToStart > 1)

{

_timeToStart--;

sayToAll(creator.getName() + " создал бой " + _team1count + "х" + _team2count + ", " + _team1min + "-" + _team1max + "lv vs " + _team2min + "-" + _team2max + "lv, ставка " + _price + " " + ITEM_NAME + ", начало через " + _timeToStart + " мин");

executeTask("events.TvTArena." + _className, "announce", new Object[0], 60000);

}

else if(_team2list.size() > 0)

{

sayToAll("Подготовка к бою");

executeTask("events.TvTArena." + _className, "prepare", new Object[0], 5000);

}

else

{

sayToAll("Бой не состоялся, нет противников");

_status = 0;

returnItemToTeams();

clearTeams();

}

}

 

public void template_prepare()

{

if(_status != 1)

return;

 

_status = 2;

for(Player player : getPlayers(_team1list))

if(!player.isDead())

_team1live.add(player.getStoredId());

for(Player player : getPlayers(_team2list))

if(!player.isDead())

_team2live.add(player.getStoredId());

if(!checkTeams())

return;

saveBackCoords();

clearArena();

ressurectPlayers();

removeBuff();

healPlayers();

paralyzeTeams();

teleportTeamsToArena();

sayToAll("Бой начнется через 30 секунд");

executeTask("events.TvTArena." + _className, "start", new Object[0], 30000);

}

 

public void template_start()

{

if(_status != 2)

return;

 

if(!checkTeams())

return;

sayToAll("Go!!!");

unParalyzeTeams();

_status = 3;

executeTask("events.TvTArena." + _className, "timeOut", new Object[0], 180000);

_timeOutTask = true;

}

 

public void clearArena()

{

for(GameObject obj : _zone.getObjects())

if(obj != null && obj.isPlayable())

((Playable) obj).teleToLocation(_zone.getSpawn());

}

 

public boolean checkTeams()

{

if(_team1live.isEmpty())

{

teamHasLost(1);

return false;

}

else if(_team2live.isEmpty())

{

teamHasLost(2);

return false;

}

return true;

}

 

public void saveBackCoords()

{

for(Player player : getPlayers(_team1list))

player.setVar("TvTArena_backCoords", player.getX() + " " + player.getY() + " " + player.getZ() + " " + player.getReflectionId(), -1);

for(Player player : getPlayers(_team2list))

player.setVar("TvTArena_backCoords", player.getX() + " " + player.getY() + " " + player.getZ() + " " + player.getReflectionId(), -1);

}

 

public void teleportPlayersToSavedCoords()

{

for(Player player : getPlayers(_team1list))

try

{

String var = player.getVar("TvTArena_backCoords");

if(var == null || var.equals(""))

continue;

String[] coords = var.split(" ");

if(coords.length != 4)

continue;

player.teleToLocation(Integer.parseInt(coords[0]), Integer.parseInt(coords[1]), Integer.parseInt(coords[2]), Integer.parseInt(coords[3]));

player.unsetVar("TvTArena_backCoords");

}

catch(Exception e)

{

e.printStackTrace();

}

for(Player player : getPlayers(_team2list))

try

{

String var = player.getVar("TvTArena_backCoords");

if(var == null || var.equals(""))

continue;

String[] coords = var.split(" ");

if(coords.length != 4)

continue;

player.teleToLocation(Integer.parseInt(coords[0]), Integer.parseInt(coords[1]), Integer.parseInt(coords[2]), Integer.parseInt(coords[3]));

player.unsetVar("TvTArena_backCoords");

}

catch(Exception e)

{

e.printStackTrace();

}

}

 

public void healPlayers()

{

for(Player player : getPlayers(_team1list))

{

player.setCurrentHpMp(player.getMaxHp(), player.getMaxMp());

player.setCurrentCp(player.getMaxCp());

}

for(Player player : getPlayers(_team2list))

{

player.setCurrentHpMp(player.getMaxHp(), player.getMaxMp());

player.setCurrentCp(player.getMaxCp());

}

}

 

public void ressurectPlayers()

{

for(Player player : getPlayers(_team1list))

if(player.isDead())

{

player.restoreExp();

player.setCurrentHp(player.getMaxHp(), true);

player.setCurrentMp(player.getMaxMp());

player.setCurrentCp(player.getMaxCp());

player.broadcastPacket(new Revive(player));

}

for(Player player : getPlayers(_team2list))

if(player.isDead())

{

player.restoreExp();

player.setCurrentHp(player.getMaxHp(), true);

player.setCurrentMp(player.getMaxMp());

player.setCurrentCp(player.getMaxCp());

player.broadcastPacket(new Revive(player));

}

}

 

public void removeBuff()

{

for(Player player : getPlayers(_team1list))

if(player != null)

try

{

if(player.isCastingNow())

player.abortCast(true, true);

 

if(!ALLOW_CLAN_SKILL)

if(player.getClan() != null)

for(Skill skill : player.getClan().getAllSkills())

player.removeSkill(skill, false);

 

if(!ALLOW_HERO_SKILL)

if(player.isHero())

Hero.removeSkills(player);

 

if(!ALLOW_BUFFS)

{

player.getEffectList().stopAllEffects();

 

if(player.getPet() != null)

{

Summon summon = player.getPet();

summon.getEffectList().stopAllEffects();

if(summon.isPet())

summon.unSummon();

}

 

if(player.getAgathionId() > 0)

player.setAgathion(0);

}

 

player.sendPacket(new SkillList(player));

}

catch(Exception e)

{

e.printStackTrace();

}

 

for(Player player : getPlayers(_team2list))

if(player != null)

try

{

if(player.isCastingNow())

player.abortCast(true, true);

 

if(!ALLOW_CLAN_SKILL)

if(player.getClan() != null)

for(Skill skill : player.getClan().getAllSkills())

player.removeSkill(skill, false);

 

if(!ALLOW_HERO_SKILL)

if(player.isHero())

Hero.removeSkills(player);

 

if(!ALLOW_BUFFS)

{

player.getEffectList().stopAllEffects();

 

if(player.getPet() != null)

{

Summon summon = player.getPet();

summon.getEffectList().stopAllEffects();

if(summon.isPet())

summon.unSummon();

}

 

if(player.getAgathionId() > 0)

player.setAgathion(0);

}

 

player.sendPacket(new SkillList(player));

}

catch(Exception e)

{

e.printStackTrace();

}

}

 

public void backBuff()

{

for(Player player : getPlayers(_team1list))

{

if(player == null)

continue;

try

{

player.getEffectList().stopAllEffects();

 

if(!ALLOW_CLAN_SKILL)

if(player.getClan() != null)

for(Skill skill : player.getClan().getAllSkills())

if(skill.getMinPledgeClass() <= player.getPledgeClass())

player.addSkill(skill, false);

 

if(!ALLOW_HERO_SKILL)

if(player.isHero())

Hero.addSkills(player);

 

player.sendPacket(new SkillList(player));

}

catch(Exception e)

{

e.printStackTrace();

}

}

 

for(Player player : getPlayers(_team2list))

{

if(player == null)

continue;

try

{

player.getEffectList().stopAllEffects();

 

if(!ALLOW_CLAN_SKILL)

if(player.getClan() != null)

for(Skill skill : player.getClan().getAllSkills())

if(skill.getMinPledgeClass() <= player.getPledgeClass())

player.addSkill(skill, false);

 

if(!ALLOW_HERO_SKILL)

if(player.isHero())

Hero.addSkills(player);

 

player.sendPacket(new SkillList(player));

}

catch(Exception e)

{

e.printStackTrace();

}

}

}

 

public void paralyzeTeams()

{

Skill revengeSkill = SkillTable.getInstance().getInfo(Skill.SKILL_RAID_CURSE, 1);

for(Player player : getPlayers(_team1list))

{

player.getEffectList().stopEffect(Skill.SKILL_MYSTIC_IMMUNITY);

revengeSkill.getEffects(player, player, false, false);

if(player.getPet() != null)

revengeSkill.getEffects(player, player.getPet(), false, false);

}

for(Player player : getPlayers(_team2list))

{

player.getEffectList().stopEffect(Skill.SKILL_MYSTIC_IMMUNITY);

revengeSkill.getEffects(player, player, false, false);

if(player.getPet() != null)

revengeSkill.getEffects(player, player.getPet(), false, false);

}

}

 

public void unParalyzeTeams()

{

for(Player player : getPlayers(_team1list))

{

player.getEffectList().stopEffect(Skill.SKILL_RAID_CURSE);

if(player.getPet() != null)

player.getPet().getEffectList().stopEffect(Skill.SKILL_RAID_CURSE);

 

player.leaveParty();

}

for(Player player : getPlayers(_team2list))

{

player.getEffectList().stopEffect(Skill.SKILL_RAID_CURSE);

if(player.getPet() != null)

player.getPet().getEffectList().stopEffect(Skill.SKILL_RAID_CURSE);

 

player.leaveParty();

}

}

 

public void teleportTeamsToArena()

{

Integer n = 0;

for(Player player : getPlayers(_team1live))

{

unRide(player);

unSummonPet(player, true);

player.teleToLocation(_team1points.get(n), ReflectionManager.DEFAULT);

n++;

}

n = 0;

for(Player player : getPlayers(_team2live))

{

unRide(player);

unSummonPet(player, true);

player.teleToLocation(_team2points.get(n), ReflectionManager.DEFAULT);

n++;

}

}

 

public boolean playerHasLost(Player player)

{

if(player.getTeam() == TeamType.BLUE)

_team1live.remove(player.getStoredId());

else

_team2live.remove(player.getStoredId());

Skill revengeSkill = SkillTable.getInstance().getInfo(Skill.SKILL_RAID_CURSE, 1);

revengeSkill.getEffects(player, player, false, false);

return !checkTeams();

}

 

public void teamHasLost(Integer team_id)

{

if(team_id == 1)

{

sayToAll("Команда 2 победила");

payItemToTeam(2);

}

else

{

sayToAll("Команда 1 победила");

payItemToTeam(1);

}

unParalyzeTeams();

backBuff();

teleportPlayersToSavedCoords();

ressurectPlayers();

healPlayers();

clearTeams();

_status = 0;

_timeOutTask = false;

}

 

public void template_timeOut()

{

if(_timeOutTask && _status == 3)

{

sayToAll("Время истекло, ничья!");

returnItemToTeams();

unParalyzeTeams();

backBuff();

teleportPlayersToSavedCoords();

ressurectPlayers();

healPlayers();

clearTeams();

_status = 0;

_timeOutTask = false;

}

}

 

public void payItemToTeam(Integer team_id)

{

if(team_id == 1)

for(Player player : getPlayers(_team1list))

addItem(player, ITEM_ID, _price + _team2list.size() * _price / _team1list.size());

else

for(Player player : getPlayers(_team2list))

addItem(player, ITEM_ID, _price + _team2list.size() * _price / _team1list.size());

}

 

public void returnItemToTeams()

{

for(Player player : getPlayers(_team1list))

addItem(player, ITEM_ID, _price);

for(Player player : getPlayers(_team2list))

addItem(player, ITEM_ID, _price);

}

 

public void clearTeams()

{

for(Player player : getPlayers(_team1list))

player.setTeam(TeamType.NONE);

for(Player player : getPlayers(_team2list))

player.setTeam(TeamType.NONE);

_team1list.clear();

_team2list.clear();

_team1live.clear();

_team2live.clear();

}

 

public void onDeath(Creature self, Creature killer)

{

if(_status >= 2 && self.isPlayer() && self.getTeam() != TeamType.NONE && (_team1list.contains(self.getStoredId()) || _team2list.contains(self.getStoredId())))

{

Player player = self.getPlayer();

Player kplayer = killer.getPlayer();

if(kplayer != null)

{

sayToAll(kplayer.getName() + " убил " + player.getName());

if(player.getTeam() == kplayer.getTeam() || !_team1list.contains(kplayer.getStoredId()) && !_team2list.contains(kplayer.getStoredId()))

{

sayToAll("Нарушение правил, игрок " + kplayer.getName() + " оштрафован на " + _price + " " + ITEM_NAME);

removeItem(kplayer, ITEM_ID, _price);

}

playerHasLost(player);

}

else

{

sayToAll(player.getName() + " убит");

playerHasLost(player);

}

}

}

 

public void onPlayerExit(Player player)

{

if(player != null && _status > 0 && player.getTeam() != TeamType.NONE && (_team1list.contains(player.getStoredId()) || _team2list.contains(player.getStoredId())))

switch(_status)

{

case 1:

removePlayer(player);

sayToAll(player.getName() + " дисквалифицирован");

if(player.getStoredId() == _creatorId)

{

sayToAll("Бой прерван, ставки возвращены");

 

returnItemToTeams();

backBuff();

teleportPlayersToSavedCoords();

unParalyzeTeams();

ressurectPlayers();

healPlayers();

clearTeams();

 

unParalyzeTeams();

clearTeams();

_status = 0;

_timeOutTask = false;

}

break;

case 2:

removePlayer(player);

sayToAll(player.getName() + " дисквалифицирован");

checkTeams();

break;

case 3:

removePlayer(player);

sayToAll(player.getName() + " дисквалифицирован");

checkTeams();

break;

}

}

 

public void onTeleport(Player player)

{

if(player != null && _status > 1 && player.getTeam() != TeamType.NONE && player.isInZone(_zone))

onPlayerExit(player);

}

 

public class ZoneListener implements OnZoneEnterLeaveListener

{

@Override

public void onZoneEnter(Zone zone, Creature cha)

{

Player player = cha.getPlayer();

if(_status >= 2 && player != null && !(_team1list.contains(player.getStoredId()) || _team2list.contains(player.getStoredId())))

ThreadPoolManager.getInstance().schedule(new TeleportTask(cha, _zone.getSpawn()), 3000);

}

 

@Override

public void onZoneLeave(Zone zone, Creature cha)

{

Player player = cha.getPlayer();

if(_status >= 2 && player != null && player.getTeam() != TeamType.NONE && (_team1list.contains(player.getStoredId()) || _team2list.contains(player.getStoredId())))

{

double angle = PositionUtils.convertHeadingToDegree(cha.getHeading()); // угол в градусах

double radian = Math.toRadians(angle - 90); // угол в радианах

int x = (int) (cha.getX() + 50 * Math.sin(radian));

int y = (int) (cha.getY() - 50 * Math.cos(radian));

int z = cha.getZ();

ThreadPoolManager.getInstance().schedule(new TeleportTask(cha, new Location(x, y, z)), 3000);

}

}

}

 

public class TeleportTask extends RunnableImpl

{

Location loc;

Creature target;

 

public TeleportTask(Creature target, Location loc)

{

this.target = target;

this.loc = loc;

target.block();

}

 

@Override

public void runImpl() throws Exception

{

target.unblock();

target.teleToLocation(loc);

}

}

 

private void removePlayer(Player player)

{

if(player != null)

{

_team1list.remove(player.getStoredId());

_team2list.remove(player.getStoredId());

_team1live.remove(player.getStoredId());

_team2live.remove(player.getStoredId());

player.setTeam(TeamType.NONE);

}

}

 

private List getPlayers(List list)

{

List result = new ArrayList();

for(Long storeId : list)

{

Player player = GameObjectsStorage.getAsPlayer(storeId);

if(player != null)

result.add(player);

}

return result;

}

 

public void sayToAll(String text)

{

Announcements.getInstance().announceToAll(_manager.getName() + ": " + text, ChatType.CRITICAL_ANNOUNCE);

}

}

 

 

 

package events.TvTArena;

 

import java.util.ArrayList;

import java.util.List;

import java.util.concurrent.CopyOnWriteArrayList;

 

import l2r.gameserver.Announcements;

import l2r.gameserver.data.htm.HtmCache;

import l2r.gameserver.data.xml.holder.NpcHolder;

import l2r.gameserver.instancemanager.ServerVariables;

import l2r.gameserver.listener.actor.OnDeathListener;

import l2r.gameserver.listener.actor.player.OnPlayerExitListener;

import l2r.gameserver.listener.actor.player.OnTeleportListener;

import l2r.gameserver.model.Creature;

import l2r.gameserver.model.Player;

import l2r.gameserver.model.SimpleSpawner;

import l2r.gameserver.model.actor.listener.CharListenerList;

import l2r.gameserver.model.entity.Reflection;

import l2r.gameserver.model.instances.NpcInstance;

import l2r.gameserver.scripts.Functions;

import l2r.gameserver.scripts.ScriptFile;

import l2r.gameserver.templates.npc.NpcTemplate;

import l2r.gameserver.utils.Location;

import l2r.gameserver.utils.ReflectionUtils;

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

 

public class TvTArena1 extends Functions implements ScriptFile, OnDeathListener, OnTeleportListener, OnPlayerExitListener

{

private static final Logger _log = LoggerFactory.getLogger(TvTArena1.class);

 

private static class TvTArena1Impl extends TvTTemplate

{

@Override

protected void onLoad()

{

_managerId = 31390;

_className = "TvTArena1";

_status = 0;

 

_team1list = new CopyOnWriteArrayList();

_team2list = new CopyOnWriteArrayList();

_team1live = new CopyOnWriteArrayList();

_team2live = new CopyOnWriteArrayList();

 

_zoneListener = new ZoneListener();

_zone = ReflectionUtils.getZone("[tvt_arena1]");

_zone.addListener(_zoneListener);

 

_team1points = new ArrayList();

_team2points = new ArrayList();

 

_team1points.add(new Location(-81806, -44865, -11418));

_team1points.add(new Location(-81617, -44893, -11418));

_team1points.add(new Location(-81440, -44945, -11418));

_team1points.add(new Location(-81301, -48066, -11418));

_team1points.add(new Location(-81168, -45208, -11418));

_team1points.add(new Location(-81114, -46379, -11418));

_team1points.add(new Location(-81068, -45570, -11418));

_team1points.add(new Location(-81114, -45728, -11418));

_team1points.add(new Location(-81162, -45934, -11418));

_team1points.add(new Location(-81280, -46045, -11418));

_team1points.add(new Location(-81424, -46196, -11418));

_team1points.add(new Location(-81578, -46238, -11418));

_team2points.add(new Location(-81792, -46299, -11418));

_team2points.add(new Location(-81959, -46247, -11418));

_team2points.add(new Location(-82147, -46206, -11418));

_team2points.add(new Location(-82256, -46093, -11418));

_team2points.add(new Location(-82418, -45940, -11418));

_team2points.add(new Location(-82455, -45779, -11418));

_team2points.add(new Location(-82513, -45573, -11418));

_team2points.add(new Location(-82464, -45499, -11418));

_team2points.add(new Location(-82421, -45215, -11418));

_team2points.add(new Location(-82308, -45106, -11418));

_team2points.add(new Location(-82160, -44948, -11418));

_team2points.add(new Location(-81978, -44904, -11418));

}

 

@Override

protected void onReload()

{

if(_status > 0)

template_stop();

_zone.removeListener(_zoneListener);

}

 

}

 

private static TvTTemplate _instance;

 

public static TvTTemplate getInstance()

{

if(_instance == null)

_instance = new TvTArena1Impl();

return _instance;

}

 

@Override

public void onLoad()

{

CharListenerList.addGlobal(this);

getInstance().onLoad();

if(isActive())

{

spawnEventManagers();

_log.info("Loaded Event: TvT Arena 1 [state: activated]");

}

else

_log.info("Loaded Event: TvT Arena 1 [state: deactivated]");

}

 

@Override

public void onReload()

{

getInstance().onReload();

unSpawnEventManagers();

_instance = null;

}

 

@Override

public void onShutdown()

{

 

}

 

@Override

public void onDeath(Creature cha, Creature killer)

{

getInstance().onDeath(cha, killer);

}

 

@Override

public void onPlayerExit(Player player)

{

getInstance().onPlayerExit(player);

}

 

@Override

public void onTeleport(Player player, int x, int y, int z, Reflection reflection)

{

getInstance().onTeleport(player);

}

 

public String DialogAppend_31390(Integer val)

{

if(val == 0)

{

Player player = getSelf();

if(player.isGM())

return HtmCache.getInstance().getNotNull("scripts/events/TvTArena/31390.htm", player) + HtmCache.getInstance().getNotNull("scripts/events/TvTArena/31390-4.htm", player);

return HtmCache.getInstance().getNotNull("scripts/events/TvTArena/31390.htm", player);

}

return "";

}

 

public void create1()

{

getInstance().template_create1(getSelf());

}

 

public void register()

{

getInstance().template_register(getSelf());

}

 

public void check1(String[] var)

{

getInstance().template_check1(getSelf(), getNpc(), var);

}

 

public void register_check()

{

getInstance().template_register_check(getSelf());

}

 

public void stop()

{

getInstance().template_stop();

}

 

public void announce()

{

getInstance().template_announce();

}

 

public void prepare()

{

getInstance().template_prepare();

}

 

public void start()

{

getInstance().template_start();

}

 

public void timeOut()

{

getInstance().template_timeOut();

}

 

private List _spawns = new ArrayList();

 

/**

* Читает статус эвента из базы.

*/

private boolean isActive()

{

return IsActive("TvT Arena 1");

}

 

/**

* Запускает эвент

*/

public void startEvent()

{

Player player = getSelf();

if(!player.getPlayerAccess().IsEventGm)

return;

 

if(SetActive("TvT Arena 1", true))

{

spawnEventManagers();

System.out.println("Event: TvT Arena 1 started.");

Announcements.getInstance().announceToAll("Начался TvT Arena 1 эвент.");

}

else

player.sendMessage("TvT Arena 1 Event already started.");

 

show("admin/events/events.htm", player);

}

 

/**

* Останавливает эвент

*/

public void stopEvent()

{

Player player = getSelf();

if(!player.getPlayerAccess().IsEventGm)

return;

 

if(SetActive("TvT Arena 1", false))

{

ServerVariables.unset("TvT Arena 1");

unSpawnEventManagers();

stop();

System.out.println("TvT Arena 1 Event stopped.");

Announcements.getInstance().announceToAll("TvT Arena 1 эвент окончен.");

}

else

player.sendMessage("TvT Arena 1 Event not started.");

 

show("admin/events/events.htm", player);

}

 

/**

* Спавнит эвент менеджеров

*/

private void spawnEventManagers()

{

final int EVENT_MANAGERS[][] = { { 82840, 149167, -3495, 0 } };

 

NpcTemplate template = NpcHolder.getInstance().getTemplate(31390);

for(int[] element : EVENT_MANAGERS)

{

SimpleSpawner sp = new SimpleSpawner(template);

sp.setLocx(element[0]);

sp.setLocy(element[1]);

sp.setLocz(element[2]);

sp.setHeading(element[3]);

NpcInstance npc = sp.doSpawn(true);

npc.setName("Arena 1");

npc.setTitle("TvT Event");

_spawns.add(npc);

}

}

 

/**

* Удаляет спавн эвент менеджеров

*/

private void unSpawnEventManagers()

{

for(NpcInstance npc : _spawns)

npc.deleteMe();

_spawns.clear();

}

}

 

 

С твт арена 2 и 3 таже самая история.

 

Помогите пожалуйста

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

решил проблему:

 

Затык в формуле расчета призов для проигравшей команды.

 

Ключевые моменты:

 

java.lang.ArithmeticException: / by zero

at events.TvTArena.TvTTemplate.payItemToTeam(TvTTemplate.java:738)

 

public void payItemToTeam(Integer team_id)

{

if(team_id == 1)

for(Player player : getPlayers(_team1list))

addItem(player, ITEM_ID, _price + _team2list.size() * _price / _team1list.size());

else

for(Player player : getPlayers(_team2list))

addItem(player, ITEM_ID, _price + _team2list.size() * _price / _team1list.size());

}

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

Для публикации сообщений создайте учётную запись или авторизуйтесь

Вы должны быть пользователем, чтобы оставить комментарий

Создать учетную запись

Зарегистрируйте новую учётную запись в нашем сообществе. Это очень просто!

Регистрация нового пользователя

Войти

Уже есть аккаунт? Войти в систему.

Войти
Авторизация  

  • Последние посетители   0 пользователей онлайн

    Ни одного зарегистрированного пользователя не просматривает данную страницу

×
×
  • Создать...