Addition of Team vs Team event.

This commit is contained in:
MobiusDev
2017-12-11 06:15:57 +00:00
parent eda8dfccfe
commit 2747c3fa29
125 changed files with 7372 additions and 245 deletions

View File

@@ -674,6 +674,7 @@ public final class L2PcInstance extends L2Playable
@SuppressWarnings("rawtypes")
private volatile Map<Class<? extends AbstractEvent>, AbstractEvent<?>> _events;
private boolean _isOnCustomEvent = false;
public boolean isSpawnProtected()
{
@@ -8150,7 +8151,12 @@ public final class L2PcInstance extends L2Playable
return false;
}
// Check if the attacker is in TvT and TvT is started
if (isOnCustomEvent() && (getTeam() == attacker.getTeam()))
{
return false;
}
// CoC needs this check?
if (isOnEvent())
{
return true;
@@ -13117,12 +13123,26 @@ public final class L2PcInstance extends L2Playable
_canRevive = val;
}
public boolean isOnCustomEvent()
{
return _isOnCustomEvent;
}
public void setOnCustomEvent(boolean value)
{
_isOnCustomEvent = value;
}
/**
* @return {@code true} if player is on event, {@code false} otherwise.
*/
@Override
public boolean isOnEvent()
{
if (_isOnCustomEvent)
{
return true;
}
if (_events != null)
{
for (AbstractEvent<?> listener : _events.values())
@@ -13138,6 +13158,10 @@ public final class L2PcInstance extends L2Playable
public boolean isBlockedFromExit()
{
if (_isOnCustomEvent)
{
return true;
}
if (_events != null)
{
for (AbstractEvent<?> listener : _events.values())
@@ -13153,6 +13177,10 @@ public final class L2PcInstance extends L2Playable
public boolean isBlockedFromDeathPenalty()
{
if (_isOnCustomEvent)
{
return true;
}
if (_events != null)
{
for (AbstractEvent<?> listener : _events.values())

View File

@@ -63,6 +63,10 @@ public class ConditionPlayerCanEscape extends Condition
{
canTeleport = false;
}
else if (player.isOnCustomEvent())
{
canTeleport = false;
}
return (_val == canTeleport);
}
}

View File

@@ -64,6 +64,11 @@ public class ConditionPlayerCanTransform extends Condition
player.sendPacket(SystemMessageId.YOU_CANNOT_TRANSFORM_WHILE_RIDING_A_PET);
canTransform = false;
}
else if (player.isOnCustomEvent())
{
player.sendMessage("You cannot transform while registered on an event.");
canTransform = false;
}
return (_val == canTransform);
}
}

View File

@@ -888,19 +888,22 @@ public final class Instance implements IIdentifiable, INamable
*/
public void onDeath(L2PcInstance player)
{
// Send message
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.IF_YOU_ARE_NOT_RESURRECTED_WITHIN_S1_MINUTE_S_YOU_WILL_BE_EXPELLED_FROM_THE_INSTANT_ZONE);
sm.addInt(_template.getEjectTime());
player.sendPacket(sm);
// Start eject task
_ejectDeadTasks.put(player.getObjectId(), ThreadPoolManager.schedule(() ->
if (!player.isOnCustomEvent())
{
if (player.isDead())
// Send message
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.IF_YOU_ARE_NOT_RESURRECTED_WITHIN_S1_MINUTE_S_YOU_WILL_BE_EXPELLED_FROM_THE_INSTANT_ZONE);
sm.addInt(_template.getEjectTime());
player.sendPacket(sm);
// Start eject task
_ejectDeadTasks.put(player.getObjectId(), ThreadPoolManager.schedule(() ->
{
ejectPlayer(player.getActingPlayer());
}
}, _template.getEjectTime() * 60 * 1000)); // minutes to milliseconds
if (player.isDead())
{
ejectPlayer(player.getActingPlayer());
}
}, _template.getEjectTime() * 60 * 1000)); // minutes to milliseconds
}
}
/**

View File

@@ -365,6 +365,7 @@ public class InstanceTemplate extends ListenersContainer implements IIdentifiabl
public Location getExitLocation(L2PcInstance player)
{
Location location = null;
switch (_exitLocationType)
{
case RANDOM:

View File

@@ -179,8 +179,8 @@ public enum ExIncomingPackets implements IIncomingPackets<L2GameClient>
EX_BOOKMARK_PACKET(0x4E, ExBookmarkPacket::new, ConnectionState.IN_GAME),
REQUEST_WITHDRAW_PREMIUM_ITEM(0x4F, RequestWithDrawPremiumItem::new, ConnectionState.IN_GAME),
REQUEST_EX_JUMP(0x50, null, ConnectionState.IN_GAME),
REQUEST_EX_START_SHOW_CRATAE_CUBE_RANK(0x51, null, ConnectionState.IN_GAME),
REQUEST_EX_STOP_SHOW_CRATAE_CUBE_RANK(0x52, null, ConnectionState.IN_GAME),
REQUEST_EX_START_SHOW_CRATAE_CUBE_RANK(0x51, RequestStartShowKrateisCubeRank::new, ConnectionState.IN_GAME),
REQUEST_EX_STOP_SHOW_CRATAE_CUBE_RANK(0x52, RequestStopShowKrateisCubeRank::new, ConnectionState.IN_GAME),
NOTIFY_START_MINI_GAME(0x53, null, ConnectionState.IN_GAME),
REQUEST_EX_JOIN_DOMINION_WAR(0x54, null, ConnectionState.IN_GAME),
REQUEST_EX_DOMINION_INFO(0x55, null, ConnectionState.IN_GAME),

View File

@@ -29,7 +29,10 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.entity.Castle;
import com.l2jmobius.gameserver.model.entity.ClanHall;
import com.l2jmobius.gameserver.model.entity.Fort;
import com.l2jmobius.gameserver.model.events.EventType;
import com.l2jmobius.gameserver.model.events.listeners.AbstractEventListener;
import com.l2jmobius.gameserver.model.instancezone.Instance;
import com.l2jmobius.gameserver.model.quest.Event;
import com.l2jmobius.gameserver.model.residences.AbstractResidence;
import com.l2jmobius.gameserver.model.residences.ResidenceFunctionType;
import com.l2jmobius.gameserver.network.L2GameClient;
@@ -92,6 +95,19 @@ public final class RequestRestartPoint implements IClientIncomingPacket
return;
}
// Custom event resurrection management.
if (activeChar.isOnCustomEvent())
{
for (AbstractEventListener listener : activeChar.getListeners(EventType.ON_CREATURE_DEATH))
{
if (listener.getOwner() instanceof Event)
{
((Event) listener.getOwner()).notifyEvent("ResurrectPlayer", null, activeChar);
return;
}
}
}
final Castle castle = CastleManager.getInstance().getCastle(activeChar.getX(), activeChar.getY(), activeChar.getZ());
if ((castle != null) && castle.getSiege().isInProgress())
{

View File

@@ -0,0 +1,39 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.clientpackets;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.network.L2GameClient;
/**
* @author Mobius
*/
public class RequestStartShowKrateisCubeRank implements IClientIncomingPacket
{
@Override
public boolean read(L2GameClient client, PacketReader packet)
{
return false;
}
@Override
public void run(L2GameClient client)
{
// TODO: Implement.
System.out.println("RequestStartShowKrateisCubeRank");
}
}

View File

@@ -0,0 +1,39 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.clientpackets;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.network.L2GameClient;
/**
* @author Mobius
*/
public class RequestStopShowKrateisCubeRank implements IClientIncomingPacket
{
@Override
public boolean read(L2GameClient client, PacketReader packet)
{
return false;
}
@Override
public void run(L2GameClient client)
{
// TODO: Implement.
System.out.println("RequestStopShowKrateisCubeRank");
}
}

View File

@@ -0,0 +1,41 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.serverpackets;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.network.OutgoingPackets;
/**
* @author Mobius
*/
public class ExPVPMatchCCMyRecord implements IClientOutgoingPacket
{
private final int _points;
public ExPVPMatchCCMyRecord(int points)
{
_points = points;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_PVP_MATCH_CCMY_RECORD.writeId(packet);
packet.writeD(_points);
return true;
}
}

View File

@@ -0,0 +1,57 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.serverpackets;
import java.util.Map;
import java.util.Map.Entry;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.OutgoingPackets;
/**
* @author Mobius
*/
public class ExPVPMatchCCRecord implements IClientOutgoingPacket
{
public static final int INITIALIZE = 0;
public static final int UPDATE = 1;
public static final int FINISH = 2;
private final int _state;
private final Map<L2PcInstance, Integer> _players;
public ExPVPMatchCCRecord(int state, Map<L2PcInstance, Integer> players)
{
_state = state;
_players = players;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_PVP_MATCH_CCRECORD.writeId(packet);
packet.writeD(_state); // 0 - initialize, 1 - update, 2 - finish
packet.writeD(_players.size());
for (Entry<L2PcInstance, Integer> entry : _players.entrySet())
{
packet.writeS(entry.getKey().getName());
packet.writeD(entry.getValue());
}
return true;
}
}

View File

@@ -31,6 +31,8 @@ import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import java.util.TreeMap;
import java.util.logging.Logger;
import com.l2jmobius.Config;
@@ -788,4 +790,15 @@ public final class Util
return (input < min) ? min : (input > max) ? max : input;
}
/**
* Short an <L2PcInstance, Integer> map by its integer values.
* @param unsortedMap
* @return
*/
public static Map<L2PcInstance, Integer> sortByValue(Map<L2PcInstance, Integer> unsortedMap)
{
Map<L2PcInstance, Integer> sortedMap = new TreeMap<>(new ValueComparator(unsortedMap));
sortedMap.putAll(unsortedMap);
return sortedMap;
}
}

View File

@@ -0,0 +1,46 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.util;
import java.util.Comparator;
import java.util.Map;
/**
* @author Mobius
*/
public class ValueComparator implements Comparator<Object>
{
Map<?, ?> _map;
public ValueComparator(Map<?, ?> map)
{
_map = map;
}
@SuppressWarnings(
{
"rawtypes",
"unchecked"
})
@Override
public int compare(Object keyA, Object keyB)
{
Comparable valueA = (Comparable<?>) _map.get(keyA);
Comparable valueB = (Comparable) _map.get(keyB);
return valueB.compareTo(valueA);
}
}