|
|
@ -5871,10 +5871,12 @@ public class PlayerCharacter extends AbstractCharacter { |
|
|
|
this.resetRegenUpdateTime(); |
|
|
|
this.resetRegenUpdateTime(); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
regenerateHealth(); |
|
|
|
this.updateMovementState(); |
|
|
|
regenerateMana(); |
|
|
|
this.regenerateHealth(); |
|
|
|
regenerateStamina(); |
|
|
|
this.regenerateMana(); |
|
|
|
consumeStamina(); |
|
|
|
this.regenerateStamina(); |
|
|
|
|
|
|
|
this.consumeStamina(); |
|
|
|
|
|
|
|
this.syncClient(); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
Logger.error(e); |
|
|
|
Logger.error(e); |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
@ -5944,17 +5946,26 @@ public class PlayerCharacter extends AbstractCharacter { |
|
|
|
this.timestamps.put("LastRegenMana",currentTime); |
|
|
|
this.timestamps.put("LastRegenMana",currentTime); |
|
|
|
} |
|
|
|
} |
|
|
|
public void regenerateStamina(){ |
|
|
|
public void regenerateStamina(){ |
|
|
|
if(this.isMoving()) |
|
|
|
|
|
|
|
|
|
|
|
Long currentTime = System.currentTimeMillis(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(this.isMoving() || this.isFlying() || !this.canBreathe) { |
|
|
|
|
|
|
|
this.timestamps.put("LastRegenStamina",currentTime); |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Long regenTime; |
|
|
|
Long regenTime; |
|
|
|
Long currentTime = System.currentTimeMillis(); |
|
|
|
|
|
|
|
regenTime = this.timestamps.getOrDefault("LastRegenStamina", currentTime); |
|
|
|
regenTime = this.timestamps.getOrDefault("LastRegenStamina", currentTime); |
|
|
|
float secondsPassed = (currentTime - regenTime) / 1000f; |
|
|
|
float secondsPassed = (currentTime - regenTime) / 1000f; |
|
|
|
|
|
|
|
|
|
|
|
float rate = RecoveryType.getRecoveryType(this).staminaRate; |
|
|
|
float secondsToRecover1 = RecoveryType.getRecoveryType(this).staminaRate; |
|
|
|
rate *= this.getRegenModifier(ModType.StaminaRecoverRate); // Adjust rate with modifiers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float staminaRegenerated = secondsPassed / rate; // Stamina regenerates 1 point per `rate` seconds
|
|
|
|
float ratio = secondsPassed / secondsToRecover1; |
|
|
|
|
|
|
|
//rate *= this.getRegenModifier(ModType.StaminaRecoverRate); // Adjust rate with modifiers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//float staminaRegenerated = secondsPassed / rate; // Stamina regenerates 1 point per `rate` seconds
|
|
|
|
|
|
|
|
float staminaRegenerated = secondsPassed * ratio; // Stamina regenerates 1 point per `rate` seconds
|
|
|
|
|
|
|
|
|
|
|
|
boolean workedStamina = false; |
|
|
|
boolean workedStamina = false; |
|
|
|
float old, mod; |
|
|
|
float old, mod; |
|
|
@ -5967,7 +5978,7 @@ public class PlayerCharacter extends AbstractCharacter { |
|
|
|
mod = 0; |
|
|
|
mod = 0; |
|
|
|
workedStamina = this.stamina.compareAndSet(old, mod); |
|
|
|
workedStamina = this.stamina.compareAndSet(old, mod); |
|
|
|
} |
|
|
|
} |
|
|
|
//ChatManager.chatSystemInfo(this, "STAM: " + this.stamina.get() + " / " + this.staminaMax);
|
|
|
|
ChatManager.chatSystemInfo(this, "STAM: " + this.stamina.get() + " / " + this.staminaMax); |
|
|
|
this.timestamps.put("LastRegenStamina", currentTime); |
|
|
|
this.timestamps.put("LastRegenStamina", currentTime); |
|
|
|
} |
|
|
|
} |
|
|
|
public void consumeStamina(){ |
|
|
|
public void consumeStamina(){ |
|
|
@ -5977,7 +5988,8 @@ public class PlayerCharacter extends AbstractCharacter { |
|
|
|
float secondsPassed = (currentTime - regenTime) / 1000f; |
|
|
|
float secondsPassed = (currentTime - regenTime) / 1000f; |
|
|
|
|
|
|
|
|
|
|
|
float consumption; |
|
|
|
float consumption; |
|
|
|
if(!this.isMoving() && !this.isFlying()) { |
|
|
|
|
|
|
|
|
|
|
|
if(!this.isMoving() && !this.isFlying() && this.canBreathe) { |
|
|
|
this.timestamps.put("LastConsumeStamina",currentTime); |
|
|
|
this.timestamps.put("LastConsumeStamina",currentTime); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -5986,8 +5998,10 @@ public class PlayerCharacter extends AbstractCharacter { |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
consumption = 0.65f * secondsPassed; |
|
|
|
consumption = 0.65f * secondsPassed; |
|
|
|
} |
|
|
|
} |
|
|
|
if(!this.canBreathe || this.isFlying()) |
|
|
|
if(this.canBreathe) |
|
|
|
consumption *= 2; |
|
|
|
consumption = 1.5f * secondsPassed; |
|
|
|
|
|
|
|
else if(this.isFlying()) |
|
|
|
|
|
|
|
consumption = 2.0f * secondsPassed; |
|
|
|
|
|
|
|
|
|
|
|
boolean workedStamina = false; |
|
|
|
boolean workedStamina = false; |
|
|
|
float old,mod; |
|
|
|
float old,mod; |
|
|
@ -5998,7 +6012,7 @@ public class PlayerCharacter extends AbstractCharacter { |
|
|
|
mod = 0; |
|
|
|
mod = 0; |
|
|
|
workedStamina = this.stamina.compareAndSet(old, mod); |
|
|
|
workedStamina = this.stamina.compareAndSet(old, mod); |
|
|
|
} |
|
|
|
} |
|
|
|
//ChatManager.chatSystemInfo(this, "CONSUMED STAM: " + consumption);
|
|
|
|
ChatManager.chatSystemInfo(this, "STAM: " + this.stamina.get() + " / " + this.staminaMax); |
|
|
|
this.timestamps.put("LastConsumeStamina",currentTime); |
|
|
|
this.timestamps.put("LastConsumeStamina",currentTime); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|