public void Death(RealmTime time) { DamageCounter.Death(time); CurrentState?.OnDeath(new BehaviorEventArgs(this, time)); OnDeath?.Invoke(this, new BehaviorEventArgs(this, time)); Owner.LeaveWorld(this); }
public void Death(RealmTime time) { counter.Death(time); if (CurrentState != null) { CurrentState.OnDeath(new BehaviorEventArgs(this, time)); } Owner.LeaveWorld(this); }
public void Death(RealmTime time) { State state = CurrentState; if (state == null) { Log.Warn($"Enemy '{Name}' doesn't have any behavior declaration."); counter.Dispose(); } else { counter.Death(time); state.OnDeath(new BehaviorEventArgs(this, time)); } Owner.LeaveWorld(this); }
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 void Death(RealmTime time) { counter.Death(time); CurrentState?.OnDeath(new BehaviorEventArgs(this, time)); Owner?.LeaveWorld(this); }