Exemplo n.º 1
0
        protected override void resetSharedState()
        {
            base.resetSharedState();
            if ((bool)addedSlimesToday)
            {
                return;
            }
            addedSlimesToday.Value = true;
            Random rand = new Random((int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame + 12);

            Microsoft.Xna.Framework.Rectangle spawnArea = new Microsoft.Xna.Framework.Rectangle(13, 15, 7, 6);
            for (int tries = 5; tries > 0; tries--)
            {
                Vector2 tile = Utility.getRandomPositionInThisRectangle(spawnArea, rand);
                if (isTileLocationTotallyClearAndPlaceable(tile))
                {
                    GreenSlime i = new GreenSlime(tile * 64f, 9999899);
                    characters.Add(i);
                }
            }
            if (rand.NextDouble() < 0.5 && isTileLocationTotallyClearAndPlaceable(new Vector2(17f, 18f)))
            {
                objects.Add(new Vector2(17f, 18f), new Object(new Vector2(17f, 18f), 56));
            }
            GreenSlime slime2 = new GreenSlime(new Vector2(42f, 34f) * 64f);

            slime2.makeTigerSlime();
            characters.Add(slime2);
            slime2 = new GreenSlime(new Vector2(38f, 33f) * 64f);
            slime2.makeTigerSlime();
            characters.Add(slime2);
        }
Exemplo n.º 2
0
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("생성");
        m_Slime = gameObject.GetComponent <GreenSlime>();
        root.AddChild(selector);
        selector.AddChild(seqDead);
        selector.AddChild(selectPattern);

        //노드
        m_Dead.Enemy        = m_Slime;
        m_Attack.Enemy      = m_Slime;
        m_MonsterMove.Enemy = m_Slime;
        m_Patrol.Enemy      = m_Slime;
        m_GetHit.Enemy      = m_Slime;

        seqDead.AddChild(m_Dead);

        selectPattern.AddChild(seqMove);
        selectPattern.AddChild(seqAttack);
        selectPattern.AddChild(seqPatrol);
        selectPattern.AddChild(seqGetHit);

        seqMove.AddChild(m_MonsterMove);
        seqAttack.AddChild(m_Attack);
        seqPatrol.AddChild(m_Patrol);
        seqGetHit.AddChild(m_GetHit);

        behaviorProcess = BehaviorProcess();
        StartCoroutine(behaviorProcess);
    }
        /// <summary>Patch for slimes to damage monsters around Slimecharmer.</summary>
        private static void GreenSlimeUpdatePostfix(ref GreenSlime __instance, GameLocation location)
        {
            try
            {
                if (!Utility.AnyPlayerInLocationHasProfession("Slimecharmer", location))
                {
                    return;
                }

                foreach (var npc in __instance.currentLocation.characters.Where(npc => npc.IsMonster && npc is not GreenSlime))
                {
                    var monster    = (Monster)npc;
                    var monsterBox = monster.GetBoundingBox();
                    if (monster.IsInvisible || monster.isInvincible() || monster.isGlider.Value || !monsterBox.Intersects(__instance.GetBoundingBox()))
                    {
                        continue;
                    }

                    var damageToMonster = Math.Max(1, __instance.DamageToFarmer + Game1.random.Next(-__instance.DamageToFarmer / 4, __instance.DamageToFarmer / 4));
                    var trajectory      = SUtility.getAwayFromPositionTrajectory(monsterBox, __instance.Position) / 2f;
                    monster.takeDamage(damageToMonster, (int)trajectory.X, (int)trajectory.Y, isBomb: false, 1.0, hitSound: "slime");
                    monster.setInvincibleCountdown(225);
                    monster.currentLocation.debris.Add(new Debris(damageToMonster, new Vector2(monsterBox.Center.X + 16, monsterBox.Center.Y), new Color(255, 130, 0), 1f, monster));
                }
            }
            catch (Exception ex)
            {
                Monitor.Log($"Failed in {nameof(GreenSlimeUpdatePostfix)}:\n{ex}");
            }
        }
Exemplo n.º 4
0
        private void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e)
        {
            if (e.KeyPressed == Keys.G)
            {
                this.Monitor.Log("Summoning slimes", LogLevel.Trace);

                Farmer f         = Game1.player;
                Farm   farm      = Game1.getFarm();
                var    positions = new Microsoft.Xna.Framework.Vector2[]
                {
                    new Microsoft.Xna.Framework.Vector2(3489f, 1391f),
                    new Microsoft.Xna.Framework.Vector2(3489f, 1829f),
                    new Microsoft.Xna.Framework.Vector2(4270f, 1829f),
                    new Microsoft.Xna.Framework.Vector2(4270f, 1391f),
                };
                Random  rnd     = new Random();
                var     pos     = positions[rnd.Next(0, 4)];
                Monster monster = new GreenSlime(pos);
                monster.wildernessFarmMonster = true;
                Game1.currentLocation.characters.Add(monster);
            }
            else if (e.KeyPressed == Keys.H)
            {
                this.Monitor.Log("Summoning friendly slimes", LogLevel.Trace);

                Farmer f    = Game1.player;
                Farm   farm = Game1.getFarm();
                //NPCFollower follower = new NPCFollower(new Microsoft.Xna.Framework.Vector2(4200f, 1605f));
                NPCFollower follower = new NPCFollower(f.position);
                Game1.currentLocation.characters.Add(follower);
            }
        }
        public void slimeTalkToPlayer(GreenSlime Slime)
        {
            String[] smart = { "All slime activities are equivalent… and… all are on principle doomed to failure.", "Nothingness lies coiled at the heart of being like a slime", "I exist, that is all, and I find it nauseating",       "We the Slimes of the Slime Hutch...",
                               "The opposite of love is not hate; it’s indifference",                               "Life is like a bocolate of choxes",                          "The journey of a thousand miles begins with one step", "Once I overcome my fear of the sun, I will become the ultimate lifeform!","I think, therfore I am",
                               "What lies beyond the horizon?",                                                     "Slimes die when they are killed",                            "He who fights with monsters should look to it that he himself does not become a monster. And if you gaze long into an abyss, the abyss also gazes into you" };

            String[] average = { "Good day to you farmer!", "This slime hutch is very comfortable!", "I wonder what the outside world looks like!", "Do you ever wonder why where here?", "Wow the water quality is great today!", "I love being a slime!" };
            String[] dumb    = { "I'm hungryyy", "The slime hutch is flat", "Where is my food" };

            /*if (Slime.maxHealth > 30)
             * {
             *  if (Game1.timeOfDay < 1200)
             *  {
             *      Slime.sayHiTo(Game1.player);
             *  }
             *  else if (Game1.timeOfDay < 1900)
             *  {
             *      Slime.showTextAboveHead("Good Afternoon!", -1, 2, 3000, 0);
             *  }
             *  else
             *  {
             *      Slime.showTextAboveHead("Good Night!", -1, 2, 3000, 0);
             *  }
             * }
             * else if(Slime.maxHealth > 20)
             * {
             *  if (Game1.timeOfDay < 1200)
             *  {
             *      Slime.showTextAboveHead("Foooodd", -1, 2, 3000, 0); //This should play something from the dumb list
             *  }
             * }
             * else
             * {
             *  Slime.showTextAboveHead("Yes", -1, 2, 3000, 0); //This should play something from the dumb list
             * } */

            var num = rand.NextDouble();

            if (num < .25)
            {
                if (Game1.timeOfDay < 1200)
                {
                    Slime.sayHiTo(Game1.player);
                }
                else if (Game1.timeOfDay < 1900)
                {
                    Slime.showTextAboveHead("Good Afternoon!", -1, 2, 3000, 0);
                }
                else
                {
                    Slime.showTextAboveHead("Good Night!", -1, 2, 3000, 0);
                }
            }
            else
            {
                //Have the slimes talk depending on hp
                //If there are 2 slimes, have them do a dialog
                Slime.showTextAboveHead("Scheme is the best programming language!", -1, 2, 3000, 0);
            }
        }
Exemplo n.º 6
0
 private static void GreenSlime_behaviorAtGameTick_prefix(GreenSlime __instance, GameTime time, ref int ___readyToJump)
 {
     if (__instance.Health <= 0 || Config.MonstersIgnorePlayer)
     {
         ___readyToJump = -1;
     }
 }
Exemplo n.º 7
0
        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);
        }
        // Token: 0x06000132 RID: 306 RVA: 0x0000C914 File Offset: 0x0000AB14
        public override void DayUpdate(int dayOfMonth)
        {
            int waters = 0;

            for (int i = 0; i < this.waterSpots.Length; i++)
            {
                if (this.waterSpots[i] && waters * 5 < this.characters.Count)
                {
                    waters++;
                    this.waterSpots[i] = false;
                    base.setMapTileIndex(16, 6 + i, 2134, "Buildings", 0);
                }
            }
            for (int numSlimeBalls = Math.Min(this.characters.Count / 5, waters); numSlimeBalls > 0; numSlimeBalls--)
            {
                int     tries = 50;
                Vector2 tile  = base.getRandomTile();
                while ((!this.isTileLocationTotallyClearAndPlaceable(tile) || base.doesTileHaveProperty((int)tile.X, (int)tile.Y, "NPCBarrier", "Back") != null || tile.Y >= 12f) && tries > 0)
                {
                    tile = base.getRandomTile();
                    tries--;
                }
                if (tries > 0)
                {
                    this.objects.Add(tile, new Object(tile, 56, false));
                }
            }
            while (this.slimeMatingsLeft > 0)
            {
                if (this.characters.Count > 1 && !this.isFull())
                {
                    NPC mate = this.characters[Game1.random.Next(this.characters.Count)];
                    if (mate is GreenSlime)
                    {
                        GreenSlime mate2 = mate as GreenSlime;
                        if (mate2.ageUntilFullGrown <= 0)
                        {
                            for (int distance = 1; distance < 10; distance++)
                            {
                                GreenSlime mate3 = (GreenSlime)Utility.checkForCharacterWithinArea(mate2.GetType(), mate.position, this, new Rectangle((int)mate2.position.X - Game1.tileSize * distance, (int)mate2.position.Y - Game1.tileSize * distance, Game1.tileSize * (distance * 2 + 1), Game1.tileSize * (distance * 2 + 1)));
                                if (mate3 != null && mate3.cute != mate2.cute && mate3.ageUntilFullGrown <= 0)
                                {
                                    mate2.mateWith(mate3, this);
                                    break;
                                }
                            }
                        }
                    }
                }
                this.slimeMatingsLeft--;
            }
            this.slimeMatingsLeft = this.characters.Count / 5 + 1;
            base.DayUpdate(dayOfMonth);
        }
Exemplo n.º 9
0
        public override void DayUpdate(int dayOfMonth)
        {
            int num = 0;

            for (int i = 0; i < this.waterSpots.Length; i++)
            {
                if (this.waterSpots[i] && num * 5 < this.characters.Count)
                {
                    num++;
                    this.waterSpots[i] = false;
                    base.setMapTileIndex(16, 6 + i, 2134, "Buildings", 0);
                }
            }
            for (int j = Math.Min(this.characters.Count / 5, num); j > 0; j--)
            {
                int     num2       = 50;
                Vector2 randomTile = base.getRandomTile();
                while ((!this.isTileLocationTotallyClearAndPlaceable(randomTile) || base.doesTileHaveProperty((int)randomTile.X, (int)randomTile.Y, "NPCBarrier", "Back") != null || randomTile.Y >= 12f) && num2 > 0)
                {
                    randomTile = base.getRandomTile();
                    num2--;
                }
                if (num2 > 0)
                {
                    this.objects.Add(randomTile, new Object(randomTile, 56, false));
                }
            }
            while (this.slimeMatingsLeft > 0)
            {
                if (this.characters.Count > 1 && !this.isFull())
                {
                    NPC nPC = this.characters[Game1.random.Next(this.characters.Count)];
                    if (nPC is GreenSlime)
                    {
                        GreenSlime greenSlime = nPC as GreenSlime;
                        if (greenSlime.ageUntilFullGrown <= 0)
                        {
                            for (int k = 1; k < 10; k++)
                            {
                                GreenSlime greenSlime2 = (GreenSlime)Utility.checkForCharacterWithinArea(greenSlime.GetType(), nPC.position, this, new Rectangle((int)greenSlime.position.X - Game1.tileSize * k, (int)greenSlime.position.Y - Game1.tileSize * k, Game1.tileSize * (k * 2 + 1), Game1.tileSize * (k * 2 + 1)));
                                if (greenSlime2 != null && greenSlime2.cute != greenSlime.cute && greenSlime2.ageUntilFullGrown <= 0)
                                {
                                    greenSlime.mateWith(greenSlime2, this);
                                    break;
                                }
                            }
                        }
                    }
                }
                this.slimeMatingsLeft--;
            }
            this.slimeMatingsLeft = this.characters.Count / 5 + 1;
            base.DayUpdate(dayOfMonth);
        }
        /// <inheritdoc/>
        public override void OnWarped(object sender, WarpedEventArgs e)
        {
            if (e.NewLocation is not MineShaft && e.NewLocation is not VolcanoDungeon)
            {
                return;
            }

            var count = Game1.getFarm().buildings.Where(b => (b.owner.Value == e.Player.UniqueMultiplayerID || !Game1.IsMultiplayer) && b.indoors.Value is SlimeHutch && !b.isUnderConstruction() && b.indoors.Value.characters.Any()).Sum(b => b.indoors.Value.characters.Count(npc => npc is GreenSlime)) + Game1.getFarm().characters.Count(npc => npc is GreenSlime);
            var r     = new Random(Guid.NewGuid().GetHashCode());

            while (count-- > 0)
            {
                var x             = r.Next(e.NewLocation.Map.GetLayer("Back").LayerWidth);
                var y             = r.Next(e.NewLocation.Map.GetLayer("Back").LayerHeight);
                var spawnPosition = new Vector2(x, y);

                GreenSlime slime;
                switch (e.NewLocation)
                {
                case MineShaft shaft when e.NewLocation is MineShaft:
                {
                    shaft.checkForMapAlterations(x, y);
                    if (!shaft.isTileClearForMineObjects(spawnPosition) || shaft.isTileOccupied(spawnPosition))
                    {
                        continue;
                    }

                    slime = new GreenSlime(Vector2.Zero, shaft.mineLevel);
                    if (shaft.GetAdditionalDifficulty() > 0 && r.NextDouble() < Math.Min(shaft.GetAdditionalDifficulty() * 0.1f, 0.5f))
                    {
                        slime.stackedSlimes.Value = r.NextDouble() < 0.0099999997764825821 ? 4 : 2;
                    }

                    slime.setTilePosition(x, y);
                    shaft.characters.Add(shaft.BuffMonsterIfNecessary(slime));
                    break;
                }

                case VolcanoDungeon dungeon when e.NewLocation is VolcanoDungeon:
                {
                    if (!e.NewLocation.isTileLocationTotallyClearAndPlaceable(spawnPosition))
                    {
                        continue;
                    }

                    slime = new GreenSlime(spawnPosition, 1);
                    slime.makeTigerSlime();
                    dungeon.characters.Add(slime);
                    break;
                }
                }
            }
        }
Exemplo n.º 11
0
        public override void DayUpdate(int dayOfMonth)
        {
            int waters = 0;

            for (int i = 0; i < waterSpots.Length; i++)
            {
                if (waterSpots[i] && waters * 5 < characters.Count)
                {
                    waters++;
                    waterSpots[i] = false;
                }
            }
            for (int numSlimeBalls = Math.Min(characters.Count / 5, waters); numSlimeBalls > 0; numSlimeBalls--)
            {
                int     tries = 50;
                Vector2 tile  = getRandomTile();
                while ((!isTileLocationTotallyClearAndPlaceable(tile) || doesTileHaveProperty((int)tile.X, (int)tile.Y, "NPCBarrier", "Back") != null || tile.Y >= 12f) && tries > 0)
                {
                    tile = getRandomTile();
                    tries--;
                }
                if (tries > 0)
                {
                    objects.Add(tile, new Object(tile, 56));
                }
            }
            while ((int)slimeMatingsLeft > 0)
            {
                if (characters.Count > 1 && !isFull())
                {
                    NPC mate4 = characters[Game1.random.Next(characters.Count)];
                    if (mate4 is GreenSlime)
                    {
                        GreenSlime mate3 = mate4 as GreenSlime;
                        if ((int)mate3.ageUntilFullGrown <= 0)
                        {
                            for (int distance = 1; distance < 10; distance++)
                            {
                                GreenSlime mate2 = (GreenSlime)Utility.checkForCharacterWithinArea(mate3.GetType(), mate4.Position, this, new Rectangle((int)mate3.Position.X - 64 * distance, (int)mate3.Position.Y - 64 * distance, 64 * (distance * 2 + 1), 64 * (distance * 2 + 1)));
                                if (mate2 != null && mate2.cute != mate3.cute && (int)mate2.ageUntilFullGrown <= 0)
                                {
                                    mate3.mateWith(mate2, this);
                                    break;
                                }
                            }
                        }
                    }
                }
                slimeMatingsLeft.Value--;
            }
            slimeMatingsLeft.Value = characters.Count / 5 + 1;
            base.DayUpdate(dayOfMonth);
        }
Exemplo n.º 12
0
        public override void DayUpdate(int dayOfMonth)
        {
            int val2 = 0;

            for (int index = 0; index < this.waterSpots.Length; ++index)
            {
                if (this.waterSpots[index] && val2 * 5 < this.characters.Count)
                {
                    ++val2;
                    this.waterSpots[index] = false;
                    this.setMapTileIndex(16, 6 + index, 2134, "Buildings", 0);
                }
            }
            for (int index = Math.Min(this.characters.Count / 5, val2); index > 0; --index)
            {
                int     num = 50;
                Vector2 randomTile;
                for (randomTile = this.getRandomTile(); (!this.isTileLocationTotallyClearAndPlaceable(randomTile) || this.doesTileHaveProperty((int)randomTile.X, (int)randomTile.Y, "NPCBarrier", "Back") != null || (double)randomTile.Y >= 12.0) && num > 0; --num)
                {
                    randomTile = this.getRandomTile();
                }
                if (num > 0)
                {
                    this.objects.Add(randomTile, new Object(randomTile, 56, false));
                }
            }
            for (; this.slimeMatingsLeft > 0; this.slimeMatingsLeft = this.slimeMatingsLeft - 1)
            {
                if (this.characters.Count > 1 && !this.isFull())
                {
                    NPC character = this.characters[Game1.random.Next(this.characters.Count)];
                    if (character is GreenSlime)
                    {
                        GreenSlime greenSlime = character as GreenSlime;
                        if (greenSlime.ageUntilFullGrown <= 0)
                        {
                            for (int index = 1; index < 10; ++index)
                            {
                                GreenSlime mateToPursue = (GreenSlime)Utility.checkForCharacterWithinArea(greenSlime.GetType(), character.position, (GameLocation)this, new Rectangle((int)greenSlime.position.X - Game1.tileSize * index, (int)greenSlime.position.Y - Game1.tileSize * index, Game1.tileSize * (index * 2 + 1), Game1.tileSize * (index * 2 + 1)));
                                if (mateToPursue != null && mateToPursue.cute != greenSlime.cute && mateToPursue.ageUntilFullGrown <= 0)
                                {
                                    greenSlime.mateWith(mateToPursue, (GameLocation)this);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            this.slimeMatingsLeft = this.characters.Count / 5 + 1;
            base.DayUpdate(dayOfMonth);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Clones the given monster and puts it on the same place as the original
        /// </summary>
        /// <param name="dungeon"></param>
        /// <param name="monster"></param>
        private void CloneVolcanoDungeonMonster(VolcanoDungeon dungeon, Monster monster)
        {
            Monster clone            = null;
            var     originalPosition = monster.Position;

            if (monster is Duggy)
            {
                clone = new Duggy(originalPosition, magmaDuggy: true);
            }
            else if (monster is RockCrab)
            {
                clone = new RockCrab(originalPosition, ModEntry.VolcanoRockCrabName);
            }
            else if (monster is Bat bat)
            {
                var batName = bat.Name;
                if (ModEntry.VolcanoBatNameToMineLevel.ContainsKey(batName))
                {
                    clone = new Bat(originalPosition, ModEntry.VolcanoBatNameToMineLevel[batName]);
                }
            }
            else if (monster is LavaLurk)
            {
                clone = new LavaLurk(originalPosition);
            }
            else if (monster is HotHead)
            {
                clone = new HotHead(originalPosition);
            }
            else if (monster is GreenSlime)
            {
                var greenSlime = new GreenSlime(originalPosition, 0);
                greenSlime.makeTigerSlime();
                clone = greenSlime;
            }
            else if (monster is Spiker spike)
            {
                return;
            }
            if (clone == null)
            {
                this.Monitor.Log($"Cloning of monster \"{monster.Name}\" is not supported.", LogLevel.Warn);
            }
            else
            {
                dungeon.addCharacter(clone);
            }
        }
Exemplo n.º 14
0
        public void checkForSlimeAndSpawn(object sender, EventArgsMouseStateChanged e)
        {
            Farmer f = Game1.player;

            if (f.CurrentItem != null)
            {
                if (f.CurrentItem.parentSheetIndex == 766)
                {
                    if (e.NewState.RightButton == ButtonState.Pressed && e.PriorState.RightButton != ButtonState.Pressed)
                    {
                        f.reduceActiveItemByOne();
                        Monster monster = new GreenSlime(f.position);
                        Game1.currentLocation.characters.Add(monster);
                        monster.jump();
                    }
                }
            }
        }
Exemplo n.º 15
0
    private void OnGridCollision(GridTransform other)
    {
        GreenSlime slime = other.GetComponentInParent <GreenSlime>();

        if (slime == this)
        {
            return;
        }

        Player player = other.GetComponent <Player>();

        if (player != null)
        {
            Destroy(gameObject);
            CEventSystem.BroadcastEvent(EventChannel.gameState, EventSubChannel.none, new GrowEvent(GameState.SnakeGrowCount));
            CEventSystem.BroadcastEvent(EventChannel.gameState, EventSubChannel.none, new GameState.EnemyDestroyedEvent());
        }
    }
Exemplo n.º 16
0
        protected override void resetSharedState()
        {
            base.resetSharedState();
            if ((bool)addedSlimesToday)
            {
                return;
            }
            addedSlimesToday.Value = true;
            Random rand = new Random((int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame + 12);

            Microsoft.Xna.Framework.Rectangle spawnArea = new Microsoft.Xna.Framework.Rectangle(28, 24, 19, 8);
            for (int tries = 5; tries > 0; tries--)
            {
                Vector2 tile = Utility.getRandomPositionInThisRectangle(spawnArea, rand);
                if (isTileLocationTotallyClearAndPlaceable(tile))
                {
                    GreenSlime i = new GreenSlime(tile * 64f, 0);
                    i.makeTigerSlime();
                    characters.Add(i);
                }
            }
        }
Exemplo n.º 17
0
            /// <summary>Generates a monster and places it on the specified map and tile.</summary>
            /// <param name="monsterType">The monster type's name and an optional dictionary of monster-specific settings.</param>
            /// <param name="location">The GameLocation where the monster should be spawned.</param>
            /// <param name="tile">The x/y coordinates of the tile where the monster should be spawned.</param>
            /// <param name="areaID">The UniqueAreaID of the related SpawnArea. Required for log messages.</param>
            /// <returns>Returns the monster's ID value, or null if the spawn process failed.</returns>
            public static int?SpawnMonster(MonsterType monsterType, GameLocation location, Vector2 tile, string areaID = "")
            {
                Monster monster = null;                                                                      //an instatiated monster, to be spawned into the world later

                Color?color = null;                                                                          //the monster's color (used by specific monster types)

                if (monsterType.Settings != null)                                                            //if settings were provided
                {
                    if (monsterType.Settings.ContainsKey("Color"))                                           //if this setting was provided
                    {
                        string[]   colorText    = ((string)monsterType.Settings["Color"]).Trim().Split(' '); //split the setting string into strings for each number
                        List <int> colorNumbers = new List <int>();
                        foreach (string text in colorText)                                                   //for each string
                        {
                            int num = Convert.ToInt32(text);                                                 //convert it to a number
                            if (num < 0)
                            {
                                num = 0;
                            }                         //minimum 0
                            else if (num > 255)
                            {
                                num = 255;
                            }                      //maximum 255
                            colorNumbers.Add(num); //add it to the list
                        }

                        //convert strings into RGBA values
                        int r = Convert.ToInt32(colorNumbers[0]);
                        int g = Convert.ToInt32(colorNumbers[1]);
                        int b = Convert.ToInt32(colorNumbers[2]);
                        int a;
                        if (colorNumbers.Count > 3) //if the setting included an "A" value
                        {
                            a = Convert.ToInt32(colorNumbers[3]);
                        }
                        else //if the setting did not include an "A" value
                        {
                            a = 255; //default to no transparency
                        }

                        color = new Color(r, g, b, a);                                                                     //set the color
                    }
                    else if (monsterType.Settings.ContainsKey("MinColor") && monsterType.Settings.ContainsKey("MaxColor")) //if color wasn't provided, but mincolor & maxcolor were
                    {
                        string[]   minColorText    = ((string)monsterType.Settings["MinColor"]).Trim().Split(' ');         //split the setting string into strings for each number
                        List <int> minColorNumbers = new List <int>();
                        foreach (string text in minColorText)                                                              //for each string
                        {
                            int num = Convert.ToInt32(text);                                                               //convert it to a number
                            if (num < 0)
                            {
                                num = 0;
                            }                         //minimum 0
                            else if (num > 255)
                            {
                                num = 255;
                            }                         //maximum 255
                            minColorNumbers.Add(num); //add it to the list
                        }

                        string[]   maxColorText    = ((string)monsterType.Settings["MaxColor"]).Trim().Split(' '); //split the setting string into strings for each number
                        List <int> maxColorNumbers = new List <int>();
                        foreach (string text in maxColorText)                                                      //for each string
                        {
                            int num = Convert.ToInt32(text);                                                       //convert it to a number
                            if (num < 0)
                            {
                                num = 0;
                            }                         //minimum 0
                            else if (num > 255)
                            {
                                num = 255;
                            }                         //maximum 255
                            maxColorNumbers.Add(num); //convert to number
                        }

                        for (int x = 0; x < minColorNumbers.Count && x < maxColorNumbers.Count; x++) //for each pair of values
                        {
                            if (minColorNumbers[x] > maxColorNumbers[x])                             //if min > max
                            {
                                //swap min and max
                                int temp = minColorNumbers[x];
                                minColorNumbers[x] = maxColorNumbers[x];
                                maxColorNumbers[x] = temp;
                            }
                        }

                        //pick random RGBA values between min and max
                        int r = RNG.Next(minColorNumbers[0], maxColorNumbers[0] + 1);
                        int g = RNG.Next(minColorNumbers[1], maxColorNumbers[1] + 1);
                        int b = RNG.Next(minColorNumbers[2], maxColorNumbers[2] + 1);
                        int a;
                        if (minColorNumbers.Count > 3 && maxColorNumbers.Count > 3) //if both settings included an "A" value
                        {
                            a = RNG.Next(minColorNumbers[3], maxColorNumbers[3] + 1);
                        }
                        else //if one/both of the settings did not include an "A" value
                        {
                            a = 255; //default to no transparency
                        }

                        color = new Color(r, g, b, a); //set the color
                    }
                }

                bool seesPlayers = false;                                               //whether the monster automatically "sees" players at spawn (handled differently by some monster types)

                if (monsterType.Settings != null)                                       //if settings were provided
                {
                    if (monsterType.Settings.ContainsKey("SeesPlayersAtSpawn"))         //if this setting was provided
                    {
                        seesPlayers = (bool)monsterType.Settings["SeesPlayersAtSpawn"]; //use the provided setting
                    }
                }

                //create a new monster based on the provided name & apply type-specific settings
                switch (monsterType.MonsterName.ToLower()) //avoid most casing issues by making this lower-case
                {
                case "bat":
                    monster = new BatFTM(tile, 0);
                    break;

                case "frostbat":
                case "frost bat":
                    monster = new BatFTM(tile, 40);
                    break;

                case "lavabat":
                case "lava bat":
                    monster = new BatFTM(tile, 80);
                    break;

                case "iridiumbat":
                case "iridium bat":
                    monster = new BatFTM(tile, 171);
                    break;

                case "doll":
                case "curseddoll":
                case "cursed doll":
                    monster = new BatFTM(tile, -666);
                    break;

                case "skull":
                case "hauntedskull":
                case "haunted skull":
                    monster = new BatFTM(tile, 77377);
                    break;

                case "bigslime":
                case "big slime":
                case "biggreenslime":
                case "big green slime":
                    monster = new BigSlimeFTM(tile, 0);
                    if (color.HasValue)                               //if color was provided
                    {
                        ((BigSlimeFTM)monster).c.Value = color.Value; //set its color after creation
                    }
                    if (seesPlayers)                                  //if the "SeesPlayersAtSpawn" setting is true
                    {
                        monster.IsWalkingTowardPlayer = true;
                    }
                    break;

                case "bigblueslime":
                case "big blue slime":
                case "bigfrostjelly":
                case "big frost jelly":
                    monster = new BigSlimeFTM(tile, 40);
                    if (color.HasValue)                               //if color was provided
                    {
                        ((BigSlimeFTM)monster).c.Value = color.Value; //set its color after creation
                    }
                    if (seesPlayers)                                  //if the "SeesPlayersAtSpawn" setting is true
                    {
                        monster.IsWalkingTowardPlayer = true;
                    }
                    break;

                case "bigredslime":
                case "big red slime":
                case "bigredsludge":
                case "big red sludge":
                    monster = new BigSlimeFTM(tile, 80);
                    if (color.HasValue)                               //if color was provided
                    {
                        ((BigSlimeFTM)monster).c.Value = color.Value; //set its color after creation
                    }
                    if (seesPlayers)                                  //if the "SeesPlayersAtSpawn" setting is true
                    {
                        monster.IsWalkingTowardPlayer = true;
                    }
                    break;

                case "bigpurpleslime":
                case "big purple slime":
                case "bigpurplesludge":
                case "big purple sludge":
                    monster = new BigSlimeFTM(tile, 121);
                    if (color.HasValue)                               //if color was provided
                    {
                        ((BigSlimeFTM)monster).c.Value = color.Value; //set its color after creation
                    }
                    if (seesPlayers)                                  //if the "SeesPlayersAtSpawn" setting is true
                    {
                        monster.IsWalkingTowardPlayer = true;
                    }
                    break;

                case "bug":
                    monster = new Bug(tile, 0);
                    break;

                case "armoredbug":
                case "armored bug":
                    monster = new Bug(tile, 121);
                    break;

                case "dino":
                case "dinomonster":
                case "dino monster":
                case "pepper":
                case "pepperrex":
                case "pepper rex":
                case "rex":
                    monster = new DinoMonster(tile);
                    break;

                case "duggy":
                    monster = new DuggyFTM(tile);
                    break;

                case "dust":
                case "sprite":
                case "dustsprite":
                case "dust sprite":
                case "spirit":
                case "dustspirit":
                case "dust spirit":
                    monster = new DustSpirit(tile);
                    break;

                case "ghost":
                    monster = new GhostFTM(tile);
                    break;

                case "carbonghost":
                case "carbon ghost":
                    monster = new GhostFTM(tile, "Carbon Ghost");
                    break;

                case "slime":
                case "greenslime":
                case "green slime":
                    monster = new GreenSlime(tile, 0);
                    if (color.HasValue)                                  //if color was also provided
                    {
                        ((GreenSlime)monster).color.Value = color.Value; //set its color after creation
                    }
                    break;

                case "blueslime":
                case "blue slime":
                case "frostjelly":
                case "frost jelly":
                    monster = new GreenSlime(tile, 40);
                    if (color.HasValue)                                  //if color was also provided
                    {
                        ((GreenSlime)monster).color.Value = color.Value; //set its color after creation
                    }
                    break;

                case "redslime":
                case "red slime":
                case "redsludge":
                case "red sludge":
                    monster = new GreenSlime(tile, 80);
                    if (color.HasValue)                                  //if color was also provided
                    {
                        ((GreenSlime)monster).color.Value = color.Value; //set its color after creation
                    }
                    break;

                case "purpleslime":
                case "purple slime":
                case "purplesludge":
                case "purple sludge":
                    monster = new GreenSlime(tile, 121);
                    if (color.HasValue)                                  //if color was also provided
                    {
                        ((GreenSlime)monster).color.Value = color.Value; //set its color after creation
                    }
                    break;

                case "grub":
                case "cavegrub":
                case "cave grub":
                    monster = new GrubFTM(tile, false);
                    break;

                case "fly":
                case "cavefly":
                case "cave fly":
                    monster = new FlyFTM(tile, false);
                    break;

                case "mutantgrub":
                case "mutant grub":
                    monster = new GrubFTM(tile, true);
                    break;

                case "mutantfly":
                case "mutant fly":
                    monster = new FlyFTM(tile, true);
                    break;

                case "metalhead":
                case "metal head":
                    monster = new MetalHead(tile, 0);
                    if (color.HasValue)                             //if color was provided
                    {
                        ((MetalHead)monster).c.Value = color.Value; //set its color after creation
                    }
                    break;

                case "mummy":
                    monster = new MummyFTM(tile);
                    break;

                case "rockcrab":
                case "rock crab":
                    monster = new RockCrab(tile);
                    break;

                case "lavacrab":
                case "lava crab":
                    monster = new LavaCrab(tile);
                    break;

                case "iridiumcrab":
                case "iridium crab":
                    monster = new RockCrab(tile, "Iridium Crab");
                    break;

                case "rockgolem":
                case "rock golem":
                case "stonegolem":
                case "stone golem":
                    monster = new RockGolemFTM(tile);
                    break;

                case "wildernessgolem":
                case "wilderness golem":
                    monster = new RockGolemFTM(tile, Game1.player.CombatLevel);
                    break;

                case "serpent":
                    monster = new SerpentFTM(tile);
                    break;

                case "brute":
                case "shadowbrute":
                case "shadow brute":
                    monster = new ShadowBrute(tile);
                    break;

                case "shaman":
                case "shadowshaman":
                case "shadow shaman":
                    monster = new ShadowShaman(tile);
                    break;

                case "skeleton":
                    monster = new Skeleton(tile);
                    if (seesPlayers)                                                                                        //if the "SeesPlayersAtSpawn" setting is true
                    {
                        IReflectedField <bool> spottedPlayer = Helper.Reflection.GetField <bool>(monster, "spottedPlayer"); //try to access this skeleton's private "spottedPlayer" field
                        spottedPlayer.SetValue(true);
                        monster.IsWalkingTowardPlayer = true;
                    }
                    break;

                case "squid":
                case "kid":
                case "squidkid":
                case "squid kid":
                    monster = new SquidKidFTM(tile);
                    break;

                default:                                                                           //if the name doesn't match any directly known monster types
                    Type externalType = GetTypeFromName(monsterType.MonsterName, typeof(Monster)); //find a monster subclass with a matching name
                    monster = (Monster)Activator.CreateInstance(externalType, tile);               //create a monster with the Vector2 constructor
                    break;
                }

                if (monster == null)
                {
                    Monitor.Log($"The monster to be spawned (\"{monsterType.MonsterName}\") doesn't match any known monster types. Make sure that name isn't misspelled in your config file.", LogLevel.Info);
                    return(null);
                }

                int?ID = MonsterTracker.AddMonster(monster);  //generate an ID for this monster

                if (!ID.HasValue)
                {
                    Monitor.Log("A new monster ID could not be generated. This is may be due to coding issue; please report it to this mod's developer. This monster won't be spawned.", LogLevel.Warn);
                    return(null);
                }
                monster.id = ID.Value;                                       //assign the ID to this monster

                monster.MaxHealth = monster.Health;                          //some monster types set Health on creation and expect MaxHealth to be updated like this

                ApplyMonsterSettings(monster, monsterType.Settings, areaID); //adjust the monster based on any other provided optional settings

                //spawn the completed monster at the target location
                Monitor.VerboseLog($"Spawning monster. Type: {monsterType.MonsterName}. Location: {tile.X},{tile.Y} ({location.Name}).");
                monster.currentLocation = location;
                monster.setTileLocation(tile);
                location.addCharacter(monster);
                return(monster.id);
            }
Exemplo n.º 18
0
        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);
        }
Exemplo n.º 19
0
        /*********
        ** 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!");
            }
        }
        public override void Damage(Mobile m)
        {
            base.Damage(m);

            if (m.Alive)
            {
                Item item = m.FindItemOnLayer(Layer.OuterTorso);

                if (item is GMRobe)
                {
                    AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                }
                else if (item is GMRobeExplosion)
                {
                    AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                    m.PlaySound(Utility.RandomList(0x307, 0x308));
                }
                else if (item is GMRobeHoly)
                {
                    AOS.Damage(m, 0, 0, 0, 0, 0, 0);

                    m.FixedParticles(0x375A, 1, 30, 9966, 88, 2, EffectLayer.Head);
                    m.FixedParticles(0x37B9, 1, 30, 9502, 85, 3, EffectLayer.Head);
                    m.FixedParticles(0x376A, 1, 31, 9961, 80, 0, EffectLayer.Waist);
                    m.FixedParticles(0x37C4, 1, 31, 9502, 88, 2, EffectLayer.Waist);
                }
                else if (item is GMRobeFarts)
                {
                    AOS.Damage(m, 0, 0, 0, 0, 0, 0);

                    m.PlaySound(Utility.RandomList(792, 1064));
                }
                else if (item is GMRobeTrailfire)
                {
                    AOS.Damage(m, 0, 0, 0, 0, 0, 0);

                    m.FixedParticles(0x3709, 10, 30, 5052, EffectLayer.LeftFoot);
                }
                else
                {
                    if (m.Title == "the Running Pants")
                    {
                        if (m.Str <= 100)
                        {
                            if (Utility.RandomDouble() < 0.0003)
                            {
                                m.Str += 1;
                                m.BoltEffect(0x480);
                                m.PlaySound(0x5CE);
                                AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                            }
                        }
                    }

                    // Wind
                    if (Utility.RandomDouble() < 0.002)
                    {
                        m.PlaySound(Utility.RandomList(0x014, 0x15, 0x016, 0x5C7));
                        AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                    }

                    if (Utility.RandomDouble() < 0.002)
                    {
                        m.PlaySound(Utility.RandomList(0x014, 0x15, 0x016, 0x5C7));
                        AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                    }

                    if (m.Kills >= 5)
                    {
                        // Wasteland Mercenary Ambush
                        if (Utility.RandomDouble() < 0.005)
                        {
                            if (m.Map == Map.Malas)
                            {
                                int x1 = m.X + 20;
                                int y1 = m.Y + 20;
                                int z1 = Map.Malas.GetAverageZ(x1, y1);

                                if (Map.Malas.CanSpawnMobile(x1, y1, z1))
                                {
                                    BaseCreature wastelandmercenary = new WastelandMercenary();
                                    wastelandmercenary.MoveToWorld(new Point3D(x1, y1, z1), Map.Malas);
                                    wastelandmercenary.Combatant = m;
                                    wastelandmercenary.PlaySound(0x220);                           // Earthquake

                                    m.PlaySound(0x5CE);
                                    wastelandmercenary.BoltEffect(0x480);
                                    AOS.Damage(m, 0, 0, 0, 0, 0, 0);

                                    Timer.DelayCall(TimeSpan.FromMinutes(30.0), new TimerStateCallback(DeleteWastelandMercenary), wastelandmercenary);
                                }
                            }

                            // Wasteland Mercenary 2
                            if (Utility.RandomDouble() < 0.005)
                            {
                                if (m.Map == Map.Malas)
                                {
                                    int x2 = m.X - 20;
                                    int y2 = m.Y - 20;
                                    int z2 = Map.Malas.GetAverageZ(x2, y2);

                                    if (Map.Malas.CanSpawnMobile(x2, y2, z2))
                                    {
                                        BaseCreature wastelandmercenary = new WastelandMercenary();
                                        wastelandmercenary.MoveToWorld(new Point3D(x2, y2, z2), Map.Malas);
                                        wastelandmercenary.Combatant = m;
                                        wastelandmercenary.PlaySound(0x220);                           // Earthquake

                                        m.PlaySound(0x5CE);
                                        wastelandmercenary.BoltEffect(0x480);
                                        AOS.Damage(m, 0, 0, 0, 0, 0, 0);

                                        Timer.DelayCall(TimeSpan.FromMinutes(30.0), new TimerStateCallback(DeleteWastelandMercenary), wastelandmercenary);
                                    }
                                }
                            }
                        }
                    }

                    // Dragon Encounter 1
                    if (Utility.RandomDouble() < 0.0001)
                    {
                        if (m.Map == Map.Malas)
                        {
                            int x1 = m.X + 15;
                            int y1 = m.Y + 15;
                            int z1 = Map.Malas.GetAverageZ(x1, y1);

                            if (Map.Malas.CanSpawnMobile(x1, y1, z1))
                            {
                                BaseCreature dragonencounter;
                                switch (Utility.Random(2))
                                {
                                default:
                                case 0: dragonencounter = new BlackDragon(); break;

                                case 1: dragonencounter = new BlackDragon(); break;
                                }
                                dragonencounter.MoveToWorld(new Point3D(x1, y1, z1), Map.Malas);
                                dragonencounter.Combatant = m;
                                m.PlaySound(0x656);                 // risingColossus

                                AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                                Timer.DelayCall(TimeSpan.FromMinutes(30.0), new TimerStateCallback(DeleteDragonEncounter), dragonencounter);
                            }
                        }
                    }

                    // Dragon Encounter 2
                    if (Utility.RandomDouble() < 0.0001)
                    {
                        if (m.Map == Map.Malas)
                        {
                            int x2 = m.X - 12;
                            int y2 = m.Y - 12;
                            int z2 = Map.Malas.GetAverageZ(x2, y2);

                            if (Map.Malas.CanSpawnMobile(x2, y2, z2))
                            {
                                BaseCreature dragonencounter;
                                switch (Utility.Random(8))
                                {
                                default:
                                case 0: dragonencounter = new BlackDragon(); break;

                                case 1: dragonencounter = new BlackDragon(); break;
                                }
                                dragonencounter.MoveToWorld(new Point3D(x2, y2, z2), Map.Malas);
                                dragonencounter.Combatant = m;
                                m.PlaySound(0x656);                 // risingColossus

                                AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                                Timer.DelayCall(TimeSpan.FromMinutes(30.0), new TimerStateCallback(DeleteDragonEncounter), dragonencounter);
                            }
                        }
                    }

                    // Random Encounter 1
                    if (Utility.RandomDouble() < 0.00002)
                    {
                        if (m.Map == Map.Malas)
                        {
                            int x1 = m.X + 12;
                            int y1 = m.Y + 12;
                            int z1 = Map.Malas.GetAverageZ(x1, y1);

                            if (Map.Malas.CanSpawnMobile(x1, y1, z1))
                            {
                                BaseCreature encountera;
                                switch (Utility.Random(15))
                                {
                                default:
                                case 0: encountera = new Almiraj(); break;

                                case 1: encountera = new BlackAntAmbusher(); break;

                                case 2: encountera = new FaerieBeetleCollector(); break;

                                case 3: encountera = new GazerLarva(); break;

                                case 4: encountera = new Gizzard(); break;

                                case 5: encountera = new GreenSlime(); break;

                                case 6: encountera = new HordeMinion(); break;

                                case 7: encountera = new Mongbat(); break;

                                case 8: encountera = new Orc(); break;

                                case 9: encountera = new Ratman(); break;

                                case 10: encountera = new StreamingWisp(); break;

                                case 11: encountera = new SwampVine(); break;

                                case 12: encountera = new Tokoloshe(); break;

                                case 13: encountera = new VerdantSprite(); break;

                                case 14: encountera = new WaterLizard(); break;
                                }
                                encountera.MoveToWorld(new Point3D(x1, y1, z1), Map.Malas);

                                AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                                Timer.DelayCall(TimeSpan.FromMinutes(10.0), new TimerStateCallback(DeleteEncounterA), encountera);
                            }
                        }
                    }

                    // Random Encounter 2
                    if (Utility.RandomDouble() < 0.00002)
                    {
                        if (m.Map == Map.Malas)
                        {
                            int x2 = m.X - 12;
                            int y2 = m.Y - 12;
                            int z2 = Map.Malas.GetAverageZ(x2, y2);

                            if (Map.Malas.CanSpawnMobile(x2, y2, z2))
                            {
                                BaseCreature encountera;
                                switch (Utility.Random(15))
                                {
                                default:
                                case 0: encountera = new Almiraj(); break;

                                case 1: encountera = new BlackAntAmbusher(); break;

                                case 2: encountera = new FaerieBeetleCollector(); break;

                                case 3: encountera = new GazerLarva(); break;

                                case 4: encountera = new Gizzard(); break;

                                case 5: encountera = new GreenSlime(); break;

                                case 6: encountera = new HordeMinion(); break;

                                case 7: encountera = new Mongbat(); break;

                                case 8: encountera = new Orc(); break;

                                case 9: encountera = new Ratman(); break;

                                case 10: encountera = new StreamingWisp(); break;

                                case 11: encountera = new SwampVine(); break;

                                case 12: encountera = new Tokoloshe(); break;

                                case 13: encountera = new VerdantSprite(); break;

                                case 14: encountera = new WaterLizard(); break;
                                }
                                encountera.MoveToWorld(new Point3D(x2, y2, z2), Map.Malas);

                                AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                                Timer.DelayCall(TimeSpan.FromMinutes(10.0), new TimerStateCallback(DeleteEncounterA), encountera);
                            }
                        }
                    }

                    // Tamable Encounter 1
                    if (Utility.RandomDouble() < 0.00002)
                    {
                        if (m.Map == Map.Malas)
                        {
                            int x1 = m.X + 12;
                            int y1 = m.Y + 12;
                            int z1 = Map.Malas.GetAverageZ(x1, y1);

                            if (Map.Malas.CanSpawnMobile(x1, y1, z1))
                            {
                                BaseCreature tameable;
                                switch (Utility.Random(23))
                                {
                                default:
                                case 0: tameable = new Bird(); break;

                                case 1: tameable = new Boar(); break;

                                case 2: tameable = new BrownBear(); break;

                                case 3: tameable = new Bull(); break;

                                case 4: tameable = new Chicken(); break;

                                case 5: tameable = new Cow(); break;

                                case 6: tameable = new ForestBat(); break;

                                case 7: tameable = new Goat(); break;

                                case 8: tameable = new GreatHart(); break;

                                case 9: tameable = new GreenSlime(); break;

                                case 10: tameable = new GreySquirrel(); break;

                                case 11: tameable = new GreyWolfPup(); break;

                                case 12: tameable = new Hind(); break;

                                case 13: tameable = new Horse(); break;

                                case 14: tameable = new LargeFrog(); break;

                                case 15: tameable = new Ogumo(); break;

                                case 16: tameable = new Panther(); break;

                                case 17: tameable = new Pig(); break;

                                case 18: tameable = new Rabbit(); break;

                                case 19: tameable = new Rat(); break;

                                case 20: tameable = new RhinoBeetle(); break;

                                case 21: tameable = new RunningPants(); break;

                                case 22: tameable = new Sheep(); break;
                                }
                                tameable.MoveToWorld(new Point3D(x1, y1, z1), Map.Malas);

                                AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                                Timer.DelayCall(TimeSpan.FromMinutes(10.0), new TimerStateCallback(DeleteTameable), tameable);
                            }
                        }
                    }

                    // Tamable Encounter 2
                    if (Utility.RandomDouble() < 0.00002)
                    {
                        if (m.Map == Map.Malas)
                        {
                            int x2 = m.X - 12;
                            int y2 = m.Y - 12;
                            int z2 = Map.Malas.GetAverageZ(x2, y2);

                            if (Map.Malas.CanSpawnMobile(x2, y2, z2))
                            {
                                BaseCreature tameable;
                                switch (Utility.Random(23))
                                {
                                default:
                                case 0: tameable = new Bird(); break;

                                case 1: tameable = new Boar(); break;

                                case 2: tameable = new BrownBear(); break;

                                case 3: tameable = new Bull(); break;

                                case 4: tameable = new Chicken(); break;

                                case 5: tameable = new Cow(); break;

                                case 6: tameable = new ForestBat(); break;

                                case 7: tameable = new Goat(); break;

                                case 8: tameable = new GreatHart(); break;

                                case 9: tameable = new GreenSlime(); break;

                                case 10: tameable = new GreySquirrel(); break;

                                case 11: tameable = new GreyWolfPup(); break;

                                case 12: tameable = new Hind(); break;

                                case 13: tameable = new Horse(); break;

                                case 14: tameable = new LargeFrog(); break;

                                case 15: tameable = new Ogumo(); break;

                                case 16: tameable = new Panther(); break;

                                case 17: tameable = new Pig(); break;

                                case 18: tameable = new Rabbit(); break;

                                case 19: tameable = new Rat(); break;

                                case 20: tameable = new RhinoBeetle(); break;

                                case 21: tameable = new RunningPants(); break;

                                case 22: tameable = new Sheep(); break;
                                }
                                tameable.MoveToWorld(new Point3D(x2, y2, z2), Map.Malas);

                                AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                                Timer.DelayCall(TimeSpan.FromMinutes(10.0), new TimerStateCallback(DeleteTameable), tameable);
                            }
                        }
                    }

                    // Random Adventurer 1
                    if (Utility.RandomDouble() < 0.00002)
                    {
                        if (m.Map == Map.Malas)
                        {
                            int x1 = m.X + 15;
                            int y1 = m.Y + 15;
                            int z1 = Map.Malas.GetAverageZ(x1, y1);

                            if (Map.Malas.CanSpawnMobile(x1, y1, z1))
                            {
                                BaseCreature friendlyencounter;
                                switch (Utility.Random(2))
                                {
                                default:
                                case 0: friendlyencounter = new ZaythalorHuman(); break;

                                case 1: friendlyencounter = new ZaythalorSunElf(); break;

                                case 2: friendlyencounter = new ZaythalorMoonElf(); break;
                                }
                                friendlyencounter.MoveToWorld(new Point3D(x1, y1, z1), Map.Malas);

                                AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                                Timer.DelayCall(TimeSpan.FromMinutes(10.0), new TimerStateCallback(DeleteFriendlyEncounter), friendlyencounter);
                            }
                        }
                    }

                    // Random Adventurer 2
                    if (Utility.RandomDouble() < 0.00002)
                    {
                        if (m.Map == Map.Malas)
                        {
                            int x2 = m.X - 15;
                            int y2 = m.Y - 15;
                            int z2 = Map.Malas.GetAverageZ(x2, y2);

                            if (Map.Malas.CanSpawnMobile(x2, y2, z2))
                            {
                                BaseCreature friendlyencounter;
                                switch (Utility.Random(2))
                                {
                                default:
                                case 0: friendlyencounter = new ZaythalorHuman(); break;

                                case 1: friendlyencounter = new ZaythalorSunElf(); break;

                                case 2: friendlyencounter = new ZaythalorMoonElf(); break;
                                }
                                friendlyencounter.MoveToWorld(new Point3D(x2, y2, z2), Map.Malas);

                                AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                                Timer.DelayCall(TimeSpan.FromMinutes(10.0), new TimerStateCallback(DeleteFriendlyEncounter), friendlyencounter);
                            }
                        }
                    }

                    // Random Treasure Chest 1
                    if (Utility.RandomDouble() < 0.0005)
                    {
                        if (m.Map == Map.Malas)
                        {
                            int x1 = m.X + 12;
                            int y1 = m.Y + 12;
                            int z1 = Map.Malas.GetAverageZ(x1, y1);

                            if (Map.Malas.CanSpawnMobile(x1, y1, z1))
                            {
                                BaseContainer treasurechest;

                                if (m.Skills.Tracking.Base > 4.9)
                                {
                                    switch (Utility.Random(2))
                                    {
                                    default:
                                    case 0: treasurechest = new ZaythalorForestTreasureChest1(); break;

                                    case 1: treasurechest = new ZaythalorForestTreasureChest1(); break;
                                    }
                                    treasurechest.MoveToWorld(new Point3D(x1, y1, z1), Map.Malas);

                                    AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                                    Timer.DelayCall(TimeSpan.FromMinutes(5.0), new TimerStateCallback(DeleteTreasureChest), treasurechest);
                                }
                            }
                        }
                    }

                    // Random Treasure Chest 2
                    if (Utility.RandomDouble() < 0.0005)
                    {
                        if (m.Map == Map.Malas)
                        {
                            int x2 = m.X - 12;
                            int y2 = m.Y - 12;
                            int z2 = Map.Malas.GetAverageZ(x2, y2);

                            if (Map.Malas.CanSpawnMobile(x2, y2, z2))
                            {
                                BaseContainer treasurechest;

                                if (m.Skills.Tracking.Base > 4.9)
                                {
                                    switch (Utility.Random(2))
                                    {
                                    default:
                                    case 0: treasurechest = new ZaythalorForestTreasureChest1(); break;

                                    case 1: treasurechest = new ZaythalorForestTreasureChest1(); break;
                                    }
                                    treasurechest.MoveToWorld(new Point3D(x2, y2, z2), Map.Malas);

                                    AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                                    Timer.DelayCall(TimeSpan.FromMinutes(5.0), new TimerStateCallback(DeleteTreasureChest), treasurechest);
                                }
                            }
                        }
                    }

                    // Random Dead Body 1
                    if (Utility.RandomDouble() < 0.0003)
                    {
                        if (m.Map == Map.Malas)
                        {
                            int x1 = m.X + 10;
                            int y1 = m.Y + 10;
                            int z1 = Map.Malas.GetAverageZ(x1, y1);

                            if (Map.Malas.CanSpawnMobile(x1, y1, z1))
                            {
                                BaseContainer deadbody;

                                switch (Utility.Random(4))
                                {
                                default:
                                case 0: deadbody = new UnknownBardSkeletonZaythalor(); break;

                                case 1: deadbody = new UnknownMageSkeletonZaythalor(); break;

                                case 2: deadbody = new UnknownRogueSkeletonZaythalor(); break;

                                case 3: deadbody = new UnknownRogueSkeletonZaythalor(); break;
                                }

                                deadbody.MoveToWorld(new Point3D(x1, y1, z1), Map.Malas);

                                AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                                Timer.DelayCall(TimeSpan.FromMinutes(5.0), new TimerStateCallback(DeleteDeadBody), deadbody);
                            }
                        }
                    }

                    // Random Dead Body 2
                    if (Utility.RandomDouble() < 0.0003)
                    {
                        if (m.Map == Map.Malas)
                        {
                            int x2 = m.X - 10;
                            int y2 = m.Y - 10;
                            int z2 = Map.Malas.GetAverageZ(x2, y2);

                            if (Map.Malas.CanSpawnMobile(x2, y2, z2))
                            {
                                BaseContainer deadbody;

                                switch (Utility.Random(4))
                                {
                                default:
                                case 0: deadbody = new UnknownBardSkeletonZaythalor(); break;

                                case 1: deadbody = new UnknownMageSkeletonZaythalor(); break;

                                case 2: deadbody = new UnknownRogueSkeletonZaythalor(); break;

                                case 3: deadbody = new UnknownRogueSkeletonZaythalor(); break;
                                }

                                deadbody.MoveToWorld(new Point3D(x2, y2, z2), Map.Malas);

                                AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                                Timer.DelayCall(TimeSpan.FromMinutes(5.0), new TimerStateCallback(DeleteDeadBody), deadbody);
                            }
                        }
                    }

                    PlayerMobile player1 = m as PlayerMobile;
                    QuestSystem  qs1     = player1.Quest;

                    if (qs1 is StolenNecklaceQuest)
                    {
                        if (qs1.IsObjectiveInProgress(typeof(ReturnStolenNecklaceObjective)))
                        {
                            m.Send(Network.PlayMusic.GetInstance(MusicName.StygianAbyss));
                            AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                        }
                    }

                    PlayerMobile player = m as PlayerMobile;
                    QuestSystem  qs     = player.Quest;

                    if (qs is StolenNecklaceQuest)
                    {
                        if (qs.IsObjectiveInProgress(typeof(ReturnStolenNecklaceObjective)))
                        {
                            // Brigand Ambush
                            if (Utility.RandomDouble() < 0.015)
                            {
                                if (m.Map == Map.Malas)
                                {
                                    int x1 = m.X + 20;
                                    int y1 = m.Y + 20;
                                    int z1 = Map.Malas.GetAverageZ(x1, y1);

                                    if (Map.Malas.CanSpawnMobile(x1, y1, z1))
                                    {
                                        BaseCreature brigandmale = new BrigandMaleQuest();
                                        brigandmale.MoveToWorld(new Point3D(x1, y1, z1), Map.Malas);
                                        brigandmale.Combatant = m;
                                        m.Send(Network.PlayMusic.GetInstance(MusicName.StygianAbyss));

                                        AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                                        Timer.DelayCall(TimeSpan.FromMinutes(2.0), new TimerStateCallback(DeleteBrigandMale), brigandmale);
                                    }
                                }
                            }

                            // Brigand Ambush 2
                            if (Utility.RandomDouble() < 0.015)
                            {
                                if (m.Map == Map.Malas)
                                {
                                    int x2 = m.X - 20;
                                    int y2 = m.Y - 20;
                                    int z2 = Map.Malas.GetAverageZ(x2, y2);

                                    if (Map.Malas.CanSpawnMobile(x2, y2, z2))
                                    {
                                        BaseCreature brigandfemale = new BrigandFemaleQuest();
                                        brigandfemale.MoveToWorld(new Point3D(x2, y2, z2), Map.Malas);
                                        brigandfemale.Combatant = m;
                                        m.Send(Network.PlayMusic.GetInstance(MusicName.StygianAbyss));

                                        AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                                        Timer.DelayCall(TimeSpan.FromMinutes(2.0), new TimerStateCallback(DeleteBrigandFemale), brigandfemale);
                                    }
                                }
                            }
                        }
                    }

                    else if (qs is StaffOfFlyingMonkeysQuest)
                    {
                        if (qs.IsObjectiveInProgress(typeof(EscapeObjective)))
                        {
                            // Mongbat Ambush
                            if (Utility.RandomDouble() < 0.015)
                            {
                                if (m.Map == Map.Malas)
                                {
                                    int x1 = m.X + 20;
                                    int y1 = m.Y + 20;
                                    int z1 = Map.Malas.GetAverageZ(x1, y1);

                                    if (Map.Malas.CanSpawnMobile(x1, y1, z1))
                                    {
                                        BaseCreature cavernmongbatberserker = new CavernMongbatBerserkerQuest();
                                        cavernmongbatberserker.MoveToWorld(new Point3D(x1, y1, z1), Map.Malas);
                                        cavernmongbatberserker.Combatant = m;
                                        m.Send(Network.PlayMusic.GetInstance(MusicName.Medieval));

                                        AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                                        Timer.DelayCall(TimeSpan.FromMinutes(2.0), new TimerStateCallback(DeleteCavernMongbatBerserkerQuest), cavernmongbatberserker);
                                    }
                                }
                            }

                            // Mongbat Ambush 2
                            if (Utility.RandomDouble() < 0.015)
                            {
                                if (m.Map == Map.Malas)
                                {
                                    int x2 = m.X - 20;
                                    int y2 = m.Y - 20;
                                    int z2 = Map.Malas.GetAverageZ(x2, y2);

                                    if (Map.Malas.CanSpawnMobile(x2, y2, z2))
                                    {
                                        BaseCreature cavernmongbatberserker = new CavernMongbatBerserkerQuest();
                                        cavernmongbatberserker.MoveToWorld(new Point3D(x2, y2, z2), Map.Malas);
                                        cavernmongbatberserker.Combatant = m;
                                        m.Send(Network.PlayMusic.GetInstance(MusicName.Medieval));

                                        AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                                        Timer.DelayCall(TimeSpan.FromMinutes(2.0), new TimerStateCallback(DeleteCavernMongbatBerserkerQuest), cavernmongbatberserker);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 21
0
        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);
        }
Exemplo n.º 22
0
 // void draw(SpriteBatch b)
 private static void GreenSlime_DrawPostfix(GreenSlime __instance, SpriteBatch b)
 {
     ModFestiveSlimes._greenSlimeManager.DrawHat(SDateTime.Today, b, __instance);
 }
        public override void Damage(Mobile m)
        {
            base.Damage(m);

            if (m.Alive)
            {
                Item item = m.FindItemOnLayer(Layer.OuterTorso);

                if (item is GMRobe)
                {
                    AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                }
                else
                {
                    // Forest noises
                    if (Utility.RandomDouble() < 0.008)
                    {
                        m.PlaySound(Utility.RandomList(0x000, 0x001, 0x002));
                        AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                    }

                    // Bird chirps
                    if (Utility.RandomDouble() < 0.002)
                    {
                        m.PlaySound(Utility.RandomList(0x094, 0x095, 0x096, 0x097, 0x0D1, 0x0D2));
                        AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                    }

                    // Cricket noises
                    if (Utility.RandomDouble() < 0.003)
                    {
                        m.PlaySound(Utility.RandomList(0x00A, 0x00B));
                        AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                    }

                    // Turdy Encounter 1
                    if (Utility.RandomDouble() < 0.002)
                    {
                        if (m.Map == Map.Malas)
                        {
                            int x1 = m.X + 8;
                            int y1 = m.Y + 8;
                            int z1 = Map.Malas.GetAverageZ(x1, y1);

                            if (Map.Malas.CanSpawnMobile(x1, y1, z1))
                            {
                                BaseCreature turdyencounter;
                                switch (Utility.Random(2))
                                {
                                default:
                                case 0: turdyencounter = new Turdy(); break;

                                case 1: turdyencounter = new Turdy(); break;
                                }
                                turdyencounter.MoveToWorld(new Point3D(x1, y1, z1), Map.Malas);

                                turdyencounter.Combatant = m;
                                AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                                Timer.DelayCall(TimeSpan.FromMinutes(10.0), new TimerStateCallback(DeleteTurdyEncounter), turdyencounter);
                            }
                        }
                    }

                    // Turdy Encounter 2
                    if (Utility.RandomDouble() < 0.002)
                    {
                        if (m.Map == Map.Malas)
                        {
                            int x2 = m.X - 8;
                            int y2 = m.Y - 8;
                            int z2 = Map.Malas.GetAverageZ(x2, y2);

                            if (Map.Malas.CanSpawnMobile(x2, y2, z2))
                            {
                                BaseCreature turdyencounter;
                                switch (Utility.Random(2))
                                {
                                default:
                                case 0: turdyencounter = new Turdy(); break;

                                case 1: turdyencounter = new Turdy(); break;
                                }
                                turdyencounter.MoveToWorld(new Point3D(x2, y2, z2), Map.Malas);

                                turdyencounter.Combatant = m;
                                AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                                Timer.DelayCall(TimeSpan.FromMinutes(10.0), new TimerStateCallback(DeleteTurdyEncounter), turdyencounter);
                            }
                        }
                    }

                    // Random Encounter 1
                    if (Utility.RandomDouble() < 0.0002)
                    {
                        if (m.Map == Map.Malas)
                        {
                            int x1 = m.X + 8;
                            int y1 = m.Y + 8;
                            int z1 = Map.Malas.GetAverageZ(x1, y1);

                            if (Map.Malas.CanSpawnMobile(x1, y1, z1))
                            {
                                BaseCreature encounterb;
                                switch (Utility.Random(2))
                                {
                                default:
                                case 0: encounterb = new AutumnwoodAdventurer(); break;

                                case 1: encounterb = new AutumnwoodAdventurer(); break;
                                }
                                encounterb.MoveToWorld(new Point3D(x1, y1, z1), Map.Malas);

                                AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                                Timer.DelayCall(TimeSpan.FromMinutes(10.0), new TimerStateCallback(DeleteEncounterB), encounterb);
                            }
                        }
                    }

                    // Random Encounter 2
                    if (Utility.RandomDouble() < 0.0002)
                    {
                        if (m.Map == Map.Malas)
                        {
                            int x2 = m.X - 8;
                            int y2 = m.Y - 8;
                            int z2 = Map.Malas.GetAverageZ(x2, y2);

                            if (Map.Malas.CanSpawnMobile(x2, y2, z2))
                            {
                                BaseCreature encounterb;
                                switch (Utility.Random(2))
                                {
                                default:
                                case 0: encounterb = new AutumnwoodAdventurer(); break;

                                case 1: encounterb = new AutumnwoodAdventurer(); break;
                                }
                                encounterb.MoveToWorld(new Point3D(x2, y2, z2), Map.Malas);

                                AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                                Timer.DelayCall(TimeSpan.FromMinutes(10.0), new TimerStateCallback(DeleteEncounterB), encounterb);
                            }
                        }
                    }

                    // Tamable Encounter 1
                    if (Utility.RandomDouble() < 0.002)
                    {
                        if (m.Map == Map.Malas)
                        {
                            int x1 = m.X + 8;
                            int y1 = m.Y + 8;
                            int z1 = Map.Malas.GetAverageZ(x1, y1);

                            if (Map.Malas.CanSpawnMobile(x1, y1, z1))
                            {
                                BaseCreature tameable;
                                switch (Utility.Random(23))
                                {
                                default:
                                case 0: tameable = new Bird(); break;

                                case 1: tameable = new Boar(); break;

                                case 2: tameable = new BlackBear(); break;

                                case 3: tameable = new Bull(); break;

                                case 4: tameable = new Chicken(); break;

                                case 5: tameable = new Cow(); break;

                                case 6: tameable = new ForestBat(); break;

                                case 7: tameable = new Goat(); break;

                                case 8: tameable = new GreatHart(); break;

                                case 9: tameable = new GreenSlime(); break;

                                case 10: tameable = new GreySquirrel(); break;

                                case 11: tameable = new GreyWolfPup(); break;

                                case 12: tameable = new Hind(); break;

                                case 13: tameable = new Horse(); break;

                                case 14: tameable = new LargeFrog(); break;

                                case 15: tameable = new Ogumo(); break;

                                case 16: tameable = new Panther(); break;

                                case 17: tameable = new Pig(); break;

                                case 18: tameable = new Rabbit(); break;

                                case 19: tameable = new Rat(); break;

                                case 20: tameable = new RhinoBeetle(); break;

                                case 21: tameable = new RunningPants(); break;

                                case 22: tameable = new Sheep(); break;
                                }
                                tameable.MoveToWorld(new Point3D(x1, y1, z1), Map.Malas);

                                AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                                Timer.DelayCall(TimeSpan.FromMinutes(10.0), new TimerStateCallback(DeleteTameable), tameable);
                            }
                        }
                    }

                    // Tamable Encounter 2
                    if (Utility.RandomDouble() < 0.002)
                    {
                        if (m.Map == Map.Malas)
                        {
                            int x2 = m.X - 8;
                            int y2 = m.Y - 8;
                            int z2 = Map.Malas.GetAverageZ(x2, y2);

                            if (Map.Malas.CanSpawnMobile(x2, y2, z2))
                            {
                                BaseCreature tameable;
                                switch (Utility.Random(23))
                                {
                                default:
                                case 0: tameable = new Bird(); break;

                                case 1: tameable = new Boar(); break;

                                case 2: tameable = new BlackBear(); break;

                                case 3: tameable = new Bull(); break;

                                case 4: tameable = new Chicken(); break;

                                case 5: tameable = new Cow(); break;

                                case 6: tameable = new ForestBat(); break;

                                case 7: tameable = new Goat(); break;

                                case 8: tameable = new GreatHart(); break;

                                case 9: tameable = new GreenSlime(); break;

                                case 10: tameable = new GreySquirrel(); break;

                                case 11: tameable = new GreyWolfPup(); break;

                                case 12: tameable = new Hind(); break;

                                case 13: tameable = new Horse(); break;

                                case 14: tameable = new LargeFrog(); break;

                                case 15: tameable = new Ogumo(); break;

                                case 16: tameable = new Panther(); break;

                                case 17: tameable = new Pig(); break;

                                case 18: tameable = new Rabbit(); break;

                                case 19: tameable = new Rat(); break;

                                case 20: tameable = new RhinoBeetle(); break;

                                case 21: tameable = new RunningPants(); break;

                                case 22: tameable = new Sheep(); break;
                                }
                                tameable.MoveToWorld(new Point3D(x2, y2, z2), Map.Malas);

                                AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                                Timer.DelayCall(TimeSpan.FromMinutes(10.0), new TimerStateCallback(DeleteTameable), tameable);
                            }
                        }
                    }

                    // Random Treasure Chest 1
                    if (Utility.RandomDouble() < 0.0005)
                    {
                        if (m.Map == Map.Malas)
                        {
                            int x1 = m.X + 12;
                            int y1 = m.Y + 12;
                            int z1 = Map.Malas.GetAverageZ(x1, y1);

                            if (Map.Malas.CanSpawnMobile(x1, y1, z1))
                            {
                                BaseContainer treasurechest;

                                if (m.Skills.Tracking.Base > 14.9)
                                {
                                    switch (Utility.Random(2))
                                    {
                                    default:
                                    case 0: treasurechest = new AutumnwoodTreasureChest1(); break;

                                    case 1: treasurechest = new AutumnwoodTreasureChest1(); break;
                                    }
                                    treasurechest.MoveToWorld(new Point3D(x1, y1, z1), Map.Malas);

                                    AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                                    Timer.DelayCall(TimeSpan.FromMinutes(5.0), new TimerStateCallback(DeleteTreasureChest), treasurechest);
                                }
                            }
                        }
                    }

                    // Random Treasure Chest 2
                    if (Utility.RandomDouble() < 0.0005)
                    {
                        if (m.Map == Map.Malas)
                        {
                            int x2 = m.X - 12;
                            int y2 = m.Y - 12;
                            int z2 = Map.Malas.GetAverageZ(x2, y2);

                            if (Map.Malas.CanSpawnMobile(x2, y2, z2))
                            {
                                BaseContainer treasurechest;

                                if (m.Skills.Tracking.Base > 14.9)
                                {
                                    switch (Utility.Random(2))
                                    {
                                    default:
                                    case 0: treasurechest = new AutumnwoodTreasureChest1(); break;

                                    case 1: treasurechest = new AutumnwoodTreasureChest1(); break;
                                    }
                                    treasurechest.MoveToWorld(new Point3D(x2, y2, z2), Map.Malas);

                                    AOS.Damage(m, 0, 0, 0, 0, 0, 0);
                                    Timer.DelayCall(TimeSpan.FromMinutes(5.0), new TimerStateCallback(DeleteTreasureChest), treasurechest);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 24
0
        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);
                }
            }
        }
Exemplo n.º 25
0
 // List<Item> GreenSlime.getExtraDropItems()
 private static void GreenSlime_GetExtraDropItemsPostfix(GreenSlime __instance, ref List <Item> __result)
 {
     // Add extra drops
     __result.AddRange(ModFestiveSlimes._greenSlimeManager.GetExtraDrops(SDateTime.Today, __instance));
 }
 public NiceGreenSlime(GreenSlime sli)
 {
     slime = sli;
 }
Exemplo n.º 27
0
            /// <summary>Generates a monster and places it on the specified map and tile.</summary>
            /// <param name="monsterType">The monster type's name and an optional dictionary of monster-specific settings.</param>
            /// <param name="location">The GameLocation where the monster should be spawned.</param>
            /// <param name="tile">The x/y coordinates of the tile where the monster should be spawned.</param>
            /// <param name="areaID">The UniqueAreaID of the related SpawnArea. Required for log messages.</param>
            /// <returns>Returns the monster's ID value, or null if the spawn process failed.</returns>
            public static int?SpawnMonster(MonsterType monsterType, GameLocation location, Vector2 tile, string areaID = "")
            {
                Monster monster = null;                                                                      //an instatiated monster, to be spawned into the world later

                Color?color = null;                                                                          //the monster's color (used by specific monster types)

                if (monsterType.Settings != null)                                                            //if settings were provided
                {
                    if (monsterType.Settings.ContainsKey("Color"))                                           //if this setting was provided
                    {
                        string[]   colorText    = ((string)monsterType.Settings["Color"]).Trim().Split(' '); //split the setting string into strings for each number
                        List <int> colorNumbers = new List <int>();
                        foreach (string text in colorText)                                                   //for each string
                        {
                            int num = Convert.ToInt32(text);                                                 //convert it to a number
                            if (num < 0)
                            {
                                num = 0;
                            }                         //minimum 0
                            else if (num > 255)
                            {
                                num = 255;
                            }                      //maximum 255
                            colorNumbers.Add(num); //add it to the list
                        }

                        //convert strings into RGBA values
                        int r = Convert.ToInt32(colorNumbers[0]);
                        int g = Convert.ToInt32(colorNumbers[1]);
                        int b = Convert.ToInt32(colorNumbers[2]);
                        int a;
                        if (colorNumbers.Count > 3) //if the setting included an "A" value
                        {
                            a = Convert.ToInt32(colorNumbers[3]);
                        }
                        else //if the setting did not include an "A" value
                        {
                            a = 255; //default to no transparency
                        }

                        color = new Color(r, g, b, a);                                                                     //set the color
                    }
                    else if (monsterType.Settings.ContainsKey("MinColor") && monsterType.Settings.ContainsKey("MaxColor")) //if color wasn't provided, but mincolor & maxcolor were
                    {
                        string[]   minColorText    = ((string)monsterType.Settings["MinColor"]).Trim().Split(' ');         //split the setting string into strings for each number
                        List <int> minColorNumbers = new List <int>();
                        foreach (string text in minColorText)                                                              //for each string
                        {
                            int num = Convert.ToInt32(text);                                                               //convert it to a number
                            if (num < 0)
                            {
                                num = 0;
                            }                         //minimum 0
                            else if (num > 255)
                            {
                                num = 255;
                            }                         //maximum 255
                            minColorNumbers.Add(num); //add it to the list
                        }

                        string[]   maxColorText    = ((string)monsterType.Settings["MaxColor"]).Trim().Split(' '); //split the setting string into strings for each number
                        List <int> maxColorNumbers = new List <int>();
                        foreach (string text in maxColorText)                                                      //for each string
                        {
                            int num = Convert.ToInt32(text);                                                       //convert it to a number
                            if (num < 0)
                            {
                                num = 0;
                            }                         //minimum 0
                            else if (num > 255)
                            {
                                num = 255;
                            }                         //maximum 255
                            maxColorNumbers.Add(num); //convert to number
                        }

                        for (int x = 0; x < minColorNumbers.Count && x < maxColorNumbers.Count; x++) //for each pair of values
                        {
                            if (minColorNumbers[x] > maxColorNumbers[x])                             //if min > max
                            {
                                //swap min and max
                                int temp = minColorNumbers[x];
                                minColorNumbers[x] = maxColorNumbers[x];
                                maxColorNumbers[x] = temp;
                            }
                        }

                        //pick random RGBA values between min and max
                        int r = RNG.Next(minColorNumbers[0], maxColorNumbers[0] + 1);
                        int g = RNG.Next(minColorNumbers[1], maxColorNumbers[1] + 1);
                        int b = RNG.Next(minColorNumbers[2], maxColorNumbers[2] + 1);
                        int a;
                        if (minColorNumbers.Count > 3 && maxColorNumbers.Count > 3) //if both settings included an "A" value
                        {
                            a = RNG.Next(minColorNumbers[3], maxColorNumbers[3] + 1);
                        }
                        else //if one/both of the settings did not include an "A" value
                        {
                            a = 255; //default to no transparency
                        }

                        color = new Color(r, g, b, a); //set the color
                    }
                }

                //set fields that affect some monster types in different ways
                bool seesPlayers     = false;                                           //whether the monster automatically "sees" players at spawn
                int  facingDirection = 2;                                               //the direction the monster should be facing at spawn
                bool rangedAttacks   = true;                                            //whether the monster is allowed to use its ranged attacks (if any)

                if (monsterType.Settings != null)                                       //if settings were provided
                {
                    if (monsterType.Settings.ContainsKey("SeesPlayersAtSpawn"))         //if this setting was provided
                    {
                        seesPlayers = (bool)monsterType.Settings["SeesPlayersAtSpawn"]; //use it
                    }

                    if (monsterType.Settings.ContainsKey("FacingDirection"))                      //if this setting was provided
                    {
                        string directionString = (string)monsterType.Settings["FacingDirection"]; //get it
                        switch (directionString.Trim().ToLower())
                        {
                        //get an integer representing the direction
                        case "up":
                            facingDirection = 0;
                            break;

                        case "right":
                            facingDirection = 1;
                            break;

                        case "down":
                            facingDirection = 2;
                            break;

                        case "left":
                            facingDirection = 3;
                            break;
                        }
                    }

                    if (monsterType.Settings.ContainsKey("RangedAttacks"))           //if this setting was provided
                    {
                        rangedAttacks = (bool)monsterType.Settings["RangedAttacks"]; //use it
                    }
                }

                //create a new monster based on the provided name & apply type-specific settings
                switch (monsterType.MonsterName.ToLower()) //avoid most casing issues by making this lower-case
                {
                case "bat":
                    monster = new BatFTM(tile, 0);
                    break;

                case "frostbat":
                case "frost bat":
                    monster = new BatFTM(tile, 40);
                    break;

                case "lavabat":
                case "lava bat":
                    monster = new BatFTM(tile, 80);
                    break;

                case "iridiumbat":
                case "iridium bat":
                    monster = new BatFTM(tile, 171);
                    break;

                case "doll":
                case "curseddoll":
                case "cursed doll":
                    monster = new BatFTM(tile, -666);
                    break;

                case "skull":
                case "hauntedskull":
                case "haunted skull":
                    monster = new BatFTM(tile, 77377);
                    break;

                case "magmasprite":
                case "magma sprite":
                    monster = new BatFTM(tile, -555);
                    break;

                case "magmasparker":
                case "magma sparker":
                    monster = new BatFTM(tile, -556);
                    break;

                case "bigslime":
                case "big slime":
                case "biggreenslime":
                case "big green slime":
                    monster = new BigSlimeFTM(tile, 0);
                    if (color.HasValue)                               //if color was provided
                    {
                        ((BigSlimeFTM)monster).c.Value = color.Value; //set its color after creation
                    }
                    if (seesPlayers)
                    {
                        monster.IsWalkingTowardPlayer = true;
                    }
                    break;

                case "bigblueslime":
                case "big blue slime":
                case "bigfrostjelly":
                case "big frost jelly":
                    monster = new BigSlimeFTM(tile, 40);
                    if (color.HasValue)                               //if color was provided
                    {
                        ((BigSlimeFTM)monster).c.Value = color.Value; //set its color after creation
                    }
                    if (seesPlayers)
                    {
                        monster.IsWalkingTowardPlayer = true;
                    }
                    break;

                case "bigredslime":
                case "big red slime":
                case "bigredsludge":
                case "big red sludge":
                    monster = new BigSlimeFTM(tile, 80);
                    if (color.HasValue)                               //if color was provided
                    {
                        ((BigSlimeFTM)monster).c.Value = color.Value; //set its color after creation
                    }
                    if (seesPlayers)
                    {
                        monster.IsWalkingTowardPlayer = true;
                    }
                    break;

                case "bigpurpleslime":
                case "big purple slime":
                case "bigpurplesludge":
                case "big purple sludge":
                    monster = new BigSlimeFTM(tile, 121);
                    if (color.HasValue)                               //if color was provided
                    {
                        ((BigSlimeFTM)monster).c.Value = color.Value; //set its color after creation
                    }
                    if (seesPlayers)                                  //if the "SeesPlayersAtSpawn" setting is true
                    {
                        monster.IsWalkingTowardPlayer = true;
                    }
                    break;

                case "bluesquid":
                case "blue squid":
                    monster = new BlueSquid(tile);
                    break;

                case "bug":
                    monster = new Bug(tile, 0);
                    break;

                case "armoredbug":
                case "armored bug":
                    monster = new Bug(tile, 121);
                    break;

                case "dino":
                case "dinomonster":
                case "dino monster":
                case "pepper":
                case "pepperrex":
                case "pepper rex":
                case "rex":
                    monster = new DinoMonster(tile);
                    if (!rangedAttacks)
                    {
                        DinoMonster dino = monster as DinoMonster;
                        dino.timeUntilNextAttack = int.MaxValue;
                        dino.nextFireTime        = int.MaxValue;
                    }
                    break;

                case "duggy":
                    monster = new DuggyFTM(tile);
                    break;

                case "magmaduggy":
                case "magma duggy":
                    monster = new DuggyFTM(tile, true);
                    break;

                case "dust":
                case "sprite":
                case "dustsprite":
                case "dust sprite":
                case "spirit":
                case "dustspirit":
                case "dust spirit":
                    monster = new DustSpiritFTM(tile);
                    break;

                case "dwarvishsentry":
                case "dwarvish sentry":
                case "dwarvish":
                case "sentry":
                    monster = new DwarvishSentry(tile);
                    for (int x = Game1.delayedActions.Count - 1; x >= 0; x--)       //check each existing DelayedAction (from last to first)
                    {
                        if (Game1.delayedActions[x].stringData == "DwarvishSentry") //if this action seems to be playing this monster's sound effect
                        {
                            Game1.delayedActions.Remove(Game1.delayedActions[x]);   //remove the action (preventing this monster's global sound effect after creation)
                            break;                                                  //skip the rest of the actions
                        }
                    }
                    break;

                case "ghost":
                    monster = new GhostFTM(tile);
                    break;

                case "carbonghost":
                case "carbon ghost":
                    monster = new GhostFTM(tile, "Carbon Ghost");
                    break;

                case "putridghost":
                case "putrid ghost":
                    monster = new GhostFTM(tile, "Putrid Ghost");
                    break;

                case "slime":
                case "greenslime":
                case "green slime":
                    monster = new GreenSlime(tile, 0);
                    if (color.HasValue)                                  //if color was also provided
                    {
                        ((GreenSlime)monster).color.Value = color.Value; //set its color after creation
                    }
                    break;

                case "blueslime":
                case "blue slime":
                case "frostjelly":
                case "frost jelly":
                    monster = new GreenSlime(tile, 40);
                    if (color.HasValue)                                  //if color was also provided
                    {
                        ((GreenSlime)monster).color.Value = color.Value; //set its color after creation
                    }
                    break;

                case "redslime":
                case "red slime":
                case "redsludge":
                case "red sludge":
                    monster = new GreenSlime(tile, 80);
                    if (color.HasValue)                                  //if color was also provided
                    {
                        ((GreenSlime)monster).color.Value = color.Value; //set its color after creation
                    }
                    break;

                case "purpleslime":
                case "purple slime":
                case "purplesludge":
                case "purple sludge":
                    monster = new GreenSlime(tile, 121);
                    if (color.HasValue)                                  //if color was also provided
                    {
                        ((GreenSlime)monster).color.Value = color.Value; //set its color after creation
                    }
                    break;

                case "tigerslime":
                case "tiger slime":
                    monster = new GreenSlime(tile, 0);                   //create any "normal" slime
                    ((GreenSlime)monster).makeTigerSlime();              //convert it into a tiger slime
                    if (color.HasValue)                                  //if color was also provided
                    {
                        ((GreenSlime)monster).color.Value = color.Value; //set its color after creation
                    }
                    break;

                case "prismaticslime":
                case "prismatic slime":
                    monster = new GreenSlime(tile, 0);                   //create any "normal" slime
                    ((GreenSlime)monster).makePrismatic();               //convert it into a prismatic slime
                    if (color.HasValue)                                  //if color was also provided
                    {
                        ((GreenSlime)monster).color.Value = color.Value; //set its color after creation
                    }
                    break;

                case "grub":
                case "cavegrub":
                case "cave grub":
                    monster = new GrubFTM(tile, false);
                    break;

                case "fly":
                case "cavefly":
                case "cave fly":
                    monster = new FlyFTM(tile, false);
                    break;

                case "mutantgrub":
                case "mutant grub":
                    monster = new GrubFTM(tile, true);
                    break;

                case "mutantfly":
                case "mutant fly":
                    monster = new FlyFTM(tile, true);
                    break;

                case "metalhead":
                case "metal head":
                    monster = new MetalHead(tile, 0);
                    if (color.HasValue)                             //if color was provided
                    {
                        ((MetalHead)monster).c.Value = color.Value; //set its color after creation
                    }
                    break;

                case "hothead":
                case "hot head":
                    monster = new HotHead(tile);
                    if (color.HasValue)                           //if color was provided
                    {
                        ((HotHead)monster).c.Value = color.Value; //set its color after creation
                    }
                    break;

                case "lavalurk":
                case "lava lurk":
                    monster = new LavaLurkFTM(tile, rangedAttacks);
                    break;

                case "leaper":
                    monster = new Leaper(tile);
                    break;

                case "mummy":
                    monster = new MummyFTM(tile);
                    break;

                case "rockcrab":
                case "rock crab":
                    monster = new RockCrab(tile);
                    break;

                case "lavacrab":
                case "lava crab":
                    monster = new LavaCrab(tile);
                    break;

                case "iridiumcrab":
                case "iridium crab":
                    monster = new RockCrab(tile, "Iridium Crab");
                    break;

                case "falsemagmacap":
                case "false magma cap":
                case "magmacap":
                case "magma cap":
                    monster            = new RockCrab(tile, "False Magma Cap");
                    monster.HideShadow = true;     //hide shadow, making them look more like "real" magma caps
                    break;

                case "stickbug":
                case "stick bug":
                    monster = new RockCrab(tile);
                    (monster as RockCrab).makeStickBug();
                    break;

                case "rockgolem":
                case "rock golem":
                case "stonegolem":
                case "stone golem":
                    monster = new RockGolemFTM(tile);
                    break;

                case "wildernessgolem":
                case "wilderness golem":
                    monster = new RockGolemFTM(tile, Game1.player.CombatLevel);
                    break;

                case "serpent":
                    monster = new SerpentFTM(tile);
                    break;

                case "royalserpent":
                case "royal serpent":
                    monster = new SerpentFTM(tile, "Royal Serpent");
                    break;

                case "brute":
                case "shadowbrute":
                case "shadow brute":
                    monster = new ShadowBrute(tile);
                    break;

                case "shaman":
                case "shadowshaman":
                case "shadow shaman":
                    monster = new ShadowShaman(tile);
                    if (!rangedAttacks)
                    {
                        Helper.Reflection.GetField <int>(monster, "coolDown", false)?.SetValue(int.MaxValue);    //set spell cooldown to max
                    }
                    break;

                case "sniper":
                case "shadowsniper":
                case "shadow sniper":
                    monster = new Shooter(tile);
                    if (!rangedAttacks)
                    {
                        (monster as Shooter).nextShot = float.MaxValue;     //set shot cooldown to max
                    }
                    break;

                case "skeleton":
                    monster = new SkeletonFTM(tile, false, rangedAttacks);
                    if (seesPlayers)
                    {
                        Helper.Reflection.GetField <bool>(monster, "spottedPlayer", false)?.SetValue(true);    //set "spotted player" field to true
                        monster.IsWalkingTowardPlayer = true;
                    }
                    break;

                case "skeletonmage":
                case "skeleton mage":
                    monster = new SkeletonFTM(tile, true, rangedAttacks);
                    if (seesPlayers)
                    {
                        Helper.Reflection.GetField <bool>(monster, "spottedPlayer", false)?.SetValue(true);    //set "spotted player" field to true
                        monster.IsWalkingTowardPlayer = true;
                    }
                    break;

                case "spiker":
                    monster = new Spiker(tile, facingDirection);
                    break;

                case "squidkid":
                case "squid kid":
                    monster = new SquidKidFTM(tile);
                    if (!rangedAttacks)
                    {
                        Helper.Reflection.GetField <int>(monster, "lastFireball", false)?.SetValue(int.MaxValue);    //set fireball cooldown to max
                    }
                    break;

                default:                                                                           //if the name doesn't match any directly known monster types
                    //check MTF monster types
                    if (MonstersTheFrameworkAPI.IsKnownMonsterType(monsterType.MonsterName, true)) //if this is a known (and previously validated) monster type from MTF
                    {
                        monster = MonstersTheFrameworkAPI.CreateMonster(monsterType.MonsterName);  //create it through the MTF interface
                        break;
                    }
                    //handle the name as a custom Type
                    Type externalType = GetTypeFromName(monsterType.MonsterName, typeof(Monster)); //find a monster subclass with a matching name
                    monster = (Monster)Activator.CreateInstance(externalType, tile);               //create a monster with the Vector2 constructor
                    break;
                }

                if (monster == null)
                {
                    Monitor.Log($"The monster to be spawned (\"{monsterType.MonsterName}\") doesn't match any known monster types. Make sure that name isn't misspelled in your config file.", LogLevel.Info);
                    return(null);
                }

                int?ID = MonsterTracker.AddMonster(monster);  //generate an ID for this monster

                if (!ID.HasValue)
                {
                    Monitor.Log("A new monster ID could not be generated. This is may be due to coding issue; please report it to this mod's developer. This monster won't be spawned.", LogLevel.Warn);
                    return(null);
                }
                monster.id = ID.Value;                                       //assign the ID to this monster

                monster.MaxHealth = monster.Health;                          //some monster types set Health on creation and expect MaxHealth to be updated like this

                ApplyMonsterSettings(monster, monsterType.Settings, areaID); //adjust the monster based on any other provided optional settings

                //spawn the completed monster at the target location
                Monitor.VerboseLog($"Spawning monster. Type: {monsterType.MonsterName}. Location: {tile.X},{tile.Y} ({location.Name}).");
                monster.currentLocation = location;
                monster.setTileLocation(tile);
                location.addCharacter(monster);
                return(monster.id);
            }
Exemplo n.º 28
0
        public override void DayUpdate(int dayOfMonth)
        {
            int waters     = 0;
            int startIndex = Game1.random.Next(waterSpots.Length);

            for (int i = 0; i < waterSpots.Length; i++)
            {
                if (waterSpots[(i + startIndex) % waterSpots.Length] && waters * 5 < characters.Count)
                {
                    waters++;
                    waterSpots[(i + startIndex) % waterSpots.Length] = false;
                }
            }
            for (int j = objects.Count() - 1; j >= 0; j--)
            {
                if (objects.Pairs.ElementAt(j).Value.IsSprinkler())
                {
                    foreach (Vector2 v in objects.Pairs.ElementAt(j).Value.GetSprinklerTiles())
                    {
                        if (v.X == 16f && v.Y >= 6f && v.Y <= 9f)
                        {
                            waterSpots[(int)v.Y - 6] = true;
                        }
                    }
                }
            }
            for (int numSlimeBalls = Math.Min(characters.Count / 5, waters); numSlimeBalls > 0; numSlimeBalls--)
            {
                int     tries = 50;
                Vector2 tile  = getRandomTile();
                while ((!isTileLocationTotallyClearAndPlaceable(tile) || doesTileHaveProperty((int)tile.X, (int)tile.Y, "NPCBarrier", "Back") != null || tile.Y >= 12f) && tries > 0)
                {
                    tile = getRandomTile();
                    tries--;
                }
                if (tries > 0)
                {
                    objects.Add(tile, new Object(tile, 56));
                }
            }
            while ((int)slimeMatingsLeft > 0)
            {
                if (characters.Count > 1 && !isFull())
                {
                    NPC mate2 = characters[Game1.random.Next(characters.Count)];
                    if (mate2 is GreenSlime)
                    {
                        GreenSlime mate = mate2 as GreenSlime;
                        if ((int)mate.ageUntilFullGrown <= 0)
                        {
                            for (int distance = 1; distance < 10; distance++)
                            {
                                GreenSlime mate3 = (GreenSlime)Utility.checkForCharacterWithinArea(mate.GetType(), mate2.Position, this, new Rectangle((int)mate.Position.X - 64 * distance, (int)mate.Position.Y - 64 * distance, 64 * (distance * 2 + 1), 64 * (distance * 2 + 1)));
                                if (mate3 != null && mate3.cute != mate.cute && (int)mate3.ageUntilFullGrown <= 0)
                                {
                                    mate.mateWith(mate3, this);
                                    break;
                                }
                            }
                        }
                    }
                }
                slimeMatingsLeft.Value--;
            }
            slimeMatingsLeft.Value = characters.Count / 5 + 1;
            base.DayUpdate(dayOfMonth);
        }
Exemplo n.º 29
0
        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);
        }
Exemplo n.º 30
0
        private void PlayerWarped(object sender, WarpedEventArgs e)
        {
            //prints that the character has warped
            this.Monitor.Log($"The player has warped to {e.NewLocation.name}!", LogLevel.Debug);
            string bannerNot = "The player has warped to " + e.NewLocation.name;

            Game1.addHUDMessage(new HUDMessage(bannerNot, 3));

            //Game1.player.chestConsumedMineLevels[10] = false;
            //StardewValley.Locations.MineShaft.permanentMineChanges[10].chestsLeft = -1;

            //MineShaft.permanentMineChanges[this.mineLevel].chestsLeft > numberSoFar;

            if (Game1.player.chestConsumedMineLevels.ContainsKey(10))
            {
                this.Monitor.Log("Theres a key to get rid of", LogLevel.Debug);
            }
            else
            {
                this.Monitor.Log("The key is gone", LogLevel.Debug);
            }

            //Game1.player.chestConsumedMineLevels.Remove(10);

            if (Game1.player.chestConsumedMineLevels.ContainsKey(10))
            {
                this.Monitor.Log("Theres a key to get rid of", LogLevel.Debug);
            }
            else
            {
                this.Monitor.Log("The key is gone", LogLevel.Debug);
            }



            //bool canAddChest = Game1.player.chestConsumedMineLevels[10];
            //int chestsLeft = StardewValley.Locations.MineShaft.permanentMineChanges[10].chestsLeft;

            //this.Monitor.Log($"The chestsLeft Val for mineshaft 10 is {chestsLeft}!", LogLevel.Debug);
            //this.Monitor.Log($"The chest consumed value for mineshaft 10 is {canAddChest}!", LogLevel.Debug);



            // String currentLocation = e.NewLocation;

            if (e.NewLocation.name == "UndergroundMine10")
            {
                Game1.player.position.X = 19;
                Game1.player.position.Y = 20;

                Monster monster1  = null;
                Vector2 spawnSpot = Game1.player.getTileLocation();
                monster1 = new GreenSlime(spawnSpot, 0);
                monster1.DamageToFarmer = 10;

                Monster monster2 = null;
                monster2 = new GreenSlime(spawnSpot, 0);
                monster2.DamageToFarmer = 10;

                Monster monster3 = null;
                monster3 = new GreenSlime(spawnSpot, 0);
                monster3.DamageToFarmer = 10;



                spawnSpot.X  = 15;
                spawnSpot.Y  = 10;
                this.monster = AddMonster("GreenSlime", spawnSpot);

                /*
                 * spawnSpot.X = 14;
                 * spawnSpot.Y = 10;
                 * monster2.currentLocation = location;
                 * monster2.setTileLocation(spawnSpot);
                 * location.addCharacter(monster2);
                 *
                 * spawnSpot.X = 14;
                 * spawnSpot.Y = 11;
                 * monster3.currentLocation = location;
                 * monster3.setTileLocation(spawnSpot);
                 * location.addCharacter(monster3);
                 */

                //this.Monitor.Log("The player is in level 6 of the mines!", LogLevel.Debug);
            }

            //StardewValley.Monsters.Monster instance = (StardewValley.Monsters.Monster)Activator.CreateInstance(monsterData.Type, constructorArgs);
            //instance.currentLocation = Game1.currentLocation;

            //MonsterData monsterData = MonsterData.GetMonsterData(monster);

            if (e.NewLocation.name == "Farm")
            {
                this.Monitor.Log("The player on the farm, trying to load a monster.", LogLevel.Debug);

                Vector2 farmSpot = Game1.player.getTileLocation();
                this.Monitor.Log($"The position is {farmSpot}", LogLevel.Debug);


                Vector2 spawnSpot = Game1.player.getTileLocation();
                spawnSpot.Y += 3;
                this.monster = this.AddMonster("GreenSlime", spawnSpot);

                /*
                 * Monster monster = null;
                 * Vector2 spawnSpot = Game1.player.getTileLocation();
                 * monster = new Bat(spawnSpot, 0);
                 * monster.DamageToFarmer = 10;
                 *
                 * spawnSpot.Y += 5;
                 * GameLocation location = Game1.currentLocation;
                 * monster.currentLocation = location;
                 * monster.setTileLocation(spawnSpot);
                 * location.addCharacter(monster);
                 */

                /*
                 * Vector2 spawnSpot = Game1.player.getTileLocation();
                 * string typeOfMonster = "Green Slime";
                 * object[] constructorArgs;
                 * constructorArgs[0] = spawnSpot;
                 *
                 * StardewValley.Monsters.Monster instance = (StardewValley.Monsters.Monster)Activator.CreateInstance(typeOfMonster, spawnSpot);
                 * instance.currentLocation = Game1.currentLocation;
                 */
            }
        }