protected override void OnStateEntry(Entity host, RealmTime time, ref object state)
 {
     Entity[] ens = host.GetNearestEntities(dist).ToArray();
     foreach (Entity e in ens)
         if (e.ObjectType == host.Manager.GameData.IdToObjectType[children])
             host.Owner.LeaveWorld(e);
 }
        protected override void TickCore(Entity host, RealmTime time, ref object state)
        {
            //sinceCopy_ += time.thisTickCounts;
            //if (sinceCopy_ < 1.0)
            //{
            //    return;
            //}
            //sinceCopy_ = 0.0;

            if (targetId_ == ushort.MaxValue)
            {
                targetId_ = host.Manager.GameData.IdToObjectType[this.targetName_];
            }

            Entity[] target = (host.GetNearestEntities(range_, targetId_).ToArray());
            if (target.FirstOrDefault() == null)
            {
                targetId_ = ushort.MaxValue;
                return;
            }

            for (var i = 0; i < target.Count(); i++)
            {
                if ((host as Enemy).DamageCounter.Total == (target[i] as Enemy).DamageCounter.Total)
                {
                    return;
                }
                (target[i] as Enemy).SetDamageCounter((host as Enemy).DamageCounter, (target[i] as Enemy));
            }
            return;
        }
 protected override void TickCore(Entity host, RealmTime time, ref object state)
 {
     if (targetState == null)
         targetState = FindState(host.Manager.Behaviors.Definitions[(ushort)target].Item1, targetStateName);
     foreach (Entity i in host.GetNearestEntities(range, target))
         if (!i.CurrentState.Is(targetState))
             i.SwitchTo(targetState);
 }
Example #4
0
 protected override void TickCore(Entity host, RealmTime time, ref object state)
 {
     if (targetState == null)
         this.targetState = FindState(BehaviorDb.Definitions[this.children].Item1, targetStateName);
     foreach (var i in host.GetNearestEntities(range, children))
         if (!i.CurrentState.Is(targetState))
             i.SwitchTo(targetState);
 }
 protected override void OnStateEntry(Entity host, RealmTime time, ref object state)
 {
     if (host is Enemy)
     {
         foreach (Entity i in host.GetNearestEntities(radius, children))
             if(i is Enemy)
                 if ((i as Enemy).LootState != (host as Enemy).LootState)
                     (i as Enemy).LootState = (host as Enemy).LootState;
     }
 }
 protected override void OnStateEntry(Entity host, RealmTime time, ref object state)
 {
     foreach (var i in host.GetNearestEntities(25, null).OfType<Player>())
     {
         i.Client.SendPacket(new PlaySoundPacket
         {
             OwnerId = host.Id,
             SoundId = soundId
         });
     }
 }
        protected override void TickCore(Entity host, RealmTime time, ref object state)
        {
            int cool = (int)state;
            if (cool <= 0)
            {
                var entities = host.GetNearestEntities(6);

                Enemy en = null;
                foreach (Entity e in entities)
                    if (e is Enemy)
                    {
                        en = e as Enemy;
                        break;
                    }

                if (en != null & en.ObjectDesc.Enemy)
                {
                    en.Owner.BroadcastPacket(new ShowEffectPacket
                    {
                        EffectType = EffectType.AreaBlast,
                        Color = new ARGB(0x48D747),
                        TargetId = en.Id,
                        PosA = new Position { X = 1, }
                    }, null);
                    en.Owner.BroadcastPacket(new ShowEffectPacket
                    {
                        EffectType = EffectType.Trail,
                        TargetId = host.Id,
                        PosA = new Position { X = en.X, Y = en.Y },
                        Color = new ARGB(0x48D747)
                    }, null);
                    en.ApplyConditionEffect(new ConditionEffect
                    {
                        Effect = ConditionEffectIndex.Slowed,
                        DurationMS = 10000
                    });

                }
                cool = 300;
            }
            else
                cool -= time.thisTickTimes;

            state = cool;
        }
        protected override void TickCore(Entity host, RealmTime time, ref object state)
        {
            int cool = (int)state;
            if (cool <= 0)
            {
                var entities = host.GetNearestEntities(6);

                Enemy en = null;
                foreach (Entity e in entities)
                    if (e is Enemy)
                    {
                        en = e as Enemy;
                        break;
                    }

                if (en != null & en.ObjectDesc.Enemy)
                {
                    en.Owner.BroadcastPacket(new ShowEffectPacket
                    {
                        EffectType = EffectType.AreaBlast,
                        Color = new ARGB(0x3E3A78),
                        TargetId = en.Id,
                        PosA = new Position { X = 1, }
                    }, null);
                    en.Owner.BroadcastPacket(new ShowEffectPacket
                    {
                        EffectType = EffectType.Trail,
                        TargetId = host.Id,
                        PosA = new Position { X = en.X, Y = en.Y },
                        Color = new ARGB(0x3E3A78)
                    }, null);
                    en.Damage(host.GetPlayerOwner(), time, 35, false, new ConditionEffect[] { });
                }
                cool = 300;
            }
            else
                cool -= time.thisTickTimes;

            state = cool;
        }
 protected override void TickCore(Entity host, RealmTime time, ref object state)
 {
     Result = host.GetNearestEntities(dist, target).Count() > amount;
 }
        protected override void TickCore(Entity host, RealmTime time, ref object state)
        {
            if (state == null) return;
            int cool = (int) state;

            if (cool <= 0)
            {

                PetLevel level = null;
                if (host is Pet)
                {
                    Pet p = host as Pet;
                    level = p.GetPetLevelFromAbility(Ability.Electric, true);
                }
                else return;

                if (level == null) return;

                double dist = getDist(host as Pet, level);

                Enemy[] targets = host.GetNearestEntities(dist).OfType<Enemy>().ToArray();
                foreach (Enemy e in targets)
                {
                    if (e.HasConditionEffect(ConditionEffectIndex.Invulnerable) || e.HasConditionEffect(ConditionEffectIndex.Invincible) || e.HasConditionEffect(ConditionEffectIndex.Stasis)) continue;
                    if (Random.Next(0, 100) > level.Level) break;

                    if (e.ObjectDesc == null | !e.ObjectDesc.Enemy) continue;

                    if (e.HasConditionEffect(ConditionEffectIndex.Invincible)) continue;

                    e.ApplyConditionEffect(new ConditionEffect
                    {
                        DurationMS = level.Level * 40,
                        Effect = ConditionEffectIndex.Paralyzed
                    });

                    e.Owner.BroadcastPacket(new ShowEffectPacket
                    {
                        EffectType = EffectType.ElectricFlashing,
                        PosA = new Position { X = level.Level * 40},
                        TargetId = e.Id
                    }, null);

                    host.Owner.BroadcastPacket(new ShowEffectPacket
                    {
                        PosA = new Position { X = host.X, Y = host.Y },
                        EffectType = EffectType.ElectricBolts,
                        TargetId = host.Id,
                    }, null);

                    e.Damage(null, time, level.Level, true, new ConditionEffect
                    {
                        DurationMS = level.Level * 40,
                        Effect = ConditionEffectIndex.Paralyzed
                    });
                }

                cool = getCooldown(host as Pet, level) / host.Manager.TPS;
            }
            else
                cool -= time.thisTickTimes;

            state = cool;
        }
        protected override void TickCore(Entity host, RealmTime time, ref object state)
        {
            int cool = (int)state;

            if (cool <= 0)
            {
                var entities = host.GetNearestEntities(28, 0x0d5e)
                    .Concat(host.GetNearestEntities(28, 0x0d60))
                    .ToArray();
                if (entities.Length != 5)
                    return;

                var packets = new List<Packet>();
                if (!entities.Any(_ => _.ObjectType == 0x0d5e))
                {
                    var players = new HashSet<Entity>();
                    foreach (var i in entities.SelectMany(_ => (_ as Enemy).DamageCounter.GetPlayerData()))
                        if (i.Item1.Quest == host)
                            players.Add(i.Item1);
                    foreach (var i in players)
                        packets.Add(new NotificationPacket
                        {
                            ObjectId = i.Id,
                            Color = new ARGB(0xFF00FF00),
                            Text = "{\"key\":\"blank\",\"tokens\":{\"data\":\"Quest Complete!\"}}"
                        });

                    if (host.Owner is GameWorld)
                        (host.Owner as GameWorld).EnemyKilled(host as Enemy,
                            (entities.Last() as Enemy).DamageCounter.Parent.LastHitter);
                    new Decay(0).Tick(host, time);
                    foreach (var i in entities)
                        new Suicide().Tick(i, time);
                }
                else
                {
                    var hasCorpse = entities.Any(_ => _.ObjectType == 0x0d60);
                    for (var i = 0; i < entities.Length; i++)
                        for (var j = i + 1; j < entities.Length; j++)
                        {
                            packets.Add(new ShowEffectPacket
                            {
                                TargetId = entities[i].Id,
                                EffectType = EffectType.Stream,
                                Color = new ARGB(hasCorpse ? 0xFFFFFF : 0xffff0000),
                                PosA = new Position
                                {
                                    X = entities[j].X,
                                    Y = entities[j].Y
                                },
                                PosB = new Position
                                {
                                    X = entities[i].X,
                                    Y = entities[i].Y
                                }
                            });
                        }
                }
                host.Owner.BroadcastPackets(packets, null);
                cool = this.cool.Next(Random);
            }
            else
                cool -= time.thisTickTimes;

            state = cool;
        }
        protected override void TickCore(Entity host, RealmTime time, ref object state)
        {
            var cool = (int)state;

            if (cool <= 0)
            {
                if (host.HasConditionEffect(ConditionEffects.Sick)) return;

                if(host.GetNearestEntity(radius, null) != null)
                {
                    var pkts = new List<Packet>();
                    foreach (var player in host.GetNearestEntities(radius, null).Select(p => (p as Player)).Where(player => player.Stats[0] + player.Boost[0] != player.HP))
                    {
                        player.EntityHealHp(player, host, amount, pkts);
                        pkts.Add(new ShowEffectPacket
                        {
                            EffectType = EffectType.Trail,
                            TargetId = host.Id,
                            PosA = new Position {X = player.X, Y = player.Y},
                            Color = new ARGB(0xffffffff)
                        });
                    }
                    host.Owner.BroadcastPackets(pkts, null);
                }
                cool = coolDown.Next(Random);
            }
            else
                cool -= time.thisTickTimes;

            state = cool;
        }