Exemplo n.º 1
0
        void PoisonEnemy(Enemy enemy, ActivateEffect eff)
        {
            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();

                Manager.Logic.AddPendingAction(_ => w.Timers.Add(tmr), PendingPriority.Creation);
            });
            Owner.Timers.Add(tmr);
        }
Exemplo n.º 2
0
        void PoisonEnemy(World world, Enemy enemy, ActivateEffect eff)
        {
            var remainingDmg = (int)StatsManager.GetDefenseDamage(enemy, eff.TotalDamage, enemy.ObjectDesc.Defense);
            var perDmg       = (remainingDmg * 1000) / eff.DurationMS;

            WorldTimer tmr = null;
            var        x   = 0;

            Func <World, RealmTime, bool> poisonTick = (w, t) =>
            {
                if (enemy.Owner == null || w == null)
                {
                    return(true);
                }

                /*w.BroadcastPacketConditional(new ShowEffect()
                 * {
                 *  EffectType = EffectType.Dead,
                 *  TargetObjectId = enemy.Id,
                 *  Color = new ARGB(0xffddff00)
                 * }, p => enemy.DistSqr(p) < RadiusSqr);*/

                if (x % 4 == 0) // make sure to change this if timer delay is changed
                {
                    var thisDmg = perDmg;
                    if (remainingDmg < thisDmg)
                    {
                        thisDmg = remainingDmg;
                    }

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

                tmr.Reset();
                return(false);
            };

            tmr = new WorldTimer(250, poisonTick);
            world.Timers.Add(tmr);
        }
Exemplo n.º 3
0
        public override void Tick(RealmTime time)
        {
            r++;
            if (remDuration <= 0)
            {
                Owner.LeaveWorld(this);
            }
            else
            {
                remDuration -= time.ElaspedMsDelta;
            }

            if (r % firerate == 0)
            {
                target = this.GetNearestEntity(radius, false,
                                               enemy =>
                                               enemy is Enemy) as Enemy;
                if (target != null)
                {
                    Owner.BroadcastPacket(new ShowEffectPacket
                    {
                        EffectType = EffectType.Lightning,
                        TargetId   = this.Id,
                        Color      = new ARGB(0xffC2F0FF),
                        PosA       = new Position
                        {
                            X = target.X,
                            Y = target.Y
                        },
                        PosB = new Position {
                            X = 350
                        }
                    }, null);
                    target.Damage(playerOwner, time, damage, penetration, false, null);
                }
            }
            if (Size < 100)
            {
                Size += 10;
            }

            UpdateCount++;
        }
Exemplo n.º 4
0
        void PoisonEnemy(Enemy enemy, ActivateEffect eff)
        {
            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.AddPendingAction(_ => w.Timers.Add(tmr), PendingPriority.Creation);
            });
            Owner.Timers.Add(tmr);
        }
Exemplo n.º 5
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.º 6
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;
            }
        }