Browse Source

pirateName and Rank added to CreateMob interface.

master
MagicBot 2 years ago
parent
commit
0a783f7561
  1. 4
      src/engine/devcmd/cmds/AddMobCmd.java
  2. 2
      src/engine/devcmd/cmds/SplatMobCmd.java
  3. 4
      src/engine/gameManager/BuildingManager.java
  4. 399
      src/engine/objects/Mob.java
  5. 2
      src/engine/objects/NPC.java

4
src/engine/devcmd/cmds/AddMobCmd.java

@ -44,7 +44,7 @@ public class AddMobCmd extends AbstractDevCmd { @@ -44,7 +44,7 @@ public class AddMobCmd extends AbstractDevCmd {
MobBase mb = (MobBase)mobbaseAGO;
int loadID = mb.getObjectUUID();
Mob mob = Mob.createMob( loadID, Vector3fImmutable.getRandomPointInCircle(pc.getLoc(), 100),
null, true, zone, null,0);
null, true, zone, null,0, "", 1);
if (mob != null) {
mob.updateDatabase();
this.setResult(String.valueOf(mob.getDBID()));
@ -85,7 +85,7 @@ public class AddMobCmd extends AbstractDevCmd { @@ -85,7 +85,7 @@ public class AddMobCmd extends AbstractDevCmd {
Mob mob = Mob.createMob( loadID, pc.getLoc(),
null, true, zone, null,0);
null, true, zone, null,0, "", 1);
if (mob != null) {
mob.updateDatabase();
ChatManager.chatSayInfo(pc,

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

@ -76,7 +76,7 @@ public class SplatMobCmd extends AbstractDevCmd { @@ -76,7 +76,7 @@ public class SplatMobCmd extends AbstractDevCmd {
mobile = Mob.createMob(_mobileUUID,
Vector3fImmutable.getRandomPointInCircle(_currentLocation, _targetRange),
null, true, serverZone,null,0);
null, true, serverZone,null,0, "", 1);
if (mobile != null) {
mobile.updateDatabase();

4
src/engine/gameManager/BuildingManager.java

@ -470,7 +470,7 @@ public enum BuildingManager { @@ -470,7 +470,7 @@ public enum BuildingManager {
NPC npc = null;
if (NPC.ISWallArcher(contractID.getContractID())) {
mob = Mob.createMob( contractID.getMobbaseID(), NpcLoc, contractOwner.getGuild(), true, zone, building, contractID.getContractID());
mob = Mob.createMob( contractID.getMobbaseID(), NpcLoc, contractOwner.getGuild(), true, zone, building, contractID.getContractID(), pirateName, 1);
if (mob == null)
return false;
@ -483,7 +483,7 @@ public enum BuildingManager { @@ -483,7 +483,7 @@ public enum BuildingManager {
}
if (NPC.ISGuardCaptain(contractID.getContractID())) {
mob = Mob.createMob( contractID.getMobbaseID(), NpcLoc, contractOwner.getGuild(), true, zone, building, contractID.getContractID());
mob = Mob.createMob( contractID.getMobbaseID(), NpcLoc, contractOwner.getGuild(), true, zone, building, contractID.getContractID(), pirateName, rank);
if (mob == null)
return false;

399
src/engine/objects/Mob.java

@ -40,7 +40,6 @@ import java.util.ArrayList; @@ -40,7 +40,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup;
@ -99,11 +98,11 @@ public class Mob extends AbstractIntelligenceAgent { @@ -99,11 +98,11 @@ public class Mob extends AbstractIntelligenceAgent {
private long timeToSpawnSiege;
private boolean noAggro = false;
private int aggroTargetID = 0;
private boolean walkingHome = true;
private final boolean walkingHome = true;
private long lastAttackTime = 0;
private int lastMobPowerToken = 0;
private HashMap<Integer, MobEquipment> equip = null;
private Regions lastRegion = null;
private final Regions lastRegion = null;
private DeferredPowerJob weaponPower;
private DateTime upgradeDateTime = null;
private boolean lootSync = false;
@ -501,7 +500,8 @@ public class Mob extends AbstractIntelligenceAgent { @@ -501,7 +500,8 @@ public class Mob extends AbstractIntelligenceAgent {
writer.putInt(objectType);
writer.putInt(mob.currentID);
}
public static Mob createMob(int loadID, Vector3fImmutable spawn, Guild guild, boolean isMob, Zone parent, Building building, int contractID) {
public static Mob createMob(int loadID, Vector3fImmutable spawn, Guild guild, boolean isMob, Zone parent, Building building, int contractID, String pirateName, int rank) {
Mob mobWithoutID = new Mob("", "", (short) 0, (short) 0, (short) 0, (short) 0, (short) 0, (short) 1, 0, false, false, false, spawn, spawn, Vector3fImmutable.ZERO, (short) 1, (short) 1, (short) 1, guild, (byte) 0, loadID, isMob, parent, building, contractID);
@ -521,7 +521,7 @@ public class Mob extends AbstractIntelligenceAgent { @@ -521,7 +521,7 @@ public class Mob extends AbstractIntelligenceAgent {
mob.setBindLoc(buildingWorldLoc);
mob.setLoc(buildingWorldLoc);
mob.region = AbstractWorldObject.GetRegionByWorldObject(mob);
MovementManager.translocate(mob,buildingWorldLoc,mob.region);
MovementManager.translocate(mob, buildingWorldLoc, mob.region);
mob.nameOverride = NPC.getPirateName(mob.getMobBaseID()) + " the " + mob.getContract().getName();
mob.runAfterLoad();
} catch (Exception e) {
@ -653,6 +653,184 @@ public class Mob extends AbstractIntelligenceAgent { @@ -653,6 +653,184 @@ public class Mob extends AbstractIntelligenceAgent {
mob.upgradeDateTime = upgradeDateTime;
}
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;
}
private void clearStatic() {
if (this.parentZone != null) this.parentZone.zoneMobSet.remove(this);
@ -735,6 +913,10 @@ public class Mob extends AbstractIntelligenceAgent { @@ -735,6 +913,10 @@ public class Mob extends AbstractIntelligenceAgent {
return loadID;
}
/*
* Serialization
*/
@Override
public int getObjectUUID() {
return currentID;
@ -744,10 +926,6 @@ public class Mob extends AbstractIntelligenceAgent { @@ -744,10 +926,6 @@ public class Mob extends AbstractIntelligenceAgent {
return this.statLat;
}
/*
* Serialization
*/
public float getSpawnY() {
return this.statAlt;
}
@ -958,6 +1136,10 @@ public class Mob extends AbstractIntelligenceAgent { @@ -958,6 +1136,10 @@ public class Mob extends AbstractIntelligenceAgent {
return 0f;
}
/*
* Database
*/
/**
* @ Kill this Character
*/
@ -1019,10 +1201,6 @@ public class Mob extends AbstractIntelligenceAgent { @@ -1019,10 +1201,6 @@ public class Mob extends AbstractIntelligenceAgent {
}
/*
* Database
*/
@Override
public void killCharacter(String reason) {
killCleanup();
@ -1593,9 +1771,11 @@ public class Mob extends AbstractIntelligenceAgent { @@ -1593,9 +1771,11 @@ public class Mob extends AbstractIntelligenceAgent {
Mob mob = null;
NPC npc = null;
if (ac.getObjectType().equals(GameObjectType.Mob)) mob = (Mob) ac;
if (ac.getObjectType().equals(GameObjectType.Mob))
mob = (Mob) ac;
else if (ac.getObjectType().equals(GameObjectType.NPC)) npc = (NPC) ac;
else if (ac.getObjectType().equals(GameObjectType.NPC))
npc = (NPC) ac;
BuildingModelBase buildingModel = BuildingModelBase.getModelBase(inBuilding.getMeshUUID());
@ -1609,7 +1789,8 @@ public class Mob extends AbstractIntelligenceAgent { @@ -1609,7 +1789,8 @@ public class Mob extends AbstractIntelligenceAgent {
//-1 slot means no slot available in building.
if (npc != null) {
if (npc.getSiegeMinionMap().containsKey(this)) putSlot = npc.getSiegeMinionMap().get(this);
if (npc.getSiegeMinionMap().containsKey(this))
putSlot = npc.getSiegeMinionMap().get(this);
} else if (mob != null) {
//if (mob.getSiegeMinionMap().containsKey(this)) putSlot = mob.getSiegeMinionMap().get(this);
int hirelings = mob.building.getHirelings().size();
@ -1628,7 +1809,6 @@ public class Mob extends AbstractIntelligenceAgent { @@ -1628,7 +1809,6 @@ public class Mob extends AbstractIntelligenceAgent {
}
this.inBuildingLoc = slotLocation;
}
public ItemBase getWeaponItemBase(boolean mainHand) {
@ -1685,10 +1865,10 @@ public class Mob extends AbstractIntelligenceAgent { @@ -1685,10 +1865,10 @@ public class Mob extends AbstractIntelligenceAgent {
this.equip = new HashMap<>(0);
}
// Combine mobbase and mob aggro arrays into one bitvector
if(this.getMobBase().notEnemy.size() > 0)
if (this.getMobBase().notEnemy.size() > 0)
this.notEnemy.addAll(this.getMobBase().notEnemy);
if(this.getMobBase().enemy.size() > 0)
if (this.getMobBase().enemy.size() > 0)
this.enemy.addAll(this.getMobBase().enemy);
try {
@ -1801,17 +1981,14 @@ public class Mob extends AbstractIntelligenceAgent { @@ -1801,17 +1981,14 @@ public class Mob extends AbstractIntelligenceAgent {
return this.upgradeDateTime != null;
}
public void setNoAggro(boolean noAggro) {
this.noAggro = noAggro;
}
public void setAggroTargetID(int aggroTargetID) {
this.aggroTargetID = aggroTargetID;
}
public long getLastAttackTime() {
return lastAttackTime;
}
@ -1867,7 +2044,6 @@ public class Mob extends AbstractIntelligenceAgent { @@ -1867,7 +2044,6 @@ public class Mob extends AbstractIntelligenceAgent {
this.isPlayerGuard = isPlayerGuard;
}
public void setPatrolPointIndex(int patrolPointIndex) {
}
@ -2054,6 +2230,7 @@ public class Mob extends AbstractIntelligenceAgent { @@ -2054,6 +2230,7 @@ public class Mob extends AbstractIntelligenceAgent {
}
}
}
private void slotMobInBuilding() {
int maxSlots = 10;
@ -2063,180 +2240,4 @@ public class Mob extends AbstractIntelligenceAgent { @@ -2063,180 +2240,4 @@ public class Mob extends AbstractIntelligenceAgent {
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;
}
}

2
src/engine/objects/NPC.java

@ -278,8 +278,6 @@ public class NPC extends AbstractCharacter { @@ -278,8 +278,6 @@ public class NPC extends AbstractCharacter {
this.buildingLevel = (rs.getInt("npc_buildingLevel"));
this.setParentZone(ZoneManager.getZoneByUUID(this.parentZoneID));
this.nameOverride = rs.getString("npc_name") + " the " + this.getContract().getName();
}catch(Exception e){

Loading…
Cancel
Save