Ejemplo n.º 1
0
        private void SetNightMode(TR2CombinedLevel level)
        {
            foreach (TR2Room room in level.Data.Rooms)
            {
                room.Darken();
            }

            // Replace any entities that don't "make sense" at night
            List <TR2Entity> entities = level.Data.Entities.ToList();

            // A list of item locations to choose from
            List <TR2Entity> items = entities.Where
                                     (
                e =>
                TR2EntityUtilities.IsAmmoType((TR2Entities)e.TypeID) ||
                TR2EntityUtilities.IsGunType((TR2Entities)e.TypeID) ||
                TR2EntityUtilities.IsUtilityType((TR2Entities)e.TypeID)
                                     ).ToList();

            foreach (TR2Entities entityToReplace in _entitiesToReplace.Keys)
            {
                IEnumerable <TR2Entity> ents = entities.Where(e => e.TypeID == (short)entityToReplace);
                foreach (TR2Entity entity in ents)
                {
                    TR2Entity item = items[_generator.Next(0, items.Count)];
                    entity.TypeID     = (short)_entitiesToReplace[entityToReplace];
                    entity.Room       = item.Room;
                    entity.X          = item.X;
                    entity.Y          = item.Y;
                    entity.Z          = item.Z;
                    entity.Intensity1 = item.Intensity1;
                    entity.Intensity2 = item.Intensity2;
                }
            }

            // Hide any static meshes
            if (_staticMeshesToHide.ContainsKey(level.Name))
            {
                List <TRStaticMesh> staticMeshes = level.Data.StaticMeshes.ToList();
                foreach (uint meshID in _staticMeshesToHide[level.Name])
                {
                    TRStaticMesh mesh = staticMeshes.Find(m => m.ID == meshID);
                    if (mesh != null)
                    {
                        mesh.NonCollidable = true;
                        mesh.Visible       = false;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void CleanPlaneCargo()
        {
            //In relation to #66 to ensure successive randomizations don't pollute the entity list
            List <TR2Entity> Entities = _levelInstance.Entities.ToList();

            int index = Entities.FindIndex(e => (e.Room == 1 && TR2EntityUtilities.IsAmmoType((TR2Entities)e.TypeID)));

            while (index != -1 && index < Entities.Count)
            {
                Entities.RemoveAt(index);
                _levelInstance.NumEntities--;
                index = Entities.FindIndex(e => (e.Room == 1 && TR2EntityUtilities.IsAmmoType((TR2Entities)e.TypeID)));
            }

            _levelInstance.Entities = Entities.ToArray();
        }
Ejemplo n.º 3
0
        private void PopulateHSHCloset()
        {
            List <TR2Entities> replacementWeapons = TR2EntityUtilities.GetListOfGunTypes();

            if (_levelInstance.Script.RemovesWeapons)
            {
                replacementWeapons.Add(TR2Entities.Pistols_S_P);
            }

            // Pick a new weapon, but exclude the grenade launcher because it affects the kill
            // count. Also exclude the harpoon as neither it nor the grenade launcher can break
            // Lara's bedroom window, and the enemy there may have been randomized to one without
            // a gun. Probably not a softlock scenario but safer to exclude for now.
            TR2Entities replacementWeapon;

            do
            {
                replacementWeapon = replacementWeapons[_generator.Next(0, replacementWeapons.Count)];
            }while (replacementWeapon == TR2Entities.GrenadeLauncher_S_P || replacementWeapon == TR2Entities.Harpoon_S_P);

            TR2Entities replacementAmmo = GetWeaponAmmo(replacementWeapon);

            List <TR2Entity> ents = _levelInstance.Data.Entities.ToList();

            foreach (TR2Entity entity in ents)
            {
                if (entity.Room != 57)
                {
                    continue;
                }

                TR2Entities entityType = (TR2Entities)entity.TypeID;
                if (TR2EntityUtilities.IsGunType(entityType))
                {
                    entity.TypeID = (short)replacementWeapon;
                }
                else if (TR2EntityUtilities.IsAmmoType(entityType) && replacementWeapon != TR2Entities.Pistols_S_P)
                {
                    entity.TypeID = (short)replacementAmmo;
                }
            }
        }
Ejemplo n.º 4
0
        private void CleanUnarmedPistolLocation(Location levelPistolLocation)
        {
            //In relation to #66 to ensure successive randomizations don't pollute the entity list
            List <TR2Entity> entities = _levelInstance.Entities.ToList();

            // We need to ensure x,y,z also match rather than just the room as TRGE could have added pistols
            // (which may then have been randomized and/or ammo added) to a room that already had other ammo pickups.
            IEnumerable <TR2Entity> existingInjections = entities.Where
                                                         (
                e =>
                TR2EntityUtilities.IsAmmoType((TR2Entities)e.TypeID) &&
                e.Room == levelPistolLocation.Room &&
                e.X == levelPistolLocation.X &&
                e.Y == levelPistolLocation.Y &&
                e.Z == levelPistolLocation.Z
                                                         );

            if (existingInjections.Count() > 0)
            {
                // For Rig, if it's no longer unarmed, TRGE will have added UZI clips where the pistols normally
                // would be. This is to preserve item indices as the pistols have index 4 - to remove them completely
                // would mean anything that points to higher item indices (triggers etc) would need to change. The clips
                // can be safely randomized - it's just the index that needs to remain the same.
                if (_scriptedLevelInstance.Is(LevelNames.RIG))
                {
                    TR2Entity cargoEntity = existingInjections.FirstOrDefault();
                    entities.RemoveAll(e => existingInjections.Contains(e) && e != cargoEntity);
                }
                else
                {
                    entities.RemoveAll(e => existingInjections.Contains(e));
                }
                _levelInstance.NumEntities = (uint)entities.Count;
                _levelInstance.Entities    = entities.ToArray();
            }
        }
Ejemplo n.º 5
0
        private void RandomizeEnemyTypes(string lvl)
        {
            List <TR2Entities> EnemyTypes = TR2EntityUtilities.GetEnemyTypeDictionary()[lvl];

            for (int i = 0; i < _levelInstance.Entities.Count(); i++)
            {
                //#60 - Ice Palace - Room 143 chicken man must remain to avoid softlock.
                if (lvl == LevelNames.CHICKEN &&
                    _levelInstance.Entities[i].Room == 143 &&
                    _levelInstance.Entities[i].TypeID == (int)TR2Entities.BirdMonster)
                {
                    continue;
                }

                //#45 - Check to see if any items are at the same location as the enemy.
                //If there are we need to ensure that the new random enemy type is one that can drop items.
                List <TR2Entity> SharedItems = new List <TR2Entity>(Array.FindAll(_levelInstance.Entities, e => ((e.X == _levelInstance.Entities[i].X) &&
                                                                                                                 (e.Y == _levelInstance.Entities[i].Y) && (e.Z == _levelInstance.Entities[i].Z))));

                List <TR2Entities> DroppableEnemies = TR2EntityUtilities.DroppableEnemyTypes()[lvl];

                //Is it an entity we are keen on replacing?
                if (EnemyTypes.Contains((TR2Entities)_levelInstance.Entities[i].TypeID))
                {
                    //Do multiple entities share one location?
                    if ((SharedItems.Count > 1) && (DroppableEnemies.Count != 0))
                    {
                        //Are any entities sharing a location a droppable pickup?
                        bool IsPickupItem = false;

                        foreach (TR2Entity ent in SharedItems)
                        {
                            TR2Entities EntType = (TR2Entities)ent.TypeID;

                            IsPickupItem = (TR2EntityUtilities.IsAmmoType(EntType)) ||
                                           (TR2EntityUtilities.IsGunType(EntType)) ||
                                           (TR2EntityUtilities.IsKeyItemType(EntType));

                            if (IsPickupItem)
                            {
                                break;
                            }
                        }

                        //Generate a location
                        _levelInstance.Entities[i].TypeID = (short)EnemyTypes[_generator.Next(0, EnemyTypes.Count)];

                        //Do we need to ensure the enemy can drop the item on the same tile?
                        if (!TR2EntityUtilities.CanDropPickups((TR2Entities)_levelInstance.Entities[i].TypeID) && IsPickupItem)
                        {
                            //Ensure the new random entity can drop pickups
                            _levelInstance.Entities[i].TypeID = (short)DroppableEnemies[_generator.Next(0, DroppableEnemies.Count)];
                        }
                    }
                    else
                    {
                        _levelInstance.Entities[i].TypeID = (short)EnemyTypes[_generator.Next(0, EnemyTypes.Count)];
                    }
                }
            }
        }