//New map generation code that looks for all possible locations and randomly pick one from a list static void Postfix(dmAdventureMap __instance, bool __result) { dmGame theGame = dmUtilities.theGame; int[] array = new int[5] { 45, 50, 58, 69, 79 }; int maxRange = array[Traverse.Create(__instance).Field("itemTier").GetValue <int>() - 1]; List <LocValue> possibleLocations = new List <LocValue>(); int maxDontUseThis = maxRange - 12; Rectangle dontUseInsideRectangle = new Rectangle(0, 0, maxDontUseThis, maxDontUseThis); for (int i = 0; i < maxRange; i++) { for (int j = 0; j < maxRange; j++) { LocValue locValue = new LocValue(i, j); if (!dontUseInsideRectangle.Contains(locValue.X, locValue.Y)) { WorldTile tile = theGame.theWorld.GetTile(locValue); bool newTileAlreadyUsed = false; foreach (dmObject item in tile.ContainedObjects()) { if (item is dmGateway) { newTileAlreadyUsed = true; } } if ((!__instance.bForceSpecificDungeon || tile.iTerrain == TerrainType.TT_PLAINS) && (tile.iTerrain == TerrainType.TT_PLAINS || tile.iTerrain == TerrainType.TT_FOREST || tile.iTerrain == TerrainType.TT_BADLANDS) && !newTileAlreadyUsed) { possibleLocations.Add(locValue); } } } } if (possibleLocations.Count > 0) { __instance.goalLocation = possibleLocations[dmUtilities.RandomInt() % possibleLocations.Count]; __result = true; } else { __result = false; } }
//Fixes when a map is activated in the hotbar using the keyboard, so it doesn't remove it from the inventory just because it is a consumable static bool Prefix(dmGame __instance) { if (__instance.dungeonMans.iCurrentAP > 0 && !__instance.bShowMasteriesMode && !__instance.bInventoryMode && !__instance.bSelectPowerMode) { for (int j = 0; j < 10; j++) { if (!__instance.theInput.ExecutedActions.Contains((ActionButton)(53 + j))) { continue; } int num = j; if (__instance.theInput.bCtrlIsDown) { num += 10; } else if (__instance.theInput.bShiftIsDown) { num += 20; } else if (__instance.theInput.bAltIsDown) { num += 30; } dmItem swapItem = __instance.theUIFrames.GetHeldItemFromHotbar(num); if (swapItem != null) { if (swapItem is dmConsumable && __instance.dungeonMans.iCurrentAP >= 100 && __instance.gamePhase == GameTurnPhase.WaitForHeroAction) { __instance.dungeonMans.UseConsumable(swapItem as dmConsumable, __instance); return(false); } } } } return(true); }