コード例 #1
0
        private void IncrementStat(ActivateEffect eff)
        {
            int idx = -1;

            if (eff.Stats == StatsType.MaximumHP)
            {
                idx = 0;
            }
            else if (eff.Stats == StatsType.MaximumMP)
            {
                idx = 1;
            }
            else if (eff.Stats == StatsType.Attack)
            {
                idx = 2;
            }
            else if (eff.Stats == StatsType.Defense)
            {
                idx = 3;
            }
            else if (eff.Stats == StatsType.Speed)
            {
                idx = 4;
            }
            else if (eff.Stats == StatsType.Vitality)
            {
                idx = 5;
            }
            else if (eff.Stats == StatsType.Wisdom)
            {
                idx = 6;
            }
            else if (eff.Stats == StatsType.Dexterity)
            {
                idx = 7;
            }

            Stats[idx] += eff.Amount;
            int limit =
                int.Parse(
                    Manager.GameData.ObjectTypeToElement[ObjectType].Element(
                        StatsManager.StatsIndexToName(idx))
                    .Attribute("max")
                    .Value);

            if (Stats[idx] > limit)
            {
                Stats[idx] = limit;
            }
            UpdateCount++;
        }
コード例 #2
0
        private void AEShurikenAbility(RealmTime time, Item item, Position target, ActivateEffect eff)
        {
            if (!HasConditionEffect(ConditionEffects.NinjaSpeedy))
            {
                ApplyConditionEffect(ConditionEffectIndex.NinjaSpeedy);
                return;
            }

            if (MP >= item.MpEndCost)
            {
                MP -= item.MpEndCost;
                AEShoot(time, item, target, eff);
            }

            ApplyConditionEffect(ConditionEffectIndex.NinjaSpeedy, 0);
        }
コード例 #3
0
ファイル: Player.UseItem.cs プロジェクト: ppmaks/LOE-V6-GAME
        private void MagicNova(ActivateEffect eff)
        {
            List <Message> pkts = new List <Message>();

            this?.Aoe(eff.Range / 2, true, player => { ActivateHealMp(player as Player, eff.Amount, pkts); });
            pkts.Add(new SHOWEFFECT
            {
                EffectType = EffectType.Nova,
                TargetId   = Id,
                Color      = new ARGB(0xffffffff),
                PosA       = new Position {
                    X = eff.Range
                }
            });
            Owner?.BroadcastPackets(pkts, null);
        }
コード例 #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();

                Manager.Logic.AddPendingAction(_ => w.Timers.Add(tmr), PendingPriority.Creation);
            });
            Owner.Timers.Add(tmr);
        }
コード例 #5
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);
        }
コード例 #6
0
        private void StasisBlast(RealmTime time, Item item, Position target, ActivateEffect eff)
        {
            var pkts = new List <Packet>
            {
                new ShowEffect()
                {
                    EffectType     = EffectType.Concentrate,
                    TargetObjectId = Id,
                    Pos1           = target,
                    Pos2           = new Position()
                    {
                        X = target.X + 3, Y = target.Y
                    },
                    Color = new ARGB(0xffffffff)
                }
            };

            Owner.AOE(target, 3, false, enemy =>
            {
                if (enemy.HasConditionEffect(ConditionEffects.StasisImmune))
                {
                    pkts.Add(new Notification()
                    {
                        ObjectId = enemy.Id,
                        Color    = new ARGB(0xff00ff00),
                        Message  = "Immune"
                    });
                }
                else if (!enemy.HasConditionEffect(ConditionEffects.Stasis))
                {
                    enemy.ApplyConditionEffect(ConditionEffectIndex.Stasis, eff.DurationMS);

                    Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) =>
                                                    enemy.ApplyConditionEffect(ConditionEffectIndex.StasisImmune, 3000)));

                    pkts.Add(new Notification()
                    {
                        ObjectId = enemy.Id,
                        Color    = new ARGB(0xffff0000),
                        Message  = "Stasis"
                    });
                }
            });
            BroadcastSync(pkts, p => this.DistSqr(p) < RadiusSqr);
        }
コード例 #7
0
        /**
         * Updates the varFlag summary (the references to flags and variables if the
         * effect given as argument has any)
         *
         * @param effect
         */
        protected void updateVarFlagSummary(IEffect effect)
        {
            if (effect.getType() == EffectType.ACTIVATE)
            {
                ActivateEffect activateEffect = (ActivateEffect)effect;
                controller.VarFlagSummary.deleteReference(activateEffect.getTargetId());
            }

            else if (effect.getType() == EffectType.DEACTIVATE)
            {
                DeactivateEffect deactivateEffect = (DeactivateEffect)effect;
                controller.VarFlagSummary.deleteReference(deactivateEffect.getTargetId());
            }

            else if (effect.getType() == EffectType.SET_VALUE)
            {
                SetValueEffect setValueEffect = (SetValueEffect)effect;
                controller.VarFlagSummary.deleteReference(setValueEffect.getTargetId());
            }

            else if (effect.getType() == EffectType.INCREMENT_VAR)
            {
                IncrementVarEffect setValueEffect = (IncrementVarEffect)effect;
                controller.VarFlagSummary.deleteReference(setValueEffect.getTargetId());
            }

            else if (effect.getType() == EffectType.DECREMENT_VAR)
            {
                DecrementVarEffect setValueEffect = (DecrementVarEffect)effect;
                controller.VarFlagSummary.deleteReference(setValueEffect.getTargetId());
            }

            else if (effect.getType() == EffectType.RANDOM_EFFECT)
            {
                RandomEffect randomEffect = (RandomEffect)effect;
                if (randomEffect.getPositiveEffect() != null)
                {
                    updateVarFlagSummary(randomEffect.getPositiveEffect());
                }
                if (randomEffect.getNegativeEffect() != null)
                {
                    updateVarFlagSummary(randomEffect.getNegativeEffect());
                }
            }
        }
コード例 #8
0
        private void AEMagicNova(RealmTime time, Item item, Position target, ActivateEffect eff)
        {
            var pkts = new List <Packet>();

            this.AOE(eff.Range, true, player =>
                     ActivateHealMp(player as Player, eff.Amount, pkts));
            pkts.Add(new ShowEffect()
            {
                EffectType     = EffectType.AreaBlast,
                TargetObjectId = Id,
                Color          = new ARGB(0xffffffff),
                Pos1           = new Position()
                {
                    X = eff.Range
                }
            });
            BroadcastSync(pkts, p => this.DistSqr(p) < RadiusSqr);
        }
コード例 #9
0
        private void AEStatBoostSelf(RealmTime time, Item item, Position target, ActivateEffect eff)
        {
            var idx = StatsManager.GetStatIndex((StatsType)eff.Stats);
            var s   = eff.Amount;

            Stats.Boost.ActivateBoost[idx].Push(s, false);
            Stats.ReCalculateValues();
            Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) =>
            {
                Stats.Boost.ActivateBoost[idx].Pop(s, false);
                Stats.ReCalculateValues();
            }));
            BroadcastSync(new ShowEffect()
            {
                EffectType     = EffectType.Potion,
                TargetObjectId = Id,
                Color          = new ARGB(0xffffffff)
            }, p => this.DistSqr(p) < RadiusSqr);
        }
コード例 #10
0
ファイル: Player.UseItem.cs プロジェクト: ppmaks/LOE-V6-GAME
        private void UnlockPortal(ActivateEffect eff)
        {
            Portal portal = this.GetNearestEntity(5, Manager.GameData.IdToObjectType[eff.LockedName]) as Portal;

            Message[] packets = new Message[3];
            packets[0] = new SHOWEFFECT
            {
                EffectType = EffectType.Nova,
                Color      = new ARGB(0xFFFFFF),
                PosA       = new Position {
                    X = 5
                },
                TargetId = Id
            };

            if (portal == null)
            {
                return;
            }

            portal.Unlock(eff.DungeonName);

            packets[1] = new NOTIFICATION
            {
                Color = new ARGB(0x00FF00),
                Text  =
                    "{\"key\":\"blank\",\"tokens\":{\"data\":\"Unlocked by " +
                    Name + "\"}}",
                ObjectId = Id
            };

            packets[2] = new TEXT
            {
                BubbleTime = 0,
                Stars      = -1,
                Name       = "",
                Text       = eff.DungeonName + " Unlocked by " + Name + ".",
                NameColor  = 0x123456,
                TextColor  = 0x123456
            };

            BroadcastSync(packets);
        }
コード例 #11
0
ファイル: Player.UseItem.cs プロジェクト: ppmaks/LOE-V6-GAME
        private void ConditionEffectAura(ActivateEffect eff)
        {
            int   durationCEA = eff.DurationMS;
            float rangeCEA    = eff.Range;

            if (eff.UseWisMod)
            {
                durationCEA = (int)(UseWisMod(eff.DurationSec) * 1000);
                rangeCEA    = UseWisMod(eff.Range);
            }

            this?.Aoe(rangeCEA, true, player =>
            {
                player.ApplyConditionEffect(new ConditionEffect
                {
                    Effect     = eff.ConditionEffect.Value,
                    DurationMS = durationCEA
                });
            });

            uint color = 0xffffffff;

            switch (eff.ConditionEffect.Value)
            {
            case ConditionEffectIndex.Damaging:
                color = 0xffff0000;
                break;

            case ConditionEffectIndex.Berserk:
                color = 0x808080;
                break;
            }

            BroadcastSync(new SHOWEFFECT
            {
                EffectType = EffectType.Nova,
                TargetId   = Id,
                Color      = new ARGB(color),
                PosA       = new Position {
                    X = rangeCEA
                }
            }, p => this?.Dist(p) < 25);
        }
コード例 #12
0
        void HealingPlayersPoison(World world, Player player, ActivateEffect eff)
        {
            var remainingHeal = eff.TotalDamage;
            var perHeal       = eff.TotalDamage * 1000 / eff.DurationMS;

            WorldTimer tmr = null;
            var        x   = 0;

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

                if (x % 4 == 0) // make sure to change this if timer delay is changed
                {
                    var thisHeal = perHeal;
                    if (remainingHeal < thisHeal)
                    {
                        thisHeal = remainingHeal;
                    }

                    List <Packet> pkts = new List <Packet>();

                    Player.ActivateHealHp(player, thisHeal, pkts);
                    w.BroadcastPackets(pkts, null);
                    remainingHeal -= thisHeal;
                    if (remainingHeal <= 0)
                    {
                        return(true);
                    }
                }
                x++;

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

            tmr = new WorldTimer(250, healTick);
            world.Timers.Add(tmr);
        }
コード例 #13
0
ファイル: Player.UseItem.cs プロジェクト: ppmaks/LOE-V6-GAME
 private void PoisonGrenade(ActivateEffect eff, Position target)
 {
     try
     {
         BroadcastSync(new SHOWEFFECT
         {
             EffectType = EffectType.Throw,
             Color      = new ARGB(0xffddff00),
             TargetId   = Id,
             PosA       = target
         }, p => this?.Dist(p) < 25);
         Placeholder x = new Placeholder(Manager, 1500);
         x.Move(target.X, target.Y);
         Owner?.EnterWorld(x);
         try
         {
             Owner.Timers.Add(new WorldTimer(1500, (world, t) =>
             {
                 world.BroadcastPacket(new SHOWEFFECT
                 {
                     EffectType = EffectType.Nova,
                     Color      = new ARGB(0xffddff00),
                     TargetId   = x.Id,
                     PosA       = new Position {
                         X = eff.Radius
                     }
                 }, null);
                 world.Aoe(target, eff.Radius, false,
                           enemy => PoisonEnemy(enemy as Enemy, eff));
             }));
         }
         catch (Exception ex)
         {
             log.ErrorFormat("Poison ShowEffect:\n{0}", ex);
         }
     }
     catch (Exception ex)
     {
         log.ErrorFormat("Poisons General:\n{0}", ex);
     }
 }
コード例 #14
0
ファイル: Player.UseItem.cs プロジェクト: ppmaks/LOE-V6-GAME
 private void Trap(RealmTime time, ActivateEffect eff, Position target)
 {
     BroadcastSync(new SHOWEFFECT
     {
         EffectType = EffectType.Throw,
         Color      = new ARGB(0xff9000ff),
         TargetId   = Id,
         PosA       = target
     }, p => this.Dist(p) < 25);
     Owner?.Timers.Add(new WorldTimer(1500, (world, t) =>
     {
         Trap trap = new Trap(
             this,
             eff.Radius,
             eff.TotalDamage,
             eff.ConditionEffect ?? ConditionEffectIndex.Slowed,
             eff.EffectDuration);
         trap?.Move(target.X, target.Y);
         world?.EnterWorld(trap);
     }));
 }
コード例 #15
0
ファイル: Player.UseItem.cs プロジェクト: ppmaks/LOE-V6-GAME
        private void GenericActivate(ActivateEffect eff, Position target)
        {
            bool  targetPlayer = eff.Target.Equals("player");
            bool  centerPlayer = eff.Center.Equals("player");
            int   duration     = (eff.UseWisMod) ? (int)(UseWisMod(eff.DurationSec) * 1000) : eff.DurationMS;
            float range        = (eff.UseWisMod) ? UseWisMod(eff.Range) : eff.Range;

            Owner?.Aoe((eff.Center.Equals("mouse")) ? target : new Position {
                X = X, Y = Y
            }, range, targetPlayer, entity =>
            {
                if (IsSpecial(entity.ObjectType))
                {
                    return;
                }
                if (!entity.HasConditionEffect(ConditionEffectIndex.Stasis) &&
                    !entity.HasConditionEffect(ConditionEffectIndex.Invincible))
                {
                    entity.ApplyConditionEffect(
                        new ConditionEffect()
                    {
                        Effect     = eff.ConditionEffect.Value,
                        DurationMS = duration
                    });
                }
            });

            // replaced this last bit with what I had, never noticed any issue with it. Perhaps I'm wrong?
            BroadcastSync(new SHOWEFFECT()
            {
                EffectType = (EffectType)eff.VisualEffect,
                TargetId   = Id,
                Color      = new ARGB(eff.Color ?? 0xffffffff),
                PosA       = centerPlayer ? new Position {
                    X = range
                } : target,
                PosB = new Position(target.X - range, target.Y) //Its the range of the diffuse effect
            }, p => this?.DistSqr(p) < 25);
        }
コード例 #16
0
        private void AETrap(RealmTime time, Item item, Position target, ActivateEffect eff)
        {
            BroadcastSync(new ShowEffect()
            {
                EffectType     = EffectType.Throw,
                Color          = new ARGB(0xff9000ff),
                TargetObjectId = Id,
                Pos1           = target
            }, p => this.DistSqr(p) < RadiusSqr);

            Owner.Timers.Add(new WorldTimer(1500, (world, t) =>
            {
                var trap = new Trap(
                    this,
                    eff.Radius,
                    eff.TotalDamage,
                    eff.ConditionEffect ?? ConditionEffectIndex.Slowed,
                    eff.EffectDuration);
                trap.Move(target.X, target.Y);
                world.EnterWorld(trap);
            }));
        }
コード例 #17
0
        private void AEBulletNova(RealmTime time, Item item, Position target, ActivateEffect eff)
        {
            var prjs    = new Projectile[20];
            var prjDesc = item.Projectiles[0]; //Assume only one
            var batch   = new Packet[21];

            for (var i = 0; i < 20; i++)
            {
                var proj = CreateProjectile(prjDesc, item.ObjectType,
                                            Random.Next(prjDesc.MinDamage, prjDesc.MaxDamage),
                                            time.TotalElapsedMs, target, (float)(i * (Math.PI * 2) / 20));
                Owner.EnterWorld(proj);
                FameCounter.Shoot(proj);
                batch[i] = new ServerPlayerShoot()
                {
                    BulletId      = proj.ProjectileId,
                    OwnerId       = Id,
                    ContainerType = item.ObjectType,
                    StartingPos   = target,
                    Angle         = proj.Angle,
                    Damage        = (short)proj.Damage
                };
                prjs[i] = proj;
            }
            batch[20] = new ShowEffect()
            {
                EffectType     = EffectType.Trail,
                Pos1           = target,
                TargetObjectId = Id,
                Color          = new ARGB(0xFFFF00AA)
            };

            foreach (var plr in Owner.Players.Values
                     .Where(p => p.DistSqr(this) < RadiusSqr))
            {
                plr.Client.SendPackets(batch);
            }
        }
コード例 #18
0
ファイル: Player.UseItem.cs プロジェクト: ppmaks/LOE-V6-GAME
        private void ConditionEffectSelf(ActivateEffect eff)
        {
            int durationCES = eff.DurationMS;

            if (eff.UseWisMod)
            {
                durationCES = (int)(UseWisMod(eff.DurationSec) * 1000);
            }

            uint color = 0xffffffff;

            switch (eff.ConditionEffect.Value)
            {
            case ConditionEffectIndex.Damaging:
                color = 0xffff0000;
                break;

            case ConditionEffectIndex.Berserk:
                color = 0x808080;
                break;
            }

            ApplyConditionEffect(new ConditionEffect
            {
                Effect     = eff.ConditionEffect.Value,
                DurationMS = durationCES
            });
            Owner?.BroadcastPacket(new SHOWEFFECT
            {
                EffectType = EffectType.Nova,
                TargetId   = Id,
                Color      = new ARGB(color),
                PosA       = new Position {
                    X = 2F
                }
            }, null);
        }
コード例 #19
0
        private void AEStatBoostAura(RealmTime time, Item item, Position target, ActivateEffect eff)
        {
            var idx      = StatsManager.GetStatIndex((StatsType)eff.Stats);
            var amount   = eff.Amount;
            var duration = eff.DurationMS;
            var range    = eff.Range;

            this.AOE(range, true, player =>
            {
                ((Player)player).Stats.Boost.ActivateBoost[idx].Push(amount, false);
                ((Player)player).Stats.ReCalculateValues();

                // hack job to allow instant heal of nostack boosts
                //if (eff.NoStack && amount > 0 && idx == 0)
                //{
                //    ((Player)player).HP = Math.Min(((Player)player).Stats[0], ((Player)player).HP + amount);
                //}

                Owner.Timers.Add(new WorldTimer(duration, (world, t) =>
                {
                    ((Player)player).Stats.Boost.ActivateBoost[idx].Pop(amount, false);
                    ((Player)player).Stats.ReCalculateValues();
                }));
            });

            BroadcastSync(new ShowEffect()
            {
                EffectType     = EffectType.AreaBlast,
                TargetObjectId = Id,
                Color          = new ARGB(0xffffffff),
                Pos1           = new Position()
                {
                    X = range
                }
            }, p => this.DistSqr(p) < RadiusSqr);
        }
コード例 #20
0
 private void AEBackpack(RealmTime time, Item item, Position target, ActivateEffect eff)
 {
     HasBackpack = true;
 }
コード例 #21
0
        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
                        }
                    });
                int remainingDmg = (int)StatsManager.GetDefenseDamage(enemy, eff.TotalDamage, 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(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);
            }
            catch (Exception ex)
            {
                Entity.logger.Error(ex);
            }
        }
コード例 #22
0
 public ActivateEffectEditor()
 {
     flags       = Controller.getInstance().getVarFlagSummary().getFlags();
     this.effect = new ActivateEffect(flags[0]);
 }
コード例 #23
0
        private void AEClearConditionEffectSelf(RealmTime time, Item item, Position target, ActivateEffect eff)
        {
            var condition = eff.CheckExistingEffect;
            ConditionEffects conditions = 0;

            if (condition.HasValue)
            {
                conditions |= (ConditionEffects)(1 << (Byte)condition.Value);
            }

            if (!condition.HasValue || HasConditionEffect(conditions))
            {
                ApplyConditionEffect(new ConditionEffect()
                {
                    Effect     = eff.ConditionEffect.Value,
                    DurationMS = 0
                });
            }
        }
コード例 #24
0
 private void AEClearConditionEffectAura(RealmTime time, Item item, Position target, ActivateEffect eff)
 {
     this.AOE(eff.Range, true, player =>
     {
         var condition = eff.CheckExistingEffect;
         ConditionEffects conditions = 0;
         conditions |= (ConditionEffects)(1 << (Byte)condition.Value);
         if (!condition.HasValue || player.HasConditionEffect(conditions))
         {
             player.ApplyConditionEffect(new ConditionEffect()
             {
                 Effect     = eff.ConditionEffect.Value,
                 DurationMS = 0
             });
         }
     });
 }
コード例 #25
0
 private void AETeleport(RealmTime time, Item item, Position target, ActivateEffect eff)
 {
     TeleportPosition(time, target, true);
 }
コード例 #26
0
        private void AEVampireBlast(RealmTime time, Item item, Position target, ActivateEffect eff)
        {
            var pkts = new List <Packet>
            {
                new ShowEffect()
                {
                    EffectType     = EffectType.Trail,
                    TargetObjectId = Id,
                    Pos1           = target,
                    Color          = new ARGB(0xFFFF0000)
                },
                new ShowEffect
                {
                    EffectType     = EffectType.Diffuse,
                    Color          = new ARGB(0xFFFF0000),
                    TargetObjectId = Id,
                    Pos1           = target,
                    Pos2           = new Position {
                        X = target.X + eff.Radius, Y = target.Y
                    }
                }
            };

            var totalDmg = 0;
            var enemies  = new List <Enemy>();

            Owner.AOE(target, eff.Radius, false, enemy =>
            {
                enemies.Add(enemy as Enemy);
                totalDmg += (enemy as Enemy).Damage(this, time, eff.TotalDamage, false);
            });

            var players = new List <Player>();

            this.AOE(eff.Radius, true, player =>
            {
                if (!player.HasConditionEffect(ConditionEffects.Sick))
                {
                    players.Add(player as Player);
                    ActivateHealHp(player as Player, totalDmg, pkts);
                }
            });

            if (enemies.Count > 0)
            {
                var rand = new Random();
                for (var i = 0; i < 5; i++)
                {
                    var a = enemies[rand.Next(0, enemies.Count)];
                    var b = players[rand.Next(0, players.Count)];
                    pkts.Add(new ShowEffect()
                    {
                        EffectType     = EffectType.Flow,
                        TargetObjectId = b.Id,
                        Pos1           = new Position()
                        {
                            X = a.X, Y = a.Y
                        },
                        Color = new ARGB(0xffffffff)
                    });
                }
            }

            BroadcastSync(pkts, p => this.DistSqr(p) < RadiusSqr);
        }
コード例 #27
0
        private void AEConditionEffectSelf(RealmTime time, Item item, Position target, ActivateEffect eff)
        {
            var duration = eff.DurationMS;

            ApplyConditionEffect(new ConditionEffect()
            {
                Effect     = eff.ConditionEffect.Value,
                DurationMS = duration
            });
            BroadcastSync(new ShowEffect()
            {
                EffectType     = EffectType.AreaBlast,
                TargetObjectId = Id,
                Color          = new ARGB(0xffffffff),
                Pos1           = new Position()
                {
                    X = 1
                }
            }, p => this.DistSqr(p) < RadiusSqr);
        }
コード例 #28
0
        private void AELightning(RealmTime time, Item item, Position target, ActivateEffect eff)
        {
            const double coneRange  = Math.PI / 4;
            var          mouseAngle = Math.Atan2(target.Y - Y, target.X - X);

            // get starting target
            var startTarget = this.GetNearestEntity(MaxAbilityDist, false, e => e is Enemy &&
                                                    Math.Abs(mouseAngle - Math.Atan2(e.Y - Y, e.X - X)) <= coneRange);

            // no targets? bolt air animation
            if (startTarget == null)
            {
                var noTargets = new Packet[3];
                var angles    = new double[] { mouseAngle, mouseAngle - coneRange, mouseAngle + coneRange };
                for (var i = 0; i < 3; i++)
                {
                    var x = (int)(MaxAbilityDist * Math.Cos(angles[i])) + X;
                    var y = (int)(MaxAbilityDist * Math.Sin(angles[i])) + Y;
                    noTargets[i] = new ShowEffect()
                    {
                        EffectType     = EffectType.Trail,
                        TargetObjectId = Id,
                        Color          = new ARGB(0xffff0088),
                        Pos1           = new Position()
                        {
                            X = x,
                            Y = y
                        },
                        Pos2 = new Position()
                        {
                            X = 350
                        }
                    };
                }
                BroadcastSync(noTargets, p => this.DistSqr(p) < RadiusSqr);
                return;
            }

            var current = startTarget;
            var targets = new Entity[eff.MaxTargets];

            for (int i = 0; i < targets.Length; i++)
            {
                targets[i] = current;
                var next = current.GetNearestEntity(10, false, e =>
                {
                    if (!(e is Enemy) ||
                        e.HasConditionEffect(ConditionEffects.Invincible) ||
                        e.HasConditionEffect(ConditionEffects.Stasis) ||
                        Array.IndexOf(targets, e) != -1)
                    {
                        return(false);
                    }

                    return(true);
                });

                if (next == null)
                {
                    break;
                }

                current = next;
            }

            var pkts = new List <Packet>();

            for (var i = 0; i < targets.Length; i++)
            {
                if (targets[i] == null)
                {
                    break;
                }

                var prev = i == 0 ? this : targets[i - 1];

                (targets[i] as Enemy).Damage(this, time, eff.TotalDamage, false);

                if (eff.ConditionEffect != null)
                {
                    targets[i].ApplyConditionEffect(new ConditionEffect()
                    {
                        Effect     = eff.ConditionEffect.Value,
                        DurationMS = (int)(eff.EffectDuration * 1000)
                    });
                }

                pkts.Add(new ShowEffect()
                {
                    EffectType     = EffectType.Lightning,
                    TargetObjectId = prev.Id,
                    Color          = new ARGB(0xffff0088),
                    Pos1           = new Position()
                    {
                        X = targets[i].X,
                        Y = targets[i].Y
                    },
                    Pos2 = new Position()
                    {
                        X = 350
                    }
                });
            }
            BroadcastSync(pkts, p => this.DistSqr(p) < RadiusSqr);
        }
コード例 #29
0
 private void AERemoveNegativeConditions(RealmTime time, Item item, Position target, ActivateEffect eff)
 {
     this.AOE(eff.Range, true, player => player.ApplyConditionEffect(NegativeEffs));
     BroadcastSync(new ShowEffect()
     {
         EffectType     = EffectType.AreaBlast,
         TargetObjectId = Id,
         Color          = new ARGB(0xffffffff),
         Pos1           = new Position()
         {
             X = eff.Range
         }
     }, p => this.DistSqr(p) < RadiusSqr);
 }
コード例 #30
0
 private void AERemoveNegativeConditionSelf(RealmTime time, Item item, Position target, ActivateEffect eff)
 {
     ApplyConditionEffect(NegativeEffs);
     BroadcastSync(new ShowEffect()
     {
         EffectType     = EffectType.AreaBlast,
         TargetObjectId = Id,
         Color          = new ARGB(0xffffffff),
         Pos1           = new Position()
         {
             X = 1
         }
     }, p => this.DistSqr(p) < RadiusSqr);
 }
コード例 #31
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);
        }
コード例 #32
0
ファイル: Player.UseItem.cs プロジェクト: C453/OryxKingdom
        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;
            }
        }
コード例 #33
0
        private void AEUnlockPortal(RealmTime time, Item item, Position target, ActivateEffect eff)
        {
            var gameData = Manager.Resources.GameData;

            // find locked portal
            var portals = Owner.StaticObjects.Values
                          .Where(s => s is Portal && s.ObjectDesc.ObjectId.Equals(eff.LockedName) && s.DistSqr(this) <= 9)
                          .Select(s => s as Portal);

            if (!portals.Any())
            {
                return;
            }
            var portal = portals.Aggregate(
                (curmin, x) => (curmin == null || x.DistSqr(this) < curmin.DistSqr(this) ? x : curmin));

            if (portal == null)
            {
                return;
            }

            // get proto of world
            ProtoWorld proto;

            if (!Manager.Resources.Worlds.Data.TryGetValue(eff.DungeonName, out proto))
            {
                Log.Error("Unable to unlock portal. \"" + eff.DungeonName + "\" does not exist.");
                return;
            }

            if (proto.portals == null || proto.portals.Length < 1)
            {
                Log.Error("World is not associated with any portals.");
                return;
            }

            // create portal of unlocked world
            var portalType = (ushort)proto.portals[0];
            var uPortal    = Resolve(Manager, portalType) as Portal;

            if (uPortal == null)
            {
                Log.Error("Error creating portal: {0}", portalType);
                return;
            }

            var portalDesc  = gameData.Portals[portal.ObjectType];
            var uPortalDesc = gameData.Portals[portalType];

            // create world
            World world;

            if (proto.id < 0)
            {
                world = Manager.GetWorld(proto.id);
            }
            else
            {
                DynamicWorld.TryGetWorld(proto, Client, out world);
                world = Manager.AddWorld(world ?? new World(proto));
            }
            uPortal.WorldInstance = world;

            // swap portals
            if (!portalDesc.NexusPortal || !Manager.Monitor.RemovePortal(portal))
            {
                Owner.LeaveWorld(portal);
            }
            uPortal.Move(portal.X, portal.Y);
            uPortal.Name = uPortalDesc.DisplayId;
            var uPortalPos = new Position()
            {
                X = portal.X - .5f, Y = portal.Y - .5f
            };

            if (!uPortalDesc.NexusPortal || !Manager.Monitor.AddPortal(world.Id, uPortal, uPortalPos))
            {
                Owner.EnterWorld(uPortal);
            }

            // setup timeout
            if (!uPortalDesc.NexusPortal)
            {
                var timeoutTime = gameData.Portals[portalType].Timeout;
                Owner.Timers.Add(new WorldTimer(timeoutTime * 1000, (w, t) => w.LeaveWorld(uPortal)));
            }

            // announce
            Owner.BroadcastPacket(new Notification
            {
                Color    = new ARGB(0xFF00FF00),
                ObjectId = Id,
                Message  = "Unlocked by " + Name
            }, null);
            foreach (var player in Owner.Players.Values)
            {
                player.SendInfo(string.Format("{0} unlocked by {1}!", world.SBName, Name));
            }
        }