public Entity() { this.entityFocusId = -1; queuedHits = new Queue<Hits.Hit>(); hits = new Hits(); hidden = false; dead = false; target = null; attacker = null; combatTurns = 0; poisonAmount = 0; killers = new Dictionary<Entity, double>(); temporaryAttributes = new Dictionary<string, Object>(); follow = new Follow(this); sprite = new Sprite(); this.location = new Location(2322 + misc.random(1), 3171 + misc.random(5), 0); }
public Entity() { this.entityFocusId = -1; queuedHits = new Queue <Hits.Hit>(); hits = new Hits(); hidden = false; dead = false; target = null; attacker = null; combatTurns = 0; poisonAmount = 0; killers = new Dictionary <Entity, double>(); temporaryAttributes = new Dictionary <string, Object>(); follow = new Follow(this); sprite = new Sprite(); this.location = new Location(2322 + misc.random(1), 3171 + misc.random(5), 0); }
public abstract void hit(int damage, Hits.HitType type);
public override void hit(int damage, Hits.HitType type) { if (isDead()) { damage = 0; type = Hits.HitType.NO_DAMAGE; } bool redemption = prayers.getHeadIcon() == PrayerData.REDEMPTION; byte maxHp = (byte)skills.getMaxLevel(Skills.SKILL.HITPOINTS); byte newHp = (byte)(skills.getMaxLevel(Skills.SKILL.HITPOINTS) - damage); if (redemption) { if (newHp >= 1 && newHp <= maxHp * 0.10) { setLastGraphics(new Graphics(436, 0, 0)); packets.sendMessage("Using your prayer skill, you heal yourself."); skills.setCurLevel(Skills.SKILL.PRAYER, 0); packets.sendSkillLevel(Skills.SKILL.PRAYER); heal((int)(skills.getMaxLevel(Skills.SKILL.PRAYER) * 0.25)); } } if (duelSession != null) { if (duelSession.getStatus() >= 8) return; } else { if (newHp >= 1 && newHp <= maxHp * 0.10 && !redemption) { if (equipment.getItemInSlot(ItemData.EQUIP.RING) == 2570) { teleport(new Location(3221 + misc.random(1), 3217 + misc.random(3), 0)); packets.sendMessage("Your ring of life shatters whilst teleporting you to safety."); equipment.getSlot(ItemData.EQUIP.RING).setItemId(-1); equipment.getSlot(ItemData.EQUIP.RING).setItemAmount(0); packets.refreshEquipment(); queuedHits.Clear(); Combat.resetCombat(this, 1); return; } } } bool damageOverZero = damage > 0; if (damage > skills.getCurLevel(Skills.SKILL.HITPOINTS)) { damage = skills.getCurLevel(Skills.SKILL.HITPOINTS); } if (damageOverZero && damage == 0) { type = Hits.HitType.NO_DAMAGE; } if (!updateFlags.isHitUpdateRequired()) { getHits().setHit1(new Hits.Hit(damage, type)); updateFlags.setHitUpdateRequired(true); } else { if (!updateFlags.isHit2UpdateRequired()) { getHits().setHit2(new Hits.Hit(damage, type)); updateFlags.setHit2UpdateRequired(true); } else { lock (queuedHits) { queuedHits.Enqueue(new Hits.Hit(damage, type)); } return; } } skills.setCurLevel(Skills.SKILL.HITPOINTS, skills.getCurLevel(Skills.SKILL.HITPOINTS) - damage); if (skills.getCurLevel(Skills.SKILL.HITPOINTS) <= 0) { skills.setCurLevel(Skills.SKILL.HITPOINTS, 0); if (!isDead()) { Server.registerEvent(new DeathEvent(this)); setDead(true); } } packets.sendSkillLevel(Skills.SKILL.HITPOINTS); }