예제 #1
0
    private int PartitionSpawnZones(List <SpawnZone> spawnZones, int left, int right)
    {
        SpawnZone pivot = spawnZones[left];

        while (true)
        {
            while (mapGenerator.GetRegionSize(spawnZones[left].region) > mapGenerator.GetRegionSize(pivot.region))
            {
                left++;
            }

            while (mapGenerator.GetRegionSize(spawnZones[right].region) < mapGenerator.GetRegionSize(pivot.region))
            {
                right--;
            }

            if (left < right)
            {
                SpawnZone temp = spawnZones[left];
                spawnZones[left]  = spawnZones[right];
                spawnZones[right] = temp;

                if (mapGenerator.GetRegionSize(spawnZones[left].region) == mapGenerator.GetRegionSize(spawnZones[right].region))
                {
                    left++;
                }
            }
            else
            {
                return(right);
            }
        }
    }
예제 #2
0
 void Awake()
 {
     if (!_zone)
     {
         _zone = GetComponentInParent <SpawnZone>();
     }
 }
예제 #3
0
 private void Start()
 {
     if (spawnZone == null)
     {
         spawnZone = GameObject.Find("SpawnZone")?.GetComponent <SpawnZone>();
     }
 }
예제 #4
0
        void SceneLoader_OnSceneLoaded(On.SceneLoader.orig_OnSceneLoaded orig, UnityEngine.SceneManagement.Scene scene, UnityEngine.SceneManagement.LoadSceneMode loadSceneMode)
        {
            orig(scene, loadSceneMode);

            if (scene.name.Equals(ELevel.Level_06_A_BambooCreek.ToString() + "_Build"))
            {
                try {
                    spawner = UnityEngine.Object.Instantiate(Resources.FindObjectsOfTypeAll <TurtleManRangedSpawner>()[0]);
                    Vector3 newPos = new Vector3(475f, -90.5f);
                    spawner.transform.position = newPos;
                    Manager <Level> .Instance.LevelRooms["460492-92-76"].roomObjects.Add(spawner.gameObject);

                    SpawnZone zone = UnityEngine.Object.Instantiate(Resources.FindObjectsOfTypeAll <SkeloutSpawner>()[0].transform.parent.parent.gameObject).GetComponent <SpawnZone>();
                    zone.transform.position = newPos;
                    Manager <Level> .Instance.LevelRooms["460492-92-76"].roomObjects.Add(zone.spawners[0].gameObject);
                    zone.spawnZoneRect     = new Rect(new Vector2(460, -92), new Vector2(32, 16));
                    zone.spawnLaneCount    = 3;
                    zone.spawnInterval     = .5f;
                    zone.maxSpawnedObjects = 30;

                    CourierLogger.Log("HarderBosses", "All bamboo creek spawners placed");
                } catch (Exception e) {
                    Console.WriteLine("Exception while placing bamboo creek spawners");
                    CourierLogger.LogDetailed(e, "HarderBosses");
                }
            }
        }
    // Creates the Spawn Zone and populates its traversable zone tile list
    // by checking all the tiles within its radius
    SpawnZone CreateSpawnZone(Pos candidate, float spawnZoneRadius)
    {
        SpawnZone  spawnZone = new SpawnZone(candidate, spawnZoneRadius, mapManager.GetTileRegion(candidate));
        List <Pos> zoneTiles = new List <Pos>();

        int cellX            = candidate.x;
        int cellY            = candidate.y;
        int numOfCellsToScan = Mathf.CeilToInt(spawnZoneRadius);

        int searchStartX = Mathf.Max(0, cellX - numOfCellsToScan);
        int searchEndX   = Mathf.Min(cellX + numOfCellsToScan, width - 1);
        int searchStartY = Mathf.Max(0, cellY - numOfCellsToScan);
        int searchEndY   = Mathf.Min(cellY + numOfCellsToScan, height - 1);

        for (int x = searchStartX; x <= searchEndX; x++)
        {
            for (int y = searchStartY; y <= searchEndY; y++)
            {
                Pos tile = new Pos(x, y);
                if (mapManager.IsTraversable(tile) && !mapManager.IsOccupied(tile))
                {
                    int a = cellX - x;
                    int b = cellY - y;
                    if (Mathf.Sqrt(a * a + b * b) <= spawnZoneRadius)
                    {
                        zoneTiles.Add(tile);
                    }
                }
            }
        }
        spawnZone.SetZoneTiles(zoneTiles);

        return(spawnZone);
    }
예제 #6
0
    private Queue <SpawnZone> GetEnemiesSpawnZoneAndSetCurrentSpawnZone()
    {
        GameObject[] enemiesSpawnZones = GameObject.FindGameObjectsWithTag("EnemySpawn");
        if (enemiesSpawnZones.Length == 0)
        {
            Debug.Log("No enemySpawnZone");
            return(null);
        }
        System.Array.Sort(enemiesSpawnZones, CompareObNames);
        Queue <SpawnZone> queue = new Queue <SpawnZone>(enemiesSpawnZones.Length);

        // For each spawn zone : get the beginning and the ending of the zone, put it in an SpawnZone object and add it to the queue
        foreach (GameObject EnemySpawnZone in enemiesSpawnZones)
        {
            SpawnZone spawnZone         = (SpawnZone)SpawnZone.CreateInstance("SpawnZone");
            Vector3   beginningPosition = EnemySpawnZone.transform.localPosition;
            spawnZone.beginning = new Vector2(beginningPosition.x, beginningPosition.y);
            Vector3 zoneDimensions = EnemySpawnZone.transform.localScale;
            spawnZone.ending = new Vector2(beginningPosition.x + zoneDimensions.x, beginningPosition.y + zoneDimensions.y);
            queue.Enqueue(spawnZone);
        }

        currentSpawnZone = queue.Dequeue();
        return(queue);
    }
예제 #7
0
 public Boundary(SpawnZone upper_left_zone, SpawnZone upper_right_zone, SpawnZone lower_left_zone, SpawnZone lower_right_zone)
 {
     this.upper_left_zone  = upper_left_zone;
     this.upper_right_zone = upper_right_zone;
     this.lower_left_zone  = lower_left_zone;
     this.lower_right_zone = lower_right_zone;
 }
예제 #8
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            m_Blockade = reader.ReadBool();
            m_Zone     = (SpawnZone)reader.ReadInt();
            m_StopTime = reader.ReadDateTime();
            m_Galleon  = reader.ReadItem() as BaseGalleon;
            m_OnCourse = reader.ReadBool();

            int count = reader.ReadInt();

            for (int i = 0; i < count; i++)
            {
                Mobile mob = reader.ReadMobile() as Mobile;
                if (mob != null && !mob.Deleted && mob.Alive)
                {
                    m_Crew.Add(mob);
                }
            }

            if (!m_Blockade)
            {
                ResumeCourseTimed(TimeSpan.FromSeconds(15), true);
            }

            m_NextMoveCheck  = DateTime.UtcNow;
            m_NextCannonShot = DateTime.UtcNow;
        }
 public EnemySpawnController(IInstantiator instantiator,
                             SpawnZone spawnzone, WorldData worldData)
 {
     _instantiator = instantiator;
     _spawnzone    = spawnzone;
     _spawns       = worldData.Spawns.OrderBy(x => x.secondsTillSpawn).ToList();
     _nextSpawn    = _spawns[_nextSpawnId].secondsTillSpawn;
 }
예제 #10
0
    private void SpawnBoss()
    {
        SpawnZone zone = SpawnZoneConfiguration.Instance.Zones.Find(z => z.Tag == EZoneTag.NORTH);

        m_boss = Instantiate(m_actualLevel.BossPrefab, zone.Area.transform.position, Quaternion.identity);

        StartCoroutine(_SpawnBossEffect());
    }
    // Creates a list of Spawn Zones of varrying sizes in the map
    private void GenerateSpawnZones()
    {
        regions = mapGenerator.getRegions();
        List <Pos> regionTiles = new List <Pos>();

        int[,] grid = new int[width, height];
        int distanceBetweenZones    = 0;
        int spawnZoneRadius         = 0;
        int radiusAndDistance       = 0;
        int numOfSpawnZonesInRegion = 0;

        // Iterates through each region
        foreach (Region region in regions)
        {
            numOfSpawnZonesInRegion = 0;
            regionTiles             = region.GetRegionTiles();

            // Checks through each tile in the region
            foreach (Pos tile in regionTiles)
            {
                distanceBetweenZones = rng.Next(Mathf.Max(1, Mathf.RoundToInt(this.distanceBetweenZones / 2f)), Mathf.RoundToInt(this.distanceBetweenZones));
                spawnZoneRadius      = rng.Next(Mathf.RoundToInt(lowerRadius), Mathf.RoundToInt(upperRadius + 1));
                radiusAndDistance    = distanceBetweenZones + spawnZoneRadius;
                bool valid = true;

                while (!IsValid(tile, spawnZones, grid, spawnZoneRadius))
                {
                    // If smallest radius doesn't work, then it isn't a valid spawn point
                    if (spawnZoneRadius == lowerRadius)
                    {
                        valid = false;
                        break;
                    }
                    else
                    {
                        // Try a smaller radius
                        spawnZoneRadius--;
                    }
                }

                if (valid)
                {
                    SpawnZone spawnZone = CreateSpawnZone(tile, spawnZoneRadius);
                    // Checks if the number of zone tiles is acceptable
                    if (spawnZone.GetNumberOfUnpopulatedTilesInZone() >= minimumNumberOfTilesInSpawnZone &&
                        spawnZone.GetNumberOfUnpopulatedTilesInZone() <= maximumNumberOfTilesInSpawnZone)
                    {
                        // Spawn Zone is accepted and added to the list
                        spawnZones.Add(spawnZone);
                        grid[tile.x, tile.y] = spawnZones.Count;
                        numOfSpawnZonesInRegion++;
                    }
                }
            }

            region.numOfSpawnZones = numOfSpawnZonesInRegion;
        }
    }
예제 #12
0
        public void RemoveMerchant(BaseShipCaptain merchant)
        {
            SpawnZone zone = merchant.Zone;

            if (m_ActiveZones[zone].Contains(merchant))
            {
                m_ActiveZones[zone].Remove(merchant);
            }
        }
예제 #13
0
 public Squadron(EnemyType enemyType, SpawnPattern spawnPattern, SpawnZone spawnZone = SpawnZone.Top, int count = -1, float spawnDelay = -1, bool edgeBuffer = false)
 {
     _enemyType  = enemyType;
     _pattern    = spawnPattern;
     _zone       = spawnZone;
     _count      = count;
     _spawnDelay = spawnDelay;
     _edgeBuffer = edgeBuffer;
 }
예제 #14
0
        public SpawnDefinition(Rectangle2D spawnreg, Point2D[][] waypoints, SpawnZone type, Map map)
        {
            m_SpawnRegion = spawnreg;
            m_Waypoints   = waypoints;
            m_Zone        = type;
            m_Map         = map;

            BountyQuestSpawner.AddZone(this);
        }
예제 #15
0
 public override void ResetEnemy(SpawnZone newSpawnZone, Vector3 newPos)
 {
     base.ResetEnemy(newSpawnZone, newPos);
     spawningZone = newSpawnZone;
     // Reset Position and Velocity
     transform.position = newPos;
     myRb2D.position    = newPos;
     StopVel();
 }
 // Called after being Fetched
 public virtual void ResetEnemy(SpawnZone newSpawnZone, Vector3 newPos)
 {
     // reset Hp
     hp = originalHp;
     // Attach new spawn zone
     spawningZone = newSpawnZone;
     // Reset Position
     myRb2D.position    = newPos;
     transform.position = newPos;
 }
예제 #17
0
        private void OnTriggerEnter(Collider other)
        {
            if (other.tag == "Weapon")
            {
                this.enableInformation();

                UInt64 monsterId = (stateManager as MonsterStateManager).info.id;
                SpawnZone.takeDamage(monsterId);
            }
        }
예제 #18
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            m_MaxFel    = reader.ReadInt();
            m_MaxTram   = reader.ReadInt();
            m_MaxTokuno = reader.ReadInt();
            m_SpawnTime = reader.ReadTimeSpan();
            m_Active    = reader.ReadBool();

            int count = reader.ReadInt();

            for (int i = 0; i < count; i++)
            {
                SpawnZone zone = (SpawnZone)reader.ReadInt();
                int       c    = reader.ReadInt();
                for (int j = 0; j < c; j++)
                {
                    BaseShipCaptain capt = reader.ReadMobile() as BaseShipCaptain;
                    if (capt != null && !capt.Deleted && capt.Alive)
                    {
                        m_ActiveZones[zone].Add(capt);
                    }
                }
            }

            count = reader.ReadInt();
            for (int i = 0; i < count; i++)
            {
                Mobile mob = reader.ReadMobile();
                int    amt = reader.ReadInt();

                if (mob != null && !mob.Deleted)
                {
                    m_Bounties.Add(mob, amt);
                }
            }

            if (version == 0)
            {
                m_MaxTram   = 1;
                m_MaxFel    = 1;
                m_MaxTokuno = 1;

                RemoveSpawns();
            }

            m_Instance = this;

            if (m_Active)
            {
                m_Timer = Timer.DelayCall(m_SpawnTime, m_SpawnTime, new TimerCallback(OnTick));
            }
        }
예제 #19
0
 private void Start()
 {
     if (zone == null)
     {
         zone = GetComponentInChildren <SpawnZone>();
     }
     if (lastSpawn < 0)
     {
         lastSpawn = 1f;
     }
 }
예제 #20
0
    public Bee[] SpawnBees(SpawnZone zone)
    {
        SpawnArea area = spawnAreas[(int)zone];

        Bee[] beeList = new Bee[area.nodes.Length];
        for (int i = 0; i < area.nodes.Length; i++)
        {
            beeList[i] = SpawnBee(area.nodes[i].transform.position);
        }
        return(beeList);
    }
    // Reset Function
    public override void ResetEnemy(SpawnZone newSpawnZone, Vector3 newPos)
    {
        // play sound
        SoundManager.instance.PlaySound("BirdWings");

        // Reset Shared Data
        base.ResetEnemy(newSpawnZone, newPos);

        // Get your new waypoint here..
        SetWaypointGroup(newSpawnZone.GetComponent <SpawnZone>().GetRandomPath());
    }
예제 #22
0
    // Start is called before the first frame update
    void Start()
    {
        Time.timeScale = 1;
        Application.targetFrameRate = 60;

        playerRB = Player.GetComponent <Rigidbody2D>();

        gameHandlerScript     = FindObjectOfType <GameHandler>();
        asteroidSpawnerScript = FindObjectOfType <GameAsteroidSpawner>();
        spawnZoneScript       = FindObjectOfType <SpawnZone>();
    }
예제 #23
0
 private void SpawnPlayers()
 {
     /* Spawn players in at a random position within a random spawn zone
      * since the player objects are already created, you only need to move them */
     foreach (AgentManager player in m_GameManager.Get_Players())
     {
         SpawnZone Spawner = Get_Random_Spawn_Point();
         player.Set_Spawn_Point(Spawner.gameObject);
         Vector3 new_position = Spawner.Get_Unique_Random_Spawn_Point();
         player.Set_Position(new_position);
     }
 }
예제 #24
0
 public bool NextZone()
 {
     if (spawnZones.Count > 0)
     {
         currentSpawnZone = spawnZones.Dequeue();
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #25
0
    public void Setup(SpawnZone spawnZone, float speed, List <GameObject> targetCities)
    {
        this.spawnZone    = spawnZone;
        this.speed        = speed;
        this.targetCities = targetCities;

        power = Random.Range(1, 4);

        target   = GetTarget(spawnZone);
        endScale = transform.localScale.x * 1.5f;

        isSetup = true;
    }
예제 #26
0
    private void Spawn()
    {
        m_currentIndex++;
        WaveElement element = m_waveElements[m_currentIndex];

        // Get Zone
        SpawnZone zone = SpawnZoneConfiguration.Instance.Zones.Find(z => z.Tag == element.SpawnZone);

        // Spawn object
        m_lastSpawned = Instantiate(element.UnitPrefab, zone.GetRandomPointInZone(), Quaternion.identity);

        m_lastSpawnTime = Time.time;
        m_nextSpawn     = Time.time + element.TimeBeforeNext;
    }
예제 #27
0
        public void RemoveBounty(BaseShipCaptain pirate)
        {
            SpawnZone zone = pirate.Zone;

            if (m_ActiveZones[zone].Contains(pirate))
            {
                m_ActiveZones[zone].Remove(pirate);
            }

            if (m_Bounties.ContainsKey(pirate))
            {
                m_Bounties.Remove(pirate);
            }
        }
예제 #28
0
    private Transform GetTarget(SpawnZone spawnZone)
    {
        if (targetCities.Count > 0)
        {
            GameObject targetCity = targetCities[Random.Range(0, targetCities.Count)];
            return(targetCity.transform);
        }
        else
        {
            StartCoroutine(DeathRoutine());
            return(transform);
        }

        /*Bounds spawnBounds = spawnZone.localCol.bounds;
         *
         * // TODO(Chris) Only allow collison on citizen layer
         * var hitObjs = Physics2D.OverlapBoxAll(spawnBounds.center, spawnBounds.size, 0);
         *
         * // TODO(Chris) Performance ??
         * int citizensCount = 0;
         * for ( int i = 0; i < hitObjs.Length; i++ )
         * {
         *  if ( hitObjs[i].GetComponent<Citizen>() )
         *  {
         *      citizensCount++;
         *      break;
         *  }
         * }
         *
         * if ( citizensCount > 0 )
         * {
         *  Citizen citizen;
         *  do
         *  {
         *      int randIndex = Random.Range(0, hitObjs.Length);
         *      citizen = hitObjs[randIndex].GetComponent<Citizen>();
         *  }
         *  while ( citizen == null );
         *
         *  return citizen.transform;
         * }
         * else
         * {
         *  Debug.LogWarning("No citizens in spawn, I die");
         *  StartCoroutine(DeathRoutine());
         *
         *  return transform;
         * }*/
    }
예제 #29
0
 private void Load_Security_AI()
 {
     for (int i = 0; i < m_NumberOfSecurityAI; i++)
     {
         SpawnZone    Spawner = Get_Random_Spawn_Point();
         AgentManager newAI   = new AgentManager();
         newAI.Set_Spawn_Point(Spawner.gameObject);
         //create players
         newAI.Set_Instance(Instantiate(m_SecurityAI_Prefab, Spawner.Get_Unique_Random_Spawn_Point(), newAI.Get_Spawn_Point().transform.rotation) as GameObject);
         newAI.Initialise_Agent(Agent_Type.Security_AI, 0);
         newAI.Enable();
         m_SecurityAI.Add(newAI);
         m_AllAI.Add(newAI);
     }
 }
    void Awake()
    {
        // Create empty object to contain all spawned enemies
        _enemyEmptyParent = new GameObject("enemies");
        _enemyEmptyParent.transform.parent = this.transform;

        // Auto-find closest zone
        if (_getClosestZone)
        {
            SpawnZone[] zones   = FindObjectsOfType <SpawnZone>();
            SpawnZone   nearest = null;

            // Find closest zone
            if (zones.Length > 0)
            {
                float smallestDistance = float.MaxValue;
                foreach (SpawnZone z in zones)
                {
                    // Get distance to the zone
                    float dist = Vector3.Distance(z.transform.position, transform.position);

                    if (dist < smallestDistance)
                    {
                        smallestDistance = dist;
                        nearest          = z;
                    }
                }
            }

            if (nearest == null)
            {
                Debug.LogError("No Spawn Zones were found. Right click in the scene heirarchy to create a new zone.");
            }

            _zone = nearest;
        }

        // Register this script with the zone, or remove this script if there is no zone specified
        if (_zone)
        {
            _zone.AddNode(this);
        }
        else
        {
            Debug.LogError("SpawnNode is not assigned to a SpawnZone. The node will be destroyed.", this);
            Destroy(this);
        }
    }
 public void AddSpawnZone(int region, SpawnZone spawn)
 {
     _spawnZones.Add(region, spawn);
 }
예제 #32
0
        /// <summary>
        /// The h 2 spawn info.
        /// </summary>
        /// <param name="map">The map.</param>
        /// <remarks></remarks>
        public void H2SpawnInfo(Map map)
        {
            map.OpenMap(MapTypes.Internal);

            // find default mc model
            map.BR.BaseStream.Position = map.MetaInfo.Offset[0] + 308;
            int tempr = map.BR.ReadInt32() - map.SecondaryMagic;
            map.BR.BaseStream.Position = tempr + 4;
            int tempbipdtag = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
            //map.CloseMap();
            int bipdmodeltag = map.Functions.FindModelByBaseClass(tempbipdtag);

            int ctfmodeltag = -1;
            int ballmodeltag = -1;
            int juggernautdmodeltag = -1;
            int assultmodeltag = -1;

            #region  //// Find objective models ////

            try
            {
                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position =
                    map.MetaInfo.Offset[
                        map.Functions.ForMeta.FindByNameAndTagType("mulg", "multiplayer\\multiplayer_globals")] + 12;
                tempr = map.BR.ReadInt32();
                if (tempr != 0)
                {
                    tempr -= map.SecondaryMagic;
                    map.BR.BaseStream.Position = tempr + 4;
                    int tempCtftag = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    map.BR.BaseStream.Position = tempr + 12;
                    int tempBalltag = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());

                    map.BR.BaseStream.Position = tempr + 36;
                    int tempHillShader = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());

                    // I believe the Hill Shader above is not used, but just in case. Otherwise, load the usual one below
                    if (tempHillShader == -1)
                    {
                        map.BR.BaseStream.Position = tempr + 1332;
                        int tempr2 = map.BR.ReadInt32();
                        if (tempr2 != 0)
                        {
                            tempr2 -= map.SecondaryMagic;
                            map.BR.BaseStream.Position = tempr2 + 196;
                            tempHillShader = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                        }
                    }

                    map.BR.BaseStream.Position = tempr + 52;
                    int tempJuggernauttag = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    map.BR.BaseStream.Position = tempr + 60;
                    int tempAssaulttag = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    //map.CloseMap();

                    ctfmodeltag = map.Functions.FindModelByBaseClass(tempCtftag);
                    ballmodeltag = map.Functions.FindModelByBaseClass(tempBalltag);

                    // *** This is not right. It's a shader, not a model. But I don't know how to display a shader...
                    hillshadertag = map.Functions.ForMeta.FindMetaByID(tempHillShader);

                    juggernautdmodeltag = map.Functions.FindModelByBaseClass(tempJuggernauttag);
                    assultmodeltag = map.Functions.FindModelByBaseClass(tempAssaulttag);
                }
            }
            catch (Exception e)
            {
               System.Windows.Forms.MessageBox.Show("Error loading an objective model (CTF/Juggernaut/Assault/Bomb)\n" + e.Message);
            }

            #endregion

            #region //// Player Spawns ////

            try
            {
                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 256;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < tempc; x++)
                {
                    map.BR.BaseStream.Position = tempr + (52 * x);
                    PlayerSpawn ps = new PlayerSpawn();
                    ps.Read(map);

                    ps.ModelTagNumber = bipdmodeltag;
                    ps.ModelName = map.FileNames.Name[ps.ModelTagNumber];

                    Spawn.Add(ps);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading player spawns", e);
            }

            #endregion

            #region //// trigger volumes / death zones ////

            try
            {
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 264;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < tempc; x++)
                {
                    DeathZone tv = new DeathZone();
                    map.BR.BaseStream.Position = tempr + (68 * x);
                    tv.Read(map);

                    Spawn.Add(tv);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading death zones", e);
            }

            #endregion

            #region //// lights ////

            try
            {
                //// palette ////
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 240;
                int[] temppalette = new int[map.BR.ReadInt32()];
                int[] temppalette2 = new int[temppalette.Length];
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < temppalette.Length; x++)
                {
                    map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                    int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    temppalette2[x] = tempbase;
                    temppalette[x] = tempbase;
                }

                //// placement ////
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 232;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < tempc; x++)
                {
                    map.BR.BaseStream.Position = tempr + (108 * x);
                    short tempshort = map.BR.ReadInt16();

                    LightSpawn ls = new LightSpawn();
                    map.BR.BaseStream.Position = tempr + (108 * x);
                    ls.Read(map);

                    if (ls.PaletteIndex == -1)
                    {
                        continue;
                    }

                    int nameIndex = temppalette2[tempshort];
                    if (nameIndex >= 0)
                        ls.TagPath = map.FileNames.Name[nameIndex];
                    ls.ModelTagNumber = temppalette[tempshort];
                    if (ls.ModelTagNumber == -1)
                    {
                        continue;
                    }

                    ls.ModelName = map.FileNames.Name[ls.ModelTagNumber];
                    Spawn.Add(ls);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading Lights", e);
            }

            #endregion

            #region //// sounds ////

            try
            {
                //// Sound Scenery palette ////
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 224;

                int[] temppalette = new int[map.BR.ReadInt32()];
                int[] temppalette2 = new int[temppalette.Length];
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < temppalette.Length; x++)
                {
                    map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                    int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    temppalette2[x] = tempbase;
                    temppalette[x] = tempbase;
                }

                //// placement ////
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 216;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < tempc; x++)
                {
                    SoundSpawn ss = new SoundSpawn();
                    map.BR.BaseStream.Position = tempr + (80 * x);
                    ss.Read(map);

                    if (ss.PaletteIndex == -1 || temppalette2[ss.PaletteIndex] == -1)
                    {
                        ss.TagPath = NullTags;
                    }
                    else
                    {
                        ss.TagPath = map.FileNames.Name[temppalette2[ss.PaletteIndex]];
                    }

                    ss.ModelTagNumber = temppalette[ss.PaletteIndex];
                    if (ss.ModelTagNumber == -1)
                    {
                        // { continue; }
                        ss.ModelName = null;
                    }
                    else
                    {
                        ss.ModelName = map.FileNames.Name[ss.ModelTagNumber];
                    }

                    Spawn.Add(ss);
                }

            }
            catch (Exception e)
            {
                throw new Exception("Error loading sounds", e);
            }

            #endregion

            #region //// objectives ////

            try
            {
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 280;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < tempc; x++)
                {
                    ObjectiveSpawn os = new ObjectiveSpawn();
                    map.BR.BaseStream.Position = tempr + (32 * x);
                    os.Read(map);

                    if (os.ObjectiveType == ObjectiveSpawn.ObjectiveTypeEnum.OddballSpawn && ballmodeltag != -1)
                    {
                        os.ModelTagNumber = ballmodeltag;
                    }
                    else if (os.ObjectiveType == ObjectiveSpawn.ObjectiveTypeEnum.CTFRespawn && ctfmodeltag != -1)
                    {
                        os.ModelTagNumber = ctfmodeltag;
                    }
                    else if (
                        os.ObjectiveType.ToString().StartsWith(
                            ObjectiveSpawn.ObjectiveTypeEnum.KingOfTheHill_1.ToString().Substring(0, 13)) &&
                        ctfmodeltag != -1)
                    {
                        os.ModelTagNumber = ctfmodeltag;
                    }
                    else if (os.ObjectiveType == ObjectiveSpawn.ObjectiveTypeEnum.AssaultRespawn && assultmodeltag != -1)
                    {
                        os.ModelTagNumber = assultmodeltag;
                    }
                    else
                    {
                        os.ModelTagNumber = bipdmodeltag;
                    }

                    os.ModelName = map.FileNames.Name[os.ModelTagNumber];
                    Spawn.Add(os);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading lights", e);
            }
            #endregion

            #region //// vehicles ////

            try
            {
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 120;
                int[] temppalette = new int[map.BR.ReadInt32()];
                int[] temppalette2 = new int[temppalette.Length];
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < temppalette.Length; x++)
                {
                    //map.OpenMap(MapTypes.Internal);
                    map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                    int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    //map.CloseMap();
                    temppalette2[x] = tempbase;
                    temppalette[x] = map.Functions.FindModelByBaseClass(tempbase);
                }

                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 112;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;

                for (int x = 0; x < tempc; x++)
                {
                    VehicleSpawn vs = new VehicleSpawn();
                    map.BR.BaseStream.Position = tempr + (84 * x);
                    vs.Read(map);

                    if (vs.PaletteIndex == -1)
                    {
                        continue;
                    }

                    vs.TagPath = map.FileNames.Name[temppalette2[vs.PaletteIndex]];
                    vs.ModelTagNumber = temppalette[vs.PaletteIndex];
                    if (vs.ModelTagNumber == -1)
                    {
                        continue;
                    }

                    vs.ModelName = map.FileNames.Name[vs.ModelTagNumber];
                    Spawn.Add(vs);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading vehicles", e);
            }

            #endregion

            #region //// equipment ////

            try
            {
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 136;
                int[] temppalette = new int[map.BR.ReadInt32()];
                int[] temppalette2 = new int[temppalette.Length];
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < temppalette.Length; x++)
                {
                    //map.OpenMap(MapTypes.Internal);
                    map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                    int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    //map.CloseMap();
                    temppalette2[x] = tempbase;
                    temppalette[x] = map.Functions.FindModelByBaseClass(tempbase);
                }

                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 128;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;

                for (int x = 0; x < tempc; x++)
                {
                    EquipmentSpawn es = new EquipmentSpawn();
                    map.BR.BaseStream.Position = tempr + (56 * x);
                    es.Read(map);

                    if (es.PaletteIndex == -1)
                    {
                        continue;
                    }

                    es.TagPath = map.FileNames.Name[temppalette2[es.PaletteIndex]];
                    es.ModelTagNumber = temppalette[es.PaletteIndex];
                    if (es.ModelTagNumber == -1)
                    {
                        continue;
                    }

                    es.ModelName = map.FileNames.Name[es.ModelTagNumber];
                    Spawn.Add(es);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading equipment", e);
            }

            #endregion

            #region //// bipeds ////

            try
            {
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 104;
                int[] temppalette = new int[map.BR.ReadInt32()];
                int[] temppalette2 = new int[temppalette.Length];
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < temppalette.Length; x++)
                {
                    //map.OpenMap(MapTypes.Internal);
                    map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                    int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    //map.CloseMap();
                    temppalette2[x] = tempbase;
                    temppalette[x] = map.Functions.FindModelByBaseClass(tempbase);
                }

                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 96;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;

                for (int x = 0; x < tempc; x++)
                {
                    BipedSpawn bs = new BipedSpawn();
                    map.BR.BaseStream.Position = tempr + (84 * x);
                    bs.Read(map);

                    if (bs.PaletteIndex == -1)
                    {
                        continue;
                    }

                    bs.TagPath = map.FileNames.Name[temppalette2[bs.PaletteIndex]];
                    bs.ModelTagNumber = temppalette[bs.PaletteIndex];
                    if (bs.ModelTagNumber == -1)
                    {
                        continue;
                    }

                    bs.ModelName = map.FileNames.Name[bs.ModelTagNumber];
                    Spawn.Add(bs);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading Bipeds", e);
            }

            #endregion

            #region //// control ////

            try
            {
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 192;
                int[] temppalette = new int[map.BR.ReadInt32()];
                int[] temppalette2 = new int[temppalette.Length];
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < temppalette.Length; x++)
                {
                    //map.OpenMap(MapTypes.Internal);
                    map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                    int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    //map.CloseMap();
                    temppalette2[x] = tempbase;
                    temppalette[x] = map.Functions.FindModelByBaseClass(tempbase);
                }

                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 184;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;

                for (int x = 0; x < tempc; x++)
                {
                    ControlSpawn cs = new ControlSpawn();
                    map.BR.BaseStream.Position = tempr + (68 * x);
                    cs.Read(map);

                    if (cs.PaletteIndex == -1)
                    {
                        continue;
                    }

                    cs.TagPath = map.FileNames.Name[temppalette2[cs.PaletteIndex]];
                    cs.ModelTagNumber = temppalette[cs.PaletteIndex];
                    if (cs.ModelTagNumber == -1)
                    {
                        continue;
                    }

                    cs.ModelName = map.FileNames.Name[cs.ModelTagNumber];
                    Spawn.Add(cs);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading Control", e);
            }

            #endregion

            #region //// machines ////

            try
            {
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 176;
                int[] temppalette = new int[map.BR.ReadInt32()];
                int[] temppalette2 = new int[temppalette.Length];
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < temppalette.Length; x++)
                {
                    //map.OpenMap(MapTypes.Internal);
                    map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                    int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    //map.CloseMap();
                    temppalette2[x] = tempbase;
                    temppalette[x] = map.Functions.FindModelByBaseClass(tempbase);
                }

                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 168;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;

                for (int x = 0; x < tempc; x++)
                {
                    MachineSpawn ms = new MachineSpawn();
                    map.BR.BaseStream.Position = tempr + (72 * x);
                    ms.Read(map);

                    if (ms.PaletteIndex == -1)
                    {
                        continue;
                    }

                    if (temppalette2[ms.PaletteIndex] == -1 || temppalette[ms.PaletteIndex] == -1)
                    {
                        continue;
                    }

                    ms.TagPath = map.FileNames.Name[temppalette2[ms.PaletteIndex]];
                    ms.ModelTagNumber = temppalette[ms.PaletteIndex];
                    if (ms.ModelTagNumber == -1)
                    {
                        continue;
                    }

                    ms.ModelName = map.FileNames.Name[ms.ModelTagNumber];
                    Spawn.Add(ms);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading Machines", e);
            }

            #endregion

            #region //// scenery ////

            try
            {
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 88;
                int[] temppalette = new int[map.BR.ReadInt32()];
                int[] temppalette2 = new int[temppalette.Length];
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < temppalette.Length; x++)
                {
                    //map.OpenMap(MapTypes.Internal);
                    map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                    int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    //map.CloseMap();
                    temppalette2[x] = tempbase;
                    temppalette[x] = map.Functions.FindModelByBaseClass(tempbase);
                }

                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 80;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;

                for (int x = 0; x < tempc; x++)
                {
                    ScenerySpawn ss = new ScenerySpawn();
                    map.BR.BaseStream.Position = tempr + (92 * x);
                    ss.Read(map);

                    if (ss.PaletteIndex == -1)
                    {
                        continue;
                    }

                    if (temppalette2[ss.PaletteIndex] == -1 || temppalette[ss.PaletteIndex] == -1)
                    {
                        continue;
                    }

                    ss.TagPath = map.FileNames.Name[temppalette2[ss.PaletteIndex]];
                    ss.ModelTagNumber = temppalette[ss.PaletteIndex];
                    if (ss.ModelTagNumber == -1)
                    {
                        continue;
                    }

                    ss.ModelName = map.FileNames.Name[ss.ModelTagNumber];
                    Spawn.Add(ss);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading Scenery", e);
            }

            #endregion

            #region //// weapons ////

            try
            {
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 152;
                int[] temppalette = new int[map.BR.ReadInt32()];
                int[] temppalette2 = new int[temppalette.Length];
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < temppalette.Length; x++)
                {
                    //map.OpenMap(MapTypes.Internal);
                    map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                    int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    //map.CloseMap();
                    temppalette2[x] = tempbase;
                    temppalette[x] = map.Functions.FindModelByBaseClass(tempbase);
                }

                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 144;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;

                for (int x = 0; x < tempc; x++)
                {
                    WeaponSpawn ws = new WeaponSpawn();
                    map.BR.BaseStream.Position = tempr + (84 * x);
                    ws.Read(map);

                    if (ws.PaletteIndex == -1)
                    {
                        continue;
                    }

                    ws.TagPath = map.FileNames.Name[temppalette2[ws.PaletteIndex]];
                    ws.ModelTagNumber = temppalette[ws.PaletteIndex];
                    if (ws.ModelTagNumber == -1)
                    {
                        continue;
                    }

                    ws.ModelName = map.FileNames.Name[ws.ModelTagNumber];
                    Spawn.Add(ws);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading Weapons", e);
            }

            #endregion

            #region //// obstacles ////

            try
            {
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 816;
                int[] temppalette = new int[map.BR.ReadInt32()];
                int[] temppalette2 = new int[temppalette.Length];
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < temppalette.Length; x++)
                {
                    //map.OpenMap(MapTypes.Internal);
                    map.BR.BaseStream.Position = tempr + (x * 40) + 4;
                    int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    //map.CloseMap();
                    temppalette2[x] = tempbase;
                    temppalette[x] = map.Functions.FindModelByBaseClass(tempbase);
                }

                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 808;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;

                for (int x = 0; x < tempc; x++)
                {
                    ObstacleSpawn os = new ObstacleSpawn();
                    map.BR.BaseStream.Position = tempr + (76 * x);
                    os.Read(map);

                    if (os.PaletteIndex == -1)
                    {
                        continue;
                    }

                    if (temppalette2[os.PaletteIndex] == -1)
                    {
                        continue;
                    }

                    os.TagPath = map.FileNames.Name[temppalette2[os.PaletteIndex]];
                    os.ModelTagNumber = temppalette[os.PaletteIndex];
                    if (os.ModelTagNumber == -1)
                    {
                        continue;
                    }

                    os.ModelName = map.FileNames.Name[os.ModelTagNumber];
                    Spawn.Add(os);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading Obstacles", e);
            }

            #endregion

            #region //// collections ////

            try
            {
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 288;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;

                for (int x = 0; x < tempc; x++)
                {
                    //map.OpenMap(MapTypes.Internal);
                    Collection collect = new Collection();
                    map.BR.BaseStream.Position = tempr + (144 * x);
                    collect.Read(map);

                    // ID Type
                    if (collect.TagPath == NullTags)
                    {
                        continue;
                    }

                    if (collect.ModelTagNumber == -1)
                    {
                        continue;
                    }

                    collect.ModelName = map.FileNames.Name[collect.ModelTagNumber];
                    Spawn.Add(collect);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading Collections", e);
            }

            #endregion

            #region //// cameras ////

            try
            {
                //map.OpenMap(MapTypes.Internal);
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 488;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;

                for (int x = 0; x < tempc; x++)
                {
                    //map.OpenMap(MapTypes.Internal);
                    CameraSpawn cs = new CameraSpawn();
                    map.BR.BaseStream.Position = tempr + (64 * x);
                    cs.Read(map);

                    Spawn.Add(cs);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading Collections", e);
            }

            #endregion

            #region //// AI_Squads ////

            try
            {
                // Reading Character Palette
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 376;
                int[] temppalette = new int[map.BR.ReadInt32()];
                int[] temppalette2 = new int[temppalette.Length];
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;
                for (int x = 0; x < temppalette.Length; x++)
                {
                    map.BR.BaseStream.Position = tempr + (x * 8) + 4;
                    int tempbase = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32());
                    temppalette2[x] = tempbase;
                    temppalette[x] = map.Functions.FindModelByBaseClass(tempbase);
                }

                // Reading ai squads reflexive
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 352;
                int tempc = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;

                for (int x = 0; x < tempc; x++)
                {
                    // Reads AI Squad character index
                    map.BR.BaseStream.Position = tempr + (x * 116) + 54;
                    short charIndex = map.BR.ReadInt16();

                    // Reading locations sub reflexive
                    map.BR.BaseStream.Position = tempr + (x * 116) + 72;
                    int locc = map.BR.ReadInt32();
                    int locr = map.BR.ReadInt32() - map.SecondaryMagic;

                    for (int y = 0; y < locc; y++)
                    {
                        AI_Squads ai = new AI_Squads(x);
                        map.BR.BaseStream.Position = locr + (100 * y);
                        ai.Read(map);

                        if (charIndex != -1)
                        {
                            ai.TagPath = map.FileNames.Name[temppalette2[charIndex]];
                            ai.ModelTagNumber = temppalette[charIndex];
                            if (ai.ModelTagNumber == -1)
                            {
                                continue;
                            }

                            // ai.ModelName = map.FileNames.Name[vs.ModelTagNumber];
                            Spawn.Add(ai);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error loading AI Squads", e);
            }

            #endregion

            #region //// Spawn Zones ////

            try
            {
                // Reading Spawn Zone Section
                // 792 = Spawn Data
                map.BR.BaseStream.Position = map.MetaInfo.Offset[3] + 792;
                int SpawnDataCount = map.BR.ReadInt32();
                tempr = map.BR.ReadInt32() - map.SecondaryMagic;

                #region //// Inital Spawn Zones ////
                // 88 = Static Initial Spawn Zones
                map.BR.BaseStream.Position = tempr + 88;
                int[] temppalette = new int[map.BR.ReadInt32()];
                int initialR = map.BR.ReadInt32() - map.SecondaryMagic;

                for (int x = 0; x < temppalette.Length; x++)
                {
                    // Each Initial Spawn Zone chunk = 48 bytes
                    map.BR.BaseStream.Position = initialR + (x * 48);
                    SpawnZone spawnZone = new SpawnZone(SpawnZoneType.Inital);
                    spawnZone.Read(map);

                    Spawn.Add(spawnZone);
                }
                #endregion

                #region //// Respawn Zones ////
                // 80 = Static Respawn Zones
                map.BR.BaseStream.Position = tempr + 80;
                temppalette = new int[map.BR.ReadInt32()];
                int respawnR = map.BR.ReadInt32() - map.SecondaryMagic;

                for (int x = 0; x < temppalette.Length; x++)
                {
                    // Each Respawn Zone chunk = 48 bytes
                    map.BR.BaseStream.Position = respawnR + (x * 48);
                    SpawnZone spawnZone = new SpawnZone(SpawnZoneType.Respawn);
                    spawnZone.Read(map);

                    Spawn.Add(spawnZone);
                }
                #endregion
            }
            catch (Exception e)
            {
                throw new Exception("Error loading Spawn Zones (Initial)", e);
            }
            #endregion

            map.CloseMap();
        }
예제 #33
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            m_Blockade = reader.ReadBool();
            m_Zone = (SpawnZone)reader.ReadInt();
            m_StopTime = reader.ReadDateTime();
            m_Galleon = reader.ReadItem() as BaseGalleon;
            m_OnCourse = reader.ReadBool();

            int count = reader.ReadInt();
            for (int i = 0; i < count; i++)
            {
                Mobile mob = reader.ReadMobile() as Mobile;
                if (mob != null && !mob.Deleted && mob.Alive)
                    m_Crew.Add(mob);
            }

            if (!m_Blockade)
                ResumeCourseTimed(TimeSpan.FromSeconds(15), true);

            m_NextMoveCheck = DateTime.UtcNow;
            m_NextCannonShot = DateTime.UtcNow;
        }
예제 #34
0
        public void SpawnPirateAndGalleon(SpawnZone zone, Map map)
        {
            SpawnDefinition def = m_Zones[zone];

            if (map != Map.Internal && map != null)
            {
                Rectangle2D rec = def.SpawnRegion;
                OrcishGalleon gal = new OrcishGalleon(Direction.North);
                PirateCaptain pirate = new PirateCaptain(gal);
                pirate.Zone = zone;
                gal.Owner = pirate;
                FillHold(gal);
                Point3D p = Point3D.Zero;
                bool spawned = false;
                for(int i = 0; i < 25; i++)
                {
                    int x = Utility.Random(rec.X, rec.Width);
                    int y = Utility.Random(rec.Y, rec.Height);
                    p = new Point3D(x, y, -5);

                    if (gal.CanFit(p, map, gal.ItemID))
                    {
                        spawned = true;
                        break;
                    }
                }

                if (!spawned)
                {
                    gal.Delete();
                    pirate.Delete();
                    return;
                }

                int gold = Utility.RandomMinMax(GoldRange[0], GoldRange[1]);
                gal.MoveToWorld(p, map);
                gal.AutoAddCannons(pirate);
                pirate.MoveToWorld(new Point3D(gal.X, gal.Y - 1, gal.ZSurface), map);

                int crewCount = Utility.RandomMinMax(3, 5);

                for (int i = 0; i < crewCount; i++)
                {
                    Mobile crew = new PirateCrew();

                    if (i == 0)
                        crew.Title = "the orc captain";

                    pirate.AddToCrew(crew);
                    crew.MoveToWorld(new Point3D(gal.X + Utility.RandomList(-1, 1), gal.Y + Utility.RandomList(-1, 0, 1), gal.ZSurface), map);
                }

                Point2D[] course = def.GetRandomWaypoints();
                gal.BoatCourse = new BoatCourse(gal, new List<Point2D>(def.GetRandomWaypoints()));

                gal.NextNavPoint = 0;
                gal.StartCourse(false, false);
                /*MapItem mapItem = new MapItem(map);

                if (map == Map.Tokuno)
                    mapItem.SetDisplay(5, 5, 1448 - 32, 1448 - 10, 400, 400);
                else
                    mapItem.SetDisplay(5, 5, 5120 - 32, 4096 - 10, 400, 400);

                for (int i = 0; i < course.Length; i++)
                    mapItem.AddWorldPin(course[i].X, course[i].Y);

                pirate.Backpack.DropItem(mapItem);

                gal.MapItem = mapItem;*/

                //mapItem.Name = "Pirate Map";

                //if (0.90 > Utility.RandomDouble())
                //    mapItem.Movable = false;

                m_Bounties.Add(pirate, gold);
                m_ActiveZones[zone].Add(pirate);
            }
        }
예제 #35
0
        public SpawnDefinition(Rectangle2D spawnreg, Point2D[][] waypoints, SpawnZone type, Map map)
        {
            m_SpawnRegion = spawnreg;
            m_Waypoints = waypoints;
            m_Zone = type;
            m_Map = map;

            BountyQuestSpawner.AddZone(this);
        }
예제 #36
0
        public void SpawnMerchantAndGalleon(SpawnZone zone, Map map)
        {
            SpawnDefinition def = m_Zones[zone];

            if (map != Map.Internal && map != null)
            {
                Rectangle2D rec = def.SpawnRegion;
                bool garg = Utility.RandomBool();
                BaseGalleon gal;
                Point3D p = Point3D.Zero;
                bool spawned = false;

                if (garg)
                    gal = new GargishGalleon(Direction.North);
                else
                    gal = new TokunoGalleon(Direction.North);

                MerchantCaptain captain = new MerchantCaptain(gal);

                for(int i = 0; i < 25; i++)
                {
                    int x = Utility.Random(rec.X, rec.Width);
                    int y = Utility.Random(rec.Y, rec.Height);
                    p = new Point3D(x, y, -5);

                    if (gal.CanFit(p, map, gal.ItemID))
                    {
                        spawned = true;
                        break;
                    }
                }

                if (!spawned)
                {
                    gal.Delete();
                    captain.Delete();
                    return;
                }

                gal.Owner = captain;
                FillHold(gal);
                captain.Zone = zone;
                gal.MoveToWorld(p, map);
                gal.AutoAddCannons(captain);
                captain.MoveToWorld(new Point3D(gal.X, gal.Y - 1, gal.ZSurface), map);

                int crewCount = Utility.RandomMinMax(3, 5);

                for (int i = 0; i < crewCount; i++)
                {
                    Mobile crew = new MerchantCrew();
                    captain.AddToCrew(crew);
                    crew.MoveToWorld(new Point3D(gal.X + Utility.RandomList(-1, 1), gal.Y + Utility.RandomList(-1, 0, 1), gal.ZSurface), map);
                }

                Point2D[] course = def.GetRandomWaypoints();
                gal.BoatCourse = new BoatCourse(gal, new List<Point2D>(def.GetRandomWaypoints()));

                gal.NextNavPoint = 0;
                gal.StartCourse(false, false);

                m_ActiveZones[zone].Add(captain);
            }
        }