Compare commits
37 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0b18afc211 | |||
| 5670da8d96 | |||
| d2d236aa93 | |||
| 9b5d32b70b | |||
| 8e158e1d27 | |||
| 8c166c8d4b | |||
| 3b12faee9e | |||
| 243403782d | |||
| 9e1e12b177 | |||
| 1c1578595f | |||
| e5f47a7d73 | |||
| 7d80363d65 | |||
| 1a95bc8e27 | |||
| 473003ed44 | |||
| fbdca5b917 | |||
| 78dfa0c68c | |||
| a04ad2f382 | |||
| 257a8aff15 | |||
| 291a20c4d0 | |||
| eec08ce962 | |||
| 99183dc248 | |||
| 6c7f01dc72 | |||
| 6ebeb9cadf | |||
| 8e0f1090d9 | |||
| bc0bc577ea | |||
| 3b5c0e6210 | |||
| d6fa7dba9d | |||
| b5fbc8478d | |||
| b79c827d81 | |||
| b9b254f8e8 | |||
| 6834146eb2 | |||
| e9f1711120 | |||
| 29f054e192 | |||
| 7d9c5d3498 | |||
| 618353c088 | |||
| 24656b1030 | |||
| 27cb704837 |
@@ -301,6 +301,17 @@ public enum CombatManager {
|
||||
if (target == null)
|
||||
return 0;
|
||||
|
||||
//pet to assist in attacking target
|
||||
if(abstractCharacter.getObjectType().equals(GameObjectType.PlayerCharacter)){
|
||||
PlayerCharacter attacker = (PlayerCharacter)abstractCharacter;
|
||||
if(attacker.getPet() != null){
|
||||
Mob pet = attacker.getPet();
|
||||
if(pet.combatTarget == null && pet.assist)
|
||||
pet.setCombatTarget(attacker.combatTarget);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//target must be valid type
|
||||
|
||||
if (AbstractWorldObject.IsAbstractCharacter(target)) {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
package engine.mobileAI;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.InterestManagement.InterestManager;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.gameManager.*;
|
||||
import engine.math.Vector3f;
|
||||
@@ -106,6 +107,10 @@ public class MobAI {
|
||||
return;
|
||||
}
|
||||
|
||||
if(target.getPet() != null && target.getPet().isAlive()){
|
||||
mob.setCombatTarget(target.getPet());
|
||||
}
|
||||
|
||||
if (mob.BehaviourType.callsForHelp)
|
||||
MobCallForHelp(mob);
|
||||
|
||||
@@ -156,6 +161,12 @@ public class MobAI {
|
||||
if (target.getPet().getCombatTarget() == null && target.getPet().assist == true)
|
||||
target.getPet().setCombatTarget(mob);
|
||||
|
||||
try{
|
||||
InterestManager.forceLoad(mob);
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackPlayer" + " " + e.getMessage());
|
||||
}
|
||||
@@ -253,6 +264,9 @@ public class MobAI {
|
||||
target.setCombatTarget(mob);
|
||||
}
|
||||
}
|
||||
|
||||
if(target.combatTarget == null)
|
||||
target.setCombatTarget(mob);
|
||||
} catch (Exception e) {
|
||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackMob" + " " + e.getMessage());
|
||||
}
|
||||
@@ -712,8 +726,8 @@ public class MobAI {
|
||||
DefaultLogic(mob);
|
||||
break;
|
||||
}
|
||||
if(mob.isAlive())
|
||||
RecoverHealth(mob);
|
||||
//if(mob.isAlive())
|
||||
// RecoverHealth(mob);
|
||||
} catch (Exception e) {
|
||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DetermineAction" + " " + e.getMessage());
|
||||
}
|
||||
@@ -723,6 +737,10 @@ public class MobAI {
|
||||
|
||||
try {
|
||||
|
||||
//do not switch target if you already have one, dropping out of range is handled elsewhere
|
||||
if(aiAgent.combatTarget != null)
|
||||
return;
|
||||
|
||||
//looks for and sets mobs combatTarget
|
||||
|
||||
if (!aiAgent.isAlive())
|
||||
@@ -1090,17 +1108,17 @@ public class MobAI {
|
||||
if (mob.getCombatTarget() == null)
|
||||
CheckForPlayerGuardAggro(mob);
|
||||
|
||||
AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob);
|
||||
//AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob);
|
||||
|
||||
if (newTarget != null) {
|
||||
//if (newTarget != null) {
|
||||
|
||||
if (newTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
|
||||
if (GuardCanAggro(mob, (PlayerCharacter) newTarget))
|
||||
mob.setCombatTarget(newTarget);
|
||||
} else
|
||||
mob.setCombatTarget(newTarget);
|
||||
// if (newTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
|
||||
// if (GuardCanAggro(mob, (PlayerCharacter) newTarget))
|
||||
// mob.setCombatTarget(newTarget);
|
||||
// } else
|
||||
// mob.setCombatTarget(newTarget);
|
||||
|
||||
}
|
||||
//}
|
||||
CheckMobMovement(mob);
|
||||
CheckForAttack(mob);
|
||||
} catch (Exception e) {
|
||||
@@ -1186,25 +1204,24 @@ public class MobAI {
|
||||
try {
|
||||
|
||||
//check for players that can be aggroed if mob is agressive and has no target
|
||||
|
||||
if (mob.getCombatTarget() != null && mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false)
|
||||
if (mob.getCombatTarget() != null && mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false && !mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.Mob))
|
||||
mob.setCombatTarget(null);
|
||||
|
||||
if (mob.BehaviourType.isAgressive) {
|
||||
//if (mob.BehaviourType.isAgressive) {
|
||||
|
||||
AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob);
|
||||
// AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob);
|
||||
|
||||
if (newTarget != null)
|
||||
mob.setCombatTarget(newTarget);
|
||||
else {
|
||||
if (mob.getCombatTarget() == null) {
|
||||
if (mob.BehaviourType == Enum.MobBehaviourType.HamletGuard)
|
||||
SafeGuardAggro(mob); //safehold guard
|
||||
else
|
||||
CheckForAggro(mob); //normal aggro
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (newTarget != null)
|
||||
// mob.setCombatTarget(newTarget);
|
||||
// else {
|
||||
// if (mob.getCombatTarget() == null) {
|
||||
// if (mob.BehaviourType == Enum.MobBehaviourType.HamletGuard)
|
||||
// SafeGuardAggro(mob); //safehold guard
|
||||
// else
|
||||
// CheckForAggro(mob); //normal aggro
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
//check if mob can move for patrol or moving to target
|
||||
|
||||
@@ -1216,6 +1233,7 @@ public class MobAI {
|
||||
if (!mob.BehaviourType.isWimpy && mob.getCombatTarget() != null)
|
||||
CheckForAttack(mob);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DefaultLogic" + " " + e.getMessage());
|
||||
}
|
||||
|
||||
@@ -43,14 +43,13 @@ public class MobRespawnThread implements Runnable {
|
||||
if (zones != null) {
|
||||
for (Zone zone : zones) {
|
||||
synchronized (zone) { // Optional: Synchronize on zone
|
||||
if (!zone.respawnQue.isEmpty() &&
|
||||
zone.lastRespawn + RESPAWN_INTERVAL < System.currentTimeMillis()) {
|
||||
if (!Zone.respawnQue.isEmpty() && Zone.lastRespawn + RESPAWN_INTERVAL < System.currentTimeMillis()) {
|
||||
|
||||
Mob respawner = zone.respawnQue.iterator().next();
|
||||
Mob respawner = Zone.respawnQue.iterator().next();
|
||||
if (respawner != null) {
|
||||
respawner.respawn();
|
||||
zone.respawnQue.remove(respawner);
|
||||
zone.lastRespawn = System.currentTimeMillis();
|
||||
Zone.respawnQue.remove(respawner);
|
||||
Zone.lastRespawn = System.currentTimeMillis();
|
||||
Thread.sleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,12 +201,10 @@ public class CombatUtilities {
|
||||
return;
|
||||
|
||||
int anim = 75;
|
||||
float speed;
|
||||
|
||||
if (mainHand)
|
||||
speed = agent.getSpeedHandOne();
|
||||
else
|
||||
speed = agent.getSpeedHandTwo();
|
||||
//handle the retaliate here because even if the mob misses you can still retaliate
|
||||
if (AbstractWorldObject.IsAbstractCharacter(target))
|
||||
CombatManager.handleRetaliate((AbstractCharacter) target, agent);
|
||||
|
||||
DamageType dt = DamageType.Crush;
|
||||
|
||||
@@ -288,11 +286,6 @@ public class CombatUtilities {
|
||||
if (((Mob) target).isSiege())
|
||||
return;
|
||||
|
||||
//handle the retaliate
|
||||
|
||||
if (AbstractWorldObject.IsAbstractCharacter(target))
|
||||
CombatManager.handleRetaliate((AbstractCharacter) target, agent);
|
||||
|
||||
if (target.getObjectType() == GameObjectType.Mob) {
|
||||
Mob targetMob = (Mob) target;
|
||||
if (targetMob.isSiege())
|
||||
|
||||
@@ -11,6 +11,7 @@ package engine.objects;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.Enum.TargetColor;
|
||||
import engine.gameManager.LootManager;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.server.MBServerStatics;
|
||||
@@ -352,135 +353,69 @@ public class Experience {
|
||||
if(killer.pvpKills.contains(mob.getObjectUUID()))
|
||||
return;
|
||||
|
||||
double grantedExperience = 0.0;
|
||||
double baseXP;
|
||||
|
||||
if (g != null) { // Do group EXP stuff
|
||||
if(g != null) {
|
||||
//group experience
|
||||
PlayerCharacter leader = g.getGroupLead();
|
||||
float leadership = 0.0f;
|
||||
if(leader.skills.containsKey("Leadership"))
|
||||
leadership = leader.skills.get("Leadership").getModifiedAmount();
|
||||
|
||||
int leadership = 0;
|
||||
int highestLevel = 0;
|
||||
double penalty = 0.0;
|
||||
for(PlayerCharacter member : g.members){
|
||||
|
||||
ArrayList<PlayerCharacter> giveEXPTo = new ArrayList<>();
|
||||
|
||||
// Check if leader is within range of kill and then get leadership
|
||||
// skill
|
||||
|
||||
Vector3fImmutable killLoc = mob.getLoc();
|
||||
|
||||
if (killLoc.distanceSquared2D(g.getGroupLead().getLoc()) < (MBServerStatics.EXP_RANGE * MBServerStatics.EXP_RANGE)) {
|
||||
CharacterSkill leaderskill = g.getGroupLead().skills
|
||||
.get("Leadership");
|
||||
|
||||
if (leaderskill != null)
|
||||
leadership = leaderskill.getNumTrains();
|
||||
if (leadership > 90)
|
||||
leadership = 90; // leadership caps at 90%
|
||||
}
|
||||
|
||||
// Check every group member for distance to see if they get xp
|
||||
|
||||
for (PlayerCharacter pc : g.getMembers()) {
|
||||
if (pc.isAlive()) { // Skip if the player is dead.
|
||||
|
||||
// Check within range
|
||||
|
||||
if (killLoc.distanceSquared2D(pc.getLoc()) < (MBServerStatics.EXP_RANGE * MBServerStatics.EXP_RANGE)) {
|
||||
|
||||
giveEXPTo.add(pc);
|
||||
|
||||
// Track highest level character
|
||||
|
||||
if (pc.getLevel() > highestLevel)
|
||||
highestLevel = pc.getLevel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Process every player in the group getting XP
|
||||
|
||||
for (PlayerCharacter playerCharacter : giveEXPTo) {
|
||||
if (playerCharacter.getLevel() >= MBServerStatics.LEVELCAP)
|
||||
if (member.getLevel() >= MBServerStatics.LEVELCAP)
|
||||
continue;
|
||||
|
||||
if(playerCharacter.level >= 75 && !mob.getObjectType().equals(Enum.GameObjectType.PlayerCharacter))
|
||||
if(!member.isAlive())
|
||||
continue;
|
||||
|
||||
if(member.level >= 75 && !mob.getObjectType().equals(Enum.GameObjectType.PlayerCharacter))
|
||||
continue; // cannot PVE higher than level 75
|
||||
|
||||
// Sets Max XP with server exp mod taken into account.
|
||||
float range = member.loc.distanceSquared(killer.loc);
|
||||
if(range <= (MBServerStatics.CHARACTER_LOAD_RANGE * MBServerStatics.CHARACTER_LOAD_RANGE)){
|
||||
baseXP = LootManager.NORMAL_EXP_RATE * maxXPPerKill(member.getLevel());
|
||||
double mod = getConMod(member, mob);
|
||||
|
||||
grantedExperience = (double) LOOTMANAGER.NORMAL_EXP_RATE * maxXPPerKill(playerCharacter.getLevel());
|
||||
if(leadership > 0 && mod != 0)
|
||||
mod += (leadership * 0.01f);
|
||||
|
||||
// Adjust XP for Mob Level
|
||||
baseXP *= mod;
|
||||
|
||||
grantedExperience *= getConMod(playerCharacter, mob);
|
||||
if(baseXP < 1)
|
||||
baseXP = 1;
|
||||
|
||||
// Process XP for this member
|
||||
baseXP *= (1.0f / g.members.size()+0.9f);
|
||||
|
||||
penalty = getGroupMemberPenalty(leadership, playerCharacter, giveEXPTo,
|
||||
highestLevel);
|
||||
|
||||
// Leadership Penalty Reduction
|
||||
|
||||
if (leadership > 0)
|
||||
penalty -= ((leadership) * 0.01) * penalty;
|
||||
|
||||
// Modify for hotzone
|
||||
|
||||
if (grantedExperience != 0)
|
||||
if (ZoneManager.inHotZone(mob.getLoc()))
|
||||
grantedExperience *= LOOTMANAGER.HOTZONE_EXP_RATE;
|
||||
|
||||
// Check for 0 XP due to white mob, otherwise subtract penalty
|
||||
// xp
|
||||
|
||||
if (grantedExperience == 0)
|
||||
grantedExperience = 1;
|
||||
else {
|
||||
grantedExperience -= (penalty * 0.01) * grantedExperience;
|
||||
|
||||
// Errant Penalty Calculation
|
||||
if (playerCharacter.getGuild().isEmptyGuild())
|
||||
grantedExperience *= 0.6;
|
||||
member.grantXP((int) baseXP);
|
||||
}
|
||||
|
||||
if (grantedExperience == 0)
|
||||
grantedExperience = 1;
|
||||
|
||||
//scaling
|
||||
grantedExperience *= (1 / giveEXPTo.size()+0.9);
|
||||
|
||||
// Grant the player the EXP
|
||||
playerCharacter.grantXP((int) Math.floor(grantedExperience));
|
||||
}
|
||||
|
||||
} else { // Give EXP to a single character
|
||||
//if (!killer.isAlive()) // Skip if the player is dead.
|
||||
// return;
|
||||
}else{
|
||||
//solo no group
|
||||
|
||||
if (killer.getLevel() >= MBServerStatics.LEVELCAP)
|
||||
return;
|
||||
|
||||
if(killer.level >= 75 && !mob.getObjectType().equals(Enum.GameObjectType.PlayerCharacter))
|
||||
return;
|
||||
return; // cannot PVE higher than level 75
|
||||
|
||||
// Get XP and adjust for Mob Level with world xp modifier taken into account
|
||||
grantedExperience = (double) LOOTMANAGER.NORMAL_EXP_RATE * maxXPPerKill(killer.getLevel());
|
||||
grantedExperience *= getConMod(killer, mob);
|
||||
|
||||
// Modify for hotzone
|
||||
if (ZoneManager.inHotZone(mob.getLoc()))
|
||||
grantedExperience *= LOOTMANAGER.HOTZONE_EXP_RATE;
|
||||
|
||||
// Errant penalty
|
||||
if (grantedExperience != 1) {
|
||||
if (killer.getGuild().isEmptyGuild())
|
||||
grantedExperience *= 0.6f;
|
||||
baseXP = LootManager.NORMAL_EXP_RATE * maxXPPerKill(killer.getLevel());
|
||||
double mod = getConMod(killer, mob);
|
||||
float leadership = 0.0f;
|
||||
if(killer.skills.containsKey("Leadership"))
|
||||
leadership = killer.skills.get("Leadership").getModifiedAmount();
|
||||
if(leadership > 0 && mod != 0){
|
||||
mod += (leadership * 0.01f);
|
||||
}
|
||||
|
||||
//bonus for no group
|
||||
grantedExperience *= 1.9f;
|
||||
baseXP *= mod;
|
||||
if(baseXP < 1)
|
||||
baseXP = 1;
|
||||
|
||||
// Grant XP
|
||||
killer.grantXP((int) Math.floor(grantedExperience));
|
||||
baseXP *= 1.9f;
|
||||
|
||||
killer.grantXP((int) baseXP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -620,6 +620,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
DbManager.addToCache(mob);
|
||||
mob.setPet(owner, true);
|
||||
mob.setWalkMode(false);
|
||||
mob.level = level;
|
||||
mob.runAfterLoad();
|
||||
|
||||
} catch (Exception e) {
|
||||
@@ -628,8 +629,12 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
createLock.writeLock().unlock();
|
||||
}
|
||||
parent.zoneMobSet.add(mob);
|
||||
mob.level = level;
|
||||
mob.healthMax = mob.getMobBase().getHealthMax() * (mob.level * 0.5f);
|
||||
// mob.level = level;
|
||||
float healthMax = mob.getMobBase().getHealthMax();
|
||||
if(mob.bonuses != null){
|
||||
healthMax += mob.bonuses.getFloat(ModType.HealthFull,SourceType.None);
|
||||
}
|
||||
mob.healthMax = healthMax;
|
||||
mob.health.set(mob.healthMax);
|
||||
return mob;
|
||||
}
|
||||
@@ -1957,6 +1962,9 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
|
||||
}
|
||||
try {
|
||||
if(this.equipmentSetID == 6481) {
|
||||
int i = 0;
|
||||
}
|
||||
if (this.equipmentSetID != 0)
|
||||
this.equip = MobBase.loadEquipmentSet(this.equipmentSetID);
|
||||
else
|
||||
|
||||
@@ -131,16 +131,22 @@ public class MobBase extends AbstractGameObject {
|
||||
return equip;
|
||||
|
||||
for (BootySetEntry equipmentSetEntry : equipList) {
|
||||
try {
|
||||
if(equipmentSetEntry.itemBase == 189500){
|
||||
int i = 0;
|
||||
}
|
||||
MobEquipment mobEquipment = new MobEquipment(equipmentSetEntry.itemBase, equipmentSetEntry.dropChance);
|
||||
ItemBase itemBase = mobEquipment.getItemBase();
|
||||
|
||||
MobEquipment mobEquipment = new MobEquipment(equipmentSetEntry.itemBase, equipmentSetEntry.dropChance);
|
||||
ItemBase itemBase = mobEquipment.getItemBase();
|
||||
if (itemBase != null) {
|
||||
if (itemBase.getType().equals(Enum.ItemType.WEAPON))
|
||||
if (mobEquipment.getSlot() == 1 && itemBase.getEquipFlag() == 2)
|
||||
mobEquipment.setSlot(2);
|
||||
|
||||
if (itemBase != null) {
|
||||
if (itemBase.getType().equals(Enum.ItemType.WEAPON))
|
||||
if (mobEquipment.getSlot() == 1 && itemBase.getEquipFlag() == 2)
|
||||
mobEquipment.setSlot(2);
|
||||
|
||||
equip.put(mobEquipment.getSlot(), mobEquipment);
|
||||
equip.put(mobEquipment.getSlot(), mobEquipment);
|
||||
}
|
||||
}catch(Exception e){
|
||||
Logger.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,6 +314,10 @@ public class MobBase extends AbstractGameObject {
|
||||
}
|
||||
|
||||
public static void applyMobbaseEffects(Mob mob){
|
||||
if(mob.getMobBaseID() == 12008)
|
||||
mob.level = 65;
|
||||
else if(mob.getMobBaseID() == 12019)
|
||||
mob.level = 80;
|
||||
for(MobBaseEffects mbe : mob.mobBase.mobbaseEffects){
|
||||
if(mob.level >= mbe.getReqLvl()){
|
||||
try {
|
||||
|
||||
@@ -98,7 +98,11 @@ public class MobEquipment extends AbstractGameObject {
|
||||
this.dropChance = dropChance;
|
||||
|
||||
this.parentID = 0;
|
||||
setMagicValue();
|
||||
try {
|
||||
setMagicValue();
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static int getNewID() {
|
||||
|
||||
@@ -3084,7 +3084,7 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
checkGuildStatus();
|
||||
|
||||
//give gold for level up if level is under or equal to 20 and over 10
|
||||
if(!this.isBoxed && this.level > 10 && this.level <= 20) {
|
||||
if(!this.isBoxed && this.level > 10 && this.level <= 20 && this.safeZone) {
|
||||
int gold = (int) ((100000 * (this.level - 10) / 55.0) );
|
||||
this.charItemManager.addGoldToInventory(gold, false);
|
||||
this.charItemManager.updateInventory();
|
||||
@@ -5147,26 +5147,26 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
forceRespawn(this);
|
||||
return;
|
||||
}
|
||||
if(!this.timestamps.containsKey("stamTick")){
|
||||
this.timestamps.put("stamTick", System.currentTimeMillis());
|
||||
}else{
|
||||
if(this.containsEffect(441156479) || this.containsEffect(441156455)) {
|
||||
if(System.currentTimeMillis() - this.timestamps.get("stamTick") > 5000){
|
||||
boolean worked = false;
|
||||
while(!worked) {
|
||||
float old = this.stamina.get();
|
||||
float mod = old + 4;
|
||||
if (mod > this.staminaMax)
|
||||
mod = this.staminaMax;
|
||||
|
||||
worked = this.stamina.compareAndSet(old, mod);
|
||||
}
|
||||
this.timestamps.put("stamTick", System.currentTimeMillis());
|
||||
}
|
||||
}else{
|
||||
this.timestamps.put("stamTick", System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
//if(!this.timestamps.containsKey("stamTick")){
|
||||
// this.timestamps.put("stamTick", System.currentTimeMillis());
|
||||
//}else{
|
||||
// if(this.containsEffect(441156479) || this.containsEffect(441156455)) {
|
||||
// if(System.currentTimeMillis() - this.timestamps.get("stamTick") > 5000){
|
||||
// boolean worked = false;
|
||||
// while(!worked) {
|
||||
// float old = this.stamina.get();
|
||||
// float mod = old + 4;
|
||||
// if (mod > this.staminaMax)
|
||||
// mod = this.staminaMax;
|
||||
//
|
||||
// worked = this.stamina.compareAndSet(old, mod);
|
||||
// }
|
||||
// this.timestamps.put("stamTick", System.currentTimeMillis());
|
||||
// }
|
||||
// }else{
|
||||
// this.timestamps.put("stamTick", System.currentTimeMillis());
|
||||
// }
|
||||
//}
|
||||
|
||||
if (this.isAlive() && this.isActive && this.enteredWorld) {
|
||||
|
||||
@@ -5178,6 +5178,7 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
this.combatStats.update();
|
||||
}
|
||||
this.doRegen();
|
||||
//this.combatStats.regenerate();
|
||||
}
|
||||
|
||||
if (this.getStamina() < 10) {
|
||||
@@ -5249,14 +5250,22 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
}
|
||||
}
|
||||
|
||||
for(PlayerCharacter pc : sameMachine)
|
||||
pc.isBoxed = true;
|
||||
|
||||
player.isBoxed = false;
|
||||
if(player.containsEffect(1672601862)) {
|
||||
player.removeEffectBySource(EffectSourceType.DeathShroud,41,false);
|
||||
boolean valid = true;
|
||||
for(PlayerCharacter pc : sameMachine){
|
||||
if(!pc.safeZone)
|
||||
valid = false;
|
||||
}
|
||||
if(valid) {
|
||||
for (PlayerCharacter pc : sameMachine)
|
||||
pc.isBoxed = true;
|
||||
|
||||
player.isBoxed = false;
|
||||
if (player.containsEffect(1672601862)) {
|
||||
player.removeEffectBySource(EffectSourceType.DeathShroud, 41, false);
|
||||
}
|
||||
}else{
|
||||
ChatManager.chatSystemInfo(player, "All Boxes Must Be In Safezone To Switch");
|
||||
}
|
||||
}
|
||||
public static boolean checkIfBoxed(PlayerCharacter player){
|
||||
if(ConfigManager.MB_WORLD_BOXLIMIT.getValue().equals("false")) {
|
||||
|
||||
@@ -887,4 +887,146 @@ public class PlayerCombatStats {
|
||||
return HIT_VALUE_MAP.get(key);
|
||||
}
|
||||
|
||||
|
||||
public void regenerate(){
|
||||
if(!this.owner.effects.containsKey("Stunned")) {
|
||||
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("LASTSTAMINAREGEN",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 = 2.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 consumed = ((deltaTime * 0.001f) * 0.6f * stateMultiplier);
|
||||
float mod = current - consumed;
|
||||
boolean worked = false;
|
||||
if(mod <= 0)
|
||||
mod = 0;
|
||||
if(mod == 0){
|
||||
healthConsume(pc, (int) (consumed * 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){
|
||||
if (pc.isAlive.compareAndSet(true, false))
|
||||
pc.killCharacter("Water");
|
||||
return;
|
||||
}
|
||||
while(!worked){
|
||||
worked = pc.health.compareAndSet(current,mod);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package engine.workthreads;
|
||||
|
||||
import engine.job.AbstractJob;
|
||||
import engine.job.JobThread;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
public class ProcessUpdate implements Runnable{
|
||||
private final ReentrantLock lock = new ReentrantLock();
|
||||
private PlayerCharacter playerCharacter;
|
||||
public ProcessUpdate(PlayerCharacter pc){
|
||||
this.playerCharacter = pc;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
if (this.playerCharacter != null) {
|
||||
if (lock.tryLock(10, TimeUnit.SECONDS)) { // Timeout to prevent deadlock
|
||||
try {
|
||||
this.playerCharacter.update(true);
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
} else {
|
||||
Logger.warn("JobThread could not acquire lock in time, skipping job.");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void startUpdate(PlayerCharacter pc) {
|
||||
ProcessUpdate updateThread = new ProcessUpdate(pc);
|
||||
Thread thread = new Thread(updateThread);
|
||||
thread.setName(pc.getObjectUUID() + " UPDATE");
|
||||
thread.start();
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,8 @@ import engine.objects.PlayerCharacter;
|
||||
import engine.objects.PlayerCombatStats;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.concurrent.*;
|
||||
|
||||
public class UpdateThread implements Runnable {
|
||||
|
||||
private volatile Long lastRun;
|
||||
@@ -27,36 +29,35 @@ public class UpdateThread implements Runnable {
|
||||
}
|
||||
|
||||
|
||||
public void processPlayerUpdate() {
|
||||
private static final long INSTANCE_DELAY = 1500; // Adjust as needed
|
||||
|
||||
public void processPlayerUpdate() {
|
||||
try {
|
||||
for(PlayerCharacter player : SessionManager.getAllActivePlayerCharacters()){
|
||||
for (PlayerCharacter player : SessionManager.getAllActivePlayerCharacters()) {
|
||||
if (player != null) {
|
||||
player.update(true);
|
||||
try {
|
||||
player.update(true);
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.error("UPDATE ERROR",e);
|
||||
}catch(Exception e){
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
|
||||
//for (PlayerCharacter player : SessionManager.getAllActivePlayerCharacters()) {
|
||||
// ProcessUpdate.startUpdate(player);
|
||||
//}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
lastRun = System.currentTimeMillis();
|
||||
while (true) {
|
||||
if (System.currentTimeMillis() >= lastRun + instancedelay) { // Correct condition
|
||||
this.processPlayerUpdate();
|
||||
lastRun = System.currentTimeMillis(); // Update lastRun after processing
|
||||
}else {
|
||||
try {
|
||||
Thread.sleep(100); // Pause for 100ms to reduce CPU usage
|
||||
} catch (InterruptedException e) {
|
||||
Logger.error("Thread interrupted", e);
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
Thread.yield();
|
||||
try {
|
||||
processPlayerUpdate();
|
||||
Thread.sleep(100);
|
||||
} catch (Exception e) {
|
||||
Logger.error("Thread Execution Error", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user