/** Parse npcsJSON array and create the amount of npcs needed into npcsEntities */ public void createNpcs() { try { /* * For each entry in Npcs JSON Array */ for (int i = 0; i < npcsJSON.length(); i++) { int npcID = npcsJSON.getJSONObject(i).getInt("npcID"); int amount = npcsJSON.getJSONObject(i).getInt("count"); // This has int npcID, String name, Ship ship, int averageDamage, int shieldAbsorb Npc npcTemplate = GameManager.getNpc(npcID); // If something went wrong because the npc doesn't exists in the templates if (npcTemplate != null) { for (int j = 0; j < amount; j++) { // Because all the npcs will have negative ID's int entityID = -(mapCharacterEntities.size() + 1); Npc createdNpc = new Npc( entityID, npcID, npcTemplate.getName(), npcTemplate.getShip(), new Point(0, 0), // TODO add random spawn mapID, npcTemplate.getShip().getShipHealth(), npcTemplate.getActualNanohull(), npcTemplate.getAverageDamage(), npcTemplate.getShieldAbsorb()); // adds the npc to the map addEntity(createdNpc); } } } } catch (JSONException e) { Console.error( "Something went wrong reading the Npcs JSONArray in Spacemap.createNpcs()", e.getMessage()); } }