private void PlaceRandomCorpses(Dungeon dungeon, RoomHandler currentRoom, ExpandObjectDatabase objectDatabase, int RandomObjectsPlaced, int RandomObjectsSkipped) { PrototypeDungeonRoom.RoomCategory roomCategory = currentRoom.area.PrototypeRoomCategory; int MaxObjectsPerRoom = 12; if (currentRoom != null && !string.IsNullOrEmpty(currentRoom.GetRoomName()) && !currentRoom.IsMaintenanceRoom() && !currentRoom.GetRoomName().StartsWith("Boss Foyer")) { if (Random.value <= 0.6f && roomCategory != PrototypeDungeonRoom.RoomCategory.ENTRANCE && roomCategory != PrototypeDungeonRoom.RoomCategory.REWARD) { List <IntVector2> m_CachedPositions = new List <IntVector2>(); int MaxCorpseCount = MaxObjectsPerRoom; if (Random.value <= 0.3f) { MaxCorpseCount = 20; } else if (roomCategory == PrototypeDungeonRoom.RoomCategory.BOSS) { MaxCorpseCount = 17; } int CorpseCount = Random.Range(6, MaxObjectsPerRoom); for (int i = 0; i < CorpseCount; i++) { IntVector2?RandomVector = GetRandomAvailableCell(dungeon, currentRoom, m_CachedPositions); if (RandomVector.HasValue) { if (Random.value <= 0.08f) { GameObject SkeletonCorpse = Instantiate(ExpandPrefabs.Sarco_Skeleton, RandomVector.Value.ToVector3(), Quaternion.identity); SkeletonCorpse.GetComponent <tk2dSprite>().HeightOffGround = -1; SkeletonCorpse.GetComponent <tk2dSprite>().UpdateZDepth(); SkeletonCorpse.transform.parent = currentRoom.hierarchyParent; RandomObjectsPlaced++; } else { GameObject WrithingBulletManCorpse = objectDatabase.WrithingBulletman.InstantiateObject(currentRoom, (RandomVector.Value - currentRoom.area.basePosition)); WrithingBulletManCorpse.transform.parent = currentRoom.hierarchyParent; RandomObjectsPlaced++; } if (m_CachedPositions.Count <= 0) { break; } } else { RandomObjectsSkipped++; } } } } }
// Generate a DungeonFlowNode with a default configuration public static DungeonFlowNode GenerateDefaultNode(DungeonFlow targetflow, PrototypeDungeonRoom.RoomCategory roomType, PrototypeDungeonRoom overrideRoom = null, GenericRoomTable overrideTable = null, bool oneWayLoopTarget = false, bool isWarpWingNode = false, string nodeGUID = null, DungeonFlowNode.NodePriority priority = DungeonFlowNode.NodePriority.MANDATORY, float percentChance = 1, bool handlesOwnWarping = true) { try { if (string.IsNullOrEmpty(nodeGUID)) { nodeGUID = Guid.NewGuid().ToString(); } DungeonFlowNode m_CachedNode = new DungeonFlowNode(targetflow) { isSubchainStandin = false, nodeType = DungeonFlowNode.ControlNodeType.ROOM, roomCategory = roomType, percentChance = percentChance, priority = priority, overrideExactRoom = overrideRoom, overrideRoomTable = overrideTable, capSubchain = false, subchainIdentifier = string.Empty, limitedCopiesOfSubchain = false, maxCopiesOfSubchain = 1, subchainIdentifiers = new List <string>(0), receivesCaps = false, isWarpWingEntrance = isWarpWingNode, handlesOwnWarping = handlesOwnWarping, forcedDoorType = DungeonFlowNode.ForcedDoorType.NONE, loopForcedDoorType = DungeonFlowNode.ForcedDoorType.NONE, nodeExpands = false, initialChainPrototype = "n", chainRules = new List <ChainRule>(0), minChainLength = 3, maxChainLength = 8, minChildrenToBuild = 1, maxChildrenToBuild = 1, canBuildDuplicateChildren = false, guidAsString = nodeGUID, parentNodeGuid = string.Empty, childNodeGuids = new List <string>(0), loopTargetNodeGuid = string.Empty, loopTargetIsOneWay = oneWayLoopTarget, flow = targetflow }; return(m_CachedNode); } catch (Exception e) { ETGModConsole.Log(e.ToString()); return(null); } }
// Generate a DungeonFlowNode with a default configuration public static DungeonFlowNode GenerateDefaultNode(DungeonFlow targetflow, PrototypeDungeonRoom.RoomCategory roomType, PrototypeDungeonRoom overrideRoom = null, GenericRoomTable overrideTable = null, bool oneWayLoopTarget = false, bool isWarpWingNode = false, string nodeGUID = null) { DungeonFlowNode m_CachedNode = new DungeonFlowNode(targetflow); m_CachedNode.isSubchainStandin = false; m_CachedNode.nodeType = DungeonFlowNode.ControlNodeType.ROOM; m_CachedNode.roomCategory = roomType; m_CachedNode.percentChance = 1f; m_CachedNode.priority = DungeonFlowNode.NodePriority.MANDATORY; m_CachedNode.overrideExactRoom = overrideRoom; m_CachedNode.overrideRoomTable = overrideTable; m_CachedNode.capSubchain = false; m_CachedNode.subchainIdentifier = string.Empty; m_CachedNode.limitedCopiesOfSubchain = false; m_CachedNode.maxCopiesOfSubchain = 1; m_CachedNode.subchainIdentifiers = new List <string>(0); m_CachedNode.receivesCaps = false; m_CachedNode.isWarpWingEntrance = isWarpWingNode; if (isWarpWingNode) { m_CachedNode.handlesOwnWarping = true; } else { m_CachedNode.handlesOwnWarping = false; } m_CachedNode.forcedDoorType = DungeonFlowNode.ForcedDoorType.NONE; m_CachedNode.loopForcedDoorType = DungeonFlowNode.ForcedDoorType.NONE; m_CachedNode.nodeExpands = false; m_CachedNode.initialChainPrototype = "n"; m_CachedNode.chainRules = new List <ChainRule>(0); m_CachedNode.minChainLength = 3; m_CachedNode.maxChainLength = 8; m_CachedNode.minChildrenToBuild = 1; m_CachedNode.maxChildrenToBuild = 1; m_CachedNode.canBuildDuplicateChildren = false; m_CachedNode.parentNodeGuid = string.Empty; m_CachedNode.childNodeGuids = new List <string>(0); m_CachedNode.loopTargetNodeGuid = string.Empty; m_CachedNode.loopTargetIsOneWay = oneWayLoopTarget; if (nodeGUID == null) { m_CachedNode.guidAsString = Guid.NewGuid().ToString(); } else { m_CachedNode.guidAsString = nodeGUID; } m_CachedNode.flow = targetflow; return(m_CachedNode); }
public static DungeonFlowNode GenerateFlowNode(DungeonFlow flow, PrototypeDungeonRoom.RoomCategory category, PrototypeDungeonRoom overrideRoom = null, GenericRoomTable overrideRoomTable = null, bool loopTargetIsOneWay = false, bool isWarpWing = false, bool handlesOwnWarping = true, float weight = 1f, DungeonFlowNode.NodePriority priority = DungeonFlowNode.NodePriority.MANDATORY, string guid = "") { if (string.IsNullOrEmpty(guid)) { guid = Guid.NewGuid().ToString(); } DungeonFlowNode node = new DungeonFlowNode(flow) { isSubchainStandin = false, nodeType = DungeonFlowNode.ControlNodeType.ROOM, roomCategory = category, percentChance = weight, priority = priority, overrideExactRoom = overrideRoom, overrideRoomTable = overrideRoomTable, capSubchain = false, subchainIdentifier = string.Empty, limitedCopiesOfSubchain = false, maxCopiesOfSubchain = 1, subchainIdentifiers = new List <string>(0), receivesCaps = false, isWarpWingEntrance = isWarpWing, handlesOwnWarping = handlesOwnWarping, forcedDoorType = DungeonFlowNode.ForcedDoorType.NONE, loopForcedDoorType = DungeonFlowNode.ForcedDoorType.NONE, nodeExpands = false, initialChainPrototype = "n", chainRules = new List <ChainRule>(0), minChainLength = 3, maxChainLength = 8, minChildrenToBuild = 1, maxChildrenToBuild = 1, canBuildDuplicateChildren = false, guidAsString = guid, parentNodeGuid = string.Empty, childNodeGuids = new List <string>(0), loopTargetNodeGuid = string.Empty, loopTargetIsOneWay = loopTargetIsOneWay, flow = flow }; return(node); }
public void PlaceRandomEnemies(Dungeon dungeon, int currentFloor) { if (!dungeon.IsGlitchDungeon) { return; } List <string> BannedRooms = new List <string>(); foreach (WeightedRoom wRoom in ExpandPrefabs.MegaMiniBossRoomTable.includedRooms.elements) { if (wRoom.room != null) { BannedRooms.Add(wRoom.room.name); } } foreach (WeightedRoom wRoom in ExpandPrefabs.MegaBossRoomTable.includedRooms.elements) { if (wRoom.room != null) { BannedRooms.Add(wRoom.room.name); } } PlayerController player = GameManager.Instance.PrimaryPlayer; int RandomEnemiesPlaced = 0; int RandomEnemiesSkipped = 0; int MaxEnemies = 20; float GlitchedBossOdds = 0.15f; float BonusGlitchEnemyOdds = 0.05f; if (dungeon.IsGlitchDungeon) { MaxEnemies = 65; GlitchedBossOdds = 0.3f; BonusGlitchEnemyOdds = 0.28f; } if (dungeon.data.rooms == null | dungeon.data.rooms.Count <= 0) { return; } foreach (RoomHandler currentRoom in dungeon.data.rooms) { PrototypeDungeonRoom.RoomCategory roomCategory = currentRoom.area.PrototypeRoomCategory; try { if (currentRoom != null && !string.IsNullOrEmpty(currentRoom.GetRoomName()) && currentRoom.HasActiveEnemies(RoomHandler.ActiveEnemyType.RoomClear) && !currentRoom.IsMaintenanceRoom() && !currentRoom.IsSecretRoom && !currentRoom.IsWinchesterArcadeRoom && !currentRoom.IsGunslingKingChallengeRoom && !currentRoom.GetRoomName().StartsWith("Boss Foyer") && !BannedRooms.Contains(currentRoom.GetRoomName())) { if (roomCategory != PrototypeDungeonRoom.RoomCategory.BOSS && roomCategory != PrototypeDungeonRoom.RoomCategory.ENTRANCE && roomCategory != PrototypeDungeonRoom.RoomCategory.REWARD && roomCategory != PrototypeDungeonRoom.RoomCategory.EXIT) { List <IntVector2> m_CachedPositions = new List <IntVector2>(); IntVector2? RandomGlitchEnemyVector = GetRandomAvailableCell(dungeon, currentRoom, m_CachedPositions); IntVector2? RandomGlitchEnemyVector2 = null; IntVector2? RandomGlitchEnemyVector3 = null; IntVector2? RandomGlitchEnemyVector4 = null; if (m_CachedPositions.Count > 0) { RandomGlitchEnemyVector2 = GetRandomAvailableCell(dungeon, currentRoom, m_CachedPositions); } if (m_CachedPositions.Count > 0) { RandomGlitchEnemyVector3 = GetRandomAvailableCell(dungeon, currentRoom, m_CachedPositions, ExitClearence: 13); } if (m_CachedPositions.Count > 0) { RandomGlitchEnemyVector4 = GetRandomAvailableCell(dungeon, currentRoom, m_CachedPositions); } if (RandomGlitchEnemyVector.HasValue) { m_GlitchEnemyDatabase.SpawnRandomGlitchEnemy(currentRoom, RandomGlitchEnemyVector.Value, false, AIActor.AwakenAnimationType.Spawn); } else { RandomEnemiesSkipped++; } if (RandomGlitchEnemyVector2.HasValue && Random.value <= BonusGlitchEnemyOdds) { m_GlitchEnemyDatabase.SpawnRandomGlitchEnemy(currentRoom, RandomGlitchEnemyVector2.Value, false, AIActor.AwakenAnimationType.Spawn); } else { RandomEnemiesSkipped++; } if (RandomGlitchEnemyVector3.HasValue && Random.value <= GlitchedBossOdds) { m_GlitchEnemyDatabase.SpawnRandomGlitchBoss(currentRoom, RandomGlitchEnemyVector3.Value, false, AIActor.AwakenAnimationType.Spawn); } if (RandomGlitchEnemyVector4.HasValue && Random.value <= GlitchedBossOdds) { if (Random.value <= 0.65f) { m_GlitchEnemyDatabase.SpawnGlitchedObjectAsEnemy(currentRoom, RandomGlitchEnemyVector4.Value, false, AIActor.AwakenAnimationType.Spawn); } else { m_GlitchEnemyDatabase.SpawnGlitchedPlayerAsEnemy(currentRoom, RandomGlitchEnemyVector4.Value, false, AIActor.AwakenAnimationType.Spawn); } } RandomEnemiesPlaced++; if (RandomEnemiesPlaced + RandomEnemiesSkipped >= MaxEnemies) { break; } } } } catch (System.Exception ex) { if (ExpandStats.debugMode) { ETGModConsole.Log("[DEBUG] Exception while setting up or placing enemy for current room" /*+ currentRoom.GetRoomName()*/, false); } if (ExpandStats.debugMode) { ETGModConsole.Log("[DEBUG] Skipping current room...", false); } if (ExpandStats.debugMode) { ETGModConsole.Log(ex.Message + ex.StackTrace + ex.Source, false); } continue; } AIActor[] allAIActors = FindObjectsOfType <AIActor>(); if (allAIActors != null && allAIActors.Length > 0) { foreach (AIActor enemy in allAIActors) { if (enemy.name.ToLower().StartsWith("corrupted")) { RoomHandler ParentRoom = enemy.transform.position.GetAbsoluteRoom(); if (ParentRoom != null) { if (!enemy.gameObject.transform.parent) { enemy.transform.parent = ParentRoom.hierarchyParent; } } } } } } if (ExpandStats.debugMode) { ETGModConsole.Log("[DEBUG] Max Number of Glitched Enemies assigned to floor: " + MaxEnemies, false); ETGModConsole.Log("[DEBUG] Number of Glitched Enemies placed: " + RandomEnemiesPlaced, false); ETGModConsole.Log("[DEBUG] Number of Glitched Enemies skipped: " + RandomEnemiesSkipped, false); if (RandomEnemiesPlaced <= 0) { ETGModConsole.Log("[DEBUG] Error: No Glitched Enemies have been placed!", false); } } Destroy(m_GlitchEnemyDatabase); return; }
public void PlaceRandomJunkEnemies(Dungeon dungeon, RoomHandler roomHandler) { if (dungeon.IsGlitchDungeon) { return; } if (dungeon.tileIndices.tilesetId == GlobalDungeonData.ValidTilesets.RATGEON) { return; } if (Random.value <= 0.85f) { return; } int RandomEnemiesPlaced = 0; int RandomEnemiesSkipped = 0; int MaxEnemies = 1; int iterations = 0; if (Random.value <= 0.1f) { MaxEnemies = 2; } if (dungeon.data.rooms == null | dungeon.data.rooms.Count <= 0) { return; } List <int> roomList = Enumerable.Range(0, dungeon.data.rooms.Count).ToList(); roomList = roomList.Shuffle(); if (roomHandler != null) { roomList = new List <int>(new int[] { dungeon.data.rooms.IndexOf(roomHandler) }); } while (iterations < roomList.Count && RandomEnemiesPlaced < MaxEnemies) { RoomHandler currentRoom = dungeon.data.rooms[roomList[iterations]]; PrototypeDungeonRoom.RoomCategory roomCategory = currentRoom.area.PrototypeRoomCategory; try { if (currentRoom != null && !string.IsNullOrEmpty(currentRoom.GetRoomName()) && currentRoom.HasActiveEnemies(RoomHandler.ActiveEnemyType.RoomClear) && !currentRoom.IsMaintenanceRoom() && !currentRoom.IsSecretRoom && !currentRoom.IsWinchesterArcadeRoom && !currentRoom.IsGunslingKingChallengeRoom && !currentRoom.GetRoomName().StartsWith("Boss Foyer") && !currentRoom.GetRoomName().StartsWith(ExpandRoomPrefabs.Expand_Keep_TreeRoom.name) && !currentRoom.GetRoomName().StartsWith(ExpandRoomPrefabs.Expand_Keep_TreeRoom2.name)) { if (roomCategory != PrototypeDungeonRoom.RoomCategory.BOSS && roomCategory != PrototypeDungeonRoom.RoomCategory.ENTRANCE && roomCategory != PrototypeDungeonRoom.RoomCategory.REWARD && roomCategory != PrototypeDungeonRoom.RoomCategory.EXIT) { if (RandomEnemiesPlaced >= MaxEnemies) { break; } List <IntVector2> m_CachedPositions = new List <IntVector2>(); IntVector2? RandomGlitchEnemyVector = GetRandomAvailableCellForEnemy(dungeon, currentRoom, m_CachedPositions); if (RandomGlitchEnemyVector.HasValue) { if (Random.value <= 0.5f) { m_GlitchEnemyDatabase.SpawnGlitchedRaccoon(currentRoom, RandomGlitchEnemyVector.Value, false, AIActor.AwakenAnimationType.Spawn, true); } else { m_GlitchEnemyDatabase.SpawnGlitchedTurkey(currentRoom, RandomGlitchEnemyVector.Value, false, AIActor.AwakenAnimationType.Spawn, true); } } else { RandomEnemiesSkipped++; } RandomEnemiesPlaced++; } } iterations++; } catch (System.Exception ex) { if (ExpandStats.debugMode) { ETGModConsole.Log("[DEBUG] Exception while setting up or placing enemy for current room" /*+ currentRoom.GetRoomName()*/, false); } if (ExpandStats.debugMode) { ETGModConsole.Log("[DEBUG] Skipping current room...", false); } if (ExpandStats.debugMode) { ETGModConsole.Log(ex.Message + ex.StackTrace + ex.Source, false); } if (RandomEnemiesPlaced >= MaxEnemies) { break; } iterations++; } } if (ExpandStats.debugMode) { ETGModConsole.Log("[DEBUG] Max Number of Junk Enemies assigned to floor: " + MaxEnemies, false); ETGModConsole.Log("[DEBUG] Number of Junk Enemies placed: " + RandomEnemiesPlaced, false); ETGModConsole.Log("[DEBUG] Number of Junk Enemies skipped: " + RandomEnemiesSkipped, false); if (RandomEnemiesPlaced <= 0) { ETGModConsole.Log("[DEBUG] Error: No Junk Enemies have been placed!", false); } } if (RandomEnemiesPlaced > 0) { AIActor[] actors = FindObjectsOfType <AIActor>(); if (actors != null & actors.Length > 0) { foreach (AIActor actor in actors) { if (!string.IsNullOrEmpty(actor.ActorName)) { if (actor.ActorName == "Junk Raccoon") { actor.AdditionalSafeItemDrops.Add(PickupObjectDatabase.GetById(127)); if (Random.value <= 0.2f) { actor.AdditionalSafeItemDrops.Add(PickupObjectDatabase.GetById(127)); } else { if (Random.value <= 0.1f) { actor.AdditionalSafeItemDrops.Add(PickupObjectDatabase.GetById(74)); } else { actor.AdditionalSafeItemDrops.Add(PickupObjectDatabase.GetById(85)); } } if (Random.value <= 0.01f) { if (GameManager.Instance.PrimaryPlayer.HasPickupID(641)) { actor.AdditionalSafeItemDrops.Add(PickupObjectDatabase.GetById(74)); } else { actor.AdditionalSafeItemDrops.Add(PickupObjectDatabase.GetById(641)); } } else if (Random.value <= 0.01f) { if (GameManager.Instance.PrimaryPlayer.HasPickupID(580)) { actor.AdditionalSafeItemDrops.Add(PickupObjectDatabase.GetById(74)); } else { actor.AdditionalSafeItemDrops.Add(PickupObjectDatabase.GetById(580)); } } } else if (actor.ActorName == "Junk Turkey") { if (BraveUtility.RandomBool()) { actor.AdditionalSafeItemDrops.Add(PickupObjectDatabase.GetById(600)); } else { actor.AdditionalSafeItemDrops.Add(PickupObjectDatabase.GetById(78)); } } } } } } Destroy(m_GlitchEnemyDatabase); return; }
public static PrototypeDungeonRoom GenerateRoomPrefabFromTexture2D(Texture2D sourceTexture, PrototypeDungeonRoom.RoomCategory roomCategory = PrototypeDungeonRoom.RoomCategory.NORMAL, PrototypeRoomPitEntry.PitBorderType PitBorderType = PrototypeRoomPitEntry.PitBorderType.FLAT, CoreDamageTypes DamageCellsType = CoreDamageTypes.None) { PrototypeDungeonRoom m_NewRoomPrefab = ScriptableObject.CreateInstance <PrototypeDungeonRoom>(); m_NewRoomPrefab.name = "Expand Corrupted Room"; m_NewRoomPrefab.QAID = "FF" + Random.Range(1000, 9999); m_NewRoomPrefab.GUID = System.Guid.NewGuid().ToString(); m_NewRoomPrefab.PreventMirroring = false; m_NewRoomPrefab.category = roomCategory; m_NewRoomPrefab.subCategoryBoss = PrototypeDungeonRoom.RoomBossSubCategory.FLOOR_BOSS; m_NewRoomPrefab.subCategoryNormal = PrototypeDungeonRoom.RoomNormalSubCategory.COMBAT; m_NewRoomPrefab.subCategorySpecial = PrototypeDungeonRoom.RoomSpecialSubCategory.STANDARD_SHOP; m_NewRoomPrefab.subCategorySecret = PrototypeDungeonRoom.RoomSecretSubCategory.UNSPECIFIED_SECRET; m_NewRoomPrefab.exitData = new PrototypeRoomExitData() { exits = new List <PrototypeRoomExit>() }; m_NewRoomPrefab.pits = new List <PrototypeRoomPitEntry>(); m_NewRoomPrefab.placedObjects = new List <PrototypePlacedObjectData>(); m_NewRoomPrefab.placedObjectPositions = new List <Vector2>(); m_NewRoomPrefab.eventTriggerAreas = new List <PrototypeEventTriggerArea>(); m_NewRoomPrefab.roomEvents = new List <RoomEventDefinition>() { new RoomEventDefinition(RoomEventTriggerCondition.ON_ENTER_WITH_ENEMIES, RoomEventTriggerAction.SEAL_ROOM), new RoomEventDefinition(RoomEventTriggerCondition.ON_ENEMIES_CLEARED, RoomEventTriggerAction.UNSEAL_ROOM), }; m_NewRoomPrefab.overriddenTilesets = 0; m_NewRoomPrefab.prerequisites = new List <DungeonPrerequisite>(); m_NewRoomPrefab.InvalidInCoop = false; m_NewRoomPrefab.cullProceduralDecorationOnWeakPlatforms = false; m_NewRoomPrefab.preventAddedDecoLayering = false; m_NewRoomPrefab.precludeAllTilemapDrawing = false; m_NewRoomPrefab.drawPrecludedCeilingTiles = false; m_NewRoomPrefab.preventBorders = false; m_NewRoomPrefab.preventFacewallAO = false; m_NewRoomPrefab.usesCustomAmbientLight = false; m_NewRoomPrefab.customAmbientLight = Color.white; m_NewRoomPrefab.ForceAllowDuplicates = false; m_NewRoomPrefab.injectionFlags = new RuntimeInjectionFlags() { CastleFireplace = false, ShopAnnexed = false }; m_NewRoomPrefab.IsLostWoodsRoom = false; m_NewRoomPrefab.UseCustomMusic = false; m_NewRoomPrefab.UseCustomMusicState = false; m_NewRoomPrefab.CustomMusicEvent = string.Empty; m_NewRoomPrefab.UseCustomMusicSwitch = false; m_NewRoomPrefab.CustomMusicSwitch = string.Empty; m_NewRoomPrefab.overrideRoomVisualTypeForSecretRooms = false; m_NewRoomPrefab.rewardChestSpawnPosition = new IntVector2(6, 14); m_NewRoomPrefab.Width = sourceTexture.width; m_NewRoomPrefab.Height = sourceTexture.height; m_NewRoomPrefab.additionalObjectLayers = new List <PrototypeRoomObjectLayer>(0); GenerateRoomLayoutFromTexture2D(m_NewRoomPrefab, sourceTexture, PitBorderType, DamageCellsType); return(m_NewRoomPrefab); }
private void PlaceRandomAlarmMushrooms(Dungeon dungeon, RoomHandler currentRoom, int RandomObjectsPlaced, int RandomObjectsSkipped) { PrototypeDungeonRoom.RoomCategory roomCategory = currentRoom.area.PrototypeRoomCategory; if (currentRoom == null | roomCategory == PrototypeDungeonRoom.RoomCategory.REWARD | string.IsNullOrEmpty(currentRoom.GetRoomName()) | currentRoom.GetRoomName().StartsWith("Boss Foyer") | currentRoom.IsMaintenanceRoom() | !currentRoom.HasActiveEnemies(RoomHandler.ActiveEnemyType.RoomClear)) { return; } if (currentRoom != null && !string.IsNullOrEmpty(currentRoom.GetRoomName()) && !currentRoom.IsMaintenanceRoom() && !currentRoom.GetRoomName().StartsWith("Boss Foyer") && currentRoom.RoomVisualSubtype == 0) { if (Random.value <= 0.6f) { List <IntVector2> m_CachedPositions = new List <IntVector2>(); int MinMushroomCount = 2; int MaxMushroomCount = 6; if (Random.value <= 0.3f) { MinMushroomCount = 6; MaxMushroomCount = 12; } else if (roomCategory == PrototypeDungeonRoom.RoomCategory.BOSS) { MaxMushroomCount = 10; } int X = currentRoom.area.dimensions.x; int Y = currentRoom.area.dimensions.y; if (X * Y < 100) { MinMushroomCount = 1; MaxMushroomCount = 3; } int MushroomCount = Random.Range(MinMushroomCount, MaxMushroomCount); for (int i = 0; i < MushroomCount; i++) { IntVector2?RandomVector = GetRandomAvailableCell(dungeon, currentRoom, m_CachedPositions, ExitClearence: 3, avoidExits: true, PositionRelativeToRoom: true); if (RandomVector.HasValue) { GameObject alarmMushroomObject = ExpandPrefabs.EXAlarmMushroom.GetComponent <ExpandAlarmMushroomPlacable>().InstantiateObject(currentRoom, RandomVector.Value, true); alarmMushroomObject.transform.parent = currentRoom.hierarchyParent; ExpandAlarmMushroomPlacable m_AlarmMushRoomPlacable = ExpandPrefabs.EXAlarmMushroom.GetComponent <ExpandAlarmMushroomPlacable>(); m_AlarmMushRoomPlacable.ConfigureOnPlacement(currentRoom); RandomObjectsPlaced++; if (m_CachedPositions.Count <= 0) { break; } } else { RandomObjectsSkipped++; } } } } }
private void PlaceRandomCacti(Dungeon dungeon, RoomHandler currentRoom, ExpandObjectDatabase objectDatabase, int RandomObjectsPlaced, int RandomObjectsSkipped) { PrototypeDungeonRoom.RoomCategory roomCategory = currentRoom.area.PrototypeRoomCategory; if (currentRoom == null | roomCategory == PrototypeDungeonRoom.RoomCategory.REWARD | currentRoom.IsMaintenanceRoom() | string.IsNullOrEmpty(currentRoom.GetRoomName()) | currentRoom.GetRoomName().StartsWith("Boss Foyer") | currentRoom.RoomVisualSubtype != 0 | !currentRoom.HasActiveEnemies(RoomHandler.ActiveEnemyType.RoomClear)) { return; } if (Random.value <= 0.8f) { List <IntVector2> m_CachedPositions = new List <IntVector2>(); int MaxCactiCount = 12; int MinCactiCount = 6; if (Random.value <= 0.3f) { MaxCactiCount = 20; } else if (roomCategory == PrototypeDungeonRoom.RoomCategory.BOSS) { MaxCactiCount = 10; } int X = currentRoom.area.dimensions.x; int Y = currentRoom.area.dimensions.y; if (X * Y < 100) { MinCactiCount = 3; MaxCactiCount = 6; } int CactusCount = Random.Range(MinCactiCount, MaxCactiCount); for (int i = 0; i < CactusCount; i++) { IntVector2?RandomVector = GetRandomAvailableCell(dungeon, currentRoom, m_CachedPositions, ExitClearence: 3, avoidExits: true); List <GameObject> CactiList = new List <GameObject>() { ExpandPrefabs.Cactus_A, ExpandPrefabs.Cactus_B }; CactiList = CactiList.Shuffle(); if (RandomVector.HasValue) { GameObject Cactus = Instantiate(BraveUtility.RandomElement(CactiList), RandomVector.Value.ToVector3(), Quaternion.identity); Cactus.transform.parent = currentRoom.hierarchyParent; RandomObjectsPlaced++; if (m_CachedPositions.Count <= 0) { break; } } else { RandomObjectsSkipped++; } } } }
public void PlaceRandomEnemies(Dungeon dungeon, int currentFloor) { if (dungeon.IsGlitchDungeon | ChaosGlitchMod.isGlitchFloor) { goto IL_SKIP; } if (!ChaosConsole.isUltraMode && !ChaosConsole.GlitchEnemies) { return; } IL_SKIP :; PlayerController player = GameManager.Instance.PrimaryPlayer; int RandomEnemiesPlaced = 0; int RandomEnemiesSkipped = 0; int MaxEnemies = 20; float GlitchedBossOdds = 0.15f; float BonusGlitchEnemyOdds = 0.05f; if (currentFloor == -1) { if (dungeon.tileIndices.tilesetId == GlobalDungeonData.ValidTilesets.SEWERGEON) { MaxEnemies = 15; GlitchedBossOdds = 0.2f; BonusGlitchEnemyOdds = 0.1f; } if (dungeon.tileIndices.tilesetId == GlobalDungeonData.ValidTilesets.CATHEDRALGEON) { MaxEnemies = 32; GlitchedBossOdds = 0.22f; BonusGlitchEnemyOdds = 0.13f; } } if (currentFloor == 1) { MaxEnemies = 8; GlitchedBossOdds = 0.15f; BonusGlitchEnemyOdds = 0.05f; } if (currentFloor == 2) { MaxEnemies = 20; GlitchedBossOdds = 0.2f; BonusGlitchEnemyOdds = 0.1f; } if (currentFloor == 3) { MaxEnemies = 25; GlitchedBossOdds = 0.25f; BonusGlitchEnemyOdds = 0.15f; } if (currentFloor == 4) { MaxEnemies = 35; GlitchedBossOdds = 0.27f; BonusGlitchEnemyOdds = 0.2f; } if (currentFloor == 5) { MaxEnemies = 55; GlitchedBossOdds = 0.3f; BonusGlitchEnemyOdds = 0.25f; } if (currentFloor == 6) { MaxEnemies = 90; GlitchedBossOdds = 0.35f; BonusGlitchEnemyOdds = 0.3f; } if (dungeon.IsGlitchDungeon) { MaxEnemies = 65; GlitchedBossOdds = 0.3f; BonusGlitchEnemyOdds = 0.28f; } if (ChaosGlitchMod.isGlitchFloor) { MaxEnemies = 60; GlitchedBossOdds = 0.3f; BonusGlitchEnemyOdds = 0.28f; } if (dungeon.data.rooms == null | dungeon.data.rooms.Count <= 0) { return; } foreach (RoomHandler currentRoom in dungeon.data.rooms) { PrototypeDungeonRoom.RoomCategory roomCategory = currentRoom.area.PrototypeRoomCategory; try { if (currentRoom != null && !string.IsNullOrEmpty(currentRoom.GetRoomName()) && currentRoom.HasActiveEnemies(RoomHandler.ActiveEnemyType.RoomClear) && !currentRoom.IsMaintenanceRoom() && !currentRoom.IsSecretRoom && !currentRoom.IsWinchesterArcadeRoom && !currentRoom.IsGunslingKingChallengeRoom && !currentRoom.GetRoomName().StartsWith("Boss Foyer")) { if (roomCategory != PrototypeDungeonRoom.RoomCategory.BOSS && roomCategory != PrototypeDungeonRoom.RoomCategory.ENTRANCE && roomCategory != PrototypeDungeonRoom.RoomCategory.REWARD && roomCategory != PrototypeDungeonRoom.RoomCategory.EXIT) { List <IntVector2> m_CachedPositions = new List <IntVector2>(); IntVector2? RandomGlitchEnemyVector = GetRandomAvailableCellForEnemy(dungeon, currentRoom, m_CachedPositions); IntVector2? RandomGlitchEnemyVector2 = null; IntVector2? RandomGlitchEnemyVector3 = null; if (m_CachedPositions.Count > 0) { RandomGlitchEnemyVector2 = GetRandomAvailableCellForEnemy(dungeon, currentRoom, m_CachedPositions); } if (m_CachedPositions.Count > 0) { RandomGlitchEnemyVector3 = GetRandomAvailableCellForEnemy(dungeon, currentRoom, m_CachedPositions); } if (RandomGlitchEnemyVector.HasValue) { m_GlitchEnemyDatabase.SpawnRandomGlitchEnemy(currentRoom, RandomGlitchEnemyVector.Value, false, AIActor.AwakenAnimationType.Spawn); } else { RandomEnemiesSkipped++; } if (RandomGlitchEnemyVector2.HasValue && Random.value <= BonusGlitchEnemyOdds) { m_GlitchEnemyDatabase.SpawnRandomGlitchEnemy(currentRoom, RandomGlitchEnemyVector2.Value, false, AIActor.AwakenAnimationType.Spawn); } else { RandomEnemiesSkipped++; } if (RandomGlitchEnemyVector3.HasValue && Random.value <= GlitchedBossOdds) { m_GlitchEnemyDatabase.SpawnRandomGlitchBoss(currentRoom, RandomGlitchEnemyVector3.Value, false, AIActor.AwakenAnimationType.Spawn); } RandomEnemiesPlaced++; if (RandomEnemiesPlaced + RandomEnemiesSkipped >= MaxEnemies) { break; } } } } catch (System.Exception ex) { if (ChaosConsole.debugMimicFlag) { ETGModConsole.Log("[DEBUG] Exception while setting up or placing enemy for current room" /*+ currentRoom.GetRoomName()*/, false); } if (ChaosConsole.debugMimicFlag) { ETGModConsole.Log("[DEBUG] Skipping current room...", false); } if (ChaosConsole.debugMimicFlag) { ETGModConsole.Log(ex.Message + ex.StackTrace + ex.Source, false); } continue; } } if (ChaosConsole.debugMimicFlag) { ETGModConsole.Log("[DEBUG] Max Number of Glitched Enemies assigned to floor: " + MaxEnemies, false); ETGModConsole.Log("[DEBUG] Number of Glitched Enemies placed: " + RandomEnemiesPlaced, false); ETGModConsole.Log("[DEBUG] Number of Glitched Enemies skipped: " + RandomEnemiesSkipped, false); if (RandomEnemiesPlaced <= 0) { ETGModConsole.Log("[DEBUG] Error: No Glitched Enemies have been placed!", false); } } Destroy(m_GlitchEnemyDatabase); return; }
private static void PlaceRandomAlarmMushrooms(Dungeon dungeon, RoomHandler currentRoom) { PrototypeDungeonRoom.RoomCategory roomCategory = currentRoom.area.PrototypeRoomCategory; if (currentRoom == null | roomCategory == PrototypeDungeonRoom.RoomCategory.REWARD | string.IsNullOrEmpty(currentRoom.GetRoomName()) | currentRoom.GetRoomName().StartsWith("Boss Foyer") | currentRoom.IsMaintenanceRoom() | !currentRoom.HasActiveEnemies(RoomHandler.ActiveEnemyType.RoomClear) | roomCategory == PrototypeDungeonRoom.RoomCategory.BOSS) { return; } if (DebugMode) { Debug.Log("[ExpandTheGungeon] Checking room for valid Mushroom locations... "); } if (currentRoom != null && !string.IsNullOrEmpty(currentRoom.GetRoomName()) && !currentRoom.IsMaintenanceRoom() && !currentRoom.GetRoomName().StartsWith("Boss Foyer")) { if (Random.value <= 0.6f) { List <IntVector2> m_CachedPositions = new List <IntVector2>(); int MinMushroomCount = 2; int MaxMushroomCount = 6; if (Random.value <= 0.3f) { MinMushroomCount = 6; MaxMushroomCount = 12; } int X = currentRoom.area.dimensions.x; int Y = currentRoom.area.dimensions.y; if (X * Y < 100) { MinMushroomCount = 1; MaxMushroomCount = 3; } int MushroomCount = Random.Range(MinMushroomCount, MaxMushroomCount); for (int i = 0; i < MushroomCount; i++) { if (DebugMode) { Debug.Log("[ExpandTheGungeon] Test Mushroom Iteration: " + i.ToString()); } if (DebugMode) { if (!string.IsNullOrEmpty(currentRoom.GetRoomName())) { ETGModConsole.Log("[ExpandTheGungeon] On Room: " + currentRoom.GetRoomName()); } } IntVector2?RandomVector = GetRandomAvailableCell(dungeon, currentRoom, m_CachedPositions, 1, 4, avoidExits: true, PositionRelativeToRoom: true); if (RandomVector.HasValue) { if (DebugMode) { ETGModConsole.Log("[ExpandTheGungeon] Valid Location found. Placing Mushroom..."); } try { GameObject alarmMushroomObject = ExpandPrefabs.EXAlarmMushroom.GetComponent <ExpandAlarmMushroomPlacable>().InstantiateObject(currentRoom, RandomVector.Value, true); alarmMushroomObject.transform.parent = currentRoom.hierarchyParent; ExpandAlarmMushroomPlacable m_AlarmMushRoomPlacable = ExpandPrefabs.EXAlarmMushroom.GetComponent <ExpandAlarmMushroomPlacable>(); m_AlarmMushRoomPlacable.ConfigureOnPlacement(currentRoom); } catch (System.Exception ex) { if (DebugMode) { ETGModConsole.Log("[ExpandTheGungeon] Exception While placing/configuring mushroom!", DebugMode); Debug.LogException(ex); } } RandomObjectsPlaced++; if (DebugMode) { Debug.Log("[ExpandTheGungeon] Mushroom successfully placed!"); } if (m_CachedPositions.Count <= 0) { break; } } else { if (DebugMode) { Debug.Log("[ExpandTheGungeon] No valid cells found. Mushroom skipped!"); } RandomObjectsSkipped++; } } } } }
private static void PlaceRandomCacti(Dungeon dungeon, RoomHandler currentRoom) { PrototypeDungeonRoom.RoomCategory roomCategory = currentRoom.area.PrototypeRoomCategory; if (currentRoom == null | roomCategory == PrototypeDungeonRoom.RoomCategory.REWARD | currentRoom.IsMaintenanceRoom() | string.IsNullOrEmpty(currentRoom.GetRoomName()) | currentRoom.GetRoomName().StartsWith("Boss Foyer") | currentRoom.RoomVisualSubtype != 0 | !currentRoom.HasActiveEnemies(RoomHandler.ActiveEnemyType.RoomClear) | currentRoom.PrecludeTilemapDrawing) { return; } if (Random.value <= 0.8f | currentRoom.GetRoomName().ToLower().StartsWith("expand_west_entrance")) { List <IntVector2> m_CachedPositions = new List <IntVector2>(); int MaxCactiCount = 12; int MinCactiCount = 6; if (Random.value <= 0.3f) { MaxCactiCount = 20; } else if (roomCategory == PrototypeDungeonRoom.RoomCategory.BOSS) { MaxCactiCount = 10; } int X = currentRoom.area.dimensions.x; int Y = currentRoom.area.dimensions.y; if (X * Y < 100) { MinCactiCount = 3; MaxCactiCount = 6; } if (!string.IsNullOrEmpty(currentRoom.GetRoomName()) && currentRoom.GetRoomName().ToLower().StartsWith("expand_west_canyon1_tiny")) { MinCactiCount = 1; MaxCactiCount = 3; } int CactusCount = Random.Range(MinCactiCount, MaxCactiCount); if (!currentRoom.GetRoomName().ToLower().StartsWith("expand_west_entrance")) { for (int i = 0; i < CactusCount; i++) { IntVector2?RandomVector = GetRandomAvailableCell(dungeon, currentRoom, m_CachedPositions, ExitClearence: 3, avoidExits: true); List <GameObject> CactiList = new List <GameObject>() { ExpandPrefabs.Cactus_A, ExpandPrefabs.Cactus_B }; CactiList = CactiList.Shuffle(); if (RandomVector.HasValue) { GameObject Cactus = Object.Instantiate(BraveUtility.RandomElement(CactiList), RandomVector.Value.ToVector3(), Quaternion.identity); Cactus.transform.parent = currentRoom.hierarchyParent; RandomObjectsPlaced++; if (m_CachedPositions.Count <= 0) { break; } } else { RandomObjectsSkipped++; } } } else { List <GameObject> CactiList = new List <GameObject>() { ExpandPrefabs.Cactus_A, ExpandPrefabs.Cactus_B }; CactiList = CactiList.Shuffle(); m_CachedPositions = new List <IntVector2>() { new IntVector2(34, 49), new IntVector2(29, 43), new IntVector2(16, 43), new IntVector2(2, 19), new IntVector2(49, 17), new IntVector2(9, 23), new IntVector2(40, 23), new IntVector2(30, 20), new IntVector2(22, 29), new IntVector2(31, 31), new IntVector2(14, 14), new IntVector2(14, 37), new IntVector2(37, 14), new IntVector2(37, 37), new IntVector2(33, 2), new IntVector2(33, 10), new IntVector2(3, 17), new IntVector2(2, 34), new IntVector2(14, 20), new IntVector2(16, 39), new IntVector2(31, 38), new IntVector2(49, 34), new IntVector2(38, 29), new IntVector2(21, 21), new IntVector2(20, 32), new IntVector2(31, 22), }; m_CachedPositions = m_CachedPositions.Shuffle(); for (int i = 0; i < 14; i++) { IntVector2 selectedPosition = BraveUtility.RandomElement(m_CachedPositions); m_CachedPositions.Remove(selectedPosition); m_CachedPositions = m_CachedPositions.Shuffle(); GameObject Cactus = Object.Instantiate(BraveUtility.RandomElement(CactiList), (selectedPosition + currentRoom.area.basePosition).ToVector3(), Quaternion.identity); Cactus.transform.SetParent(currentRoom.hierarchyParent); RandomObjectsPlaced++; } } } }