public int Damage(Player from, RealmTime time, int dmg, bool noDef, params ConditionEffect[] effs) { if (stat) { return(0); } if (HasConditionEffect(ConditionEffects.Invincible)) { return(0); } if (HasConditionEffect(ConditionEffects.Paused) || HasConditionEffect(ConditionEffects.Stasis)) { return(0); } var def = ObjectDesc.Defense; if (noDef) { def = 0; } dmg = (int)StatsManager.GetDefenseDamage(this, dmg, def); int effDmg = dmg; if (effDmg > HP) { effDmg = HP; } if (!HasConditionEffect(ConditionEffects.Invulnerable)) { HP -= dmg; } ApplyConditionEffect(effs); Owner.BroadcastPacket(new DamagePacket { TargetId = Id, Effects = 0, Damage = (ushort)dmg, Killed = HP < 0, BulletId = 0, ObjectId = @from.Id }, null); counter.HitBy(@from, time, null, dmg); if (HP < 0 && Owner != null) { Death(time); } UpdateCount++; return(effDmg); }
public int Damage(Player from, RealmTime time, int dmg, bool noDef, params ConditionEffect[] effs) { if (stat) { return(0); } if (HasConditionEffect(ConditionEffects.Invincible)) { return(0); } if (!HasConditionEffect(ConditionEffects.Paused) && !HasConditionEffect(ConditionEffects.Stasis)) { var def = this.ObjectDesc.Defense; if (noDef) { def = 0; } dmg = (int)StatsManager.GetDefenseDamage(this, dmg, def); int effDmg = dmg; if (effDmg > HP) { effDmg = HP; } if (!HasConditionEffect(ConditionEffects.Invulnerable)) { HP -= dmg; } ApplyConditionEffect(effs); Owner.BroadcastPacketNearby(new Damage() { TargetId = this.Id, Effects = 0, DamageAmount = (ushort)dmg, Kill = HP < 0, BulletId = 0, ObjectId = from.Id }, this, null, PacketPriority.Low); counter.HitBy(from, time, null, dmg); if (HP < 0 && Owner != null) { Death(time); } return(effDmg); } return(0); }
public int Damage(Player from, RealmTime time, int dmg, bool noDef, bool fromProjectile, Projectile proj, params ConditionEffect[] effs) { if (nonDamage || isDead) { return(0); } if (HasConditionEffect(ConditionEffects.Invincible)) { return(0); } if (!HasConditionEffect(ConditionEffects.Paused) && !HasConditionEffect(ConditionEffects.Stasis)) { var effDmg = (int)StatsManager.GetEnemyDamage(this, dmg, 0); if (!noDef) { effDmg = (int)StatsManager.GetEnemyDamage(this, dmg, Defense); } HP -= effDmg; ApplyConditionEffect(effs); Owner.BroadcastPacket(new DamagePacket { TargetId = Id, Effects = 0, Damage = (ushort)effDmg, Killed = HP <= 0, BulletId = 0, ObjectId = from.Id }, fromProjectile ? from : null); if (from.IsValid()) { counter.HitBy(from, time, proj, effDmg); } if (HP <= 0 && Owner != null) { Death(time); } UpdateCount++; return(effDmg); } return(0); }
public override bool HitByProjectile(Projectile projectile, RealmTime time) { if (stat) { return(false); } if (HasConditionEffect(ConditionEffectIndex.Invincible)) { return(false); } if (projectile.ProjectileOwner is Player && !HasConditionEffect(ConditionEffectIndex.Paused) && !HasConditionEffect(ConditionEffectIndex.Stasis)) { var prevHp = HP; var dmg = (int)StatsManager.GetDefenseDamage(this, projectile.Damage, projectile.ProjDesc.ArmorPiercing ? 0 : ObjectDesc.Defense); if (!HasConditionEffect(ConditionEffectIndex.Invulnerable)) { HP -= dmg; } foreach (ConditionEffect effect in projectile.ProjDesc.Effects.Where(effect => (effect.Effect != ConditionEffectIndex.Stunned || !ObjectDesc.StunImmune) && (effect.Effect != ConditionEffectIndex.Paralyzed || !ObjectDesc.ParalyzedImmune) && (effect.Effect != ConditionEffectIndex.Dazed || !ObjectDesc.DazedImmune))) { ApplyConditionEffect(effect); } Owner.BroadcastMessage(new DAMAGE { TargetId = Id, Effects = projectile.ConditionEffects, Damage = (ushort)dmg, Killed = HP <= 0, BulletId = projectile.ProjectileId, ObjectId = projectile.ProjectileOwner.Id }, HP <= 0 && !IsOneHit(dmg, prevHp) ? null : projectile.ProjectileOwner as Player); counter.HitBy(projectile.ProjectileOwner as Player, time, projectile, dmg); if (HP <= 0) { //CheckDeath = true; Death(time); } UpdateCount++; return(true); } return(false); }
public override bool HitByProjectile(Projectile projectile, RealmTime time) { if (stat) { return(false); } if (HasConditionEffect(ConditionEffects.Invincible)) { return(false); } if (projectile.ProjectileOwner is Player && !HasConditionEffect(ConditionEffects.Paused) && !HasConditionEffect(ConditionEffects.Stasis)) { var def = this.ObjectDesc.Defense; if (projectile.ProjDesc.ArmorPiercing) { def = 0; } int dmg = (int)StatsManager.GetDefenseDamage(this, projectile.Damage, def); if (!HasConditionEffect(ConditionEffects.Invulnerable)) { HP -= dmg; } ApplyConditionEffect(projectile.ProjDesc.Effects); Owner.BroadcastPacketNearby(new Damage() { TargetId = this.Id, Effects = projectile.ConditionEffects, DamageAmount = (ushort)dmg, Kill = HP < 0, BulletId = projectile.ProjectileId, ObjectId = projectile.ProjectileOwner.Self.Id }, this, (projectile.ProjectileOwner as Player), PacketPriority.Low); DamageCounter.HitBy(projectile.ProjectileOwner as Player, time, projectile, dmg); if (HP < 0 && Owner != null) { Death(time); } return(true); } return(false); }
public int Damage(Player from, RealmTime time, int dmg, bool noDef, params ConditionEffect[] effs) { if (stat) { return(0); } if (HasConditionEffect(ConditionEffectIndex.Invincible)) { return(0); } if (!HasConditionEffect(ConditionEffectIndex.Paused) && !HasConditionEffect(ConditionEffectIndex.Stasis)) { int def = ObjectDesc.Defense; if (noDef) { def = 0; } dmg = (int)StatsManager.GetDefenseDamage(this, dmg, def); int effDmg = dmg; if (effDmg > HP) { effDmg = HP; } if (!HasConditionEffect(ConditionEffectIndex.Invulnerable)) { HP -= dmg; } ApplyConditionEffect(effs); if (from != null) { Owner?.BroadcastMessage(new DAMAGE { TargetId = Id, Effects = 0, Damage = (ushort)dmg, Killed = HP <= 0, BulletId = 0, ObjectId = from.Id }, null); counter?.HitBy(from, time, null, dmg); } else { Owner?.BroadcastMessage(new DAMAGE { TargetId = Id, Effects = 0, Damage = (ushort)dmg, Killed = HP <= 0, BulletId = 0, ObjectId = -1 }, null); } if (HP <= 0) { CheckDeath = true; } UpdateCount++; return(effDmg); } return(0); }
public int Damage(Player from, RealmTime time, int dmg, bool noDef, params ConditionEffect[] effs) { if (stat) { return(0); } if (HasConditionEffect(ConditionEffects.Invincible)) { return(0); } if (!HasConditionEffect(ConditionEffects.Paused) && !HasConditionEffect(ConditionEffects.Stasis)) { var def = ObjectDesc.Defense; if (noDef) { def = 0; } dmg = (int)StatsManager.GetDefenseDamage(this, dmg, def); var effDmg = dmg; if (effDmg > HP) { effDmg = HP; } if (!HasConditionEffect(ConditionEffects.Invulnerable)) { /*Owner.BroadcastPacket(new DamagePacket * { * TargetId = Id, * Effects = 0, * Damage = (ushort) dmg, * Killed = HP < 0, * BulletId = 0, * ObjectId = from.Id * }, null);*/ //if (!HasConditionEffect(ConditionEffects.Invulnerable)) { Owner.BroadcastPacket(new NotificationPacket { ObjectId = Id, Text = "-" + dmg + " [" + HP + "]", Color = new ARGB(0xffff0000) }, null); HP -= dmg; ApplyConditionEffect(effs); } //purple color on armor broken else if (HasConditionEffect(ConditionEffects.ArmorBroken)) { Owner.BroadcastPacket(new NotificationPacket { ObjectId = Id, Text = "-" + dmg + " [" + HP + "]", Color = new ARGB(0x9900FF) }, null); HP -= dmg; ApplyConditionEffect(effs); } foreach (var i in CondBehaviors) { if ((i.Condition & BehaviorCondition.OnHit) != 0) { i.Behave(BehaviorCondition.OnHit, this, time, null); } } counter.HitBy(from, null, dmg); if (HP < 0) { foreach (var i in CondBehaviors) { if ((i.Condition & BehaviorCondition.OnDeath) != 0) { i.Behave(BehaviorCondition.OnDeath, this, time, counter); } } counter.Death(); if (Owner != null) { Owner.LeaveWorld(this); } } UpdateCount++; return(effDmg); } return(0); }
public int Damage(Player from, RealmTime time, int dmg, bool noDef, params ConditionEffect[] effs) { if (stat) { return(0); } if (HasConditionEffect(ConditionEffects.Invincible)) { return(0); } if (!HasConditionEffect(ConditionEffects.Paused) && !HasConditionEffect(ConditionEffects.Stasis)) { var def = this.ObjectDesc.Defense; if (noDef) { def = 0; } dmg = (int)StatsManager.GetDefenseDamage(this, dmg, def); int effDmg = dmg; if (effDmg > HP) { effDmg = HP; } if (!HasConditionEffect(ConditionEffects.Invulnerable)) { HP -= dmg; } ApplyConditionEffect(effs); Owner.BroadcastPacket(new DamagePacket() { TargetId = this.Id, Effects = 0, Damage = (ushort)dmg, Killed = HP < 0, BulletId = 0, ObjectId = from.Id }, null); foreach (var i in CondBehaviors) { if ((i.Condition & BehaviorCondition.OnHit) != 0) { i.Behave(BehaviorCondition.OnHit, this, time, null); } } counter.HitBy(from, null, dmg); if (HP < 0) { foreach (var i in CondBehaviors) { if ((i.Condition & BehaviorCondition.OnDeath) != 0) { i.Behave(BehaviorCondition.OnDeath, this, time, counter); } } counter.Death(); if (Owner != null) { Owner.LeaveWorld(this); } } UpdateCount++; return(effDmg); } return(0); }
public int Damage(Player from, RealmTime time, int dmg, int pen, bool noDef, Projectile proj, bool deathmark = false, params ConditionEffect[] effs) { if (zeroHealth) { return(0); } if (HasConditionEffect(ConditionEffects.Invincible)) { return(0); } if (!HasConditionEffect(ConditionEffects.Paused) && !HasConditionEffect(ConditionEffects.Stasis)) { int def = Defense; int res = Resilience; if (noDef) { def = 0; Resilience = 0; } if (from.Specialization == "Blood" && from.AbilityActiveDurations[2] != 0) { float totalhealth = from.Stats[0]; float dmgPercentage = from.HP / totalhealth; dmg = dmg + (int)(dmg * dmgPercentage); } if (from.Specialization == "Marksmanship" && from.AbilityActiveDurations[2] != 0) { from.bowBlessing = from.bowBlessing + 5; float blessing = from.bowBlessing; float dmgmodifier = blessing / 100; dmg = (int)(dmg * dmgmodifier); } if (proj != null && proj.abil != null && proj.abil.Ability == ActivateAbilities.FireBall && burning) { dmg = dmg * 3; } if (proj != null && proj.abil != null && proj.abil.Ability == ActivateAbilities.PoisonDagger) { from.poisons.Add(new Poison(this, proj.abil)); } if (proj != null && proj.abil != null && proj.abil.Ability == ActivateAbilities.ToxicBolt) { if (Owner != null) { Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffddff00), PosA = new Position { X = proj.abil.Radius } }, null); Owner.AOE(new Position { X = this.X, Y = this.Y }, proj.abil.Radius, false, enemy => { from.poisons.Add(new Poison(enemy as Enemy, proj.abil)); }); } } if (proj != null && proj.abil != null && proj.abil.Ability == ActivateAbilities.FireBlast) { from.burns.Add(new Burn(this, proj.abil)); } if (proj != null && proj.abil != null && proj.abil.Ability == ActivateAbilities.FlameVolley) { from.burns.Add(new Burn(this, proj.abil)); } if (proj != null && proj.abil != null && proj.abil.Ability == ActivateAbilities.BlastVolley) { Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffff5500), PosA = new Position { X = proj.abil.Radius } }, null); Owner.AOE(new Position { X = this.X, Y = this.Y }, proj.abil.Radius, false, enemy => { (enemy as Enemy).Damage(from, time, proj.abil.Damage, pen, false, null); if (burning) { from.burns.Add(new Burn(enemy as Enemy, proj.abil)); } }); } if (proj != null && proj.abil != null && proj.abil.Ability == ActivateAbilities.SkillShot) { float elapsed = time.TotalElapsedMs - proj.BeginTime; float dmgmodifier = elapsed / 1500; dmg = (int)(dmg + (dmg * dmgmodifier * 5)); } if (proj != null && proj.abil != null && proj.abil.Ability == ActivateAbilities.DeathArrow) { proj.deathhitcount++; dmg = dmg * proj.deathhitcount; } int effDmg = Math.Min((int)StatsManager.GetEnemyDamage(this, dmg, pen, def, res), HP); if (HasConditionEffect(ConditionEffects.Invulnerable)) { effDmg = 0; } HP -= effDmg; if (from.DeathMarked != null) { if (deathmark == false) { foreach (var i in from.DeathMarked.Keys) { if (i == this || i.Owner == null) { continue; } i.Damage(from, time, dmg / 10, pen, false, null, true); } } } ApplyConditionEffect(effs); if (effDmg != 0) { Owner.BroadcastPacket(new DamagePacket { TargetId = Id, Effects = 0, Damage = (ushort)effDmg, Killed = HP <= 0, BulletId = 0, ObjectId = from != null ? from.Id : -1 }, null); } if (from != null) { counter.HitBy(from, time, proj, effDmg); } if (HP <= 0 && Owner != null) { Death(time); } UpdateCount++; return(effDmg); } return(0); }
public override bool HitByProjectile(Projectile projectile, RealmTime time) { if (stat) { return(false); } if (HasConditionEffect(ConditionEffects.Invincible)) { return(false); } if (projectile.ProjectileOwner is Player p && !HasConditionEffect(ConditionEffects.Paused) && !HasConditionEffect(ConditionEffects.Stasis)) { var def = ObjectDesc.Defense; if (projectile.ProjDesc.ArmorPiercing) { def = 0; } var dmg = (int)StatsManager.GetDefenseDamage(this, projectile.Damage, def); if (!HasConditionEffect(ConditionEffects.Invulnerable)) { HP -= dmg; } ConditionEffect[] effs = null; foreach (var pair in projectile.ProjDesc.CondChance) { if (pair.Value == 0 || pair.Key == default(ConditionEffect)) { continue; } if (pair.Value / 100d > new Random().NextDouble()) { var effList = new List <ConditionEffect>(projectile.ProjDesc.Effects) { pair.Key }; effs = effList.ToArray(); } } ApplyConditionEffect(effs ?? projectile.ProjDesc.Effects); Owner.BroadcastPacketNearby(new Damage { TargetId = Id, Effects = projectile.ConditionEffects, DamageAmount = (ushort)dmg, Kill = HP < 0, BulletId = projectile.ProjectileId, ObjectId = projectile.ProjectileOwner.Self.Id }, this, p, PacketPriority.Low); if (p.StealAmount != null) { if (p.StealAmount[0] != 0 && !p.HasConditionEffect(ConditionEffects.Sick)) { var maxHP = p.Stats[0]; var lifeSteal = p.StealAmount[0]; if (lifeSteal >= 1 && p.HP < maxHP) { p.HP = p.HP + lifeSteal > maxHP ? maxHP : p.HP + lifeSteal; } else { stealHits[0]++; if (stealHits[0] >= 1 / lifeSteal) { p.HP = p.HP + lifeSteal > maxHP ? maxHP : p.HP + lifeSteal; } } } if (p.StealAmount[1] != 0 && !p.HasConditionEffect(ConditionEffects.Quiet)) { var maxMP = p.Stats[1]; var manaLeech = p.StealAmount[1]; if (manaLeech >= 1 && p.MP < maxMP) { p.MP = p.MP + manaLeech > maxMP ? maxMP : p.MP + manaLeech; } else { stealHits[1]++; if (stealHits[1] >= 1 / manaLeech) { p.MP = p.MP + manaLeech > maxMP ? maxMP : p.MP + manaLeech; } } } } DamageCounter.HitBy(p, time, projectile, dmg); if (HP < 0 && Owner != null) { Death(time); } return(true); } return(false); }