Browse Source

Merge remote-tracking branch 'origin/bugfix-safeguard-aggro' into magicbox-1.5.2

magicbox-1.5.2
MagicBot 10 months ago
parent
commit
250e3407fa
  1. 35
      src/engine/devcmd/cmds/AddMobCmd.java
  2. 2
      src/engine/gameManager/BuildingManager.java
  3. 6
      src/engine/mobileAI/MobAI.java
  4. 21
      src/engine/objects/Mob.java
  5. 8
      src/engine/objects/NPC.java

35
src/engine/devcmd/cmds/AddMobCmd.java

@ -10,18 +10,15 @@ @@ -10,18 +10,15 @@
package engine.devcmd.cmds;
import engine.Enum;
import engine.Enum.GameObjectType;
import engine.devcmd.AbstractDevCmd;
import engine.gameManager.ChatManager;
import engine.gameManager.DbManager;
import engine.gameManager.ZoneManager;
import engine.math.Vector3fImmutable;
import engine.objects.*;
import engine.objects.AbstractGameObject;
import engine.objects.Mob;
import engine.objects.PlayerCharacter;
import engine.objects.Zone;
import org.pmw.tinylog.Logger;
/**
* @author Eighty
*/
public class AddMobCmd extends AbstractDevCmd {
public AddMobCmd() {
@ -38,27 +35,8 @@ public class AddMobCmd extends AbstractDevCmd { @@ -38,27 +35,8 @@ public class AddMobCmd extends AbstractDevCmd {
Zone zone = ZoneManager.findSmallestZone(pc.getLoc());
if (words[0].equals("all")) {
for (AbstractGameObject mobbaseAGO : DbManager.getList(GameObjectType.MobBase)) {
MobBase mb = (MobBase) mobbaseAGO;
int loadID = mb.getObjectUUID();
Mob mob = Mob.createMob(loadID, Vector3fImmutable.getRandomPointInCircle(pc.getLoc(), 100),
null, zone, null, null, "", 1, Enum.AIAgentType.MOBILE);
if (mob != null) {
mob.updateDatabase();
this.setResult(String.valueOf(mob.getDBID()));
} else {
throwbackError(pc, "Failed to create mob of type " + loadID);
Logger.error("Failed to create mob of type "
+ loadID);
}
}
return;
}
int loadID;
try {
loadID = Integer.parseInt(words[0]);
} catch (NumberFormatException e) {
@ -72,7 +50,6 @@ public class AddMobCmd extends AbstractDevCmd { @@ -72,7 +50,6 @@ public class AddMobCmd extends AbstractDevCmd {
return; // NaN
}
if (zone == null) {
throwbackError(pc, "Failed to find zone to place mob in.");
return;
@ -83,9 +60,9 @@ public class AddMobCmd extends AbstractDevCmd { @@ -83,9 +60,9 @@ public class AddMobCmd extends AbstractDevCmd {
return;
}
Mob mob = Mob.createMob(loadID, pc.getLoc(),
null, zone, null, null, "", 1, Enum.AIAgentType.MOBILE);
if (mob != null) {
mob.updateDatabase();
ChatManager.chatSayInfo(pc,

2
src/engine/gameManager/BuildingManager.java

@ -545,7 +545,7 @@ public enum BuildingManager { @@ -545,7 +545,7 @@ public enum BuildingManager {
NPC npc = null;
npc = NPC.createNPC(pirateName, NpcID.getObjectUUID(), NpcLoc, null, zone, (short) rank, building);
npc = NPC.createNPC(pirateName, NpcID.getObjectUUID(), NpcLoc, building.getGuild(), zone, (short) rank, building);
if (npc == null)
return false;

6
src/engine/mobileAI/MobAI.java

@ -939,16 +939,16 @@ public class MobAI { @@ -939,16 +939,16 @@ public class MobAI {
//dont scan self.
if (mob.equals(awoMob) || (mob.agentType.equals(Enum.AIAgentType.GUARDCAPTAIN)) == true)
if (mob.equals(awoMob))
continue;
Mob aggroMob = (Mob) awoMob;
//don't attack other guards
if ((aggroMob.agentType.equals(Enum.AIAgentType.GUARDCAPTAIN)))
if (aggroMob.isGuard() == true)
continue;
//don't attack pets
if (aggroMob.agentType.equals(Enum.AIAgentType.PET))
continue;

21
src/engine/objects/Mob.java

@ -406,7 +406,6 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed { @@ -406,7 +406,6 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
Mob mobile = new Mob();
mobile.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET;
//mobile.agentType = AIAgentType.MOBILE; this method is only called to make guard captains and wall archers
mobile.agentType = mobType;
mobile.behaviourType = MobBehaviourType.None;
mobile.loadID = loadID;
@ -418,12 +417,17 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed { @@ -418,12 +417,17 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
mobile.guildUUID = guild.getObjectUUID();
mobile.parentZoneUUID = parent.getObjectUUID();
if (building == null)
mobile.buildingUUID = 0;
else
mobile.buildingUUID = building.getObjectUUID();
if (mobile.buildingUUID != 0)
mobile.bindLoc = Vector3fImmutable.ZERO;
else
mobile.bindLoc = spawn;
mobile.bindLoc = ZoneManager.worldToLocal(spawn, parent);
;
mobile.firstName = pirateName;
@ -1889,6 +1893,19 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed { @@ -1889,6 +1893,19 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
}
}
public Boolean isGuard(){
switch(this.behaviourType){
case GuardMinion:
case GuardCaptain:
case GuardWallArcher:
case HamletGuard:
case SimpleStandingGuard:
return true;
}
return false;
}
@Override
public long getDelay(@NotNull TimeUnit unit) {
long timeRemaining = this.respawnTime - System.currentTimeMillis();

8
src/engine/objects/NPC.java

@ -461,15 +461,19 @@ public class NPC extends AbstractCharacter { @@ -461,15 +461,19 @@ public class NPC extends AbstractCharacter {
NPC newNPC = new NPC();
newNPC.parentZoneUUID = parent.getObjectUUID();
newNPC.name = name;
newNPC.contractUUID = contractID;
if (building == null)
newNPC.bindLoc = spawn;
newNPC.bindLoc = ZoneManager.worldToLocal(spawn, parent);
else
newNPC.bindLoc = Vector3fImmutable.ZERO;
newNPC.parentZoneUUID = parent.getObjectUUID();
if (guild == null)
newNPC.guildUUID = 0;
else
newNPC.guildUUID = guild.getObjectUUID();
if (building == null)

Loading…
Cancel
Save