Battalion zone - incomplete.

Contributed by Ionut.
This commit is contained in:
mobius
2015-01-15 13:21:00 +00:00
parent 7b2eeaf75d
commit 3ae2479692
12 changed files with 596 additions and 1 deletions

View File

@@ -251,6 +251,7 @@ import com.l2jserver.gameserver.model.variables.AccountVariables;
import com.l2jserver.gameserver.model.variables.PlayerVariables;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
import com.l2jserver.gameserver.model.zone.ZoneId;
import com.l2jserver.gameserver.model.zone.type.L2BattalionZone;
import com.l2jserver.gameserver.model.zone.type.L2BossZone;
import com.l2jserver.gameserver.network.L2GameClient;
import com.l2jserver.gameserver.network.SystemMessageId;
@@ -5599,6 +5600,8 @@ public final class L2PcInstance extends L2Playable
{
setPvpKills(getPvpKills() + 1);
L2BattalionZone.givereward(this);
// Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
UserInfo ui = new UserInfo(this, false);
ui.addComponentType(UserInfoType.SOCIAL);

View File

@@ -47,7 +47,8 @@ public enum ZoneId
NO_BOOKMARK,
NO_ITEM_DROP,
NO_RESTART,
JUMP;
JUMP,
BATTALION;
public static int getZoneCount()
{

View File

@@ -0,0 +1,268 @@
/*
* Copyright (C) 2004-2015 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.zone.type;
import com.l2jserver.Config;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.datatables.ItemTable;
import com.l2jserver.gameserver.datatables.SkillData;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Summon;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.itemcontainer.PcInventory;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.zone.L2ZoneRespawn;
import com.l2jserver.gameserver.model.zone.ZoneId;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ExShowScreenMessage;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.util.Rnd;
/**
* Another type of damage zone with skills
* @author kerberos
*/
public class L2BattalionZone extends L2ZoneRespawn
{
private final static Skill NOBLESS_SKILL = SkillData.getInstance().getSkill(1323, 1);
private final static String[] GRADE_NAMES =
{
"",
"D",
"C",
"B",
"A",
"S",
"S80",
"S84",
"R",
"R95",
"R99"
};
public L2BattalionZone(int id)
{
super(id);
}
@Override
protected void onEnter(L2Character character)
{
character.setInsideZone(ZoneId.NO_SUMMON_FRIEND, true);
character.setInsideZone(ZoneId.BATTALION, true);
character.setInsideZone(ZoneId.PVP, true);
if (!Config.BTZ_STORE_ZONE)
{
character.setInsideZone(ZoneId.NO_STORE, true);
}
if (character.isPlayer())
{
final L2PcInstance activeChar = character.getActingPlayer();
if ((Config.BTZ_CLASSES != null) && Config.BTZ_CLASSES.contains("" + activeChar.getClassId().getId()))
{
activeChar.teleToLocation(83597, 147888, -3405);
activeChar.sendMessage("Your class is not allowed in the Battalion zone.");
return;
}
for (L2ItemInstance o : activeChar.getInventory().getItems())
{
if (o.isEquipable() && o.isEquipped() && !checkItem(o))
{
int slot = activeChar.getInventory().getSlotFromItem(o);
activeChar.getInventory().unEquipItemInBodySlot(slot);
activeChar.sendMessage(o.getName() + " unequiped because is not allowed inside this zone.");
}
}
activeChar.sendMessage("You entered into the Battalion zone.");
clear(activeChar);
if (Config.BTZ_GIVE_NOBLES)
{
NOBLESS_SKILL.applyEffects(activeChar, activeChar);
}
if (Config.BTZ_PVP_ENABLED)
{
activeChar.updatePvPFlag(1);
}
}
}
@Override
protected void onExit(L2Character character)
{
character.setInsideZone(ZoneId.NO_SUMMON_FRIEND, false);
character.setInsideZone(ZoneId.BATTALION, false);
character.setInsideZone(ZoneId.PVP, false);
if (!Config.BTZ_STORE_ZONE)
{
character.setInsideZone(ZoneId.NO_STORE, false);
}
if (character.isPlayer())
{
final L2PcInstance activeChar = character.getActingPlayer();
activeChar.sendMessage("You left from a Battalion zone.");
if (Config.BTZ_PVP_ENABLED)
{
activeChar.stopPvPFlag();
}
}
}
@Override
public void onDieInside(final L2Character character)
{
if (character.isPlayer())
{
final L2PcInstance activeChar = character.getActingPlayer();
if (Config.BTZ_REVIVE)
{
ThreadPoolManager.getInstance().scheduleGeneral(() ->
{
activeChar.doRevive();
heal(activeChar);
int[] loc = Config.BTZ_SPAWN_LOCATIONS[Rnd.get(Config.BTZ_SPAWN_LOCATIONS.length)];
activeChar.teleToLocation(loc[0] + Rnd.get(-Config.BTZ_RADIUS, Config.BTZ_RADIUS), loc[1] + Rnd.get(-Config.BTZ_RADIUS, Config.BTZ_RADIUS), loc[2]);
}, Config.BTZ_REVIVE_DELAY * 1000);
ExShowScreenMessage revive = new ExShowScreenMessage("You will be respawned in " + Config.BTZ_REVIVE_DELAY + " seconds.", 5000, true, 2); // 5 Seconds display
activeChar.sendPacket(revive);
}
}
}
@Override
public void onReviveInside(L2Character character)
{
if (character.isPlayer())
{
final L2PcInstance activeChar = character.getActingPlayer();
if (Config.BTZ_REVIVE_NOBLESS)
{
NOBLESS_SKILL.applyEffects(activeChar, activeChar);
}
if (Config.BTZ_REVIVE_HEAL)
{
heal(activeChar);
}
}
}
private void clear(L2PcInstance player)
{
if (Config.BTZ_REMOVE_BUFFS)
{
player.stopAllEffectsExceptThoseThatLastThroughDeath();
if (Config.BTZ_REMOVE_PETS)
{
L2Summon pet = player.getSummon();
if (pet != null)
{
pet.stopAllEffectsExceptThoseThatLastThroughDeath();
pet.unSummon(player);
}
}
}
else
{
if (Config.BTZ_REMOVE_PETS)
{
L2Summon pet = player.getSummon();
if (pet != null)
{
pet.unSummon(player);
}
}
}
}
private static void heal(L2PcInstance activeChar)
{
activeChar.setCurrentHp(activeChar.getMaxHp());
activeChar.setCurrentCp(activeChar.getMaxCp());
activeChar.setCurrentMp(activeChar.getMaxMp());
}
public static void givereward(L2PcInstance player)
{
if (player.isInsideZone(ZoneId.BATTALION))
{
SystemMessage systemMessage = null;
for (int[] reward : Config.BTZ_REWARDS)
{
final PcInventory inv = player.getInventory();
if (ItemTable.getInstance().createDummyItem(reward[0]).isStackable())
{
inv.addItem("L2MultiFunctionZone ", reward[0], reward[1], player, player);
if (reward[1] > 1)
{
systemMessage = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S2_S1_S);
systemMessage.addItemName(reward[0]);
systemMessage.addLong(reward[1]);
}
else
{
systemMessage = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1);
systemMessage.addItemName(reward[0]);
}
player.sendPacket(systemMessage);
}
else
{
for (int i = 0; i < reward[1]; ++i)
{
inv.addItem("L2MultiFunctionZone ", reward[0], 1, player, player);
systemMessage = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1);
systemMessage.addItemName(reward[0]);
player.sendPacket(systemMessage);
}
}
}
}
}
public static boolean checkItem(L2ItemInstance item)
{
final int o = item.getItem().getCrystalType().ordinal();
final int e = item.getEnchantLevel();
if ((Config.BTZ_ENCHANT != 0) && (e >= Config.BTZ_ENCHANT))
{
return false;
}
if (Config.BTZ_GRADES.contains(GRADE_NAMES[o]))
{
return false;
}
if ((Config.BTZ_ITEMS != null) && Config.BTZ_ITEMS.contains("" + item.getId()))
{
return false;
}
return true;
}
}

View File

@@ -25,6 +25,7 @@ import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.L2Event;
import com.l2jserver.gameserver.model.zone.ZoneId;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.taskmanager.AttackStanceTaskManager;
@@ -70,6 +71,13 @@ public final class Logout extends L2GameClientPacket
return;
}
if (player.isInsideZone(ZoneId.BATTALION) && !Config.BTZ_LOGOUT_ZONE)
{
player.sendMessage("You cannot logout while inside a Battalion zone.");
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Don't allow leaving if player is fighting
if (AttackStanceTaskManager.getInstance().hasAttackStanceTask(player))
{

View File

@@ -26,6 +26,7 @@ import com.l2jserver.Config;
import com.l2jserver.gameserver.enums.PrivateStoreType;
import com.l2jserver.gameserver.instancemanager.AntiFeedManager;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.zone.ZoneId;
import com.l2jserver.gameserver.network.L2GameClient;
import com.l2jserver.gameserver.network.L2GameClient.GameClientState;
import com.l2jserver.gameserver.network.SystemMessageId;
@@ -90,6 +91,13 @@ public final class RequestRestart extends L2GameClientPacket
return;
}
if (player.isInsideZone(ZoneId.BATTALION) && !Config.BTZ_RESTART_ZONE)
{
player.sendMessage("You cannot restart while inside a Battalion zone.");
sendPacket(RestartResponse.valueOf(false));
return;
}
if (player.isBlockedFromExit())
{
sendPacket(RestartResponse.valueOf(false));

View File

@@ -42,6 +42,8 @@ import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.model.items.type.ArmorType;
import com.l2jserver.gameserver.model.items.type.WeaponType;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.zone.ZoneId;
import com.l2jserver.gameserver.model.zone.type.L2BattalionZone;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.ExUseSharedGroupItem;
@@ -127,6 +129,12 @@ public final class UseItem extends L2GameClientPacket
return;
}
if (activeChar.isInsideZone(ZoneId.BATTALION) && !L2BattalionZone.checkItem(item))
{
getClient().getActiveChar().sendMessage("You cannot use " + item.getName() + " inside this zone.");
return;
}
if (item.getItem().getType2() == L2Item.TYPE2_QUEST)
{
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_USE_QUEST_ITEMS);

View File

@@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.l2jserver.Config;
import com.l2jserver.gameserver.instancemanager.CHSiegeManager;
import com.l2jserver.gameserver.instancemanager.CastleManager;
import com.l2jserver.gameserver.instancemanager.FortManager;
@@ -31,6 +32,7 @@ import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.entity.Castle;
import com.l2jserver.gameserver.model.entity.Fort;
import com.l2jserver.gameserver.model.entity.clanhall.SiegableHall;
import com.l2jserver.gameserver.model.zone.ZoneId;
/**
* @author UnAfraid, Nos
@@ -81,6 +83,16 @@ public class Die extends L2GameServerPacket
_toFortress = ((clan != null) && (clan.getFortId() > 0)) || isInFortDefense;
}
if (activeChar.isInsideZone(ZoneId.BATTALION) && !Config.BTZ_REVIVE)
{
_toVillage = false;
_toClanHall = false;
_toCastle = false;
_toOutpost = false;
_useFeather = false;
_toFortress = false;
}
_isSweepable = activeChar.isAttackable() && activeChar.isSweepActive();
}

View File

@@ -74,6 +74,30 @@ public class ExShowScreenMessage extends L2GameServerPacket
_npcString = -1;
}
/**
* Display a String on the screen for a given time.
* @param text the text to display
* @param time the display time
* @param position the position on the screen
* @param showEffect upper effect (false - disabled, true - enabled) - _position must be 2 (center) otherwise no effect
*/
public ExShowScreenMessage(String text, int time, boolean showEffect, int position)
{
_type = 2;
_sysMessageId = -1;
_unk1 = 0;
_unk2 = 0;
_unk3 = 0;
_fade = false;
_position = TOP_CENTER;
_text = text;
_time = time;
_size = 0;
_effect = showEffect;
_npcString = -1;
}
/**
* Display a NPC String on the screen for a given position and time.
* @param npcString the NPC String Id