Browse Source

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

magicbox-1.5.2
MagicBot 9 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 @@
package engine.devcmd.cmds; package engine.devcmd.cmds;
import engine.Enum; import engine.Enum;
import engine.Enum.GameObjectType;
import engine.devcmd.AbstractDevCmd; import engine.devcmd.AbstractDevCmd;
import engine.gameManager.ChatManager; import engine.gameManager.ChatManager;
import engine.gameManager.DbManager;
import engine.gameManager.ZoneManager; import engine.gameManager.ZoneManager;
import engine.math.Vector3fImmutable; import engine.objects.AbstractGameObject;
import engine.objects.*; import engine.objects.Mob;
import engine.objects.PlayerCharacter;
import engine.objects.Zone;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
/**
* @author Eighty
*/
public class AddMobCmd extends AbstractDevCmd { public class AddMobCmd extends AbstractDevCmd {
public AddMobCmd() { public AddMobCmd() {
@ -38,27 +35,8 @@ public class AddMobCmd extends AbstractDevCmd {
Zone zone = ZoneManager.findSmallestZone(pc.getLoc()); 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; int loadID;
try { try {
loadID = Integer.parseInt(words[0]); loadID = Integer.parseInt(words[0]);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
@ -72,7 +50,6 @@ public class AddMobCmd extends AbstractDevCmd {
return; // NaN return; // NaN
} }
if (zone == null) { if (zone == null) {
throwbackError(pc, "Failed to find zone to place mob in."); throwbackError(pc, "Failed to find zone to place mob in.");
return; return;
@ -83,9 +60,9 @@ public class AddMobCmd extends AbstractDevCmd {
return; return;
} }
Mob mob = Mob.createMob(loadID, pc.getLoc(), Mob mob = Mob.createMob(loadID, pc.getLoc(),
null, zone, null, null, "", 1, Enum.AIAgentType.MOBILE); null, zone, null, null, "", 1, Enum.AIAgentType.MOBILE);
if (mob != null) { if (mob != null) {
mob.updateDatabase(); mob.updateDatabase();
ChatManager.chatSayInfo(pc, ChatManager.chatSayInfo(pc,

2
src/engine/gameManager/BuildingManager.java

@ -545,7 +545,7 @@ public enum BuildingManager {
NPC npc = null; 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) if (npc == null)
return false; return false;

6
src/engine/mobileAI/MobAI.java

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

21
src/engine/objects/Mob.java

@ -406,7 +406,6 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
Mob mobile = new Mob(); Mob mobile = new Mob();
mobile.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; 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.agentType = mobType;
mobile.behaviourType = MobBehaviourType.None; mobile.behaviourType = MobBehaviourType.None;
mobile.loadID = loadID; mobile.loadID = loadID;
@ -418,12 +417,17 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
mobile.guildUUID = guild.getObjectUUID(); mobile.guildUUID = guild.getObjectUUID();
mobile.parentZoneUUID = parent.getObjectUUID(); mobile.parentZoneUUID = parent.getObjectUUID();
if (building == null)
mobile.buildingUUID = 0;
else
mobile.buildingUUID = building.getObjectUUID(); mobile.buildingUUID = building.getObjectUUID();
if (mobile.buildingUUID != 0) if (mobile.buildingUUID != 0)
mobile.bindLoc = Vector3fImmutable.ZERO; mobile.bindLoc = Vector3fImmutable.ZERO;
else else
mobile.bindLoc = spawn; mobile.bindLoc = ZoneManager.worldToLocal(spawn, parent);
;
mobile.firstName = pirateName; mobile.firstName = pirateName;
@ -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 @Override
public long getDelay(@NotNull TimeUnit unit) { public long getDelay(@NotNull TimeUnit unit) {
long timeRemaining = this.respawnTime - System.currentTimeMillis(); long timeRemaining = this.respawnTime - System.currentTimeMillis();

8
src/engine/objects/NPC.java

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

Loading…
Cancel
Save