Monster CreateRandomMonster(Vector2 location) { Monster monster = null; if (Game1.isDarkOut() && CanHazMonster(Settings.Monsters.Bat)) { monster = new Bat(new Vector2()); } else if (Game1.isDarkOut() && CanHazMonster(Settings.Monsters.Ghost)) { monster = new Ghost(new Vector2()); } else if (CanHazMonster(Settings.Monsters.BigSlime)) { monster = new BigSlime(new Vector2(), GetSlimeLevel()); } else if (CanHazMonster(Settings.Monsters.Grub)) { monster = new Grub(new Vector2(), true); } else if (CanHazMonster(Settings.Monsters.Fly)) { monster = new Fly(new Vector2(), true); } else if (CanHazMonster(Settings.Monsters.Brute)) { monster = new ShadowBrute(new Vector2()); } else if (CanHazMonster(Settings.Monsters.Golem)) { monster = new RockGolem(new Vector2(), deepWoods.GetCombatLevel()); } else if (CanHazMonster(Settings.Monsters.RockCrab)) { monster = new RockCrab(new Vector2(), GetRockCrabType()); } else { foreach (var modMonster in DeepWoodsAPI.ToShuffledList(ModEntry.GetAPI().Monsters)) { if (modMonster.Item1(deepWoods, location)) { monster = modMonster.Item2(); break; } } if (monster == null) { monster = new GreenSlime(new Vector2(), GetSlimeLevel()); } } if (deepWoods.level.Value >= Settings.Level.MinLevelForBuffedMonsters && !this.random.CheckChance(Settings.Monsters.ChanceForUnbuffedMonster)) { BuffMonster(monster); } return(monster); }
public static Vector2 SpawnRandomMonster(GameLocation location) { for (int index = 0; index < 15; ++index) { Vector2 randomTile = location.getRandomTile(); if (Utility.isOnScreen(Utility.Vector2ToPoint(randomTile), 64, location)) { randomTile.X -= Game1.viewport.Width / 64; } if (location.isTileLocationTotallyClearAndPlaceable(randomTile)) { if (Game1.player.CombatLevel >= 10 && Game1.MasterPlayer.deepestMineLevel >= 145 && Game1.random.NextDouble() <= .001 && Game1.MasterPlayer.stats.getMonstersKilled("Pepper Rex") > 0) { DinoMonster squidKid = new DinoMonster(randomTile * Game1.tileSize) { focusedOnFarmers = true }; location.characters.Add(squidKid); return(randomTile); } else if (Game1.player.CombatLevel >= 10 && Game1.MasterPlayer.deepestMineLevel >= 145 && Game1.random.NextDouble() <= .05) { MetalHead squidKid = new MetalHead(randomTile * Game1.tileSize, 145) { focusedOnFarmers = true }; location.characters.Add(squidKid); return(randomTile); } else if (Game1.player.CombatLevel >= 10 && Game1.random.NextDouble() <= .25) { Skeleton skeleton = new Skeleton(randomTile * Game1.tileSize) { focusedOnFarmers = true }; location.characters.Add(skeleton); return(randomTile); } else if (Game1.player.CombatLevel >= 8 && Game1.random.NextDouble() <= 0.15) { ShadowBrute shadowBrute = new ShadowBrute(randomTile * Game1.tileSize) { focusedOnFarmers = true }; location.characters.Add(shadowBrute); return(randomTile); } else if (Game1.random.NextDouble() < 0.65 && location.isTileLocationTotallyClearAndPlaceable(randomTile)) { RockGolem rockGolem = new RockGolem(randomTile * Game1.tileSize, Game1.player.CombatLevel) { focusedOnFarmers = true }; rockGolem.Sprite.currentFrame = 16; rockGolem.Sprite.loop = false; rockGolem.Sprite.UpdateSourceRect(); location.characters.Add(rockGolem); return(randomTile); } else { int mineLevel; if (Game1.player.CombatLevel > 1 && Game1.player.CombatLevel <= 4) { mineLevel = 41; } else if (Game1.player.CombatLevel > 4 && Game1.player.CombatLevel <= 8) { mineLevel = 100; } else if (Game1.player.CombatLevel > 8 && Game1.player.CombatLevel <= 10) { mineLevel = 140; } else { mineLevel = 200; } GreenSlime greenSlime = new GreenSlime(randomTile * Game1.tileSize, mineLevel) { focusedOnFarmers = true, }; greenSlime.color.Value = Color.IndianRed; location.characters.Add(greenSlime); return(randomTile); } } } return(Vector2.Zero); }
private Monster GetMonster(int x, Vector2 loc) { Monster m; switch (x) { case 0: m = new DustSpirit(loc); break; case 1: m = new Grub(loc); break; case 2: m = new Skeleton(loc); break; case 3: m = new RockCrab(loc); break; case 4: m = new Ghost(loc); break; case 5: m = new GreenSlime(loc); break; case 6: m = new RockGolem(loc); break; case 7: m = new ShadowBrute(loc); break; case 8: int y = rand.Next(1, 6); //m = new Monster(); if (y == 1) { m = new RockCrab(loc, "Iridium Crab"); } else if (y == 2) { m = new Ghost(loc, "Carbon Ghost"); } else if (y == 3) { m = new LavaCrab(loc); } //else if (y == 4) //m = new Bat(loc, Math.Max(Game1.player.CombatLevel * 5, 50)); else if (y == 4) { m = new GreenSlime(loc, Math.Max(Game1.player.CombatLevel * 5, 50)); } else if (y == 5) { m = new BigSlime(loc, Math.Max(Game1.player.CombatLevel * 5, 50)); } else { m = new Mummy(loc); } break; default: m = new Monster(); break; } return(m); }
/********* ** Private methods *********/ private void SpawnEntity(string command, string[] args) { //We need a world to spawn monsters in, duh if (Context.IsWorldReady) { // Determine if we have arguments if (args.Length > 0) { //Set defaults NPC entity = null; int xTile = Game1.player.getTileX(); int yTile = Game1.player.getTileY(); int amount = 1; //Ensure provided coordinatees are actually coordinates try { //Determine X tile if (args.Length >= 2) { if (!args[1].Equals("~")) { xTile = int.Parse(args[1]); } } //Determine Y tile if (args.Length >= 3) { if (!args[1].Equals("~")) { yTile = int.Parse(args[2]); } } } catch (Exception) { Monitor.Log("Arguments 1 and 2 must be coordinates or '~' to use the Farmer's coordinates! Make sure you don't add any brackets!"); return; } try { if (args.Length >= 4) { amount = int.Parse(args[3]); if (amount < 1) { throw new Exception(); } } } catch (Exception) { Monitor.Log("Argument 3 must be an amount larger than 0!"); return; } Vector2 pos = new Vector2(xTile, yTile); for (int i = 0; i < amount; i++) { // Determine the monster to spawn switch (args[0]) { case "greenSlime": entity = new GreenSlime(pos, 0); break; case "blueSlime": entity = new GreenSlime(pos, 40); break; case "redSlime": entity = new GreenSlime(pos, 80); break; case "purpleSlime": entity = new GreenSlime(pos, 121); break; case "yellowSlime": entity = new GreenSlime(pos, new Color(255, 255, 50)); break; case "blackSlime": Random r = new Random(); entity = new GreenSlime(pos, new Color(40 + r.Next(10), 40 + r.Next(10), 40 + r.Next(10))); break; case "bat": entity = new Bat(pos); break; //minelevel: 0 - 40 - 80 - 171 -> type case "frostBat": entity = new Bat(pos, 40); break; case "lavaBat": entity = new Bat(pos, 80); break; case "iridiumBat": entity = new Bat(pos, 171); break; case "bug": entity = new Bug(pos, 0); break; //available areatypes: 121 -> armored case "armoredBug": entity = new Bug(pos, 121); break; case "fly": entity = new Fly(pos); break; //hard -> mutant case "mutantFly": entity = new Fly(pos, true); break; case "ghost": entity = new Ghost(pos); break; //name -> carbon ghost case "carbonGhost": entity = new Ghost(pos, "Carbon Ghost"); break; case "grub": entity = new Grub(pos); break; //hard -> mutant case "mutantGrub": entity = new Grub(pos, true); break; case "rockCrab": entity = new RockCrab(pos); break; //name -> iridium crab case "lavaCrab": entity = new LavaCrab(pos); break; case "iridiumCrab": entity = new RockCrab(pos, "Iridium Crab"); break; case "metalHead": entity = new MetalHead(pos, 80); break; //mineareas: 0, 40, 80 - seems to only spawn at 80+ case "rockGolem": entity = new RockGolem(pos); break; //mineareas: 0, 40, 80 - changes health and damage; difficultymod: case "wildernessGolem": entity = new RockGolem(pos, 5); break; case "mummy": entity = new Mummy(pos); break; case "serpent": entity = new Serpent(pos); break; case "shadowBrute": entity = new ShadowBrute(pos); break; case "shadowShaman": entity = new ShadowShaman(pos); break; case "skeleton": entity = new Skeleton(pos); break; case "squidKid": entity = new SquidKid(pos); break; case "duggy": entity = new Duggy(pos); break; case "dustSpirit": entity = new DustSpirit(pos); break; } if (entity != null) { entity.currentLocation = Game1.currentLocation; entity.setTileLocation(new Vector2(xTile, yTile)); Game1.currentLocation.addCharacter(entity); } else { Monitor.Log($"{args[0]} not found! Type monster_list to view a list of available monsters to spawn!"); return; } } Monitor.Log($"{amount} {entity.Name} added at {entity.currentLocation.Name} {entity.getTileX()},{entity.getTileY()}", LogLevel.Info); } else { Monitor.Log("Usage: monster_spawn <name> [posX] [posY] [amount]\n\nUses Farmer's coordinates if none or '~' was given."); } } else { Monitor.Log("Load a save first!"); } }
Monster CreateRandomMonster(Vector2 location) { Monster monster = null; if (Game1.isDarkOut() && CanHazMonster(Settings.Monsters.Bat)) { monster = new Bat(new Vector2()); } else if (Game1.isDarkOut() && CanHazMonster(Settings.Monsters.Ghost)) { monster = new Ghost(new Vector2()); } else if (CanHazMonster(Settings.Monsters.BigSlime)) { monster = new BigSlime(new Vector2(), GetSlimeLevel()); } else if (CanHazMonster(Settings.Monsters.Grub)) { monster = new Grub(new Vector2(), true); } else if (CanHazMonster(Settings.Monsters.Fly)) { monster = new Fly(new Vector2(), true); } else if (CanHazMonster(Settings.Monsters.Brute)) { monster = new ShadowBrute(new Vector2()); } else if (CanHazMonster(Settings.Monsters.Golem)) { monster = new RockGolem(new Vector2(), deepWoods.GetCombatLevel()); } else if (CanHazMonster(Settings.Monsters.RockCrab)) { monster = new RockCrab(new Vector2(), GetRockCrabType()); } else if (CanHazMonster(Settings.Monsters.Bug)) { monster = new Bug(new Vector2(), 121); monster.isHardModeMonster.Value = true; } else if (CanHazMonster(Settings.Monsters.ArmoredBug)) { monster = new Bug(new Vector2(), 121); monster.isHardModeMonster.Value = true; } else if (Game1.isDarkOut() && CanHazMonster(Settings.Monsters.PutridGhost)) { monster = new Ghost(new Vector2(), "Putrid Ghost"); } else if (Game1.isDarkOut() && CanHazMonster(Settings.Monsters.DustSprite)) { monster = new DustSpirit(new Vector2()); new Leaper(); } else if (Game1.isDarkOut() && CanHazMonster(Settings.Monsters.Spider)) { monster = new Leaper(new Vector2()); } else { foreach (var modMonster in DeepWoodsAPI.ToShuffledList(ModEntry.GetAPI().Monsters)) { // Item1 is a mod provided function that returns true if the mod wants to spawn a custom monster at this location. // Item2 is a mod provided function that returns the custom monster. if (modMonster.Item1(deepWoods, location)) { monster = modMonster.Item2(); break; } } } // No other monster was selected and no mod provided a monster, default to green slime if (monster == null) { monster = new GreenSlime(new Vector2(), GetSlimeLevel()); } if (!Settings.Monsters.DisableBuffedMonsters && deepWoods.level.Value >= Settings.Level.MinLevelForBuffedMonsters && !this.random.CheckChance(Settings.Monsters.ChanceForUnbuffedMonster)) { BuffMonster(monster); } if (!Settings.Monsters.DisableDangerousMonsters && deepWoods.level.Value >= Settings.Level.MinLevelForDangerousMonsters && !this.random.CheckChance(Settings.Monsters.ChanceForNonDangerousMonster)) { monster.isHardModeMonster.Value = true; } monster.faceDirection(this.random.GetRandomValue(0, 4)); return(monster); }
public static void SpawnMonster(GameLocation location) { Vector2 zero = Vector2.Zero; Vector2 randomTile = Vector2.Zero; int numTries = 0; do { randomTile = location.getRandomTile(); numTries++; } while (GetDistance(randomTile, Game1.player.position) > 45 && numTries < 10000); if (Utility.isOnScreen(Utility.Vector2ToPoint(randomTile), Game1.tileSize, location)) { randomTile.X -= (Game1.viewport.Width / Game1.tileSize); } if (location.isTileLocationTotallyClearAndPlaceable(randomTile)) { if (Game1.player.CombatLevel >= 10 && Game1.random.NextDouble() < .05) { Skeleton skeleton = new Skeleton(randomTile * Game1.tileSize) { focusedOnFarmers = true }; location.characters.Add(skeleton); } if (Game1.player.CombatLevel >= 8 && Game1.random.NextDouble() < 0.15) { ShadowBrute shadowBrute = new ShadowBrute(randomTile * Game1.tileSize) { focusedOnFarmers = true }; location.characters.Add(shadowBrute); } else if (Game1.random.NextDouble() < 0.65 && location.isTileLocationTotallyClearAndPlaceable(randomTile)) { RockGolem rockGolem = new RockGolem(randomTile * Game1.tileSize, Game1.player.CombatLevel) { focusedOnFarmers = true }; location.characters.Add(rockGolem); } else { int mineLevel = 1; if (Game1.player.CombatLevel >= 10) { mineLevel = 140; } else if (Game1.player.CombatLevel >= 8) { mineLevel = 100; } else if (Game1.player.CombatLevel >= 4) { mineLevel = 41; } GreenSlime greenSlime = new GreenSlime(randomTile * Game1.tileSize, mineLevel); location.characters.Add(greenSlime); } } }