From 486fce400f1420a9b0ee023e755fe7e4057f395e Mon Sep 17 00:00:00 2001 From: sp1ky Date: Mon, 28 Nov 2011 23:07:29 +0000 Subject: [PATCH] Power regeneration rate increase as power decreases --- src/com/massivecraft/factions/Conf.java | 2 ++ src/com/massivecraft/factions/FPlayer.java | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/com/massivecraft/factions/Conf.java b/src/com/massivecraft/factions/Conf.java index 6a936efc..3685f1e6 100644 --- a/src/com/massivecraft/factions/Conf.java +++ b/src/com/massivecraft/factions/Conf.java @@ -34,6 +34,8 @@ public class Conf public static double powerPlayerMin = -10.0; 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 scaleNegativePower = false; // Power regeneration rate increase as power decreases + public static double scaleNegativeDivisor = 40.0; // Divisor for inverse power regeneration curve public static boolean powerRegenOffline = false; // does player power regenerate even while they're offline? public static double powerOfflineLossPerDay = 0.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 diff --git a/src/com/massivecraft/factions/FPlayer.java b/src/com/massivecraft/factions/FPlayer.java index a236c7fd..18e8ec0e 100644 --- a/src/com/massivecraft/factions/FPlayer.java +++ b/src/com/massivecraft/factions/FPlayer.java @@ -377,9 +377,15 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator long now = System.currentTimeMillis(); long millisPassed = now - this.lastPowerUpdateTime; this.lastPowerUpdateTime = now; + + int millisPerMinute = 60*1000; + double powerPerMinute = Conf.powerPerMinute; + if(Conf.scaleNegativePower && this.power < 0) + { + powerPerMinute += (Math.sqrt(Math.abs(this.power)) * Math.abs(this.power)) / Conf.scaleNegativeDivisor; + } + this.alterPower(millisPassed * powerPerMinute / millisPerMinute); - int millisPerMinute = 60*1000; - this.alterPower(millisPassed * Conf.powerPerMinute / millisPerMinute); } protected void losePowerFromBeingOffline()