From a6ec6db55c82dcb320163d435039b97e9ca2d65a Mon Sep 17 00:00:00 2001 From: MobiusDev <8391001+MobiusDevelopment@users.noreply.github.com> Date: Sat, 7 Oct 2017 11:25:44 +0000 Subject: [PATCH] Faction points quest reward rate config. Contributed by gigilo1968. --- .../dist/game/config/Rates.ini | 3 ++ .../java/com/l2jmobius/Config.java | 2 ++ .../model/actor/instance/L2PcInstance.java | 23 +++++++------- .../model/events/AbstractScript.java | 31 +++++++++++++++++++ 4 files changed, 47 insertions(+), 12 deletions(-) diff --git a/L2J_Mobius_3.0_Helios/dist/game/config/Rates.ini b/L2J_Mobius_3.0_Helios/dist/game/config/Rates.ini index 5fbd9b24a4..2492a307cb 100644 --- a/L2J_Mobius_3.0_Helios/dist/game/config/Rates.ini +++ b/L2J_Mobius_3.0_Helios/dist/game/config/Rates.ini @@ -56,6 +56,9 @@ RateQuestDrop = 1 RateQuestRewardXP = 1 RateQuestRewardSP = 1 +# Faction points reward multiplier +RateQuestRewardFP = 1 + # Adena reward multiplier RateQuestRewardAdena = 1 diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/Config.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/Config.java index 7f3f6dce07..8c5c52a5a4 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/Config.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/Config.java @@ -681,6 +681,7 @@ public final class Config public static float RATE_QUEST_REWARD; public static float RATE_QUEST_REWARD_XP; public static float RATE_QUEST_REWARD_SP; + public static float RATE_QUEST_REWARD_FP; public static float RATE_QUEST_REWARD_ADENA; public static boolean RATE_QUEST_REWARD_USE_MULTIPLIERS; public static float RATE_QUEST_REWARD_POTION; @@ -1993,6 +1994,7 @@ public final class Config RATE_QUEST_REWARD = RatesSettings.getFloat("RateQuestReward", 1); RATE_QUEST_REWARD_XP = RatesSettings.getFloat("RateQuestRewardXP", 1); RATE_QUEST_REWARD_SP = RatesSettings.getFloat("RateQuestRewardSP", 1); + RATE_QUEST_REWARD_FP = RatesSettings.getFloat("RateQuestRewardFP", 1); RATE_QUEST_REWARD_ADENA = RatesSettings.getFloat("RateQuestRewardAdena", 1); RATE_QUEST_REWARD_USE_MULTIPLIERS = RatesSettings.getBoolean("UseQuestRewardMultipliers", false); RATE_QUEST_REWARD_POTION = RatesSettings.getFloat("RateQuestRewardPotion", 1); diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java index 7b820d9bab..6b717290c8 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java @@ -280,7 +280,6 @@ import com.l2jmobius.gameserver.network.serverpackets.ExPledgeCount; import com.l2jmobius.gameserver.network.serverpackets.ExPrivateStoreSetWholeMsg; import com.l2jmobius.gameserver.network.serverpackets.ExQuestItemList; import com.l2jmobius.gameserver.network.serverpackets.ExSetCompassZoneCode; -import com.l2jmobius.gameserver.network.serverpackets.ExShowScreenMessage; import com.l2jmobius.gameserver.network.serverpackets.ExStartScenePlayer; import com.l2jmobius.gameserver.network.serverpackets.ExStopScenePlayer; import com.l2jmobius.gameserver.network.serverpackets.ExStorageMaxCount; @@ -13881,9 +13880,14 @@ public final class L2PcInstance extends L2Playable _trueHero = val; } + public int getFactionPoints(Faction faction) + { + return getVariables().getInt(faction.toString(), 0); + } + public int getFactionLevel(Faction faction) { - final int currentPoints = getVariables().getInt(faction.toString(), 0); + final int currentPoints = getFactionPoints(faction); for (int i = 0; i < faction.getLevelCount(); i++) { if (currentPoints <= faction.getPointsOfLevel(i)) @@ -13897,7 +13901,7 @@ public final class L2PcInstance extends L2Playable public float getFactionProgress(Faction faction) { final int currentLevel = getFactionLevel(faction); - final int currentLevelPoints = getVariables().getInt(faction.toString(), 0); + final int currentLevelPoints = getFactionPoints(faction); final int previousLevelPoints = faction.getPointsOfLevel(currentLevel - 1); final int nextLevelPoints = faction.getPointsOfLevel(currentLevel + 1); return (float) (currentLevelPoints - previousLevelPoints) / (nextLevelPoints - previousLevelPoints); @@ -13905,20 +13909,15 @@ public final class L2PcInstance extends L2Playable public void addFactionPoints(Faction faction, int count) { - final int currentPoints = getVariables().getInt(faction.toString(), 0); - final String message; - if ((currentPoints + count) > faction.getPointsOfLevel(faction.getLevelCount() - 1)) + final int currentPoints = getFactionPoints(faction); + if ((currentPoints + count) < faction.getPointsOfLevel(faction.getLevelCount() - 1)) { - getVariables().set(faction.toString(), faction.getPointsOfLevel(faction.getLevelCount() - 1)); - message = "Your reputation with the " + faction.toString().toLowerCase().replace("_", " ") + " faction is at the highest level possible."; + getVariables().set(faction.toString(), currentPoints + count); } else { - getVariables().set(faction.toString(), currentPoints + count); - message = "Your reputation with the " + faction.toString().toLowerCase().replace("_", " ") + " faction was increased by " + count + " points."; + getVariables().set(faction.toString(), faction.getPointsOfLevel(faction.getLevelCount() - 1)); } - sendPacket(new ExShowScreenMessage(message, 5000)); - sendMessage(message); } @Override diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/events/AbstractScript.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/events/AbstractScript.java index d62c0be382..13bb8ff21f 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/events/AbstractScript.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/events/AbstractScript.java @@ -41,6 +41,7 @@ import com.l2jmobius.gameserver.data.xml.impl.DoorData; import com.l2jmobius.gameserver.data.xml.impl.NpcData; import com.l2jmobius.gameserver.datatables.ItemTable; import com.l2jmobius.gameserver.enums.AttributeType; +import com.l2jmobius.gameserver.enums.Faction; import com.l2jmobius.gameserver.enums.Movie; import com.l2jmobius.gameserver.enums.QuestSound; import com.l2jmobius.gameserver.instancemanager.CastleManager; @@ -2994,6 +2995,36 @@ public abstract class AbstractScript extends ManagedScript implements IEventTime PcCafePointsManager.getInstance().givePcCafePoint(player, (long) (exp * Config.RATE_QUEST_REWARD_XP)); } + /** + * Add faction points as quest reward. + * @param player the player whom to reward with the faction points. + * @param faction the faction to which the points belong + * @param factionPoints the base amount of faction points to give to the player. It will be influenced by RATE_QUEST_REWARD_FP. + */ + public static void addFactionPoints(L2PcInstance player, Faction faction, int factionPoints) + { + factionPoints *= Config.RATE_QUEST_REWARD_FP; + final int currentPoints = player.getFactionPoints(faction); + final int oldLevel = player.getFactionLevel(faction); + + if ((currentPoints + factionPoints) < faction.getPointsOfLevel(faction.getLevelCount() - 1)) + { + player.sendPacket(new ExShowScreenMessage("Your reputation with the " + faction.toString().toLowerCase().replace("_", " ") + " faction was increased by " + factionPoints + " points.", 5000)); + } + else + { + player.sendPacket(new ExShowScreenMessage("Your reputation with the " + faction.toString().toLowerCase().replace("_", " ") + " faction is at the highest level possible.", 5000)); + } + + player.addFactionPoints(faction, factionPoints); + final int newLevel = player.getFactionLevel(faction); + + if (oldLevel < newLevel) + { + player.sendPacket(new ExShowScreenMessage("Your reputation level with the " + faction.toString().toLowerCase().replace("_", " ") + " faction has increased.", 5000)); + } + } + /** * Get a random integer from 0 (inclusive) to {@code max} (exclusive).
* Use this method instead of importing {@link com.l2jmobius.commons.util.Rnd} utility.