Thread: [RS2HD] 562/659 Disconnect in combat bug

Results 1 to 9 of 9
  1. #1 [RS2HD] 562/659 Disconnect in combat bug 
    Registered Member
    Join Date
    Nov 2012
    Age
    27
    Posts
    30
    Thanks given
    2
    Thanks received
    0
    Rep Power
    11
    Hey guys,

    Those who played 562 revision will probably know what I am talking about. When you wear OP items like perfect ring, if you hit too high your client crash and close.

    Would anyone know what it could be? Or has anyone seen a fix somewhere?

    I've been working with these revisions for years without finding anything.. :/

    Thanks!
    Alex
    Currently working on my 562/659 Server project! Server will probably be online soon
    Reply With Quote  
     

  2. #2  
    Contributor

    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,788
    Thanks given
    706
    Thanks received
    702
    Rep Power
    570
    Quote Originally Posted by Addict View Post
    Hey guys,

    Those who played 562 revision will probably know what I am talking about. When you wear OP items like perfect ring, if you hit too high your client crash and close.

    Would anyone know what it could be? Or has anyone seen a fix somewhere?

    I've been working with these revisions for years without finding anything.. :/

    Thanks!
    Alex
    Make it so it only adds hits that are 32767- to the list of hits in your Entity.java or w/e it is called on 562. If it's higher (35000 for example), you should put it down to 32767.
    Project thread
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Registered Member
    Join Date
    Nov 2012
    Age
    27
    Posts
    30
    Thanks given
    2
    Thanks received
    0
    Rep Power
    11
    Quote Originally Posted by clem585 View Post
    Make it so it only adds hits that are 32767- to the list of hits in your Entity.java or w/e it is called on 562. If it's higher (35000 for example), you should put it down to 32767.
    Code:
    package com.rs2hd.model;
    
    import java.util.*;
    
    import com.rs2hd.content.DeathEvent;
    import com.rs2hd.content.Combat.CombatType;
    /**
     * An 'entity' in the game world.
     * @author Graham
     *
     */
    public abstract class Entity {
    
    	public static final Location DEFAULT_LOCATION = Location.location(2856, 2960, 0);
    	private Location location;
    	public static final Location CLAN_DEATH = Location.location(2856, 2960, 0);
    	public static final Location SOUL_DEATH = Location.location(2993, 3295, 0);
    	private transient int index;
    	private transient Location teleportTo;
    	private transient Hits hits;
    	private transient Sprite sprite;
    	private transient Animation lastAnimation;
    	private transient Graphics lastGraphics;
    	private transient NpcSwitch lastNpcSwitch;
    	private transient Entity interactingWith;
    	private transient boolean attacking;
    	private transient int combatTurns;
    	private transient boolean dead;
    	private Hashtable<String, Integer> enemyHits;
    	public Map<Player, Integer> killerHits;
    	private transient boolean hidden;
    	private transient boolean isAggressor;
    	public int attackStyle;
    	/**
    	 * The current region.
    	 */
    	public transient int currentRegion;
    	private transient boolean destroyed;
    	public abstract boolean isAutoRetaliating();
    	
    	public Entity() {
    		setLocation(DEFAULT_LOCATION);
    	}
    
    	public Object readResolve() {
    		hits = new Hits();
    		lastAnimation = null;
    		lastGraphics = null;
    		lastNpcSwitch = null;
    		teleportTo = null;
    		interactingWith = null;
    		attacking = false;
    		combatTurns = 0;
    		sprite = new Sprite();
    		dead = false;
    		hidden = false;
    		isAggressor = false;
    		destroyed = false;
    		enemyHits = new Hashtable<String, Integer>();
    		killerHits = new HashMap<Player, Integer>();
    		setLocation(getLocation());
    		return this;
    	}
    
    	public Player getPlayerToLoot() {
    		return findBest();
    	}
    
    	public Player findBest() {
    		if(killerHits.size() == 0) {
    			return null;
    		}
    		int bestHit = 0;
    		Player bestPlayer = null;
    		for(Map.Entry<Player, Integer> entry : killerHits.entrySet()) {
    			if (entry.getValue() > bestHit) {
    				bestHit = entry.getValue();
    				bestPlayer = entry.getKey();
    			}
    		}
    		return bestPlayer;
    	}
    
    	public void addKillerHit(Player killer, int hit) {
    		if(hit > 0) {
    			if(killer != null) {
    				if(!killerHits.containsKey(killer)) {
    					killerHits.put(killer, hit);
    				} else {
    					killerHits.put(killer, killerHits.get(killer)+hit);
    				}
    			}
    		}
    	}
    
    	public Player getKiller() {
    		return findBest();
    	}
    
    	public void clearKillersHits() {
    		killerHits.clear();
    	}	
    
    	public boolean isAggressor() {
    		return isAggressor;
    	}
    
    	public void setAggressor(boolean b) {
    		isAggressor = b;
    	}
    
    	public Sprite getSprites() {
    		return sprite;
    	}
    	public Hits getHits() {
    		return hits;
    	}
    
    	public void teleport(Location location) {
    		if(this instanceof Player) {
    			Player p = (Player) this;
    			p.getUpdateFlags().setDidTeleport(true);
    			this.teleportTo = location;
    		}
    		if(this instanceof NPC) {
    			NPC n = (NPC) this;
    			setLocation(location);
    			n.getUpdateFlags().setDidTeleport(true);
    		}
    	}
    
    	public void resetTeleportTo() {
    		this.teleportTo = null;
    	}
    
    	public Location getTeleportTo() {
    		return this.teleportTo;
    	}
    
    	public void setLocation(Location location) {
    		this.location = location;
    		int newRegion = (location.getX() / 32) + (location.getY() / 32);
    		if(newRegion != currentRegion) {
    			removeFromRegion(currentRegion);
    			currentRegion = newRegion;
    			addToRegion(currentRegion);
    		}
    	}
    
    	/**
    	 * Adds the entity to the region.
    	 * @param region The region.
    	 */
    	private void addToRegion(int region) {
    		if(this instanceof Player) {
    			World.getWorld().getRegionManager().getRegion(region).addPlayer((Player) this);
    		} else {
    			World.getWorld().getRegionManager().getRegion(region).addNPC((NPC) this);
    		}
    	}
    
    	/**
    	 * Removes the entity from the region.
    	 * @param region The region.
    	 */
    	private void removeFromRegion(int region) {
    		if(this instanceof Player) {
    			World.getWorld().getRegionManager().getRegion(region).removePlayer((Player) this);
    		} else {
    			World.getWorld().getRegionManager().getRegion(region).removeNPC((NPC) this);
    		}
    	}
    
    	public Location getLocation() {
    		return this.location;
    	}
    
    	public void setIndex(int index) {
    		this.index = index;
    	}
    
    	public int getIndex() {
    		return index;
    	}
    
    	public boolean SafeZone() {
    		if ((getLocation().getX() >= 3264 && getLocation().getX() <= 3279 && getLocation().getY() >= 3672 && getLocation().getY() <= 3695) || (getLocation().getX() >= 3182 && getLocation().getX() <= 3195 && getLocation().getY() >= 3680 && getLocation().getY() <= 3800) || (getLocation().getX() >= 3140 && getLocation().getX() <= 3181 && getLocation().getY() >= 3656 && getLocation().getY() <= 3678) || (getLocation().getX() >= 3158 && getLocation().getX() <= 3181 && getLocation().getY() >= 3679 && getLocation().getY() <= 3697) || (getLocation().getX() >= 3082 && getLocation().getX() <= 3128 && getLocation().getY() >= 3911 && getLocation().getY() <= 3954) || (getLocation().getX() >= 3158 && getLocation().getX() <= 3181 && getLocation().getY() >= 3679 && getLocation().getY() <= 3697) || (getLocation().getX() >= 3284 && getLocation().getX() <= 3293 && getLocation().getY() >= 3879 && getLocation().getY() <= 3891))
    			return true;
    		else if ((getLocation().getX() >= 2940 && getLocation().getX() <= 3395 && getLocation().getY() >= 3524 && getLocation().getY() <= 4000) || (getLocation().getX() >= 3264 && getLocation().getX() <= 3279 && getLocation().getY() >= 3279 && getLocation().getY() <= 3672) || (getLocation().getX() >= 2756 && getLocation().getX() <= 2875 && getLocation().getY() >= 5512 && getLocation().getY() <= 5627) || (getLocation().getX() >= 3158 && getLocation().getX() <= 3181 && getLocation().getY() >= 3679 && getLocation().getY() <= 3697) || (getLocation().getX() >= 3280 && getLocation().getX() <= 3183 && getLocation().getY() >= 3883 && getLocation().getY() <= 3888))
    			return false;
    		else if ((getLocation().getX() >= 3190 && getLocation().getX() <= 3140 && getLocation().getY() >= 3679 && getLocation().getY() <= 3656) || (getLocation().getX() >= 3322 && getLocation().getX() <= 3318 && getLocation().getY() >= 3783 && getLocation().getY() <= 3776) || (getLocation().getX() >= 3284 && getLocation().getX() <= 3292 && getLocation().getY() >= 3879 && getLocation().getY() <= 3891));
    		return true;
    	}
    
    	public boolean multiZone() {
    		if(this instanceof Player) {
    			if(((Player) this).inFightPits) {
    				return true;
    			}
    		}
    		if(location.getClanLevel() >= 6) {
    			return true;
    		}
    		//		if ((getLocation().getX() >= 2756 && getLocation().getX() <= 2875 && getLocation().getY() >= 5512 && getLocation().getY() <= 5627) || (getLocation().getX() >= 3264 && getLocation().getX() <= 3279 && getLocation().getY() >= 3279 && getLocation().getY() <= 3672) || (getLocation().getX() >= 3266 && getLocation().getX() <= 3317 && getLocation().getY() >= 3769 && getLocation().getY() <= 3789))
    		//			return true;
    		//		else if ((getLocation().getX() >= 2381 && getLocation().getX() <= 2413 && getLocation().getY() >= 5131 && getLocation().getY() <= 5166))
    		//			return true;
    		return false;
    	}
    
    	public boolean inCastleWars(){
    		if(getLocation().getX() >= 2377 && getLocation().getX() <= 2420 && getLocation().getY() >= 3080 && getLocation().getY() <=3129)
    			return true;
    		else
    			return false;
    	}
    
    	public boolean inClanWars() {
    		return getLocation().getX() >= 2756 && getLocation().getX() <= 2875 && getLocation().getY() >= 5512 && getLocation().getY() <= 5627;
    	}
    
    	public boolean inFightPits() {
    		if ((getLocation().getX() >= 2381 && getLocation().getX() <= 2413 && getLocation().getY() >= 5131 && getLocation().getY() <= 5166))
    			return true;
    		return false;
    	}
    	public boolean inSWGame() {
    		if(getLocation().getX() >= 1790 && getLocation().getY() >= 3200 && getLocation().getX() <= 1985 && getLocation().getY() <= 3265) {
    			return true;
    		} else {
    			return false;
    		}
    	}
    	public boolean swGameArea(){
    		if(swLobbys())
    			return false;
    		else
    			return false;
    	}
    	public boolean pcLobby(){
    		if(getLocation().getX() >= 2660 && getLocation().getY() >= 2638 && getLocation().getX() <= 2663 && getLocation().getY() <= 2643)
    			return true;
    		else
    			return false;
    	}
    	public boolean pcGame(){
    		if(getLocation().getX() >= 2625 && getLocation().getY() >= 2560 && getLocation().getX() <= 2685 && getLocation().getY() <= 2613)
    			return true;
    		else
    			return false;
    	}	
    	public boolean swLobbys(){
    		if(getLocation().getX() >= 1900 && getLocation().getY() >= 3157 && getLocation().getX() <= 1909 && getLocation().getY() <= 3166 || getLocation().getX() >= 1870 && getLocation().getY() >= 3158 && getLocation().getX() <= 1879 && getLocation().getY() <= 3166)
    			return true;
    		else
    			return false;
    	}
    	public boolean noTargZone(){
    		if(getLocation().getX() >= 1790 && getLocation().getY() >= 3200 && getLocation().getX() <= 1985 && getLocation().getY() <= 3265)
    			return true;
    		else
    			return false;
    	}
    	public int getClientIndex() {
    		if(this instanceof Player) {
    			return this.index + 32768;
    		} else {
    			return this.index;
    		}
    	}
    
    	public abstract void heal(int amount);
    	public abstract void hit(int damage);
    	public abstract void hit(int damage, Hits.HitType type, Hits.IconType icon);
    	public abstract void turnTo(Entity entity);
    	public abstract void turnTemporarilyTo(Entity entity);
    	public abstract void resetTurnTo();
    	public abstract void npcswitch(int id);
    	public abstract void graphics(int id);
    	public abstract void graphics(int id, int delay);
    	public abstract void animate(int id);
    	public abstract void animate(int id, int delay);
    
    	public Animation getLastAnimation() {
    		return lastAnimation;
    	}
    
    	public void setLastAnimation(Animation lastAnimation) {
    		this.lastAnimation = lastAnimation;
    
    	}
    	public NpcSwitch getLastNpcSwitch() {
    		return lastNpcSwitch;
    	}
    
    	public void setLastNpcSwitch(NpcSwitch LastNpcSwitch) {
    		this.lastNpcSwitch = LastNpcSwitch;
    	}
    	public Graphics getLastGraphics() {
    		return lastGraphics;
    	}
    
    	public void setLastGraphics(Graphics lastGraphics) {
    		this.lastGraphics = lastGraphics;
    	}
    
    	public Entity getInteractingWith() {
    		return interactingWith;
    	}
    
    	public boolean isInteracting() {
    		return interactingWith != null;
    	}
    
    	public void setInteractingWith(Entity entity) {
    		this.interactingWith = entity;
    	}
    
    	public boolean isAttacking() {
    		return this.attacking;
    	}
    
    	public void setAttacking(boolean b) {
    		if(!b) {
    			interactingWith = null;
    			this.resetTurnTo();
    			this.setAggressor(false);
    		}
    		this.attacking = b;
    	}
    
    	public int getCombatTurns() {
    		return combatTurns;
    	}
    
    	public void resetCombatTurns() {
    		combatTurns = 0;
    	}
    
    	public void incrementCombatTurns() {
    		combatTurns++;
    	}
    
    	/**
    	 * Destroys the entity.
    	 */
    	public void destroy() {
    		if(this instanceof Player) {
    			Player player = (Player) this;
    			player.isOnline = false;
    			if(!player.canLogout()) {
    				dropLoot(getKiller());
    				setLocation(DEFAULT_LOCATION);
    				setDead(false);
    				setHp(getMaxHp());
    				DeathEvent.resetVars(player);
    			}
    			clearKillersHits();
    		}
    		destroyed = true;
    		removeFromRegion(currentRegion);
    	}
    
    	public abstract int getAttackAnimation();
    	public abstract int getAttackSpeed();
    	public abstract int getDefenceAnimation();
    	public abstract boolean isAnimating();
    	public abstract int getDeathAnimation();
    
    	public boolean isDestroyed() {
    		if(this instanceof Player) {
    			Player player = (Player) this;
    			if(!player.isOnline) {
    				return true;
    			}
    		}
    		return destroyed;
    	}
    
    	public void setCombatTurns(int i) {
    		combatTurns = i;
    	}
    
    	public void setDead(boolean b) {
    		dead = b;
    	}
    
    	public boolean isDead() {
    		return dead;
    	}
    
    	public void setHidden(boolean b) {
    		hidden = b;
    	}
    
    	public boolean isHidden() {
    		return hidden;
    	}
    
    	public abstract int getMaxHp();
    	public abstract int getHp();
    	public abstract void setHp(int val);
    
    	public abstract void dropLoot(Player winner);
    	public abstract void dropLoot2(Player winner);
    
    	public void setAttackStyle(int i) {
    		this.attackStyle = i;
    	}
    
    	public int getAttackStyle() {
    		return attackStyle;
    	}
    	
    	public abstract int getMaxHit();
    	public abstract CombatType getCombatType();
    	public abstract int getDrawBackGraphics();
    	public abstract int getProjectileId();
    	public abstract boolean hasAmmo();
    
    }
    Do you see anything related to what you're saying? This is my Entity.java

    Thanks for your answer!
    Currently working on my 562/659 Server project! Server will probably be online soon
    Reply With Quote  
     

  5. #4  
    Contributor

    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,788
    Thanks given
    706
    Thanks received
    702
    Rep Power
    570
    Quote Originally Posted by Addict View Post
    Code:
    package com.rs2hd.model;
    
    import java.util.*;
    
    import com.rs2hd.content.DeathEvent;
    import com.rs2hd.content.Combat.CombatType;
    /**
     * An 'entity' in the game world.
     * @author Graham
     *
     */
    public abstract class Entity {
    
    	public static final Location DEFAULT_LOCATION = Location.location(2856, 2960, 0);
    	private Location location;
    	public static final Location CLAN_DEATH = Location.location(2856, 2960, 0);
    	public static final Location SOUL_DEATH = Location.location(2993, 3295, 0);
    	private transient int index;
    	private transient Location teleportTo;
    	private transient Hits hits;
    	private transient Sprite sprite;
    	private transient Animation lastAnimation;
    	private transient Graphics lastGraphics;
    	private transient NpcSwitch lastNpcSwitch;
    	private transient Entity interactingWith;
    	private transient boolean attacking;
    	private transient int combatTurns;
    	private transient boolean dead;
    	private Hashtable<String, Integer> enemyHits;
    	public Map<Player, Integer> killerHits;
    	private transient boolean hidden;
    	private transient boolean isAggressor;
    	public int attackStyle;
    	/**
    	 * The current region.
    	 */
    	public transient int currentRegion;
    	private transient boolean destroyed;
    	public abstract boolean isAutoRetaliating();
    	
    	public Entity() {
    		setLocation(DEFAULT_LOCATION);
    	}
    
    	public Object readResolve() {
    		hits = new Hits();
    		lastAnimation = null;
    		lastGraphics = null;
    		lastNpcSwitch = null;
    		teleportTo = null;
    		interactingWith = null;
    		attacking = false;
    		combatTurns = 0;
    		sprite = new Sprite();
    		dead = false;
    		hidden = false;
    		isAggressor = false;
    		destroyed = false;
    		enemyHits = new Hashtable<String, Integer>();
    		killerHits = new HashMap<Player, Integer>();
    		setLocation(getLocation());
    		return this;
    	}
    
    	public Player getPlayerToLoot() {
    		return findBest();
    	}
    
    	public Player findBest() {
    		if(killerHits.size() == 0) {
    			return null;
    		}
    		int bestHit = 0;
    		Player bestPlayer = null;
    		for(Map.Entry<Player, Integer> entry : killerHits.entrySet()) {
    			if (entry.getValue() > bestHit) {
    				bestHit = entry.getValue();
    				bestPlayer = entry.getKey();
    			}
    		}
    		return bestPlayer;
    	}
    
    	public void addKillerHit(Player killer, int hit) {
    		if(hit > 0) {
    			if(killer != null) {
    				if(!killerHits.containsKey(killer)) {
    					killerHits.put(killer, hit);
    				} else {
    					killerHits.put(killer, killerHits.get(killer)+hit);
    				}
    			}
    		}
    	}
    
    	public Player getKiller() {
    		return findBest();
    	}
    
    	public void clearKillersHits() {
    		killerHits.clear();
    	}	
    
    	public boolean isAggressor() {
    		return isAggressor;
    	}
    
    	public void setAggressor(boolean b) {
    		isAggressor = b;
    	}
    
    	public Sprite getSprites() {
    		return sprite;
    	}
    	public Hits getHits() {
    		return hits;
    	}
    
    	public void teleport(Location location) {
    		if(this instanceof Player) {
    			Player p = (Player) this;
    			p.getUpdateFlags().setDidTeleport(true);
    			this.teleportTo = location;
    		}
    		if(this instanceof NPC) {
    			NPC n = (NPC) this;
    			setLocation(location);
    			n.getUpdateFlags().setDidTeleport(true);
    		}
    	}
    
    	public void resetTeleportTo() {
    		this.teleportTo = null;
    	}
    
    	public Location getTeleportTo() {
    		return this.teleportTo;
    	}
    
    	public void setLocation(Location location) {
    		this.location = location;
    		int newRegion = (location.getX() / 32) + (location.getY() / 32);
    		if(newRegion != currentRegion) {
    			removeFromRegion(currentRegion);
    			currentRegion = newRegion;
    			addToRegion(currentRegion);
    		}
    	}
    
    	/**
    	 * Adds the entity to the region.
    	 * @param region The region.
    	 */
    	private void addToRegion(int region) {
    		if(this instanceof Player) {
    			World.getWorld().getRegionManager().getRegion(region).addPlayer((Player) this);
    		} else {
    			World.getWorld().getRegionManager().getRegion(region).addNPC((NPC) this);
    		}
    	}
    
    	/**
    	 * Removes the entity from the region.
    	 * @param region The region.
    	 */
    	private void removeFromRegion(int region) {
    		if(this instanceof Player) {
    			World.getWorld().getRegionManager().getRegion(region).removePlayer((Player) this);
    		} else {
    			World.getWorld().getRegionManager().getRegion(region).removeNPC((NPC) this);
    		}
    	}
    
    	public Location getLocation() {
    		return this.location;
    	}
    
    	public void setIndex(int index) {
    		this.index = index;
    	}
    
    	public int getIndex() {
    		return index;
    	}
    
    	public boolean SafeZone() {
    		if ((getLocation().getX() >= 3264 && getLocation().getX() <= 3279 && getLocation().getY() >= 3672 && getLocation().getY() <= 3695) || (getLocation().getX() >= 3182 && getLocation().getX() <= 3195 && getLocation().getY() >= 3680 && getLocation().getY() <= 3800) || (getLocation().getX() >= 3140 && getLocation().getX() <= 3181 && getLocation().getY() >= 3656 && getLocation().getY() <= 3678) || (getLocation().getX() >= 3158 && getLocation().getX() <= 3181 && getLocation().getY() >= 3679 && getLocation().getY() <= 3697) || (getLocation().getX() >= 3082 && getLocation().getX() <= 3128 && getLocation().getY() >= 3911 && getLocation().getY() <= 3954) || (getLocation().getX() >= 3158 && getLocation().getX() <= 3181 && getLocation().getY() >= 3679 && getLocation().getY() <= 3697) || (getLocation().getX() >= 3284 && getLocation().getX() <= 3293 && getLocation().getY() >= 3879 && getLocation().getY() <= 3891))
    			return true;
    		else if ((getLocation().getX() >= 2940 && getLocation().getX() <= 3395 && getLocation().getY() >= 3524 && getLocation().getY() <= 4000) || (getLocation().getX() >= 3264 && getLocation().getX() <= 3279 && getLocation().getY() >= 3279 && getLocation().getY() <= 3672) || (getLocation().getX() >= 2756 && getLocation().getX() <= 2875 && getLocation().getY() >= 5512 && getLocation().getY() <= 5627) || (getLocation().getX() >= 3158 && getLocation().getX() <= 3181 && getLocation().getY() >= 3679 && getLocation().getY() <= 3697) || (getLocation().getX() >= 3280 && getLocation().getX() <= 3183 && getLocation().getY() >= 3883 && getLocation().getY() <= 3888))
    			return false;
    		else if ((getLocation().getX() >= 3190 && getLocation().getX() <= 3140 && getLocation().getY() >= 3679 && getLocation().getY() <= 3656) || (getLocation().getX() >= 3322 && getLocation().getX() <= 3318 && getLocation().getY() >= 3783 && getLocation().getY() <= 3776) || (getLocation().getX() >= 3284 && getLocation().getX() <= 3292 && getLocation().getY() >= 3879 && getLocation().getY() <= 3891));
    		return true;
    	}
    
    	public boolean multiZone() {
    		if(this instanceof Player) {
    			if(((Player) this).inFightPits) {
    				return true;
    			}
    		}
    		if(location.getClanLevel() >= 6) {
    			return true;
    		}
    		//		if ((getLocation().getX() >= 2756 && getLocation().getX() <= 2875 && getLocation().getY() >= 5512 && getLocation().getY() <= 5627) || (getLocation().getX() >= 3264 && getLocation().getX() <= 3279 && getLocation().getY() >= 3279 && getLocation().getY() <= 3672) || (getLocation().getX() >= 3266 && getLocation().getX() <= 3317 && getLocation().getY() >= 3769 && getLocation().getY() <= 3789))
    		//			return true;
    		//		else if ((getLocation().getX() >= 2381 && getLocation().getX() <= 2413 && getLocation().getY() >= 5131 && getLocation().getY() <= 5166))
    		//			return true;
    		return false;
    	}
    
    	public boolean inCastleWars(){
    		if(getLocation().getX() >= 2377 && getLocation().getX() <= 2420 && getLocation().getY() >= 3080 && getLocation().getY() <=3129)
    			return true;
    		else
    			return false;
    	}
    
    	public boolean inClanWars() {
    		return getLocation().getX() >= 2756 && getLocation().getX() <= 2875 && getLocation().getY() >= 5512 && getLocation().getY() <= 5627;
    	}
    
    	public boolean inFightPits() {
    		if ((getLocation().getX() >= 2381 && getLocation().getX() <= 2413 && getLocation().getY() >= 5131 && getLocation().getY() <= 5166))
    			return true;
    		return false;
    	}
    	public boolean inSWGame() {
    		if(getLocation().getX() >= 1790 && getLocation().getY() >= 3200 && getLocation().getX() <= 1985 && getLocation().getY() <= 3265) {
    			return true;
    		} else {
    			return false;
    		}
    	}
    	public boolean swGameArea(){
    		if(swLobbys())
    			return false;
    		else
    			return false;
    	}
    	public boolean pcLobby(){
    		if(getLocation().getX() >= 2660 && getLocation().getY() >= 2638 && getLocation().getX() <= 2663 && getLocation().getY() <= 2643)
    			return true;
    		else
    			return false;
    	}
    	public boolean pcGame(){
    		if(getLocation().getX() >= 2625 && getLocation().getY() >= 2560 && getLocation().getX() <= 2685 && getLocation().getY() <= 2613)
    			return true;
    		else
    			return false;
    	}	
    	public boolean swLobbys(){
    		if(getLocation().getX() >= 1900 && getLocation().getY() >= 3157 && getLocation().getX() <= 1909 && getLocation().getY() <= 3166 || getLocation().getX() >= 1870 && getLocation().getY() >= 3158 && getLocation().getX() <= 1879 && getLocation().getY() <= 3166)
    			return true;
    		else
    			return false;
    	}
    	public boolean noTargZone(){
    		if(getLocation().getX() >= 1790 && getLocation().getY() >= 3200 && getLocation().getX() <= 1985 && getLocation().getY() <= 3265)
    			return true;
    		else
    			return false;
    	}
    	public int getClientIndex() {
    		if(this instanceof Player) {
    			return this.index + 32768;
    		} else {
    			return this.index;
    		}
    	}
    
    	public abstract void heal(int amount);
    	public abstract void hit(int damage);
    	public abstract void hit(int damage, Hits.HitType type, Hits.IconType icon);
    	public abstract void turnTo(Entity entity);
    	public abstract void turnTemporarilyTo(Entity entity);
    	public abstract void resetTurnTo();
    	public abstract void npcswitch(int id);
    	public abstract void graphics(int id);
    	public abstract void graphics(int id, int delay);
    	public abstract void animate(int id);
    	public abstract void animate(int id, int delay);
    
    	public Animation getLastAnimation() {
    		return lastAnimation;
    	}
    
    	public void setLastAnimation(Animation lastAnimation) {
    		this.lastAnimation = lastAnimation;
    
    	}
    	public NpcSwitch getLastNpcSwitch() {
    		return lastNpcSwitch;
    	}
    
    	public void setLastNpcSwitch(NpcSwitch LastNpcSwitch) {
    		this.lastNpcSwitch = LastNpcSwitch;
    	}
    	public Graphics getLastGraphics() {
    		return lastGraphics;
    	}
    
    	public void setLastGraphics(Graphics lastGraphics) {
    		this.lastGraphics = lastGraphics;
    	}
    
    	public Entity getInteractingWith() {
    		return interactingWith;
    	}
    
    	public boolean isInteracting() {
    		return interactingWith != null;
    	}
    
    	public void setInteractingWith(Entity entity) {
    		this.interactingWith = entity;
    	}
    
    	public boolean isAttacking() {
    		return this.attacking;
    	}
    
    	public void setAttacking(boolean b) {
    		if(!b) {
    			interactingWith = null;
    			this.resetTurnTo();
    			this.setAggressor(false);
    		}
    		this.attacking = b;
    	}
    
    	public int getCombatTurns() {
    		return combatTurns;
    	}
    
    	public void resetCombatTurns() {
    		combatTurns = 0;
    	}
    
    	public void incrementCombatTurns() {
    		combatTurns++;
    	}
    
    	/**
    	 * Destroys the entity.
    	 */
    	public void destroy() {
    		if(this instanceof Player) {
    			Player player = (Player) this;
    			player.isOnline = false;
    			if(!player.canLogout()) {
    				dropLoot(getKiller());
    				setLocation(DEFAULT_LOCATION);
    				setDead(false);
    				setHp(getMaxHp());
    				DeathEvent.resetVars(player);
    			}
    			clearKillersHits();
    		}
    		destroyed = true;
    		removeFromRegion(currentRegion);
    	}
    
    	public abstract int getAttackAnimation();
    	public abstract int getAttackSpeed();
    	public abstract int getDefenceAnimation();
    	public abstract boolean isAnimating();
    	public abstract int getDeathAnimation();
    
    	public boolean isDestroyed() {
    		if(this instanceof Player) {
    			Player player = (Player) this;
    			if(!player.isOnline) {
    				return true;
    			}
    		}
    		return destroyed;
    	}
    
    	public void setCombatTurns(int i) {
    		combatTurns = i;
    	}
    
    	public void setDead(boolean b) {
    		dead = b;
    	}
    
    	public boolean isDead() {
    		return dead;
    	}
    
    	public void setHidden(boolean b) {
    		hidden = b;
    	}
    
    	public boolean isHidden() {
    		return hidden;
    	}
    
    	public abstract int getMaxHp();
    	public abstract int getHp();
    	public abstract void setHp(int val);
    
    	public abstract void dropLoot(Player winner);
    	public abstract void dropLoot2(Player winner);
    
    	public void setAttackStyle(int i) {
    		this.attackStyle = i;
    	}
    
    	public int getAttackStyle() {
    		return attackStyle;
    	}
    	
    	public abstract int getMaxHit();
    	public abstract CombatType getCombatType();
    	public abstract int getDrawBackGraphics();
    	public abstract int getProjectileId();
    	public abstract boolean hasAmmo();
    
    }
    Do you see anything related to what you're saying? This is my Entity.java

    Thanks for your answer!
    Hm I'm assuming you hit too high when you attack NPC? If so post your "NPC.java" (the class used to manage npcs). If it's on players I can try something else.
    Project thread
    Reply With Quote  
     

  6. #5  
    Registered Member
    Join Date
    Nov 2012
    Age
    27
    Posts
    30
    Thanks given
    2
    Thanks received
    0
    Rep Power
    11
    Quote Originally Posted by clem585 View Post
    Hm I'm assuming you hit too high when you attack NPC? If so post your "NPC.java" (the class used to manage npcs). If it's on players I can try something else.
    I get DC when a boss or high npc attack a player, and I get DC when i'm attacking an NPC too high. Here is my NPC.java

    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;
    	}
    
    }
    Currently working on my 562/659 Server project! Server will probably be online soon
    Reply With Quote  
     

  7. #6  
    Contributor

    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,788
    Thanks given
    706
    Thanks received
    702
    Rep Power
    570
    Quote Originally Posted by Addict View Post
    I get DC when a boss or high npc attack a player, and I get DC when i'm attacking an NPC too high. Here is my NPC.java

    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;
    	}
    
    }
    Huh honestly I would probably have to look at the packet in the client because I don't really know what the issue is. You can try setting the max hit to 16384 instead of 32767 but I doubt it'll work. Are you sure you're sending the correct flag for npcs/players hits?
    Project thread
    Reply With Quote  
     

  8. #7  
    Registered Member
    Join Date
    Nov 2012
    Age
    27
    Posts
    30
    Thanks given
    2
    Thanks received
    0
    Rep Power
    11
    Quote Originally Posted by clem585 View Post
    Huh honestly I would probably have to look at the packet in the client because I don't really know what the issue is. You can try setting the max hit to 16384 instead of 32767 but I doubt it'll work. Are you sure you're sending the correct flag for npcs/players hits?
    I don't know about flags and stuff. I tried to add the whole combat system from another source since the one I had is shitty... but I guess I f*ck'd somewhere haha! I really love them 562's but I think it's time to move on to something newer... Thanks alot mate, you can hit me up on skype if you want @sk1llzd3m0n
    Currently working on my 562/659 Server project! Server will probably be online soon
    Reply With Quote  
     

  9. #8  
    Contributor

    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,788
    Thanks given
    706
    Thanks received
    702
    Rep Power
    570
    Quote Originally Posted by Addict View Post
    I don't know about flags and stuff. I tried to add the whole combat system from another source since the one I had is shitty... but I guess I f*ck'd somewhere haha! I really love them 562's but I think it's time to move on to something newer... Thanks alot mate, you can hit me up on skype if you want @sk1llzd3m0n
    Yea, you really shouldn't try to add something from X to X without understanding both of them correctly. Good luck in the future though!
    Project thread
    Reply With Quote  
     

  10. #9  
    Banned
    Join Date
    Mar 2016
    Posts
    8
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    Look into how the hit damage is dealt and just check the amount it deals..
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 10
    Last Post: 08-14-2016, 09:20 AM
  2. Disconnect in combat
    By The Watcher in forum Help
    Replies: 0
    Last Post: 03-11-2013, 03:56 AM
  3. Replies: 12
    Last Post: 06-22-2010, 10:41 PM
  4. [562] Help lol, In combat
    By Stability666 in forum Help
    Replies: 2
    Last Post: 01-30-2010, 03:53 PM
  5. [562] help with npc combat bug please...
    By darkness in forum Help
    Replies: 4
    Last Post: 11-07-2009, 06:32 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •