From 5b36c274cd973e6b2c2a8f0b3614150e607cff28 Mon Sep 17 00:00:00 2001 From: MobiusDev <8391001+MobiusDevelopment@users.noreply.github.com> Date: Fri, 23 Mar 2018 14:37:35 +0000 Subject: [PATCH] Adapted random spawn system to newer branches. --- .../dist/game/config/Custom/RandomSpawns.ini | 21 ++++++++++++++++ .../java/com/l2jmobius/Config.java | 21 ++++++++++++++++ .../l2jmobius/gameserver/model/L2Spawn.java | 17 +++++++++++++ .../dist/game/config/Custom/RandomSpawns.ini | 21 ++++++++++++++++ .../java/com/l2jmobius/Config.java | 21 ++++++++++++++++ .../l2jmobius/gameserver/model/L2Spawn.java | 17 +++++++++++++ .../dist/game/config/Custom/RandomSpawns.ini | 21 ++++++++++++++++ .../java/com/l2jmobius/Config.java | 21 ++++++++++++++++ .../l2jmobius/gameserver/model/L2Spawn.java | 17 +++++++++++++ .../dist/game/config/Custom/RandomSpawns.ini | 21 ++++++++++++++++ .../java/com/l2jmobius/Config.java | 21 ++++++++++++++++ .../l2jmobius/gameserver/model/L2Spawn.java | 17 +++++++++++++ .../l2jmobius/gameserver/model/L2Spawn.java | 24 +++++++++---------- .../dist/game/config/Custom/RandomSpawns.ini | 21 ++++++++++++++++ .../java/com/l2jmobius/Config.java | 21 ++++++++++++++++ .../l2jmobius/gameserver/model/L2Spawn.java | 17 +++++++++++++ .../dist/game/config/Custom/RandomSpawns.ini | 21 ++++++++++++++++ .../java/com/l2jmobius/Config.java | 21 ++++++++++++++++ .../l2jmobius/gameserver/model/L2Spawn.java | 17 +++++++++++++ 19 files changed, 366 insertions(+), 12 deletions(-) create mode 100644 L2J_Mobius_1.0_Ertheia/dist/game/config/Custom/RandomSpawns.ini create mode 100644 L2J_Mobius_2.5_Underground/dist/game/config/Custom/RandomSpawns.ini create mode 100644 L2J_Mobius_3.0_Helios/dist/game/config/Custom/RandomSpawns.ini create mode 100644 L2J_Mobius_4.0_GrandCrusade/dist/game/config/Custom/RandomSpawns.ini create mode 100644 L2J_Mobius_Classic_2.0_Saviors/dist/game/config/Custom/RandomSpawns.ini create mode 100644 L2J_Mobius_Classic_2.0_Zaken/dist/game/config/Custom/RandomSpawns.ini diff --git a/L2J_Mobius_1.0_Ertheia/dist/game/config/Custom/RandomSpawns.ini b/L2J_Mobius_1.0_Ertheia/dist/game/config/Custom/RandomSpawns.ini new file mode 100644 index 0000000000..0e55b3bb57 --- /dev/null +++ b/L2J_Mobius_1.0_Ertheia/dist/game/config/Custom/RandomSpawns.ini @@ -0,0 +1,21 @@ +# --------------------------------------------------------------------------- +# Random Spawn System for Monsters +# --------------------------------------------------------------------------- + +# Enable random monster spawns. +# Default: True +EnableRandomMonsterSpawns = True + +# Max range for X and Y coords. +# Default: 150 +MaxSpawnMobRange = 150 + +# Examples: No random spawns for Kasha's Eye, Pagan Guards, Sel Mahums, Four Sepulchers +# MobsSpawnNotRandom = 18812,18813,18814 +MobsSpawnNotRandom = 18812,18813,18814,22138,\ +18908,22775,22776,22777,22778,22779,22780,22781,22782,22783,22784,22785,22786,22787,22788,\ +18120,18132,18133,18137,18141,18145,18150,18151,18152,18153,18154,18155,18156,18157,18166,\ +18170,18171,18183,18184,18185,18186,18187,18191,18195,18196,18197,18198,18199,18212,18220,\ +18221,18222,18226,18230,18231,18232,18233,18234,18235,18236,18237,18238,18239,18240,18241,\ +18242,18243,18256,31452,31468,31469,31470,31471,31472,31473,31474,31475,31476,31477,31478,\ +31479,31480,31481,31482,31483,31484,31485,31486,31487 diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/Config.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/Config.java index ae8bef9ce1..276b470dde 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/Config.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/Config.java @@ -127,6 +127,7 @@ public final class Config public static final String CUSTOM_PVP_ANNOUNCE_CONFIG_FILE = "./config/Custom/PvpAnnounce.ini"; public static final String CUSTOM_PVP_REWARD_ITEM_CONFIG_FILE = "./config/Custom/PvpRewardItem.ini"; public static final String CUSTOM_PVP_TITLE_CONFIG_FILE = "./config/Custom/PvpTitleColor.ini"; + public static final String CUSTOM_RANDOM_SPAWNS_CONFIG_FILE = "./config/Custom/RandomSpawns.ini"; public static final String CUSTOM_SAYUNE_FOR_ALL_CONFIG_FILE = "./config/Custom/SayuneForAll.ini"; public static final String CUSTOM_SCREEN_WELCOME_MESSAGE_CONFIG_FILE = "./config/Custom/ScreenWelcomeMessage.ini"; public static final String CUSTOM_SELL_BUFFS_CONFIG_FILE = "./config/Custom/SellBuffs.ini"; @@ -1119,6 +1120,10 @@ public final class Config public static int CUSTOM_STARTING_LOC_Z; public static int SHOP_MIN_RANGE_FROM_NPC; public static int SHOP_MIN_RANGE_FROM_PLAYER; + public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; + public static int MOB_MIN_SPAWN_RANGE; + public static int MOB_MAX_SPAWN_RANGE; + public static List MOBS_LIST_NOT_RANDOM; public static boolean FREE_JUMPS_FOR_ALL; public static boolean CUSTOM_CB_ENABLED; public static int COMMUNITYBOARD_CURRENCY; @@ -2809,6 +2814,22 @@ public final class Config TITLE_FOR_PVP_AMOUNT4 = PvpTitleColor.getString("PvPTitleForAmount4", "Title"); TITLE_FOR_PVP_AMOUNT5 = PvpTitleColor.getString("PvPTitleForAmount5", "Title"); + // Load RandomSpawns config file (if exists) + final PropertiesParser RandomSpawns = new PropertiesParser(CUSTOM_RANDOM_SPAWNS_CONFIG_FILE); + + ENABLE_RANDOM_MONSTER_SPAWNS = RandomSpawns.getBoolean("EnableRandomMonsterSpawns", false); + MOB_MAX_SPAWN_RANGE = RandomSpawns.getInt("MaxSpawnMobRange", 150); + MOB_MIN_SPAWN_RANGE = MOB_MAX_SPAWN_RANGE * -1; + if (ENABLE_RANDOM_MONSTER_SPAWNS) + { + final String[] mobsIds = RandomSpawns.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); + MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + for (String id : mobsIds) + { + MOBS_LIST_NOT_RANDOM.add(Integer.valueOf(id)); + } + } + // Load SayuneForAll config file (if exists) final PropertiesParser SayuneForAll = new PropertiesParser(CUSTOM_SAYUNE_FOR_ALL_CONFIG_FILE); diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/L2Spawn.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/L2Spawn.java index 7ea99ed955..7d30f2e834 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/L2Spawn.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/L2Spawn.java @@ -23,9 +23,11 @@ import java.util.concurrent.ConcurrentLinkedDeque; import java.util.logging.Level; import java.util.logging.Logger; +import com.l2jmobius.Config; import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.data.xml.impl.NpcData; +import com.l2jmobius.gameserver.geoengine.GeoEngine; import com.l2jmobius.gameserver.model.actor.L2Npc; import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance; import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate; @@ -35,6 +37,7 @@ import com.l2jmobius.gameserver.model.interfaces.ILocational; import com.l2jmobius.gameserver.model.interfaces.INamable; import com.l2jmobius.gameserver.model.interfaces.IPositionable; import com.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; +import com.l2jmobius.gameserver.model.zone.ZoneId; /** * This class manages the spawn and respawn of a group of L2NpcInstance that are in the same are and have the same type.
@@ -540,6 +543,20 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable newlocz = getZ(); } + // If random spawn system is enabled + if (Config.ENABLE_RANDOM_MONSTER_SPAWNS) + { + final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); + final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); + + final boolean isQuestMonster = (npc.getTitle() != null) && npc.getTitle().contains("Quest"); + if (npc.isMonster() && !isQuestMonster && !npc.isWalker() && !npc.isInsideZone(ZoneId.NO_BOOKMARK) && (getInstanceId() == 0) && GeoEngine.getInstance().canMoveToTarget(newlocx, newlocy, newlocz, randX, randY, newlocz, npc.getInstanceWorld()) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId())) + { + newlocx = randX; + newlocy = randY; + } + } + // DO NOT CORRECT SPAWN Z IN GENERAL - Prevent NPC spawns on top of buildings // don't correct z of flying npc's // if (!npc.isFlying()) diff --git a/L2J_Mobius_2.5_Underground/dist/game/config/Custom/RandomSpawns.ini b/L2J_Mobius_2.5_Underground/dist/game/config/Custom/RandomSpawns.ini new file mode 100644 index 0000000000..0e55b3bb57 --- /dev/null +++ b/L2J_Mobius_2.5_Underground/dist/game/config/Custom/RandomSpawns.ini @@ -0,0 +1,21 @@ +# --------------------------------------------------------------------------- +# Random Spawn System for Monsters +# --------------------------------------------------------------------------- + +# Enable random monster spawns. +# Default: True +EnableRandomMonsterSpawns = True + +# Max range for X and Y coords. +# Default: 150 +MaxSpawnMobRange = 150 + +# Examples: No random spawns for Kasha's Eye, Pagan Guards, Sel Mahums, Four Sepulchers +# MobsSpawnNotRandom = 18812,18813,18814 +MobsSpawnNotRandom = 18812,18813,18814,22138,\ +18908,22775,22776,22777,22778,22779,22780,22781,22782,22783,22784,22785,22786,22787,22788,\ +18120,18132,18133,18137,18141,18145,18150,18151,18152,18153,18154,18155,18156,18157,18166,\ +18170,18171,18183,18184,18185,18186,18187,18191,18195,18196,18197,18198,18199,18212,18220,\ +18221,18222,18226,18230,18231,18232,18233,18234,18235,18236,18237,18238,18239,18240,18241,\ +18242,18243,18256,31452,31468,31469,31470,31471,31472,31473,31474,31475,31476,31477,31478,\ +31479,31480,31481,31482,31483,31484,31485,31486,31487 diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/Config.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/Config.java index 113fb01d82..ee7153c925 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/Config.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/Config.java @@ -128,6 +128,7 @@ public final class Config public static final String CUSTOM_PVP_ANNOUNCE_CONFIG_FILE = "./config/Custom/PvpAnnounce.ini"; public static final String CUSTOM_PVP_REWARD_ITEM_CONFIG_FILE = "./config/Custom/PvpRewardItem.ini"; public static final String CUSTOM_PVP_TITLE_CONFIG_FILE = "./config/Custom/PvpTitleColor.ini"; + public static final String CUSTOM_RANDOM_SPAWNS_CONFIG_FILE = "./config/Custom/RandomSpawns.ini"; public static final String CUSTOM_SAYUNE_FOR_ALL_CONFIG_FILE = "./config/Custom/SayuneForAll.ini"; public static final String CUSTOM_SCREEN_WELCOME_MESSAGE_CONFIG_FILE = "./config/Custom/ScreenWelcomeMessage.ini"; public static final String CUSTOM_SELL_BUFFS_CONFIG_FILE = "./config/Custom/SellBuffs.ini"; @@ -1126,6 +1127,10 @@ public final class Config public static int CUSTOM_STARTING_LOC_Z; public static int SHOP_MIN_RANGE_FROM_NPC; public static int SHOP_MIN_RANGE_FROM_PLAYER; + public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; + public static int MOB_MIN_SPAWN_RANGE; + public static int MOB_MAX_SPAWN_RANGE; + public static List MOBS_LIST_NOT_RANDOM; public static boolean FREE_JUMPS_FOR_ALL; public static boolean CUSTOM_CB_ENABLED; public static int COMMUNITYBOARD_CURRENCY; @@ -2825,6 +2830,22 @@ public final class Config TITLE_FOR_PVP_AMOUNT4 = PvpTitleColor.getString("PvPTitleForAmount4", "Title"); TITLE_FOR_PVP_AMOUNT5 = PvpTitleColor.getString("PvPTitleForAmount5", "Title"); + // Load RandomSpawns config file (if exists) + final PropertiesParser RandomSpawns = new PropertiesParser(CUSTOM_RANDOM_SPAWNS_CONFIG_FILE); + + ENABLE_RANDOM_MONSTER_SPAWNS = RandomSpawns.getBoolean("EnableRandomMonsterSpawns", false); + MOB_MAX_SPAWN_RANGE = RandomSpawns.getInt("MaxSpawnMobRange", 150); + MOB_MIN_SPAWN_RANGE = MOB_MAX_SPAWN_RANGE * -1; + if (ENABLE_RANDOM_MONSTER_SPAWNS) + { + final String[] mobsIds = RandomSpawns.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); + MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + for (String id : mobsIds) + { + MOBS_LIST_NOT_RANDOM.add(Integer.valueOf(id)); + } + } + // Load SayuneForAll config file (if exists) final PropertiesParser SayuneForAll = new PropertiesParser(CUSTOM_SAYUNE_FOR_ALL_CONFIG_FILE); diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/L2Spawn.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/L2Spawn.java index 7ea99ed955..7d30f2e834 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/L2Spawn.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/L2Spawn.java @@ -23,9 +23,11 @@ import java.util.concurrent.ConcurrentLinkedDeque; import java.util.logging.Level; import java.util.logging.Logger; +import com.l2jmobius.Config; import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.data.xml.impl.NpcData; +import com.l2jmobius.gameserver.geoengine.GeoEngine; import com.l2jmobius.gameserver.model.actor.L2Npc; import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance; import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate; @@ -35,6 +37,7 @@ import com.l2jmobius.gameserver.model.interfaces.ILocational; import com.l2jmobius.gameserver.model.interfaces.INamable; import com.l2jmobius.gameserver.model.interfaces.IPositionable; import com.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; +import com.l2jmobius.gameserver.model.zone.ZoneId; /** * This class manages the spawn and respawn of a group of L2NpcInstance that are in the same are and have the same type.
@@ -540,6 +543,20 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable newlocz = getZ(); } + // If random spawn system is enabled + if (Config.ENABLE_RANDOM_MONSTER_SPAWNS) + { + final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); + final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); + + final boolean isQuestMonster = (npc.getTitle() != null) && npc.getTitle().contains("Quest"); + if (npc.isMonster() && !isQuestMonster && !npc.isWalker() && !npc.isInsideZone(ZoneId.NO_BOOKMARK) && (getInstanceId() == 0) && GeoEngine.getInstance().canMoveToTarget(newlocx, newlocy, newlocz, randX, randY, newlocz, npc.getInstanceWorld()) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId())) + { + newlocx = randX; + newlocy = randY; + } + } + // DO NOT CORRECT SPAWN Z IN GENERAL - Prevent NPC spawns on top of buildings // don't correct z of flying npc's // if (!npc.isFlying()) diff --git a/L2J_Mobius_3.0_Helios/dist/game/config/Custom/RandomSpawns.ini b/L2J_Mobius_3.0_Helios/dist/game/config/Custom/RandomSpawns.ini new file mode 100644 index 0000000000..0e55b3bb57 --- /dev/null +++ b/L2J_Mobius_3.0_Helios/dist/game/config/Custom/RandomSpawns.ini @@ -0,0 +1,21 @@ +# --------------------------------------------------------------------------- +# Random Spawn System for Monsters +# --------------------------------------------------------------------------- + +# Enable random monster spawns. +# Default: True +EnableRandomMonsterSpawns = True + +# Max range for X and Y coords. +# Default: 150 +MaxSpawnMobRange = 150 + +# Examples: No random spawns for Kasha's Eye, Pagan Guards, Sel Mahums, Four Sepulchers +# MobsSpawnNotRandom = 18812,18813,18814 +MobsSpawnNotRandom = 18812,18813,18814,22138,\ +18908,22775,22776,22777,22778,22779,22780,22781,22782,22783,22784,22785,22786,22787,22788,\ +18120,18132,18133,18137,18141,18145,18150,18151,18152,18153,18154,18155,18156,18157,18166,\ +18170,18171,18183,18184,18185,18186,18187,18191,18195,18196,18197,18198,18199,18212,18220,\ +18221,18222,18226,18230,18231,18232,18233,18234,18235,18236,18237,18238,18239,18240,18241,\ +18242,18243,18256,31452,31468,31469,31470,31471,31472,31473,31474,31475,31476,31477,31478,\ +31479,31480,31481,31482,31483,31484,31485,31486,31487 diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/Config.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/Config.java index a228a1b729..57917084f0 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/Config.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/Config.java @@ -128,6 +128,7 @@ public final class Config public static final String CUSTOM_PVP_ANNOUNCE_CONFIG_FILE = "./config/Custom/PvpAnnounce.ini"; public static final String CUSTOM_PVP_REWARD_ITEM_CONFIG_FILE = "./config/Custom/PvpRewardItem.ini"; public static final String CUSTOM_PVP_TITLE_CONFIG_FILE = "./config/Custom/PvpTitleColor.ini"; + public static final String CUSTOM_RANDOM_SPAWNS_CONFIG_FILE = "./config/Custom/RandomSpawns.ini"; public static final String CUSTOM_SAYUNE_FOR_ALL_CONFIG_FILE = "./config/Custom/SayuneForAll.ini"; public static final String CUSTOM_SCREEN_WELCOME_MESSAGE_CONFIG_FILE = "./config/Custom/ScreenWelcomeMessage.ini"; public static final String CUSTOM_SELL_BUFFS_CONFIG_FILE = "./config/Custom/SellBuffs.ini"; @@ -1134,6 +1135,10 @@ public final class Config public static int CUSTOM_STARTING_LOC_Z; public static int SHOP_MIN_RANGE_FROM_NPC; public static int SHOP_MIN_RANGE_FROM_PLAYER; + public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; + public static int MOB_MIN_SPAWN_RANGE; + public static int MOB_MAX_SPAWN_RANGE; + public static List MOBS_LIST_NOT_RANDOM; public static boolean FREE_JUMPS_FOR_ALL; public static boolean CUSTOM_CB_ENABLED; public static int COMMUNITYBOARD_CURRENCY; @@ -2842,6 +2847,22 @@ public final class Config TITLE_FOR_PVP_AMOUNT4 = PvpTitleColor.getString("PvPTitleForAmount4", "Title"); TITLE_FOR_PVP_AMOUNT5 = PvpTitleColor.getString("PvPTitleForAmount5", "Title"); + // Load RandomSpawns config file (if exists) + final PropertiesParser RandomSpawns = new PropertiesParser(CUSTOM_RANDOM_SPAWNS_CONFIG_FILE); + + ENABLE_RANDOM_MONSTER_SPAWNS = RandomSpawns.getBoolean("EnableRandomMonsterSpawns", false); + MOB_MAX_SPAWN_RANGE = RandomSpawns.getInt("MaxSpawnMobRange", 150); + MOB_MIN_SPAWN_RANGE = MOB_MAX_SPAWN_RANGE * -1; + if (ENABLE_RANDOM_MONSTER_SPAWNS) + { + final String[] mobsIds = RandomSpawns.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); + MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + for (String id : mobsIds) + { + MOBS_LIST_NOT_RANDOM.add(Integer.valueOf(id)); + } + } + // Load SayuneForAll config file (if exists) final PropertiesParser SayuneForAll = new PropertiesParser(CUSTOM_SAYUNE_FOR_ALL_CONFIG_FILE); diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/L2Spawn.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/L2Spawn.java index 7ea99ed955..7d30f2e834 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/L2Spawn.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/L2Spawn.java @@ -23,9 +23,11 @@ import java.util.concurrent.ConcurrentLinkedDeque; import java.util.logging.Level; import java.util.logging.Logger; +import com.l2jmobius.Config; import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.data.xml.impl.NpcData; +import com.l2jmobius.gameserver.geoengine.GeoEngine; import com.l2jmobius.gameserver.model.actor.L2Npc; import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance; import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate; @@ -35,6 +37,7 @@ import com.l2jmobius.gameserver.model.interfaces.ILocational; import com.l2jmobius.gameserver.model.interfaces.INamable; import com.l2jmobius.gameserver.model.interfaces.IPositionable; import com.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; +import com.l2jmobius.gameserver.model.zone.ZoneId; /** * This class manages the spawn and respawn of a group of L2NpcInstance that are in the same are and have the same type.
@@ -540,6 +543,20 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable newlocz = getZ(); } + // If random spawn system is enabled + if (Config.ENABLE_RANDOM_MONSTER_SPAWNS) + { + final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); + final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); + + final boolean isQuestMonster = (npc.getTitle() != null) && npc.getTitle().contains("Quest"); + if (npc.isMonster() && !isQuestMonster && !npc.isWalker() && !npc.isInsideZone(ZoneId.NO_BOOKMARK) && (getInstanceId() == 0) && GeoEngine.getInstance().canMoveToTarget(newlocx, newlocy, newlocz, randX, randY, newlocz, npc.getInstanceWorld()) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId())) + { + newlocx = randX; + newlocy = randY; + } + } + // DO NOT CORRECT SPAWN Z IN GENERAL - Prevent NPC spawns on top of buildings // don't correct z of flying npc's // if (!npc.isFlying()) diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/config/Custom/RandomSpawns.ini b/L2J_Mobius_4.0_GrandCrusade/dist/game/config/Custom/RandomSpawns.ini new file mode 100644 index 0000000000..0e55b3bb57 --- /dev/null +++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/config/Custom/RandomSpawns.ini @@ -0,0 +1,21 @@ +# --------------------------------------------------------------------------- +# Random Spawn System for Monsters +# --------------------------------------------------------------------------- + +# Enable random monster spawns. +# Default: True +EnableRandomMonsterSpawns = True + +# Max range for X and Y coords. +# Default: 150 +MaxSpawnMobRange = 150 + +# Examples: No random spawns for Kasha's Eye, Pagan Guards, Sel Mahums, Four Sepulchers +# MobsSpawnNotRandom = 18812,18813,18814 +MobsSpawnNotRandom = 18812,18813,18814,22138,\ +18908,22775,22776,22777,22778,22779,22780,22781,22782,22783,22784,22785,22786,22787,22788,\ +18120,18132,18133,18137,18141,18145,18150,18151,18152,18153,18154,18155,18156,18157,18166,\ +18170,18171,18183,18184,18185,18186,18187,18191,18195,18196,18197,18198,18199,18212,18220,\ +18221,18222,18226,18230,18231,18232,18233,18234,18235,18236,18237,18238,18239,18240,18241,\ +18242,18243,18256,31452,31468,31469,31470,31471,31472,31473,31474,31475,31476,31477,31478,\ +31479,31480,31481,31482,31483,31484,31485,31486,31487 diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/Config.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/Config.java index dd407347ec..674c870c92 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/Config.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/Config.java @@ -128,6 +128,7 @@ public final class Config public static final String CUSTOM_PVP_ANNOUNCE_CONFIG_FILE = "./config/Custom/PvpAnnounce.ini"; public static final String CUSTOM_PVP_REWARD_ITEM_CONFIG_FILE = "./config/Custom/PvpRewardItem.ini"; public static final String CUSTOM_PVP_TITLE_CONFIG_FILE = "./config/Custom/PvpTitleColor.ini"; + public static final String CUSTOM_RANDOM_SPAWNS_CONFIG_FILE = "./config/Custom/RandomSpawns.ini"; public static final String CUSTOM_SAYUNE_FOR_ALL_CONFIG_FILE = "./config/Custom/SayuneForAll.ini"; public static final String CUSTOM_SCREEN_WELCOME_MESSAGE_CONFIG_FILE = "./config/Custom/ScreenWelcomeMessage.ini"; public static final String CUSTOM_SELL_BUFFS_CONFIG_FILE = "./config/Custom/SellBuffs.ini"; @@ -1133,6 +1134,10 @@ public final class Config public static int CUSTOM_STARTING_LOC_Z; public static int SHOP_MIN_RANGE_FROM_NPC; public static int SHOP_MIN_RANGE_FROM_PLAYER; + public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; + public static int MOB_MIN_SPAWN_RANGE; + public static int MOB_MAX_SPAWN_RANGE; + public static List MOBS_LIST_NOT_RANDOM; public static boolean FREE_JUMPS_FOR_ALL; public static boolean CUSTOM_CB_ENABLED; public static int COMMUNITYBOARD_CURRENCY; @@ -2840,6 +2845,22 @@ public final class Config TITLE_FOR_PVP_AMOUNT4 = PvpTitleColor.getString("PvPTitleForAmount4", "Title"); TITLE_FOR_PVP_AMOUNT5 = PvpTitleColor.getString("PvPTitleForAmount5", "Title"); + // Load RandomSpawns config file (if exists) + final PropertiesParser RandomSpawns = new PropertiesParser(CUSTOM_RANDOM_SPAWNS_CONFIG_FILE); + + ENABLE_RANDOM_MONSTER_SPAWNS = RandomSpawns.getBoolean("EnableRandomMonsterSpawns", false); + MOB_MAX_SPAWN_RANGE = RandomSpawns.getInt("MaxSpawnMobRange", 150); + MOB_MIN_SPAWN_RANGE = MOB_MAX_SPAWN_RANGE * -1; + if (ENABLE_RANDOM_MONSTER_SPAWNS) + { + final String[] mobsIds = RandomSpawns.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); + MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + for (String id : mobsIds) + { + MOBS_LIST_NOT_RANDOM.add(Integer.valueOf(id)); + } + } + // Load SayuneForAll config file (if exists) final PropertiesParser SayuneForAll = new PropertiesParser(CUSTOM_SAYUNE_FOR_ALL_CONFIG_FILE); diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/L2Spawn.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/L2Spawn.java index 7ea99ed955..7d30f2e834 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/L2Spawn.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/L2Spawn.java @@ -23,9 +23,11 @@ import java.util.concurrent.ConcurrentLinkedDeque; import java.util.logging.Level; import java.util.logging.Logger; +import com.l2jmobius.Config; import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.data.xml.impl.NpcData; +import com.l2jmobius.gameserver.geoengine.GeoEngine; import com.l2jmobius.gameserver.model.actor.L2Npc; import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance; import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate; @@ -35,6 +37,7 @@ import com.l2jmobius.gameserver.model.interfaces.ILocational; import com.l2jmobius.gameserver.model.interfaces.INamable; import com.l2jmobius.gameserver.model.interfaces.IPositionable; import com.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; +import com.l2jmobius.gameserver.model.zone.ZoneId; /** * This class manages the spawn and respawn of a group of L2NpcInstance that are in the same are and have the same type.
@@ -540,6 +543,20 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable newlocz = getZ(); } + // If random spawn system is enabled + if (Config.ENABLE_RANDOM_MONSTER_SPAWNS) + { + final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); + final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); + + final boolean isQuestMonster = (npc.getTitle() != null) && npc.getTitle().contains("Quest"); + if (npc.isMonster() && !isQuestMonster && !npc.isWalker() && !npc.isInsideZone(ZoneId.NO_BOOKMARK) && (getInstanceId() == 0) && GeoEngine.getInstance().canMoveToTarget(newlocx, newlocy, newlocz, randX, randY, newlocz, npc.getInstanceWorld()) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId())) + { + newlocx = randX; + newlocy = randY; + } + } + // DO NOT CORRECT SPAWN Z IN GENERAL - Prevent NPC spawns on top of buildings // don't correct z of flying npc's // if (!npc.isFlying()) diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/L2Spawn.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/L2Spawn.java index 32e2afcb82..cb2fa4b15f 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/L2Spawn.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/L2Spawn.java @@ -600,23 +600,23 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable } else { - // The L2NpcInstance is spawned at a random position + // The L2NpcInstance is spawned at the exact position (Lox, Locy, Locz) newlocx = getX(); newlocy = getY(); newlocz = getZ(); + } + + // If random spawn system is enabled + if (Config.ENABLE_RANDOM_MONSTER_SPAWNS) + { + final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); + final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); - // If random spawn system is enabled - if (Config.ENABLE_RANDOM_MONSTER_SPAWNS) + final boolean isQuestMonster = (mob.getTitle() != null) && mob.getTitle().contains("Quest"); + if (mob.isMonster() && !isQuestMonster && !mob.isWalker() && !mob.isInsideZone(ZoneId.NO_BOOKMARK) && (getInstanceId() == 0) && GeoEngine.getInstance().canMoveToTarget(newlocx, newlocy, newlocz, randX, randY, newlocz, getInstanceId()) && !getTemplate().isUndying() && !mob.isRaid() && !mob.isRaidMinion() && !Config.MOBS_LIST_NOT_RANDOM.contains(mob.getId())) { - final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); - final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); - - final boolean isQuestMonster = (mob.getTitle() != null) && mob.getTitle().contains("Quest"); - if (mob.isMonster() && !isQuestMonster && !mob.isWalker() && !mob.isInsideZone(ZoneId.NO_BOOKMARK) && GeoEngine.getInstance().canMoveToTarget(newlocx, newlocy, newlocz, randX, randY, newlocz, getInstanceId()) && (getInstanceId() == 0) && !getTemplate().isUndying() && !mob.isRaid() && !mob.isRaidMinion() && !Config.MOBS_LIST_NOT_RANDOM.contains(mob.getId())) - { - newlocx = randX; - newlocy = randY; - } + newlocx = randX; + newlocy = randY; } } diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/Custom/RandomSpawns.ini b/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/Custom/RandomSpawns.ini new file mode 100644 index 0000000000..0e55b3bb57 --- /dev/null +++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/Custom/RandomSpawns.ini @@ -0,0 +1,21 @@ +# --------------------------------------------------------------------------- +# Random Spawn System for Monsters +# --------------------------------------------------------------------------- + +# Enable random monster spawns. +# Default: True +EnableRandomMonsterSpawns = True + +# Max range for X and Y coords. +# Default: 150 +MaxSpawnMobRange = 150 + +# Examples: No random spawns for Kasha's Eye, Pagan Guards, Sel Mahums, Four Sepulchers +# MobsSpawnNotRandom = 18812,18813,18814 +MobsSpawnNotRandom = 18812,18813,18814,22138,\ +18908,22775,22776,22777,22778,22779,22780,22781,22782,22783,22784,22785,22786,22787,22788,\ +18120,18132,18133,18137,18141,18145,18150,18151,18152,18153,18154,18155,18156,18157,18166,\ +18170,18171,18183,18184,18185,18186,18187,18191,18195,18196,18197,18198,18199,18212,18220,\ +18221,18222,18226,18230,18231,18232,18233,18234,18235,18236,18237,18238,18239,18240,18241,\ +18242,18243,18256,31452,31468,31469,31470,31471,31472,31473,31474,31475,31476,31477,31478,\ +31479,31480,31481,31482,31483,31484,31485,31486,31487 diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/Config.java b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/Config.java index 7bc69b8542..e15091a727 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/Config.java @@ -128,6 +128,7 @@ public final class Config public static final String CUSTOM_PVP_ANNOUNCE_CONFIG_FILE = "./config/Custom/PvpAnnounce.ini"; public static final String CUSTOM_PVP_REWARD_ITEM_CONFIG_FILE = "./config/Custom/PvpRewardItem.ini"; public static final String CUSTOM_PVP_TITLE_CONFIG_FILE = "./config/Custom/PvpTitleColor.ini"; + public static final String CUSTOM_RANDOM_SPAWNS_CONFIG_FILE = "./config/Custom/RandomSpawns.ini"; public static final String CUSTOM_SAYUNE_FOR_ALL_CONFIG_FILE = "./config/Custom/SayuneForAll.ini"; public static final String CUSTOM_SCREEN_WELCOME_MESSAGE_CONFIG_FILE = "./config/Custom/ScreenWelcomeMessage.ini"; public static final String CUSTOM_SELL_BUFFS_CONFIG_FILE = "./config/Custom/SellBuffs.ini"; @@ -1066,6 +1067,10 @@ public final class Config public static int CUSTOM_STARTING_LOC_Z; public static int SHOP_MIN_RANGE_FROM_NPC; public static int SHOP_MIN_RANGE_FROM_PLAYER; + public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; + public static int MOB_MIN_SPAWN_RANGE; + public static int MOB_MAX_SPAWN_RANGE; + public static List MOBS_LIST_NOT_RANDOM; public static boolean FREE_JUMPS_FOR_ALL; public static boolean CUSTOM_CB_ENABLED; public static int COMMUNITYBOARD_CURRENCY; @@ -2714,6 +2719,22 @@ public final class Config TITLE_FOR_PVP_AMOUNT4 = PvpTitleColor.getString("PvPTitleForAmount4", "Title"); TITLE_FOR_PVP_AMOUNT5 = PvpTitleColor.getString("PvPTitleForAmount5", "Title"); + // Load RandomSpawns config file (if exists) + final PropertiesParser RandomSpawns = new PropertiesParser(CUSTOM_RANDOM_SPAWNS_CONFIG_FILE); + + ENABLE_RANDOM_MONSTER_SPAWNS = RandomSpawns.getBoolean("EnableRandomMonsterSpawns", false); + MOB_MAX_SPAWN_RANGE = RandomSpawns.getInt("MaxSpawnMobRange", 150); + MOB_MIN_SPAWN_RANGE = MOB_MAX_SPAWN_RANGE * -1; + if (ENABLE_RANDOM_MONSTER_SPAWNS) + { + final String[] mobsIds = RandomSpawns.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); + MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + for (String id : mobsIds) + { + MOBS_LIST_NOT_RANDOM.add(Integer.valueOf(id)); + } + } + // Load SayuneForAll config file (if exists) final PropertiesParser SayuneForAll = new PropertiesParser(CUSTOM_SAYUNE_FOR_ALL_CONFIG_FILE); diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/L2Spawn.java b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/L2Spawn.java index 7ea99ed955..7d30f2e834 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/L2Spawn.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/L2Spawn.java @@ -23,9 +23,11 @@ import java.util.concurrent.ConcurrentLinkedDeque; import java.util.logging.Level; import java.util.logging.Logger; +import com.l2jmobius.Config; import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.data.xml.impl.NpcData; +import com.l2jmobius.gameserver.geoengine.GeoEngine; import com.l2jmobius.gameserver.model.actor.L2Npc; import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance; import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate; @@ -35,6 +37,7 @@ import com.l2jmobius.gameserver.model.interfaces.ILocational; import com.l2jmobius.gameserver.model.interfaces.INamable; import com.l2jmobius.gameserver.model.interfaces.IPositionable; import com.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; +import com.l2jmobius.gameserver.model.zone.ZoneId; /** * This class manages the spawn and respawn of a group of L2NpcInstance that are in the same are and have the same type.
@@ -540,6 +543,20 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable newlocz = getZ(); } + // If random spawn system is enabled + if (Config.ENABLE_RANDOM_MONSTER_SPAWNS) + { + final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); + final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); + + final boolean isQuestMonster = (npc.getTitle() != null) && npc.getTitle().contains("Quest"); + if (npc.isMonster() && !isQuestMonster && !npc.isWalker() && !npc.isInsideZone(ZoneId.NO_BOOKMARK) && (getInstanceId() == 0) && GeoEngine.getInstance().canMoveToTarget(newlocx, newlocy, newlocz, randX, randY, newlocz, npc.getInstanceWorld()) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId())) + { + newlocx = randX; + newlocy = randY; + } + } + // DO NOT CORRECT SPAWN Z IN GENERAL - Prevent NPC spawns on top of buildings // don't correct z of flying npc's // if (!npc.isFlying()) diff --git a/L2J_Mobius_Classic_2.0_Zaken/dist/game/config/Custom/RandomSpawns.ini b/L2J_Mobius_Classic_2.0_Zaken/dist/game/config/Custom/RandomSpawns.ini new file mode 100644 index 0000000000..0e55b3bb57 --- /dev/null +++ b/L2J_Mobius_Classic_2.0_Zaken/dist/game/config/Custom/RandomSpawns.ini @@ -0,0 +1,21 @@ +# --------------------------------------------------------------------------- +# Random Spawn System for Monsters +# --------------------------------------------------------------------------- + +# Enable random monster spawns. +# Default: True +EnableRandomMonsterSpawns = True + +# Max range for X and Y coords. +# Default: 150 +MaxSpawnMobRange = 150 + +# Examples: No random spawns for Kasha's Eye, Pagan Guards, Sel Mahums, Four Sepulchers +# MobsSpawnNotRandom = 18812,18813,18814 +MobsSpawnNotRandom = 18812,18813,18814,22138,\ +18908,22775,22776,22777,22778,22779,22780,22781,22782,22783,22784,22785,22786,22787,22788,\ +18120,18132,18133,18137,18141,18145,18150,18151,18152,18153,18154,18155,18156,18157,18166,\ +18170,18171,18183,18184,18185,18186,18187,18191,18195,18196,18197,18198,18199,18212,18220,\ +18221,18222,18226,18230,18231,18232,18233,18234,18235,18236,18237,18238,18239,18240,18241,\ +18242,18243,18256,31452,31468,31469,31470,31471,31472,31473,31474,31475,31476,31477,31478,\ +31479,31480,31481,31482,31483,31484,31485,31486,31487 diff --git a/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/Config.java b/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/Config.java index da8bea079f..c5cce612aa 100644 --- a/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/Config.java @@ -128,6 +128,7 @@ public final class Config public static final String CUSTOM_PVP_ANNOUNCE_CONFIG_FILE = "./config/Custom/PvpAnnounce.ini"; public static final String CUSTOM_PVP_REWARD_ITEM_CONFIG_FILE = "./config/Custom/PvpRewardItem.ini"; public static final String CUSTOM_PVP_TITLE_CONFIG_FILE = "./config/Custom/PvpTitleColor.ini"; + public static final String CUSTOM_RANDOM_SPAWNS_CONFIG_FILE = "./config/Custom/RandomSpawns.ini"; public static final String CUSTOM_SAYUNE_FOR_ALL_CONFIG_FILE = "./config/Custom/SayuneForAll.ini"; public static final String CUSTOM_SCREEN_WELCOME_MESSAGE_CONFIG_FILE = "./config/Custom/ScreenWelcomeMessage.ini"; public static final String CUSTOM_SELL_BUFFS_CONFIG_FILE = "./config/Custom/SellBuffs.ini"; @@ -1070,6 +1071,10 @@ public final class Config public static int CUSTOM_STARTING_LOC_Z; public static int SHOP_MIN_RANGE_FROM_NPC; public static int SHOP_MIN_RANGE_FROM_PLAYER; + public static boolean ENABLE_RANDOM_MONSTER_SPAWNS; + public static int MOB_MIN_SPAWN_RANGE; + public static int MOB_MAX_SPAWN_RANGE; + public static List MOBS_LIST_NOT_RANDOM; public static boolean FREE_JUMPS_FOR_ALL; public static boolean CUSTOM_CB_ENABLED; public static int COMMUNITYBOARD_CURRENCY; @@ -2721,6 +2726,22 @@ public final class Config TITLE_FOR_PVP_AMOUNT4 = PvpTitleColor.getString("PvPTitleForAmount4", "Title"); TITLE_FOR_PVP_AMOUNT5 = PvpTitleColor.getString("PvPTitleForAmount5", "Title"); + // Load RandomSpawns config file (if exists) + final PropertiesParser RandomSpawns = new PropertiesParser(CUSTOM_RANDOM_SPAWNS_CONFIG_FILE); + + ENABLE_RANDOM_MONSTER_SPAWNS = RandomSpawns.getBoolean("EnableRandomMonsterSpawns", false); + MOB_MAX_SPAWN_RANGE = RandomSpawns.getInt("MaxSpawnMobRange", 150); + MOB_MIN_SPAWN_RANGE = MOB_MAX_SPAWN_RANGE * -1; + if (ENABLE_RANDOM_MONSTER_SPAWNS) + { + final String[] mobsIds = RandomSpawns.getString("MobsSpawnNotRandom", "18812,18813,18814,22138").split(","); + MOBS_LIST_NOT_RANDOM = new ArrayList<>(mobsIds.length); + for (String id : mobsIds) + { + MOBS_LIST_NOT_RANDOM.add(Integer.valueOf(id)); + } + } + // Load SayuneForAll config file (if exists) final PropertiesParser SayuneForAll = new PropertiesParser(CUSTOM_SAYUNE_FOR_ALL_CONFIG_FILE); diff --git a/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/gameserver/model/L2Spawn.java b/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/gameserver/model/L2Spawn.java index 7ea99ed955..7d30f2e834 100644 --- a/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/gameserver/model/L2Spawn.java +++ b/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/gameserver/model/L2Spawn.java @@ -23,9 +23,11 @@ import java.util.concurrent.ConcurrentLinkedDeque; import java.util.logging.Level; import java.util.logging.Logger; +import com.l2jmobius.Config; import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.data.xml.impl.NpcData; +import com.l2jmobius.gameserver.geoengine.GeoEngine; import com.l2jmobius.gameserver.model.actor.L2Npc; import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance; import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate; @@ -35,6 +37,7 @@ import com.l2jmobius.gameserver.model.interfaces.ILocational; import com.l2jmobius.gameserver.model.interfaces.INamable; import com.l2jmobius.gameserver.model.interfaces.IPositionable; import com.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; +import com.l2jmobius.gameserver.model.zone.ZoneId; /** * This class manages the spawn and respawn of a group of L2NpcInstance that are in the same are and have the same type.
@@ -540,6 +543,20 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable newlocz = getZ(); } + // If random spawn system is enabled + if (Config.ENABLE_RANDOM_MONSTER_SPAWNS) + { + final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); + final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); + + final boolean isQuestMonster = (npc.getTitle() != null) && npc.getTitle().contains("Quest"); + if (npc.isMonster() && !isQuestMonster && !npc.isWalker() && !npc.isInsideZone(ZoneId.NO_BOOKMARK) && (getInstanceId() == 0) && GeoEngine.getInstance().canMoveToTarget(newlocx, newlocy, newlocz, randX, randY, newlocz, npc.getInstanceWorld()) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId())) + { + newlocx = randX; + newlocy = randY; + } + } + // DO NOT CORRECT SPAWN Z IN GENERAL - Prevent NPC spawns on top of buildings // don't correct z of flying npc's // if (!npc.isFlying())