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

@@ -717,3 +717,124 @@ PremiumRateSpoilAmount = 2
# Usage: itemId1,multiplier1;itemId2,multiplier2;...
PremiumRateDropChanceByItemId = 57,2
PremiumRateDropAmountByItemId = 57,2
# ---------------------------------------------------------------------------
# Battalion zone - a custom feature for your server (Mass or Solo Battalion)
# ---------------------------------------------------------------------------
# This option will turn on PvP flag to all people when entering to the zone.
BTZEnablePvP = True
# If set to false, zone will be no-restart zone.
BTZRestartZone = False
# If set to false, zone will be no-logout zone.
BTZLogoutZone = False
# If set to false, zone will be no-store zone.
BTZStoreZone = False
# Give noblesse after revive?
BTZReviveNoblesse = False
# Heal after revive?
BTZReviveHeal = False
# If set to true, players will take noblesse blessing when entering.
BTZGiveNoblesse = True
# Remove buffs when entering to the zone.
BTZRemoveBuffs = False
# Remove pets when entering to the zone.
BTZRemovePets = False
# Delay, in seconds, to wait before revive.
# 0 to disable
BTZReviveDelay = 10
# Delay, in seconds, to wait before revive (for support classes).
# 0 to disable
BTZReviveSupportDelay = 15
# Which are the support classes?
# Example: 93,85,12
BTZSupport = 93
# Set the spawn points where players will be teleported on revive, if enabled.
# Example: 150111,144740,-12248;143665,144418,-12022;144443,147685,-12139
BTZSpawnLoc = 150111,144740,-12248;143665,144418,-12022;144443,147685,-12139
# Random respawn radius
BTZRespawnRadius = 500
# List of Items(id's) that won't be usable inside this area and also will be unequiped when entering.
# (armor, weapons, scrolls, potions, etc), example: 728,7575, 6383, 1538
BTZItems = 728,7575,6383,1538
# List of Grades that won't be usable inside this area and also will be unequiped when entering.
# Example: D,C,B,A,S,S80,S84,R,R95,R99
BTZGrades = C,B,A
# Items with this enchant or more won't be usable inside this area and also will be unequiped when entering.
# 0 to disable
BTZEnchant = 0
# Players with one of that classes won't be able to enter to the zone.
# Example: 93,85,12
BTZClasses = 92
# ---------------------------------------------------------------------------
# Options if you set Battalion zone as Solo.
# ---------------------------------------------------------------------------
# Disable clan crests?
BTZDisableCrests = False
# Allow mass skills (heal hp, heal mp, heal cp etc.) for clan/allies members?
BTZHealAllies = False
# Can attack clan/allies members w.o CTRL on?
BTZAttackAllies = False
# Character custom name inside zone?
BTZAddCustomName = False
# Character custom name inside zone?
BTZName = Player
# Character custom title inside zone?
BTZAddCustomTitle = False
# Character custom title inside zone?
BTZTitle = Kill Me
# PvP Count restriction while joining the zone?
# 0 to disable
BTZPvpCount = 500
# ---------------------------------------------------------------------------
# Rewards for hunting inside Battalion zone
# ---------------------------------------------------------------------------
# Reward for every kill you make.
# Example: 57,100000;14720,1
BTZRewards = 57,100000;14720,1
# Reward for every kill your party makes.
# Example: 57,100000;14720,1
BTZSupportRewards = 57,100000;14720,1
# Chances to get rewarded when your party killing someone (calculated in %)
# Example: 57,100000;14720,1
BTZChanceSupportRewards = 50
# ---------------------------------------------------------------------------
# Anti feed inside Battalion zone
# ---------------------------------------------------------------------------
# Delay time when killing the same person multiple times (calculated in seconds).
# Example: 30
# 0 for no delay (disable)
BTZDelay = 10

View File

@@ -149,6 +149,7 @@
<xs:enumeration value="TerritoryWarZone" />
<xs:enumeration value="TownZone" />
<xs:enumeration value="WaterZone" />
<xs:enumeration value="BattalionZone" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<list enabled="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/zones.xsd">
<zone name="Battalion" type="BattalionZone" shape="NPoly" minZ="-15000" maxZ="-10000">
<node X="130000" Y="160000" />
<node X="130000" Y="130000" />
<node X="160000" Y="130000" />
<node X="160000" Y="160000" />
</zone>
</list>

View File

@@ -847,6 +847,24 @@ public final class Config
public static float PREMIUM_RATE_SPOIL_AMOUNT;
public static Map<Integer, Float> PREMIUM_RATE_DROP_CHANCE_BY_ID;
public static Map<Integer, Float> PREMIUM_RATE_DROP_AMOUNT_BY_ID;
public static boolean BTZ_PVP_ENABLED;
public static int[][] BTZ_SPAWN_LOCATIONS;
public static int BTZ_REVIVE_DELAY;
public static boolean BTZ_REVIVE;
public static boolean BTZ_GIVE_NOBLES;
public static List<String> BTZ_ITEMS = new ArrayList<>();
public static List<String> BTZ_CLASSES = new ArrayList<>();
public static List<String> BTZ_GRADES = new ArrayList<>();
public static int BTZ_RADIUS;
public static int BTZ_ENCHANT;
public static boolean BTZ_RESTART_ZONE;
public static boolean BTZ_STORE_ZONE;
public static boolean BTZ_LOGOUT_ZONE;
public static boolean BTZ_REVIVE_NOBLESS;
public static boolean BTZ_REVIVE_HEAL;
public static boolean BTZ_REMOVE_BUFFS;
public static boolean BTZ_REMOVE_PETS;
public static List<int[]> BTZ_REWARDS;
// --------------------------------------------------
// NPC Settings
@@ -2725,6 +2743,71 @@ public final class Config
}
}
BTZ_PVP_ENABLED = CustomSettings.getBoolean("BTZEnablePvP", false);
BTZ_SPAWN_LOCATIONS = parseZonesList(CustomSettings.getString("BTZSpawnLoc", "150111,144740,-12248"));
BTZ_REVIVE_DELAY = CustomSettings.getInt("BTZReviveDelay", 10);
if (BTZ_REVIVE_DELAY != 0)
{
BTZ_REVIVE = true;
}
BTZ_GIVE_NOBLES = CustomSettings.getBoolean("BTZGiveNoblesse", false);
tempString = CustomSettings.getString("BTZItems", "").split(",");
if (tempString.length != 0)
{
for (String i : tempString)
{
BTZ_ITEMS.add(i);
}
}
tempString = CustomSettings.getString("BTZGrades", "").split(",");
if (tempString.length != 0)
{
for (String i : tempString)
{
if (i.equals("D") || i.equals("C") || i.equals("B") || i.equals("A") || i.equals("S") || i.equals("S80") || i.equals("S84") || i.equals("R") || i.equals("R95") || i.equals("R99"))
{
BTZ_GRADES.add(i);
}
}
}
tempString = CustomSettings.getString("BTZClasses", "").split(",");
if (tempString.length != 0)
{
for (String i : tempString)
{
BTZ_CLASSES.add(i);
}
}
BTZ_RADIUS = CustomSettings.getInt("BTZRespawnRadius", 500);
BTZ_ENCHANT = CustomSettings.getInt("BTZEnchant", 0);
BTZ_REMOVE_BUFFS = CustomSettings.getBoolean("BTZRemoveBuffs", false);
BTZ_REMOVE_PETS = CustomSettings.getBoolean("BTZRemovePets", false);
BTZ_RESTART_ZONE = CustomSettings.getBoolean("BTZRestartZone", false);
BTZ_STORE_ZONE = CustomSettings.getBoolean("BTZStoreZone", false);
BTZ_LOGOUT_ZONE = CustomSettings.getBoolean("BTZLogoutZone", false);
BTZ_REVIVE_NOBLESS = CustomSettings.getBoolean("BTZReviveNoblesse", false);
BTZ_REVIVE_HEAL = CustomSettings.getBoolean("BTZReviveHeal", false);
BTZ_REWARDS = new ArrayList<>();
tempString = CustomSettings.getString("BTZRewards", "57,100000").split(";");
for (String reward : tempString)
{
String[] rewardSplit = reward.split(",");
if (rewardSplit.length == 2)
{
try
{
BTZ_REWARDS.add(new int[]
{
Integer.parseInt(rewardSplit[0]),
Integer.parseInt(rewardSplit[1])
});
}
catch (NumberFormatException nfe)
{
}
}
}
// Load PvP L2Properties file (if exists)
final PropertiesParser PVPSettings = new PropertiesParser(PVP_CONFIG_FILE);
@@ -4093,6 +4176,55 @@ public final class Config
return result;
}
private static int[][] parseZonesList(String line)
{
final String[] propertySplit = line.split(";");
if (propertySplit.length == 0)
{
return null;
}
int i = 0;
String[] valueSplit;
final int[][] result = new int[propertySplit.length][];
for (String value : propertySplit)
{
valueSplit = value.split(",");
if (valueSplit.length != 3)
{
return null;
}
result[i] = new int[3];
try
{
result[i][0] = Integer.parseInt(valueSplit[0]);
}
catch (NumberFormatException e)
{
return null;
}
try
{
result[i][1] = Integer.parseInt(valueSplit[1]);
}
catch (NumberFormatException e)
{
return null;
}
try
{
result[i][2] = Integer.parseInt(valueSplit[2]);
}
catch (NumberFormatException e)
{
return null;
}
i++;
}
return result;
}
private static class IPConfigData implements DocumentParser
{
private static final List<String> _subnets = new ArrayList<>(5);

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