|
|
@ -887,4 +887,142 @@ public class PlayerCombatStats { |
|
|
|
return HIT_VALUE_MAP.get(key); |
|
|
|
return HIT_VALUE_MAP.get(key); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void regenerate(){ |
|
|
|
|
|
|
|
healthRegen(this.owner); |
|
|
|
|
|
|
|
manaRegen(this.owner); |
|
|
|
|
|
|
|
staminaRegen(this.owner); |
|
|
|
|
|
|
|
staminaConsume(this.owner); |
|
|
|
|
|
|
|
this.owner.syncClient(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public static void healthRegen(PlayerCharacter pc){ |
|
|
|
|
|
|
|
if(!pc.timestamps.containsKey("LASTHEALTHREGEN")) |
|
|
|
|
|
|
|
pc.timestamps.put("LASTHEALTHREGEN",System.currentTimeMillis()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float stateMultiplier = 1.0f; |
|
|
|
|
|
|
|
if(pc.isSit()) |
|
|
|
|
|
|
|
stateMultiplier = 2.0f; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long deltaTime = System.currentTimeMillis() - pc.timestamps.get("LASTHEALTHREGEN"); |
|
|
|
|
|
|
|
float current = pc.health.get(); |
|
|
|
|
|
|
|
float onePercent = pc.healthMax * 0.01f; |
|
|
|
|
|
|
|
float mod = current + ((deltaTime * 0.001f) * onePercent * stateMultiplier); |
|
|
|
|
|
|
|
if(pc.bonuses != null) |
|
|
|
|
|
|
|
mod *= 1 + pc.bonuses.getFloatPercentAll(Enum.ModType.HealthRecoverRate, Enum.SourceType.None); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean worked = false; |
|
|
|
|
|
|
|
if(mod > pc.healthMax) |
|
|
|
|
|
|
|
mod = pc.healthMax; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (!worked) { |
|
|
|
|
|
|
|
worked = pc.health.compareAndSet(current, mod); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pc.timestamps.put("LASTHEALTHREGEN",System.currentTimeMillis()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void manaRegen(PlayerCharacter pc){ |
|
|
|
|
|
|
|
if(!pc.timestamps.containsKey("LASTMANAREGEN")) |
|
|
|
|
|
|
|
pc.timestamps.put("LASTMANAREGEN",System.currentTimeMillis()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float stateMultiplier = 1.0f; |
|
|
|
|
|
|
|
if(pc.isSit()) |
|
|
|
|
|
|
|
stateMultiplier = 2.0f; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long deltaTime = System.currentTimeMillis() - pc.timestamps.get("LASTMANAREGEN"); |
|
|
|
|
|
|
|
float current = pc.mana.get(); |
|
|
|
|
|
|
|
float onePercent = pc.manaMax * 0.01f; |
|
|
|
|
|
|
|
float mod = current + ((deltaTime * 0.001f) * onePercent * stateMultiplier); |
|
|
|
|
|
|
|
if(pc.bonuses != null) |
|
|
|
|
|
|
|
mod *= 1 + pc.bonuses.getFloatPercentAll(Enum.ModType.ManaRecoverRate, Enum.SourceType.None); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean worked = false; |
|
|
|
|
|
|
|
if(mod > pc.manaMax) |
|
|
|
|
|
|
|
mod = pc.manaMax; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (!worked) { |
|
|
|
|
|
|
|
worked = pc.mana.compareAndSet(current, mod); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pc.timestamps.put("LASTMANAREGEN",System.currentTimeMillis()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void staminaRegen(PlayerCharacter pc){ |
|
|
|
|
|
|
|
//cannot regen is moving, swimming or flying
|
|
|
|
|
|
|
|
if(pc.isFlying() && pc.isSwimming() && pc.isMoving()) { |
|
|
|
|
|
|
|
pc.timestamps.put("LASTSTAMINAREGEN",System.currentTimeMillis()); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!pc.timestamps.containsKey("LASTSTAMINAREGEN")) |
|
|
|
|
|
|
|
pc.timestamps.put("LASTSTAMINAREGEN",System.currentTimeMillis()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float stateMultiplier = 1.0f; |
|
|
|
|
|
|
|
if(pc.isSit()) |
|
|
|
|
|
|
|
stateMultiplier = 2.0f; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long deltaTime = System.currentTimeMillis() - pc.timestamps.get("LASTSTAMINAREGEN"); |
|
|
|
|
|
|
|
float current = pc.stamina.get(); |
|
|
|
|
|
|
|
float mod = current + ((deltaTime * 0.001f) * stateMultiplier); |
|
|
|
|
|
|
|
if(pc.bonuses != null) |
|
|
|
|
|
|
|
mod *= 1 + pc.bonuses.getFloatPercentAll(Enum.ModType.StaminaRecoverRate, Enum.SourceType.None); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean worked = false; |
|
|
|
|
|
|
|
if(mod > pc.staminaMax) |
|
|
|
|
|
|
|
mod = pc.staminaMax; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (!worked) { |
|
|
|
|
|
|
|
worked = pc.stamina.compareAndSet(current, mod); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pc.timestamps.put("LASTSTAMINACONSUME",System.currentTimeMillis()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void staminaConsume(PlayerCharacter pc){ |
|
|
|
|
|
|
|
//no natural consumption if not moving, swimming or flying
|
|
|
|
|
|
|
|
if(!pc.isFlying() && !pc.isSwimming() && !pc.isMoving()) { |
|
|
|
|
|
|
|
pc.timestamps.put("LASTSTAMINACONSUME",System.currentTimeMillis()); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//no stamina consumption for TravelStance
|
|
|
|
|
|
|
|
if(pc.containsEffect(441156479) || pc.containsEffect(441156455)) { |
|
|
|
|
|
|
|
pc.timestamps.put("LASTSTAMINACONSUME",System.currentTimeMillis()); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
float stateMultiplier = 1.0f; |
|
|
|
|
|
|
|
if(pc.isSwimming() || pc.isFlying()) |
|
|
|
|
|
|
|
stateMultiplier = 1.5f; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!pc.timestamps.containsKey("LASTSTAMINACONSUME")) |
|
|
|
|
|
|
|
pc.timestamps.put("LASTSTAMINACONSUME",System.currentTimeMillis()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long deltaTime = System.currentTimeMillis() - pc.timestamps.get("LASTSTAMINACONSUME"); |
|
|
|
|
|
|
|
float current = pc.stamina.get(); |
|
|
|
|
|
|
|
float mod = current - ((deltaTime *0.001f) * 0.6f * stateMultiplier); |
|
|
|
|
|
|
|
boolean worked = false; |
|
|
|
|
|
|
|
if(mod <= 0) |
|
|
|
|
|
|
|
mod = 0; |
|
|
|
|
|
|
|
if(mod == 0){ |
|
|
|
|
|
|
|
healthConsume(pc, (int) (deltaTime * 0.6f * 2.5f)); |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
while (!worked) { |
|
|
|
|
|
|
|
worked = pc.stamina.compareAndSet(current,mod); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
pc.timestamps.put("LASTSTAMINACONSUME",System.currentTimeMillis()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void healthConsume(PlayerCharacter pc, int amount){ |
|
|
|
|
|
|
|
boolean worked = false; |
|
|
|
|
|
|
|
float current = pc.health.get(); |
|
|
|
|
|
|
|
float mod = current = amount; |
|
|
|
|
|
|
|
if(mod <= 0){ |
|
|
|
|
|
|
|
pc.killCharacter("water"); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
while(!worked){ |
|
|
|
|
|
|
|
worked = pc.health.compareAndSet(current,mod); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|