Browse Source

updated regen system

lakebane
FatBoy-DOTC 7 days ago
parent
commit
d142097b0f
  1. 38
      src/engine/objects/PlayerCharacter.java

38
src/engine/objects/PlayerCharacter.java

@ -5691,14 +5691,6 @@ public class PlayerCharacter extends AbstractCharacter {
} }
public void RunRegen(){ public void RunRegen(){
//this.updateRegen();
Long lastRegen;
if(this.timestamps.containsKey("LastRegen"))
lastRegen = this.timestamps.get("LastRegen");
else
lastRegen = System.currentTimeMillis();
float secondsDifference = (System.currentTimeMillis() - lastRegen) / 1000.0f;
float healthRegen = 0f; float healthRegen = 0f;
float manaRegen = 0f; float manaRegen = 0f;
@ -5722,11 +5714,10 @@ public class PlayerCharacter extends AbstractCharacter {
healthRegen *= .75f; healthRegen *= .75f;
// Characters regen mana when in only walk mode and idle // Characters regen mana when in only walk mode and idle
if (this.walkMode) if (this.walkMode)
manaRegen = ((this.manaMax * MBServerStatics.MANA_REGEN_IDLE) * getRegenModifier(ModType.ManaRecoverRate)); manaRegen = (this.manaMax * 0.01f) * getRegenModifier(ModType.ManaRecoverRate) * MBServerStatics.MANA_REGEN_WALK;
else if (!this.isCasting() && !this.isItemCasting()) else {
manaRegen = ((this.manaMax * MBServerStatics.MANA_REGEN_RUN) * getRegenModifier(ModType.ManaRecoverRate)); manaRegen = (this.manaMax * 0.01f) * getRegenModifier(ModType.ManaRecoverRate) * MBServerStatics.MANA_REGEN_IDLE;
else }
manaRegen = 0;
if (!PlayerCharacter.CanBreathe(this)) if (!PlayerCharacter.CanBreathe(this))
stamRegen = MBServerStatics.STAMINA_REGEN_SWIM; stamRegen = MBServerStatics.STAMINA_REGEN_SWIM;
@ -5841,16 +5832,25 @@ public class PlayerCharacter extends AbstractCharacter {
// Multiple regen values by current deltaTime // Multiple regen values by current deltaTime
// Logger.info("", healthRegen + ""); // Logger.info("", healthRegen + "");
healthRegen *= getDeltaTime(); long currentTime = System.currentTimeMillis();
manaRegen *= getDeltaTime(); Long regenTime;
stamRegen *= getStamDeltaTime(); if(this.timestamps.containsKey("LastRegen"))
regenTime = this.timestamps.get("LastRegen");
else
regenTime = currentTime;
float secondsPassed = (currentTime - regenTime) / 1000f;
healthRegen *= secondsPassed;
manaRegen *= secondsPassed;
stamRegen *= secondsPassed;
this.timestamps.put("LastRegen",currentTime);
ChatManager.chatSystemInfo(this,"Mana: " + this.mana.get());
boolean workedHealth = false; boolean workedHealth = false;
boolean workedMana = false; boolean workedMana = false;
boolean workedStamina = false; boolean workedStamina = false;
ChatManager.chatSystemInfo(this,"Recovering Mana: " + manaRegen);
float old, mod; float old, mod;
while (!workedHealth || !workedMana || !workedStamina) { while (!workedHealth || !workedMana || !workedStamina) {
if (!this.isAlive() || !this.isActive()) if (!this.isAlive() || !this.isActive())
@ -5887,7 +5887,7 @@ public class PlayerCharacter extends AbstractCharacter {
} }
} }
if (updateClient || secondsDifference > 2.5f) if (updateClient)
this.syncClient(); this.syncClient();
// Reset this char's frame time. // Reset this char's frame time.

Loading…
Cancel
Save