@ -5916,202 +5916,11 @@ public class PlayerCharacter extends AbstractCharacter {
				@@ -5916,202 +5916,11 @@ public class PlayerCharacter extends AbstractCharacter {
					 
			
		
	
		
			
				
					            // Reset this char's frame time.
   
			
		
	
		
			
				
					            this . lastUpdateTime  =  System . currentTimeMillis ( ) ;   
			
		
	
		
			
				
					            this . lastStamUpdateTime  =  System . currentTimeMillis ( ) ;   
			
		
	
		
			
				
					        //this.updateMovementState();
   
			
		
	
		
			
				
					        ///boolean updateHealth = this.regenerateHealth();
   
			
		
	
		
			
				
					        //boolean updateMana = this.regenerateMana();
   
			
		
	
		
			
				
					        //boolean updateStamina = this.regenerateStamina();
   
			
		
	
		
			
				
					        //boolean consumeStamina = this.consumeStamina();
   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        if  ( this . timestamps . get ( "SyncClient" )  +  5000L  <  System . currentTimeMillis ( ) )  {   
			
		
	
		
			
				
					            //if (updateHealth || updateMana || updateStamina || consumeStamina) {
   
			
		
	
		
			
				
					                this . syncClient ( ) ;   
			
		
	
		
			
				
					                this . timestamps . put ( "SyncClient" ,  System . currentTimeMillis ( ) ) ;   
			
		
	
		
			
				
					            //}
   
			
		
	
		
			
				
					        }   
			
		
	
		
			
				
					    }   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    public  boolean  regenerateHealth ( ) {   
			
		
	
		
			
				
					        Long  regenTime ;   
			
		
	
		
			
				
					        Long  currentTime  =  System . currentTimeMillis ( ) ;   
			
		
	
		
			
				
					        regenTime  =  this . timestamps . getOrDefault ( "LastRegenHealth" ,  currentTime ) ;   
			
		
	
		
			
				
					        float  secondsPassed  =  ( currentTime  -  regenTime )  /  1000f ;   
			
		
	
		
			
				
					        float  onePercent  =  this . healthMax  *  0 . 01f ;   
			
		
	
		
			
				
					        float  rate  =  1 . 0f  /  RecoveryType . getRecoveryType ( this ) . healthRate ;   
			
		
	
		
			
				
					        rate  * =  this . getRegenModifier ( ModType . HealthRecoverRate ) ;   
			
		
	
		
			
				
					        rate  * =  this . combatStats . healthRegen ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        if ( this . isMoving ( )  & &  ! this . walkMode )   
			
		
	
		
			
				
					            rate  =  0 . 0f ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        float  healthRegenerated  =  onePercent  *  rate  *  secondsPassed ;   
			
		
	
		
			
				
					        //ChatManager.chatSystemInfo(this,"HEALTH REGENERATED: " + healthRegenerated + " SECONDS PASSED: " + secondsPassed);
   
			
		
	
		
			
				
					        ChatManager . chatSystemInfo ( this , "HEALTH : "  +  Math . round ( this . health . get ( ) )  +  " / "  +  this . healthMax ) ;   
			
		
	
		
			
				
					        boolean  workedHealth  =  false ;   
			
		
	
		
			
				
					        float  old  =  this . health . get ( ) ;   
			
		
	
		
			
				
					        float  mod  =  old  +  healthRegenerated ;   
			
		
	
		
			
				
					        while ( ! workedHealth )  {   
			
		
	
		
			
				
					            if  ( mod  >  this . healthMax )   
			
		
	
		
			
				
					                mod  =  healthMax ;   
			
		
	
		
			
				
					            else  if  ( mod  < =  0 )  {   
			
		
	
		
			
				
					                if  ( this . isAlive . compareAndSet ( true ,  false ) )   
			
		
	
		
			
				
					                    killCharacter ( "Water" ) ;   
			
		
	
		
			
				
					                return  false ;   
			
		
	
		
			
				
					            }   
			
		
	
		
			
				
					            workedHealth  =  this . health . compareAndSet ( old ,  mod ) ;   
			
		
	
		
			
				
					        }   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        this . timestamps . put ( "LastRegenHealth" , currentTime ) ;   
			
		
	
		
			
				
					        return  mod  >  old ;   
			
		
	
		
			
				
					    }   
			
		
	
		
			
				
					    public  boolean  regenerateMana ( ) {   
			
		
	
		
			
				
					        Long  regenTime ;   
			
		
	
		
			
				
					        Long  currentTime  =  System . currentTimeMillis ( ) ;   
			
		
	
		
			
				
					        regenTime  =  this . timestamps . getOrDefault ( "LastRegenMana" ,  currentTime ) ;   
			
		
	
		
			
				
					        float  secondsPassed  =  ( currentTime  -  regenTime )  /  1000f ;   
			
		
	
		
			
				
					        float  onePercent  =  this . manaMax  *  0 . 01f ;   
			
		
	
		
			
				
					        float  rate  =  1 . 0f  /  RecoveryType . getRecoveryType ( this ) . manaRate ;   
			
		
	
		
			
				
					        rate  * =  this . combatStats . manaRegen ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        if ( this . isMoving ( )  & &  ! this . walkMode )   
			
		
	
		
			
				
					            rate  =  0 . 0f ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        float  manaRegenerated  =  onePercent  *  secondsPassed  *  rate ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        boolean  workedMana  =  false ;   
			
		
	
		
			
				
					        float   old  =  this . mana . get ( ) ;   
			
		
	
		
			
				
					        float  mod  =  old  +  manaRegenerated ;   
			
		
	
		
			
				
					        while ( ! workedMana )  {   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					            if  ( mod  >  this . manaMax )   
			
		
	
		
			
				
					                mod  =  manaMax ;   
			
		
	
		
			
				
					            else  if  ( mod  <  0 )   
			
		
	
		
			
				
					                mod  =  0 ;   
			
		
	
		
			
				
					            workedMana  =  this . mana . compareAndSet ( old ,  mod ) ;   
			
		
	
		
			
				
					        }   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        this . timestamps . put ( "LastRegenMana" , currentTime ) ;   
			
		
	
		
			
				
					        return  mod  >  old ;   
			
		
	
		
			
				
					    }   
			
		
	
		
			
				
					    public  boolean  regenerateStamina ( ) {   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        Long  currentTime  =  System . currentTimeMillis ( ) ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        if ( this . isMoving ( )  | |  this . isFlying ( )  | |  ! this . canBreathe )  {   
			
		
	
		
			
				
					            this . timestamps . put ( "LastRegenStamina" , currentTime ) ;   
			
		
	
		
			
				
					            return  false ;   
			
		
	
		
			
				
					        }   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        Long  regenTime ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        regenTime  =  this . timestamps . getOrDefault ( "LastRegenStamina" ,  currentTime ) ;   
			
		
	
		
			
				
					        float  secondsPassed  =  ( currentTime  -  regenTime )  /  1000f ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        float  secondsToRecover1  =  RecoveryType . getRecoveryType ( this ) . staminaRate ;   
			
		
	
		
			
				
					        secondsToRecover1  * =  this . combatStats . staminaRegen ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        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 ;   
			
		
	
		
			
				
					        float  old  =  this . stamina . get ( ) ;   
			
		
	
		
			
				
					        float  mod  =  old  +  staminaRegenerated ;   
			
		
	
		
			
				
					        while  ( ! workedStamina )  {   
			
		
	
		
			
				
					            if  ( mod  >  this . staminaMax )   
			
		
	
		
			
				
					                mod  =  staminaMax ;   
			
		
	
		
			
				
					            else  if  ( mod  <  0 )   
			
		
	
		
			
				
					                mod  =  0 ;   
			
		
	
		
			
				
					            workedStamina  =  this . stamina . compareAndSet ( old ,  mod ) ;   
			
		
	
		
			
				
					        }   
			
		
	
		
			
				
					        //ChatManager.chatSystemInfo(this, "STAM: " + this.stamina.get() + " / " + this.staminaMax);
   
			
		
	
		
			
				
					        this . timestamps . put ( "LastRegenStamina" ,  currentTime ) ;   
			
		
	
		
			
				
					        return  mod  >  old ;   
			
		
	
		
			
				
					    }   
			
		
	
		
			
				
					    public  boolean  consumeStamina ( ) {   
			
		
	
		
			
				
					        Long  regenTime ;   
			
		
	
		
			
				
					        Long  currentTime  =  System . currentTimeMillis ( ) ;   
			
		
	
		
			
				
					        regenTime  =  this . timestamps . getOrDefault ( "LastConsumeStamina" ,  currentTime ) ;   
			
		
	
		
			
				
					        float  secondsPassed  =  ( currentTime  -  regenTime )  /  1000f ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        float  consumption ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        if ( ! this . isMoving ( )  & &  ! this . isFlying ( )  & &  this . canBreathe )  {   
			
		
	
		
			
				
					            this . timestamps . put ( "LastConsumeStamina" , currentTime ) ;   
			
		
	
		
			
				
					            return  false ;   
			
		
	
		
			
				
					        }   
			
		
	
		
			
				
					        if ( ! this . combat ) {   
			
		
	
		
			
				
					            consumption  =  0 . 4f  *  secondsPassed ;   
			
		
	
		
			
				
					        } else {   
			
		
	
		
			
				
					            consumption  =  0 . 65f  *  secondsPassed ;   
			
		
	
		
			
				
					        }   
			
		
	
		
			
				
					        if ( ! this . canBreathe )   
			
		
	
		
			
				
					            consumption  =  1 . 5f  *  secondsPassed ;   
			
		
	
		
			
				
					        else  if ( this . isFlying ( ) )   
			
		
	
		
			
				
					            consumption  =  2 . 0f  *  secondsPassed ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        boolean  workedStamina  =  false ;   
			
		
	
		
			
				
					        float  old  =  this . stamina . get ( ) ;   
			
		
	
		
			
				
					        float  mod  =  old  -  consumption ;   
			
		
	
		
			
				
					        while  ( ! workedStamina )  {   
			
		
	
		
			
				
					            if  ( mod  < =  0 )   
			
		
	
		
			
				
					                mod  =  0 ;   
			
		
	
		
			
				
					            workedStamina  =  this . stamina . compareAndSet ( old ,  mod ) ;   
			
		
	
		
			
				
					        }   
			
		
	
		
			
				
					        //ChatManager.chatSystemInfo(this, "STAM: " + this.stamina.get() + " / " + this.staminaMax);
   
			
		
	
		
			
				
					        this . timestamps . put ( "LastConsumeStamina" , currentTime ) ;   
			
		
	
		
			
				
					        if ( this . stamina . get ( )  = =  0 ) {   
			
		
	
		
			
				
					            return  this . consumeHealth ( secondsPassed ) ;   
			
		
	
		
			
				
					        }   
			
		
	
		
			
				
					        return  mod  <  old ;   
			
		
	
		
			
				
					    }   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    public  boolean  consumeHealth ( float  secondsPassed ) {   
			
		
	
		
			
				
					        float  consumption  =  2 . 0f  *  secondsPassed ;   
			
		
	
		
			
				
					        boolean  workedHealth  =  false ;   
			
		
	
		
			
				
					        float  old  =  this . health . get ( ) ;   
			
		
	
		
			
				
					        float  mod  =  old  -  consumption ;   
			
		
	
		
			
				
					        while ( ! workedHealth )  {   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					            if  ( mod  >  this . healthMax )   
			
		
	
		
			
				
					                mod  =  healthMax ;   
			
		
	
		
			
				
					            else  if  ( mod  < =  0 )  {   
			
		
	
		
			
				
					                if  ( this . isAlive . compareAndSet ( true ,  false ) )   
			
		
	
		
			
				
					                    killCharacter ( "Water" ) ;   
			
		
	
		
			
				
					                return  true ;   
			
		
	
		
			
				
					            }   
			
		
	
		
			
				
					            workedHealth  =  this . health . compareAndSet ( old ,  mod ) ;   
			
		
	
		
			
				
					        }   
			
		
	
		
			
				
					        return  mod  <  old ;   
			
		
	
		
			
				
					    }   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    enum  RecoveryType {   
			
		
	
		
			
				
					        //Values for health and mana are in terms of the number of seconds it takes to recover 1% of max pool
   
			
		
	
		
			
				
					        //Values for stamina are in terms of the number of seconds it takes to recover 1 point
   
			
		
	
		
			
				
					        RESTING ( 3 . 0f , 1 . 2f , 0 . 5f ) ,  //sitting
   
			
		
	
		
			
				
					        IDLING ( 15 . 0f , 6 . 0f , 5 . 0f ) ,  //standing not moving
   
			
		
	
		
			
				
					        WALKING ( 20 . 0f , 8 . 0f , 0 . 0f ) ,  // moving in walk mode
   
			
		
	
		
			
				
					        RUNNING ( 0 . 0f , 0 . 0f , 0 . 0f ) ;  // moving in run mode
   
			
		
	
		
			
				
					        public  float  healthRate ;   
			
		
	
		
			
				
					        public  float  manaRate ;   
			
		
	
		
			
				
					        public  float  staminaRate ;   
			
		
	
		
			
				
					        RecoveryType ( float  health ,  float  mana ,  float  stamina )  {   
			
		
	
		
			
				
					            this . healthRate  =  health ;   
			
		
	
		
			
				
					            this . manaRate  =  mana ;   
			
		
	
		
			
				
					            this . staminaRate  =  stamina ;   
			
		
	
		
			
				
					        }   
			
		
	
		
			
				
					        public  static  RecoveryType  getRecoveryType ( PlayerCharacter  pc ) {   
			
		
	
		
			
				
					            if  ( pc . isMoving ( ) )  {   
			
		
	
		
			
				
					                if ( pc . walkMode ) {   
			
		
	
		
			
				
					                    return  RecoveryType . WALKING ;   
			
		
	
		
			
				
					                } else {   
			
		
	
		
			
				
					                    return  RecoveryType . RUNNING ;   
			
		
	
		
			
				
					                }   
			
		
	
		
			
				
					            } else  if ( pc . isSit ( ) ) {   
			
		
	
		
			
				
					                return  RecoveryType . RESTING ;   
			
		
	
		
			
				
					            } else {   
			
		
	
		
			
				
					                return  RecoveryType . IDLING ;   
			
		
	
		
			
				
					            }   
			
		
	
		
			
				
					                InterestManager . setObjectDirty ( this ) ;   
			
		
	
		
			
				
					        }   
			
		
	
		
			
				
					    }   
			
		
	
		
			
				
					}