Browse Source

Unused and duplicate variable removed.

master
MagicBot 1 year ago
parent
commit
3883963225
  1. 6
      src/engine/db/handlers/dbMobHandler.java
  2. 45
      src/engine/mobileAI/MobAI.java
  3. 3
      src/engine/mobileAI/Threads/MobRespawnThread.java
  4. 23
      src/engine/net/client/handlers/MinionTrainingMsgHandler.java
  5. 27
      src/engine/objects/Mob.java

6
src/engine/db/handlers/dbMobHandler.java

@ -12,7 +12,6 @@ package engine.db.handlers; @@ -12,7 +12,6 @@ package engine.db.handlers;
import engine.gameManager.DbManager;
import engine.objects.Mob;
import engine.objects.Zone;
import engine.server.MBServerStatics;
import org.joda.time.DateTime;
import org.pmw.tinylog.Logger;
@ -122,10 +121,9 @@ public class dbMobHandler extends dbHandlerBase { @@ -122,10 +121,9 @@ public class dbMobHandler extends dbHandlerBase {
if (toCreate == null)
return;
if (toCreate != null) {
toCreate.setTimeToSpawnSiege(System.currentTimeMillis() + MBServerStatics.FIFTEEN_MINUTES);
if (toCreate != null)
toCreate.setDeathTime(System.currentTimeMillis());
}
}
} catch (SQLException e) {

45
src/engine/mobileAI/MobAI.java

@ -50,15 +50,18 @@ public class MobAI { @@ -50,15 +50,18 @@ public class MobAI {
}
if (target.getObjectType() == Enum.GameObjectType.PlayerCharacter && canCast(mob)) {
if (mob.isPlayerGuard() == false && MobCast(mob)) {
mob.updateLocation();
return;
}
if (mob.isPlayerGuard() == true && GuardCast(mob)) {
mob.updateLocation();
return;
}
}
if (!CombatUtilities.inRangeToAttack(mob, target))
return;
@ -258,7 +261,9 @@ public class MobAI { @@ -258,7 +261,9 @@ public class MobAI {
//guard captains inherit barracks patrol points dynamically
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) {
Building barracks = mob.building;
if (barracks != null && barracks.patrolPoints != null && !barracks.getPatrolPoints().isEmpty()) {
mob.patrolPoints = barracks.patrolPoints;
} else {
@ -275,8 +280,8 @@ public class MobAI { @@ -275,8 +280,8 @@ public class MobAI {
MovementUtilities.aiMove(mob, mob.destination, true);
if (mob.BehaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) {
for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet()) {
if (mob.BehaviourType.equals(Enum.MobBehaviourType.GuardCaptain))
for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet())
//make sure mob is out of combat stance
@ -288,8 +293,6 @@ public class MobAI { @@ -288,8 +293,6 @@ public class MobAI {
MovementUtilities.aiMove(minion.getKey(), formationPatrolPoint, true);
}
}
}
}
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackTarget" + " " + e.getMessage());
}
@ -306,11 +309,14 @@ public class MobAI { @@ -306,11 +309,14 @@ public class MobAI {
return false;
if(mob.isPlayerGuard == true){
int contractID;
if(mob.BehaviourType.equals(Enum.MobBehaviourType.GuardMinion))
contractID = mob.npcOwner.contract.getContractID();
else
contractID = mob.contract.getContractID();
if(Enum.MinionType.ContractToMinionMap.get(contractID).isMage() == false)
return false;
}
@ -384,24 +390,20 @@ public class MobAI { @@ -384,24 +390,20 @@ public class MobAI {
//check for hit-roll
if (mobPower.requiresHitRoll) {
if (mobPower.requiresHitRoll)
if (CombatUtilities.triggerDefense(mob, mob.getCombatTarget()))
return false;
}
// Cast the spell
if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mobPower.getRange())) {
PerformActionMsg msg;
if (!mobPower.isHarmful() || mobPower.targetSelf) {
PowersManager.useMobPower(mob, mob, mobPower, powerRank);
msg = PowersManager.createPowerMsg(mobPower, powerRank, mob, mob);
}
else {
} else {
PowersManager.useMobPower(mob, target, mobPower, powerRank);
msg = PowersManager.createPowerMsg(mobPower, powerRank, mob, target);
}
@ -410,6 +412,7 @@ public class MobAI { @@ -410,6 +412,7 @@ public class MobAI {
PowersManager.finishUseMobPower(msg, mob, 0, 0);
long randomCooldown = (long)((ThreadLocalRandom.current().nextInt(10,15) * 1000) * MobAIThread.AI_CAST_FREQUENCY);
mob.nextCastTime = System.currentTimeMillis() + randomCooldown;
return true;
}
@ -642,10 +645,12 @@ public class MobAI { @@ -642,10 +645,12 @@ public class MobAI {
mob.setCombatTarget(null);
return;
}
if (mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal())
CheckToSendMobHome(mob);
if (mob.getCombatTarget() != null) {
if (mob.getCombatTarget().isAlive() == false) {
mob.setCombatTarget(null);
return;
@ -753,7 +758,7 @@ public class MobAI { @@ -753,7 +758,7 @@ public class MobAI {
for (AbstractWorldObject awoMob : awoList) {
//dont scan self.
// exclude self.
if (aiAgent.equals(awoMob))
continue;
@ -867,7 +872,7 @@ public class MobAI { @@ -867,7 +872,7 @@ public class MobAI {
}
}
} else if (System.currentTimeMillis() > (aiAgent.deathTime + (aiAgent.spawnTime * 1000))) {
//aiAgent.respawn();
if (Zone.respawnQue.contains(aiAgent) == false) {
Zone.respawnQue.add(aiAgent);
}
@ -957,6 +962,7 @@ public class MobAI { @@ -957,6 +962,7 @@ public class MobAI {
float rangeSquared = mob.getRange() * mob.getRange();
float distanceSquared = mob.getLoc().distanceSquared2D(mob.getCombatTarget().getLoc());
if(mob.isMoving() == true && distanceSquared < rangeSquared - 50) {
mob.destination = mob.getLoc();
MovementUtilities.moveToLocation(mob, mob.destination, 0);
@ -1002,12 +1008,14 @@ public class MobAI { @@ -1002,12 +1008,14 @@ public class MobAI {
Mob aggroMob = (Mob) awoMob;
//dont attack other guards
//don't attack other guards
if (aggroMob.isGuard())
continue;
if(aggroMob.BehaviourType.equals(Enum.MobBehaviourType.Pet1))
continue;
if (mob.getLoc().distanceSquared2D(aggroMob.getLoc()) > sqr(50))
continue;
@ -1095,10 +1103,10 @@ public class MobAI { @@ -1095,10 +1103,10 @@ public class MobAI {
private static void PetLogic(Mob mob) {
try {
if (mob.getOwner() == null && mob.isNecroPet() == false && mob.isSiege() == false) {
if (mob.getOwner() == null && mob.isNecroPet() == false && mob.isSiege() == false)
if (ZoneManager.getSeaFloor().zoneMobSet.contains(mob))
mob.killCharacter("no owner");
}
if (MovementUtilities.canMove(mob) && mob.BehaviourType.canRoam)
CheckMobMovement(mob);
@ -1110,17 +1118,16 @@ public class MobAI { @@ -1110,17 +1118,16 @@ public class MobAI {
if (mob.getTimestamps().containsKey("HEALTHRECOVERED") == false)
mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis());
if (mob.isSit() && mob.getTimeStamp("HEALTHRECOVERED") < System.currentTimeMillis() + 3000) {
if (mob.isSit() && mob.getTimeStamp("HEALTHRECOVERED") < System.currentTimeMillis() + 3000)
if (mob.getHealth() < mob.getHealthMax()) {
float recoveredHealth = mob.getHealthMax() * ((1 + mob.getBonuses().getFloatPercentAll(Enum.ModType.HealthRecoverRate, Enum.SourceType.None)) * 0.01f);
mob.setHealth(mob.getHealth() + recoveredHealth);
mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis());
if (mob.getHealth() > mob.getHealthMax()) {
if (mob.getHealth() > mob.getHealthMax())
mob.setHealth(mob.getHealthMax());
}
}
}
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: PetLogic" + " " + e.getMessage());
}

3
src/engine/mobileAI/Threads/MobRespawnThread.java

@ -25,9 +25,6 @@ import org.pmw.tinylog.Logger; @@ -25,9 +25,6 @@ import org.pmw.tinylog.Logger;
public class MobRespawnThread implements Runnable {
// Instance variables
// Thread constructor
public MobRespawnThread() {
Logger.info(" MobRespawnThread thread has started!");

23
src/engine/net/client/handlers/MinionTrainingMsgHandler.java

@ -14,7 +14,6 @@ import engine.net.DispatchMessage; @@ -14,7 +14,6 @@ import engine.net.DispatchMessage;
import engine.net.client.ClientConnection;
import engine.net.client.msg.*;
import engine.objects.*;
import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger;
import java.util.ArrayList;
@ -69,7 +68,6 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { @@ -69,7 +68,6 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
npc.getSiegeMinionMap().remove(toRemove);
//toRemove.disableIntelligence();
WorldGrid.RemoveWorldObject(toRemove);
if (toRemove.getParentZone() != null)
@ -199,9 +197,9 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { @@ -199,9 +197,9 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
if (npc == null)
return true;
Building b = BuildingManager.getBuildingFromCache(minionMsg.getBuildingID());
Building building = BuildingManager.getBuildingFromCache(minionMsg.getBuildingID());
if (b == null)
if (building == null)
return true;
//clear minion
@ -211,6 +209,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { @@ -211,6 +209,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
if (minionMsg.getType() == 2) {
Mob toRemove = Mob.getFromCache(minionMsg.getUUID());
if (!npc.getSiegeMinionMap().containsKey(toRemove))
return true;
@ -219,7 +218,6 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { @@ -219,7 +218,6 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
npc.getSiegeMinionMap().remove(toRemove);
//toRemove.disableIntelligence();
WorldGrid.RemoveWorldObject(toRemove);
if (toRemove.getParentZone() != null)
@ -236,21 +234,18 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { @@ -236,21 +234,18 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
}
// we Found the move to remove, lets break the for loop so it doesnt look for more.
ManageCityAssetsMsg mca1 = new ManageCityAssetsMsg(player, b);
ManageCityAssetsMsg mca1 = new ManageCityAssetsMsg(player, building);
mca1.actionType = 3;
mca1.setTargetType(b.getObjectType().ordinal());
mca1.setTargetID(b.getObjectUUID());
mca1.setTargetType(building.getObjectType().ordinal());
mca1.setTargetID(building.getObjectUUID());
mca1.setTargetType3(npc.getObjectType().ordinal());
mca1.setTargetID3(npc.getObjectUUID());
mca1.setAssetName1(b.getName());
mca1.setAssetName1(building.getName());
mca1.setUnknown54(1);
Dispatch dispatch = Dispatch.borrow(player, mca1);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
;
ManageNPCMsg mnm = new ManageNPCMsg(npc);
dispatch = Dispatch.borrow(player, mnm);
@ -302,14 +297,14 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { @@ -302,14 +297,14 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
if (!DbManager.MobQueries.ADD_TO_GUARDS(npc.getObjectUUID(), mobBase, pirateName, npc.getSiegeMinionMap().size() + 1))
return true;
Mob toCreate = Mob.createGuardMob(npc, npc.getGuild(), zone, b.getLoc(), npc.getLevel(), pirateName);
Mob toCreate = Mob.createGuardMob(npc, npc.getGuild(), zone, building.getLoc(), npc.getLevel(), pirateName);
if (toCreate == null)
return true;
// toCreate.despawn();
if (toCreate != null) {
toCreate.setTimeToSpawnSiege(System.currentTimeMillis() + MBServerStatics.FIFTEEN_MINUTES);
toCreate.setDeathTime(System.currentTimeMillis());
toCreate.parentZone.zoneMobSet.add(toCreate);
}

27
src/engine/objects/Mob.java

@ -95,7 +95,6 @@ public class Mob extends AbstractIntelligenceAgent { @@ -95,7 +95,6 @@ public class Mob extends AbstractIntelligenceAgent {
private AbstractWorldObject fearedObject = null;
private int buildingID;
private boolean isSiege = false;
private long timeToSpawnSiege;
private long lastAttackTime = 0;
private int lastMobPowerToken = 0;
private HashMap<Integer, MobEquipment> equip = null;
@ -103,6 +102,7 @@ public class Mob extends AbstractIntelligenceAgent { @@ -103,6 +102,7 @@ public class Mob extends AbstractIntelligenceAgent {
private DateTime upgradeDateTime = null;
private boolean lootSync = false;
/**
* No Id Constructor
*/
@ -1309,10 +1309,9 @@ public class Mob extends AbstractIntelligenceAgent { @@ -1309,10 +1309,9 @@ public class Mob extends AbstractIntelligenceAgent {
this.hasLoot = false;
this.playerAgroMap.clear();
this.timeToSpawnSiege = System.currentTimeMillis() + 60 * 15 * 1000;
if (this.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) {
if (this.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal())
this.spawnTime = (int) (-2.500 * ((Mob) this.npcOwner).building.getRank() + 22.5) * 60;
}
if (this.isPet()) {
PlayerCharacter petOwner = this.getOwner();
@ -1334,9 +1333,7 @@ public class Mob extends AbstractIntelligenceAgent { @@ -1334,9 +1333,7 @@ public class Mob extends AbstractIntelligenceAgent {
//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) {
@ -1382,9 +1379,8 @@ public class Mob extends AbstractIntelligenceAgent { @@ -1382,9 +1379,8 @@ public class Mob extends AbstractIntelligenceAgent {
}
public void respawn() {
//Commenting out Mob ID rotation.
this.despawned = false;
//this.playerAgroMap.clear();
this.setCombatTarget(null);
this.setHealth(this.healthMax);
this.stamina.set(this.staminaMax);
@ -1397,17 +1393,22 @@ public class Mob extends AbstractIntelligenceAgent { @@ -1397,17 +1393,22 @@ public class Mob extends AbstractIntelligenceAgent {
this.lastBindLoc = this.bindLoc;
this.setLoc(this.lastBindLoc);
this.stopMovement(this.lastBindLoc);
NPCManager.applyRuneSetEffects(this);
this.recalculateStats();
this.setHealth(this.healthMax);
if (this.building == null && this.npcOwner != null && ((Mob) this.npcOwner).BehaviourType.ordinal() == MobBehaviourType.GuardCaptain.ordinal()) {
if (this.building == null && this.npcOwner != null && ((Mob) this.npcOwner).BehaviourType.ordinal() == MobBehaviourType.GuardCaptain.ordinal())
this.building = ((Mob) this.npcOwner).building;
} else if (this.building != null) {
else if (this.building != null)
this.region = BuildingManager.GetRegion(this.building, bindLoc.x, bindLoc.y, bindLoc.z);
}
//MovementManager.translocate(this, this.bindLoc, this.region);
if (!this.isSiege && !this.isPlayerGuard && contract == null)
loadInventory();
this.updateLocation();
}
@ -2059,10 +2060,6 @@ public class Mob extends AbstractIntelligenceAgent { @@ -2059,10 +2060,6 @@ public class Mob extends AbstractIntelligenceAgent {
this.isSiege = isSiege;
}
public void setTimeToSpawnSiege(long timeToSpawnSiege) {
this.timeToSpawnSiege = timeToSpawnSiege;
}
public void setNpcOwner(AbstractCharacter npcOwner) {
this.npcOwner = npcOwner;
}

Loading…
Cancel
Save