Support for retail Faction system.
This commit is contained in:
parent
526e3d63fe
commit
c9288c912e
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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.enums;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public enum Faction
|
||||
{
|
||||
BLACKBIRD_PLEDGE(1, 200, 1200, 3200, 6200, 11200, 19200, 30200),
|
||||
MOTHERTREE_GUARDIAN(2, 100, 1000, 2800, 5500, 10000, 17200, 27100),
|
||||
GIANT_CHASER(3, 200, 1350, 3650, 7100, 12850, 22050, 34700),
|
||||
DIMENSIONAL_STRANGER(4, 100, 1200, 3400, 6700, 12200, 21000, 33100),
|
||||
KINGDOM_ROYALGUARD(5, 100, 900, 2500, 4900, 8100, 12100, 16900, 22500, 29700, 38500, 48900),
|
||||
FISHER_GUILD(6, 100, 7300, 18100, 32500, 53500, 78700, 106700);
|
||||
|
||||
private int _id;
|
||||
private int[] _points;
|
||||
|
||||
private Faction(int id, int... points)
|
||||
{
|
||||
_id = id;
|
||||
_points = points;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public int getLevelCount()
|
||||
{
|
||||
return _points.length;
|
||||
}
|
||||
|
||||
public int getPointsOfLevel(int level)
|
||||
{
|
||||
if (level < 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (level > (_points.length - 1))
|
||||
{
|
||||
return _points[_points.length - 1];
|
||||
}
|
||||
return _points[level];
|
||||
}
|
||||
}
|
@ -79,6 +79,7 @@ import com.l2jmobius.gameserver.enums.BroochJewel;
|
||||
import com.l2jmobius.gameserver.enums.CastleSide;
|
||||
import com.l2jmobius.gameserver.enums.CategoryType;
|
||||
import com.l2jmobius.gameserver.enums.ChatType;
|
||||
import com.l2jmobius.gameserver.enums.Faction;
|
||||
import com.l2jmobius.gameserver.enums.GroupType;
|
||||
import com.l2jmobius.gameserver.enums.HtmlActionScope;
|
||||
import com.l2jmobius.gameserver.enums.IllegalActionPunishmentType;
|
||||
@ -13984,6 +13985,41 @@ public final class L2PcInstance extends L2Playable
|
||||
_trueHero = val;
|
||||
}
|
||||
|
||||
public int getFactionLevel(Faction faction)
|
||||
{
|
||||
final int currentPoints = getVariables().getInt(faction.toString(), 0);
|
||||
for (int i = 0; i < faction.getLevelCount(); i++)
|
||||
{
|
||||
if (currentPoints <= faction.getPointsOfLevel(i))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float getFactionProgress(Faction faction)
|
||||
{
|
||||
final int currentLevel = getFactionLevel(faction);
|
||||
final int currentLevelPoints = getVariables().getInt(faction.toString(), 0);
|
||||
final int previousLevelPoints = faction.getPointsOfLevel(currentLevel - 1);
|
||||
final int nextLevelPoints = faction.getPointsOfLevel(currentLevel + 1);
|
||||
return (float) (currentLevelPoints - previousLevelPoints) / (nextLevelPoints - previousLevelPoints);
|
||||
}
|
||||
|
||||
public void addFactionPoints(Faction faction, int count)
|
||||
{
|
||||
final int currentPoints = getVariables().getInt(faction.toString(), 0);
|
||||
if ((currentPoints + count) > faction.getPointsOfLevel(faction.getLevelCount() - 1))
|
||||
{
|
||||
getVariables().set(faction.toString(), faction.getPointsOfLevel(faction.getLevelCount() - 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
getVariables().set(faction.toString(), currentPoints + count);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initStatusUpdateCache()
|
||||
{
|
||||
|
@ -42,6 +42,7 @@ import com.l2jmobius.commons.util.Rnd;
|
||||
import com.l2jmobius.gameserver.cache.HtmCache;
|
||||
import com.l2jmobius.gameserver.datatables.ItemTable;
|
||||
import com.l2jmobius.gameserver.enums.CategoryType;
|
||||
import com.l2jmobius.gameserver.enums.Faction;
|
||||
import com.l2jmobius.gameserver.enums.QuestType;
|
||||
import com.l2jmobius.gameserver.enums.Race;
|
||||
import com.l2jmobius.gameserver.enums.TrapAction;
|
||||
@ -3318,6 +3319,17 @@ public class Quest extends AbstractScript implements IIdentifiable
|
||||
addCondStart(p -> (p.getClan() != null) && (p.getClan().getLevel() > clanLevel), pairs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a faction level start condition to the quest.
|
||||
* @param faction the faction
|
||||
* @param factionLevel the faction level
|
||||
* @param html the HTML to display if the condition is not met
|
||||
*/
|
||||
public void addFactionLevel(Faction faction, int factionLevel, String html)
|
||||
{
|
||||
addCondStart(p -> (p.getFactionLevel(faction)) > factionLevel, html);
|
||||
}
|
||||
|
||||
public void onQuestAborted(L2PcInstance player)
|
||||
{
|
||||
|
||||
|
@ -26,14 +26,12 @@ import com.l2jmobius.gameserver.network.serverpackets.faction.ExFactionInfo;
|
||||
*/
|
||||
public class RequestUserFactionInfo implements IClientIncomingPacket
|
||||
{
|
||||
|
||||
private int _playerId;
|
||||
private boolean _openDialog;
|
||||
|
||||
@Override
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_playerId = packet.readD();
|
||||
packet.readD();
|
||||
_openDialog = packet.readC() != 0;
|
||||
|
||||
return true;
|
||||
@ -42,6 +40,6 @@ public class RequestUserFactionInfo implements IClientIncomingPacket
|
||||
@Override
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
client.getActiveChar().sendPacket(new ExFactionInfo(_playerId, _openDialog));
|
||||
client.getActiveChar().sendPacket(new ExFactionInfo(client.getActiveChar(), _openDialog));
|
||||
}
|
||||
}
|
@ -17,21 +17,22 @@
|
||||
package com.l2jmobius.gameserver.network.serverpackets.faction;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketWriter;
|
||||
import com.l2jmobius.gameserver.enums.Faction;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author Mathael
|
||||
* @author Mathael, Mobius
|
||||
*/
|
||||
public class ExFactionInfo implements IClientOutgoingPacket
|
||||
{
|
||||
|
||||
private final int _playerId;
|
||||
private final L2PcInstance _player;
|
||||
private final boolean _openDialog;
|
||||
|
||||
public ExFactionInfo(int playerId, boolean openDialog)
|
||||
public ExFactionInfo(L2PcInstance player, boolean openDialog)
|
||||
{
|
||||
_playerId = playerId;
|
||||
_player = player;
|
||||
_openDialog = openDialog;
|
||||
}
|
||||
|
||||
@ -40,15 +41,15 @@ public class ExFactionInfo implements IClientOutgoingPacket
|
||||
{
|
||||
OutgoingPackets.EX_FACTION_INFO.writeId(packet);
|
||||
|
||||
packet.writeD(_playerId);
|
||||
packet.writeD(_player.getObjectId());
|
||||
packet.writeC(_openDialog ? 1 : 0);
|
||||
packet.writeD(6);
|
||||
packet.writeD(Faction.values().length);
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
for (Faction faction : Faction.values())
|
||||
{
|
||||
packet.writeC(i);
|
||||
packet.writeH(0);
|
||||
packet.writeE(0);
|
||||
packet.writeC(faction.getId());
|
||||
packet.writeH(_player.getFactionLevel(faction));
|
||||
packet.writeE(_player.getFactionProgress(faction));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user