Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 76284cf3c9 | |||
| 9d79afa395 | |||
| 944290f958 | |||
| e6eb753666 | |||
| 4ad7e0f021 | |||
| 8d587538e0 | |||
| 4ae64ab94c | |||
| c5e6205801 | |||
| 5a3f4e690f | |||
| 048474b014 | |||
| 24e01acff4 | |||
| a75670bf0e | |||
| d56d58492a | |||
| 7b33c1392a | |||
| 86c95f0eb5 | |||
| 6ed648d6d4 | |||
| c722450f65 |
@@ -27,6 +27,7 @@ import engine.objects.*;
|
|||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
import engine.server.world.WorldServer;
|
import engine.server.world.WorldServer;
|
||||||
import engine.session.Session;
|
import engine.session.Session;
|
||||||
|
import engine.util.KeyCloneAudit;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -84,6 +85,10 @@ public enum ChatManager {
|
|||||||
if ((checkTime > 0L) && (curMsgTime - checkTime < FLOOD_TIME_THRESHOLD))
|
if ((checkTime > 0L) && (curMsgTime - checkTime < FLOOD_TIME_THRESHOLD))
|
||||||
isFlood = true;
|
isFlood = true;
|
||||||
|
|
||||||
|
if(KeyCloneAudit.auditChatMsg(pc,msg.getMessage())){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (protocolMsg) {
|
switch (protocolMsg) {
|
||||||
case CHATSAY:
|
case CHATSAY:
|
||||||
ChatManager.chatSay(pc, msg.getMessage(), isFlood);
|
ChatManager.chatSay(pc, msg.getMessage(), isFlood);
|
||||||
|
|||||||
@@ -1627,6 +1627,7 @@ public enum PowersManager {
|
|||||||
case 431511776:
|
case 431511776:
|
||||||
case 429578587:
|
case 429578587:
|
||||||
case 429503360:
|
case 429503360:
|
||||||
|
case 44106356:
|
||||||
trackChars = getTrackList(playerCharacter);
|
trackChars = getTrackList(playerCharacter);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -107,8 +107,10 @@ public class MobAI {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(target.getPet() != null && target.getPet().isAlive()){
|
if(target.getPet() != null && target.getPet().isAlive() && !target.getPet().isSiege()){
|
||||||
mob.setCombatTarget(target.getPet());
|
mob.setCombatTarget(target.getPet());
|
||||||
|
AttackTarget(mob,mob.combatTarget);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mob.BehaviourType.callsForHelp)
|
if (mob.BehaviourType.callsForHelp)
|
||||||
@@ -264,9 +266,6 @@ public class MobAI {
|
|||||||
target.setCombatTarget(mob);
|
target.setCombatTarget(mob);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(target.combatTarget == null)
|
|
||||||
target.setCombatTarget(mob);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackMob" + " " + e.getMessage());
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackMob" + " " + e.getMessage());
|
||||||
}
|
}
|
||||||
@@ -726,8 +725,8 @@ public class MobAI {
|
|||||||
DefaultLogic(mob);
|
DefaultLogic(mob);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//if(mob.isAlive())
|
if(mob.isAlive())
|
||||||
// RecoverHealth(mob);
|
RecoverHealth(mob);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DetermineAction" + " " + e.getMessage());
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DetermineAction" + " " + e.getMessage());
|
||||||
}
|
}
|
||||||
@@ -737,10 +736,6 @@ public class MobAI {
|
|||||||
|
|
||||||
try {
|
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
|
//looks for and sets mobs combatTarget
|
||||||
|
|
||||||
if (!aiAgent.isAlive())
|
if (!aiAgent.isAlive())
|
||||||
@@ -1108,17 +1103,17 @@ public class MobAI {
|
|||||||
if (mob.getCombatTarget() == null)
|
if (mob.getCombatTarget() == null)
|
||||||
CheckForPlayerGuardAggro(mob);
|
CheckForPlayerGuardAggro(mob);
|
||||||
|
|
||||||
//AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob);
|
AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob);
|
||||||
|
|
||||||
//if (newTarget != null) {
|
if (newTarget != null) {
|
||||||
|
|
||||||
// if (newTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
|
if (newTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
|
||||||
// if (GuardCanAggro(mob, (PlayerCharacter) newTarget))
|
if (GuardCanAggro(mob, (PlayerCharacter) newTarget))
|
||||||
// mob.setCombatTarget(newTarget);
|
mob.setCombatTarget(newTarget);
|
||||||
// } else
|
} else
|
||||||
// mob.setCombatTarget(newTarget);
|
mob.setCombatTarget(newTarget);
|
||||||
|
|
||||||
//}
|
}
|
||||||
CheckMobMovement(mob);
|
CheckMobMovement(mob);
|
||||||
CheckForAttack(mob);
|
CheckForAttack(mob);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -1204,24 +1199,25 @@ public class MobAI {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
//check for players that can be aggroed if mob is agressive and has no target
|
//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 && !mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.Mob))
|
|
||||||
|
if (mob.getCombatTarget() != null && mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false)
|
||||||
mob.setCombatTarget(null);
|
mob.setCombatTarget(null);
|
||||||
|
|
||||||
//if (mob.BehaviourType.isAgressive) {
|
if (mob.BehaviourType.isAgressive) {
|
||||||
|
|
||||||
// AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob);
|
AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob);
|
||||||
|
|
||||||
// if (newTarget != null)
|
if (newTarget != null)
|
||||||
// mob.setCombatTarget(newTarget);
|
mob.setCombatTarget(newTarget);
|
||||||
// else {
|
else {
|
||||||
// if (mob.getCombatTarget() == null) {
|
if (mob.getCombatTarget() == null) {
|
||||||
// if (mob.BehaviourType == Enum.MobBehaviourType.HamletGuard)
|
if (mob.BehaviourType == Enum.MobBehaviourType.HamletGuard)
|
||||||
// SafeGuardAggro(mob); //safehold guard
|
SafeGuardAggro(mob); //safehold guard
|
||||||
// else
|
else
|
||||||
// CheckForAggro(mob); //normal aggro
|
CheckForAggro(mob); //normal aggro
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
|
|
||||||
//check if mob can move for patrol or moving to target
|
//check if mob can move for patrol or moving to target
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ package engine.objects;
|
|||||||
|
|
||||||
import engine.Enum;
|
import engine.Enum;
|
||||||
import engine.Enum.TargetColor;
|
import engine.Enum.TargetColor;
|
||||||
import engine.gameManager.LootManager;
|
|
||||||
import engine.gameManager.ZoneManager;
|
import engine.gameManager.ZoneManager;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
@@ -353,69 +352,135 @@ public class Experience {
|
|||||||
if(killer.pvpKills.contains(mob.getObjectUUID()))
|
if(killer.pvpKills.contains(mob.getObjectUUID()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
double baseXP;
|
double grantedExperience = 0.0;
|
||||||
|
|
||||||
if(g != null) {
|
if (g != null) { // Do group EXP stuff
|
||||||
//group experience
|
|
||||||
PlayerCharacter leader = g.getGroupLead();
|
|
||||||
float leadership = 0.0f;
|
|
||||||
if(leader.skills.containsKey("Leadership"))
|
|
||||||
leadership = leader.skills.get("Leadership").getModifiedAmount();
|
|
||||||
|
|
||||||
for(PlayerCharacter member : g.members){
|
int leadership = 0;
|
||||||
|
int highestLevel = 0;
|
||||||
|
double penalty = 0.0;
|
||||||
|
|
||||||
if (member.getLevel() >= MBServerStatics.LEVELCAP)
|
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)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(!member.isAlive())
|
if(playerCharacter.level >= 75 && !mob.getObjectType().equals(Enum.GameObjectType.PlayerCharacter))
|
||||||
continue;
|
|
||||||
|
|
||||||
if(member.level >= 75 && !mob.getObjectType().equals(Enum.GameObjectType.PlayerCharacter))
|
|
||||||
continue; // cannot PVE higher than level 75
|
continue; // cannot PVE higher than level 75
|
||||||
|
|
||||||
float range = member.loc.distanceSquared(killer.loc);
|
// Sets Max XP with server exp mod taken into account.
|
||||||
if(range <= (MBServerStatics.CHARACTER_LOAD_RANGE * MBServerStatics.CHARACTER_LOAD_RANGE)){
|
|
||||||
baseXP = LootManager.NORMAL_EXP_RATE * maxXPPerKill(member.getLevel());
|
|
||||||
double mod = getConMod(member, mob);
|
|
||||||
|
|
||||||
if(leadership > 0 && mod != 0)
|
grantedExperience = (double) LOOTMANAGER.NORMAL_EXP_RATE * maxXPPerKill(playerCharacter.getLevel());
|
||||||
mod += (leadership * 0.01f);
|
|
||||||
|
|
||||||
baseXP *= mod;
|
// Adjust XP for Mob Level
|
||||||
|
|
||||||
if(baseXP < 1)
|
grantedExperience *= getConMod(playerCharacter, mob);
|
||||||
baseXP = 1;
|
|
||||||
|
|
||||||
baseXP *= (1.0f / g.members.size()+0.9f);
|
// Process XP for this member
|
||||||
|
|
||||||
member.grantXP((int) baseXP);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (grantedExperience == 0)
|
||||||
|
grantedExperience = 1;
|
||||||
|
|
||||||
|
//scaling
|
||||||
|
grantedExperience *= (1 / giveEXPTo.size()+0.9);
|
||||||
|
|
||||||
|
// Grant the player the EXP
|
||||||
|
playerCharacter.grantXP((int) Math.floor(grantedExperience));
|
||||||
}
|
}
|
||||||
}else{
|
|
||||||
//solo no group
|
} else { // Give EXP to a single character
|
||||||
|
//if (!killer.isAlive()) // Skip if the player is dead.
|
||||||
|
// return;
|
||||||
|
|
||||||
if (killer.getLevel() >= MBServerStatics.LEVELCAP)
|
if (killer.getLevel() >= MBServerStatics.LEVELCAP)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(killer.level >= 75 && !mob.getObjectType().equals(Enum.GameObjectType.PlayerCharacter))
|
if(killer.level >= 75 && !mob.getObjectType().equals(Enum.GameObjectType.PlayerCharacter))
|
||||||
return; // cannot PVE higher than level 75
|
return;
|
||||||
|
|
||||||
baseXP = LootManager.NORMAL_EXP_RATE * maxXPPerKill(killer.getLevel());
|
// Get XP and adjust for Mob Level with world xp modifier taken into account
|
||||||
double mod = getConMod(killer, mob);
|
grantedExperience = (double) LOOTMANAGER.NORMAL_EXP_RATE * maxXPPerKill(killer.getLevel());
|
||||||
float leadership = 0.0f;
|
grantedExperience *= getConMod(killer, mob);
|
||||||
if(killer.skills.containsKey("Leadership"))
|
|
||||||
leadership = killer.skills.get("Leadership").getModifiedAmount();
|
// Modify for hotzone
|
||||||
if(leadership > 0 && mod != 0){
|
if (ZoneManager.inHotZone(mob.getLoc()))
|
||||||
mod += (leadership * 0.01f);
|
grantedExperience *= LOOTMANAGER.HOTZONE_EXP_RATE;
|
||||||
|
|
||||||
|
// Errant penalty
|
||||||
|
if (grantedExperience != 1) {
|
||||||
|
if (killer.getGuild().isEmptyGuild())
|
||||||
|
grantedExperience *= 0.6f;
|
||||||
}
|
}
|
||||||
|
|
||||||
baseXP *= mod;
|
//bonus for no group
|
||||||
if(baseXP < 1)
|
grantedExperience *= 1.9f;
|
||||||
baseXP = 1;
|
|
||||||
|
|
||||||
baseXP *= 1.9f;
|
// Grant XP
|
||||||
|
killer.grantXP((int) Math.floor(grantedExperience));
|
||||||
killer.grantXP((int) baseXP);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1962,9 +1962,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if(this.equipmentSetID == 6481) {
|
|
||||||
int i = 0;
|
|
||||||
}
|
|
||||||
if (this.equipmentSetID != 0)
|
if (this.equipmentSetID != 0)
|
||||||
this.equip = MobBase.loadEquipmentSet(this.equipmentSetID);
|
this.equip = MobBase.loadEquipmentSet(this.equipmentSetID);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -131,10 +131,7 @@ public class MobBase extends AbstractGameObject {
|
|||||||
return equip;
|
return equip;
|
||||||
|
|
||||||
for (BootySetEntry equipmentSetEntry : equipList) {
|
for (BootySetEntry equipmentSetEntry : equipList) {
|
||||||
try {
|
|
||||||
if(equipmentSetEntry.itemBase == 189500){
|
|
||||||
int i = 0;
|
|
||||||
}
|
|
||||||
MobEquipment mobEquipment = new MobEquipment(equipmentSetEntry.itemBase, equipmentSetEntry.dropChance);
|
MobEquipment mobEquipment = new MobEquipment(equipmentSetEntry.itemBase, equipmentSetEntry.dropChance);
|
||||||
ItemBase itemBase = mobEquipment.getItemBase();
|
ItemBase itemBase = mobEquipment.getItemBase();
|
||||||
|
|
||||||
@@ -145,9 +142,6 @@ public class MobBase extends AbstractGameObject {
|
|||||||
|
|
||||||
equip.put(mobEquipment.getSlot(), mobEquipment);
|
equip.put(mobEquipment.getSlot(), mobEquipment);
|
||||||
}
|
}
|
||||||
}catch(Exception e){
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return equip;
|
return equip;
|
||||||
|
|||||||
@@ -98,11 +98,7 @@ public class MobEquipment extends AbstractGameObject {
|
|||||||
this.dropChance = dropChance;
|
this.dropChance = dropChance;
|
||||||
|
|
||||||
this.parentID = 0;
|
this.parentID = 0;
|
||||||
try {
|
|
||||||
setMagicValue();
|
setMagicValue();
|
||||||
}catch(Exception e){
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getNewID() {
|
public static int getNewID() {
|
||||||
|
|||||||
@@ -3084,7 +3084,7 @@ public class PlayerCharacter extends AbstractCharacter {
|
|||||||
checkGuildStatus();
|
checkGuildStatus();
|
||||||
|
|
||||||
//give gold for level up if level is under or equal to 20 and over 10
|
//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 && this.safeZone) {
|
if(!this.isBoxed && this.level > 10 && this.level <= 20) {
|
||||||
int gold = (int) ((100000 * (this.level - 10) / 55.0) );
|
int gold = (int) ((100000 * (this.level - 10) / 55.0) );
|
||||||
this.charItemManager.addGoldToInventory(gold, false);
|
this.charItemManager.addGoldToInventory(gold, false);
|
||||||
this.charItemManager.updateInventory();
|
this.charItemManager.updateInventory();
|
||||||
@@ -5147,26 +5147,6 @@ public class PlayerCharacter extends AbstractCharacter {
|
|||||||
forceRespawn(this);
|
forceRespawn(this);
|
||||||
return;
|
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.isAlive() && this.isActive && this.enteredWorld) {
|
if (this.isAlive() && this.isActive && this.enteredWorld) {
|
||||||
|
|
||||||
@@ -5178,7 +5158,6 @@ public class PlayerCharacter extends AbstractCharacter {
|
|||||||
this.combatStats.update();
|
this.combatStats.update();
|
||||||
}
|
}
|
||||||
this.doRegen();
|
this.doRegen();
|
||||||
//this.combatStats.regenerate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.getStamina() < 10) {
|
if (this.getStamina() < 10) {
|
||||||
@@ -5205,8 +5184,14 @@ public class PlayerCharacter extends AbstractCharacter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isBoxed && !this.containsEffect(1672601862)) {
|
if (this.isBoxed && !this.containsEffect(508555434)) {
|
||||||
PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 1672601862, 40, false);
|
PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 508555434, 40, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.ZergMultiplier != 1.0f && !this.containsEffect(-906894951)) {
|
||||||
|
PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, -906894951, 40, false);
|
||||||
|
}else if(this.containsEffect(-906894951)){
|
||||||
|
this.effects.remove("Zerg Penalty");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isFlying()) {
|
if (this.isFlying()) {
|
||||||
@@ -5914,10 +5899,16 @@ public class PlayerCharacter extends AbstractCharacter {
|
|||||||
// Reset this char's frame time.
|
// Reset this char's frame time.
|
||||||
this.lastUpdateTime = System.currentTimeMillis();
|
this.lastUpdateTime = System.currentTimeMillis();
|
||||||
this.lastStamUpdateTime = 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 (this.timestamps.get("SyncClient") + 5000L < System.currentTimeMillis()) {
|
||||||
|
//if (updateHealth || updateMana || updateStamina || consumeStamina) {
|
||||||
this.syncClient();
|
this.syncClient();
|
||||||
this.timestamps.put("SyncClient", System.currentTimeMillis());
|
this.timestamps.put("SyncClient", System.currentTimeMillis());
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -887,146 +887,4 @@ public class PlayerCombatStats {
|
|||||||
return HIT_VALUE_MAP.get(key);
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,7 +164,17 @@ public class WorldServer {
|
|||||||
long uptimeSeconds = Math.abs(uptimeDuration.getSeconds());
|
long uptimeSeconds = Math.abs(uptimeDuration.getSeconds());
|
||||||
String uptime = String.format("%d hours %02d minutes %02d seconds", uptimeSeconds / 3600, (uptimeSeconds % 3600) / 60, (uptimeSeconds % 60));
|
String uptime = String.format("%d hours %02d minutes %02d seconds", uptimeSeconds / 3600, (uptimeSeconds % 3600) / 60, (uptimeSeconds % 60));
|
||||||
outString += "uptime: " + uptime;
|
outString += "uptime: " + uptime;
|
||||||
outString += " pop: " + SessionManager.getActivePlayerCharacterCount() + " max pop: " + SessionManager._maxPopulation;
|
int activePop = 0;
|
||||||
|
int boxedPop = 0;
|
||||||
|
for(PlayerCharacter pc : SessionManager.getAllActivePlayerCharacters()){
|
||||||
|
if(pc.isBoxed){
|
||||||
|
boxedPop ++;
|
||||||
|
}else{
|
||||||
|
activePop ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//outString += " pop: " + SessionManager.getActivePlayerCharacterCount() + " max pop: " + SessionManager._maxPopulation;
|
||||||
|
outString += "Active Players: " + activePop + " Boxed Players: " + boxedPop;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.error("Failed to build string");
|
Logger.error("Failed to build string");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package engine.util;
|
|||||||
|
|
||||||
import engine.gameManager.ConfigManager;
|
import engine.gameManager.ConfigManager;
|
||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
|
import engine.gameManager.GroupManager;
|
||||||
import engine.gameManager.SessionManager;
|
import engine.gameManager.SessionManager;
|
||||||
import engine.net.client.ClientConnection;
|
import engine.net.client.ClientConnection;
|
||||||
import engine.net.client.Protocol;
|
import engine.net.client.Protocol;
|
||||||
@@ -15,6 +16,25 @@ import org.pmw.tinylog.Logger;
|
|||||||
public enum KeyCloneAudit {
|
public enum KeyCloneAudit {
|
||||||
KEYCLONEAUDIT;
|
KEYCLONEAUDIT;
|
||||||
|
|
||||||
|
public static boolean auditChatMsg(PlayerCharacter pc, String message) {
|
||||||
|
|
||||||
|
if(pc.combatTarget != null && message.contains(String.valueOf(pc.combatTarget.getObjectUUID()))) {
|
||||||
|
//targeting software detected
|
||||||
|
|
||||||
|
Group g = GroupManager.getGroup(pc);
|
||||||
|
|
||||||
|
if (g == null)
|
||||||
|
pc.getClientConnection().forceDisconnect();
|
||||||
|
else
|
||||||
|
for (PlayerCharacter member : g.members)
|
||||||
|
member.getClientConnection().forceDisconnect();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void audit(PlayerCharacter player, Group group) {
|
public void audit(PlayerCharacter player, Group group) {
|
||||||
|
|
||||||
int machineCount = 0;
|
int machineCount = 0;
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
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,8 +17,6 @@ import engine.objects.PlayerCharacter;
|
|||||||
import engine.objects.PlayerCombatStats;
|
import engine.objects.PlayerCombatStats;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.util.concurrent.*;
|
|
||||||
|
|
||||||
public class UpdateThread implements Runnable {
|
public class UpdateThread implements Runnable {
|
||||||
|
|
||||||
private volatile Long lastRun;
|
private volatile Long lastRun;
|
||||||
@@ -29,35 +27,30 @@ public class UpdateThread implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static final long INSTANCE_DELAY = 1500; // Adjust as needed
|
|
||||||
|
|
||||||
public void processPlayerUpdate() {
|
public void processPlayerUpdate() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for(PlayerCharacter player : SessionManager.getAllActivePlayerCharacters()){
|
for(PlayerCharacter player : SessionManager.getAllActivePlayerCharacters()){
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
try {
|
|
||||||
player.update(true);
|
player.update(true);
|
||||||
} catch (Exception e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.error(e);
|
Logger.error("UPDATE ERROR",e);
|
||||||
}
|
}
|
||||||
|
|
||||||
//for (PlayerCharacter player : SessionManager.getAllActivePlayerCharacters()) {
|
|
||||||
// ProcessUpdate.startUpdate(player);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
public void run() {
|
||||||
|
lastRun = System.currentTimeMillis();
|
||||||
|
while (true) {
|
||||||
try {
|
try {
|
||||||
processPlayerUpdate();
|
this.processPlayerUpdate();
|
||||||
Thread.sleep(100);
|
Thread.sleep(100); // Pause for 100ms to reduce CPU usage
|
||||||
} catch (Exception e) {
|
} catch (InterruptedException e) {
|
||||||
Logger.error("Thread Execution Error", e);
|
Logger.error("Thread interrupted", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user