forked from MagicBane/Server
Enum moved to Enum.
Updated logic in rs constructor to handle blanks properly.
This commit is contained in:
@@ -2792,4 +2792,66 @@ public class Enum {
|
|||||||
ADMIN;
|
ADMIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum MobBehaviourType {
|
||||||
|
//Power
|
||||||
|
Power(null, false, true, true, true, false),
|
||||||
|
PowerHelpee(Power, false, true, true, false, true),
|
||||||
|
PowerHelpeeWimpy(Power, true, false, true, false, false),
|
||||||
|
PowerGrouperWimpy(Power, true, false, true, false, false),
|
||||||
|
PowerAggro(Power, false, true, true, false, true),
|
||||||
|
PowerAggroHelpee(Power, false, true, true, false, true),
|
||||||
|
//Aggro
|
||||||
|
Aggro(null, false, true, true, true, false),
|
||||||
|
AggroHelpee(Aggro, false, true, true, false, true),
|
||||||
|
AggroHelpeeWimpy(Aggro, true, false, true, false, false),
|
||||||
|
AggroGrouperWimpy(Aggro, true, false, true, false, false),
|
||||||
|
//Spell
|
||||||
|
Spell(null, false, true, true, true, false),
|
||||||
|
SpellHelpee(Spell, false, true, true, false, true),
|
||||||
|
SpellHelpeeWimpy(Spell, true, false, true, false, false),
|
||||||
|
SpellGrouperWimpy(Spell, true, false, true, false, false),
|
||||||
|
SpellAggro(Spell, false, true, true, false, true),
|
||||||
|
SpellAggroHelpee(Spell, false, true, true, false, true),
|
||||||
|
SpellAggroHelpeeWimpy(Spell, true, false, true, false, false),
|
||||||
|
SpellAggroHelpeeEpic(Spell, false, true, true, false, true),
|
||||||
|
SpellAggroGrouperWimpy(Spell, true, false, true, false, false),
|
||||||
|
//Independent Types
|
||||||
|
SimpleStandingGuard(null, false, false, false, false, false),
|
||||||
|
Pet1(null, false, false, true, false, false),
|
||||||
|
Simple(null, false, false, true, false, false),
|
||||||
|
Helpee(null, false, true, true, false, true),
|
||||||
|
HelpeeWimpy(null, true, false, true, false, false),
|
||||||
|
None(null, false, false, false, false, false),
|
||||||
|
GuardCaptain(null, false, true, true, true, false),
|
||||||
|
GuardMinion(GuardCaptain, false, true, true, false, true),
|
||||||
|
Wanderer(null, false, false, false, false, false),
|
||||||
|
HamletGuard(null, false, false, false, false, false),
|
||||||
|
AggroWanderer(null, false, false, false, false, false);
|
||||||
|
|
||||||
|
private static HashMap<Integer, MobBehaviourType> _behaviourTypes = new HashMap<>();
|
||||||
|
public MobBehaviourType BehaviourHelperType;
|
||||||
|
public boolean isWimpy;
|
||||||
|
public boolean isAgressive;
|
||||||
|
public boolean canRoam;
|
||||||
|
public boolean callsForHelp;
|
||||||
|
public boolean respondsToCallForHelp;
|
||||||
|
|
||||||
|
MobBehaviourType(MobBehaviourType helpeebehaviourType, boolean wimpy, boolean agressive, boolean canroam, boolean callsforhelp, boolean respondstocallforhelp) {
|
||||||
|
this.BehaviourHelperType = helpeebehaviourType;
|
||||||
|
this.isWimpy = wimpy;
|
||||||
|
this.isAgressive = agressive;
|
||||||
|
this.canRoam = canroam;
|
||||||
|
this.callsForHelp = callsforhelp;
|
||||||
|
this.respondsToCallForHelp = respondstocallforhelp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MobBehaviourType getByName(String name) {
|
||||||
|
for (MobBehaviourType behaviourType : values()) {
|
||||||
|
if (behaviourType.name().equalsIgnoreCase(name)) {
|
||||||
|
return behaviourType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return MobBehaviourType.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
// Magicbane Emulator Project © 2013 - 2022
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
// www.magicbane.com
|
// www.magicbane.com
|
||||||
package engine.ai;
|
package engine.ai;
|
||||||
|
import engine.Enum;
|
||||||
import engine.Enum.DispatchChannel;
|
import engine.Enum.DispatchChannel;
|
||||||
import engine.InterestManagement.WorldGrid;
|
import engine.InterestManagement.WorldGrid;
|
||||||
import engine.ai.utilities.CombatUtilities;
|
import engine.ai.utilities.CombatUtilities;
|
||||||
@@ -20,64 +21,12 @@ import engine.powers.ActionsBase;
|
|||||||
import engine.powers.PowersBase;
|
import engine.powers.PowersBase;
|
||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
import static engine.math.FastMath.sqr;
|
import static engine.math.FastMath.sqr;
|
||||||
public class MobileFSM {
|
public class MobileFSM {
|
||||||
public enum MobBehaviourType {
|
|
||||||
//Power
|
|
||||||
Power(null, false, true, true, true, false),
|
|
||||||
PowerHelpee(Power, false, true, true, false, true),
|
|
||||||
PowerHelpeeWimpy(Power, true, false, true, false, false),
|
|
||||||
PowerGrouperWimpy(Power, true, false, true, false, false),
|
|
||||||
PowerAggro(Power, false, true, true, false, true),
|
|
||||||
PowerAggroHelpee(Power, false, true, true, false, true),
|
|
||||||
//Aggro
|
|
||||||
Aggro(null, false, true, true, true, false),
|
|
||||||
AggroHelpee(Aggro, false, true, true, false, true),
|
|
||||||
AggroHelpeeWimpy(Aggro, true, false, true, false, false),
|
|
||||||
AggroGrouperWimpy(Aggro, true, false, true, false, false),
|
|
||||||
//Spell
|
|
||||||
Spell(null, false, true, true, true, false),
|
|
||||||
SpellHelpee(Spell, false, true, true, false, true),
|
|
||||||
SpellHelpeeWimpy(Spell, true, false, true, false, false),
|
|
||||||
SpellGrouperWimpy(Spell, true, false, true, false, false),
|
|
||||||
SpellAggro(Spell, false, true, true, false, true),
|
|
||||||
SpellAggroHelpee(Spell, false, true, true, false, true),
|
|
||||||
SpellAggroHelpeeWimpy(Spell, true, false, true, false, false),
|
|
||||||
SpellAggroHelpeeEpic(Spell, false, true, true, false, true),
|
|
||||||
SpellAggroGrouperWimpy(Spell, true, false, true, false, false),
|
|
||||||
//Independent Types
|
|
||||||
SimpleStandingGuard(null, false, false, false, false, false),
|
|
||||||
Pet1(null, false, false, true, false, false),
|
|
||||||
Simple(null, false, false, true, false, false),
|
|
||||||
Helpee(null, false, true, true, false, true),
|
|
||||||
HelpeeWimpy(null, true, false, true, false, false),
|
|
||||||
None(null, false, false, false, false, false),
|
|
||||||
GuardCaptain(null, false, true, true, true, false),
|
|
||||||
GuardMinion(GuardCaptain, false, true, true, false, true);
|
|
||||||
|
|
||||||
private static HashMap<Integer, MobBehaviourType> _behaviourTypes = new HashMap<>();
|
|
||||||
public MobBehaviourType BehaviourHelperType;
|
|
||||||
public boolean isWimpy;
|
|
||||||
public boolean isAgressive;
|
|
||||||
public boolean canRoam;
|
|
||||||
public boolean callsForHelp;
|
|
||||||
public boolean respondsToCallForHelp;
|
|
||||||
|
|
||||||
MobBehaviourType(MobBehaviourType helpeebehaviourType, boolean wimpy, boolean agressive, boolean canroam, boolean callsforhelp, boolean respondstocallforhelp) {
|
|
||||||
this.BehaviourHelperType = helpeebehaviourType;
|
|
||||||
this.isWimpy = wimpy;
|
|
||||||
this.isAgressive = agressive;
|
|
||||||
this.canRoam = canroam;
|
|
||||||
this.callsForHelp = callsforhelp;
|
|
||||||
this.respondsToCallForHelp = respondstocallforhelp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void mobAttack(Mob aiAgent) {
|
private static void mobAttack(Mob aiAgent) {
|
||||||
|
|
||||||
@@ -534,7 +483,7 @@ public class MobileFSM {
|
|||||||
if (mob == null) {
|
if (mob == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(mob.BehaviourType.ordinal() == MobBehaviourType.GuardCaptain.ordinal()){
|
if(mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()){
|
||||||
//this is a player slotted guard captain
|
//this is a player slotted guard captain
|
||||||
GuardCaptainLogic(mob);
|
GuardCaptainLogic(mob);
|
||||||
return;
|
return;
|
||||||
@@ -553,10 +502,10 @@ public class MobileFSM {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//check for players that can be aggroed if mob is agressive and has no target
|
//check for players that can be aggroed if mob is agressive and has no target
|
||||||
if (mob.BehaviourType.isAgressive && mob.getCombatTarget() == null && mob.BehaviourType != MobBehaviourType.SimpleStandingGuard) {
|
if (mob.BehaviourType.isAgressive && mob.getCombatTarget() == null && mob.BehaviourType != Enum.MobBehaviourType.SimpleStandingGuard) {
|
||||||
//normal aggro
|
//normal aggro
|
||||||
CheckForAggro(mob);
|
CheckForAggro(mob);
|
||||||
} else if (mob.BehaviourType == MobBehaviourType.SimpleStandingGuard) {
|
} else if (mob.BehaviourType == Enum.MobBehaviourType.SimpleStandingGuard) {
|
||||||
//safehold guard
|
//safehold guard
|
||||||
SafeGuardAggro(mob);
|
SafeGuardAggro(mob);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package engine.gameManager;
|
|||||||
|
|
||||||
import engine.Enum;
|
import engine.Enum;
|
||||||
import engine.InterestManagement.WorldGrid;
|
import engine.InterestManagement.WorldGrid;
|
||||||
import engine.ai.MobileFSM;
|
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.net.Dispatch;
|
import engine.net.Dispatch;
|
||||||
import engine.net.DispatchMessage;
|
import engine.net.DispatchMessage;
|
||||||
@@ -325,7 +324,7 @@ public enum NPCManager {
|
|||||||
mob.deathTime = System.currentTimeMillis();
|
mob.deathTime = System.currentTimeMillis();
|
||||||
mob.spawnTime = 900;
|
mob.spawnTime = 900;
|
||||||
mob.npcOwner = guardCaptain;
|
mob.npcOwner = guardCaptain;
|
||||||
mob.BehaviourType = MobileFSM.MobBehaviourType.GuardMinion;
|
mob.BehaviourType = Enum.MobBehaviourType.GuardMinion;
|
||||||
return mob;
|
return mob;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
|
|
||||||
public EnumBitSet<MonsterType> notEnemy;
|
public EnumBitSet<MonsterType> notEnemy;
|
||||||
public EnumBitSet<Enum.MonsterType> enemy;
|
public EnumBitSet<Enum.MonsterType> enemy;
|
||||||
public MobileFSM.MobBehaviourType BehaviourType;
|
public MobBehaviourType BehaviourType;
|
||||||
public ArrayList<Vector3fImmutable> patrolPoints;
|
public ArrayList<Vector3fImmutable> patrolPoints;
|
||||||
public int lastPatrolPointIndex = 0;
|
public int lastPatrolPointIndex = 0;
|
||||||
public long stopPatrolTime = 0;
|
public long stopPatrolTime = 0;
|
||||||
@@ -184,7 +184,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
this.parentZone = parent;
|
this.parentZone = parent;
|
||||||
this.parentZoneID = (parent != null) ? parent.getObjectUUID() : 0;
|
this.parentZoneID = (parent != null) ? parent.getObjectUUID() : 0;
|
||||||
this.ownerUID = owner.getObjectUUID();
|
this.ownerUID = owner.getObjectUUID();
|
||||||
this.BehaviourType = MobileFSM.MobBehaviourType.Pet1;
|
this.BehaviourType = Enum.MobBehaviourType.Pet1;
|
||||||
initializeMob(true, false, false);
|
initializeMob(true, false, false);
|
||||||
clearStatic();
|
clearStatic();
|
||||||
}
|
}
|
||||||
@@ -1996,7 +1996,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
}
|
}
|
||||||
this.BehaviourType = this.getMobBase().fsm;
|
this.BehaviourType = this.getMobBase().fsm;
|
||||||
if(this.isPlayerGuard() && this.contract != null){
|
if(this.isPlayerGuard() && this.contract != null){
|
||||||
this.BehaviourType = MobileFSM.MobBehaviourType.GuardCaptain;
|
this.BehaviourType = Enum.MobBehaviourType.GuardCaptain;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.error(e.getMessage());
|
Logger.error(e.getMessage());
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ package engine.objects;
|
|||||||
|
|
||||||
import ch.claude_martin.enumbitset.EnumBitSet;
|
import ch.claude_martin.enumbitset.EnumBitSet;
|
||||||
import engine.Enum;
|
import engine.Enum;
|
||||||
import engine.ai.MobileFSM;
|
|
||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
import engine.gameManager.NPCManager;
|
import engine.gameManager.NPCManager;
|
||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
@@ -61,7 +60,7 @@ public class MobBase extends AbstractGameObject {
|
|||||||
private float walkCombat = 0;
|
private float walkCombat = 0;
|
||||||
private float runCombat = 0;
|
private float runCombat = 0;
|
||||||
public int bootySet;
|
public int bootySet;
|
||||||
public MobileFSM.MobBehaviourType fsm;
|
public Enum.MobBehaviourType fsm;
|
||||||
|
|
||||||
public EnumBitSet<Enum.MonsterType> notEnemy;
|
public EnumBitSet<Enum.MonsterType> notEnemy;
|
||||||
public EnumBitSet<Enum.MonsterType> enemy;
|
public EnumBitSet<Enum.MonsterType> enemy;
|
||||||
@@ -90,7 +89,7 @@ public class MobBase extends AbstractGameObject {
|
|||||||
this.defenseRating = rs.getInt("defense");
|
this.defenseRating = rs.getInt("defense");
|
||||||
this.attackRange = rs.getFloat("attackRange");
|
this.attackRange = rs.getFloat("attackRange");
|
||||||
this.bootySet = rs.getInt("bootySet");
|
this.bootySet = rs.getInt("bootySet");
|
||||||
this.fsm = MobileFSM.MobBehaviourType.valueOf(rs.getString("fsm"));
|
this.fsm = Enum.MobBehaviourType.getByName(rs.getString("fsm"));
|
||||||
|
|
||||||
if (MobbaseGoldEntry.MobbaseGoldMap.containsKey(this.loadID)){
|
if (MobbaseGoldEntry.MobbaseGoldMap.containsKey(this.loadID)){
|
||||||
MobbaseGoldEntry goldEntry = MobbaseGoldEntry.MobbaseGoldMap.get(this.loadID);
|
MobbaseGoldEntry goldEntry = MobbaseGoldEntry.MobbaseGoldMap.get(this.loadID);
|
||||||
|
|||||||
Reference in New Issue
Block a user