Browse Source

guard aggro rules for hostiles

master
FatBoy-DOTC 2 years ago
parent
commit
c54aa5f9fc
  1. 4
      src/engine/Enum.java
  2. 10
      src/engine/ai/MobileFSM.java
  3. 10
      src/engine/gameManager/CombatManager.java

4
src/engine/Enum.java

@ -2823,8 +2823,8 @@ public class Enum { @@ -2823,8 +2823,8 @@ public class Enum {
Simple(null, false, false, true, false, false),
Helpee(null, false, true, true, false, true),
HelpeeWimpy(null, true, false, true, false, false),
GuardCaptain(null, false, true, true, true, false),
GuardMinion(GuardCaptain, false, true, true, false, true),
GuardCaptain(null, false, true, true, false, false),
GuardMinion(GuardCaptain, false, true, true, false, false),
GuardWallArcher(null, false, true, false, false, false),
Wanderer(null, false, true, true, false, false),
HamletGuard(null, false, true, false, false, false),

10
src/engine/ai/MobileFSM.java

@ -550,9 +550,10 @@ public class MobileFSM { @@ -550,9 +550,10 @@ public class MobileFSM {
CheckForPlayerGuardAggro(mob);
return;
}
if(mob.npcOwner.getCombatTarget() != null){
if(mob.npcOwner.getCombatTarget() != null)
mob.setCombatTarget(mob.npcOwner.getCombatTarget());
}
else
mob.setCombatTarget(null);
CheckMobMovement(mob);
if (mob.getCombatTarget() != null)
CheckForAttack(mob);
@ -622,14 +623,11 @@ public class MobileFSM { @@ -622,14 +623,11 @@ public class MobileFSM {
continue;
if (MovementUtilities.inRangeToAggro(mob, loadedPlayer)) {
mob.setCombatTarget(loadedPlayer);
if (mob.contract != null)
for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet())
minion.getKey().setCombatTarget(loadedPlayer);
return;
}
}
}
private static Boolean GuardCanAggro(Mob mob, PlayerCharacter target) {
public static Boolean GuardCanAggro(Mob mob, PlayerCharacter target) {
if (mob.getGuild().getNation().equals(target.getGuild().getNation()))
return false;
//first check condemn list for aggro allowed (allies button is checked)

10
src/engine/gameManager/CombatManager.java

@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
package engine.gameManager;
import engine.Enum.*;
import engine.ai.MobileFSM;
import engine.exception.MsgSendException;
import engine.job.JobContainer;
import engine.job.JobScheduler;
@ -27,6 +28,7 @@ import engine.server.MBServerStatics; @@ -27,6 +28,7 @@ import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger;
import java.util.HashSet;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadLocalRandom;
@ -134,6 +136,14 @@ public enum CombatManager { @@ -134,6 +136,14 @@ public enum CombatManager {
CombatManager.createTimer(pc, MBServerStatics.SLOT_OFFHAND, 1, true); // attack in 0.1 of a second
}
}
City playerCity = ZoneManager.getCityAtLocation(pc.getLoc());
if( playerCity != null)
for(Building barracks : playerCity.cityBarracks)
for(Map.Entry<AbstractCharacter,Integer> entry : barracks.getHirelings().entrySet())
if(entry.getKey().getCombatTarget() == null){
if(MobileFSM.GuardCanAggro((Mob) entry.getKey(),pc))
entry.getKey().setCombatTarget(pc);
}
}
public static void setAttackTarget(PetAttackMsg msg, ClientConnection origin) throws MsgSendException {

Loading…
Cancel
Save