Browse Source

isPlayerguard refactored to derive from agenttype.

feature-workorder
MagicBot 1 year ago
parent
commit
1ac76cfcd8
  1. 9
      src/engine/gameManager/NPCManager.java
  2. 4
      src/engine/mobileAI/MobAI.java
  3. 2
      src/engine/objects/AbstractIntelligenceAgent.java
  4. 30
      src/engine/objects/Mob.java

9
src/engine/gameManager/NPCManager.java

@ -30,18 +30,11 @@ public enum NPCManager { @@ -30,18 +30,11 @@ public enum NPCManager {
if (mob.runeSet == 0)
return;
//Apply all rune effects.
if (NPCManager._runeSetMap.get(mob.runeSet).contains(252623)) {
mob.isPlayerGuard = true;
}
// Only captains have contracts
if (mob.contract != null || mob.isPlayerGuard)
if (mob.contract != null || mob.isPlayerGuard())
applyEffectsForRune(mob, 252621);
// Apply effects from RuneSet
if (mob.runeSet != 0)

4
src/engine/mobileAI/MobAI.java

@ -308,7 +308,7 @@ public class MobAI { @@ -308,7 +308,7 @@ public class MobAI {
if (mob == null)
return false;
if(mob.isPlayerGuard == true){
if (mob.isPlayerGuard() == true) {
int contractID;
@ -606,7 +606,7 @@ public class MobAI { @@ -606,7 +606,7 @@ public class MobAI {
//override for guards
if (mob.despawned && mob.isPlayerGuard) {
if (mob.despawned && mob.isPlayerGuard()) {
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion)) {
if (mob.guardCaptain.isAlive() == false || ((Mob) mob.guardCaptain).despawned == true) {

2
src/engine/objects/AbstractIntelligenceAgent.java

@ -32,7 +32,7 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter { @@ -32,7 +32,7 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
protected Vector3fImmutable lastBindLoc;
public boolean assist = false;
public Enum.AIAgentType agentType = Enum.AIAgentType.MOBILE;
public boolean isPlayerGuard = false;
public AbstractCharacter guardCaptain;
public EnumBitSet<Enum.MonsterType> notEnemy = EnumBitSet.noneOf(Enum.MonsterType.class);
public EnumBitSet<Enum.MonsterType> enemy = EnumBitSet.noneOf(Enum.MonsterType.class);

30
src/engine/objects/Mob.java

@ -32,6 +32,7 @@ import org.pmw.tinylog.Logger; @@ -32,6 +32,7 @@ import org.pmw.tinylog.Logger;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.concurrent.ConcurrentHashMap;
@ -183,7 +184,7 @@ public class Mob extends AbstractIntelligenceAgent { @@ -183,7 +184,7 @@ public class Mob extends AbstractIntelligenceAgent {
} else if (tid == 100962 || tid == 100965) { //Spydraxxx the Mighty, Denigo Tantric
writer.putInt(2);
serializeRune(mob, writer, 5, GameObjectType.NPCClassRuneTwo.ordinal(), 252621); //guard rune
} else if (mob.contract != null || mob.isPlayerGuard) {
} else if (mob.contract != null || mob.isPlayerGuard()) {
writer.putInt(3);
serializeRune(mob, writer, 3, GameObjectType.NPCClassRuneTwo.ordinal(), MobBase.GetClassType(mob.getMobBaseID())); //warrior class
serializeRune(mob, writer, 5, GameObjectType.NPCClassRuneThree.ordinal(), 252621); //guard rune
@ -340,7 +341,7 @@ public class Mob extends AbstractIntelligenceAgent { @@ -340,7 +341,7 @@ public class Mob extends AbstractIntelligenceAgent {
writer.putInt(0);
writer.putInt(0);
if (!mob.isAlive() && !mob.isPet() && !mob.isNecroPet() && !mob.behaviourType.equals(MobBehaviourType.SiegeEngine) && !mob.isPlayerGuard) {
if (!mob.isAlive() && !mob.isPet() && !mob.isNecroPet() && !mob.behaviourType.equals(MobBehaviourType.SiegeEngine) && !mob.isPlayerGuard()) {
writer.putInt(0);
writer.putInt(0);
}
@ -454,7 +455,6 @@ public class Mob extends AbstractIntelligenceAgent { @@ -454,7 +455,6 @@ public class Mob extends AbstractIntelligenceAgent {
minionMobile.guardCaptain = guardCaptain;
minionMobile.spawnTime = (int) (-2.500 * guardCaptain.building.getRank() + 22.5) * 60;
minionMobile.behaviourType = Enum.MobBehaviourType.GuardMinion;
minionMobile.isPlayerGuard = true;
minionMobile.guardedCity = guardCaptain.guardedCity;
minionMobile.patrolPoints = guardCaptain.building.patrolPoints;
@ -545,7 +545,6 @@ public class Mob extends AbstractIntelligenceAgent { @@ -545,7 +545,6 @@ public class Mob extends AbstractIntelligenceAgent {
petMinion.healthMax = MobBase.getMobBase(loadID).getHealthMax() * (petMinion.level * 0.5f);
petMinion.health.set(petMinion.healthMax);
petMinion.behaviourType = MobBehaviourType.Pet1;
petMinion.agentType = AIAgentType.PET;
petMinion.firstName = "";
petMinion.lastName = "";
@ -747,7 +746,7 @@ public class Mob extends AbstractIntelligenceAgent { @@ -747,7 +746,7 @@ public class Mob extends AbstractIntelligenceAgent {
// get rune and effect bonuses
bonus *= (1 + this.bonuses.getFloatPercentAll(ModType.Speed, SourceType.None));
if (this.isPlayerGuard)
if (this.isPlayerGuard())
switch (this.mobBase.getLoadID()) {
case 2111:
if (this.isWalk())
@ -815,7 +814,7 @@ public class Mob extends AbstractIntelligenceAgent { @@ -815,7 +814,7 @@ public class Mob extends AbstractIntelligenceAgent {
Group g = GroupManager.getGroup((PlayerCharacter) attacker);
// Give XP, now handled inside the Experience Object
if (!this.isPet() && !this.isNecroPet() && !(this.agentType.equals(AIAgentType.PET)) && !this.isPlayerGuard)
if (!this.isPet() && !this.isNecroPet() && !(this.agentType.equals(AIAgentType.PET)) && !this.isPlayerGuard())
Experience.doExperience((PlayerCharacter) attacker, this, g);
} else if (attacker.getObjectType().equals(GameObjectType.Mob)) {
Mob mobAttacker = (Mob) attacker;
@ -826,7 +825,7 @@ public class Mob extends AbstractIntelligenceAgent { @@ -826,7 +825,7 @@ public class Mob extends AbstractIntelligenceAgent {
PlayerCharacter owner = (PlayerCharacter) mobAttacker.guardCaptain;
if (owner != null)
if (!this.isPet() && !this.isNecroPet() && !(this.agentType.equals(AIAgentType.PET)) && !this.isPlayerGuard) {
if (!this.isPet() && !this.isNecroPet() && !(this.agentType.equals(AIAgentType.PET)) && !this.isPlayerGuard()) {
Group g = GroupManager.getGroup(owner);
// Give XP, now handled inside the Experience Object
@ -940,7 +939,7 @@ public class Mob extends AbstractIntelligenceAgent { @@ -940,7 +939,7 @@ public class Mob extends AbstractIntelligenceAgent {
playerAgroMap.clear();
if (!this.isPlayerGuard && this.equip != null)
if (!this.isPlayerGuard() && this.equip != null)
LootManager.GenerateEquipmentDrop(this);
}
@ -987,7 +986,7 @@ public class Mob extends AbstractIntelligenceAgent { @@ -987,7 +986,7 @@ public class Mob extends AbstractIntelligenceAgent {
else if (this.building != null)
this.region = BuildingManager.GetRegion(this.building, bindLoc.x, bindLoc.y, bindLoc.z);
if (!this.behaviourType.equals(MobBehaviourType.SiegeEngine) && !this.isPlayerGuard && contract == null)
if (!this.behaviourType.equals(MobBehaviourType.SiegeEngine) && !this.isPlayerGuard() && contract == null)
loadInventory();
this.updateLocation();
@ -1026,7 +1025,7 @@ public class Mob extends AbstractIntelligenceAgent { @@ -1026,7 +1025,7 @@ public class Mob extends AbstractIntelligenceAgent {
this.charItemManager.clearInventory();
this.charItemManager.clearEquip();
if (isPlayerGuard)
if (this.isPlayerGuard())
return;
LootManager.GenerateMobLoot(this);
@ -1539,6 +1538,7 @@ public class Mob extends AbstractIntelligenceAgent { @@ -1539,6 +1538,7 @@ public class Mob extends AbstractIntelligenceAgent {
if (this.contract != null) {
// Setup equipset for contract
this.equipmentSetID = this.contract.getEquipmentSet();
// Configure AI related values
@ -1550,10 +1550,12 @@ public class Mob extends AbstractIntelligenceAgent { @@ -1550,10 +1550,12 @@ public class Mob extends AbstractIntelligenceAgent {
this.guardedCity = ZoneManager.getCityAtLocation(this.building.getLoc());
break;
case GuardWallArcher:
this.gridObjectType = GridObjectType.DYNAMIC;
this.agentType = AIAgentType.GUARDWALLARCHER;
this.spawnTime = 450;
this.guardedCity = ZoneManager.getCityAtLocation(this.building.getLoc());
case Pet1:
this.agentType = AIAgentType.PET;
break;
}
}
@ -1809,7 +1811,11 @@ public class Mob extends AbstractIntelligenceAgent { @@ -1809,7 +1811,11 @@ public class Mob extends AbstractIntelligenceAgent {
}
public boolean isPlayerGuard() {
return isPlayerGuard;
if (EnumSet.of(AIAgentType.GUARDCAPTAIN, AIAgentType.GUARDMINION, AIAgentType.GUARDWALLARCHER).contains(this.agentType))
return true;
else
return false;
}
public int getLastMobPowerToken() {

Loading…
Cancel
Save