Players now lose power over time while they are offline. New conf.json setting "powerOfflineLossPerDay" (default 1.0) is how much power they lose; note that this power loss actually occurs frequently in very tiny amounts as time passes, not just once per day. New conf.json setting "powerOfflineLossLimit" (default 0.0) which will stop offline power loss once a player's power drops to the specified amount.
As an example, the default 1.0 power loss per day offline is roughly 0.0417 power loss per hour, 0.00695 per minute, and so forth.
This commit is contained in:
parent
fa21358a23
commit
28e881d905
@ -28,6 +28,8 @@ public class Conf {
|
||||
public static double powerPerMinute = 0.2; // Default health rate... it takes 5 min to heal one power
|
||||
public static double powerPerDeath = 4.0; // A death makes you lose 4 power
|
||||
public static boolean powerRegenOffline = false; // does player power regenerate even while they're offline?
|
||||
public static double powerOfflineLossPerDay = 1.0; // players will lose this much power per day offline
|
||||
public static double powerOfflineLossLimit = 0.0; // players will no longer lose power from being offline once their power drops to this amount or less
|
||||
public static double powerFactionMax = 0.0; // if greater than 0, the cap on how much power a faction can have (additional power from players beyond that will act as a "buffer" of sorts)
|
||||
|
||||
public static String prefixAdmin = "**";
|
||||
|
@ -190,6 +190,7 @@ public class FPlayer {
|
||||
}
|
||||
|
||||
public void setLastLoginTime(long lastLoginTime) {
|
||||
losePowerFromBeingOffline();
|
||||
this.lastLoginTime = lastLoginTime;
|
||||
this.lastPowerUpdateTime = lastLoginTime;
|
||||
if (Conf.noPVPDamageToOthersForXSecondsAfterLogin > 0) {
|
||||
@ -404,9 +405,12 @@ public class FPlayer {
|
||||
}
|
||||
|
||||
protected void updatePower() {
|
||||
if (this.isOffline() && !Conf.powerRegenOffline) {
|
||||
if (this.isOffline()) {
|
||||
losePowerFromBeingOffline();
|
||||
if (!Conf.powerRegenOffline) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
long now = System.currentTimeMillis();
|
||||
long millisPassed = now - this.lastPowerUpdateTime;
|
||||
this.lastPowerUpdateTime = now;
|
||||
@ -415,6 +419,20 @@ public class FPlayer {
|
||||
this.alterPower(millisPassed * Conf.powerPerMinute / millisPerMinute);
|
||||
}
|
||||
|
||||
protected void losePowerFromBeingOffline() {
|
||||
if (Conf.powerOfflineLossPerDay > 0.0 && this.power > Conf.powerOfflineLossLimit) {
|
||||
long now = System.currentTimeMillis();
|
||||
long millisPassed = now - this.lastPowerUpdateTime;
|
||||
this.lastPowerUpdateTime = now;
|
||||
|
||||
double loss = millisPassed * Conf.powerOfflineLossPerDay / (24*60*60*1000);
|
||||
if (this.power - loss < Conf.powerOfflineLossLimit) {
|
||||
loss = this.power;
|
||||
}
|
||||
this.alterPower(-loss);
|
||||
}
|
||||
}
|
||||
|
||||
public void onDeath() {
|
||||
this.updatePower();
|
||||
this.alterPower(-Conf.powerPerDeath);
|
||||
|
Loading…
Reference in New Issue
Block a user