Faction balance online players.
This commit is contained in:
parent
37b9e72fe2
commit
01bb57d197
10
trunk/dist/game/config/Custom.properties
vendored
10
trunk/dist/game/config/Custom.properties
vendored
@ -667,10 +667,18 @@ EnableFactionGuards = True
|
||||
# Default: True
|
||||
RespawnAtFactionBase = True
|
||||
|
||||
# Disable chat between factions.
|
||||
# Disallow chat between factions.
|
||||
# Default: True
|
||||
EnableFactionChat = True
|
||||
|
||||
# Prohibit login when faction has more online players.
|
||||
# Default: True
|
||||
BalanceOnlinePlayers = True
|
||||
|
||||
# Online player exceed limit (used by setting above).
|
||||
# Default: 20
|
||||
BalancePlayerExceedLimit = 20
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Premium System (VIP)
|
||||
|
3
trunk/dist/game/data/html/mods/Faction/ExceededOnlineLimit.htm
vendored
Normal file
3
trunk/dist/game/data/html/mods/Faction/ExceededOnlineLimit.htm
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
<html><title>Restriction</title></head><body>It seems that there are currently more %more% than %less% players online.<br>
|
||||
Try selecting an opposing faction character or wait for some %more% players to logout.
|
||||
</body></html>
|
@ -63,6 +63,17 @@ public class FactionManager extends AbstractNpcAI
|
||||
{
|
||||
case "selectGoodFaction":
|
||||
{
|
||||
if (Config.FACTION_BALANCE_ONLINE_PLAYERS && (L2World.getInstance().getAllGoodPlayersCount() >= ((L2World.getInstance().getAllEvilPlayersCount() + Config.FACTION_BALANCE_PLAYER_EXCEED_LIMIT))))
|
||||
{
|
||||
String htmltext = null;
|
||||
final NpcHtmlMessage packet = new NpcHtmlMessage(npc.getObjectId());
|
||||
packet.setHtml(getHtm(player.getHtmlPrefix(), "onlinelimit.html"));
|
||||
packet.replace("%name%", player.getName());
|
||||
packet.replace("%more%", Config.FACTION_GOOD_TEAM_NAME);
|
||||
packet.replace("%less%", Config.FACTION_EVIL_TEAM_NAME);
|
||||
player.sendPacket(packet);
|
||||
return htmltext;
|
||||
}
|
||||
player.setGood();
|
||||
player.getAppearance().setNameColor(Config.FACTION_GOOD_NAME_COLOR);
|
||||
player.getAppearance().setTitleColor(Config.FACTION_GOOD_NAME_COLOR);
|
||||
@ -75,6 +86,17 @@ public class FactionManager extends AbstractNpcAI
|
||||
}
|
||||
case "selectEvilFaction":
|
||||
{
|
||||
if (Config.FACTION_BALANCE_ONLINE_PLAYERS && (L2World.getInstance().getAllEvilPlayersCount() >= ((L2World.getInstance().getAllGoodPlayersCount() + Config.FACTION_BALANCE_PLAYER_EXCEED_LIMIT))))
|
||||
{
|
||||
String htmltext = null;
|
||||
final NpcHtmlMessage packet = new NpcHtmlMessage(npc.getObjectId());
|
||||
packet.setHtml(getHtm(player.getHtmlPrefix(), "onlinelimit.html"));
|
||||
packet.replace("%name%", player.getName());
|
||||
packet.replace("%more%", Config.FACTION_EVIL_TEAM_NAME);
|
||||
packet.replace("%less%", Config.FACTION_GOOD_TEAM_NAME);
|
||||
player.sendPacket(packet);
|
||||
return htmltext;
|
||||
}
|
||||
player.setEvil();
|
||||
player.getAppearance().setNameColor(Config.FACTION_EVIL_NAME_COLOR);
|
||||
player.getAppearance().setTitleColor(Config.FACTION_EVIL_NAME_COLOR);
|
||||
|
5
trunk/dist/game/data/scripts/custom/FactionManager/onlinelimit.html
vendored
Normal file
5
trunk/dist/game/data/scripts/custom/FactionManager/onlinelimit.html
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
<html><body>Faction Manager:<br>
|
||||
I am sorry %name%.<br1>
|
||||
It seems that there are currently more %more% than %less% players online.<br>
|
||||
Try selecting the opposing faction or wait for some %more% players to logout.
|
||||
</body></html>
|
@ -834,6 +834,8 @@ public final class Config
|
||||
public static boolean FACTION_GUARDS_ENABLED;
|
||||
public static boolean FACTION_RESPAWN_AT_BASE;
|
||||
public static boolean FACTION_SPECIFIC_CHAT;
|
||||
public static boolean FACTION_BALANCE_ONLINE_PLAYERS;
|
||||
public static int FACTION_BALANCE_PLAYER_EXCEED_LIMIT;
|
||||
public static boolean PREMIUM_SYSTEM_ENABLED;
|
||||
public static float PREMIUM_RATE_XP;
|
||||
public static float PREMIUM_RATE_SP;
|
||||
@ -2655,7 +2657,9 @@ public final class Config
|
||||
FACTION_EVIL_NAME_COLOR = Integer.decode("0x" + CustomSettings.getString("EvilNameColor", "0000FF"));
|
||||
FACTION_GUARDS_ENABLED = CustomSettings.getBoolean("EnableFactionGuards", true);
|
||||
FACTION_RESPAWN_AT_BASE = CustomSettings.getBoolean("RespawnAtFactionBase", true);
|
||||
FACTION_SPECIFIC_CHAT = Boolean.valueOf(CustomSettings.getBoolean("EnableFactionChat", true));
|
||||
FACTION_SPECIFIC_CHAT = CustomSettings.getBoolean("EnableFactionChat", true);
|
||||
FACTION_BALANCE_ONLINE_PLAYERS = CustomSettings.getBoolean("BalanceOnlinePlayers", true);
|
||||
FACTION_BALANCE_PLAYER_EXCEED_LIMIT = CustomSettings.getInt("BalancePlayerExceedLimit", 20);
|
||||
|
||||
PREMIUM_SYSTEM_ENABLED = CustomSettings.getBoolean("EnablePremiumSystem", false);
|
||||
PREMIUM_RATE_XP = CustomSettings.getFloat("PremiumRateXp", 2);
|
||||
|
@ -59,6 +59,8 @@ public class CharSelectInfoPackage
|
||||
private String _htmlPrefix = null;
|
||||
private int _vitalityPoints = 0;
|
||||
private int _accessLevel = 0;
|
||||
private boolean _isGood = false;
|
||||
private boolean _isEvil = false;
|
||||
private final PlayerVariables _vars;
|
||||
|
||||
/**
|
||||
@ -103,6 +105,28 @@ public class CharSelectInfoPackage
|
||||
_accessLevel = level;
|
||||
}
|
||||
|
||||
public boolean isGood()
|
||||
{
|
||||
return _isGood;
|
||||
}
|
||||
|
||||
public void setGood()
|
||||
{
|
||||
_isGood = true;
|
||||
_isEvil = false;
|
||||
}
|
||||
|
||||
public boolean isEvil()
|
||||
{
|
||||
return _isEvil;
|
||||
}
|
||||
|
||||
public void setEvil()
|
||||
{
|
||||
_isGood = false;
|
||||
_isEvil = true;
|
||||
}
|
||||
|
||||
public int getClanId()
|
||||
{
|
||||
return _clanId;
|
||||
|
@ -28,6 +28,7 @@ import com.l2jserver.gameserver.datatables.SecondaryAuthData;
|
||||
import com.l2jserver.gameserver.instancemanager.AntiFeedManager;
|
||||
import com.l2jserver.gameserver.instancemanager.PunishmentManager;
|
||||
import com.l2jserver.gameserver.model.CharSelectInfoPackage;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.events.Containers;
|
||||
import com.l2jserver.gameserver.model.events.EventDispatcher;
|
||||
@ -126,6 +127,28 @@ public class CharacterSelect extends L2GameClientPacket
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.FACTION_SYSTEM_ENABLED && Config.FACTION_BALANCE_ONLINE_PLAYERS)
|
||||
{
|
||||
if (info.isGood() && (L2World.getInstance().getAllGoodPlayersCount() >= ((L2World.getInstance().getAllEvilPlayersCount() + Config.FACTION_BALANCE_PLAYER_EXCEED_LIMIT))))
|
||||
{
|
||||
final NpcHtmlMessage msg = new NpcHtmlMessage();
|
||||
msg.setFile(info.getHtmlPrefix(), "data/html/mods/Faction/ExceededOnlineLimit.htm");
|
||||
msg.replace("%more%", Config.FACTION_GOOD_TEAM_NAME);
|
||||
msg.replace("%less%", Config.FACTION_EVIL_TEAM_NAME);
|
||||
client.sendPacket(msg);
|
||||
return;
|
||||
}
|
||||
if (info.isEvil() && (L2World.getInstance().getAllEvilPlayersCount() >= ((L2World.getInstance().getAllGoodPlayersCount() + Config.FACTION_BALANCE_PLAYER_EXCEED_LIMIT))))
|
||||
{
|
||||
final NpcHtmlMessage msg = new NpcHtmlMessage();
|
||||
msg.setFile(info.getHtmlPrefix(), "data/html/mods/Faction/ExceededOnlineLimit.htm");
|
||||
msg.replace("%more%", Config.FACTION_EVIL_TEAM_NAME);
|
||||
msg.replace("%less%", Config.FACTION_GOOD_TEAM_NAME);
|
||||
client.sendPacket(msg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// The L2PcInstance must be created here, so that it can be attached to the L2GameClient
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
|
@ -132,6 +132,11 @@ public abstract class AbstractHtmlPacket extends L2GameServerPacket
|
||||
public final void runImpl()
|
||||
{
|
||||
L2PcInstance player = getClient().getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
player.clearHtmlActions(getScope());
|
||||
|
||||
if (_disabledValidation)
|
||||
|
@ -307,6 +307,16 @@ public class CharSelectionInfo extends L2GameServerPacket
|
||||
charInfopackage.setY(chardata.getInt("y"));
|
||||
charInfopackage.setZ(chardata.getInt("z"));
|
||||
|
||||
final int faction = chardata.getInt("faction");
|
||||
if (faction == 1)
|
||||
{
|
||||
charInfopackage.setGood();
|
||||
}
|
||||
if (faction == 2)
|
||||
{
|
||||
charInfopackage.setEvil();
|
||||
}
|
||||
|
||||
if (Config.L2JMOD_MULTILANG_ENABLE)
|
||||
{
|
||||
String lang = chardata.getString("language");
|
||||
|
Loading…
Reference in New Issue
Block a user