|
|
@ -13,6 +13,7 @@ import engine.Enum.GameObjectType; |
|
|
|
import engine.InterestManagement.WorldGrid; |
|
|
|
import engine.InterestManagement.WorldGrid; |
|
|
|
import engine.devcmd.AbstractDevCmd; |
|
|
|
import engine.devcmd.AbstractDevCmd; |
|
|
|
import engine.gameManager.*; |
|
|
|
import engine.gameManager.*; |
|
|
|
|
|
|
|
import engine.math.Vector3fImmutable; |
|
|
|
import engine.objects.*; |
|
|
|
import engine.objects.*; |
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
|
|
|
|
|
|
|
@ -31,7 +32,6 @@ public class AddNPCCmd extends AbstractDevCmd { |
|
|
|
int contractID; |
|
|
|
int contractID; |
|
|
|
String name = ""; |
|
|
|
String name = ""; |
|
|
|
int level = 0; |
|
|
|
int level = 0; |
|
|
|
|
|
|
|
|
|
|
|
if (words.length < 2) { |
|
|
|
if (words.length < 2) { |
|
|
|
this.sendUsage(pc); |
|
|
|
this.sendUsage(pc); |
|
|
|
return; |
|
|
|
return; |
|
|
@ -39,59 +39,54 @@ public class AddNPCCmd extends AbstractDevCmd { |
|
|
|
try { |
|
|
|
try { |
|
|
|
contractID = Integer.parseInt(words[0]); |
|
|
|
contractID = Integer.parseInt(words[0]); |
|
|
|
level = Integer.parseInt(words[1]); |
|
|
|
level = Integer.parseInt(words[1]); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 2; i < words.length; i++) { |
|
|
|
for (int i = 2; i < words.length; i++) { |
|
|
|
name += words[i]; |
|
|
|
name += words[i]; |
|
|
|
if (i + 1 < words.length) |
|
|
|
if (i + 1 < words.length) |
|
|
|
name += ""; |
|
|
|
name += ""; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} catch (NumberFormatException e) { |
|
|
|
} catch (NumberFormatException e) { |
|
|
|
throwbackError(pc, |
|
|
|
throwbackError(pc, |
|
|
|
"Failed to parse supplied contractID or level to an Integer."); |
|
|
|
"Failed to parse supplied contractID or level to an Integer."); |
|
|
|
return; // NaN
|
|
|
|
return; // NaN
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Contract contract = DbManager.ContractQueries.GET_CONTRACT(contractID); |
|
|
|
Contract contract = DbManager.ContractQueries.GET_CONTRACT(contractID); |
|
|
|
|
|
|
|
|
|
|
|
if (contract == null || level < 1 || level > 75) { |
|
|
|
if (contract == null || level < 1 || level > 75) { |
|
|
|
throwbackError(pc, |
|
|
|
throwbackError(pc, |
|
|
|
"Invalid addNPC Command. Need contract ID, and level"); |
|
|
|
"Invalid addNPC Command. Need contract ID, and level"); |
|
|
|
return; // NaN
|
|
|
|
return; // NaN
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Pick a random name
|
|
|
|
// Pick a random name
|
|
|
|
if (name.isEmpty()) |
|
|
|
if (name.isEmpty()) |
|
|
|
name = NPCManager.getPirateName(contract.getMobbaseID()); |
|
|
|
name = NPCManager.getPirateName(contract.getMobbaseID()); |
|
|
|
|
|
|
|
|
|
|
|
Zone zone = ZoneManager.findSmallestZone(pc.getLoc()); |
|
|
|
Zone zone = ZoneManager.findSmallestZone(pc.getLoc()); |
|
|
|
|
|
|
|
|
|
|
|
if (zone == null) { |
|
|
|
if (zone == null) { |
|
|
|
throwbackError(pc, "Failed to find zone to place npc in."); |
|
|
|
throwbackError(pc, "Failed to find zone to place npc in."); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Building building = null; |
|
|
|
if (target != null) |
|
|
|
if (target != null) |
|
|
|
if (target.getObjectType() == GameObjectType.Building) { |
|
|
|
if (target.getObjectType() == GameObjectType.Building) { |
|
|
|
Building parentBuilding = (Building) target; |
|
|
|
building = (Building)target; |
|
|
|
BuildingManager.addHirelingForWorld(parentBuilding, pc, parentBuilding.getLoc(), parentBuilding.getParentZone(), contract, level); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
NPC created; |
|
|
|
NPC npc = NPC.createNPC(name, contractID, |
|
|
|
Guild guild = null; |
|
|
|
pc.getLoc(), null, zone, (short) level, null); |
|
|
|
Vector3fImmutable loc; |
|
|
|
|
|
|
|
if(building != null){ |
|
|
|
if (npc != null) { |
|
|
|
guild = building.getGuild(); |
|
|
|
WorldGrid.addObject(npc, pc); |
|
|
|
loc = building.loc; |
|
|
|
ChatManager.chatSayInfo(pc, |
|
|
|
} else{ |
|
|
|
"NPC with ID " + npc.getDBID() + " added"); |
|
|
|
loc = pc.loc; |
|
|
|
this.setResult(String.valueOf(npc.getDBID())); |
|
|
|
} |
|
|
|
} else { |
|
|
|
created = NPC.createNPC(name, contractID, loc, guild, zone, (short)level, building); |
|
|
|
throwbackError(pc, "Failed to create npc of contract type " |
|
|
|
created.bindLoc = loc; |
|
|
|
+ contractID); |
|
|
|
if(building != null) { |
|
|
|
Logger.error( |
|
|
|
created.buildingUUID = building.getObjectUUID(); |
|
|
|
"Failed to create npc of contract type " + contractID); |
|
|
|
created.building = building; |
|
|
|
|
|
|
|
NPCManager.slotCharacterInBuilding(created); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
created.setLoc(created.bindLoc); |
|
|
|
|
|
|
|
created.updateDatabase(); |
|
|
|
|
|
|
|
throwbackInfo(pc, "Created NPC with UUID: " + created.getObjectUUID()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|