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; @@ -13,6 +13,7 @@ import engine.InterestManagement.WorldGrid;
import engine.ai.utilities.CombatUtilities;
import engine.ai.utilities.MovementUtilities;
import engine.gameManager.*;
import engine.math.Vector2f;
import engine.math.Vector3f;
import engine.math.Vector3fImmutable;
import engine.net.DispatchMessage;
@ -350,7 +351,9 @@ public class MobileFSM { @@ -350,7 +351,9 @@ public class MobileFSM {
}
CheckForRespawn(mob);
//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;
}
if (!mob.isAlive()) {
@ -358,7 +361,7 @@ public class MobileFSM { @@ -358,7 +361,7 @@ public class MobileFSM {
CheckForRespawn(mob);
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
return;
if (mob.isCombat() && mob.getCombatTarget() == null) {
@ -368,10 +371,13 @@ public class MobileFSM { @@ -368,10 +371,13 @@ public class MobileFSM {
DispatchMessage.sendToAllInRange(mob, rwss);
}
mob.updateLocation();
CheckToSendMobHome(mob);
if(mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal()) {
CheckToSendMobHome(mob);
}
if (mob.combatTarget != null && mob.combatTarget.isAlive() == false) {
mob.setCombatTarget(null);
}
mob.updateLocation();
switch (mob.BehaviourType) {
case GuardCaptain:
GuardCaptainLogic(mob);
@ -430,6 +436,9 @@ public class MobileFSM { @@ -430,6 +436,9 @@ public class MobileFSM {
return;
switch (mob.BehaviourType) {
case Pet1:
if(mob.getOwner() == null){
return;
}
if (!mob.playerAgroMap.containsKey(mob.getOwner().getObjectUUID())) {
//mob no longer has its owner loaded, translocate pet to owner
MovementManager.translocate(mob, mob.getOwner().getLoc(), null);
@ -479,6 +488,7 @@ public class MobileFSM { @@ -479,6 +488,7 @@ public class MobileFSM {
if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_WITH_LOOT) {
aiAgent.despawn();
aiAgent.deathTime = System.currentTimeMillis();
return;
}
//No items in inventory.
} else {
@ -487,17 +497,20 @@ public class MobileFSM { @@ -487,17 +497,20 @@ public class MobileFSM {
if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_ONCE_LOOTED) {
aiAgent.despawn();
aiAgent.deathTime = System.currentTimeMillis();
return;
}
//Mob never had Loot.
} else {
if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER) {
aiAgent.despawn();
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();
return;
}
}
@ -568,17 +581,28 @@ public class MobileFSM { @@ -568,17 +581,28 @@ public class MobileFSM {
private static void chaseTarget(Mob mob) {
mob.updateMovementState();
if (mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false) {
mob.setCombatTarget(null);
return;
}
//if (mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false) {
// mob.setCombatTarget(null);
// return;
//}
if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == false) {
if (mob.getRange() > 15) {
mob.destination = mob.getCombatTarget().getLoc();
MovementUtilities.moveToLocation(mob, mob.destination, 0);
} else {
mob.destination = MovementUtilities.GetDestinationToCharacter(mob, (AbstractCharacter) mob.getCombatTarget());
MovementUtilities.moveToLocation(mob, mob.destination, mob.getRange());
//check if building
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 { @@ -626,6 +650,11 @@ public class MobileFSM {
}
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())
mob.setCombatTarget(null);
if (MovementUtilities.canMove(mob) && mob.BehaviourType.canRoam)

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

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

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

@ -31,7 +31,7 @@ public class dbBuildingLocationHandler extends dbHandlerBase { @@ -31,7 +31,7 @@ public class dbBuildingLocationHandler extends dbHandlerBase {
ArrayList<BuildingLocation> buildingLocations = new ArrayList<>();
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 " +
"GROUP BY buildingID, slot " +
"ORDER BY buildingID, slot ASC;")) {

26
src/engine/objects/Mob.java

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

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

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

Loading…
Cancel
Save