Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2fa9030682 | |||
| 6961b186a9 | |||
| bee91a6aa7 | |||
| 8c5b1d56c2 | |||
| f21e8c130b | |||
| 345c451ac8 |
@@ -27,7 +27,6 @@ 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;
|
||||||
@@ -85,10 +84,6 @@ 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);
|
||||||
|
|||||||
@@ -301,17 +301,6 @@ public enum CombatManager {
|
|||||||
if (target == null)
|
if (target == null)
|
||||||
return 0;
|
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
|
//target must be valid type
|
||||||
|
|
||||||
if (AbstractWorldObject.IsAbstractCharacter(target)) {
|
if (AbstractWorldObject.IsAbstractCharacter(target)) {
|
||||||
|
|||||||
@@ -1627,7 +1627,6 @@ 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:
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
package engine.mobileAI;
|
package engine.mobileAI;
|
||||||
|
|
||||||
import engine.Enum;
|
import engine.Enum;
|
||||||
import engine.InterestManagement.InterestManager;
|
|
||||||
import engine.InterestManagement.WorldGrid;
|
import engine.InterestManagement.WorldGrid;
|
||||||
import engine.gameManager.*;
|
import engine.gameManager.*;
|
||||||
import engine.math.Vector3f;
|
import engine.math.Vector3f;
|
||||||
@@ -107,12 +106,6 @@ public class MobAI {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(target.getPet() != null && target.getPet().isAlive() && !target.getPet().isSiege()){
|
|
||||||
mob.setCombatTarget(target.getPet());
|
|
||||||
AttackTarget(mob,mob.combatTarget);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mob.BehaviourType.callsForHelp)
|
if (mob.BehaviourType.callsForHelp)
|
||||||
MobCallForHelp(mob);
|
MobCallForHelp(mob);
|
||||||
|
|
||||||
@@ -163,12 +156,6 @@ public class MobAI {
|
|||||||
if (target.getPet().getCombatTarget() == null && target.getPet().assist == true)
|
if (target.getPet().getCombatTarget() == null && target.getPet().assist == true)
|
||||||
target.getPet().setCombatTarget(mob);
|
target.getPet().setCombatTarget(mob);
|
||||||
|
|
||||||
try{
|
|
||||||
InterestManager.forceLoad(mob);
|
|
||||||
}catch(Exception e){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackPlayer" + " " + e.getMessage());
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackPlayer" + " " + e.getMessage());
|
||||||
}
|
}
|
||||||
@@ -1229,7 +1216,6 @@ public class MobAI {
|
|||||||
if (!mob.BehaviourType.isWimpy && mob.getCombatTarget() != null)
|
if (!mob.BehaviourType.isWimpy && mob.getCombatTarget() != null)
|
||||||
CheckForAttack(mob);
|
CheckForAttack(mob);
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DefaultLogic" + " " + e.getMessage());
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DefaultLogic" + " " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package engine.mobileAI.Threads;
|
|||||||
import engine.gameManager.ConfigManager;
|
import engine.gameManager.ConfigManager;
|
||||||
import engine.mobileAI.MobAI;
|
import engine.mobileAI.MobAI;
|
||||||
import engine.gameManager.ZoneManager;
|
import engine.gameManager.ZoneManager;
|
||||||
|
import engine.mobileAI.behaviours.GuardAI;
|
||||||
|
import engine.mobileAI.behaviours.SiegeEngineAI;
|
||||||
import engine.objects.Mob;
|
import engine.objects.Mob;
|
||||||
import engine.objects.Zone;
|
import engine.objects.Zone;
|
||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
@@ -33,6 +35,13 @@ public class MobAIThread implements Runnable{
|
|||||||
for (Mob mob : zone.zoneMobSet) {
|
for (Mob mob : zone.zoneMobSet) {
|
||||||
try {
|
try {
|
||||||
if (mob != null) {
|
if (mob != null) {
|
||||||
|
if(mob.isSiege()){
|
||||||
|
SiegeEngineAI.run(mob);
|
||||||
|
continue;
|
||||||
|
}else if(mob.isPlayerGuard){
|
||||||
|
GuardAI.run(mob);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
MobAI.DetermineAction(mob);
|
MobAI.DetermineAction(mob);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -43,13 +43,14 @@ public class MobRespawnThread implements Runnable {
|
|||||||
if (zones != null) {
|
if (zones != null) {
|
||||||
for (Zone zone : zones) {
|
for (Zone zone : zones) {
|
||||||
synchronized (zone) { // Optional: Synchronize on zone
|
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) {
|
if (respawner != null) {
|
||||||
respawner.respawn();
|
respawner.respawn();
|
||||||
Zone.respawnQue.remove(respawner);
|
zone.respawnQue.remove(respawner);
|
||||||
Zone.lastRespawn = System.currentTimeMillis();
|
zone.lastRespawn = System.currentTimeMillis();
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,259 @@
|
|||||||
|
package engine.mobileAI.behaviours;
|
||||||
|
|
||||||
|
import engine.Enum;
|
||||||
|
import engine.gameManager.MovementManager;
|
||||||
|
import engine.gameManager.PowersManager;
|
||||||
|
import engine.gameManager.ZoneManager;
|
||||||
|
import engine.math.Vector3f;
|
||||||
|
import engine.math.Vector3fImmutable;
|
||||||
|
import engine.mobileAI.utilities.CombatUtilities;
|
||||||
|
import engine.mobileAI.utilities.MovementUtilities;
|
||||||
|
import engine.objects.*;
|
||||||
|
import engine.powers.MobPowerEntry;
|
||||||
|
import engine.powers.PowersBase;
|
||||||
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
|
public class GuardAI {
|
||||||
|
|
||||||
|
public static HashMap<Mob,PowersBase> quedPowerCasts = new HashMap<>();
|
||||||
|
|
||||||
|
public static void run(Mob guard){
|
||||||
|
|
||||||
|
//1. check for players nearby to aggro to
|
||||||
|
if(guard.combatTarget == null)
|
||||||
|
CheckForPlayerGuardAggro(guard);
|
||||||
|
|
||||||
|
//2. patrol if no target acquired
|
||||||
|
if(guard.combatTarget == null) {
|
||||||
|
patrol(guard);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//3. attack based on whether spellcaster, archer or mele
|
||||||
|
if(guard.mobPowers.isEmpty()){
|
||||||
|
if(guard.getEquip().get(2) != null && guard.getEquip().get(2).getItemBase().getRange() > 20) {
|
||||||
|
runArcher(guard);
|
||||||
|
}else {
|
||||||
|
runMele(guard);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
runCaster(guard);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void runCaster(Mob guard){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void runMele(Mob guard){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void runArcher(Mob guard){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CheckForPlayerGuardAggro(Mob mob) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
//looks for and sets mobs combatTarget
|
||||||
|
|
||||||
|
if (!mob.isAlive())
|
||||||
|
return;
|
||||||
|
|
||||||
|
ConcurrentHashMap<Integer, Boolean> loadedPlayers = mob.playerAgroMap;
|
||||||
|
|
||||||
|
for (Map.Entry playerEntry : loadedPlayers.entrySet()) {
|
||||||
|
|
||||||
|
int playerID = (int) playerEntry.getKey();
|
||||||
|
PlayerCharacter loadedPlayer = PlayerCharacter.getFromCache(playerID);
|
||||||
|
|
||||||
|
//Player is null, let's remove them from the list.
|
||||||
|
|
||||||
|
if (loadedPlayer == null) {
|
||||||
|
loadedPlayers.remove(playerID);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Player is Dead, Mob no longer needs to attempt to aggro. Remove them from aggro map.
|
||||||
|
|
||||||
|
if (!loadedPlayer.isAlive()) {
|
||||||
|
loadedPlayers.remove(playerID);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Can't see target, skip aggro.
|
||||||
|
|
||||||
|
if (!mob.canSee(loadedPlayer))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// No aggro for this player
|
||||||
|
|
||||||
|
if (GuardCanAggro(mob, loadedPlayer) == false)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (MovementUtilities.inRangeToAggro(mob, loadedPlayer) && mob.getCombatTarget() == null) {
|
||||||
|
mob.setCombatTarget(loadedPlayer);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckForPlayerGuardAggro" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Boolean GuardCanAggro(Mob mob, PlayerCharacter target) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
if (mob.getGuild().getNation().equals(target.getGuild().getNation()))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) {
|
||||||
|
if (((Mob) mob.npcOwner).building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else if (mob.building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//first check condemn list for aggro allowed (allies button is checked)
|
||||||
|
|
||||||
|
if (ZoneManager.getCityAtLocation(mob.getLoc()).getTOL().reverseKOS) {
|
||||||
|
for (Map.Entry<Integer, Condemned> entry : ZoneManager.getCityAtLocation(mob.getLoc()).getTOL().getCondemned().entrySet()) {
|
||||||
|
|
||||||
|
//target is listed individually
|
||||||
|
|
||||||
|
if (entry.getValue().getPlayerUID() == target.getObjectUUID() && entry.getValue().isActive())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
//target's guild is listed
|
||||||
|
|
||||||
|
if (Guild.getGuild(entry.getValue().getGuildUID()) == target.getGuild())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
//target's nation is listed
|
||||||
|
|
||||||
|
if (Guild.getGuild(entry.getValue().getGuildUID()) == target.getGuild().getNation())
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
//allies button is not checked
|
||||||
|
|
||||||
|
for (Map.Entry<Integer, Condemned> entry : ZoneManager.getCityAtLocation(mob.getLoc()).getTOL().getCondemned().entrySet()) {
|
||||||
|
|
||||||
|
//target is listed individually
|
||||||
|
|
||||||
|
if (entry.getValue().getPlayerUID() == target.getObjectUUID() && entry.getValue().isActive())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
//target's guild is listed
|
||||||
|
|
||||||
|
if (Guild.getGuild(entry.getValue().getGuildUID()) == target.getGuild())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
//target's nation is listed
|
||||||
|
|
||||||
|
if (Guild.getGuild(entry.getValue().getGuildUID()) == target.getGuild().getNation())
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardCanAggro" + " " + e.getMessage());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void randomGuardPatrolPoint(Mob mob) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
//early exit for a mob who is already moving to a patrol point
|
||||||
|
//while mob moving, update lastPatrolTime so that when they stop moving the 10 second timer can begin
|
||||||
|
|
||||||
|
if (mob.isMoving() == true) {
|
||||||
|
mob.stopPatrolTime = System.currentTimeMillis();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//wait between 10 and 15 seconds after reaching patrol point before moving
|
||||||
|
|
||||||
|
int patrolDelay = ThreadLocalRandom.current().nextInt(10000) + 5000;
|
||||||
|
|
||||||
|
//early exit while waiting to patrol again
|
||||||
|
|
||||||
|
if (mob.stopPatrolTime + patrolDelay > System.currentTimeMillis())
|
||||||
|
return;
|
||||||
|
|
||||||
|
float xPoint = ThreadLocalRandom.current().nextInt(400) - 200;
|
||||||
|
float zPoint = ThreadLocalRandom.current().nextInt(400) - 200;
|
||||||
|
Vector3fImmutable TreePos = mob.getGuild().getOwnedCity().getLoc();
|
||||||
|
mob.destination = new Vector3fImmutable(TreePos.x + xPoint, TreePos.y, TreePos.z + zPoint);
|
||||||
|
|
||||||
|
MovementUtilities.aiMove(mob, mob.destination, true);
|
||||||
|
|
||||||
|
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) {
|
||||||
|
for (Map.Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet()) {
|
||||||
|
|
||||||
|
//make sure mob is out of combat stance
|
||||||
|
|
||||||
|
if (minion.getKey().despawned == false) {
|
||||||
|
if (MovementUtilities.canMove(minion.getKey())) {
|
||||||
|
Vector3f minionOffset = Formation.getOffset(2, minion.getValue() + 3);
|
||||||
|
minion.getKey().updateLocation();
|
||||||
|
Vector3fImmutable formationPatrolPoint = new Vector3fImmutable(mob.destination.x + minionOffset.x, mob.destination.y, mob.destination.z + minionOffset.z);
|
||||||
|
MovementUtilities.aiMove(minion.getKey(), formationPatrolPoint, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: randomGuardPatrolPoints" + " " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void patrol(Mob guard){
|
||||||
|
if (!guard.BehaviourType.equals(Enum.MobBehaviourType.GuardCaptain) && guard.npcOwner.isAlive())
|
||||||
|
return;
|
||||||
|
|
||||||
|
//patrol
|
||||||
|
Building barracks = guard.building;
|
||||||
|
|
||||||
|
if (barracks != null && barracks.patrolPoints != null && !barracks.getPatrolPoints().isEmpty()) {
|
||||||
|
guard.patrolPoints = barracks.patrolPoints;
|
||||||
|
} else {
|
||||||
|
randomGuardPatrolPoint(guard);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (guard.lastPatrolPointIndex > guard.patrolPoints.size() - 1)
|
||||||
|
guard.lastPatrolPointIndex = 0;
|
||||||
|
|
||||||
|
guard.destination = guard.patrolPoints.get(guard.lastPatrolPointIndex);
|
||||||
|
guard.lastPatrolPointIndex += 1;
|
||||||
|
|
||||||
|
MovementUtilities.aiMove(guard, guard.destination, true);
|
||||||
|
|
||||||
|
if (guard.BehaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) {
|
||||||
|
for (Map.Entry<Mob, Integer> minion : guard.siegeMinionMap.entrySet())
|
||||||
|
|
||||||
|
//make sure mob is out of combat stance
|
||||||
|
|
||||||
|
if (!minion.getKey().despawned) {
|
||||||
|
if (MovementUtilities.canMove(minion.getKey())) {
|
||||||
|
Vector3f minionOffset = Formation.getOffset(2, minion.getValue() + 3);
|
||||||
|
minion.getKey().updateLocation();
|
||||||
|
Vector3fImmutable formationPatrolPoint = new Vector3fImmutable(guard.destination.x + minionOffset.x, guard.destination.y, guard.destination.z + minionOffset.z);
|
||||||
|
MovementUtilities.aiMove(minion.getKey(), formationPatrolPoint, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package engine.mobileAI.behaviours;
|
||||||
|
|
||||||
|
import engine.objects.Mob;
|
||||||
|
|
||||||
|
public class PetAI {
|
||||||
|
|
||||||
|
public static void run(Mob pet){
|
||||||
|
|
||||||
|
//1. check for combat
|
||||||
|
|
||||||
|
//2. check for distance from player
|
||||||
|
|
||||||
|
//3. follow player
|
||||||
|
|
||||||
|
//4. chase combat target
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
package engine.mobileAI.behaviours;
|
||||||
|
|
||||||
|
import engine.Enum;
|
||||||
|
import engine.gameManager.BuildingManager;
|
||||||
|
import engine.gameManager.CombatManager;
|
||||||
|
import engine.gameManager.MovementManager;
|
||||||
|
import engine.gameManager.ZoneManager;
|
||||||
|
import engine.mobileAI.utilities.CombatUtilities;
|
||||||
|
import engine.objects.Building;
|
||||||
|
import engine.objects.City;
|
||||||
|
import engine.objects.Mob;
|
||||||
|
import engine.server.MBServerStatics;
|
||||||
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
|
public class SiegeEngineAI {
|
||||||
|
|
||||||
|
public static void run(Mob engine) {
|
||||||
|
|
||||||
|
//1. check to respawn if engine is dead or initially spawning
|
||||||
|
if (!engine.isAlive() || engine.despawned) {
|
||||||
|
if (System.currentTimeMillis() - engine.deathTime > MBServerStatics.FIFTEEN_MINUTES) {
|
||||||
|
engine.respawn();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//2. early exit if owner is null, siege engines cannot act with player intervention
|
||||||
|
if (engine.getOwner() == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
//3. early exit if target is null, siege engines have no purpose without a target
|
||||||
|
if (engine.combatTarget == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
//4. early exit if target is not a building, siege engines can only attack buildings
|
||||||
|
if (!engine.combatTarget.getObjectType().equals(Enum.GameObjectType.Building)) {
|
||||||
|
engine.setCombatTarget(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//5. early exit if target is out of range, engines don't move and neither do buildings, avoid infinite loop
|
||||||
|
if(CombatManager.NotInRange(engine,engine.combatTarget,engine.getRange())) {
|
||||||
|
engine.setCombatTarget(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//6. attack target, sanity checks passed, attack target
|
||||||
|
AttackBuilding(engine,(Building) engine.combatTarget);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AttackBuilding(Mob engine, Building target) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
if (engine == null || target == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (target.getRank() == -1 || !target.isVulnerable() || BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null) {
|
||||||
|
engine.setCombatTarget(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
City playercity = ZoneManager.getCityAtLocation(engine.getLoc());
|
||||||
|
|
||||||
|
if (playercity != null)
|
||||||
|
for (Mob guard : playercity.getParent().zoneMobSet)
|
||||||
|
if (guard.BehaviourType != null && guard.BehaviourType.equals(Enum.MobBehaviourType.GuardCaptain))
|
||||||
|
if (guard.getCombatTarget() == null && guard.getGuild() != null && engine.getGuild() != null && !guard.getGuild().equals(engine.getGuild()))
|
||||||
|
guard.setCombatTarget(engine);
|
||||||
|
|
||||||
|
|
||||||
|
MovementManager.sendRWSSMsg(engine);
|
||||||
|
|
||||||
|
CombatUtilities.combatCycle(engine, target, true, null);
|
||||||
|
int delay = 15000;
|
||||||
|
engine.setLastAttackTime(System.currentTimeMillis() + delay);
|
||||||
|
|
||||||
|
|
||||||
|
//if (mob.isSiege()) {
|
||||||
|
// PowerProjectileMsg ppm = new PowerProjectileMsg(mob, target);
|
||||||
|
// ppm.setRange(50);
|
||||||
|
// DispatchMessage.dispatchMsgToInterestArea(mob, ppm, DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
|
||||||
|
//}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.info(engine.getObjectUUID() + " " + engine.getName() + " Failed At: AttackBuilding" + " " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package engine.mobileAI.behaviours;
|
||||||
|
|
||||||
|
import engine.objects.Mob;
|
||||||
|
|
||||||
|
public class StandardAI {
|
||||||
|
public static void run(Mob mob){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -201,10 +201,12 @@ public class CombatUtilities {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
int anim = 75;
|
int anim = 75;
|
||||||
|
float speed;
|
||||||
|
|
||||||
//handle the retaliate here because even if the mob misses you can still retaliate
|
if (mainHand)
|
||||||
if (AbstractWorldObject.IsAbstractCharacter(target))
|
speed = agent.getSpeedHandOne();
|
||||||
CombatManager.handleRetaliate((AbstractCharacter) target, agent);
|
else
|
||||||
|
speed = agent.getSpeedHandTwo();
|
||||||
|
|
||||||
DamageType dt = DamageType.Crush;
|
DamageType dt = DamageType.Crush;
|
||||||
|
|
||||||
@@ -286,6 +288,11 @@ public class CombatUtilities {
|
|||||||
if (((Mob) target).isSiege())
|
if (((Mob) target).isSiege())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
//handle the retaliate
|
||||||
|
|
||||||
|
if (AbstractWorldObject.IsAbstractCharacter(target))
|
||||||
|
CombatManager.handleRetaliate((AbstractCharacter) target, agent);
|
||||||
|
|
||||||
if (target.getObjectType() == GameObjectType.Mob) {
|
if (target.getObjectType() == GameObjectType.Mob) {
|
||||||
Mob targetMob = (Mob) target;
|
Mob targetMob = (Mob) target;
|
||||||
if (targetMob.isSiege())
|
if (targetMob.isSiege())
|
||||||
|
|||||||
@@ -620,7 +620,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
DbManager.addToCache(mob);
|
DbManager.addToCache(mob);
|
||||||
mob.setPet(owner, true);
|
mob.setPet(owner, true);
|
||||||
mob.setWalkMode(false);
|
mob.setWalkMode(false);
|
||||||
mob.level = level;
|
|
||||||
mob.runAfterLoad();
|
mob.runAfterLoad();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -629,12 +628,8 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
createLock.writeLock().unlock();
|
createLock.writeLock().unlock();
|
||||||
}
|
}
|
||||||
parent.zoneMobSet.add(mob);
|
parent.zoneMobSet.add(mob);
|
||||||
// mob.level = level;
|
mob.level = level;
|
||||||
float healthMax = mob.getMobBase().getHealthMax();
|
mob.healthMax = mob.getMobBase().getHealthMax() * (mob.level * 0.5f);
|
||||||
if(mob.bonuses != null){
|
|
||||||
healthMax += mob.bonuses.getFloat(ModType.HealthFull,SourceType.None);
|
|
||||||
}
|
|
||||||
mob.healthMax = healthMax;
|
|
||||||
mob.health.set(mob.healthMax);
|
mob.health.set(mob.healthMax);
|
||||||
return mob;
|
return mob;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -308,10 +308,6 @@ public class MobBase extends AbstractGameObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void applyMobbaseEffects(Mob mob){
|
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){
|
for(MobBaseEffects mbe : mob.mobBase.mobbaseEffects){
|
||||||
if(mob.level >= mbe.getReqLvl()){
|
if(mob.level >= mbe.getReqLvl()){
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -5147,6 +5147,26 @@ 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) {
|
||||||
|
|
||||||
@@ -5184,14 +5204,8 @@ public class PlayerCharacter extends AbstractCharacter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isBoxed && !this.containsEffect(508555434)) {
|
if (this.isBoxed && !this.containsEffect(1672601862)) {
|
||||||
PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 508555434, 40, false);
|
PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 1672601862, 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()) {
|
||||||
@@ -5235,22 +5249,14 @@ public class PlayerCharacter extends AbstractCharacter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean valid = true;
|
for(PlayerCharacter pc : sameMachine)
|
||||||
for(PlayerCharacter pc : sameMachine){
|
|
||||||
if(!pc.safeZone)
|
|
||||||
valid = false;
|
|
||||||
}
|
|
||||||
if(valid) {
|
|
||||||
for (PlayerCharacter pc : sameMachine)
|
|
||||||
pc.isBoxed = true;
|
pc.isBoxed = true;
|
||||||
|
|
||||||
player.isBoxed = false;
|
player.isBoxed = false;
|
||||||
if (player.containsEffect(1672601862)) {
|
if(player.containsEffect(1672601862)) {
|
||||||
player.removeEffectBySource(EffectSourceType.DeathShroud, 41, false);
|
player.removeEffectBySource(EffectSourceType.DeathShroud,41,false);
|
||||||
}
|
|
||||||
}else{
|
|
||||||
ChatManager.chatSystemInfo(player, "All Boxes Must Be In Safezone To Switch");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public static boolean checkIfBoxed(PlayerCharacter player){
|
public static boolean checkIfBoxed(PlayerCharacter player){
|
||||||
if(ConfigManager.MB_WORLD_BOXLIMIT.getValue().equals("false")) {
|
if(ConfigManager.MB_WORLD_BOXLIMIT.getValue().equals("false")) {
|
||||||
@@ -5899,16 +5905,10 @@ 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());
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -164,17 +164,7 @@ 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;
|
||||||
int activePop = 0;
|
outString += " pop: " + SessionManager.getActivePlayerCharacterCount() + " max pop: " + SessionManager._maxPopulation;
|
||||||
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,7 +2,6 @@ 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;
|
||||||
@@ -16,25 +15,6 @@ 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;
|
||||||
|
|||||||
@@ -45,13 +45,19 @@ public class UpdateThread implements Runnable {
|
|||||||
public void run() {
|
public void run() {
|
||||||
lastRun = System.currentTimeMillis();
|
lastRun = System.currentTimeMillis();
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
if (System.currentTimeMillis() >= lastRun + instancedelay) { // Correct condition
|
||||||
this.processPlayerUpdate();
|
this.processPlayerUpdate();
|
||||||
|
lastRun = System.currentTimeMillis(); // Update lastRun after processing
|
||||||
|
}else {
|
||||||
|
try {
|
||||||
Thread.sleep(100); // Pause for 100ms to reduce CPU usage
|
Thread.sleep(100); // Pause for 100ms to reduce CPU usage
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Logger.error("Thread interrupted", e);
|
Logger.error("Thread interrupted", e);
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Thread.yield();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user