@ -2,6 +2,8 @@ package engine.objects;
				@@ -2,6 +2,8 @@ package engine.objects;
					 
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					import  engine.Enum ;  
			
		
	
		
			
				
					import  engine.gameManager.ChatManager ;  
			
		
	
		
			
				
					import  engine.math.Vector2f ;  
			
		
	
		
			
				
					import  engine.math.Vector3fImmutable ;  
			
		
	
		
			
				
					import  engine.powers.EffectsBase ;  
			
		
	
		
			
				
					import  engine.powers.effectmodifiers.AbstractEffectModifier ;  
			
		
	
		
			
				
					import  engine.server.MBServerStatics ;  
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -252,6 +254,18 @@ public class PlayerCombatStats {
				@@ -252,6 +254,18 @@ public class PlayerCombatStats {
					 
			
		
	
		
			
				
					        HIT_VALUE_MAP . put ( 2 . 50f ,  100f ) ;   
			
		
	
		
			
				
					    }   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    //Values for health and mana are in terms of the number of seconds it takes to recover 1%
   
			
		
	
		
			
				
					    //Values for stamina are in terms of the number of seconds it takes to recover 1 point
   
			
		
	
		
			
				
					    //HEALTH//MANA//STAMINA
   
			
		
	
		
			
				
					    private  static  Vector3fImmutable  resting  =  new  Vector3fImmutable ( 3 . 0f , 1 . 2f , 0 . 5f ) ;   
			
		
	
		
			
				
					    private  static  Vector3fImmutable  idling  =  new  Vector3fImmutable ( 15 . 0f , 6 . 0f , 5 . 0f ) ;   
			
		
	
		
			
				
					    private  static  Vector3fImmutable  walking  =  new  Vector3fImmutable ( 20 . 0f , 8 . 0f , 0 . 0f ) ;   
			
		
	
		
			
				
					    private  static  Vector3fImmutable  running  =  new  Vector3fImmutable ( 0 . 0f , 0 . 0f , 0 . 0f ) ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    //#Values for how fast mana is consumed.  The first is how fast when player is not in combat
   
			
		
	
		
			
				
					    //#mode, the second is when he IS in combat mode.  This is in Stamina reduction per second.
   
			
		
	
		
			
				
					    private  static  Vector2f  consumption  =  new  Vector2f ( 0 . 4f , 0 . 65f ) ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    public  PlayerCombatStats ( PlayerCharacter  pc )  {   
			
		
	
		
			
				
					        this . owner  =  pc ;   
			
		
	
		
			
				
					        this . update ( ) ;   
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -324,6 +338,11 @@ public class PlayerCombatStats {
				@@ -324,6 +338,11 @@ public class PlayerCombatStats {
					 
			
		
	
		
			
				
					        }  catch  ( Exception  e )  {   
			
		
	
		
			
				
					            //Logger.error("FAILED TO CALCULATE Defense FOR: " + this.owner.getObjectUUID());
   
			
		
	
		
			
				
					        }   
			
		
	
		
			
				
					        try {   
			
		
	
		
			
				
					            this . doRegen ( ) ;   
			
		
	
		
			
				
					        } catch ( Exception  ignored ) {   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        }   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    }   
			
		
	
		
			
				
					
 
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -868,4 +887,80 @@ public class PlayerCombatStats {
				@@ -868,4 +887,80 @@ public class PlayerCombatStats {
					 
			
		
	
		
			
				
					        return  HIT_VALUE_MAP . get ( key ) ;   
			
		
	
		
			
				
					    }   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    public  void  doRegen ( ) {   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        long  current  =  System . currentTimeMillis ( ) ;   
			
		
	
		
			
				
					        Vector3fImmutable  regenRate ;   
			
		
	
		
			
				
					        PlayerCharacter  pc  =  this . owner ;   
			
		
	
		
			
				
					        if ( ! pc . timestamps . containsKey ( "LastRegen" ) ) {   
			
		
	
		
			
				
					            pc . timestamps . put ( "LastRegen" ,  current ) ;   
			
		
	
		
			
				
					        }   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        if ( pc . isSit ( ) ) {   
			
		
	
		
			
				
					            regenRate  =  resting ;   
			
		
	
		
			
				
					        }  else  if ( ! pc . isMoving ( ) ) {   
			
		
	
		
			
				
					            regenRate  =  idling ;   
			
		
	
		
			
				
					        } else {   
			
		
	
		
			
				
					            if ( pc . isWalk ( ) ) {   
			
		
	
		
			
				
					                regenRate  =  walking ;   
			
		
	
		
			
				
					            } else {   
			
		
	
		
			
				
					                regenRate  =  running ;   
			
		
	
		
			
				
					            }   
			
		
	
		
			
				
					        }   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        double  secondsPassed  =  current  -  pc . timestamps . get ( "LastRegen" )  *  0 . 001f ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        double  healthRegenerated  =  0 . 01f  /  regenRate . x ;   
			
		
	
		
			
				
					        double  manaRegenerated  =  0 . 01f  /  regenRate . y ;   
			
		
	
		
			
				
					        if ( pc . bonuses  ! =  null ) {   
			
		
	
		
			
				
					            healthRegenerated  * =  1  +  pc . bonuses . getFloatPercentAll ( Enum . ModType . HealthRecoverRate ,  Enum . SourceType . None ) ;   
			
		
	
		
			
				
					            manaRegenerated  * =  1  +  pc . bonuses . getFloatPercentAll ( Enum . ModType . ManaRecoverRate ,  Enum . SourceType . None ) ;   
			
		
	
		
			
				
					        }   
			
		
	
		
			
				
					        healthRegenerated  * =  pc . healthMax  *  secondsPassed ;   
			
		
	
		
			
				
					        manaRegenerated  * =  pc . manaMax  *  secondsPassed ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        double  newHealth  =  pc . health . get ( )  +  healthRegenerated ;   
			
		
	
		
			
				
					        double  newMana  =  pc . mana . get ( )  +  manaRegenerated ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        if ( newHealth  >  pc . healthMax )   
			
		
	
		
			
				
					            newHealth  =  pc . healthMax ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        if ( newMana  >  pc . manaMax )   
			
		
	
		
			
				
					            newMana  =  pc . manaMax ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        pc . health . compareAndSet ( pc . health . get ( ) ,  ( float )  newHealth ) ;   
			
		
	
		
			
				
					        pc . mana . compareAndSet ( pc . mana . get ( ) ,  ( float )  newMana ) ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        if ( regenRate . z  >  0 )  {   
			
		
	
		
			
				
					            //recover stamina
   
			
		
	
		
			
				
					            double  staminaRegenerated  =  1  /  regenRate . z ;   
			
		
	
		
			
				
					            if  ( pc . bonuses  ! =  null )  {   
			
		
	
		
			
				
					                staminaRegenerated  * =  1  +  pc . bonuses . getFloatPercentAll ( Enum . ModType . StaminaRecoverRate ,  Enum . SourceType . None ) ;   
			
		
	
		
			
				
					            }   
			
		
	
		
			
				
					            double  newStamina  =  pc . stamina . get ( )  +  staminaRegenerated ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					            if ( newStamina  >  pc . staminaMax )   
			
		
	
		
			
				
					                newStamina  =  pc . staminaMax ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					            pc . stamina . compareAndSet ( pc . stamina . get ( ) ,  ( float )  newStamina ) ;   
			
		
	
		
			
				
					        } else {   
			
		
	
		
			
				
					            //consume stamina
   
			
		
	
		
			
				
					            if ( pc . isMoving ( ) ) {   
			
		
	
		
			
				
					                double  newStamina ;   
			
		
	
		
			
				
					                if ( pc . walkMode ) {   
			
		
	
		
			
				
					                    //walking
   
			
		
	
		
			
				
					                    newStamina  =  consumption . x  *  secondsPassed ;   
			
		
	
		
			
				
					                } else {   
			
		
	
		
			
				
					                    //running
   
			
		
	
		
			
				
					                    newStamina  =  consumption . y  *  secondsPassed ;   
			
		
	
		
			
				
					                }   
			
		
	
		
			
				
					                if ( newStamina  <  0 )   
			
		
	
		
			
				
					                    newStamina  =  0 ;   
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					                pc . stamina . compareAndSet ( pc . stamina . get ( ) ,  pc . stamina . get ( )  -  ( float )  newStamina ) ;   
			
		
	
		
			
				
					                if ( newStamina  = =  0  & &  pc . isSwimming ( ) )   
			
		
	
		
			
				
					                    pc . health . compareAndSet ( pc . health . get ( ) ,  pc . health . get ( )  -  ( float )  newStamina ) ;   
			
		
	
		
			
				
					            }   
			
		
	
		
			
				
					        }   
			
		
	
		
			
				
					    }   
			
		
	
		
			
				
					}