I'm working on a Vencillio based Project and can't figure out why poison doesn't work. For example weapons that should apply poison don't actually work. Any help would be appreciated.
Item weapon = player.getEquipment().getItems()[3];
Item ammo = player.getEquipment().getItems()[13];
CombatTypes type = player.getCombat().getCombatType();
if (type == CombatTypes.MELEE) {
if ((weapon == null) || (poison.get(Integer.valueOf(weapon.getId())) == null)) {
return;
}
attack.poison(poison.get(Integer.valueOf(weapon.ge tId())).getStart());
} else if (type == CombatTypes.RANGED) {
if ((ammo == null) || (poison.get(Integer.valueOf(ammo.getId())) == null)) {
return;
}
attack.poison(poison.get(Integer.valueOf(ammo.getI d())).getStart());
}
}
public static final void declare() {
for (int i = 0; i < 20145; i++) {
ItemDefinition def = GameDefinitionLoader.getItemDef(i);
if ((def != null) && (def.getName() != null)) {
String name = def.getName();
if (name.equalsIgnoreCase("toxic blowpipe")) {
poison.put(Integer.valueOf(i), new PoisonData(20));
}
if (name.contains(""))
poison.put(Integer.valueOf(i), new PoisonData(4));
else if (name.contains("(p+)"))
poison.put(Integer.valueOf(i), new PoisonData(5));
else if (name.contains("(p++)"))
poison.put(Integer.valueOf(i), new PoisonData(6));
}
}
}
}
Also heres the Process in PlayerCombatInterface.java
Spoiler for PlayerCombatInterface:
public void onCombatProcess(Entity entity) {
if (player.getSpecialAttack().isInitialized() && player.getCombat().getCombatType() != CombatTypes.MAGIC) {
SpecialAttackHandler.handleSpecialAttack(player);
if (player.getCombat().getCombatType() == CombatTypes.RANGED) {
player.getRanged().doActionsForDarkBow(entity);
}
} else if (player.getCombat().getCombatType() == CombatTypes.RANGED) {
//BoltSpecials.checkForBoltSpecial(player, entity);
BarrowsSpecials.checkForBarrowsSpecial(player);
player.getRanged().doActionsForDarkBow(entity);
} else {
if (player.getMagic().isDFireShieldEffect()) {
player.getMagic().decrDragonFireShieldCharges();
}
/**
* Represents a single combatable entity
*
* @author Michael Sasse
*
*/
public abstract class Entity implements CombatInterface {
/**
* The player index mod
*/
public static final int PLAYER_INDEX_MOD = 32768;
public static boolean inWilderness(int x, int y) {
return (x > 2941 && x < 3392 && y > 3521 && y < 3966) || (x > 2941 && x < 3392 && y > 9918 && y < 10366);
}
/**
* The index of the entity
*/
private short index = -1;
/**
* The size of the entity
*/
private byte size = 1;
/**
* The last damage dealt by the entity
*/
private byte lastDamageDealt = 0;
/**
* The entities max levels
*/
private short[] maxLevels = new short[Skills.SKILL_COUNT];
/**
* The entities current levels
*/
private short[] levels = new short[Skills.SKILL_COUNT];
/**
* The entities current bonuses
*/
private short[] bonuses = new short[13];
/**
* the last attacked entity
*/
private Entity lastAttacked;
private int consecutiveAttacks;
private double rangedWeaknessMod;
private double magicWeaknessMod;
private double meleeWeaknessMod;
/**
* A list of tasks
*/
private final LinkedList<Task> tasks = new LinkedList<Task>();
/**
* The entity is an npc
*/
private boolean npc = true;
/**
* The entity is active
*/
private boolean active = false;
/**
* The entity is dead
*/
private boolean dead = false;
/**
* The entity can take damage
*/
private boolean takeDamage = true;
/**
* The entity can retaliate
*/
private boolean retaliate = true;
/**
* The last hit success
*/
private boolean lastHitSuccess = false;
/**
* The entity is poisoned
*/
private boolean poisoned = false;
/**
* The current poison damage
*/
private int poisonDamage = 0;
/**
* The teleblock time
*/
private int teleblockTime;
/**
* The freeze delay
*/
private long freeze;
/**
* The spear delay
*/
private long stun;
/**
* The immunity from being frozen
*/
private long iceImmunity;
/**
* The immunity from being poisoned again
*/
private long poisonImmunity;
/**
* The immunity from being hit
*/
private long hitImmunity = 0L;
/**
* The immunity from fire
*/
private long fireImmunity = 0;
public static enum AttackType {
STAB,
SLASH,
CRUSH
}
private AttackType attackType = AttackType.CRUSH;
public AttackType getAttackType() {
return attackType;
}
public void setAttackType(AttackType attackType) {
this.attackType = attackType;
}
/**
* the location of the entity
*/
private final Location location = new Location(0, 0, 0);
/**
* Constructs an update flags instance
*/
private final UpdateFlags updateFlags = new UpdateFlags();
/**
* Constructs a new combat instance
*/
private final Combat combat = new Combat(this);
/**
* Constructs a new attributes instance
*/
private final Attributes attributes = new Attributes();
/**
* Adds a bonus to the bonuses
*
* @[Only registered and activated users can see links. ] id
* The bonus id
* @[Only registered and activated users can see links. ] add
* The amount to add to the bonus
*/
public void addBonus(int id, int add) {
int tmp5_4 = id;
short[] tmp5_1 = bonuses;
tmp5_1[tmp5_4] = ((short) (tmp5_1[tmp5_4] + add));
}
/**
* Gets if the entity can take damage
*
* @[Only registered and activated users can see links. ]
*/
public boolean canTakeDamage() {
return takeDamage;
}
/**
* Cures poison
*
* @[Only registered and activated users can see links. ] immunity
*/
public void curePoison(int immunity) {
poisoned = false;
poisonDamage = 0;
if (immunity > 0)
poisonImmunity = (World.getCycles() + immunity);
}
/**
* Performs a consecutive attack
*
* @[Only registered and activated users can see links. ] attacking
*/
public void doConsecutiveAttacks(Entity attacking) {
if (lastAttacked == null) {
consecutiveAttacks = 1;
lastAttacked = attacking;
return;
}
/**
* Provides fire immunity for a set amount of seconds
*
* @[Only registered and activated users can see links. ] delayInSeconds
* The delay of the immunity
*/
public void doFireImmunity(int delayInSeconds) {
fireImmunity = System.currentTimeMillis() + (delayInSeconds * 1000);
}
@Override
public boolean equals(Object other) {
if ((other instanceof Entity)) {
Entity e = (Entity) other;
return (e.getIndex() == index) && (e.isNpc() == npc);
}
return false;
}
/**
* Forces an entity to face a direction
*
* @[Only registered and activated users can see links. ] entity
*/
public void face(Entity entity) {
if (entity == null) {
return;
}
if (!entity.isNpc())
updateFlags.faceEntity(entity.getIndex() + 32768);
else
updateFlags.faceEntity(entity.getIndex());
}
/**
* Freezes an entity for a certain time
*
* @[Only registered and activated users can see links. ] time
* The time to freeze the entity
* @[Only registered and activated users can see links. ] immunity
* The time the entity is immune to being frozen again
*/
public void freeze(double time, int immunity) {
if ((isFrozen()) || (isImmuneToIce())) {
return;
}
/**
* Stuns an entity for a certain time
*
* @[Only registered and activated users can see links. ] time
* The time to stun the entity
*/
public void stun(double time) {
if (isStunned()) {
return;
}
stun = (long) (System.currentTimeMillis() + (time * 1000));
}
public boolean isStunned() {
return stun > System.currentTimeMillis();
}
/**
* Gets the entities attributes
*
* @[Only registered and activated users can see links. ]
*/
public Attributes getAttributes() {
return attributes;
}
/**
* Gets the bonuses for the entity
*
* @[Only registered and activated users can see links. ]
*/
public short[] getBonuses() {
return bonuses;
}
/**
* Gets the combat instance
*
* @[Only registered and activated users can see links. ]
*/
public Combat getCombat() {
return combat;
}
/**
* Gets the current following instance
*
* @[Only registered and activated users can see links. ]
*/
public abstract Following getFollowing();
/**
* Gets the entities index
*
* @[Only registered and activated users can see links. ]
*/
public int getIndex() {
return index;
}
/**
* Gets the last damage dealt
*
* @[Only registered and activated users can see links. ]
*/
public int getLastDamageDealt() {
return lastDamageDealt;
}
/**
* Gets the entities levels
*
* @[Only registered and activated users can see links. ]
*/
public short[] getLevels() {
return levels;
}
/**
* Gets the entities location
*
* @[Only registered and activated users can see links. ]
*/
public Location getLocation() {
return location;
}
public double getMagicWeaknessMod() {
return magicWeaknessMod;
}
/**
* Gets the entities max levels
*
* @[Only registered and activated users can see links. ]
*/
public short[] getMaxLevels() {
return maxLevels;
}
public double getMeleeWeaknessMod() {
return meleeWeaknessMod;
}
/**
* Get the current movement handler instance
*
* @[Only registered and activated users can see links. ]
*/
public abstract MovementHandler getMovementHandler();
public Player getPlayer() {
return npc ? null : World.getPlayers()[index];
}
/**
* Gets the poison damage
*
* @[Only registered and activated users can see links. ]
*/
public int getPoisonDamage() {
return poisonDamage;
}
public double getRangedWeaknessMod() {
return rangedWeaknessMod;
}
/**
* Gets the size of the entity
*
* @[Only registered and activated users can see links. ]
*/
public int getSize() {
return size;
}
/**
* Gets a list of tasks
*
* @[Only registered and activated users can see links. ]
*/
public LinkedList<Task> getTasks() {
return tasks;
}
/**
* Gets the current teleblock time
*
* @[Only registered and activated users can see links. ]
*/
public int getTeleblockTime() {
return teleblockTime;
}
/**
* Gets the entities update flags
*
* @[Only registered and activated users can see links. ]
*/
public UpdateFlags getUpdateFlags() {
return updateFlags;
}
/**
* Gets the wilderness level the entity is in
*
* @[Only registered and activated users can see links. ]
*/
public int getWildernessLevel() {
int y = location.getY();
int level = -1;
int modY = y > 6400 ? y - 6400 : y;
level = (((modY - 3520) / 8) + 1);
return level;
}
/**
* Gets the entities x coordinate
*
* @[Only registered and activated users can see links. ]
*/
public int getX() {
return location.getX();
}
/**
* Gets the entities y coordinate
*
* @[Only registered and activated users can see links. ]
*/
public int getY() {
return location.getY();
}
/**
* Gets the entities z coordinate
*
* @[Only registered and activated users can see links. ]
*/
public int getZ() {
return location.getZ();
}
/**
* The entity has attacked consecutively
*
* @[Only registered and activated users can see links. ] check
* @[Only registered and activated users can see links. ] req
* @[Only registered and activated users can see links. ]
*/
public boolean hasAttackedConsecutively(Entity check, int req) {
return (lastAttacked != null) && (lastAttacked.equals(check)) && (consecutiveAttacks >= req);
}
/**
* The entity has fire immunity
*
* @[Only registered and activated users can see links. ]
*/
public boolean hasFireImmunity() {
return fireImmunity > System.currentTimeMillis() || (getAttributes().get("fire_resist") != null && (Boolean) getAttributes().get("fire_resist")) || (getAttributes().get("super_fire_resist") != null && (Boolean) getAttributes().get("super_fire_resist"));
}
/**
* The entity has super fire immunity
*
* @[Only registered and activated users can see links. ]
*/
public boolean hasSuperFireImmunity() {
return (getAttributes().get("super_fire_resist") != null && (Boolean) getAttributes().get("super_fire_resist"));
}
/**
* Gets if an entity is in an area
*
* @[Only registered and activated users can see links. ] bottomLeft
* The bottom left corner
* @[Only registered and activated users can see links. ] topRight
* The top right corner
* @[Only registered and activated users can see links. ] heightSupport
* Should the height be checked
* @[Only registered and activated users can see links. ]
*/
public boolean inArea(Location bottomLeft, Location topRight, boolean heightSupport) {
if ((heightSupport) && (location.getZ() != bottomLeft.getZ()))
return false;
return (location.getX() >= bottomLeft.getX()) && (location.getX() <= topRight.getX()) && (location.getY() >= bottomLeft.getY()) && (location.getY() <= topRight.getY());
}
/**
* The entity is in duel arena
*
* @[Only registered and activated users can see links. ]
*/
public boolean inDuelArena() {
return (location.getX() >= 3325) && (location.getX() <= 3396) && (location.getY() >= 3199) && (location.getY() <= 3289);
}
/**
* The entity is in godwars
*
* @[Only registered and activated users can see links. ]
*/
public boolean inGodwars() {
return inArea(new Location(2816, 5243, 2), new Location(2960, 5400, 2), false);
}
/**
* The entity is in a multi area
*
* @[Only registered and activated users can see links. ]
*/
public boolean inMultiArea() {
if (attributes.get(PestControlGame.PEST_GAME_KEY) != null) {
return true;
}
public boolean inClanWarsFFA() {
int x = location.getX();
int y = location.getY();
return (x > 3275 && x < 3379 && y > 4759 && y < 4852);
}
public boolean inWGLobby() {
int x = location.getX();
int y = location.getY();
return (x > 1859 && x < 1868 && y > 5316 && y < 5323);
}
public boolean inWGGame() {
int x = location.getX();
int y = location.getY();
return (x > 2136 && x < 2166 && y > 5089 && y < 5108);
}
public boolean nearElemental() {
int x = location.getX();
int y = location.getY();
return (x > 3253 && x < 3299 && y > 3911 && y < 3933);
}
public boolean inJailed() {
int x = location.getX();
int y = location.getY();
return (x > 2770 && x < 2777 && y > 2792 && y < 2796);
}
public boolean inKraken() {
int x = location.getX();
int y = location.getY();
return (x > 3680 && x < 3713 && y > 5789 && y < 5825);
}
public boolean inZulrah() {
int x = location.getX();
int y = location.getY();
return (x > 2254 && x < 2283 && y > 3059 && y < 3083);
}
public boolean inCorp() {
int x = location.getX();
int y = location.getY();
int z = location.getZ();
return (x > 2971 && x < 3000 && y > 4361 && y < 4402 && z == 2);
}
public boolean inMemberZone() {
int x = location.getX();
int y = location.getY();
return (x > 2800 && x < 2876 && y > 3325 && y < 3390);
}
public boolean inCyclops() {
int x = location.getX();
int y = location.getY();
int z = location.getZ();
return (x >= 2847 && x <= 2876 && y >= 3534 && y <= 3556 && z == 2 || x >= 2838 && x <= 2847 && y >= 3543 && y <= 3556 && z == 2);
}
/**
* The entity is in the wilderness
*
* @[Only registered and activated users can see links. ]
*/
public boolean inWilderness() {
int x = location.getX();
int y = location.getY();
return (x > 2941 && x < 3392 && y > 3521 && y < 3966) || (x > 2941 && x < 3392 && y > 9918 && y < 10366) || (x > 2583 && x < 2729 && y > 3255 && y < 3343);
}
/**
* Gets if the entity is active
*
* @[Only registered and activated users can see links. ]
*/
public boolean isActive() {
return active;
}
/**
* Gets if the entity is dead
*
* @[Only registered and activated users can see links. ]
*/
public boolean isDead() {
return dead;
}
/**
* The entity is immune
*
* @[Only registered and activated users can see links. ]
*/
public boolean isFrozen() {
return freeze > System.currentTimeMillis();
}
public int setFreeze(int value) {
return (int) (freeze = value);
}
/**
* Gets if the entity is immune to a hit
*
* @[Only registered and activated users can see links. ]
*/
public boolean isImmuneToHit() {
return System.currentTimeMillis() < hitImmunity;
}
/**
* Gets if the entity is immune to ice
*
* @[Only registered and activated users can see links. ]
*/
public boolean isImmuneToIce() {
return iceImmunity > System.currentTimeMillis();
}
/**
* Gets if the entity is an npc
*
* @[Only registered and activated users can see links. ]
*/
public boolean isNpc() {
return npc;
}
/**
* The entity is poisoned
*
* @[Only registered and activated users can see links. ]
*/
public boolean isPoisoned() {
return poisoned;
}
/**
* Gets if the entity can retaliate
*
* @[Only registered and activated users can see links. ]
*/
public boolean isRetaliate() {
return retaliate;
}
/**
* The entity is teleblocked
*
* @[Only registered and activated users can see links. ]
*/
public boolean isTeleblocked() {
return teleblockTime > 0;
}
/**
* poisons an entity
*
* @[Only registered and activated users can see links. ] start
*/
public void poison(int start) {
if ((poisoned) || (World.getCycles() < poisonImmunity)) {
return;
}
poisoned = true;
poisonDamage = start;
TaskQueue.queue(new Task(this, 30) {
int count = 0;
@Override
public void execute() {
if (!poisoned || poisonDamage <= 0 || getPlayer() == null) {
stop();
return;
}
if (getPlayer().isDead() || getPlayer().getMagic().isTeleporting()) {
return;
}
hit(new Hit(poisonDamage, Hit.HitTypes.POISON));
if (++count == 4) {
poisonDamage -= 1;
count = 0;
if (poisonDamage == 0)
stop();
}
}
@Override
public void onStop() {
}
});
}
/**
* The entities individual process
*
* @[Only registered and activated users can see links. ]s Exception
*/
public abstract void process() throws Exception;
/**
* Resets the entitys updates
*/
public abstract void reset();
/**
* Resets the entities combat stats
*/
public void resetCombatStats() {
Player p = null;
if (!npc) {
p = World.getPlayers()[index];
}
for (int i = 0; i <= 7; i++) {
levels[i] = maxLevels[i];
if (!npc)
p.getSkill().update(i);
}
}
/**
* Resets the entities levels
*/
public void resetLevels() {
for (int i = 0; i < 25; i++) {
levels[i] = maxLevels[i];
}
if (!npc) {
Player p = World.getPlayers()[index];
if (p != null) {
p.getSkill().update();
}
}
}
public abstract void retaliate(Entity attacked);
/**
* Sets if the entity is active
*
* @[Only registered and activated users can see links. ] active
*/
public void setActive(boolean active) {
this.active = active;
}
/**
* Sets the bonuses for the entity
*
* @[Only registered and activated users can see links. ] bonuses
*/
public void setBonuses(int[] bonuses) {
for (int i = 0; i < bonuses.length; i++)
this.bonuses[i] = ((short) bonuses[i]);
}
/**
* Sets the entity dead
*
* @[Only registered and activated users can see links. ] dead
*/
public void setDead(boolean dead) {
this.dead = dead;
}
/**
* Sets the hit immunity in seconds
*
* @[Only registered and activated users can see links. ] delay
* The seconds the entity is immune to hits
*/
public void setHitImmunityDelay(int delay) {
hitImmunity = (System.currentTimeMillis() + delay * 1000);
}
/**
* Sets the entities index
*
* @[Only registered and activated users can see links. ] index
* The index to place the npc
*/
public void setIndex(int index) {
this.index = ((short) index);
}
/**
* Sets the last damage dealt
*
* @[Only registered and activated users can see links. ] lastDamageDealt
*/
public void setLastDamageDealt(int lastDamageDealt) {
this.lastDamageDealt = ((byte) lastDamageDealt);
}
/**
* Sets the last hit successful
*
* @[Only registered and activated users can see links. ] lastHitSuccess
*/
public void setLastHitSuccess(boolean lastHitSuccess) {
this.lastHitSuccess = lastHitSuccess;
}
/**
* Sets the entities levels
*
* @[Only registered and activated users can see links. ] levels
*/
public void setLevels(int[] levels) {
for (int i = 0; i < levels.length; i++)
this.levels[i] = ((short) levels[i]);
}
public void setMagicWeaknessMod(double magicWeaknessMod) {
this.magicWeaknessMod = magicWeaknessMod;
}
/**
* Sets the entities max levels
*
* @[Only registered and activated users can see links. ] maxLevels
*/
public void setMaxLevels(int[] maxLevels) {
for (int i = 0; i < maxLevels.length; i++)
this.maxLevels[i] = ((short) maxLevels[i]);
}
public void setMeleeWeaknessMod(double meleeWeaknessMod) {
this.meleeWeaknessMod = meleeWeaknessMod;
}
/**
* Sets if the entity is an npc
*
* @[Only registered and activated users can see links. ] npc
*/
public void setNpc(boolean npc) {
this.npc = npc;
}
/**
* Sets the poison damage
*
* @[Only registered and activated users can see links. ] poisonDamage
*/
public void setPoisonDamage(int poisonDamage) {
this.poisonDamage = poisonDamage;
}
public void setRangedWeaknessMod(double rangedWeaknessMod) {
this.rangedWeaknessMod = rangedWeaknessMod;
}
/**
* Sets if the entity can retalite
*
* @[Only registered and activated users can see links. ] retaliate
*/
public void setRetaliate(boolean retaliate) {
this.retaliate = retaliate;
}
/**
* Sets the size of the entity
*
* @[Only registered and activated users can see links. ] size
*/
public void setSize(int size) {
this.size = ((byte) size);
}
/**
* Sets if the entity can take damage
*
* @[Only registered and activated users can see links. ] takeDamage
*/
public void setTakeDamage(boolean takeDamage) {
this.takeDamage = takeDamage;
}
/**
* Sets the teleblock time
*
* @[Only registered and activated users can see links. ] teleblockTime
* The time to teleblock the entity
*/
public void setTeleblockTime(int teleblockTime) {
this.teleblockTime = teleblockTime;
}
/**
* Starts a regeneration task
*/
public void startRegeneration() {
TaskQueue.queue(new RegenerateSkillTask(this, 75));
}
/**
* Teleblocks an entity for a certain amount of time
*
* @[Only registered and activated users can see links. ] time
* The time to teleblock the entity
*/
public void teleblock(int time) {
if (isTeleblocked()) {
return;
}
teleblockTime = time;
tickTeleblock();
}
/**
* Ticks the teleblock
*/
public void tickTeleblock() {
TaskQueue.queue(new Task(this, 1) {
@Override
public void execute() {
if (--teleblockTime <= 0) {
teleblockTime = 0;
stop();
}
}
@Override
public void onStop() {
}
});
}
/**
* Unfreezes an entity
*/
public void unfreeze() {
freeze = 0L;
}
/**
* Gets if the last hit was successful
*
* @[Only registered and activated users can see links. ]
*/
public boolean wasLastHitSuccess() {
return lastHitSuccess;
}