Browse Source

simplified mob aI

lakebane
FatBoy-DOTC 1 month ago
parent
commit
ec23f78c58
  1. 21
      src/engine/mobileAI/Behaviours/StandardMob.java

21
src/engine/mobileAI/Behaviours/StandardMob.java

@ -1,6 +1,7 @@
package engine.mobileAI.Behaviours; package engine.mobileAI.Behaviours;
import engine.Enum; import engine.Enum;
import engine.InterestManagement.InterestManager;
import engine.InterestManagement.WorldGrid; import engine.InterestManagement.WorldGrid;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import engine.mobileAI.utilities.CombatUtilities; import engine.mobileAI.utilities.CombatUtilities;
@ -86,14 +87,14 @@ public class StandardMob {
} }
//No items in inventory. //No items in inventory.
} else if (mob.isHasLoot()) { } else if (mob.isHasLoot()) {
if (System.currentTimeMillis() > mob.deathTime + MBServerStatics.DESPAWN_TIMER_ONCE_LOOTED) { if (System.currentTimeMillis() > mob.deathTime + 1000L) {
mob.despawn(); mob.despawn();
mob.deathTime = System.currentTimeMillis(); mob.deathTime = System.currentTimeMillis();
return; return;
} }
//Mob never had Loot. //Mob never had Loot.
} else { } else {
if (System.currentTimeMillis() > mob.deathTime + MBServerStatics.DESPAWN_TIMER_ONCE_LOOTED) { if (System.currentTimeMillis() > mob.deathTime + 1000L){//MBServerStatics.DESPAWN_TIMER_ONCE_LOOTED) {
mob.despawn(); mob.despawn();
mob.deathTime = System.currentTimeMillis(); mob.deathTime = System.currentTimeMillis();
return; return;
@ -104,8 +105,11 @@ public class StandardMob {
if(Mob.discDroppers.contains(mob)) if(Mob.discDroppers.contains(mob))
return; return;
float baseRespawnTimer = mob.spawnTime;
if (System.currentTimeMillis() > (mob.deathTime + (mob.spawnTime * 1000L))) { float reduction = ((100-mob.level) * 0.01f);
float reducedRespawnTime = baseRespawnTimer * reduction;
float respawnTimer = reducedRespawnTime * 1000f;
if (System.currentTimeMillis() > (mob.deathTime + respawnTimer)) {
Zone.respawnQue.add(mob); Zone.respawnQue.add(mob);
} }
} }
@ -196,12 +200,16 @@ public class StandardMob {
}else{ }else{
//patrol //patrol
if (mob.isMoving()) if (mob.isMoving()) {
mob.stopPatrolTime = System.currentTimeMillis();
return; return;
}
if(mob.stopPatrolTime + 5000L < System.currentTimeMillis()) {
Vector3fImmutable patrolPoint = Vector3fImmutable.getRandomPointOnCircle(mob.bindLoc, 40f); Vector3fImmutable patrolPoint = Vector3fImmutable.getRandomPointOnCircle(mob.bindLoc, 40f);
MovementUtilities.aiMove(mob, patrolPoint, true); MovementUtilities.aiMove(mob, patrolPoint, true);
} }
} }
}
public static void CheckForAttack(Mob mob){ public static void CheckForAttack(Mob mob){
@ -211,6 +219,8 @@ public class StandardMob {
if(mob.getLastAttackTime() > System.currentTimeMillis()) if(mob.getLastAttackTime() > System.currentTimeMillis())
return; return;
mob.updateLocation();
InterestManager.forceLoad(mob);
if (mob.BehaviourType.callsForHelp) if (mob.BehaviourType.callsForHelp)
MobCallForHelp(mob); MobCallForHelp(mob);
@ -235,6 +245,7 @@ public class StandardMob {
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay); mob.setLastAttackTime(System.currentTimeMillis() + attackDelay);
} }
} }
public static void MobCallForHelp(Mob mob){ public static void MobCallForHelp(Mob mob){
HashSet<AbstractWorldObject> mobs = WorldGrid.getObjectsInRangePartial(mob.loc,60f, MBServerStatics.MASK_MOB); HashSet<AbstractWorldObject> mobs = WorldGrid.getObjectsInRangePartial(mob.loc,60f, MBServerStatics.MASK_MOB);
for(AbstractWorldObject awo : mobs){ for(AbstractWorldObject awo : mobs){

Loading…
Cancel
Save