Faction points quest reward rate config.

Contributed by gigilo1968.
This commit is contained in:
MobiusDev 2017-10-07 11:25:44 +00:00
parent 0a1ba59d95
commit a6ec6db55c
4 changed files with 47 additions and 12 deletions

View File

@ -56,6 +56,9 @@ RateQuestDrop = 1
RateQuestRewardXP = 1
RateQuestRewardSP = 1
# Faction points reward multiplier
RateQuestRewardFP = 1
# Adena reward multiplier
RateQuestRewardAdena = 1

View File

@ -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);

View File

@ -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

View File

@ -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).<br>
* Use this method instead of importing {@link com.l2jmobius.commons.util.Rnd} utility.