fix add NPC
This commit is contained in:
@@ -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;
|
||||||
|
|
||||||
@@ -70,28 +71,30 @@ public class AddNPCCmd extends AbstractDevCmd {
|
|||||||
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 {
|
|
||||||
throwbackError(pc, "Failed to create npc of contract type "
|
|
||||||
+ contractID);
|
|
||||||
Logger.error(
|
|
||||||
"Failed to create npc of contract type " + contractID);
|
|
||||||
}
|
}
|
||||||
|
created = NPC.createNPC(name, contractID, loc, guild, zone, (short)level, building);
|
||||||
|
created.bindLoc = loc;
|
||||||
|
if(building != null) {
|
||||||
|
created.buildingUUID = building.getObjectUUID();
|
||||||
|
created.building = building;
|
||||||
|
NPCManager.slotCharacterInBuilding(created);
|
||||||
|
}
|
||||||
|
created.setLoc(created.bindLoc);
|
||||||
|
created.updateDatabase();
|
||||||
|
throwbackInfo(pc, "Created NPC with UUID: " + created.getObjectUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user