Faction System (Good vs Evil).
This commit is contained in:
@@ -105,13 +105,13 @@ public final class Config
|
||||
// Custom Config File Definitions
|
||||
// --------------------------------------------------
|
||||
public static final String CUSTOM_ALLOWED_PLAYER_RACES_CONFIG_FILE = "./config/Custom/AllowedPlayerRaces.ini";
|
||||
public static final String CUSTOM_ANTIFEED_CONFIG_FILE = "./config/Custom/AntiFeed.ini";
|
||||
public static final String CUSTOM_AUTO_POTIONS_CONFIG_FILE = "./config/Custom/AutoPotions.ini";
|
||||
public static final String CUSTOM_BANKING_CONFIG_FILE = "./config/Custom/Banking.ini";
|
||||
public static final String CUSTOM_CHAMPION_MONSTERS_CONFIG_FILE = "./config/Custom/ChampionMonsters.ini";
|
||||
public static final String CUSTOM_CHAT_MODERATION_CONFIG_FILE = "./config/Custom/ChatModeration.ini";
|
||||
public static final String CUSTOM_COMMUNITY_BOARD_CONFIG_FILE = "./config/Custom/CommunityBoard.ini";
|
||||
public static final String CUSTOM_DUALBOX_CHECK_CONFIG_FILE = "./config/Custom/DualboxCheck.ini";
|
||||
public static final String CUSTOM_FACTION_SYSTEM_CONFIG_FILE = "./config/Custom/FactionSystem.ini";
|
||||
public static final String CUSTOM_FIND_PVP_CONFIG_FILE = "./config/Custom/FindPvP.ini";
|
||||
public static final String CUSTOM_HELLBOUND_STATUS_CONFIG_FILE = "./config/Custom/HellboundStatus.ini";
|
||||
public static final String CUSTOM_OFFLINE_TRADE_CONFIG_FILE = "./config/Custom/OfflineTrade.ini";
|
||||
@@ -1200,6 +1200,24 @@ public final class Config
|
||||
public static int COMMUNITY_PREMIUM_PRICE_PER_DAY;
|
||||
public static List<Integer> COMMUNITY_AVAILABLE_BUFFS;
|
||||
public static Map<String, Location> COMMUNITY_AVAILABLE_TELEPORTS;
|
||||
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;
|
||||
public static boolean FACTION_GUARDS_ENABLED;
|
||||
public static int FACTION_GOOD_GUARD_NPCID;
|
||||
public static int FACTION_EVIL_GUARD_NPCID;
|
||||
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 ENABLE_FIND_PVP;
|
||||
public static boolean PREMIUM_SYSTEM_ENABLED;
|
||||
public static float PREMIUM_RATE_XP;
|
||||
@@ -2602,6 +2620,33 @@ public final class Config
|
||||
}
|
||||
}
|
||||
|
||||
// Load FactionSystem config file (if exists)
|
||||
final PropertiesParser FactionSystem = new PropertiesParser(CUSTOM_FACTION_SYSTEM_CONFIG_FILE);
|
||||
|
||||
String[] tempString;
|
||||
FACTION_SYSTEM_ENABLED = Boolean.valueOf(FactionSystem.getBoolean("EnableFactionSystem", false));
|
||||
tempString = FactionSystem.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 = FactionSystem.getInt("FactionManagerNpcId", 500);
|
||||
tempString = FactionSystem.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 = FactionSystem.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 = FactionSystem.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 = FactionSystem.getString("GoodTeamName", "Good");
|
||||
FACTION_EVIL_TEAM_NAME = FactionSystem.getString("EvilTeamName", "Evil");
|
||||
FACTION_GOOD_NAME_COLOR = Integer.decode("0x" + FactionSystem.getString("GoodNameColor", "00FF00"));
|
||||
FACTION_EVIL_NAME_COLOR = Integer.decode("0x" + FactionSystem.getString("EvilNameColor", "0000FF"));
|
||||
FACTION_GUARDS_ENABLED = FactionSystem.getBoolean("EnableFactionGuards", true);
|
||||
FACTION_GOOD_GUARD_NPCID = FactionSystem.getInt("GoodGuardNpcId", 501);
|
||||
FACTION_EVIL_GUARD_NPCID = FactionSystem.getInt("EvilGuardNpcId", 502);
|
||||
FACTION_RESPAWN_AT_BASE = FactionSystem.getBoolean("RespawnAtFactionBase", true);
|
||||
FACTION_AUTO_NOBLESS = FactionSystem.getBoolean("FactionAutoNobless", false);
|
||||
FACTION_SPECIFIC_CHAT = FactionSystem.getBoolean("EnableFactionChat", true);
|
||||
FACTION_BALANCE_ONLINE_PLAYERS = FactionSystem.getBoolean("BalanceOnlinePlayers", true);
|
||||
FACTION_BALANCE_PLAYER_EXCEED_LIMIT = FactionSystem.getInt("BalancePlayerExceedLimit", 20);
|
||||
|
||||
// Load FindPvP config file (if exists)
|
||||
final PropertiesParser FindPvP = new PropertiesParser(CUSTOM_FIND_PVP_CONFIG_FILE);
|
||||
|
||||
|
@@ -98,6 +98,7 @@ import com.l2jmobius.gameserver.instancemanager.CoupleManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.DayNightSpawnManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.DimensionalRiftManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.FactionManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.FishingChampionshipManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.FortManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.FortSiegeManager;
|
||||
@@ -237,6 +238,11 @@ public final class GameServer
|
||||
PetDataTable.getInstance();
|
||||
CharSummonTable.getInstance().init();
|
||||
|
||||
if (Config.FACTION_SYSTEM_ENABLED)
|
||||
{
|
||||
FactionManager.getInstance();
|
||||
}
|
||||
|
||||
if (Config.PREMIUM_SYSTEM_ENABLED)
|
||||
{
|
||||
LOGGER.info("PremiumManager: Premium system is enabled.");
|
||||
|
@@ -672,11 +672,11 @@ public class NpcData implements IGameXmlReader
|
||||
*/
|
||||
private int getOrCreateClanId(String clanName)
|
||||
{
|
||||
Integer id = _clans.get(clanName.toUpperCase());
|
||||
Integer id = _clans.get(clanName);
|
||||
if (id == null)
|
||||
{
|
||||
id = _clans.size();
|
||||
_clans.put(clanName.toUpperCase(), id);
|
||||
_clans.put(clanName, id);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
@@ -688,7 +688,7 @@ public class NpcData implements IGameXmlReader
|
||||
*/
|
||||
public int getClanId(String clanName)
|
||||
{
|
||||
final Integer id = _clans.get(clanName.toUpperCase());
|
||||
final Integer id = _clans.get(clanName);
|
||||
return id != null ? id : -1;
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 com.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* Contains objectId and factionId for all players.
|
||||
* @author Mobius
|
||||
*/
|
||||
public class FactionManager
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(FactionManager.class.getName());
|
||||
private final Map<Integer, Integer> _playerFactions = new ConcurrentHashMap<>();
|
||||
|
||||
protected FactionManager()
|
||||
{
|
||||
loadAll();
|
||||
}
|
||||
|
||||
private void loadAll()
|
||||
{
|
||||
_playerFactions.clear();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
Statement s = con.createStatement();
|
||||
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
|
||||
{
|
||||
while (rs.next())
|
||||
{
|
||||
_playerFactions.put(rs.getInt(1), rs.getInt(2));
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
_log.log(Level.WARNING, getClass().getSimpleName() + ": Could not load character faction information: " + e.getMessage(), e);
|
||||
}
|
||||
_log.info(getClass().getSimpleName() + ": Loaded " + _playerFactions.size() + " character faction values.");
|
||||
}
|
||||
|
||||
public final int getFactionByCharId(int id)
|
||||
{
|
||||
if (id <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Integer factionId = _playerFactions.get(id);
|
||||
if (factionId != null)
|
||||
{
|
||||
return factionId;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
|
||||
{
|
||||
ps.setInt(1, id);
|
||||
try (ResultSet rset = ps.executeQuery())
|
||||
{
|
||||
if (rset.next())
|
||||
{
|
||||
factionId = rset.getInt(1);
|
||||
_playerFactions.put(id, factionId);
|
||||
return factionId;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
_log.log(Level.WARNING, getClass().getSimpleName() + ": Could not check existing char id: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
return 0; // not found
|
||||
}
|
||||
|
||||
public final boolean isSameFaction(L2PcInstance player1, L2PcInstance player2)
|
||||
{
|
||||
// TODO: Maybe add support for multiple factions?
|
||||
return (player1.isGood() && player2.isGood()) || (player1.isEvil() && player2.isEvil());
|
||||
}
|
||||
|
||||
public static FactionManager getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final FactionManager _instance = new FactionManager();
|
||||
}
|
||||
}
|
@@ -25,6 +25,7 @@ import org.w3c.dom.Document;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.util.IGameXmlReader;
|
||||
import com.l2jmobius.gameserver.SevenSigns;
|
||||
import com.l2jmobius.gameserver.model.L2MapRegion;
|
||||
@@ -158,7 +159,11 @@ public final class MapRegionManager implements IGameXmlReader
|
||||
public final int getMapRegionLocId(int locX, int locY)
|
||||
{
|
||||
final L2MapRegion region = getMapRegion(locX, locY);
|
||||
return region != null ? region.getLocId() : 0;
|
||||
if (region != null)
|
||||
{
|
||||
return region.getLocId();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -405,6 +410,18 @@ public final class MapRegionManager implements IGameXmlReader
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.FACTION_SYSTEM_ENABLED && Config.FACTION_RESPAWN_AT_BASE)
|
||||
{
|
||||
if (activeChar.getActingPlayer().isGood())
|
||||
{
|
||||
return Config.FACTION_GOOD_BASE_LOCATION;
|
||||
}
|
||||
if (activeChar.getActingPlayer().isEvil())
|
||||
{
|
||||
return Config.FACTION_EVIL_BASE_LOCATION;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the nearest town
|
||||
try
|
||||
{
|
||||
|
@@ -54,6 +54,8 @@ public class CharSelectInfoPackage
|
||||
private int _y = 0;
|
||||
private int _z = 0;
|
||||
private String _htmlPrefix = null;
|
||||
private boolean _isGood = false;
|
||||
private boolean _isEvil = false;
|
||||
private int _vitalityPoints = 0;
|
||||
private int _accessLevel = 0;
|
||||
|
||||
@@ -98,6 +100,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;
|
||||
|
@@ -25,6 +25,7 @@ import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.util.CommonUtil;
|
||||
import com.l2jmobius.gameserver.ai.CtrlEvent;
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
@@ -84,6 +85,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 static final Map<Integer, L2PcInstance> _allGoodPlayers = new ConcurrentHashMap<>();
|
||||
/** Map containing all the Evil players in game. */
|
||||
private static final Map<Integer, L2PcInstance> _allEvilPlayers = new ConcurrentHashMap<>();
|
||||
/** Map containing all visible objects. */
|
||||
private final Map<Integer, L2Object> _allObjects = new ConcurrentHashMap<>();
|
||||
/** Map with the pets instances and their owner ID. */
|
||||
@@ -139,6 +144,10 @@ public final class L2World
|
||||
Disconnection.of(newPlayer).defaultSequence(false);
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Duplicate character!? Disconnected both characters (" + newPlayer.getName() + ")");
|
||||
}
|
||||
else if (Config.FACTION_SYSTEM_ENABLED)
|
||||
{
|
||||
addFactionPlayerToWorld(newPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,6 +172,18 @@ public final class L2World
|
||||
return;
|
||||
}
|
||||
_allPlayers.remove(object.getObjectId());
|
||||
|
||||
if (Config.FACTION_SYSTEM_ENABLED)
|
||||
{
|
||||
if (player.isGood())
|
||||
{
|
||||
_allGoodPlayers.remove(player.getObjectId());
|
||||
}
|
||||
else if (player.isEvil())
|
||||
{
|
||||
_allEvilPlayers.remove(player.getObjectId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,6 +219,16 @@ public final class L2World
|
||||
return _allPlayers.values();
|
||||
}
|
||||
|
||||
public Collection<L2PcInstance> getAllGoodPlayers()
|
||||
{
|
||||
return _allGoodPlayers.values();
|
||||
}
|
||||
|
||||
public Collection<L2PcInstance> getAllEvilPlayers()
|
||||
{
|
||||
return _allEvilPlayers.values();
|
||||
}
|
||||
|
||||
/**
|
||||
* <B>If you have access to player objectId use {@link #getPlayer(int playerObjId)}</B>
|
||||
* @param name Name of the player to get Instance
|
||||
@@ -323,6 +354,18 @@ public final class L2World
|
||||
});
|
||||
}
|
||||
|
||||
public static void addFactionPlayerToWorld(L2PcInstance player)
|
||||
{
|
||||
if (player.isGood())
|
||||
{
|
||||
_allGoodPlayers.put(player.getObjectId(), player);
|
||||
}
|
||||
else if (player.isEvil())
|
||||
{
|
||||
_allEvilPlayers.put(player.getObjectId(), player);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a L2Object from the world. <B><U> Concept</U> :</B> L2Object (including L2PcInstance) are identified in <B>_visibleObjects</B> of his current L2WorldRegion and in <B>_knownObjects</B> of other surrounding L2Characters <BR>
|
||||
* L2PcInstance are identified in <B>_allPlayers</B> of L2World, in <B>_allPlayers</B> of his current L2WorldRegion and in <B>_knownPlayer</B> of other surrounding L2Characters <B><U> Actions</U> :</B>
|
||||
|
@@ -653,7 +653,7 @@ public class L2Attackable extends L2Npc
|
||||
*/
|
||||
public void addDamageHate(L2Character attacker, int damage, int aggro)
|
||||
{
|
||||
if (attacker == null)
|
||||
if ((attacker == null) || (attacker == this))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@@ -16,16 +16,17 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.actor.instance;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.L2WorldRegion;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Attackable;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.events.EventType;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.npc.OnNpcFirstTalk;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
|
||||
/**
|
||||
@@ -49,11 +50,24 @@ public class L2GuardInstance extends L2Attackable
|
||||
@Override
|
||||
public boolean isAutoAttackable(L2Character attacker)
|
||||
{
|
||||
if (attacker.isPlayer())
|
||||
if (attacker.isMonster())
|
||||
{
|
||||
return ((L2PcInstance) attacker).getKarma() > 0;
|
||||
return true;
|
||||
}
|
||||
return attacker instanceof L2MonsterInstance;
|
||||
return super.isAutoAttackable(attacker);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDamage(L2Character attacker, int damage, Skill skill)
|
||||
{
|
||||
super.addDamage(attacker, damage, skill);
|
||||
getAI().startFollow(attacker);
|
||||
addDamageHate(attacker, 0, 10);
|
||||
L2World.getInstance().forEachVisibleObjectInRange(this, L2GuardInstance.class, 500, guard ->
|
||||
{
|
||||
guard.getAI().startFollow(attacker);
|
||||
guard.addDamageHate(attacker, 0, 10);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,12 +79,13 @@ public class L2GuardInstance extends L2Attackable
|
||||
setIsNoRndWalk(true);
|
||||
super.onSpawn();
|
||||
|
||||
getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
|
||||
// check the region where this mob is, do not activate the AI if region is inactive.
|
||||
final L2WorldRegion region = L2World.getInstance().getRegion(this);
|
||||
if ((region != null) && (!region.isActive()))
|
||||
{
|
||||
getAI().stopAITask();
|
||||
}
|
||||
// final L2WorldRegion region = L2World.getInstance().getRegion(this);
|
||||
// if ((region != null) && (!region.isActive()))
|
||||
// {
|
||||
// getAI().stopAITask();
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,6 +141,13 @@ public class L2GuardInstance extends L2Attackable
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.FACTION_SYSTEM_ENABLED && Config.FACTION_GUARDS_ENABLED && ((player.isGood() && getTemplate().isClan(Config.FACTION_EVIL_TEAM_NAME)) || (player.isEvil() && getTemplate().isClan(Config.FACTION_GOOD_TEAM_NAME))))
|
||||
{
|
||||
interact = false;
|
||||
// TODO: Fix normal targeting
|
||||
player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, this);
|
||||
}
|
||||
|
||||
// Check if the L2PcInstance already target the L2GuardInstance
|
||||
if (getObjectId() != player.getTargetId())
|
||||
{
|
||||
|
@@ -349,7 +349,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:
|
||||
@@ -575,6 +575,10 @@ public final class L2PcInstance extends L2Playable
|
||||
/** Premium System */
|
||||
private boolean _premiumStatus = 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;
|
||||
|
||||
@@ -593,7 +597,7 @@ public final class L2PcInstance extends L2Playable
|
||||
private final Set<L2PcInstance> _snoopListener = ConcurrentHashMap.newKeySet(1);
|
||||
private final Set<L2PcInstance> _snoopedPlayer = ConcurrentHashMap.newKeySet(1);
|
||||
|
||||
// hennas
|
||||
/** Hennas */
|
||||
private final L2Henna[] _henna = new L2Henna[3];
|
||||
private int _hennaSTR;
|
||||
private int _hennaINT;
|
||||
@@ -5436,6 +5440,16 @@ public final class L2PcInstance extends L2Playable
|
||||
return;
|
||||
}
|
||||
|
||||
if (this == player_target)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.FACTION_SYSTEM_ENABLED && target.isPlayer() && ((isGood() && player_target.isEvil()) || (isEvil() && player_target.isGood())))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (isInDuel() && (player_target.getDuelId() == getDuelId()))
|
||||
{
|
||||
return;
|
||||
@@ -6715,6 +6729,16 @@ public final class L2PcInstance extends L2Playable
|
||||
player.setNewbie(rset.getInt("newbie"));
|
||||
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"));
|
||||
if (player.getClanJoinExpiryTime() < System.currentTimeMillis())
|
||||
{
|
||||
@@ -7282,7 +7306,18 @@ public final class L2PcInstance extends L2Playable
|
||||
ps.setInt(47, getBookMarkSlot());
|
||||
ps.setInt(48, getVitalityPoints());
|
||||
ps.setString(49, getLang());
|
||||
ps.setInt(50, getObjectId());
|
||||
|
||||
int factionId = 0;
|
||||
if (isGood())
|
||||
{
|
||||
factionId = 1;
|
||||
}
|
||||
if (isEvil())
|
||||
{
|
||||
factionId = 2;
|
||||
}
|
||||
ps.setInt(50, factionId);
|
||||
ps.setInt(51, getObjectId());
|
||||
|
||||
ps.execute();
|
||||
}
|
||||
@@ -8226,7 +8261,11 @@ public final class L2PcInstance extends L2Playable
|
||||
// Check if the attacker is in olympia and olympia start
|
||||
if (attacker.isPlayer() && attacker.getActingPlayer().isInOlympiadMode())
|
||||
{
|
||||
return isInOlympiadMode() && isOlympiadStart() && (((L2PcInstance) attacker).getOlympiadGameId() == getOlympiadGameId());
|
||||
if (isInOlympiadMode() && isOlympiadStart() && (((L2PcInstance) attacker).getOlympiadGameId() == getOlympiadGameId()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the attacker is in TvT and TvT is started
|
||||
@@ -8295,8 +8334,14 @@ 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)
|
||||
|
||||
if (attacker instanceof L2DefenderInstance)
|
||||
{
|
||||
if (getClan() != null)
|
||||
{
|
||||
@@ -14301,6 +14346,28 @@ public final class L2PcInstance extends L2Playable
|
||||
return _hasCharmOfCourage;
|
||||
}
|
||||
|
||||
public boolean isGood()
|
||||
{
|
||||
return _isGood;
|
||||
}
|
||||
|
||||
public boolean isEvil()
|
||||
{
|
||||
return _isEvil;
|
||||
}
|
||||
|
||||
public void setGood()
|
||||
{
|
||||
_isGood = true;
|
||||
_isEvil = false;
|
||||
}
|
||||
|
||||
public void setEvil()
|
||||
{
|
||||
_isGood = false;
|
||||
_isEvil = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param target the target
|
||||
* @return {@code true} if this player got war with the target, {@code false} otherwise.
|
||||
|
@@ -285,6 +285,10 @@ public final class CharacterCreate implements IClientIncomingPacket
|
||||
final 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
|
||||
{
|
||||
final Location createLoc = template.getCreationPoint();
|
||||
|
@@ -27,6 +27,7 @@ import com.l2jmobius.gameserver.data.xml.impl.SecondaryAuthData;
|
||||
import com.l2jmobius.gameserver.instancemanager.AntiFeedManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.PunishmentManager;
|
||||
import com.l2jmobius.gameserver.model.CharSelectInfoPackage;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.events.Containers;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
@@ -126,6 +127,28 @@ public class CharacterSelect implements IClientIncomingPacket
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.FACTION_SYSTEM_ENABLED && Config.FACTION_BALANCE_ONLINE_PLAYERS)
|
||||
{
|
||||
if (info.isGood() && (L2World.getInstance().getAllGoodPlayers().size() >= (L2World.getInstance().getAllEvilPlayers().size() + 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().getAllEvilPlayers().size() >= (L2World.getInstance().getAllGoodPlayers().size() + 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;
|
||||
}
|
||||
}
|
||||
|
||||
// load up character from disk
|
||||
final L2PcInstance cha = client.load(_charSlot);
|
||||
if (cha == null)
|
||||
|
@@ -376,6 +376,27 @@ public class EnterWorld implements IClientIncomingPacket
|
||||
|
||||
Quest.playerEnter(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));
|
||||
activeChar.broadcastUserInfo(); // for seeing self name color
|
||||
}
|
||||
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));
|
||||
activeChar.broadcastUserInfo(); // for seeing self name color
|
||||
}
|
||||
}
|
||||
|
||||
if (!Config.DISABLE_TUTORIAL)
|
||||
{
|
||||
loadTutorial(activeChar);
|
||||
|
@@ -201,7 +201,7 @@ public class CharSelectionInfo implements IClientOutgoingPacket
|
||||
private static void loadCharacterSubclassInfo(CharSelectInfoPackage charInfopackage, int ObjectId, int activeClassId)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("SELECT exp, sp, level FROM character_subclasses WHERE charId=? && class_id=? ORDER BY charId"))
|
||||
PreparedStatement statement = con.prepareStatement("SELECT exp, sp, level FROM character_subclasses WHERE charId=? AND class_id=? ORDER BY charId"))
|
||||
{
|
||||
statement.setInt(1, ObjectId);
|
||||
statement.setInt(2, activeClassId);
|
||||
@@ -272,6 +272,16 @@ public class CharSelectionInfo implements IClientOutgoingPacket
|
||||
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.MULTILANG_ENABLE)
|
||||
{
|
||||
String lang = chardata.getString("language");
|
||||
|
@@ -56,7 +56,7 @@ public final class NpcSay implements IClientOutgoingPacket
|
||||
{
|
||||
_objectId = npc.getObjectId();
|
||||
_textType = messageType;
|
||||
_npcId = 1000000 + npc.getId();
|
||||
_npcId = 1000000 + npc.getTemplate().getDisplayId();
|
||||
_npcString = -1;
|
||||
_text = text;
|
||||
}
|
||||
@@ -73,7 +73,7 @@ public final class NpcSay implements IClientOutgoingPacket
|
||||
{
|
||||
_objectId = npc.getObjectId();
|
||||
_textType = messageType;
|
||||
_npcId = 1000000 + npc.getId();
|
||||
_npcId = 1000000 + npc.getTemplate().getDisplayId();
|
||||
_npcString = npcString.getId();
|
||||
}
|
||||
|
||||
@@ -119,6 +119,7 @@ public final class NpcSay implements IClientOutgoingPacket
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
OutgoingPackets.NPC_SAY.writeId(packet);
|
||||
|
||||
packet.writeD(_objectId);
|
||||
packet.writeD(_textType.getClientId());
|
||||
packet.writeD(_npcId);
|
||||
|
Reference in New Issue
Block a user