protected override bool TickCore(Entity host, RealmTime time, ref object state)
 {
     if (host.GetNearestEntity(dist, target) == null && host.GetNearestEntity(dist, target2) == null)
     {
         return true;
     }
     return false;
 }
        protected override void TickCore(Entity host, RealmTime time, ref object state)
        {
            int cooldown;
            if (state == null) cooldown = 1000;
            else cooldown = (int)state;

            Status = CycleStatus.NotStarted;

            if (host.HasConditionEffect(ConditionEffectIndex.Paralyzed)) return;

            Player player = (Player)host.GetNearestEntity(distance, null);
            if (player != null)
            {
                Vector2 vect;
                vect = new Vector2(player.X - host.X, player.Y - host.Y);
                vect.Normalize();
                float dist = host.GetSpeed(speed) * (time.thisTickTimes / 1000f);
                host.ValidateAndMove(host.X + (-vect.X) * dist, host.Y + (-vect.Y) * dist);
                host.UpdateCount++;

                if (cooldown <= 0)
                {
                    Status = CycleStatus.Completed;
                    cooldown = 1000;
                }
                else
                {
                    Status = CycleStatus.InProgress;
                    cooldown -= time.thisTickTimes;
                }
            }

            state = cooldown;
        }
Пример #3
0
        protected override void TickCore(Entity host, RealmTime time, ref object state)
        {
            ProtectState s;
            if (state == null) s = ProtectState.DontKnowWhere;
            else s = (ProtectState) state;

            Status = CycleStatus.NotStarted;

            if (host.HasConditionEffect(ConditionEffectIndex.Paralyzed)) return;

            Entity entity = host.GetNearestEntity(acquireRange, protectee);
            Vector2 vect;
            switch (s)
            {
                case ProtectState.DontKnowWhere:
                    if (entity != null)
                    {
                        s = ProtectState.Protecting;
                        goto case ProtectState.Protecting;
                    }
                    break;
                case ProtectState.Protecting:
                    if (entity == null)
                    {
                        s = ProtectState.DontKnowWhere;
                        break;
                    }
                    vect = new Vector2(entity.X - host.X, entity.Y - host.Y);
                    if (vect.Length > reprotectRange)
                    {
                        Status = CycleStatus.InProgress;
                        vect.Normalize();
                        float dist = host.GetSpeed(speed)*(time.thisTickTimes/1000f);
                        host.ValidateAndMove(host.X + vect.X*dist, host.Y + vect.Y*dist);
                        host.UpdateCount++;
                    }
                    else
                    {
                        Status = CycleStatus.Completed;
                        s = ProtectState.Protected;
                    }
                    break;
                case ProtectState.Protected:
                    if (entity == null)
                    {
                        s = ProtectState.DontKnowWhere;
                        break;
                    }
                    Status = CycleStatus.Completed;
                    vect = new Vector2(entity.X - host.X, entity.Y - host.Y);
                    if (vect.Length > protectionRange)
                    {
                        s = ProtectState.Protecting;
                        goto case ProtectState.Protecting;
                    }
                    break;
            }

            state = s;
        }
 protected override void OnStateEntry(Entity host, RealmTime time, ref object state)
 {
     if (host.GetNearestEntity(100, 0x5e4b) != null) return;
     Entity opener = Entity.Resolve(host.Manager, "Realm Portal Opener");
     host.Owner.EnterWorld(opener);
     opener.Move(host.X, host.Y);
 }
Пример #5
0
        protected override void TickCore(Entity host, RealmTime time, ref object state)
        {
            ChargeState s;
            if (state == null) s = new ChargeState();
            else s = (ChargeState) state;

            Status = CycleStatus.NotStarted;

            if (host.HasConditionEffect(ConditionEffectIndex.Paralyzed)) return;

            if (s.RemainingTime <= 0)
            {
                if (s.Direction == Vector2.Zero)
                {
                    var player = (Player) host.GetNearestEntity(range, null);
                    if (player != null && player.X != host.X && player.Y != host.Y)
                    {
                        s.Direction = new Vector2(player.X - host.X, player.Y - host.Y);
                        float d = s.Direction.Length;
                        s.Direction.Normalize();
                        s.RemainingTime = coolDown.Next(Random);
                        if (d/host.GetSpeed(speed) < s.RemainingTime)
                            s.RemainingTime = (int) (d/host.GetSpeed(speed)*1000);
                        Status = CycleStatus.InProgress;
                    }
                }
                else
                {
                    s.Direction = Vector2.Zero;
                    s.RemainingTime = coolDown.Next(Random);
                    Status = CycleStatus.Completed;
                }
            }
            if (s.Direction != Vector2.Zero)
            {
                float dist = host.GetSpeed(speed)*(time.thisTickTimes/1000f);
                host.ValidateAndMove(host.X + s.Direction.X*dist, host.Y + s.Direction.Y*dist);
                host.UpdateCount++;
                Status = CycleStatus.InProgress;
            }
            s.RemainingTime -= time.thisTickTimes;

            state = s;
        }
Пример #6
0
        protected override void TickCore(Entity host, RealmTime time, ref object state)
        {
            FollowState s;
            if (state == null) s = new FollowState();
            else s = (FollowState) state;

            Status = CycleStatus.NotStarted;

            if (host.HasConditionEffect(ConditionEffects.Paralyzed)) return;

            var player = host.GetNearestEntity(acquireRange, null);
            Vector2 vect;
            switch (s.State)
            {
                case F.DontKnowWhere:
                    if (player != null && s.RemainingTime <= 0)
                    {
                        s.State = F.Acquired;
                        if (duration > 0)
                            s.RemainingTime = duration;
                        goto case F.Acquired;
                    }
                    if (s.RemainingTime > 0)
                        s.RemainingTime -= time.thisTickTimes;
                    break;
                case F.Acquired:
                    if (player == null)
                    {
                        s.State = F.DontKnowWhere;
                        s.RemainingTime = 0;
                        break;
                    }
                    if (s.RemainingTime <= 0 && duration > 0)
                    {
                        s.State = F.DontKnowWhere;
                        s.RemainingTime = coolDown.Next(Random);
                        Status = CycleStatus.Completed;
                        break;
                    }
                    if (s.RemainingTime > 0)
                        s.RemainingTime -= time.thisTickTimes;

                    vect = new Vector2(player.X - host.X, player.Y - host.Y);
                    if (vect.Length() > range)
                    {
                        Status = CycleStatus.InProgress;
                        vect.X -= Random.Next(-2, 2)/2f;
                        vect.Y -= Random.Next(-2, 2)/2f;
                        vect.Normalize();
                        float dist = host.GetSpeed(speed)*(time.thisTickTimes/1000f);
                        host.ValidateAndMove(host.X + vect.X*dist, host.Y + vect.Y*dist);
                        host.UpdateCount++;
                    }
                    else
                    {
                        Status = CycleStatus.Completed;
                        s.State = F.Resting;
                        s.RemainingTime = 0;
                    }
                    break;
                case F.Resting:
                    if (player == null)
                    {
                        s.State = F.DontKnowWhere;
                        if (duration > 0)
                            s.RemainingTime = duration;
                        break;
                    }
                    Status = CycleStatus.Completed;
                    vect = new Vector2(player.X - host.X, player.Y - host.Y);
                    if (vect.Length() > range + 1)
                    {
                        s.State = F.Acquired;
                        s.RemainingTime = duration;
                        goto case F.Acquired;
                    }
                    break;
            }

            state = s;
        }
 protected override bool TickCore(Entity host, RealmTime time, ref object state)
 {
     return host.GetNearestEntity(dist, target) != null;
 }
        protected override void TickCore(Entity host, RealmTime time, ref object state)
        {
            if (checkForStates && !states.ToList().Contains(host.CurrentState.Name)) return;
            if (state != null && cooldown.CoolDown == 0) return; //cooldown = 0 -> once per state entry

            int c;
            if (state == null) c = cooldown.Next(Random);
            else c = (int)state;

            c -= time.thisTickTimes;
            state = c;
            if (c > 0) return;

            c = cooldown.Next(Random);
            state = c;

            if (Random.NextDouble() >= probability) return;

            string taunt = text.Length == 1 ? text[0] : text[Random.Next(text.Length)];
            if (taunt.Contains("{PLAYER}"))
            {
                Entity player = host.GetNearestEntity(10, null);
                if (player == null) return;
                taunt = taunt.Replace("{PLAYER}", player.Name);
            }
            taunt = taunt.Replace("{HP}", (host as Enemy).HP.ToString());

            TextPacket packet = new TextPacket
            {
                Name = "#" + (host.ObjectDesc.DisplayId ?? host.ObjectDesc.ObjectId),
                ObjectId = host.Id,
                Stars = -1,
                BubbleTime = 5,
                Recipient = "",
                Text = taunt,
                CleanText = ""
            };
            if (broadcast)
                host.Owner.BroadcastPacket(packet, null);
            else
                foreach (Player i in host.Owner.PlayersCollision.HitTest(host.X, host.Y, 15).OfType<Player>())
                    if (host.Dist(i) < 15)
                        i.Client.SendPacket(packet);
        }
 protected override bool TickCore(Entity host, RealmTime time, ref object state)
 {
     foreach (string children in childrens)
         if (host.GetNearestEntity(dist, host.Manager.GameData.IdToObjectType[children]) != null) return false;
     return true;
 }