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; } }
@Override public String toString() { return "[NPC:" + EntityHandler.getNpcDef(id).getName() + "]"; }
public void killedBy(Mob mob, boolean stake) { if (mob instanceof Player) { Player player = (Player) mob; player.getActionSender().sendSound("victory"); } Mob opponent = super.getOpponent(); if (opponent != null) { opponent.resetCombat(CombatState.WON); } resetCombat(CombatState.LOST); world.unregisterNpc(this); this.remove(); // Player owner = mob instanceof Player ? (Player) mob : null; Player owner = null; if (mob instanceof Player) { owner = handleLootAndXpDistribution((Player) mob); if (PluginHandler.getPluginHandler() .blockDefaultAction("PlayerKilledNpc", new Object[] {owner, this})) { return; } } ItemDropDef[] drops = def.getDrops(); int total = 0; for (ItemDropDef drop : drops) { total += drop.getWeight(); } // int hit = DataConversions.random(0, total); total = 0; if (getCombatLevel() >= 90 && Constants.GameServer.MEMBER_WORLD) { // key halves? if (Formulae.Rand(0, 3000) == 500) { if (Formulae.Rand(0, 1) == 1) { world.registerItem(new Item(1276, getX(), getY(), 1, owner)); } else { world.registerItem(new Item(1277, getX(), getY(), 1, owner)); } } } for (ItemDropDef drop : drops) { if (drop == null) { continue; } if (drop.getWeight() == 0) { world.registerItem(new Item(drop.getID(), getX(), getY(), drop.getAmount(), owner)); continue; } if (hit >= total && hit < (total + drop.getWeight())) { if (drop.getID() != -1) { if (EntityHandler.getItemDef(drop.getID()).members && Constants.GameServer.MEMBER_WORLD) { world.registerItem(new Item(drop.getID(), getX(), getY(), drop.getAmount(), owner)); break; } if (!EntityHandler.getItemDef(drop.getID()).members) { world.registerItem(new Item(drop.getID(), getX(), getY(), drop.getAmount(), owner)); break; } } } total += drop.getWeight(); } // World.getQuestManager().handleNpcKilled(this, owner); }
public NPCDef getDef() { return EntityHandler.getNpcDef(getID()); }