Code:
package com.rs2hd.model;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.*;
import com.rs2hd.event.Event;
import com.rs2hd.io.XStreamPlayerLoader;
import com.rs2hd.GameEngine;
import com.rs2hd.content.Combat.CombatType;
import com.rs2hd.content.clans.Clan;
import com.rs2hd.content.minigames.dungman;
import com.rs2hd.content.minigames.clanminis.WKInvasion;
import com.rs2hd.content.DeathEvent;
import com.rs2hd.model.Hits.Hit;
import com.rs2hd.util.Misc;
import com.rs2hd.content.skills.combat.PkDefinitions;
import com.rs2hd.model.Hits;
import com.rs2hd.model.Player;
import com.rs2hd.model.World;
import com.rs2hd.model.Hits.HitType;
import com.rs2hd.content.skills.prayer.CursesEffectsHandler;
import com.rs2hd.model.NPC;
import com.rs2hd.content.NomadHandler;
/**
* Represents a 'non-player' character in the game.
* @author Graham
*
*/
public class NPC extends Entity {
public static int dragD[] = {7562, 5320, 5323, 5291, 5292, 5295, 5299, 5293, 995, 1215, 5321, 5322, 5328, 5329, 5333};
public static int dragD() {
return dragD[(int) (Math.random() * dragD.length)];
}
public static int runeD[] = {7562, 5320, 5323, 5291, 5292, 5295, 5299, 5293, 995, 8850};
public static int runeD() {
return runeD[(int) (Math.random() * runeD.length)];
}
public static int addyD[] = {7562, 5320, 5323, 5291, 5292, 5295, 5299, 5293, 995, 8849};
public static int addyD() {
return addyD[(int) (Math.random() * addyD.length)];
}
public static int mithD[] = {7562, 5320, 5323, 5291, 5292, 5295, 5299, 5293, 995, 8848};
public static int mithD() {
return mithD[(int) (Math.random() * mithD.length)];
}
public static int blackD[] = {7562, 5320, 5323, 5291, 5292, 5295, 5299, 5293, 995, 8847};
public static int blackD() {
return blackD[(int) (Math.random() * blackD.length)];
}
public static int steelD[] = {7562, 5320, 5323, 5291, 5292, 5295, 5299, 5293, 995, 8846};
public static int steelD() {
return steelD[(int) (Math.random() * steelD.length)];
}
public static int ironD[] = {7562, 5320, 5323, 5291, 5292, 5295, 5299, 5293, 995, 8845};
public static int ironD() {
return ironD[(int) (Math.random() * ironD.length)];
}
public static int bronD[] = {7562, 5320, 5323, 5291, 5292, 5295, 5299, 5293, 995, 8844};
public static int bronD() {
return bronD[(int) (Math.random() * bronD.length)];
}
public static int PlayingPointsReward[] = {1, 5, 10, 10, 15, 20, 25, 30, 35, 40, 45, 50, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 100, 50, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 100, 110, 120, 130, 140, 150, 150, 1, 5, 10, 10, 15, 20, 25, 30, 35, 40, 45, 50, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 100, 110, 120, 130, 140, 150, 150};
public static int PlayingPointsReward() {
return PlayingPointsReward[(int) (Math.random() * PlayingPointsReward.length)];
}
//, 160, 170, 180, 190, 200, 215, 230, 245, 260, 275, 290, 305, 325, 345, 365, 385, 405, 430, 455, 480, 505, 535, 565, 595, 625, 660, 695, 730, 770, 810, 855, 900, 1000
public int giveDrop = 0;
public int NPCForceChat = 0;
private transient boolean IsFamiliar = false;
public transient int AttackStyle = 0;
public transient int NPCCharges = 0;
public transient boolean UsingThis = false;
public transient int NPCDamage[] = new int[14];
public transient boolean npccanloot=false;
public transient Player partner;
public transient int frozen;
public transient int npcOpp;
private transient NpcWalk NpcWalk;
public Item dropId(int id, int amt) {
return new Item(id, amt);
}
public void resetNpcDef() {
AttackStyle = 0;
NPCCharges = 0;
UsingThis = false;
NPCDamage = new int[14];
if (this.getId() == 8324) {
NPCCharges = 20;
}
}
public void npcDiedBones(Player p, int npcID) {
switch(npcID) {
case 6260:
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(14793, 1));
giveDrop = 0;
break;
case 10710:
case 10717:
case 115:
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(532, 1));
giveDrop = 0;
break;
case 2025:
case 2026:
case 2027:
case 2028:
case 2029:
case 2030:
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(592, 1));
giveDrop = 0;
break;
case 2881:
case 2882:
case 2883:
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(6729, 1));
giveDrop = 0;
break;
case 10775:
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(18830, 1));
giveDrop = 0;
break;
case 50:
case 941:
if(getId() == 941) {
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(1753, 1));
giveDrop = 0;
}else{
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(1747, 1));
giveDrop = 0;
}
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(536, 1));
giveDrop = 0;
break;
default:
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(526, 1));
giveDrop = 0;
break;
}
}
public static Random rand = new Random();
public void npcDied(Player p, int npcID) {
final int NPCList[] = {1267, 1648, 1612, 1637, 10575, 1604, 6215, 8125, 6218, 6229, 6231, 6232, 6233, 6234, 6235, 6236, 6237, 6238, 1610, 10700, 1615, 2783, 1624, 5529, 13603, 6261, 6263, 6265, 6204, 6206, 6208, 6248, 6250, 6252, 8776, 2025, 2026, 2027, 2028, 2029, 2030, 10770, 10068, 8282, 8549, 9176, 5666, 5421, 3200, 3847, 8327, 8326, 8325, 8350, 8351, 9462, 9463, 7133, 50, 6260, 6203, 6222, 6247, 2881, 2882, 2883, 1160, 8133, 2745, 10141, 10127, 11737, 13447, };
//random npcs // godwars npcs // high level slayer npcs // bandos min // Zammy min // Sara min // Cannoners // Barrows brothers // frosts //hgb
final String PointsName = "Playing Points";
final String NpcName = NPCDefinition.forId(npcID).getName();
final String Message = "<col=20B2AA>You've defeated : <shad=90EE90>"+NpcName+"</shad> and received <shad=90EE90>"+PlayingPointsReward()+"</shad> "+PointsName+" !</col>";
/** Start of code **/
for (int i = 0; i < NPCList.length; i++) {
if (npcID == NPCList[i]) {
p.PlayingPoints += PlayingPointsReward();
p.sm(Message);
return;
}
}
p.sm("This monster doesn't give any reward, please report to staff with following details :");
p.sm("Name : "+NpcName+" - ID : "+npcID+".");
switch(npcID) {
case 8596: //soulwars avatar
case 8597:
p.zeal += 4;
p.sm("<col=FFFFFF>You have gained 4 Zeals for defeating a Soulwars Avatar.");
p.PlayingPoints += PlayingPointsReward();
p.sm(Message);
break;
case 8529: // Slayer mini game
p.PlayingPoints += PlayingPointsReward();
p.sm(Message);
p.getInventory().addItem(1590, 1);
p.sm("<col=00FF00>You got a dusty key, try openning the chest at home!</col>");
break;
case 9927:
p.DungTokens += 250;
p.PlayingPoints += 105;
p.getSkills().addXp(24, 120000);
p.sm("You have defeated a Lumeinescent IceFiend and gained 250 Dung Points + 105 "+PointsName+"!");
break;
case 757:
if(p.halloweenStage == 4) {
p.halloweenStage = 5;
p.sm("You beat the count and received a green h'ween!");
if(!p.getInventory().addItem(13538, 1)) {
p.sm("That item has been banked!");
p.getBank().getContainer().add(new Item(13538, 1));
}
return;
} else {
if(p.halloweenStage != 7) {
return;
}
}
break;
}
try {
BufferedReader in = new BufferedReader(new FileReader("data/npcdrops.cfg"));
String input;
String[] splitEQL;
String[] splitCOM;
String[] splitDSH;
String[] splitCLN;
String[] splitSCL;
while ((input = in.readLine()) != null) {
splitEQL = null; splitEQL = null; splitDSH = null; splitCLN = null; splitSCL = null;
if (!input.startsWith("/") && input.contains("=") && input.contains(",") && input.contains("-") && input.contains(":")) {
try {
splitEQL = input.split("=");
if (Integer.parseInt(splitEQL[0]) == npcID) {
splitSCL = splitEQL[1].split(";");
for (int i = 0; i < splitSCL.length; i++) {
splitCOM = splitSCL[i].split(",");
splitDSH = splitCOM[1].split("-");
splitCLN = splitCOM[2].split(":");
int item = Integer.parseInt(splitCOM[0]);
int min = Integer.parseInt(splitDSH[0]);
int max = Integer.parseInt(splitDSH[1]);
int chance = Integer.parseInt(splitCLN[0]);
int outOf = Integer.parseInt(splitCLN[1]);
int amount = rand.nextInt((max - min)+1) + min;
int ifDrop = rand.nextInt(outOf)+1;
boolean wealthInc = false;
Clan clan = World.getWorld().getClanManager().getClans(p.getSettings().getClanOwner());
if(p.getEquipment().get(Equipment.SLOT_RING) != null) {
if (p.getEquipment().get(Equipment.SLOT_RING).getId() == 2572) {
int wealth = Misc.random(100);
if(wealth <= 60) {
wealthInc = true;
}
}
}
if(clan != null && clan.isLootsharing()) {
wealthInc = false;
}
if(wealthInc) {
ifDrop -= 3;
}
if (ifDrop <= chance) {
World.getWorld().getItemManager().createDropGroundItem(getLooter(p, item, amount, clan, getLocation()), this.getLocation(), dropId(item, amount));
npccanloot = false;
giveDrop = 0;
}
}
}
} catch (Exception e) {
if(e instanceof NullPointerException) {
for(StackTraceElement stack : e.getStackTrace()) {
XStreamPlayerLoader.punish.writeTo(stack.toString(), "data/text/errors");
}
XStreamPlayerLoader.punish.writeTo("", "data/text/errors");
XStreamPlayerLoader.punish.writeTo("", "data/text/errors");
}
System.out.println("Exception dropping item:\n"+e);
}
}
}
in.close();
} catch (IOException e) {
System.out.println(e);
}
}
public Player getLooter(Player player, int id, int amount, Clan clan, Location location) {
Player done = player;
if(clan != null) {
if(clan.isLootsharing()) {
List<Player> playersGetLoot = new LinkedList<Player>();
int best = 0;
for(Player pl : clan.getMembers()) {
if(location.withinDistance(pl.getLocation(), 16)) {
if(!killerHits.containsKey(pl.getUsername())) {
continue;
}
int damage = killerHits.get(pl.getUsername()) + pl.getSettings().getChances();
if(damage > best) {
playersGetLoot.add(pl);
best = damage;
} else {
if(Misc.random(2) == 1) {
playersGetLoot.add(pl);
}
}
pl.getSettings().incChances();
if(pl.getSettings().getChances() < 0) {
pl.getSettings().setChances(0);
}
}
}
for(Player pl : playersGetLoot) {
if(Misc.random(2) == 1) {
done = pl;
for(int i = 0; i < 5; i++) {
pl.getSettings().decChances();
}
break;
}
}
}
}
if(clan != null && clan.isLootsharing()) {
done.getActionSender().sendMessage("<col=008000>You received: " + amount + " x " + ItemDefinition.forId(id).getName());
for(final Player pl : clan.getMembers()) {
if(pl.getIndex() == done.getIndex()) {
continue;
}
if(location.withinDistance(pl.getLocation(), 16)) {
pl.getActionSender().sendMessage(done.getUsername() + " received: " + amount + " x " + ItemDefinition.forId(id).getName());
World.getWorld().registerEvent(new Event(3000) {
public void execute() {
pl.getActionSender().sendMessage("Your chance of receiving loot has improved.");
this.stop();
}
});
}
}
}
return done;
}
public static enum WalkType {
STATIC,
RANGE,
}
//public int pfollow = 0;
public int pid = 0;
public boolean Attacking = false;
public int combatDelay = 0;
private int id;
private transient boolean followIsDelayed;
private transient NPCDefinition definition;
private transient NPCUpdateFlags updateFlags;
private transient ForceText forceText;
public transient int sprite;
private transient int hp;
private transient Queue<Hit> queuedHits;
private WalkType walkType;
private transient Location originalLocation;
private Location minimumCoords = Location.location(0, 0, 0);
private Location maximumCoords = Location.location(0, 0, 0);
public transient int pfollow = -1;
public void setFollowDelayed(boolean b) {
try {
this.followIsDelayed = b;
} catch(Exception e) {
}
}
public boolean isFollowDelayed() {
return followIsDelayed;
}
public NPC(int id) {
this.id = id;
this.definition = NPCDefinition.forId(id);
this.setWalkType(WalkType.STATIC);
}
public boolean FullEliteBlackEquipped(Player p) {
try {
if(p.getEquipment().get(0).getDefinition().getId() == 14494 && p.getEquipment().get(4).getDefinition().getId() == 14492 && p.getEquipment().get(7).getDefinition().getId() == 14490)
{
return true;
}
return false;
} catch (Exception e) {
return false;
}
}
public void Agressive() {
if (this.isDead() || this.isDestroyed()) {
return;
}
for(int i : WKInvasion.WYRMS) {
if(id == i) {
for(Player pl : World.getWorld().getRegionManager().getLocalPlayers(getLocation())) {
if(Misc.getDistance(this.getLocation().getX(), this.getLocation().getY(), pl.getLocation().getX(), pl.getLocation().getY()) <= 8) {
this.pid = pl.getIndex();
this.Attacking = true;
}
}
break;
}
}
switch (this.getId()) {
case 6815: //melee
case 6816: //range
break;
case 50:
case 10141://Ballak
case 10127://Unholy Cursebearer
for(Player ppp : World.getWorld().getRegionManager().getLocalPlayers(getLocation())) {
if(Misc.getDistance(this.getLocation().getX(), this.getLocation().getY(), ppp.getLocation().getX(), ppp.getLocation().getY()) <= 8) {
this.pid = ppp.getIndex();
this.Attacking = true;
}
}
break;
case 6222: //melee
case 6223: //range
case 6225: //magic
case 6227:
for(Player p : World.getWorld().getRegionManager().getLocalPlayers(getLocation())) {
if (Misc.getDistance(this.getLocation().getX(), this.getLocation().getY(), p.getLocation().getX(), p.getLocation().getY()) <= 4) {
this.pid = p.getIndex();
this.Attacking = true;
}
}
break;
case 6260: //melee
case 6261: //range
case 6263: //magic
case 6265:
for(Player p : World.getWorld().getRegionManager().getLocalPlayers(getLocation())) {
if (Misc.getDistance(this.getLocation().getX(), this.getLocation().getY(), p.getLocation().getX(), p.getLocation().getY()) <= 4) {
this.pid = p.getIndex();
this.Attacking = true;
}
}
break;
case 6247: //melee
case 6248: //range
case 6250: //magic
case 6252:
for(Player p : World.getWorld().getRegionManager().getLocalPlayers(getLocation())) {
if (Misc.getDistance(this.getLocation().getX(), this.getLocation().getY(), p.getLocation().getX(), p.getLocation().getY()) <= 4) {
this.pid = p.getIndex();
this.Attacking = true;
}
}
break;
case 2881: //melee
case 2882: //range
case 2883: //magic
for(Player p : World.getWorld().getRegionManager().getLocalPlayers(getLocation())) {
if (Misc.getDistance(this.getLocation().getX(), this.getLocation().getY(), p.getLocation().getX(), p.getLocation().getY()) <= 22) {
this.pid = p.getIndex();
this.Attacking = true;
}
}
break;
case 3200: //all
case 6604: //Revs
case 6605:
case 6607:
case 6610:
case 6611:
case 8125: //Tormented wraith
for(Player p : World.getWorld().getRegionManager().getLocalPlayers(getLocation())) {
if (Misc.getDistance(this.getLocation().getX(), this.getLocation().getY(), p.getLocation().getX(), p.getLocation().getY()) <= 4) {
this.pid = p.getIndex();
this.Attacking = true;
}
}
break;
case 7133:
case 7135:
case 7134:
for(Player p : World.getWorld().getRegionManager().getLocalPlayers(getLocation())) {
if (Misc.getDistance(this.getLocation().getX(), this.getLocation().getY(), p.getLocation().getX(), p.getLocation().getY()) <= 12) {
this.pid = p.getIndex();
this.Attacking = true;
}
}
break;
case 3706:
for(Player p : World.getWorld().getRegionManager().getLocalPlayers(getLocation())) {
if (Misc.getDistance(this.getLocation().getX(), this.getLocation().getY(), p.getLocation().getX(), p.getLocation().getY()) <= 26) {
this.pid = p.getIndex();
this.Attacking = true;
}
}
break;
case 7084:
case 7085:
case 7086:
for(Player p : World.getWorld().getRegionManager().getLocalPlayers(getLocation())) {
if (Misc.getDistance(this.getLocation().getX(), this.getLocation().getY(), p.getLocation().getX(), p.getLocation().getY()) <= 40) {
this.pid = p.getIndex();
this.Attacking = true;
}
}
break;
case 2745: //all
for(Player p : World.getWorld().getRegionManager().getLocalPlayers(getLocation())) {
if (Misc.getDistance(this.getLocation().getX(), this.getLocation().getY(), p.getLocation().getX(), p.getLocation().getY()) <= 4) {
this.pid = p.getIndex();
this.Attacking = true;
}
}
break;
case 6203: //melee
case 6208: //range
case 6206: //magic
case 6204:
for(Player p : World.getWorld().getRegionManager().getLocalPlayers(getLocation())) {
if (Misc.getDistance(this.getLocation().getX(), this.getLocation().getY(), p.getLocation().getX(), p.getLocation().getY()) <= 4) {
this.pid = p.getIndex();
this.Attacking = true;
}
}
break;
case 8350:
case 8351:
case 8352:
for(Player p : World.getWorld().getRegionManager().getLocalPlayers(getLocation())) {
this.pid = p.getIndex();
this.Attacking = true;
}
break;
case 8454:
if (UsingThis == true) {
return;
}
for(Player ballenergy : World.getWorld().getRegionManager().getLocalPlayers(getLocation())) {
if(Misc.getDistance(this.getLocation().getX(), this.getLocation().getY(), ballenergy.getLocation().getX(), ballenergy.getLocation().getY()) <= 1) {
ballenergy.NpcDialogue().StartTalkingTo(this);
return;
}
}
break;
case 8127:
case 8133:
for(Player p : World.getWorld().getRegionManager().getLocalPlayers(getLocation())) {
if (p.IsAtCorporeal()) {
this.pid = p.getIndex();
this.Attacking = true;
}
}
break;
case 1158:
case 1160:
for(Player p : World.getWorld().getRegionManager().getLocalPlayers(getLocation())) {
if(Misc.getDistance(this.getLocation().getX(), this.getLocation().getY(), p.getLocation().getX(), p.getLocation().getY()) < 30) {
this.pid = p.getIndex();
this.Attacking = true;
}
}
case 8529://nomad
//LRC monsters
case 8832:
case 8833:
case 8834:
for(Player p : World.getWorld().getRegionManager().getLocalPlayers(getLocation())) {
if(Misc.getDistance(this.getLocation().getX(), this.getLocation().getY(), p.getLocation().getX(), p.getLocation().getY()) < 2) {
this.pid = p.getIndex();
this.Attacking = true;
}
}
break;
}
}
public void FollowNoAgressive(Player p) {
if (this.isDead()||this.isDestroyed()) {
return;
}
switch (this.getId()) {
case 8324:
case 8325: //melee
case 8326: //range
case 8327: //magic
if (p.IsAtBlackCastle() && !FullEliteBlackEquipped(p)) {
this.getNpcWalk().followPlayer(p,1);
}else{
this.resetAttack();
}
break;
case 8127: //follow lol no walk
this.resetAttack();
break;
case 8133:
if (p.IsAtCorporeal())
this.getNpcWalk().followPlayer(p,1);
else
this.resetAttack();
break;
case 8350:
case 8351:
// portals
case 6142:
GameEngine.pcPurple = 1;
p.getActionSender().sendString("DEAD", 408, 13);
GameEngine.pcGamebeat += 1;
break;
case 6144:
GameEngine.pcGamebeat += 1;
p.getActionSender().sendString("DEAD", 408, 15);
GameEngine.pcYellow = 1;
break;
case 6145:
GameEngine.pcGamebeat += 1;
p.getActionSender().sendString("DEAD", 408, 16);
GameEngine.pcRed = 1;
break;
case 6143:
GameEngine.pcGamebeat += 1;
p.getActionSender().sendString("DEAD", 408, 14);
GameEngine.pcBlue = 1;
break;
case 8352:
if (p.IsAtTormented()) {
this.getNpcWalk().followPlayer(p,1);
} else {
this.resetAttack();
break;
}
case 6815:
case 6816:
this.getNpcWalk().followPlayer(p,1);
break;
default:
if(Misc.getDistance(this.getLocation().getX(), this.getLocation().getY(), p.getLocation().getX(), p.getLocation().getY()) < 16)
this.getNpcWalk().followPlayer(p,1);
else
this.resetAttack();
break;
}
}
public void followPlayer(Entity p, int Size) {
if (isIsFamiliar()) {
if(this.getLocation().getDistance(p.getLocation()) == 3) {
this.setFollowDelayed(false);
return;
}
if(!this.isFollowDelayed()) {
this.setFollowDelayed(true);
return;
}
}
sprite = -1;
int moveX = 0, moveY = 0;
int pX = p.getLocation().getX();
int pY = p.getLocation().getY();
int nabsX = this.getLocation().getX();
int nabsY = this.getLocation().getY();
if(pY < nabsY && pX == nabsX) {
moveX = 0;
moveY = NpcWalk.getMove(nabsY, pY + 1);
}
else if(pY > nabsY && pX == nabsX) {
moveX = 0;
moveY = NpcWalk.getMove(nabsY, pY - 1);
}
else if(pX < nabsX && pY == nabsY) {
moveX = NpcWalk.getMove(nabsX, pX + 1);
moveY = 0;
}
else if(pX > nabsX && pY == nabsY) {
moveX = NpcWalk.getMove(nabsX, pX - 1);
moveY = 0;
}
else if(pX < nabsX && pY < nabsY) {
moveX = NpcWalk.getMove(nabsX, pX + 1);
moveY = NpcWalk.getMove(nabsY, pY + 1);
}
else if(pX > nabsX && pY > nabsY) {
moveX = NpcWalk.getMove(nabsX, pX - 1);
moveY = NpcWalk.getMove(nabsY, pY - 1);
}
else if(pX < nabsX && pY > nabsY) {
moveX = NpcWalk.getMove(nabsX, pX + 1);
moveY = NpcWalk.getMove(nabsY, pY - 1);
}
else if(pX > nabsX && pY < nabsY) {
moveX = NpcWalk.getMove(nabsX, pX - 1);
moveY = NpcWalk.getMove(nabsY, pY + 1);
}
int tgtX = this.getLocation().getX() + moveX;
int tgtY = this.getLocation().getY() + moveY;
sprite = Misc.direction(this.getLocation().getX(), this.getLocation().getY(), tgtX, tgtY);
if(sprite != -1) {
sprite >>= 1;
this.setLocation(Location.location(tgtX, tgtY, this.getLocation().getZ()));
}
}
/** Npc stats from Instinct562 **/
public int getDefenceBonusMelee() {
switch (getId()) {
case 10263:
return 0;
case 1158:
return 500;
case 1160:
return 600;
case 8324:
case 8326:
case 8327:
return 150;
case 8325:
return 1000;
case 8352:
return 1100;
case 8351:
return 700;
case 8350:
return 700;
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
return 3;
case 134:
return 90;
case 1615:
return 140;
case 2614:
return 230;
case 5902:
return 280;
case 5253:
return 190;
case 6223:
return 195;
case 6225:
return 210;
case 6227:
return 200;
case 6222:
return 190;
case 6260:
return 340;
case 13447:
return 5000;
case 8133:
return 1000; // corp
case 6261:
return 230;
case 6263:
return 250;
case 3847:
return 230;
case 1472:
return 240;
case 2745:
return 130;
case 2746:
return 10;
case 4284:
return 150;
case 4291:
return 90;
case 4292:
return 95;
case 6265:
return 240;
case 6625:
return 150;
case 6729:
return 170;
case 6247:
return 290;
case 6691:
return 190;
case 6998:
return 180;
case 6999:
return 160;
case 7770:
return 180;
case 7771:
return 420;
default:
return 20;
}
}
public int getDefenceBonusRange() {
switch (getId()) {
case 10263:
return 0;
case 1158:
return 5000;
case 1160:
return 5000;
case 8324:
case 8327:
return 200;
case 8325:
return 5000;
case 8352:
return 1100;
case 8351:
return 700;
case 8350:
return 700;
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
return 0;
case 134:
return 5000;
case 1615:
return 5000;
case 2614:
return 5000;
case 5902:
return 5000;
case 5253:
return 5000;
case 6223:
return 5000;
case 6225:
return 5000;
case 6227:
return 5000;
case 6222:
return 5000;
case 6260:
return 5000;
case 13447:
return 600000;
case 8133:
return 200000; // corp
case 6261:
return 5000;
case 6263:
return 5000;
case 3847:
return 5000;
case 1472:
return 5000;
case 2745:
return 130;
case 2746:
return 10;
case 4284:
return 150;
case 4291:
return 90;
case 4292:
return 95;
case 6265:
return 5000;
case 6625:
return 150;
case 6729:
return 170;
case 6247:
return 5000;
case 6691:
return 190;
case 6998:
return 180;
case 6999:
return 160;
case 7770:
return 180;
case 7771:
return 5000;
default:
return 0;
}
}
public int getDefenceMelee() {
switch (getId()) {
case 10263:
return 0;
case 1158:
return 114;
case 1160:
return 114;
case 8324:
case 8326:
case 8327:
return 150;
case 8325:
return 114;
case 8352:
return 114;
case 8351:
return 114;
case 8350:
return 114;
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
return 3;
case 134:
return 90;
case 1615:
return 140;
case 2614:
return 230;
case 5902:
return 280;
case 5253:
return 190;
case 6223:
return 195;
case 6225:
return 210;
case 6227:
return 200;
case 6222:
return 190;
case 6260:
return 114;
case 13447:
return 2500;
case 8133:
return 2000; // corp
case 6261:
return 230;
case 6263:
return 250;
case 3847:
return 230;
case 1472:
return 240;
case 2745:
return 130;
case 2746:
return 10;
case 4284:
return 150;
case 4291:
return 90;
case 4292:
return 95;
case 6265:
return 240;
case 6625:
return 150;
case 6729:
return 170;
case 6247:
return 290;
case 6691:
return 190;
case 6998:
return 180;
case 6999:
return 160;
case 7770:
return 180;
case 7771:
return 114;
default:
return 20;
}
}
public int getAttackLevelMelee() {
switch (getId()) {
case 10263:
return 0;
case 1158:
return 114;
case 1160:
return 114;
case 8324:
case 8326:
case 8327:
return 150;
case 8325:
return 114;
case 8352:
return 114;
case 8351:
return 114;
case 8350:
return 114;
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
return 3;
case 134:
return 90;
case 1615:
return 140;
case 2614:
return 230;
case 5902:
return 280;
case 5253:
return 190;
case 6223:
return 195;
case 6225:
return 210;
case 6227:
return 200;
case 6222:
return 190;
case 6260:
return 114;
case 13447:
return 299;
case 8133:
return 320; // corp
case 6261:
return 230;
case 6263:
return 250;
case 3847:
return 230;
case 1472:
return 240;
case 2745:
return 130;
case 2746:
return 10;
case 4284:
return 150;
case 4291:
return 90;
case 4292:
return 95;
case 6265:
return 240;
case 6625:
return 150;
case 6729:
return 170;
case 6247:
return 290;
case 6691:
return 190;
case 6998:
return 180;
case 6999:
return 160;
case 7770:
return 180;
case 7771:
return 114;
default:
return 35;
}
}
public int getAttackBonusMelee() {
switch (getId()) {
case 10263:
return 0;
case 1158:
return 114;
case 1160:
return 114;
case 8324:
case 8326:
case 8327:
return 150;
case 8325:
return 114;
case 8352:
return 114;
case 8351:
return 114;
case 8350:
return 114;
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
return 3;
case 134:
return 90;
case 1615:
return 140;
case 2614:
return 230;
case 5902:
return 280;
case 5253:
return 190;
case 6223:
return 195;
case 6225:
return 210;
case 6227:
return 200;
case 6222:
return 190;
case 6260:
return 114;
case 13447:
return 100;
case 8133:
return 320; // corp
case 6261:
return 230;
case 6263:
return 250;
case 3847:
return 230;
case 1472:
return 240;
case 2745:
return 130;
case 2746:
return 10;
case 4284:
return 150;
case 4291:
return 90;
case 4292:
return 95;
case 6265:
return 240;
case 6625:
return 150;
case 6729:
return 170;
case 6247:
return 290;
case 6691:
return 190;
case 6998:
return 180;
case 6999:
return 160;
case 7770:
return 180;
case 7771:
return 114;
default:
return 35;
}
}
public int getDefenceRange() {
switch (getId()) {
case 10263:
return 0;
case 1158:
return 450;
case 1160:
return 675;
case 8324:
case 8327:
return 200;
case 8325:
return 1000;
case 8352:
return 1100;
case 8351:
return 700;
case 8350:
return 700;
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
return 0;
case 134:
return 90;
case 1615:
return 140;
case 2614:
return 230;
case 5902:
return 280;
case 5253:
return 190;
case 6223:
return 195;
case 6225:
return 210;
case 6227:
return 200;
case 6222:
return 190;
case 6260:
return 340;
case 13447:
return 10000;
case 8133:
return 9500; // corp
case 6261:
return 230;
case 6263:
return 250;
case 3847:
return 230;
case 1472:
return 240;
case 2745:
return 130;
case 2746:
return 10;
case 4284:
return 150;
case 4291:
return 90;
case 4292:
return 95;
case 6265:
return 240;
case 6625:
return 150;
case 6729:
return 170;
case 6247:
return 290;
case 6691:
return 190;
case 6998:
return 180;
case 6999:
return 160;
case 7770:
return 180;
case 7771:
return 420;
default:
return 0;
}
}
public int getMagicLevel() {
switch (getId()) {
case 10263:
return 0;
case 1158:
return 114;
case 1160:
return 114;
case 8324:
case 8326:
case 8327:
return 150;
case 8325:
return 114;
case 8352:
return 114;
case 8351:
return 114;
case 8350:
return 114;
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
return 3;
case 134:
return 90;
case 1615:
return 100;
case 2614:
return 100;
case 5902:
return 100;
case 5253:
return 100;
case 6223:
return 100;
case 6225:
return 100;
case 6227:
return 100;
case 6222:
return 100;
case 6260:
return 100;
case 13447:
return 100;
case 8133:
return 100; // corp
case 6261:
return 100;
case 6263:
return 100;
case 3847:
return 100;
case 1472:
return 100;
case 2745:
return 100;
case 2746:
return 10;
case 4284:
return 100;
case 4291:
return 90;
case 4292:
return 95;
case 6265:
return 100;
case 6625:
return 100;
case 6729:
return 100;
case 6247:
return 100;
case 6691:
return 100;
case 6998:
return 100;
case 6999:
return 100;
case 7770:
return 100;
case 7771:
return 100;
default:
return 20;
}
}
public int getMagicBonus() {
switch (getId()) {
case 10263:
return 0;
case 1158:
return 45;
case 1160:
return 45;
case 8324:
case 8326:
case 8327:
return 45;
case 8325:
return 45;
case 8352:
return 45;
case 8351:
return 45;
case 8350:
return 45;
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
return 3;
case 134:
return 45;
case 1615:
return 45;
case 2614:
return 45;
case 5902:
return 45;
case 5253:
return 45;
case 6223:
return 45;
case 6225:
return 45;
case 6227:
return 45;
case 6222:
return 45;
case 6260:
return 45;
case 13447:
return 45;
case 8133:
return 45; // corp
case 6261:
return 45;
case 6263:
return 45;
case 3847:
return 45;
case 1472:
return 45;
case 2745:
return 45;
case 2746:
return 45;
case 4284:
return 45;
case 4291:
return 45;
case 4292:
return 45;
case 6265:
return 45;
case 6625:
return 45;
case 6729:
return 45;
case 6247:
return 45;
case 6691:
return 45;
case 6998:
return 45;
case 6999:
return 45;
case 7770:
return 45;
case 7771:
return 45;
default:
return 15;
}
}
public void giveSlayer(Player winner) {
if (isDead()) {
final Player p = winner;
this.npccanloot = true;
npcDied(p, id);
npcDiedBones(p, id);
switch (getId()) {
case 10797:
if (p.Dungquest == 3) {
p.FIRST = true;
p.dungStage = 2;
}
break;
case 10791:
if (p.Dungquest == 3) {
p.SECOND = true;
p.dungStage = 3;
}
break;
case 10776:
if (p.Dungquest == 3) {
p.THIRD = true;
p.dungStage = 4;
}
break;
case 10771:
if (p.Dungquest == 3) {
p.FOURTH = true;
p.dungStage = 5;
}
break;
case 10757:
if (p.Dungquest == 3) {
p.FITH = true;
p.dungStage = 6;
}
break;
case 10820:
if (p.Dungquest == 3) {
p.SIX = true;
p.dungStage = 7;
}
break;
case 10224:
if (p.Dungquest == 3) {
p.SEVENTH = true;
p.dungStage = 8;
}
break;
case 10141:
if (p.Dungquest == 4) {
p.BOSS = true;
dungman.COMPLETE = true;
}
break;/*
case 2030:
p.verac = 1;
p.sm("You have defeated Verac");
break;
case 2026:
p.dh = 1;
p.sm("You have defeated Dharok");
break;
case 2027:
p.guthan = 1;
p.sm("You have defeated Guthan");
break;
case 2025:
p.ahrim = 1;
p.sm("You have defeated Ahrim");
break;
case 2028:
p.karil = 1;
p.sm("You have defeated Karil");
break;
case 2029:
p.torag = 1;
p.sm("You have defeated Torag");
break;*/
case 6142:
GameEngine.pcPurple = 1;
p.getActionSender().sendString("DEAD", 408, 13);
GameEngine.pcGamebeat += 1;
break;
case 6144:
GameEngine.pcGamebeat += 1;
p.getActionSender().sendString("DEAD", 408, 15);
GameEngine.pcYellow = 1;
break;
case 6145:
GameEngine.pcGamebeat += 1;
p.getActionSender().sendString("DEAD", 408, 16);
GameEngine.pcRed = 1;
break;
case 6143:
GameEngine.pcGamebeat += 1;
p.getActionSender().sendString("DEAD", 408, 14);
GameEngine.pcBlue = 1;
break;
case 4971:
p.killcount ++;
break;
case 4972:
p.killcount ++;
break;
case 6999:
p.killcount ++;
break;
//slayer
case 1648:
case 1612:
case 10575:
case 1604:
case 1610:
case 10700:
case 1615:
case 6215:
case 2783:
case 1637:
p.getSlayer().decreaseSlayerAmount(this.getId());
break;
//end slayer
case 116:
if (p.getInventory().contains(8844)){
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(ironD(), 1));
p.getInventory().deleteItem(8851, 2);
p.sm("The cyclops are currently dropping IRON defenders!");
giveDrop = 0;
} else if (p.getInventory().contains(8845)){
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(steelD(), 1));
p.getInventory().deleteItem(8851, 2);
p.sm("The cyclops are currently dropping STEEL defenders!");
giveDrop = 0;
} else if (p.getInventory().contains(8846)){
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(blackD(), 1));
p.getInventory().deleteItem(8851, 2);
p.sm("The cyclops are currently dropping BLACK defenders!");
giveDrop = 0;
} else if (p.getInventory().contains(8847)){
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(mithD(), 1));
p.getInventory().deleteItem(8851, 2);
p.sm("The cyclops are currently dropping MITHRIL defenders!");
giveDrop = 0;
} else if (p.getInventory().contains(8848)){
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(addyD(), 1));
p.getInventory().deleteItem(8851, 2);
p.sm("The cyclops are currently dropping ADDY defenders!");
giveDrop = 0;
} else if (p.getInventory().contains(8849)){
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(runeD(), 1));
p.getInventory().deleteItem(8851, 3);
p.sm("The cyclops are currently dropping RUNE defenders!");
giveDrop = 0;
} else if (p.getInventory().contains(8850)){
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(dragD(), 1));
p.getInventory().deleteItem(8851, 4);
p.sm("The cyclops are currently dropping DRAGON defenders!");
giveDrop = 0;
} else {
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(bronD(), 1));
p.getInventory().deleteItem(8851, 2);
p.sm("The cyclops are currently dropping BRONZE defenders!");
giveDrop = 0;
}
break;
case 4284:
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(1079, 1));
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(1163, 1));
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(1127, 1));
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(8851, 40));
p.guild = 0;
p.sm("You killed the animated armour good job!");
giveDrop = 0;
break;
case 4283:
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(1073, 1));
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(1123, 1));
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(1061, 1));
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(8851, 30));
p.guild = 0;
p.sm("You killed the animated armour good job!");
giveDrop = 0;
break;
case 4282:
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(1071, 1));
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(1121, 1));
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(1059, 1));
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(8851, 25));
p.guild = 0;
p.sm("You killed the animated armour good job!");
giveDrop = 0;
break;
case 4281:
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(1077, 1));
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(1125, 1));
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(1065, 1));
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(8851, 20));
p.guild = 0;
p.sm("You killed the animated armour good job!");
giveDrop = 0;
break;
case 4280:
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(1157, 1));
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(1119, 1));
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(1069, 1));
World.getWorld().getItemManager().createDropGroundItem(p, this.getLocation(), dropId(8851, 15));
p.guild = 0;
p.sm("You killed the animated armour good job!");
giveDrop = 0;
break;
case 6204:
case 6208:
case 6219:
case 1619:
case 49:
case 6203:
case 6210:
case 6212:
case 6218:
World.getWorld().registerEvent(new Event(200) {
public void execute() {
p.godWarsKills[3]++;
p.getActionSender().sendString(""+p.godWarsKills[3]+"", 601, 9);
this.stop();
}
});
break;
default:
}
}
}
public void tick() {
if (combatDelay > 0) {
combatDelay--;
}
if(frozen > 0) {
frozen--;
}
if (NPCForceChat == 0) {
NPCForceChat = 80;
}
if (NPCForceChat > 1) {
NPCForceChat--;
}
if (getId() == 9724 && NPCForceChat == 1) {
forceChat("Click me for the vote shop");
NPCForceChat = 80;
}
if (getId() == 4946 && NPCForceChat == 2 && GameEngine.PitsWinner2 == true) {
forceChat("The present Fight Pits Champion is: ["+GameEngine.PitsWinner+"]");
NPCForceChat = 80;
}
if (getId() == 4946 && NPCForceChat == 2 && GameEngine.PitsWinner2 == false) {
forceChat("There is presently no Fight Pits Champion");
NPCForceChat = 80;
}
sprite = -1;
if (!this.isAttacking() && Math.random() > 0.8 && walkType == WalkType.RANGE) {
int moveX = (int) (Math.floor((Math.random() * 3)) - 1);
int moveY = (int) (Math.floor((Math.random() * 3)) - 1);
int tgtX = this.getLocation().getX() + moveX;
int tgtY = this.getLocation().getY() + moveY;
sprite = Misc.direction(this.getLocation().getX(), this.getLocation().getY(), tgtX, tgtY);
if (tgtX > this.maximumCoords.getX() || tgtX < this.minimumCoords.getX() || tgtY > this.maximumCoords.getY() || tgtY < this.minimumCoords.getY()) {
sprite = -1;
}
if (sprite != -1) {
sprite >>= 1;
setLocation(Location.location(tgtX, tgtY, this.getLocation().getZ()));
}
}
if(partner != null && !Attacking) {
for(NPC n : World.getWorld().getRegionManager().getLocalNpcs(getLocation())) {
if(n.pid == partner.getIndex()) {
npcOpp = n.getIndex();
Attacking = true;
}
}
}
if(partner != null && Attacking && npcOpp > -1) {
NPC n = World.getWorld().getNpcs().get(npcOpp);
if(n != null && !n.isDead() && !n.isDestroyed()) {
followPlayer(n, 0);
if(combatDelay == 0) {
animate(451);
n.hit(Misc.random(30));
n.animate(n.getDefinition().getDefenceAnimation());
combatDelay = 5;
return;
}
} else {
resetAttack();
}
}
if (Attacking == true) {
final Player p = World.getWorld().getPlayers().get(pid);
if (p == null) {
this.resetAttack();
return;
}
GameEngine.nvp.Attack(p, this);
} else {
Agressive();
}
}
public int getId() {
return id;
}
public void setId(int npcid) {
this.npcswitch(npcid);
this.id = npcid;
this.definition = NPCDefinition.forId(npcid);
}
public int getSprite() {
return sprite;
}
public NPCDefinition getDefinition() {
return definition;
}
public Object readResolve() {
super.readResolve();
npcOpp = -1;
followIsDelayed = false;
NpcWalk = new NpcWalk(this);
definition = NPCDefinition.forId(id);
updateFlags = new NPCUpdateFlags();
sprite = -1;
hp = definition.getHitpoints();
this.queuedHits = new LinkedList<Hit>();
this.originalLocation = this.getLocation();
forceText = null;
return this;
}
public NpcWalk getNpcWalk() {
return NpcWalk;
}
public void processQueuedHits() {
if(!updateFlags.isHit1UpdateRequired()) {
if(queuedHits.size() > 0) {
Hit h = queuedHits.poll();
hit(h.getDamage(), h.getType(), h.getIcon());
}
}
if(!updateFlags.isHit2UpdateRequired()) {
if(queuedHits.size() > 0) {
Hit h = queuedHits.poll();
hit(h.getDamage(), h.getType(), h.getIcon());
}
}
}
public NPCUpdateFlags getUpdateFlags() {
return updateFlags;
}
public void setForceText(ForceText forceText) {
this.forceText = forceText;
updateFlags.setForceTextUpdateRequired(true);
}
public ForceText getForceText() {
return forceText;
}
public void forceChat(String message) {
setForceText(new ForceText(message));
}
/**
* @param minimumCoords the minimumCoords to set
*/
public void setMinimumCoords(Location minimumCoords) {
this.minimumCoords = minimumCoords;
}
/**
* @return the minimumCoords
*/
public Location getMinimumCoords() {
return minimumCoords;
}
/**
* @param walkType the walkType to set
*/
public void setWalkType(WalkType walkType) {
this.walkType = walkType;
}
/**
* @return the walkType
*/
public WalkType getWalkType() {
return walkType;
}
/**
* @param maximumCoords the maximumCoords to set
*/
public void setMaximumCoords(Location maximumCoords) {
this.maximumCoords = maximumCoords;
}
/**
* @return the maximumCoords
*/
public Location getMaximumCoords() {
return maximumCoords;
}
public void heal(int amount) {
this.hp += amount;
if(hp >= this.getDefinition().getHitpoints()) {
hp = this.getDefinition().getHitpoints();
}
}
//@Override
public void hit(int i, HitType type) {
}
@Override
public void hit(int damage) {
final Player p = World.getWorld().getPlayers().get(pid);
if (damage > 32767) {
damage = 32767;
}
if (damage > hp) {
damage = hp;
}
this.pid = p.getIndex();
if (damage == 0) {
hit(damage, Hits.HitType.NO_DAMAGE, Hits.IconType.NO_HIT);
} else if (PkDefinitions.usingRange(p)) {
if (damage >= 29)
hit(damage, Hits.HitType.CRITICAL_DAMAGE, Hits.IconType.RANGE);
else
hit(damage, Hits.HitType.NORMAL_DAMAGE, Hits.IconType.RANGE);
} else {
if (damage >= 29)
hit(damage, Hits.HitType.CRITICAL_DAMAGE, Hits.IconType.MELEE);
else
hit(damage, Hits.HitType.NORMAL_DAMAGE, Hits.IconType.MELEE);
}
//TODO Check if Critical Damage makes ppl logout in combat
if (hp <= 0) {
hp = 0;
this.resetAttack();
if (!this.isDead()) {
World.getWorld().registerEvent(new DeathEvent(this));
}
this.setDead(true);
}
}
public void mageHit(int damage) {
if (damage > 32767) {
damage = 32767;
}
if (damage > hp) {
damage = hp;
}
if (damage == 0) {
hit(damage, Hits.HitType.NO_DAMAGE, Hits.IconType.NO_HIT);
} else {
if (damage >= 29)
hit(damage, Hits.HitType.CRITICAL_DAMAGE, Hits.IconType.MAGE);
else
hit(damage, Hits.HitType.NORMAL_DAMAGE, Hits.IconType.MAGE);
}
if (hp <= 0) {
hp = 0;
this.resetAttack();
if (!this.isDead()) {
World.getWorld().registerEvent(new DeathEvent(this));
}
this.setDead(true);
}
}
public void mageHit2(int damage) {
if (damage > 32767) {
damage = 32767;
}
if (damage > hp) {
damage = hp;
}
if (damage == 0) {
hit(damage, Hits.HitType.NO_DAMAGE, Hits.IconType.NO_HIT);
} else {
if (damage >= 29)
hit(damage, Hits.HitType.CRITICAL_DAMAGE, Hits.IconType.MAGE);
else
hit(damage, Hits.HitType.NORMAL_DAMAGE, Hits.IconType.MAGE);
}
if (hp <= 0) {
hp = 0;
this.resetAttack();
if (!this.isDead()) {
World.getWorld().registerEvent(new DeathEvent(this));
}
this.setDead(true);
}
}
public void deflectHit(int damage) {
if (damage > 32767) {
damage = 32767;
}
if (damage > hp) {
damage = hp;
}
if (damage == 0) {
hit(damage, Hits.HitType.NO_DAMAGE, Hits.IconType.NO_HIT);
} else {
hit(damage, Hits.HitType.NORMAL_DAMAGE, Hits.IconType.DEFLECT);
}
if (hp <= 0) {
hp = 0;
this.resetAttack();
if (!this.isDead()) {
World.getWorld().registerEvent(new DeathEvent(this));
}
this.setDead(true);
}
}
public void hit(int damage, Hits.HitType type, Hits.IconType icon) {
if (damage > 32767) {
damage = 32767;
}
if (damage > hp) {
damage = hp;
}
if (!updateFlags.isHit1UpdateRequired()) {
getHits().setHit1(new Hit(damage, type, icon));
updateFlags.setHit1UpdateRequired(true);
} else {
if (!updateFlags.isHit2UpdateRequired()) {
getHits().setHit2(new Hit(damage, type, icon));
updateFlags.setHit2UpdateRequired(true);
} else {
queuedHits.add(new Hit(damage, type, icon));
}
if (hp <= 0) {
hp = 0;
this.resetAttack();
if (!this.isDead()) {
World.getWorld().registerEvent(new DeathEvent(this));
}
this.setDead(true);
}
}
hp -= damage;
if (hp <= 0) {
hp = 0;
this.resetAttack();
if (!this.isDead()) {
World.getWorld().registerEvent(new DeathEvent(this));
}
this.setDead(true);
}
}
@Override
public void turnTo(Entity entity) {
this.getUpdateFlags().setFaceToUpdateRequired(true, entity.getClientIndex());
}
public void delete(Entity entity) {
entity.setHidden(true);
}
@Override
public void turnTemporarilyTo(Entity entity) {
this.getUpdateFlags().setFaceToUpdateRequired(true, entity.getClientIndex());
this.getUpdateFlags().setClearFaceTo(true);
}
@Override
public void resetTurnTo() {
this.getUpdateFlags().setFaceToUpdateRequired(true, 0);
}
public void graphics(int id) {
graphics(id, 0);
}
public void graphics(int id, int delay) {
this.setLastGraphics(new Graphics(id, delay));
updateFlags.setGraphicsUpdateRequired(true);
}
public void npcswitch(int id) {
this.setLastNpcSwitch(new NpcSwitch(id));
updateFlags.setNpcSwitchUpdateRequired(true);
}
public void animate(int id) {
animate(id, 0);
}
public void resetAttack() {
npcOpp = -1;
this.Attacking = false;
this.pid = 0;
}
public void animate(int id, int delay) {
this.setLastAnimation(new Animation(id, delay));
updateFlags.setAnimationUpdateRequired(true);
}
public int getHitpoints() {
return hp;
}
public int getAttackAnimation() {
return this.getDefinition().getAttackAnimation();
}
public int getAttackSpeed() {
return this.getDefinition().getAttackSpeed();
}
public int getDefenceAnimation() {
return this.getDefinition().getDefenceAnimation();
}
public boolean isAnimating() {
return this.getUpdateFlags().isAnimationUpdateRequired();
}
public int getDeathAnimation() {
return this.getDefinition().getDeathAnimation();
}
public Location getOriginalLocation() {
return this.originalLocation;
}
public int getHp() {
return this.definition.getHitpoints();
}
public int getMaxHp() {
return this.definition.getHitpoints();
}
public void setHp(int val) {
hp = val;
}
@Override
public void dropLoot(Player winner) {
}
@Override
public void dropLoot2(Player winner) {
}
public boolean isAutoRetaliating() {
return this.definition.getHitpoints() > 0;
}
@Override
public CombatType getCombatType() {
return CombatType.MELEE;
}
@Override
public int getMaxHit() {
return this.getDefinition().getMaxHit();
}
public int getDrawBackGraphics() {
return 18; // TODO atm bronze arrow
}
public int getProjectileId() {
return 10;
}
public boolean hasAmmo() {
return true;
}
public void setIsFamiliar(boolean isFamiliar) {
IsFamiliar = isFamiliar;
}
public boolean isIsFamiliar() {
return IsFamiliar;
}
public void hit(Player p, int damage) {
if(p == null) {
return;
}
if(damage > 0) {
Clan clan = World.getWorld().getClanManager().getClans(p.getSettings().getClanOwner());
if(clan == null) {
addKillerHit(p, damage);
} else {
if(clan.isLootsharing()) {
addKillerHit(p, damage);
for(Player pl : clan.getMembers()) {
if(pl.getIndex() != p.getIndex()) {
addKillerHit(pl, damage - getDecrements(clan));
}
}
}
}
}
hit(damage);
}
public void deflectHit(Player p, int damage) {
if (p == null) {
return;
}
if (damage > 0) {
Clan clan = World.getWorld().getClanManager().getClans(p.getSettings().getClanOwner());
if (clan == null) {
addKillerHit(p, damage);
} else {
if (clan.isLootsharing()) {
addKillerHit(p, damage);
for (Player pl : clan.getMembers()) {
if (pl.getIndex() != p.getIndex()) {
addKillerHit(pl, damage - getDecrements(clan));
}
}
}
}
}
deflectHit(damage);
}
public void mageHit(Player p, int damage) {
if (p == null) {
return;
}
if (damage > 0) {
Clan clan = World.getWorld().getClanManager().getClans(p.getSettings().getClanOwner());
if (clan == null) {
addKillerHit(p, damage);
} else {
if (clan.isLootsharing()) {
addKillerHit(p, damage);
for (Player pl : clan.getMembers()) {
if (pl.getIndex() != p.getIndex()) {
addKillerHit(pl, damage - getDecrements(clan));
}
}
}
}
}
mageHit(damage);
}
public void mageHit2(Player p, int damage) {
if (p == null) {
return;
}
if (damage > 0) {
Clan clan = World.getWorld().getClanManager().getClans(p.getSettings().getClanOwner());
if (clan == null) {
addKillerHit(p, damage);
} else {
if (clan.isLootsharing()) {
addKillerHit(p, damage);
for (Player pl : clan.getMembers()) {
if (pl.getIndex() != p.getIndex()) {
addKillerHit(pl, damage - getDecrements(clan));
}
}
}
}
}
mageHit2(damage);
}
public int getDecrements(Clan clan) {
int size = clan.getMembers().size();
if(size >= 1 && size <= 20) return 5;
if(size >= 20 && size <= 50) return 10;
if(size >= 50 && size <= 80) return 15;
if(size >= 80 && size <= 100) return 20;
if(size >= 100 && size <= 140) return 25;
if(size >= 140 && size <= 180) return 30;
return 5;
}
}