Browse Source

moved createSiegeMob and createGuardMob to the Mob class

master
FatBoy-DOTC 2 years ago
parent
commit
38e5081b0e
  1. 4
      src/engine/ai/MobileFSM.java
  2. 2
      src/engine/db/handlers/dbMobHandler.java
  3. 2
      src/engine/devcmd/cmds/InfoCmd.java
  4. 129
      src/engine/gameManager/NPCManager.java
  5. 4
      src/engine/net/client/handlers/MinionTrainingMsgHandler.java
  6. 200
      src/engine/objects/Mob.java
  7. 46
      src/engine/objects/NPC.java

4
src/engine/ai/MobileFSM.java

@ -554,10 +554,6 @@ public class MobileFSM {
public static void GuardMinionLogic(Mob mob){ public static void GuardMinionLogic(Mob mob){
if(mob.despawned){ if(mob.despawned){
if(System.currentTimeMillis() > mob.deathTime + (mob.spawnTime * 1000)){ if(System.currentTimeMillis() > mob.deathTime + (mob.spawnTime * 1000)){
if(mob.getEquipmentSetID() != ((Mob)mob.npcOwner).getEquipmentSetID()){
mob.equipmentSetID = ((Mob)mob.npcOwner).getEquipmentSetID();
mob.runAfterLoad();
}
mob.respawn(); mob.respawn();
} }
return; return;

2
src/engine/db/handlers/dbMobHandler.java

@ -114,7 +114,7 @@ public class dbMobHandler extends dbHandlerBase {
while (rs.next()) { while (rs.next()) {
int mobBaseID = rs.getInt("mobBaseID"); int mobBaseID = rs.getInt("mobBaseID");
String name = rs.getString("name"); String name = rs.getString("name");
Mob toCreate = NPCManager.createGuardMob(captain, captain.getGuild(), captain.getParentZone(), captain.building.getLoc(), captain.getLevel(),name); Mob toCreate = Mob.createGuardMob(captain, captain.getGuild(), captain.getParentZone(), captain.building.getLoc(), captain.getLevel(),name);
if (toCreate == null) if (toCreate == null)
return; return;

2
src/engine/devcmd/cmds/InfoCmd.java

@ -463,7 +463,7 @@ public class InfoCmd extends AbstractDevCmd {
output += newline; output += newline;
output += "Speed : " + targetMob.getSpeed(); output += "Speed : " + targetMob.getSpeed();
output += newline; output += newline;
output += "EquipSet: " + targetMob.getEquipmentSetID(); output += "EquipSet: " + targetMob.equipmentSetID;
output += newline; output += newline;
output += "Parent Zone LoadNum : " + targetMob.getParentZone().getLoadNum(); output += "Parent Zone LoadNum : " + targetMob.getParentZone().getLoadNum();
output += newline; output += newline;

129
src/engine/gameManager/NPCManager.java

@ -200,136 +200,7 @@ public enum NPCManager {
playerCharacter.necroPets.clear(); playerCharacter.necroPets.clear();
} }
public static synchronized Mob createGuardMob(Mob guardCaptain, Guild guild, Zone parent, Vector3fImmutable loc, short level, String pirateName) {
MobBase minionMobBase;
Mob mob;
int maxSlots = 1;
switch (guardCaptain.getRank()) {
case 1:
case 2:
maxSlots = 1;
break;
case 3:
maxSlots = 2;
break;
case 4:
case 5:
maxSlots = 3;
break;
case 6:
maxSlots = 4;
break;
case 7:
maxSlots = 5;
break;
default:
maxSlots = 1;
}
if (guardCaptain.siegeMinionMap.size() == maxSlots)
return null;
minionMobBase = guardCaptain.mobBase;
if (minionMobBase == null)
return null;
mob = new Mob(minionMobBase, guild, parent, level, new Vector3fImmutable(1, 1, 1), 0, true);
mob.despawned = true;
mob.setLevel(level);
//grab equipment and name from minionbase.
if (guardCaptain.contract != null) {
Enum.MinionType minionType = Enum.MinionType.ContractToMinionMap.get(guardCaptain.contract.getContractID());
if (minionType != null) {
mob.equipmentSetID = minionType.getEquipSetID();
String rank = "";
if (guardCaptain.getRank() < 3)
rank = MBServerStatics.JUNIOR;
else if (guardCaptain.getRank() < 6)
rank = "";
else if (guardCaptain.getRank() == 6)
rank = MBServerStatics.VETERAN;
else
rank = MBServerStatics.ELITE;
if (rank.isEmpty())
mob.nameOverride = pirateName + " " + minionType.getRace() + " " + minionType.getName();
else
mob.nameOverride = pirateName + " " + minionType.getRace() + " " + rank + " " + minionType.getName();
}
}
if (parent != null)
mob.setRelPos(parent, loc.x - parent.absX, loc.y - parent.absY, loc.z - parent.absZ);
mob.setObjectTypeMask(MBServerStatics.MASK_MOB | mob.getTypeMasks());
// mob.setMob();
mob.isPlayerGuard = true;
mob.setParentZone(parent);
DbManager.addToCache(mob);
mob.runAfterLoad();
RuneBase guardRune = RuneBase.getRuneBase(252621);
for (MobBaseEffects mbe : guardRune.getEffectsList()) {
EffectsBase eb = PowersManager.getEffectByToken(mbe.getToken());
if (eb == null) {
Logger.info("EffectsBase Null for Token " + mbe.getToken());
continue;
}
//check to upgrade effects if needed.
if (mob.effects.containsKey(Integer.toString(eb.getUUID()))) {
if (mbe.getReqLvl() > (int) mob.level) {
continue;
}
Effect eff = mob.effects.get(Integer.toString(eb.getUUID()));
if (eff == null)
continue;
//Current effect is a higher rank, dont apply.
if (eff.getTrains() > mbe.getRank())
continue;
//new effect is of a higher rank. remove old effect and apply new one.
eff.cancelJob();
mob.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true);
} else {
if (mbe.getReqLvl() > (int) mob.level)
continue;
mob.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true);
}
}
int slot = 0;
slot += guardCaptain.siegeMinionMap.size() + 1;
guardCaptain.siegeMinionMap.put(mob, slot);
mob.setInBuildingLoc(guardCaptain.building, guardCaptain);
//mob.setBindLoc(loc.add(mob.inBuildingLoc));
mob.setLoc(guardCaptain.building.getLoc());
mob.setLastRegion(AbstractWorldObject.GetRegionByWorldObject(mob));
mob.setBindLoc(guardCaptain.building.getStuckLocation());
mob.deathTime = System.currentTimeMillis();
mob.spawnTime = 900;
mob.npcOwner = guardCaptain;
mob.BehaviourType = Enum.MobBehaviourType.GuardMinion;
return mob;
}
public static void removeSiegeMinions(Mob mobile) { public static void removeSiegeMinions(Mob mobile) {

4
src/engine/net/client/handlers/MinionTrainingMsgHandler.java

@ -148,7 +148,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
if (mobBase == 0) if (mobBase == 0)
return true; return true;
Mob toCreate = npc.createSiegeMob(mobBase, npc.getGuild(), zone, b.getLoc(), (short) 1); Mob toCreate = Mob.createSiegeMob(npc,mobBase, npc.getGuild(), zone, b.getLoc(), (short) 1);
if (toCreate == null) if (toCreate == null)
return true; return true;
@ -280,7 +280,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
if (!DbManager.MobQueries.ADD_TO_GUARDS(npc.getObjectUUID(), mobBase, pirateName, npc.getSiegeMinionMap().size() + 1)) if (!DbManager.MobQueries.ADD_TO_GUARDS(npc.getObjectUUID(), mobBase, pirateName, npc.getSiegeMinionMap().size() + 1))
return true; return true;
Mob toCreate = NPCManager.createGuardMob(npc, npc.getGuild(), zone, b.getLoc(), npc.getLevel(),pirateName); Mob toCreate = Mob.createGuardMob(npc, npc.getGuild(), zone, b.getLoc(), npc.getLevel(),pirateName);
if (toCreate == null) if (toCreate == null)
return true; return true;

200
src/engine/objects/Mob.java

@ -29,6 +29,7 @@ import engine.net.client.msg.ErrorPopupMsg;
import engine.net.client.msg.ManageCityAssetsMsg; import engine.net.client.msg.ManageCityAssetsMsg;
import engine.net.client.msg.PetMsg; import engine.net.client.msg.PetMsg;
import engine.net.client.msg.PlaceAssetMsg; import engine.net.client.msg.PlaceAssetMsg;
import engine.powers.EffectsBase;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
@ -719,7 +720,9 @@ public class Mob extends AbstractIntelligenceAgent {
if (!isPet && this.contract == null) this.level = (short) this.mobBase.getLevel(); if (!isPet && this.contract == null) this.level = (short) this.mobBase.getLevel();
else this.level = 1; else this.level = 1;
} }
if (this.building != null && this.contract != null) {
slotMobInBuilding(); // picks first available free slot
}
//set bonuses //set bonuses
this.bonuses = new PlayerBonuses(this); this.bonuses = new PlayerBonuses(this);
@ -1913,10 +1916,6 @@ public class Mob extends AbstractIntelligenceAgent {
return lastRegion; return lastRegion;
} }
public void setLastRegion(Regions lastRegion) {
this.lastRegion = lastRegion;
}
public boolean isLootSync() { public boolean isLootSync() {
return lootSync; return lootSync;
} }
@ -1929,10 +1928,6 @@ public class Mob extends AbstractIntelligenceAgent {
return equip; return equip;
} }
public int getEquipmentSetID() {
return equipmentSetID;
}
public String getNameOverride() { public String getNameOverride() {
return nameOverride; return nameOverride;
} }
@ -2092,4 +2087,191 @@ public class Mob extends AbstractIntelligenceAgent {
} }
} }
} }
private void slotMobInBuilding() {
int maxSlots = 10;
for (int slot = 1; slot < maxSlots + 1; slot++)
if (!this.building.getHirelings().containsValue(slot)) {
this.building.getHirelings().put(this, slot);
break;
}
}
public static synchronized Mob createGuardMob(Mob guardCaptain, Guild guild, Zone parent, Vector3fImmutable loc, short level, String pirateName) {
MobBase minionMobBase;
Mob mob;
int maxSlots = 1;
switch (guardCaptain.getRank()) {
case 1:
case 2:
maxSlots = 1;
break;
case 3:
maxSlots = 2;
break;
case 4:
case 5:
maxSlots = 3;
break;
case 6:
maxSlots = 4;
break;
case 7:
maxSlots = 5;
break;
default:
maxSlots = 1;
}
if (guardCaptain.siegeMinionMap.size() == maxSlots)
return null;
minionMobBase = guardCaptain.mobBase;
if (minionMobBase == null)
return null;
mob = new Mob(minionMobBase, guild, parent, level, new Vector3fImmutable(1, 1, 1), 0, true);
mob.setLevel(level);
if(guardCaptain.equipmentSetID != 0)
mob.equipmentSetID = guardCaptain.equipmentSetID;
mob.runAfterLoad();
mob.despawned = true;
//grab equipment and name from minionbase.
if (guardCaptain.contract != null) {
Enum.MinionType minionType = Enum.MinionType.ContractToMinionMap.get(guardCaptain.contract.getContractID());
if (minionType != null) {
String rank = "";
if (guardCaptain.getRank() < 3)
rank = MBServerStatics.JUNIOR;
else if (guardCaptain.getRank() < 6)
rank = "";
else if (guardCaptain.getRank() == 6)
rank = MBServerStatics.VETERAN;
else
rank = MBServerStatics.ELITE;
if (rank.isEmpty())
mob.nameOverride = pirateName + " " + minionType.getRace() + " " + minionType.getName();
else
mob.nameOverride = pirateName + " " + minionType.getRace() + " " + rank + " " + minionType.getName();
}
}
if (parent != null)
mob.setRelPos(parent, loc.x - parent.absX, loc.y - parent.absY, loc.z - parent.absZ);
mob.setObjectTypeMask(MBServerStatics.MASK_MOB | mob.getTypeMasks());
// mob.setMob();
mob.isPlayerGuard = true;
mob.setParentZone(parent);
DbManager.addToCache(mob);
RuneBase guardRune = RuneBase.getRuneBase(252621);
for (MobBaseEffects mbe : guardRune.getEffectsList()) {
EffectsBase eb = PowersManager.getEffectByToken(mbe.getToken());
if (eb == null) {
Logger.info("EffectsBase Null for Token " + mbe.getToken());
continue;
}
//check to upgrade effects if needed.
if (mob.effects.containsKey(Integer.toString(eb.getUUID()))) {
if (mbe.getReqLvl() > (int) mob.level) {
continue;
}
Effect eff = mob.effects.get(Integer.toString(eb.getUUID()));
if (eff == null)
continue;
//Current effect is a higher rank, dont apply.
if (eff.getTrains() > mbe.getRank())
continue;
//new effect is of a higher rank. remove old effect and apply new one.
eff.cancelJob();
mob.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true);
} else {
if (mbe.getReqLvl() > (int) mob.level)
continue;
mob.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true);
}
}
int slot = 0;
slot += guardCaptain.siegeMinionMap.size() + 1;
guardCaptain.siegeMinionMap.put(mob, slot);
mob.setInBuildingLoc(guardCaptain.building, guardCaptain);
Vector3fImmutable buildingWorldLoc = ZoneManager.convertLocalToWorld(guardCaptain.building, mob.inBuildingLoc);
mob.setBindLoc(buildingWorldLoc);
mob.setLoc(buildingWorldLoc);
mob.deathTime = System.currentTimeMillis();
mob.spawnTime = 900;
mob.npcOwner = guardCaptain;
mob.BehaviourType = Enum.MobBehaviourType.GuardMinion;
return mob;
}
public static synchronized Mob createSiegeMob(NPC owner, int loadID, Guild guild, Zone parent, Vector3fImmutable loc, short level) {
MobBase minionMobBase;
Mob mob;
if (owner.getSiegeMinionMap().size() == 3)
return null;
minionMobBase = MobBase.getMobBase(loadID);
if (minionMobBase == null)
return null;
mob = new Mob(minionMobBase, guild, parent, level,new Vector3fImmutable(1,1,1), 0,false);
mob.runAfterLoad();
mob.despawned = true;
DbManager.addToCache(mob);
if (parent != null)
mob.setRelPos(parent, loc.x - parent.absX, loc.y - parent.absY, loc.z - parent.absZ);
mob.setObjectTypeMask(MBServerStatics.MASK_MOB | mob.getTypeMasks());
//mob.setMob();
mob.setSiege(true);
mob.setParentZone(parent);
int slot = 0;
if (!owner.getSiegeMinionMap().containsValue(1))
slot = 1;
else if (!owner.getSiegeMinionMap().containsValue(2))
slot = 2;
owner.getSiegeMinionMap().put(mob, slot);
mob.setInBuildingLoc(owner.building, owner);
Vector3fImmutable buildingWorldLoc = ZoneManager.convertLocalToWorld(owner.building, mob.inBuildingLoc);
mob.setBindLoc(buildingWorldLoc);
mob.setLoc(buildingWorldLoc);
mob.setSpawnTime(10);
mob.setNpcOwner(owner);
mob.BehaviourType = MobBehaviourType.Pet1;
mob.BehaviourType.canRoam = false;
return mob;
}
} }

46
src/engine/objects/NPC.java

@ -1435,53 +1435,7 @@ public class NPC extends AbstractCharacter {
} }
public synchronized Mob createSiegeMob(int loadID, Guild guild, Zone parent, Vector3fImmutable loc, short level) {
MobBase minionMobBase;
Mob mob;
if (siegeMinionMap.size() == 3)
return null;
minionMobBase = MobBase.getMobBase(loadID);
if (minionMobBase == null)
return null;
mob = new Mob(minionMobBase, guild, parent, level,new Vector3fImmutable(1,1,1), 0,false);
mob.runAfterLoad();
mob.despawned = true;
DbManager.addToCache(mob);
if (parent != null)
mob.setRelPos(parent, loc.x - parent.absX, loc.y - parent.absY, loc.z - parent.absZ);
mob.setObjectTypeMask(MBServerStatics.MASK_MOB | mob.getTypeMasks());
//mob.setMob();
mob.setSiege(true);
mob.setParentZone(parent);
int slot = 0;
if (!siegeMinionMap.containsValue(1))
slot = 1;
else if (!siegeMinionMap.containsValue(2))
slot = 2;
siegeMinionMap.put(mob, slot);
mob.setInBuildingLoc(this.building, this);
Vector3fImmutable buildingWorldLoc = ZoneManager.convertLocalToWorld(this.building, mob.inBuildingLoc);
mob.setBindLoc(buildingWorldLoc);
mob.setLoc(buildingWorldLoc);
mob.setSpawnTime(10);
mob.setNpcOwner(this);
mob.BehaviourType = MobBehaviourType.Pet1;
mob.BehaviourType.canRoam = false;
return mob;
}
public int getUpgradeCost() { public int getUpgradeCost() {

Loading…
Cancel
Save