コード例 #1
0
 public Monster getMonsterById(String id) {
   if (monsters.containsKey(id)) {
     Monster monster = monsters.get(id);
     return monster;
   } else {
     return null;
   }
 }
コード例 #2
0
 public void processMonsterUpdateUDP(UDPMonster up) {
   if (up != null) {
     if (monsters.containsKey(up.id)) {
       Monster monster = monsters.get(up.id);
       if (monster != null) {
         monster.processUpdate(up);
       }
     }
   }
 }
コード例 #3
0
 public void processMonsterUpdate(UpdateMonster um) {
   if (um != null) {
     if (monsters.containsKey(um.id)) {
       Monster monster = monsters.get(um.id);
       if (monster != null) {
         EIError.debugMsg(
             "Setting " + um.id + " to " + um.mapX + ":" + um.mapY + ", Action: " + um.action);
         monster.setPosition(um.mapX, um.mapY);
         if (um.previousGoal != null) {
           monster.ai.setPreviousGoal(um.previousGoal);
         }
         if (um.currentGoal != null) {
           monster.ai.setCurrentGoal(um.currentGoal);
         }
         if (um.action.equals("ApplyDamage")) {
           monster.applyDamage(um.dataInt, um.actor);
         } else if (um.action.equals("ApplyKnockBack")) {
           monster.applyKnockBack(um.dataInt, um.dataInt2);
         } else if (um.action.equals("Die")) {
           monster.setHitPoints(0);
         } else if (um.action.equals("Fear")) {
           monster.applyKnockBack(um.dataInt, um.dataInt2);
           monster.fear(um.dataPoint, um.dataLong);
         }
       }
     } else {
       if (gameController.multiplayerMode == gameController.multiplayerMode.CLIENT
           && registry.getNetworkThread() != null) {
         if (registry.getNetworkThread().readyForUpdates()) {
           EIError.debugMsg("Monster not found - need " + um.id);
           registry.getNetworkThread().sendData("send monster data: " + um.id);
         }
       }
     }
   }
 }
コード例 #4
0
 public void registerMonster(Monster m) {
   if (!monsters.containsKey(m.getId())) {
     monsters.put(m.getId(), m);
   }
 }
コード例 #5
0
  public void spawnNearPlayers() {
    Monster monster = null;
    float prob, rand;
    int count;
    HashMap<String, Player> players = registry.getPlayerManager().getPlayers();
    Player player = null;
    Integer spawnCoolDown = null;
    for (String key : players.keySet()) {
      player = (Player) players.get(key);

      // check for spawning Melvin
      if (registry.currentTime >= nextBossOrcSpawn && nextBossOrcSpawn != 0) {
        // to spawn melvin, player must have 40 AP, be within a range on the map and be on the
        // surface
        if (player.getMapX() >= 2000
            && player.getMapX() <= 5000
            && player.getLevel() >= 10
            && player.getMapY() == this.findFloor(player.getMapX())) {
          spawnBossOrc(player);
        }
      }

      if (spawnCoolDowns.containsKey(key)) {
        spawnCoolDown = spawnCoolDowns.get(key);
      } else {
        spawnCoolDown = new Integer(0);
        spawnCoolDowns.put(key, spawnCoolDown);
      }
      spawnCoolDown--;
      if (spawnCoolDown < 0) {
        int x = player.getMapX();
        int y = player.getMapY();
        int groundLevel = registry.getBlockManager().getLevelByY(y);
        count = -groundLevel;
        try {
          for (String key2 : monsters.keySet()) {
            monster = (Monster) monsters.get(key2);
            if (monster.getCenterPoint().distance(player.getCenterPoint())
                < MonsterManager.mobSpawnRangeMax * 3 / 2) {
              if (monster.getTouchDamage() > 0
                  && !monster.getName().equals("BlueThorn")
                  && !monster.getName().equals("VineThorn")) {
                count++;
              }
            }
          }
        } catch (ConcurrentModificationException concEx) {
          // another thread was trying to modify monsters while iterating
          // we'll continue and the new item can be grabbed on the next update
        }
        if (count < 4) {
          for (MonsterType monsterType : MonsterType.values()) {
            if (count < 4) {
              rand = Rand.getFloat();
              prob = getShouldSpawn(monsterType, groundLevel);
              if (prob > 0.0f) {
                if ((prob - count * spawnRatioDiff) > 0.005f) {
                  prob += -count * spawnRatioDiff;
                } else {
                  prob = 0.005f;
                }
              }
              if (rand <= prob) {
                // System.out.println("spawn near player " + monsterType.name());
                spawn(monsterType.name(), "Roaming", x, y);
                count++;
              }
            }
          }
        } else {
          // EIError.debugMsg("too many to spawn");
          spawnCoolDown = 20;
        }
      }
    }
  }