Damage() public method

public Damage ( int dmg, Character chr ) : void
dmg int
chr Character
return void
Exemplo n.º 1
0
        private void PoisonPlayer(Player enemy, ActivateEffect eff)
        {
            var remainingDmg =
                (int) StatsManager.GetDefenseDamage(enemy, Math.Max(1, eff.TotalDamage/5), enemy.ObjectDesc.Defense);
            int perDmg = remainingDmg*1000/eff.DurationMS;
            WorldTimer tmr = null;
            int x = 0;
            tmr = new WorldTimer(100, (w, t) =>
            {
                if (enemy.Owner == null) return;
                w.BroadcastPacket(new ShowEffectPacket
                {
                    EffectType = EffectType.Dead,
                    TargetId = enemy.Id,
                    Color = new ARGB(0xffddff00)
                }, null);

                if (x%10 == 0)
                {
                    int thisDmg;
                    if (remainingDmg < perDmg) thisDmg = remainingDmg;
                    else thisDmg = perDmg;

                    enemy.Damage(thisDmg, enemy, false, true);
                    remainingDmg -= thisDmg;
                    if (remainingDmg <= 0) return;
                }
                x++;

                tmr.Reset();

                Manager.Logic.AddPendingAction(_ => w.Timers.Add(tmr), PendingPriority.Creation);
            });
            Owner.Timers.Add(tmr);
        }