Adapted random spawn system to newer branches.

This commit is contained in:
MobiusDev 2018-03-23 14:37:35 +00:00
parent 92d615ac17
commit 5b36c274cd
19 changed files with 366 additions and 12 deletions

View File

@ -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

View File

@ -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<Integer> 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);

View File

@ -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.<br>
@ -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())

View File

@ -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

View File

@ -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<Integer> 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);

View File

@ -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.<br>
@ -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())

View File

@ -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

View File

@ -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<Integer> 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);

View File

@ -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.<br>
@ -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())

View File

@ -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

View File

@ -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<Integer> 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);

View File

@ -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.<br>
@ -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())

View File

@ -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;
}
}

View File

@ -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

View File

@ -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<Integer> 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);

View File

@ -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.<br>
@ -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())

View File

@ -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

View File

@ -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<Integer> 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);

View File

@ -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.<br>
@ -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())