for (MapSpawn mapSpawn : mapSpawns) {
float spawnX = mapSpawn.getSpawnX();
float spawnY = mapSpawn.getSpawnY();
int planeZ = mapSpawn.getSpawnPlane();
mapData.getPossibleSpawns().add(new GWVector(spawnX, spawnY, planeZ));
}
if (mapData.getPossibleSpawns().isEmpty()) {
LOGGER.warn("No possible spawn locations for map {}", mapId);
mapData.getPossibleSpawns().add(new GWVector(0, 0, 0));
}
Set<NpcSpawn> npcSpawns = getNpcSpawns(mapId, mapData.isIsOutpost(), mapData.isIsPve());
for (NpcSpawn npcSpawn : npcSpawns) {
int npcId = npcSpawn.getNpcId();
int nameId = npcSpawn.getNameId();
float spawnY = npcSpawn.getSpawnY();
float spawnX = npcSpawn.getSpawnX();
int planeZ = npcSpawn.getSpawnPlane();
float rotation = npcSpawn.getRotation();
float speed = npcSpawn.getSpeed();
int level = npcSpawn.getLevel();
int profession = npcSpawn.getProfession();
// retrieve the NPC
NpcMasterData npcMasterData = getNpcMasterDataByNpcId(npcId);
// FIXME: what if no NPCs are found??
int npcFileId = npcMasterData.getNpcFileId();
byte[] modelHash = npcMasterData.getModelHash();
byte[] appearance = npcMasterData.getAppearance();
int scale = npcMasterData.getScale();
int professionFlags = npcMasterData.getProfessionFlags();
// String selectNpcNamesSql = "select * from npcs_names where nameID=" + nameId;
// CachedRowSet resultingNpcNames = db.executeSelect(selectNpcNamesSql);
// FIXME: wtf? there probably aren't any NPCs that why we don't get into this loop
byte[] nameHash = null;// readBlob(resultingNpc.getBlob("nameHash"));
// FIXME: what if no NPC names are found??
// resultingNpcNames.next();
NpcData npcData = new NpcData();
npcData.setAgentID(mapData.getAgentIDs().borrowId());
npcData.setLocalID(npcId);
npcData.setNpcFileID(npcFileId);
npcData.setModelHash(modelHash);
npcData.setAppearance(appearance);
// TODO: verify encoding here
npcData.setName(new String(nameHash));
npcData.setScale(scale);
npcData.setNpcFlags(professionFlags);
npcData.setPosition(new GWVector(spawnX, spawnY, planeZ));
npcData.setRotation(rotation);
npcData.setIsRotating(false);
npcData.setSpeed(speed);
npcData.setLevel(level);
npcData.setProfessionPrimary((byte) profession);
npcData.setEnergy(100);
npcData.setEnergyRegen(0.3f);
npcData.setHealth(100);
npcData.setHealthRegen(0.3f);
npcData.setDirection(new GWVector(0, 0, 0));
npcData.setMorale(100);
npcData.setVitalStatus(VitalStatus.ALIVE.getValue());
npcData.setMoveState(MovementState.MOVE_KEEP_DIR);
npcData.setMoveType(MovementType.STOP);