Example #1
0
        public void Spawn(int index)
        {
            Map map = Map;

            if (map == null || map == Map.Internal || SpawnNamesCount == 0 || index >= SpawnNamesCount || Parent != null)
            {
                return;
            }

            Defrag();

            if (CheckSpawnerFull())
            {
                return;
            }

            ISpawnable spawned = CreateSpawnedObject(index);

            if (spawned == null)
            {
                return;
            }

            spawned.Spawner = this;
            m_Spawned.Add(spawned);

            Point3D loc = (spawned is BaseVendor ? this.Location : GetSpawnPosition(spawned));

            spawned.OnBeforeSpawn(loc, map);
            spawned.MoveToWorld(loc, map);
            spawned.OnAfterSpawn();

            if (spawned is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)spawned;

                if (m_WalkingRange >= 0)
                {
                    bc.RangeHome = m_WalkingRange;
                }
                else
                {
                    bc.RangeHome = m_HomeRange;
                }

                bc.CurrentWayPoint = m_WayPoint;

                bc.SeeksHome = m_MobilesSeekHome;

                if (m_Team > 0)
                {
                    bc.Team = m_Team;
                }

                bc.Home = (m_UsesSpawnerHome) ? this.HomeLocation : bc.Location;
            }

            InvalidateProperties();
        }
Example #2
0
        public void Spawn(SpawnObject so)
        {
            Map map = Map;

            if (map == null || map == Map.Internal || SpawnObjectCount == 0 || so == null || Parent != null ||
                GetSpawnCount(so) >= so.MaxCount)
            {
                return;
            }

            Defrag();

            if (CheckSpawnerFull())
            {
                return;
            }

            ISpawnable spawned = CreateSpawnedObject(so);

            if (spawned == null)
            {
                return;
            }

            spawned.Spawner = this;
            so.SpawnedObjects.Add(spawned);

            Point3D loc = (spawned is BaseVendor ? Location : GetSpawnPosition(spawned));

            spawned.OnBeforeSpawn(loc, map);

            spawned.MoveToWorld(loc, map);

            if (spawned is BaseCreature bc)
            {
                bc.RangeHome = m_WalkingRange >= 0 ? m_WalkingRange : m_HomeRange;

                bc.CurrentWayPoint = WayPoint;

                if (m_Team > 0)
                {
                    bc.Team = m_Team;
                }

                bc.Home = HomeLocation;
            }

            if (spawned is Mobile m)
            {
                m.GuardImmune = GuardImmune;
            }

            spawned.OnAfterSpawn();

            InvalidateProperties();
        }
Example #3
0
        protected virtual ISpawnable Spawn()
        {
            if (!CanSpawn())
            {
                return(null);
            }

            Map map = this.Map;

            ISpawnable spawnable = ConstructSpawnableObject();

            if (spawnable != null)
            {
                Point3D loc = map.GetSpawnPosition(this.Location, m_SpawnRange);

                spawnable.OnBeforeSpawn(loc, map);
                spawnable.MoveToWorld(loc, map);

                if (spawnable is BaseCreature)
                {
                    BaseCreature bc = (BaseCreature)spawnable;

                    bc.Home            = this.Location;
                    bc.RangeHome       = this.HomeRange;
                    bc.CurrentWayPoint = this.WayPoint;
                    bc.CantWalk        = this.CantWalk;
                    bc.Blessed         = this.Blessed;
                    bc.Team            = this.Team;

                    if (this.Blessed)
                    {
                        bc.Tamable = false;
                    }

                    if (this.Murderer)
                    {
                        bc.Kills = 100;
                    }
                }

                this.OnAfterSpawn(spawnable);

                spawnable.OnAfterSpawn();
            }

            return(spawnable);
        }