PcCafePointsManager rework.
This commit is contained in:
parent
00726289e4
commit
5127c5827a
41
trunk/dist/game/config/Custom.properties
vendored
41
trunk/dist/game/config/Custom.properties
vendored
@ -845,26 +845,37 @@ BTZDelay = 10
|
||||
# ---------------------------------------------------------------------------
|
||||
# PC BANG POINTS ID = -100
|
||||
|
||||
# PC Bang Enabled
|
||||
# PC Bang Enabled.
|
||||
Enabled = True
|
||||
|
||||
# Max points that player may have
|
||||
# Limited by int limit
|
||||
# Max points that player may have.
|
||||
# Limited by int limit.
|
||||
MaxPcBangPoints = 200000
|
||||
|
||||
# Use random in rewarding with points
|
||||
# If enabled points will be random from points/2 to points
|
||||
AcquisitionPointsRandom = False
|
||||
|
||||
# Creates a chance to aquire double point
|
||||
DoublingAcquisitionPoints = True
|
||||
|
||||
# Double points chance
|
||||
# If DoublingAcquisitionPoints=True
|
||||
DoublingAcquisitionPointsChance = 1
|
||||
|
||||
# PC Bang point rate
|
||||
# PC Bang point rate.
|
||||
# Acquisition formula equals (exp * 0.0001 * AcquisitionPointsRate)
|
||||
# e.g. with 1.0 it's 10000 exp = 1 PC Bang point
|
||||
# 2.0 - 10000 exp = 2 PC Bang points
|
||||
# 0.5 - 5000 exp = 1 PC Bang point
|
||||
AcquisitionPointsRate = 1.0
|
||||
|
||||
# Use random points rewarding.
|
||||
# If enabled points will be random from points/2 to points.
|
||||
AcquisitionPointsRandom = False
|
||||
|
||||
# Creates a chance to aquire double points.
|
||||
DoublingAcquisitionPoints = True
|
||||
|
||||
# Double points chance.
|
||||
# Used when DoublingAcquisitionPoints is enabled.
|
||||
# Default 1 (%)
|
||||
DoublingAcquisitionPointsChance = 1
|
||||
|
||||
# Reward low exp kills
|
||||
# Acquire points if player gains exp and aquire formula equals 0.
|
||||
RewardLowExpKills = True
|
||||
|
||||
# Chance for low exp kills
|
||||
# Used when RewardLowExpKills is enabled.
|
||||
# Default 50 (%)
|
||||
RewardLowExpKillsChance = 50
|
||||
|
@ -866,11 +866,13 @@ public final class Config
|
||||
public static boolean BTZ_REMOVE_PETS;
|
||||
public static List<int[]> BTZ_REWARDS;
|
||||
public static boolean PC_BANG_ENABLED;
|
||||
public static int MAX_PC_BANG_POINTS;
|
||||
public static boolean ENABLE_DOUBLE_PC_BANG_POINTS;
|
||||
public static int DOUBLE_PC_BANG_POINTS_CHANCE;
|
||||
public static int PC_BANG_MAX_POINTS;
|
||||
public static boolean PC_BANG_ENABLE_DOUBLE_POINTS;
|
||||
public static int PC_BANG_DOUBLE_POINTS_CHANCE;
|
||||
public static double PC_BANG_POINT_RATE;
|
||||
public static boolean RANDOM_PC_BANG_POINT;
|
||||
public static boolean PC_BANG_RANDOM_POINT;
|
||||
public static boolean PC_BANG_REWARD_LOW_EXP_KILLS;
|
||||
public static int PC_BANG_LOW_EXP_KILLS_CHANCE;
|
||||
|
||||
// --------------------------------------------------
|
||||
// NPC Settings
|
||||
@ -2757,22 +2759,33 @@ public final class Config
|
||||
}
|
||||
|
||||
PC_BANG_ENABLED = CustomSettings.getBoolean("Enabled", false);
|
||||
MAX_PC_BANG_POINTS = CustomSettings.getInt("MaxPcBangPoints", 200000);
|
||||
if (MAX_PC_BANG_POINTS < 0)
|
||||
PC_BANG_MAX_POINTS = CustomSettings.getInt("MaxPcBangPoints", 200000);
|
||||
if (PC_BANG_MAX_POINTS < 0)
|
||||
{
|
||||
MAX_PC_BANG_POINTS = 0;
|
||||
PC_BANG_MAX_POINTS = 0;
|
||||
}
|
||||
ENABLE_DOUBLE_PC_BANG_POINTS = CustomSettings.getBoolean("DoublingAcquisitionPoints", false);
|
||||
DOUBLE_PC_BANG_POINTS_CHANCE = CustomSettings.getInt("DoublingAcquisitionPointsChance", 1);
|
||||
if ((DOUBLE_PC_BANG_POINTS_CHANCE < 0) || (DOUBLE_PC_BANG_POINTS_CHANCE > 100))
|
||||
PC_BANG_ENABLE_DOUBLE_POINTS = CustomSettings.getBoolean("DoublingAcquisitionPoints", false);
|
||||
PC_BANG_DOUBLE_POINTS_CHANCE = CustomSettings.getInt("DoublingAcquisitionPointsChance", 1);
|
||||
if ((PC_BANG_DOUBLE_POINTS_CHANCE < 0) || (PC_BANG_DOUBLE_POINTS_CHANCE > 100))
|
||||
{
|
||||
DOUBLE_PC_BANG_POINTS_CHANCE = 1;
|
||||
PC_BANG_DOUBLE_POINTS_CHANCE = 1;
|
||||
}
|
||||
PC_BANG_POINT_RATE = CustomSettings.getDouble("AcquisitionPointsRate", 1.0);
|
||||
PC_BANG_RANDOM_POINT = CustomSettings.getBoolean("AcquisitionPointsRandom", false);
|
||||
if (PC_BANG_POINT_RATE < 0)
|
||||
{
|
||||
PC_BANG_POINT_RATE = 1;
|
||||
}
|
||||
PC_BANG_REWARD_LOW_EXP_KILLS = CustomSettings.getBoolean("RewardLowExpKills", true);
|
||||
PC_BANG_LOW_EXP_KILLS_CHANCE = CustomSettings.getInt("RewardLowExpKillsChance", 50);
|
||||
if (PC_BANG_LOW_EXP_KILLS_CHANCE < 0)
|
||||
{
|
||||
PC_BANG_LOW_EXP_KILLS_CHANCE = 0;
|
||||
}
|
||||
if (PC_BANG_LOW_EXP_KILLS_CHANCE > 100)
|
||||
{
|
||||
PC_BANG_LOW_EXP_KILLS_CHANCE = 100;
|
||||
}
|
||||
|
||||
// Load PvP L2Properties file (if exists)
|
||||
final PropertiesParser PVPSettings = new PropertiesParser(PVP_CONFIG_FILE);
|
||||
|
@ -26,24 +26,13 @@ import com.l2jserver.gameserver.network.serverpackets.ExPCCafePointInfo;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.util.Rnd;
|
||||
|
||||
public class PcCafePointsManager
|
||||
public final class PcCafePointsManager
|
||||
{
|
||||
private static PcCafePointsManager _instance;
|
||||
|
||||
public PcCafePointsManager()
|
||||
{
|
||||
}
|
||||
|
||||
public static PcCafePointsManager getInstance()
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new PcCafePointsManager();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
|
||||
public void givePcCafePoint(final L2PcInstance player, final long givedexp)
|
||||
public void givePcCafePoint(final L2PcInstance player, final long exp)
|
||||
{
|
||||
if (!Config.PC_BANG_ENABLED)
|
||||
{
|
||||
@ -55,45 +44,59 @@ public class PcCafePointsManager
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getPcBangPoints() >= Config.MAX_PC_BANG_POINTS)
|
||||
if (player.getPcBangPoints() >= Config.PC_BANG_MAX_POINTS)
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_THE_MAXIMUM_NUMBER_OF_PC_POINTS);
|
||||
player.sendPacket(sm);
|
||||
final SystemMessage message = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_THE_MAXIMUM_NUMBER_OF_PC_POINTS);
|
||||
player.sendPacket(message);
|
||||
return;
|
||||
}
|
||||
int _points = (int) (givedexp * 0.0001 * Config.PC_BANG_POINT_RATE);
|
||||
|
||||
// TODO: Mage class balance?
|
||||
// if ((player.getActiveClass() == ClassId.ARCHMAGE.getId()) || (player.getActiveClass() == ClassId.SOULTAKER.getId()) || (player.getActiveClass() == ClassId.STORM_SCREAMER.getId()) || (player.getActiveClass() == ClassId.MYSTIC_MUSE.getId()))
|
||||
// {
|
||||
// _points /= 2;
|
||||
// }
|
||||
int points = (int) (exp * 0.0001 * Config.PC_BANG_POINT_RATE);
|
||||
|
||||
if (Config.RANDOM_PC_BANG_POINT)
|
||||
if (Config.PC_BANG_RANDOM_POINT)
|
||||
{
|
||||
_points = Rnd.get(_points / 2, _points);
|
||||
points = Rnd.get(points / 2, points);
|
||||
}
|
||||
|
||||
SystemMessage sm = null;
|
||||
if (_points > 0)
|
||||
if ((points == 0) && (exp > 0) && Config.PC_BANG_REWARD_LOW_EXP_KILLS && (Rnd.get(100) < Config.PC_BANG_LOW_EXP_KILLS_CHANCE))
|
||||
{
|
||||
if (Config.ENABLE_DOUBLE_PC_BANG_POINTS && (Rnd.get(100) < Config.DOUBLE_PC_BANG_POINTS_CHANCE))
|
||||
points = 1; // minimum points
|
||||
}
|
||||
|
||||
SystemMessage message = null;
|
||||
if (points > 0)
|
||||
{
|
||||
if (Config.PC_BANG_ENABLE_DOUBLE_POINTS && (Rnd.get(100) < Config.PC_BANG_DOUBLE_POINTS_CHANCE))
|
||||
{
|
||||
_points *= 2;
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.DOUBLE_POINTS_YOU_EARNED_S1_PC_POINT_S);
|
||||
points *= 2;
|
||||
message = SystemMessage.getSystemMessage(SystemMessageId.DOUBLE_POINTS_YOU_EARNED_S1_PC_POINT_S);
|
||||
}
|
||||
else
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_EARNED_S1_PC_POINT_S2);
|
||||
message = SystemMessage.getSystemMessage(SystemMessageId.YOU_EARNED_S1_PC_POINT_S2);
|
||||
}
|
||||
if ((player.getPcBangPoints() + _points) > Config.MAX_PC_BANG_POINTS)
|
||||
if ((player.getPcBangPoints() + points) > Config.PC_BANG_MAX_POINTS)
|
||||
{
|
||||
_points = Config.MAX_PC_BANG_POINTS - player.getPcBangPoints();
|
||||
points = Config.PC_BANG_MAX_POINTS - player.getPcBangPoints();
|
||||
}
|
||||
sm.addLong(_points);
|
||||
player.sendPacket(sm);
|
||||
player.setPcBangPoints(player.getPcBangPoints() + _points);
|
||||
player.sendPacket(new ExPCCafePointInfo(player.getPcBangPoints(), _points, 1));
|
||||
message.addLong(points);
|
||||
player.sendPacket(message);
|
||||
player.setPcBangPoints(player.getPcBangPoints() + points);
|
||||
player.sendPacket(new ExPCCafePointInfo(player.getPcBangPoints(), points, 1));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the single instance of {@code PcCafePointsManager}.
|
||||
* @return single instance of {@code PcCafePointsManager}
|
||||
*/
|
||||
public static final PcCafePointsManager getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PcCafePointsManager _instance = new PcCafePointsManager();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user