private void PoisonEnemy(Enemy enemy, ActivateEffect eff)
{
try
{
if (eff.ConditionEffect != null)
enemy.ApplyConditionEffect(new[]
{
new ConditionEffect
{
Effect = (ConditionEffectIndex) eff.ConditionEffect,
DurationMS = (int) eff.EffectDuration
}
});
var remainingDmg = (int)StatsManager.GetDefenseDamage(enemy, eff.TotalDamage, enemy.ObjectDesc.Defense);
var perDmg = remainingDmg * 1000 / eff.DurationMS;
WorldTimer tmr = null;
var 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(this, t, thisDmg, true);
remainingDmg -= thisDmg;
if (remainingDmg <= 0) return;
}
x++;
tmr.Reset();
RealmManager.Logic.AddPendingAction(_ => w.Timers.Add(tmr), PendingPriority.Creation);
});
Owner.Timers.Add(tmr);
}
catch
{
Console.ForegroundColor = ConsoleColor.DarkBlue;
Console.Out.WriteLine("Crash halted - Poisons!");
Console.ForegroundColor = ConsoleColor.White;
}
}