From: ChadF <ch...@us...> - 2007-10-02 21:14:21
|
Update of /cvsroot/arianne/stendhal/src/games/stendhal/server/maps/deathmatch In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv10807/src/games/stendhal/server/maps/deathmatch Modified Files: CreatureSpawner.java Log Message: Cleanup of NPC remove code.. mostly redundent calls. Index: CreatureSpawner.java =================================================================== RCS file: /cvsroot/arianne/stendhal/src/games/stendhal/server/maps/deathmatch/CreatureSpawner.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CreatureSpawner.java 29 Sep 2007 03:51:57 -0000 1.4 --- CreatureSpawner.java 2 Oct 2007 21:14:20 -0000 1.5 *************** *** 30,40 **** private List<DeathMatchCreature> spawnedCreatures = new ArrayList<DeathMatchCreature>(); CreatureSpawner() { - super(); - Collection<Creature> creatures = StendhalRPWorld.get().getRuleManager().getEntityManager().getCreatures(); sortedCreatures.addAll(creatures); Collections.sort(sortedCreatures, new LevelBasedComparator()); - } /** * remove the critters that the player was supposed to kill --- 30,38 ---- private List<DeathMatchCreature> spawnedCreatures = new ArrayList<DeathMatchCreature>(); CreatureSpawner() { Collection<Creature> creatures = StendhalRPWorld.get().getRuleManager().getEntityManager().getCreatures(); sortedCreatures.addAll(creatures); Collections.sort(sortedCreatures, new LevelBasedComparator()); } + /** * remove the critters that the player was supposed to kill *************** *** 44,59 **** StendhalRPZone monsterZone = creature.getZone(); ! try { ! StendhalRPRuleProcessor.get().removeNPC(creature); ! monsterZone.getNPCList().remove(creature); ! if (monsterZone.has(creature.getID())) { ! monsterZone.remove(creature); ! } ! } catch (RPObjectNotFoundException e) { ! // // don't log errors here because the player may have killed a few of the monsters ! // logger.debug(e, e); } } } /** * check if all our enemies are dead --- 42,51 ---- StendhalRPZone monsterZone = creature.getZone(); ! if(monsterZone != null) { ! monsterZone.remove(creature); } } } + /** * check if all our enemies are dead *************** *** 67,72 **** --- 59,66 ---- } } + return true; } + /** * be nice to the player and give him his daily quest creature *************** *** 80,83 **** --- 74,78 ---- String[] dTokens = dailyInfo.split(";"); String daily = dTokens[0]; + if (!player.hasKilled(daily)) { for (Creature creature : sortedCreatures) { *************** *** 99,114 **** --- 94,113 ---- List<Creature> possibleCreaturesToSpawn = new ArrayList<Creature>(); int lastLevel = 0; + for (Creature creature : sortedCreatures) { if (creature.getLevel() > questLevel) { break; } + if (creature.getLevel() > lastLevel) { possibleCreaturesToSpawn.clear(); lastLevel = creature.getLevel(); } + possibleCreaturesToSpawn.add(creature); } Creature creatureToSpawn = null; + if (possibleCreaturesToSpawn.size() == 0) { creatureToSpawn = sortedCreatures.get(sortedCreatures.size() - 1); *************** *** 117,122 **** --- 116,123 ---- creatureToSpawn = possibleCreaturesToSpawn.get(0); } + return creatureToSpawn; } + /** * creates a new creature of the named type and adds it to the world *************** *** 130,133 **** --- 131,135 ---- DeathMatchCreature creature = new DeathMatchCreature( new ArenaCreature(template.getInstance(), deathmatchInfo.getArena().getShape())); + if (StendhalRPAction.placeat(deathmatchInfo.getZone(), creature, player.getX(), player.getY(), deathmatchInfo.getArena().getShape())) { creature.clearDropItemList(); *************** *** 140,143 **** --- 142,146 ---- creature = null; } + return creature; } *************** *** 149,155 **** --- 152,160 ---- int calculatePoints() { int sum = 0; + for (DeathMatchCreature creature : spawnedCreatures) { sum += creature.getDMPoints(); } + return sum; } |