Browse Source

Merge remote-tracking branch 'origin/master' into bugfix-loot-rolls

master
MagicBot 1 year ago
parent
commit
ea0370ac51
  1. 49
      src/engine/ai/MobileFSM.java
  2. 3
      src/engine/ai/utilities/CombatUtilities.java
  3. 2
      src/engine/db/handlers/dbBuildingLocationHandler.java
  4. 26
      src/engine/objects/Mob.java
  5. 15
      src/engine/powers/poweractions/CreateMobPowerAction.java

49
src/engine/ai/MobileFSM.java

@ -13,6 +13,7 @@ import engine.InterestManagement.WorldGrid;
import engine.ai.utilities.CombatUtilities; import engine.ai.utilities.CombatUtilities;
import engine.ai.utilities.MovementUtilities; import engine.ai.utilities.MovementUtilities;
import engine.gameManager.*; import engine.gameManager.*;
import engine.math.Vector2f;
import engine.math.Vector3f; import engine.math.Vector3f;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import engine.net.DispatchMessage; import engine.net.DispatchMessage;
@ -350,7 +351,9 @@ public class MobileFSM {
} }
CheckForRespawn(mob); CheckForRespawn(mob);
//check to send mob home for player guards to prevent exploit of dragging guards away and then teleporting //check to send mob home for player guards to prevent exploit of dragging guards away and then teleporting
CheckToSendMobHome(mob); if(mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal()){
CheckToSendMobHome(mob);
}
return; return;
} }
if (!mob.isAlive()) { if (!mob.isAlive()) {
@ -358,7 +361,7 @@ public class MobileFSM {
CheckForRespawn(mob); CheckForRespawn(mob);
return; return;
} }
if (mob.playerAgroMap.isEmpty() && mob.isPlayerGuard == false) if (mob.playerAgroMap.isEmpty() && mob.isPlayerGuard == false && mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal())
//no players loaded, no need to proceed //no players loaded, no need to proceed
return; return;
if (mob.isCombat() && mob.getCombatTarget() == null) { if (mob.isCombat() && mob.getCombatTarget() == null) {
@ -368,10 +371,13 @@ public class MobileFSM {
DispatchMessage.sendToAllInRange(mob, rwss); DispatchMessage.sendToAllInRange(mob, rwss);
} }
mob.updateLocation(); mob.updateLocation();
CheckToSendMobHome(mob); if(mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal()) {
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();
switch (mob.BehaviourType) { switch (mob.BehaviourType) {
case GuardCaptain: case GuardCaptain:
GuardCaptainLogic(mob); GuardCaptainLogic(mob);
@ -430,6 +436,9 @@ public class MobileFSM {
return; return;
switch (mob.BehaviourType) { switch (mob.BehaviourType) {
case Pet1: case Pet1:
if(mob.getOwner() == null){
return;
}
if (!mob.playerAgroMap.containsKey(mob.getOwner().getObjectUUID())) { if (!mob.playerAgroMap.containsKey(mob.getOwner().getObjectUUID())) {
//mob no longer has its owner loaded, translocate pet to owner //mob no longer has its owner loaded, translocate pet to owner
MovementManager.translocate(mob, mob.getOwner().getLoc(), null); MovementManager.translocate(mob, mob.getOwner().getLoc(), null);
@ -479,6 +488,7 @@ public class MobileFSM {
if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_WITH_LOOT) { if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_WITH_LOOT) {
aiAgent.despawn(); aiAgent.despawn();
aiAgent.deathTime = System.currentTimeMillis(); aiAgent.deathTime = System.currentTimeMillis();
return;
} }
//No items in inventory. //No items in inventory.
} else { } else {
@ -487,17 +497,20 @@ public class MobileFSM {
if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_ONCE_LOOTED) { if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_ONCE_LOOTED) {
aiAgent.despawn(); aiAgent.despawn();
aiAgent.deathTime = System.currentTimeMillis(); aiAgent.deathTime = System.currentTimeMillis();
return;
} }
//Mob never had Loot. //Mob never had Loot.
} else { } else {
if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER) { if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER) {
aiAgent.despawn(); aiAgent.despawn();
aiAgent.deathTime = System.currentTimeMillis(); aiAgent.deathTime = System.currentTimeMillis();
return;
} }
} }
} }
} else if (System.currentTimeMillis() > aiAgent.deathTime + (aiAgent.spawnTime * 1000)) { } else if (System.currentTimeMillis() > (aiAgent.deathTime + (aiAgent.spawnTime * 1000))) {
aiAgent.respawn(); aiAgent.respawn();
return;
} }
} }
@ -568,17 +581,28 @@ public class MobileFSM {
private static void chaseTarget(Mob mob) { private static void chaseTarget(Mob mob) {
mob.updateMovementState(); mob.updateMovementState();
if (mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false) { //if (mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false) {
mob.setCombatTarget(null); // mob.setCombatTarget(null);
return; // return;
} //}
if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == false) { if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == false) {
if (mob.getRange() > 15) { if (mob.getRange() > 15) {
mob.destination = mob.getCombatTarget().getLoc(); mob.destination = mob.getCombatTarget().getLoc();
MovementUtilities.moveToLocation(mob, mob.destination, 0); MovementUtilities.moveToLocation(mob, mob.destination, 0);
} else { } else {
mob.destination = MovementUtilities.GetDestinationToCharacter(mob, (AbstractCharacter) mob.getCombatTarget()); //check if building
MovementUtilities.moveToLocation(mob, mob.destination, mob.getRange()); switch (mob.getCombatTarget().getObjectType()) {
case PlayerCharacter:
case Mob:
mob.destination = MovementUtilities.GetDestinationToCharacter(mob, (AbstractCharacter) mob.getCombatTarget());
MovementUtilities.moveToLocation(mob, mob.destination, mob.getRange());
break;
case Building:
mob.destination = mob.getCombatTarget().getLoc();
MovementUtilities.moveToLocation(mob,mob.getCombatTarget().getLoc(),0);
break;
}
} }
} }
} }
@ -626,6 +650,11 @@ public class MobileFSM {
} }
private static void PetLogic(Mob mob) { private static void PetLogic(Mob mob) {
if(mob.getOwner() == null && mob.isNecroPet() == false && mob.isSiege() == false){
if(ZoneManager.getSeaFloor().zoneMobSet.contains(mob)){
mob.killCharacter("no owner");
}
}
if (mob.getCombatTarget() != null && !mob.getCombatTarget().isAlive()) if (mob.getCombatTarget() != null && !mob.getCombatTarget().isAlive())
mob.setCombatTarget(null); mob.setCombatTarget(null);
if (MovementUtilities.canMove(mob) && mob.BehaviourType.canRoam) if (MovementUtilities.canMove(mob) && mob.BehaviourType.canRoam)

3
src/engine/ai/utilities/CombatUtilities.java

@ -363,11 +363,10 @@ public class CombatUtilities {
float damage; float damage;
float min = 40; float min = 40;
float max = 60; float max = 60;
AbstractWorldObject target = agent.getCombatTarget();
float dmgMultiplier = 1 + agent.getBonuses().getFloatPercentAll(ModType.MeleeDamageModifier, SourceType.None); float dmgMultiplier = 1 + agent.getBonuses().getFloatPercentAll(ModType.MeleeDamageModifier, SourceType.None);
double minDmg = getMinDmg(min, agent, null); double minDmg = getMinDmg(min, agent, null);
double maxDmg = getMaxDmg(max, agent, null); double maxDmg = getMaxDmg(max, agent, null);
dmgMultiplier += agent.getLevel() / 10; dmgMultiplier += agent.getLevel() * 0.1f;
range = (float) (maxDmg - minDmg); range = (float) (maxDmg - minDmg);
damage = min + ((ThreadLocalRandom.current().nextFloat() * range) + (ThreadLocalRandom.current().nextFloat() * range)) / 2; damage = min + ((ThreadLocalRandom.current().nextFloat() * range) + (ThreadLocalRandom.current().nextFloat() * range)) / 2;
return (int) (damage * dmgMultiplier); return (int) (damage * dmgMultiplier);

2
src/engine/db/handlers/dbBuildingLocationHandler.java

@ -31,7 +31,7 @@ public class dbBuildingLocationHandler extends dbHandlerBase {
ArrayList<BuildingLocation> buildingLocations = new ArrayList<>(); ArrayList<BuildingLocation> buildingLocations = new ArrayList<>();
try (Connection connection = DbManager.getConnection(); try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("select * from static_building_location " + PreparedStatement preparedStatement = connection.prepareStatement("select `ID`, `BuildingID`, `type`, `slot`, `unknown`, `locX`, `locY`, `locZ`, `w`, `rotX`, `rotY`, `rotZ` from static_building_location " +
"where type = 6 or type = 8 " + "where type = 6 or type = 8 " +
"GROUP BY buildingID, slot " + "GROUP BY buildingID, slot " +
"ORDER BY buildingID, slot ASC;")) { "ORDER BY buildingID, slot ASC;")) {

26
src/engine/objects/Mob.java

@ -590,7 +590,10 @@ public class Mob extends AbstractIntelligenceAgent {
} finally { } finally {
createLock.writeLock().unlock(); createLock.writeLock().unlock();
} }
parent.zoneMobSet.add(mob);
mob.level = level;
mob.healthMax = mob.getMobBase().getHealthMax() * (mob.level * 0.5f);
mob.health.set(mob.healthMax);
return mob; return mob;
} }
@ -1331,9 +1334,11 @@ public class Mob extends AbstractIntelligenceAgent {
this.combatTarget = null; this.combatTarget = null;
this.hasLoot = false; this.hasLoot = false;
if (this.parentZone != null) //if (this.parentZone != null)
this.parentZone.zoneMobSet.remove(this); //this.parentZone.zoneMobSet.remove(this);
if(ZoneManager.getSeaFloor().zoneMobSet.contains(this)) {
ZoneManager.getSeaFloor().zoneMobSet.remove(this);
}
try { try {
this.clearEffects(); this.clearEffects();
} catch (Exception e) { } catch (Exception e) {
@ -1372,7 +1377,6 @@ public class Mob extends AbstractIntelligenceAgent {
this.combatTarget = null; this.combatTarget = null;
this.hasLoot = this.charItemManager.getInventoryCount() > 0; this.hasLoot = this.charItemManager.getInventoryCount() > 0;
} catch (Exception e) { } catch (Exception e) {
Logger.error(e); Logger.error(e);
} }
@ -1951,12 +1955,14 @@ public class Mob extends AbstractIntelligenceAgent {
this.equip = new HashMap<>(0); this.equip = new HashMap<>(0);
} }
// Combine mobbase and mob aggro arrays into one bitvector // Combine mobbase and mob aggro arrays into one bitvector
if (this.getMobBase().notEnemy.size() > 0) //skip for pets
this.notEnemy.addAll(this.getMobBase().notEnemy); if(this.isPet() == false && this.isSummonedPet() == false && this.isNecroPet() == false) {
if (this.getMobBase().notEnemy.size() > 0)
if (this.getMobBase().enemy.size() > 0) this.notEnemy.addAll(this.getMobBase().notEnemy);
this.enemy.addAll(this.getMobBase().enemy);
if (this.getMobBase().enemy.size() > 0)
this.enemy.addAll(this.getMobBase().enemy);
}
try { try {
NPCManager.applyRuneSetEffects(this); NPCManager.applyRuneSetEffects(this);
recalculateStats(); recalculateStats();

15
src/engine/powers/poweractions/CreateMobPowerAction.java

@ -11,7 +11,9 @@ package engine.powers.poweractions;
import engine.Enum; import engine.Enum;
import engine.InterestManagement.WorldGrid; import engine.InterestManagement.WorldGrid;
import engine.ai.utilities.MovementUtilities;
import engine.gameManager.DbManager; import engine.gameManager.DbManager;
import engine.gameManager.MovementManager;
import engine.gameManager.NPCManager; import engine.gameManager.NPCManager;
import engine.gameManager.ZoneManager; import engine.gameManager.ZoneManager;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
@ -83,9 +85,9 @@ public class CreateMobPowerAction extends AbstractPowerAction {
WorldGrid.RemoveWorldObject(currentPet); WorldGrid.RemoveWorldObject(currentPet);
currentPet.setCombatTarget(null); currentPet.setCombatTarget(null);
if (currentPet.getParentZone() != null) //if (currentPet.getParentZone() != null)
currentPet.getParentZone().zoneMobSet.remove(currentPet); //currentPet.getParentZone().zoneMobSet.remove(currentPet);
seaFloor.zoneMobSet.remove(currentPet);
currentPet.playerAgroMap.clear(); currentPet.playerAgroMap.clear();
try { try {
@ -116,8 +118,8 @@ public class CreateMobPowerAction extends AbstractPowerAction {
currentPet.setOwner(null); currentPet.setOwner(null);
WorldGrid.RemoveWorldObject(currentPet); WorldGrid.RemoveWorldObject(currentPet);
//currentPet.getParentZone().zoneMobSet.remove(currentPet);
currentPet.getParentZone().zoneMobSet.remove(currentPet); seaFloor.zoneMobSet.remove(currentPet);
currentPet.playerAgroMap.clear(); currentPet.playerAgroMap.clear();
currentPet.clearEffects(); currentPet.clearEffects();
//currentPet.disableIntelligence(); //currentPet.disableIntelligence();
@ -153,6 +155,9 @@ public class CreateMobPowerAction extends AbstractPowerAction {
// if (mobID == 12021 || mobID == 12022) //Necro Pets // if (mobID == 12021 || mobID == 12022) //Necro Pets
// pet.setPet(owner, true); // pet.setPet(owner, true);
owner.setPet(pet); owner.setPet(pet);
if(pet.isSiege() == false) {
MovementManager.translocate(pet, owner.getLoc(), owner.region);
}
PetMsg pm = new PetMsg(5, pet); PetMsg pm = new PetMsg(5, pet);
Dispatch dispatch = Dispatch.borrow(owner, pm); Dispatch dispatch = Dispatch.borrow(owner, pm);
DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY); DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY);

Loading…
Cancel
Save