Browse Source

mobs respawn, mob location sync, mobs attack

master
FatBoy-DOTC 1 year ago
parent
commit
7e25875fa2
  1. 17
      src/engine/ai/MobileFSM.java
  2. 10
      src/engine/objects/Mob.java

17
src/engine/ai/MobileFSM.java

@ -80,7 +80,7 @@ public class MobileFSM {
if (System.currentTimeMillis() < mob.getLastAttackTime()) if (System.currentTimeMillis() < mob.getLastAttackTime())
return; return;
// ranged mobs cant attack while running. skip until they finally stop. // ranged mobs cant attack while running. skip until they finally stop.
if (mob.isMoving()) if (mob.isMoving() && mob.getRange() > 20)
return; return;
// add timer for last attack. // add timer for last attack.
ItemBase mainHand = mob.getWeaponItemBase(true); ItemBase mainHand = mob.getWeaponItemBase(true);
@ -378,18 +378,19 @@ public class MobileFSM {
rwss.setPlayer(mob); rwss.setPlayer(mob);
DispatchMessage.sendToAllInRange(mob, rwss); DispatchMessage.sendToAllInRange(mob, rwss);
} }
//mob.updateLocation();
if(mob.isMoving() == true){
mob.setLoc(mob.getMovementLoc());
}
if(mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal()) { if(mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal()) {
CheckToSendMobHome(mob); CheckToSendMobHome(mob);
} }
if (mob.combatTarget != null && mob.combatTarget.isAlive() == false) { if (mob.combatTarget != null && mob.combatTarget.isAlive() == false) {
mob.setCombatTarget(null); mob.setCombatTarget(null);
} }
//mob.updateLocation(); mob.updateLocation();
if(mob.isMoving()){ if(mob.getTimestamps().containsKey("MOVEMENTSYNC") == false){
mob.getTimestamps().put("MOVEMENTSYNC",System.currentTimeMillis());
}
if(mob.getTimeStamp("MOVEMENTSYNC") < System.currentTimeMillis() + 1000){
mob.getTimestamps().put("MOVEMENTSYNC",System.currentTimeMillis());
mob.setLoc(mob.getMovementLoc()); mob.setLoc(mob.getMovementLoc());
} }
switch (mob.BehaviourType) { switch (mob.BehaviourType) {
@ -735,7 +736,7 @@ public class MobileFSM {
if (mob.BehaviourType.canRoam) if (mob.BehaviourType.canRoam)
CheckMobMovement(mob); CheckMobMovement(mob);
//check if mob can attack if it isn't wimpy //check if mob can attack if it isn't wimpy
if (!mob.BehaviourType.isWimpy && !mob.isMoving() && mob.combatTarget != null) if (!mob.BehaviourType.isWimpy && mob.combatTarget != null)
CheckForAttack(mob); CheckForAttack(mob);
} }

10
src/engine/objects/Mob.java

@ -1299,6 +1299,8 @@ public class Mob extends AbstractIntelligenceAgent {
Dispatch dispatch; Dispatch dispatch;
try { try {
//resync corpses
this.setLoc(this.getMovementLoc());
if (this.isSiege) { if (this.isSiege) {
this.deathTime = System.currentTimeMillis(); this.deathTime = System.currentTimeMillis();
//this.state = STATE.Dead; //this.state = STATE.Dead;
@ -1375,8 +1377,7 @@ public class Mob extends AbstractIntelligenceAgent {
this.combat = false; this.combat = false;
this.walkMode = true; this.walkMode = true;
this.combatTarget = null; this.combatTarget = null;
//resync corpses
this.setLoc(this.loc);
this.hasLoot = this.charItemManager.getInventoryCount() > 0; this.hasLoot = this.charItemManager.getInventoryCount() > 0;
} catch (Exception e) { } catch (Exception e) {
Logger.error(e); Logger.error(e);
@ -1385,6 +1386,7 @@ public class Mob extends AbstractIntelligenceAgent {
public void respawn() { public void respawn() {
//Commenting out Mob ID rotation. //Commenting out Mob ID rotation.
this.despawned = false;
this.playerAgroMap.clear(); this.playerAgroMap.clear();
this.setCombatTarget(null); this.setCombatTarget(null);
this.setHealth(this.healthMax); this.setHealth(this.healthMax);
@ -1396,8 +1398,7 @@ public class Mob extends AbstractIntelligenceAgent {
this.isAlive.set(true); this.isAlive.set(true);
this.deathTime = 0; this.deathTime = 0;
this.lastBindLoc = this.bindLoc; this.lastBindLoc = this.bindLoc;
//this.setLoc(this.lastBindLoc); this.setLoc(this.lastBindLoc);
this.setLoc(bindLoc);
this.stopMovement(this.lastBindLoc); this.stopMovement(this.lastBindLoc);
NPCManager.applyRuneSetEffects(this); NPCManager.applyRuneSetEffects(this);
this.recalculateStats(); this.recalculateStats();
@ -1410,7 +1411,6 @@ public class Mob extends AbstractIntelligenceAgent {
//MovementManager.translocate(this, this.bindLoc, this.region); //MovementManager.translocate(this, this.bindLoc, this.region);
if (!this.isSiege && !this.isPlayerGuard && contract == null) if (!this.isSiege && !this.isPlayerGuard && contract == null)
loadInventory(); loadInventory();
this.despawned = false;
} }
public void despawn() { public void despawn() {

Loading…
Cancel
Save