Example #1
0
  ArrayList<Mob> getMobs() {
    ArrayList<Mob> realMobs = new ArrayList<Mob>();

    for (JsonMob jm : mobs) {

      Mob xyz = null;

      Class<?> cl;
      try {
        cl = Class.forName(jm.getName());

        Constructor<?> con = cl.getConstructor(float.class, float.class);
        xyz = (Mob) con.newInstance(jm.getX(), jm.getY());
      } catch (ClassNotFoundException e) {
        e.printStackTrace();
      } catch (NoSuchMethodException e) {
        e.printStackTrace();
      } catch (SecurityException e) {
        e.printStackTrace();
      } catch (InstantiationException e) {
        e.printStackTrace();
      } catch (IllegalAccessException e) {
        e.printStackTrace();
      } catch (IllegalArgumentException e) {
        e.printStackTrace();
      } catch (InvocationTargetException e) {
        e.printStackTrace();
      }

      xyz.setID(jm.getID());

      realMobs.add(xyz);
    }
    return realMobs;
  }
Example #2
0
  public Npc(NPCLoc loc) {
    for (int i : Constants.GameServer.UNDEAD_NPCS) {
      if (loc.getId() == i) {
        this.undead = true;
      }
    }
    for (int i : Constants.GameServer.ARMOR_NPCS) {
      if (loc.getId() == i) {
        this.hasArmor = true;
      }
    }

    def = EntityHandler.getNpcDef(loc.getId());
    curHits = def.getHits();

    this.loc = loc;
    super.setID(loc.getId());
    this.setLocation(Point.location(loc.startX(), loc.startY()), true);
    super.setCombatLevel(
        Formulae.getCombatLevel(def.getAtt(), def.getDef(), def.getStr(), def.getHits(), 0, 0, 0));

    if (this.loc.getId() == 189
        || this.loc.getId() == 53
        || this.loc.getId() == 19) { // this should not be here
      this.def.aggressive = true;
    }
  }