Addition of faction system (Good vs Evil).

This commit is contained in:
MobiusDevelopment
2022-03-19 22:06:45 +00:00
parent b13798903d
commit 2937441611
48 changed files with 1193 additions and 114 deletions

View File

@ -55,6 +55,7 @@ import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.commons.util.PropertiesParser;
import org.l2jmobius.commons.util.StringUtil;
import org.l2jmobius.gameserver.enums.GeoType;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.model.olympiad.OlympiadPeriod;
import org.l2jmobius.gameserver.util.FloodProtectorConfig;
@ -102,6 +103,7 @@ public class Config
public static final String CLASS_DAMAGE_CONFIG_FILE = "./config/custom/ClassDamage.ini";
private static final String CUSTOM_AUTO_POTIONS_CONFIG_FILE = "./config/custom/AutoPotions.ini";
private static final String CUSTOM_CUSTOM_MAIL_MANAGER_CONFIG_FILE = "./config/custom/CustomMailManager.ini";
private static final String CUSTOM_FACTION_SYSTEM_CONFIG_FILE = "./config/Custom/FactionSystem.ini";
private static final String MERCHANT_ZERO_SELL_PRICE_CONFIG_FILE = "./config/custom/MerchantZeroSellPrice.ini";
private static final String CUSTOM_RANDOM_SPAWNS_CONFIG_FILE = "./config/custom/RandomSpawns.ini";
private static final String OFFLINE_CONFIG_FILE = "./config/custom/Offline.ini";
@ -494,6 +496,22 @@ public class Config
public static boolean CUSTOM_MAIL_MANAGER_ENABLED;
public static int CUSTOM_MAIL_MANAGER_DELAY;
public static boolean FACTION_SYSTEM_ENABLED;
public static Location FACTION_STARTING_LOCATION;
public static Location FACTION_MANAGER_LOCATION;
public static Location FACTION_GOOD_BASE_LOCATION;
public static Location FACTION_EVIL_BASE_LOCATION;
public static String FACTION_GOOD_TEAM_NAME;
public static String FACTION_EVIL_TEAM_NAME;
public static int FACTION_GOOD_NAME_COLOR;
public static int FACTION_EVIL_NAME_COLOR;
public static boolean FACTION_GUARDS_ENABLED;
public static boolean FACTION_RESPAWN_AT_BASE;
public static boolean FACTION_AUTO_NOBLESS;
public static boolean FACTION_SPECIFIC_CHAT;
public static boolean FACTION_BALANCE_ONLINE_PLAYERS;
public static int FACTION_BALANCE_PLAYER_EXCEED_LIMIT;
public static boolean MERCHANT_ZERO_SELL_PRICE;
public static boolean ENABLE_RANDOM_MONSTER_SPAWNS;
@ -1684,6 +1702,32 @@ public class Config
CUSTOM_MAIL_MANAGER_DELAY = customMailManagerConfig.getInt("DatabaseQueryDelay", 30) * 1000;
}
public static void loadFactionSystemConfig()
{
// Load FactionSystem config file (if exists)
final PropertiesParser factionSystemConfig = new PropertiesParser(CUSTOM_FACTION_SYSTEM_CONFIG_FILE);
String[] tempString;
FACTION_SYSTEM_ENABLED = factionSystemConfig.getBoolean("EnableFactionSystem", false);
tempString = factionSystemConfig.getString("StartingLocation", "85332,16199,-1252").split(",");
FACTION_STARTING_LOCATION = new Location(Integer.parseInt(tempString[0]), Integer.parseInt(tempString[1]), Integer.parseInt(tempString[2]));
tempString = factionSystemConfig.getString("ManagerSpawnLocation", "85712,15974,-1260,26808").split(",");
FACTION_MANAGER_LOCATION = new Location(Integer.parseInt(tempString[0]), Integer.parseInt(tempString[1]), Integer.parseInt(tempString[2]), tempString[3] != null ? Integer.parseInt(tempString[3]) : 0);
tempString = factionSystemConfig.getString("GoodBaseLocation", "45306,48878,-3058").split(",");
FACTION_GOOD_BASE_LOCATION = new Location(Integer.parseInt(tempString[0]), Integer.parseInt(tempString[1]), Integer.parseInt(tempString[2]));
tempString = factionSystemConfig.getString("EvilBaseLocation", "-44037,-113283,-237").split(",");
FACTION_EVIL_BASE_LOCATION = new Location(Integer.parseInt(tempString[0]), Integer.parseInt(tempString[1]), Integer.parseInt(tempString[2]));
FACTION_GOOD_TEAM_NAME = factionSystemConfig.getString("GoodTeamName", "Good");
FACTION_EVIL_TEAM_NAME = factionSystemConfig.getString("EvilTeamName", "Evil");
FACTION_GOOD_NAME_COLOR = Integer.decode("0x" + factionSystemConfig.getString("GoodNameColor", "00FF00"));
FACTION_EVIL_NAME_COLOR = Integer.decode("0x" + factionSystemConfig.getString("EvilNameColor", "0000FF"));
FACTION_GUARDS_ENABLED = factionSystemConfig.getBoolean("EnableFactionGuards", true);
FACTION_RESPAWN_AT_BASE = factionSystemConfig.getBoolean("RespawnAtFactionBase", true);
FACTION_AUTO_NOBLESS = factionSystemConfig.getBoolean("FactionAutoNobless", false);
FACTION_SPECIFIC_CHAT = factionSystemConfig.getBoolean("EnableFactionChat", true);
FACTION_BALANCE_ONLINE_PLAYERS = factionSystemConfig.getBoolean("BalanceOnlinePlayers", true);
FACTION_BALANCE_PLAYER_EXCEED_LIMIT = factionSystemConfig.getInt("BalancePlayerExceedLimit", 20);
}
public static void loadMerchantZeroPriceConfig()
{
final PropertiesParser merchantZeroSellPriceConfig = new PropertiesParser(MERCHANT_ZERO_SELL_PRICE_CONFIG_FILE);
@ -2941,6 +2985,7 @@ public class Config
loadChampionConfig();
loadAutoPotionsConfig();
loadCustomMailManagerConfig();
loadFactionSystemConfig();
loadMerchantZeroPriceConfig();
loadRandomSpawnsConfig();
loadWeddingConfig();

View File

@ -89,7 +89,7 @@ public class AttackableAI extends CreatureAI
}
/**
* <b><u>Actor is a GuardInstance</u>:</b>
* <b><u>Actor is a Guard</u>:</b>
* <ul>
* <li>The target isn't a Folk or a Door</li>
* <li>The target isn't dead, isn't invulnerable, isn't in silent moving mode AND too far (>100)</li>
@ -233,18 +233,15 @@ public class AttackableAI extends CreatureAI
}
}
// Check if the actor is a GuardInstance
// Check if the actor is a Guard
if (_actor instanceof Guard)
{
// Check if the Player target has karma (=PK)
if ((target instanceof Player) && (((Player) target).getKarma() > 0))
if ((target instanceof Playable) && ((target.getActingPlayer().getKarma() > 0) // Check if the Player target has karma (=PK)
|| (Config.FACTION_SYSTEM_ENABLED && Config.FACTION_GUARDS_ENABLED && ((target.getActingPlayer().isGood() && Config.FACTION_EVIL_TEAM_NAME.equals(((Npc) getActiveChar()).getTemplate().getFactionId())) || (target.getActingPlayer().isEvil() && Config.FACTION_GOOD_TEAM_NAME.equals(((Npc) getActiveChar()).getTemplate().getFactionId()))))))
{
// Los Check
return GeoEngine.getInstance().canSeeTarget(me, target);
}
// if (target instanceof Summon)
// return ((Summon)target).getKarma() > 0;
// Check if the Monster target is aggressive
if (target instanceof Monster)
{
@ -375,7 +372,7 @@ public class AttackableAI extends CreatureAI
* <ul>
* <li>Update every 1s the _globalAggro counter to come close to 0</li>
* <li>If the actor is Aggressive and can attack, add all autoAttackable Creature in its Aggro Range to its _aggroList, chose a target and order to attack it</li>
* <li>If the actor is a GuardInstance that can't attack, order to it to return to its home location</li>
* <li>If the actor is a Guard that can't attack, order to it to return to its home location</li>
* <li>If the actor is a Monster that can't attack, order to it to random walk (1/100)</li>
* </ul>
*/
@ -481,10 +478,10 @@ public class AttackableAI extends CreatureAI
}
}
// Check if the actor is a GuardInstance
// Check if the actor is a Guard
if (_actor instanceof Guard)
{
// Order to the GuardInstance to return to its home location because there's no target to attack
// Order to the Guard to return to its home location because there's no target to attack
((Guard) _actor).returnHome();
}
@ -1073,7 +1070,7 @@ public class AttackableAI extends CreatureAI
* <b><u>Actions</u>:</b>
* <ul>
* <li>Add the target to the actor _aggroList or update hate if already present</li>
* <li>Set the actor Intention to AI_INTENTION_ATTACK (if actor is GuardInstance check if it isn't too far from its home location)</li>
* <li>Set the actor Intention to AI_INTENTION_ATTACK (if actor is Guard check if it isn't too far from its home location)</li>
* </ul>
* @param target the Creature that attacks
* @param aggro The value of hate to add to the actor against the target

View File

@ -24,6 +24,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.l2jmobius.Config;
import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.data.sql.ClanHallTable;
import org.l2jmobius.gameserver.enums.Race;
@ -235,6 +236,18 @@ public class MapRegionData implements IXmlReader
return arena.getSpawnLoc();
}
if (Config.FACTION_SYSTEM_ENABLED && Config.FACTION_RESPAWN_AT_BASE)
{
if (creature.getActingPlayer().isGood())
{
return Config.FACTION_GOOD_BASE_LOCATION;
}
if (creature.getActingPlayer().isEvil())
{
return Config.FACTION_EVIL_BASE_LOCATION;
}
}
// Retrieve a random spawn location of the nearest town.
return getClosestTown(player).getSpawnLoc();
}

View File

@ -143,6 +143,12 @@ public class ScrollOfEscape implements IItemHandler
return;
}
if (Config.FACTION_SYSTEM_ENABLED && !player.isGood() && !player.isEvil())
{
player.sendMessage("You cannot use this item while you are neutral.");
return;
}
// Check if this is a blessed scroll, if it is then shorten the cast time.
final int itemId = item.getItemId();
final SystemMessage sm3 = new SystemMessage(SystemMessageId.USE_S1);

View File

@ -82,6 +82,12 @@ public class Escape implements IUserCommandHandler
return false;
}
if (Config.FACTION_SYSTEM_ENABLED && !player.isGood() && !player.isEvil())
{
player.sendMessage("You cannot use this function while you are neutral.");
return false;
}
// Check player status.
if (player.isCastingNow() || player.isMovementDisabled() || player.isMuted() || player.isAlikeDead() || player.isInOlympiadMode())
{

View File

@ -26,6 +26,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.l2jmobius.Config;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.data.sql.CharNameTable;
import org.l2jmobius.gameserver.model.actor.Player;
@ -128,6 +129,10 @@ public class BlockList
public boolean isInBlockList(Player target)
{
if (Config.FACTION_SYSTEM_ENABLED && Config.FACTION_SPECIFIC_CHAT && ((_owner.isGood() && target.isEvil()) || (_owner.isEvil() && target.isGood())))
{
return true;
}
return _blockList.contains(target.getObjectId());
}

View File

@ -25,6 +25,7 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
import org.l2jmobius.Config;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.actor.instance.Pet;
@ -64,6 +65,10 @@ public class World
/** HashMap(String Player name, Player) containing all the players in game. */
private static Map<String, Player> _allPlayers = new ConcurrentHashMap<>();
/** Map containing all the Good players in game. */
private static final Map<Integer, Player> _allGoodPlayers = new ConcurrentHashMap<>();
/** Map containing all the Evil players in game. */
private static final Map<Integer, Player> _allEvilPlayers = new ConcurrentHashMap<>();
/** WorldObjectHashMap(WorldObject) containing all visible objects. */
private static final Map<Integer, WorldObject> _allObjects = new ConcurrentHashMap<>();
@ -159,6 +164,28 @@ public class World
return _allPlayers.values();
}
public Collection<Player> getAllGoodPlayers()
{
return _allGoodPlayers.values();
}
public Collection<Player> getAllEvilPlayers()
{
return _allEvilPlayers.values();
}
public static void addFactionPlayerToWorld(Player player)
{
if (player.isGood())
{
_allGoodPlayers.put(player.getObjectId(), player);
}
else if (player.isEvil())
{
_allEvilPlayers.put(player.getObjectId(), player);
}
}
/**
* Return how many players are online.
* @return number of online players.
@ -323,9 +350,11 @@ public class World
return;
}
synchronized (_allPlayers)
_allPlayers.put(player.getName().toLowerCase(), player);
if (Config.FACTION_SYSTEM_ENABLED)
{
_allPlayers.put(player.getName().toLowerCase(), player);
addFactionPlayerToWorld(player);
}
}
@ -373,6 +402,18 @@ public class World
if ((player != null) && !player.isTeleporting())
{
_allPlayers.remove(player.getName().toLowerCase());
if (Config.FACTION_SYSTEM_ENABLED)
{
if (player.isGood())
{
_allGoodPlayers.remove(player.getObjectId());
}
else if (player.isEvil())
{
_allEvilPlayers.remove(player.getObjectId());
}
}
}
}

View File

@ -16,6 +16,7 @@
*/
package org.l2jmobius.gameserver.model.actor;
import org.l2jmobius.Config;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.knownlist.PlayableKnownList;
import org.l2jmobius.gameserver.model.actor.stat.PlayableStat;
@ -124,10 +125,12 @@ public abstract class Playable extends Creature
{
return false; // Target is null
}
if (target == this)
{
return false; // Target is self
}
if (!(target instanceof Playable))
{
return false; // Target is not a PlayableInstance
@ -147,6 +150,7 @@ public abstract class Playable extends Creature
{
return false; // Active player is null
}
if (player.getKarma() != 0)
{
return false; // Active player has karma
@ -166,19 +170,27 @@ public abstract class Playable extends Creature
{
return false; // Target player is null
}
if (targetPlayer == this)
{
return false; // Target player is self
}
if (targetPlayer.getKarma() != 0)
{
return false; // Target player has karma
}
if (targetPlayer.getPvpFlag() == 0)
{
return false;
}
if (Config.FACTION_SYSTEM_ENABLED && ((player.isGood() && targetPlayer.isEvil()) || (player.isEvil() && targetPlayer.isGood())))
{
return false;
}
return true;
}

View File

@ -246,8 +246,8 @@ import org.l2jmobius.gameserver.util.Util;
public class Player extends Playable
{
/** SQL queries */
private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,str=?,con=?,dex=?,_int=?,men=?,wit=?,face=?,hairStyle=?,hairColor=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,maxload=?,race=?,classid=?,deletetime=?,title=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,last_recom_date=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,pc_point=?,name_color=?,title_color=?,aio=?,aio_end=? WHERE charId=?";
private static final String RESTORE_CHARACTER = "SELECT account_name, charId, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, acc, crit, evasion, mAtk, mDef, mSpd, pAtk, pDef, pSpd, runSpd, walkSpd, str, con, dex, _int, men, wit, face, hairStyle, hairColor, sex, heading, x, y, z, movement_multiplier, attack_speed_multiplier, colRad, colHeight, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, maxload, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon,punish_level,punish_timer,newbie, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,pc_point,name_color,title_color,first_log,aio,aio_end FROM characters WHERE charId=?";
private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,str=?,con=?,dex=?,_int=?,men=?,wit=?,face=?,hairStyle=?,hairColor=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,maxload=?,race=?,classid=?,deletetime=?,title=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,faction=?,last_recom_date=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,pc_point=?,name_color=?,title_color=?,aio=?,aio_end=? WHERE charId=?";
private static final String RESTORE_CHARACTER = "SELECT account_name, charId, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, acc, crit, evasion, mAtk, mDef, mSpd, pAtk, pDef, pSpd, runSpd, walkSpd, str, con, dex, _int, men, wit, face, hairStyle, hairColor, sex, heading, x, y, z, movement_multiplier, attack_speed_multiplier, colRad, colHeight, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, maxload, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon,punish_level,punish_timer,newbie, nobless, power_grade, subpledge, faction, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,pc_point,name_color,title_color,first_log,aio,aio_end FROM characters WHERE charId=?";
private static final String RESTORE_SKILLS_FOR_CHAR_ALT_SUBCLASS = "SELECT skill_id,skill_level FROM character_skills WHERE char_obj_id=? ORDER BY (skill_level+0)";
private static final String RESTORE_CHAR_SUBCLASSES = "SELECT class_id,exp,sp,level,class_index FROM character_subclasses WHERE char_obj_id=? ORDER BY class_index ASC";
private static final String ADD_CHAR_SUBCLASS = "INSERT INTO character_subclasses (char_obj_id,class_id,exp,sp,level,class_index) VALUES (?,?,?,?,?,?)";
@ -363,6 +363,8 @@ public class Player extends Playable
private boolean _noble = false;
private boolean _hero = false;
private boolean _donator = false;
private boolean _isGood = false;
private boolean _isEvil = false;
private Folk _lastFolkNpc = null;
private int _questNpcObject = 0;
private int _partyFind = 0;
@ -4728,7 +4730,7 @@ public class Player extends Playable
*/
public void updatePvPColor(int pvpKillAmount)
{
if (Config.PVP_COLOR_SYSTEM_ENABLED)
if (Config.PVP_COLOR_SYSTEM_ENABLED && !Config.FACTION_SYSTEM_ENABLED) // Faction system uses title colors.
{
// Check if the character has GM access and if so, let them be.
if (isGM())
@ -5974,7 +5976,18 @@ public class Player extends Playable
}
else if (targetPlayer.getPvpFlag() == 0) // Target player doesn't have karma
{
increasePkKillsAndKarma(targetPlayer.getLevel());
if (Config.FACTION_SYSTEM_ENABLED)
{
if ((_isGood && targetPlayer.isGood()) || (_isEvil && targetPlayer.isEvil()))
{
increasePkKillsAndKarma(targetPlayer.getLevel());
}
}
else
{
increasePkKillsAndKarma(targetPlayer.getLevel());
}
if ((target instanceof Player) && Config.ANNOUNCE_PK_KILL)
{
AnnouncementsTable.getInstance().announceToAll("Player " + getName() + " has assassinated Player " + target.getName());
@ -6348,6 +6361,11 @@ public class Player extends Playable
return;
}
if (Config.FACTION_SYSTEM_ENABLED && target.isPlayer() && ((isGood() && targetPlayer.isEvil()) || (isEvil() && targetPlayer.isGood())))
{
return;
}
if ((!isInsideZone(ZoneId.PVP) || !targetPlayer.isInsideZone(ZoneId.PVP)) && (targetPlayer.getKarma() == 0))
{
if (checkIfPvP(targetPlayer))
@ -7611,6 +7629,17 @@ public class Player extends Playable
player.setOnlineTime(rset.getLong("onlinetime"));
player.setNewbie(rset.getInt("newbie") == 1);
player.setNoble(rset.getInt("nobless") == 1);
final int factionId = rset.getInt("faction");
if (factionId == 1)
{
player.setGood();
}
if (factionId == 2)
{
player.setEvil();
}
player.setClanJoinExpiryTime(rset.getLong("clan_join_expiry_time"));
player.setFirstLog(rset.getInt("first_log"));
player._pcBangPoints = rset.getInt("pc_point");
@ -8170,21 +8199,31 @@ public class Player extends Playable
statement.setInt(45, isNoble() ? 1 : 0);
statement.setLong(46, getPowerGrade());
statement.setInt(47, getPledgeType());
statement.setLong(48, getLastRecomUpdate());
statement.setInt(49, getLvlJoinedAcademy());
statement.setLong(50, getApprentice());
statement.setLong(51, getSponsor());
statement.setInt(52, getAllianceWithVarkaKetra());
statement.setLong(53, getClanJoinExpiryTime());
statement.setLong(54, getClanCreateExpiryTime());
statement.setString(55, getName());
statement.setLong(56, getDeathPenaltyBuffLevel());
statement.setInt(57, getPcBangScore());
statement.setString(58, StringToHex(Integer.toHexString(_originalNameColorOffline).toUpperCase()));
statement.setString(59, StringToHex(Integer.toHexString(getAppearance().getTitleColor()).toUpperCase()));
statement.setInt(60, isAio() ? 1 : 0);
statement.setLong(61, getAioEndTime());
statement.setInt(62, getObjectId());
int factionId = 0;
if (_isGood)
{
factionId = 1;
}
if (_isEvil)
{
factionId = 2;
}
statement.setInt(48, factionId);
statement.setLong(49, getLastRecomUpdate());
statement.setInt(50, getLvlJoinedAcademy());
statement.setLong(51, getApprentice());
statement.setLong(52, getSponsor());
statement.setInt(53, getAllianceWithVarkaKetra());
statement.setLong(54, getClanJoinExpiryTime());
statement.setLong(55, getClanCreateExpiryTime());
statement.setString(56, getName());
statement.setLong(57, getDeathPenaltyBuffLevel());
statement.setInt(58, getPcBangScore());
statement.setString(59, StringToHex(Integer.toHexString(_originalNameColorOffline).toUpperCase()));
statement.setString(60, StringToHex(Integer.toHexString(getAppearance().getTitleColor()).toUpperCase()));
statement.setInt(61, isAio() ? 1 : 0);
statement.setLong(62, getAioEndTime());
statement.setInt(63, getObjectId());
statement.execute();
statement.close();
}
@ -9174,6 +9213,7 @@ public class Player extends Playable
{
return true;
}
// Check if the Player is in an arena or a siege area
if (isInsideZone(ZoneId.PVP) && ((Player) attacker).isInsideZone(ZoneId.PVP))
{
@ -9219,6 +9259,15 @@ public class Player extends Playable
return true;
}
}
if (Config.FACTION_SYSTEM_ENABLED)
{
final Player player = attacker.getActingPlayer();
if ((player != null) && ((isGood() && player.isEvil()) || (isEvil() && player.isGood())))
{
return true;
}
}
}
else if (attacker instanceof SiegeGuard)
{
@ -9236,6 +9285,13 @@ public class Player extends Playable
return (fortsiege != null) && fortsiege.checkIsAttacker(getClan());
}
}
else if (attacker instanceof Guard)
{
if (Config.FACTION_SYSTEM_ENABLED && Config.FACTION_GUARDS_ENABLED && ((_isGood && Config.FACTION_EVIL_TEAM_NAME.equals(((Npc) attacker).getTemplate().getFactionId())) || (_isEvil && Config.FACTION_GOOD_TEAM_NAME.equals(((Npc) attacker).getTemplate().getFactionId()))))
{
return true;
}
}
return false;
}
@ -9816,12 +9872,15 @@ public class Player extends Playable
if (!checkPvpSkill(target, skill) && !getAccessLevel().allowPeaceAttack() //
&& ((skill.getId() != 3260 /* Forgiveness */) && (skill.getId() != 3261 /* Heart Shot */) && (skill.getId() != 3262 /* Double Heart Shot */)))
{
// Send a System Message to the Player
sendPacket(SystemMessageId.THAT_IS_THE_INCORRECT_TARGET);
// Send a Server->Client packet ActionFailed to the Player
sendPacket(ActionFailed.STATIC_PACKET);
return;
if (!Config.FACTION_SYSTEM_ENABLED || ((!_isGood || !target.getActingPlayer().isEvil()) && (!_isEvil || !target.getActingPlayer().isGood())))
{
// Send a System Message to the Player
sendPacket(SystemMessageId.THAT_IS_THE_INCORRECT_TARGET);
// Send a Server->Client packet ActionFailed to the Player
sendPacket(ActionFailed.STATIC_PACKET);
return;
}
}
}
}
@ -11001,6 +11060,28 @@ public class Player extends Playable
return _donator;
}
public boolean isGood()
{
return _isGood;
}
public boolean isEvil()
{
return _isEvil;
}
public void setGood()
{
_isGood = true;
_isEvil = false;
}
public void setEvil()
{
_isGood = false;
_isEvil = true;
}
/**
* Sets the checks if is in olympiad mode.
* @param value the new checks if is in olympiad mode
@ -15499,12 +15580,6 @@ public class Player extends Playable
}
}
@Override
public Player getActingPlayer()
{
return this;
}
public void checkItemRestriction()
{
for (int i = 0; i < Inventory.PAPERDOLL_TOTALSLOTS; i++)
@ -15670,6 +15745,12 @@ public class Player extends Playable
_currentPetSkill = new SkillUseHolder(currentSkill, ctrlPressed, shiftPressed);
}
@Override
public Player getActingPlayer()
{
return this;
}
@Override
public boolean isPlayer()
{

View File

@ -217,8 +217,7 @@ public class Guard extends Attackable
// Set the Player Intention to AI_INTENTION_ATTACK
player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, this);
}
else // Calculate the distance between the Player and the Npc
if (!canInteract(player))
else if (!canInteract(player)) // Calculate the distance between the Player and the Npc
{
// Set the Player Intention to AI_INTENTION_INTERACT
player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);

View File

@ -21,6 +21,8 @@ import org.l2jmobius.gameserver.ai.CreatureAI;
import org.l2jmobius.gameserver.ai.CtrlIntention;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Playable;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.actor.instance.Guard;
import org.l2jmobius.gameserver.model.actor.instance.Monster;
@ -50,19 +52,21 @@ public class GuardKnownList extends AttackableKnownList
return false;
}
// Set home location of the GuardInstance (if not already done)
// Set home location of the Guard (if not already done)
if (getActiveChar().getHomeX() == 0)
{
getActiveChar().getHomeLocation();
}
if (object instanceof Player)
if (object instanceof Playable)
{
// Check if the object added is a Player that owns Karma
final Player player = (Player) object;
// Check if the object added is a Player that owns Karma.
final Player player = object.getActingPlayer();
// Set the GuardInstance Intention to AI_INTENTION_ACTIVE
if ((player.getKarma() > 0) && (getActiveChar().getAI().getIntention() == CtrlIntention.AI_INTENTION_IDLE))
// Set the Guard Intention to AI_INTENTION_ACTIVE
if (((player.getKarma() > 0) //
|| (Config.FACTION_SYSTEM_ENABLED && Config.FACTION_GUARDS_ENABLED && ((player.isGood() && Config.FACTION_EVIL_TEAM_NAME.equals(((Npc) getActiveChar()).getTemplate().getFactionId())) || (player.isEvil() && Config.FACTION_GOOD_TEAM_NAME.equals(((Npc) getActiveChar()).getTemplate().getFactionId()))))) //
&& (getActiveChar().getAI().getIntention() == CtrlIntention.AI_INTENTION_IDLE))
{
getActiveChar().getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE, null);
}
@ -72,7 +76,7 @@ public class GuardKnownList extends AttackableKnownList
// Check if the object added is an aggressive Monster
final Monster mob = (Monster) object;
// Set the GuardInstance Intention to AI_INTENTION_ACTIVE
// Set the Guard Intention to AI_INTENTION_ACTIVE
if (mob.isAggressive() && (getActiveChar().getAI().getIntention() == CtrlIntention.AI_INTENTION_IDLE))
{
getActiveChar().getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE, null);
@ -90,10 +94,10 @@ public class GuardKnownList extends AttackableKnownList
return false;
}
// Check if the _aggroList of the GuardInstance is Empty
// Check if the _aggroList of the Guard is Empty
if (getActiveChar().noTarget())
{
// Set the GuardInstance to AI_INTENTION_IDLE
// Set the Guard to AI_INTENTION_IDLE
final CreatureAI ai = getActiveChar().getAI();
if (ai != null)
{

View File

@ -1797,6 +1797,20 @@ public class Clan
return false;
}
if (Config.FACTION_SYSTEM_ENABLED)
{
if (player.isGood() && target.isEvil())
{
player.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET));
return false;
}
if (player.isEvil() && target.isGood())
{
player.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET));
return false;
}
}
if (_charPenaltyExpiryTime > Chronos.currentTimeMillis())
{
final SystemMessage sm = new SystemMessage(SystemMessageId.AFTER_A_CLAN_MEMBER_IS_DISMISSED_FROM_A_CLAN_THE_CLAN_MUST_WAIT_AT_LEAST_A_DAY_BEFORE_ACCEPTING_A_NEW_MEMBER);
@ -1886,6 +1900,20 @@ public class Clan
return false;
}
if (Config.FACTION_SYSTEM_ENABLED)
{
if (player.isGood() && target.isEvil())
{
player.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET));
return false;
}
if (player.isEvil() && target.isGood())
{
player.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET));
return false;
}
}
if (target.getClan() == null)
{
player.sendPacket(SystemMessageId.THE_TARGET_MUST_BE_A_CLAN_MEMBER);

View File

@ -231,6 +231,10 @@ public class CharacterCreate implements IClientIncomingPacket
{
newChar.setXYZInvisible(Config.SPAWN_X, Config.SPAWN_Y, Config.SPAWN_Z);
}
else if (Config.FACTION_SYSTEM_ENABLED)
{
newChar.setXYZInvisible(Config.FACTION_STARTING_LOCATION.getX(), Config.FACTION_STARTING_LOCATION.getY(), Config.FACTION_STARTING_LOCATION.getZ());
}
else
{
newChar.setXYZInvisible(template.getSpawnX(), template.getSpawnY(), template.getSpawnZ());

View File

@ -16,13 +16,16 @@
*/
package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.network.ConnectionState;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.PacketLogger;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import org.l2jmobius.gameserver.network.serverpackets.CharSelected;
import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
@SuppressWarnings("unused")
public class CharacterSelected implements IClientIncomingPacket
@ -79,6 +82,28 @@ public class CharacterSelected implements IClientIncomingPacket
return;
}
if (Config.FACTION_SYSTEM_ENABLED && Config.FACTION_BALANCE_ONLINE_PLAYERS)
{
if (cha.isGood() && (World.getInstance().getAllGoodPlayers().size() >= (World.getInstance().getAllEvilPlayers().size() + Config.FACTION_BALANCE_PLAYER_EXCEED_LIMIT)))
{
final NpcHtmlMessage msg = new NpcHtmlMessage(0);
msg.setFile("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 (cha.isEvil() && (World.getInstance().getAllEvilPlayers().size() >= (World.getInstance().getAllGoodPlayers().size() + Config.FACTION_BALANCE_PLAYER_EXCEED_LIMIT)))
{
final NpcHtmlMessage msg = new NpcHtmlMessage(0);
msg.setFile("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;
}
}
cha.setClient(client);
client.setPlayer(cha);
client.setConnectionState(ConnectionState.ENTERING);

View File

@ -284,6 +284,27 @@ public class EnterWorld implements IClientIncomingPacket
player.sendPacket(new CreatureSay(0, ChatType.WHISPER, "[SERVER]", "Next restart is scheduled at " + ServerRestartManager.getInstance().getNextRestartTime() + "."));
}
// Faction System
if (Config.FACTION_SYSTEM_ENABLED)
{
if (player.isGood())
{
player.getAppearance().setNameColor(Config.FACTION_GOOD_NAME_COLOR);
player.getAppearance().setTitleColor(Config.FACTION_GOOD_NAME_COLOR);
player.sendMessage("Welcome " + player.getName() + ", you are fighting for the " + Config.FACTION_GOOD_TEAM_NAME + " faction.");
player.sendPacket(new ExShowScreenMessage("Welcome " + player.getName() + ", you are fighting for the " + Config.FACTION_GOOD_TEAM_NAME + " faction.", 10000));
player.broadcastUserInfo(); // for seeing self name color
}
else if (player.isEvil())
{
player.getAppearance().setNameColor(Config.FACTION_EVIL_NAME_COLOR);
player.getAppearance().setTitleColor(Config.FACTION_EVIL_NAME_COLOR);
player.sendMessage("Welcome " + player.getName() + ", you are fighting for the " + Config.FACTION_EVIL_TEAM_NAME + " faction.");
player.sendPacket(new ExShowScreenMessage("Welcome " + player.getName() + ", you are fighting for the " + Config.FACTION_EVIL_TEAM_NAME + " faction.", 10000));
player.broadcastUserInfo(); // for seeing self name color
}
}
loadTutorial(player);
// Check for crowns