Exemplo n.º 1
0
        void PoisonEnemy(Enemy enemy, ActivateEffect eff)
        {
            try
            {
                if (eff.ConditionEffect != null)
                    enemy.ApplyConditionEffect(new ConditionEffect[] {
                        new ConditionEffect() {
                            Effect = (ConditionEffectIndex)eff.ConditionEffect,
                            DurationMS = (int)eff.EffectDuration
                        }});
                int remainingDmg = (int)StatsManager.GetDefenseDamage(enemy, eff.TotalDamage, enemy.ObjectDesc.Defense);
                int perDmg = (int)(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(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;
            }
        }
Exemplo n.º 2
0
        void PoisonEnemy(Enemy enemy, ActivateEffect eff)
        {
            try
            {
                if (eff.ConditionEffect != null)
                {
                    enemy.ApplyConditionEffect(new ConditionEffect[] {
                        new ConditionEffect()
                        {
                            Effect     = (ConditionEffectIndex)eff.ConditionEffect,
                            DurationMS = (int)eff.EffectDuration
                        }
                    });
                }
                int        remainingDmg = (int)StatsManager.GetDefenseDamage(enemy, eff.TotalDamage, enemy.ObjectDesc.Defense);
                int        perDmg       = (int)(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(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;
            }
        }