Example #1
0
        protected virtual void AddHelper(BaseCreature bc, bool initial)
        {
            if (initial)
            {
                if (InitialSpawn == null)
                {
                    InitialSpawn = new List <BaseCreature>();
                }

                if (!InitialSpawn.Contains(bc))
                {
                    InitialSpawn.Add(bc);
                }
            }
            else
            {
                if (SummonedHelpers == null)
                {
                    SummonedHelpers = new List <BaseCreature>();
                }

                if (!SummonedHelpers.Contains(bc))
                {
                    SummonedHelpers.Add(bc);
                }
            }
        }
Example #2
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            SpawnLocation = reader.ReadPoint3D();

            int count = reader.ReadInt();

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    BaseCreature summon = reader.ReadMobile() as BaseCreature;

                    if (summon != null)
                    {
                        if (SummonedHelpers == null)
                        {
                            SummonedHelpers = new List <BaseCreature>();
                        }

                        SummonedHelpers.Add(summon);
                    }
                }
            }

            count = reader.ReadInt();

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    BaseCreature summon = reader.ReadMobile() as BaseCreature;

                    if (summon != null)
                    {
                        if (InitialSpawn == null)
                        {
                            InitialSpawn = new List <BaseCreature>();
                        }

                        InitialSpawn.Add(summon);
                    }
                }
            }

            _NextSpecial = DateTime.UtcNow;
        }
Example #3
0
        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);
            writer.Write(0);

            writer.Write(SpawnLocation);

            writer.Write(SummonedHelpers == null ? 0 : SummonedHelpers.Count);

            if (SummonedHelpers != null)
            {
                SummonedHelpers.ForEach(m => writer.Write(m));
            }

            writer.Write(InitialSpawn == null ? 0 : InitialSpawn.Count);

            if (InitialSpawn != null)
            {
                InitialSpawn.ForEach(m => writer.Write(m));
            }
        }
Example #4
0
        public override void OnThink()
        {
            base.OnThink();

            if (Blessed)
            {
                if (InitialSpawn != null)
                {
                    if (InitialSpawn.All(s => s.Deleted))
                    {
                        ColUtility.Free(InitialSpawn);
                        InitialSpawn = null;

                        Blessed = false;
                    }
                }
                else
                {
                    Blessed = false;
                }
            }

            if (Combatant == null)
            {
                if (SpawnLocation != Point3D.Zero &&
                    _LastActivity > DateTime.MinValue &&
                    _LastActivity + TimeSpan.FromHours(2) < DateTime.UtcNow)
                {
                    Delete();
                }

                return;
            }

            _LastActivity = DateTime.UtcNow;

            if (_NextSpecial < DateTime.UtcNow && 0.25 > Utility.RandomDouble())
            {
                if (Utility.RandomBool())
                {
                    Mobile target = GetTeleportTarget();

                    if (target != null)
                    {
                        Summon(target);
                    }
                }
                else
                {
                    int  baseDamage = 100;
                    bool switched   = false;

                    PlaySound(0x20D);

                    foreach (Mobile m in SpellHelper.AcquireIndirectTargets(this, Location, Map, 10).OfType <Mobile>())
                    {
                        int range = (int)GetDistanceToSqrt(m);

                        if (range < 1)
                        {
                            range = 1;
                        }
                        if (range > 4)
                        {
                            range = 4;
                        }

                        m.PlaySound(0x20D);
                        AOS.Damage(this, m, baseDamage / range, 0, 0, 0, 0, 0, 100, 0);

                        if (!switched && 0.2 > Utility.RandomDouble())
                        {
                            Combatant = m;
                            switched  = true;
                        }
                    }
                }

                _NextSpecial = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(30, 60));
            }

            if (Map != null && SpawnLocation != Point3D.Zero && !Utility.InRange(Location, SpawnLocation, 25))
            {
                MoveToWorld(SpawnLocation, Map);
            }
        }