Faction system.

This commit is contained in:
mobius 2015-01-12 19:00:41 +00:00
parent 4c2db62a63
commit aee828896f
22 changed files with 483 additions and 10 deletions

View File

@ -599,3 +599,48 @@ CommunityTeleportPrice = 0
# Price for Buffs
# Default: 0 (free)
CommunityBuffPrice = 0
# ---------------------------------------------------------------------------
# Faction System (Good vs Evil)
# ---------------------------------------------------------------------------
# Enable faction system
# Default: False
EnableFactionSystem = False
# Starting location for all players
# Default: 85332,16199,-1252
StartingLocation = 85332,16199,-1252
# Faction manager npc id
# Default: 109
FactionManagerNpcId = 109
# Spawn location for faction manager npc
# Default: 140221,-124559,-1904,25821
ManagerSpawnLocation = 85712,15974,-1260,26808
# Good base location
# Default: 45306,48878,-3058
GoodBaseLocation = 45306,48878,-3058
# Evil base location
# Default: -44037,-113283,-237
EvilBaseLocation = -44037,-113283,-237
# Good team name
# Default: Good
GoodTeamName = Good
# Evil team name
# Default: Evil
EvilTeamName = Evil
# Good name color
# Default: 00FF00
GoodNameColor = 00FF00
# Evil name color
# Default: 0000FF
EvilNameColor = 0000FF

View File

@ -221,6 +221,7 @@ custom/NewbieCoupons/NewbieCoupons.java
custom/RaidbossInfo/RaidbossInfo.java
custom/NpcLocationInfo/NpcLocationInfo.java
custom/Validators/SubClassSkills.java
custom/FactionManager/FactionManager.java
# Custom Events
custom/events/Elpies/Elpies.java

View File

@ -0,0 +1,142 @@
/*
* Copyright (C) 2004-2015 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J Server is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package custom.FactionManager;
import ai.npc.AbstractNpcAI;
import com.l2jserver.Config;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.clientpackets.Say2;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
/**
* @author Mobius
*/
public class FactionManager extends AbstractNpcAI
{
// NPC
private static final int MANAGER = Config.FACTION_MANAGER_NPCID;
// Other
private static final String[] TEXTS =
{
Config.FACTION_GOOD_TEAM_NAME + " or " + Config.FACTION_EVIL_TEAM_NAME + "?",
"Select your faction!",
"The choice is yours!"
};
private FactionManager()
{
super(FactionManager.class.getSimpleName(), "custom");
addSpawnId(MANAGER);
addStartNpc(MANAGER);
addTalkId(MANAGER);
addFirstTalkId(MANAGER);
if (Config.FACTION_SYSTEM_ENABLED)
{
addSpawn(MANAGER, Config.FACTION_MANAGER_LOCATION, false, 0);
}
}
@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
switch (event)
{
case "selectGoodFaction":
{
player.setGood();
player.getAppearance().setNameColor(Config.FACTION_GOOD_NAME_COLOR);
player.getAppearance().setTitleColor(Config.FACTION_GOOD_NAME_COLOR);
player.setTitle(Config.FACTION_GOOD_TEAM_NAME);
player.sendMessage("You are now fighting for the " + Config.FACTION_GOOD_TEAM_NAME + " faction.");
player.teleToLocation(Config.FACTION_GOOD_BASE_LOCATION);
broadcastMessageToFaction(Config.FACTION_GOOD_TEAM_NAME, Config.FACTION_GOOD_TEAM_NAME + " faction grows stronger with the arrival of " + player.getName() + ".");
L2World.addFactionPlayerToWorld(player);
break;
}
case "selectEvilFaction":
{
player.setEvil();
player.getAppearance().setNameColor(Config.FACTION_EVIL_NAME_COLOR);
player.getAppearance().setTitleColor(Config.FACTION_EVIL_NAME_COLOR);
player.setTitle(Config.FACTION_EVIL_TEAM_NAME);
player.sendMessage("You are now fighting for the " + Config.FACTION_EVIL_TEAM_NAME + " faction.");
player.teleToLocation(Config.FACTION_EVIL_BASE_LOCATION);
broadcastMessageToFaction(Config.FACTION_EVIL_TEAM_NAME, Config.FACTION_EVIL_TEAM_NAME + " faction grows stronger with the arrival of " + player.getName() + ".");
L2World.addFactionPlayerToWorld(player);
break;
}
case "SPEAK":
{
if (npc != null)
{
broadcastNpcSay(npc, Say2.NPC_ALL, TEXTS[getRandom(TEXTS.length)]);
}
break;
}
}
return super.onAdvEvent(event, npc, player);
}
@Override
public String onFirstTalk(L2Npc npc, L2PcInstance player)
{
String htmltext = null;
final NpcHtmlMessage packet = new NpcHtmlMessage(npc.getObjectId());
packet.setHtml(getHtm(player.getHtmlPrefix(), "manager.html"));
packet.replace("%name%", player.getName());
packet.replace("%good%", Config.FACTION_GOOD_TEAM_NAME);
packet.replace("%evil%", Config.FACTION_EVIL_TEAM_NAME);
player.sendPacket(packet);
return htmltext;
}
@Override
public String onSpawn(L2Npc npc)
{
startQuestTimer("SPEAK", 10000, npc, null, true);
return super.onSpawn(npc);
}
private void broadcastMessageToFaction(String factionName, String message)
{
if (factionName == Config.FACTION_GOOD_TEAM_NAME)
{
for (L2PcInstance player : L2World.getInstance().getAllGoodPlayers())
{
player.sendMessage(message);
}
}
else
{
for (L2PcInstance player : L2World.getInstance().getAllEvilPlayers())
{
player.sendMessage(message);
}
}
}
public static void main(String[] args)
{
new FactionManager();
}
}

View File

@ -0,0 +1,6 @@
<html><body>Faction Manager:<br>
What will your destiny be %name%?<br1>
Will you choose to be %good%? ...or maybe %evil%?<br>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest FactionManager selectGoodFaction">"I choose %good%!"</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest FactionManager selectEvilFaction">"I choose %evil%!"</Button>
</body></html>

View File

@ -60,4 +60,7 @@ CREATE TABLE IF NOT EXISTS `characters` (
KEY `char_name` (`char_name`),
KEY `clanid` (`clanid`),
KEY `online` (`online`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- Faction System
ALTER TABLE `characters` ADD `faction` TINYINT UNSIGNED NOT NULL DEFAULT 0;

View File

@ -61,6 +61,7 @@ import org.w3c.dom.Node;
import com.l2jserver.gameserver.engines.DocumentParser;
import com.l2jserver.gameserver.enums.IllegalActionPunishmentType;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.Location;
import com.l2jserver.gameserver.model.holders.ItemHolder;
import com.l2jserver.gameserver.model.itemcontainer.Inventory;
import com.l2jserver.gameserver.util.FloodProtectorConfig;
@ -817,6 +818,16 @@ public final class Config
public static int COMMUNITYBOARD_CURRENCY;
public static int COMMUNITYBOARD_TELEPORT_PRICE;
public static int COMMUNITYBOARD_BUFF_PRICE;
public static boolean FACTION_SYSTEM_ENABLED;
public static Location FACTION_STARTING_LOCATION;
public static int FACTION_MANAGER_NPCID;
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;
// --------------------------------------------------
// NPC Settings
@ -2608,6 +2619,22 @@ public final class Config
COMMUNITYBOARD_TELEPORT_PRICE = CustomSettings.getInt("CommunityTeleportPrice", 0);
COMMUNITYBOARD_BUFF_PRICE = CustomSettings.getInt("CommunityBuffPrice", 0);
String[] tempString;
FACTION_SYSTEM_ENABLED = Boolean.valueOf(CustomSettings.getBoolean("EnableFactionSystem", false));
tempString = CustomSettings.getString("StartingLocation", "85332,16199,-1252").split(",");
FACTION_STARTING_LOCATION = new Location(Integer.parseInt(tempString[0]), Integer.parseInt(tempString[1]), Integer.parseInt(tempString[2]));
FACTION_MANAGER_NPCID = CustomSettings.getInt("FactionManagerNpcId", 109);
tempString = CustomSettings.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 = CustomSettings.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 = CustomSettings.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 = CustomSettings.getString("GoodTeamName", "Good");
FACTION_EVIL_TEAM_NAME = CustomSettings.getString("EvilTeamName", "Evil");
FACTION_GOOD_NAME_COLOR = Integer.decode("0x" + CustomSettings.getString("GoodNameColor", "00FF00"));
FACTION_EVIL_NAME_COLOR = Integer.decode("0x" + CustomSettings.getString("EvilNameColor", "0000FF"));
// Load PvP L2Properties file (if exists)
final PropertiesParser PVPSettings = new PropertiesParser(PVP_CONFIG_FILE);

View File

@ -2258,6 +2258,11 @@ public class L2Clan implements IIdentifiable, INamable
activeChar.sendPacket(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET);
return false;
}
if (Config.FACTION_SYSTEM_ENABLED && ((activeChar.isGood() && target.isEvil()) || (activeChar.isEvil() && target.isGood())))
{
activeChar.sendPacket(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET);
return false;
}
if (activeChar.getObjectId() == target.getObjectId())
{
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_ASK_YOURSELF_TO_APPLY_TO_A_CLAN);
@ -2337,6 +2342,11 @@ public class L2Clan implements IIdentifiable, INamable
activeChar.sendPacket(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET);
return false;
}
if (Config.FACTION_SYSTEM_ENABLED && ((activeChar.isGood() && target.isEvil()) || (activeChar.isEvil() && target.isGood())))
{
activeChar.sendPacket(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET);
return false;
}
if (activeChar.getObjectId() == target.getObjectId())
{
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_ASK_YOURSELF_TO_APPLY_TO_A_CLAN);

View File

@ -72,6 +72,10 @@ public final class L2World
/** Map containing all the players in game. */
private final Map<Integer, L2PcInstance> _allPlayers = new ConcurrentHashMap<>();
/** Map containing all the Good players in game. */
private final static Map<Integer, L2PcInstance> _allGoodPlayers = new ConcurrentHashMap<>();
/** Map containing all the Evil players in game. */
private final static Map<Integer, L2PcInstance> _allEvilPlayers = new ConcurrentHashMap<>();
/** Map containing all visible objects. */
private final Map<Integer, L2Object> _allObjects = new ConcurrentHashMap<>();
/** Map used for debug. */
@ -165,6 +169,16 @@ public final class L2World
return _allPlayers.values();
}
public Collection<L2PcInstance> getAllGoodPlayers()
{
return _allGoodPlayers.values();
}
public Collection<L2PcInstance> getAllEvilPlayers()
{
return _allEvilPlayers.values();
}
/**
* Gets all players sorted by the given comparator.
* @param comparator the comparator
@ -186,6 +200,16 @@ public final class L2World
return _allPlayers.size();
}
public int getAllgoodPlayersCount()
{
return _allGoodPlayers.size();
}
public int getAllevilPlayersCount()
{
return _allEvilPlayers.size();
}
/**
* <B>If you have access to player objectId use {@link #getPlayer(int playerObjId)}</B>
* @param name Name of the player to get Instance
@ -315,6 +339,23 @@ public final class L2World
public void addPlayerToWorld(L2PcInstance player)
{
_allPlayers.put(player.getObjectId(), player);
if (Config.FACTION_SYSTEM_ENABLED)
{
addFactionPlayerToWorld(player);
}
}
public static void addFactionPlayerToWorld(L2PcInstance player)
{
if (player.isGood())
{
_allGoodPlayers.put(player.getObjectId(), player);
}
else if (player.isEvil())
{
_allEvilPlayers.put(player.getObjectId(), player);
}
}
/**
@ -324,6 +365,18 @@ public final class L2World
public void removeFromAllPlayers(L2PcInstance player)
{
_allPlayers.remove(player.getObjectId());
if (Config.FACTION_SYSTEM_ENABLED)
{
if (player.isGood())
{
_allGoodPlayers.remove(player.getObjectId());
}
else if (player.isEvil())
{
_allEvilPlayers.remove(player.getObjectId());
}
}
}
/**

View File

@ -980,14 +980,17 @@ public abstract class L2Summon extends L2Playable
*/
public void doAttack()
{
if (getOwner() != null)
final L2PcInstance owner = getOwner();
final L2Object target = getOwner().getTarget();
if ((owner != null) && (target != null))
{
final L2Object target = getOwner().getTarget();
if (target != null)
if (Config.FACTION_SYSTEM_ENABLED && target.isPlayer() && ((owner.isGood() && target.getActingPlayer().isGood()) || (owner.isEvil() && target.getActingPlayer().isEvil())))
{
setTarget(target);
getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
return;
}
setTarget(target);
getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
}
}

View File

@ -360,7 +360,7 @@ public final class L2PcInstance extends L2Playable
// Character Character SQL String Definitions:
private static final String INSERT_CHARACTER = "INSERT INTO characters (account_name,charId,char_name,level,maxHp,curHp,maxCp,curCp,maxMp,curMp,face,hairStyle,hairColor,sex,exp,sp,karma,fame,pvpkills,pkkills,clanid,race,classid,deletetime,cancraft,title,title_color,accesslevel,online,isin7sdungeon,clan_privs,wantspeace,base_class,newbie,nobless,power_grade,createDate) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,fame=?,pvpkills=?,pkkills=?,clanid=?,race=?,classid=?,deletetime=?,title=?,title_color=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,newbie=?,nobless=?,power_grade=?,subpledge=?,lvl_joined_academy=?,apprentice=?,sponsor=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,bookmarkslot=?,vitality_points=?,language=? WHERE charId=?";
private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,fame=?,pvpkills=?,pkkills=?,clanid=?,race=?,classid=?,deletetime=?,title=?,title_color=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,newbie=?,nobless=?,power_grade=?,subpledge=?,lvl_joined_academy=?,apprentice=?,sponsor=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,bookmarkslot=?,vitality_points=?,language=?,faction=? WHERE charId=?";
private static final String RESTORE_CHARACTER = "SELECT * FROM characters WHERE charId=?";
// Character Teleport Bookmark:
@ -421,6 +421,11 @@ public final class L2PcInstance extends L2Playable
@Override
public void doAttack(L2Character target)
{
if (Config.FACTION_SYSTEM_ENABLED && target.isPlayer() && ((isGood() && target.getActingPlayer().isGood()) || (isEvil() && target.getActingPlayer().isEvil())))
{
return;
}
super.doAttack(target);
// cancel the recent fake-death protection instantly if the player attacks or casts spells
@ -595,6 +600,10 @@ public final class L2PcInstance extends L2Playable
private boolean _noble = false;
private boolean _hero = false;
/** Faction System */
private boolean _isGood = false;
private boolean _isEvil = false;
/** The L2FolkInstance corresponding to the last Folk which one the player talked. */
private L2Npc _lastFolkNpc = null;
@ -5534,6 +5543,17 @@ public final class L2PcInstance extends L2Playable
}
else
{
if (Config.FACTION_SYSTEM_ENABLED && ((isGood() && targetPlayer.isEvil()) || (isEvil() && targetPlayer.isGood())))
{
increasePvpKills(target);
return;
}
if (Config.FACTION_SYSTEM_ENABLED && ((isGood() && targetPlayer.isGood()) || (isEvil() && targetPlayer.isEvil())))
{
increasePkKillsAndKarma(target);
}
// Target player doesn't have pvp flag set
// check about wars
if ((targetPlayer.getClan() != null) && (getClan() != null) && getClan().isAtWarWith(targetPlayer.getClanId()) && targetPlayer.getClan().isAtWarWith(getClanId()) && (targetPlayer.getPledgeType() != L2Clan.SUBUNIT_ACADEMY) && (getPledgeType() != L2Clan.SUBUNIT_ACADEMY))
@ -5593,8 +5613,11 @@ public final class L2PcInstance extends L2Playable
return;
}
// Calculate new karma. (calculate karma before incrase pk count!)
setKarma(getKarma() + Formulas.calculateKarmaGain(getPkKills(), target.isSummon()));
if (!Config.FACTION_SYSTEM_ENABLED)
{
// Calculate new karma. (calculate karma before incrase pk count!)
setKarma(getKarma() + Formulas.calculateKarmaGain(getPkKills(), target.isSummon()));
}
// PK Points are increased only if you kill a player.
if (target.isPlayer())
@ -5632,6 +5655,11 @@ public final class L2PcInstance extends L2Playable
return;
}
if (Config.FACTION_SYSTEM_ENABLED && target.isPlayer() && ((isGood() && player_target.isEvil()) || (isEvil() && player_target.isGood())))
{
return;
}
if ((isInDuel() && (player_target.getDuelId() == getDuelId())))
{
return;
@ -6908,6 +6936,19 @@ public final class L2PcInstance extends L2Playable
player.setNewbie(rset.getInt("newbie"));
player.setNoble(rset.getInt("nobless") == 1);
if (Config.FACTION_SYSTEM_ENABLED)
{
final int factionId = rset.getInt("faction");
if (factionId == 1)
{
player.setGood();
}
if (factionId == 2)
{
player.setEvil();
}
}
player.setClanJoinExpiryTime(rset.getLong("clan_join_expiry_time"));
if (player.getClanJoinExpiryTime() < System.currentTimeMillis())
{
@ -7477,7 +7518,19 @@ public final class L2PcInstance extends L2Playable
statement.setInt(47, getBookMarkSlot());
statement.setInt(48, 0); // unset
statement.setString(49, getLang());
statement.setInt(50, getObjectId());
int factionId = 0;
if (isGood())
{
factionId = 1;
}
if (isEvil())
{
factionId = 2;
}
statement.setInt(50, factionId);
statement.setInt(51, getObjectId());
statement.execute();
}
@ -8434,6 +8487,11 @@ public final class L2PcInstance extends L2Playable
{
return true;
}
if (Config.FACTION_SYSTEM_ENABLED && ((isGood() && attackerPlayer.isEvil()) || (isEvil() && attackerPlayer.isGood())))
{
return true;
}
}
else if (attacker instanceof L2DefenderInstance)
{
@ -8657,6 +8715,18 @@ public final class L2PcInstance extends L2Playable
return false;
}
if ((Config.FACTION_SYSTEM_ENABLED && target.isPlayer() && skill.isBad()) && ((isGood() && target.getActingPlayer().isGood()) || (isEvil() && target.getActingPlayer().isEvil())))
{
sendPacket(ActionFailed.STATIC_PACKET);
return false;
}
if ((Config.FACTION_SYSTEM_ENABLED && target.isPlayer() && !skill.isBad()) && ((isGood() && target.getActingPlayer().isEvil()) || (isEvil() && target.getActingPlayer().isGood())))
{
sendPacket(ActionFailed.STATIC_PACKET);
return false;
}
// skills can be used on Walls and Doors only during siege
if (target.isDoor())
{
@ -14347,6 +14417,26 @@ public final class L2PcInstance extends L2Playable
_jumpTrackId = jumpTrackId;
}
public boolean isGood()
{
return _isGood;
}
public boolean isEvil()
{
return _isEvil;
}
public void setGood()
{
_isGood = true;
}
public void setEvil()
{
_isEvil = true;
}
/**
* @param target the target
* @return {@code true} if this player got war with the target, {@code false} otherwise.

View File

@ -1219,6 +1219,11 @@ public final class Skill implements IIdentifiable
return false;
}
}
if (Config.FACTION_SYSTEM_ENABLED && target.isPlayer() && ((player.isGood() && targetPlayer.isGood()) || (player.isEvil() && targetPlayer.isEvil())))
{
return false;
}
}
}
else

View File

@ -18,6 +18,7 @@
*/
package com.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.Config;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.PartyMatchRoom;
import com.l2jserver.gameserver.model.PartyMatchRoomList;
@ -69,6 +70,13 @@ public final class AnswerJoinPartyRoom extends L2GameClientPacket
return;
}
if (Config.FACTION_SYSTEM_ENABLED && ((player.isEvil() && partner.isGood()) || (player.isGood() && partner.isEvil())))
{
player.sendMessage("You cannot party with different team members.");
player.setActiveRequester(null);
return;
}
// If answer is positive, join the requester's PartyRoom.
if ((_answer == 1) && !partner.isRequestExpired())
{

View File

@ -18,6 +18,7 @@
*/
package com.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.Config;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
@ -75,6 +76,14 @@ public final class AnswerTradeRequest extends L2GameClientPacket
return;
}
if (Config.FACTION_SYSTEM_ENABLED && ((player.isEvil() && partner.isGood()) || (player.isGood() && partner.isEvil())))
{
player.sendPacket(new TradeDone(0));
player.sendMessage("You cannot trade with different team members.");
player.setActiveRequester(null);
return;
}
if ((_response == 1) && !partner.isRequestExpired())
{
player.startTrade(partner);

View File

@ -295,6 +295,10 @@ public final class CharacterCreate extends L2GameClientPacket
Location createLoc = new Location(Config.CUSTOM_STARTING_LOC_X, Config.CUSTOM_STARTING_LOC_Y, Config.CUSTOM_STARTING_LOC_Z);
newChar.setXYZInvisible(createLoc.getX(), createLoc.getY(), createLoc.getZ());
}
else if (Config.FACTION_SYSTEM_ENABLED)
{
newChar.setXYZInvisible(Config.FACTION_STARTING_LOCATION.getX(), Config.FACTION_STARTING_LOCATION.getY(), Config.FACTION_STARTING_LOCATION.getZ());
}
else
{
Location createLoc = template.getCreationPoint();

View File

@ -388,6 +388,25 @@ public class EnterWorld extends L2GameClientPacket
activeChar.sendPacket(new ExUnReadMailCount(activeChar));
}
// Faction System
if (Config.FACTION_SYSTEM_ENABLED)
{
if (activeChar.isGood())
{
activeChar.getAppearance().setNameColor(Config.FACTION_GOOD_NAME_COLOR);
activeChar.getAppearance().setTitleColor(Config.FACTION_GOOD_NAME_COLOR);
activeChar.sendMessage("Welcome " + activeChar.getName() + ", you are fighting for the " + Config.FACTION_GOOD_TEAM_NAME + " faction.");
activeChar.sendPacket(new ExShowScreenMessage("Welcome " + activeChar.getName() + ", you are fighting for the " + Config.FACTION_GOOD_TEAM_NAME + " faction.", 10000));
}
else if (activeChar.isEvil())
{
activeChar.getAppearance().setNameColor(Config.FACTION_EVIL_NAME_COLOR);
activeChar.getAppearance().setTitleColor(Config.FACTION_EVIL_NAME_COLOR);
activeChar.sendMessage("Welcome " + activeChar.getName() + ", you are fighting for the " + Config.FACTION_EVIL_TEAM_NAME + " faction.");
activeChar.sendPacket(new ExShowScreenMessage("Welcome " + activeChar.getName() + ", you are fighting for the " + Config.FACTION_EVIL_TEAM_NAME + " faction.", 10000));
}
}
Quest.playerEnter(activeChar);
// Send Quest List

View File

@ -82,6 +82,11 @@ public final class RequestDuelStart extends L2GameClientPacket
activeChar.sendPacket(msg);
return;
}
else if (Config.FACTION_SYSTEM_ENABLED && ((activeChar.isEvil() && targetChar.isGood()) || (activeChar.isGood() && targetChar.isEvil())))
{
activeChar.sendPacket(SystemMessageId.YOU_ARE_UNABLE_TO_REQUEST_A_DUEL_AT_THIS_TIME);
return;
}
// Duel is a party duel
if (_partyDuel == 1)

View File

@ -18,6 +18,7 @@
*/
package com.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.Config;
import com.l2jserver.gameserver.model.BlockList;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
@ -97,6 +98,11 @@ public final class RequestFriendInvite extends L2GameClientPacket
activeChar.sendPacket(sm);
return;
}
if (Config.FACTION_SYSTEM_ENABLED && ((friend.isEvil() && activeChar.isGood()) || (friend.isGood() && activeChar.isEvil())))
{
activeChar.sendMessage("You cannot have a friend of the opposing faction.");
return;
}
// Friend request sent.
activeChar.onTransactionRequest(friend);
friend.sendPacket(new FriendAddRequest(activeChar.getName()));

View File

@ -120,6 +120,15 @@ public final class RequestPrivateStoreBuy extends L2GameClientPacket
return;
}
if (Config.FACTION_SYSTEM_ENABLED)
{
if ((storePlayer.isEvil() && player.isGood()) || (storePlayer.isGood() && player.isEvil()))
{
player.sendMessage("You cant buy from different faction members.");
return;
}
}
TradeList storeList = storePlayer.getSellList();
if (storeList == null)
{

View File

@ -139,6 +139,15 @@ public final class RequestPrivateStoreSell extends L2GameClientPacket
return;
}
if (Config.FACTION_SYSTEM_ENABLED)
{
if ((storePlayer.isEvil() && player.isGood()) || (storePlayer.isGood() && player.isEvil()))
{
player.sendMessage("You cant sell on different faction members.");
return;
}
}
// Update offline trade record, if realtime saving is enabled
if (Config.OFFLINE_TRADE_ENABLE && Config.STORE_OFFLINE_TRADE_IN_REALTIME && ((storePlayer.getClient() == null) || storePlayer.getClient().isDetached()))
{

View File

@ -190,6 +190,12 @@ public final class TradeRequest extends L2GameClientPacket
return;
}
if (Config.FACTION_SYSTEM_ENABLED && ((player.isEvil() && partner.isGood()) || (player.isGood() && partner.isEvil())))
{
player.sendMessage("You cannot trade with different team members.");
return;
}
player.onTransactionRequest(partner);
partner.sendPacket(new SendTradeRequest(player.getObjectId()));
sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_REQUESTED_A_TRADE_WITH_C1);

View File

@ -18,6 +18,7 @@
*/
package com.l2jserver.gameserver.network.clientpackets.friend;
import com.l2jserver.Config;
import com.l2jserver.gameserver.model.BlockList;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
@ -100,6 +101,11 @@ public final class RequestFriendInvite extends L2GameClientPacket
activeChar.sendPacket(sm);
return;
}
if (Config.FACTION_SYSTEM_ENABLED && ((friend.isEvil() && activeChar.isGood()) || (friend.isGood() && activeChar.isEvil())))
{
activeChar.sendMessage("You cannot have a friend of the opposing faction.");
return;
}
// Friend request sent.
activeChar.onTransactionRequest(friend);
friend.sendPacket(new FriendAddRequest(activeChar.getName()));

View File

@ -18,6 +18,7 @@
*/
package com.l2jserver.gameserver.network.clientpackets.mentoring;
import com.l2jserver.Config;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
@ -53,6 +54,12 @@ public class RequestMenteeAdd extends L2GameClientPacket
return;
}
if (Config.FACTION_SYSTEM_ENABLED && ((mentor.isEvil() && mentee.isGood()) || (mentor.isGood() && mentee.isEvil())))
{
mentor.sendMessage("You cannot mentor a member of the opposing faction.");
return;
}
if (ConfirmMenteeAdd.validate(mentor, mentee))
{
mentor.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_OFFERED_TO_BECOME_S1_S_MENTOR).addCharName(mentee));