public override void onCast(StardewValley.Farmer player, int level, int targetX, int targetY)
        {
            if (player != Game1.player)
            {
                return;
            }

            var ms = player.currentLocation as MineShaft;

            if (ms == null)
            {
                return;
            }

            int target = ms.mineLevel + 1 + 2 * level;

            if (ms.mineLevel <= 120 && target >= 120)
            {
                // We don't want the player to go through the bottom of the
                // original mine and into the skull cavern.
                target = 120;
            }

            Game1.enterMine(target);

            player.addMagicExp(5);
        }
Example #2
0
        public void update(object sender, EventArgs args)
        {
            height -= (int)yVelocity;
            if (height <= 0)
            {
                Game1.playSound("explosion");
                for (int i = 0; i < 10; ++i)
                {
                    for (int ix = -i; ix <= i; ++ix)
                    {
                        for (int iy = -i; iy <= i; ++iy)
                        {
                            Game1.createRadialDebris(loc, Game1.objectSpriteSheetName, new Rectangle(352, 400, 32, 32), 4, (int)this.position.X + ix * 20, (int)this.position.Y + iy * 20, 15 - 14 + rand.Next(15 - 14), (int)((double)this.position.Y / (double)Game1.tileSize) + 1, new Color(255, 255, 255, 255), 4.0f);
                        }
                    }
                }
                foreach (var npc in source.currentLocation.characters)
                {
                    if (npc is Monster mob)
                    {
                        float rad = 8 * 64;
                        if (Vector2.Distance(mob.position, new Vector2(position.X, position.Y)) <= rad)
                        {
                            mob.takeDamage(300, 0, 0, false, 0, source);
                            source.addMagicExp(5);
                        }
                    }
                }
                loc.explode(new Vector2((int)position.X / Game1.tileSize, (int)position.Y / Game1.tileSize), 4 + 2, source);

                GameEvents.UpdateTick -= update;
                GraphicsEvents.OnPreRenderHudEvent -= render;
            }
        }
Example #3
0
 public override void onCast(SFarmer player, int level, int targetX, int targetY)
 {
     Log.debug(player.Name + " casted Blink.");
     player.position.X = targetX - player.GetBoundingBox().Width / 2;
     player.position.Y = targetY - player.GetBoundingBox().Height / 2;
     Game1.playSound("powerup");
     player.addMagicExp(5);
 }
Example #4
0
        public override void onCast(SFarmer player, int level, int targetX, int targetY)
        {
            Log.debug(player.Name + " casted Heal.");
            int health = 10 + 15 * level;

            player.health += health;
            player.currentLocation.debris.Add(new Debris(health, new Vector2((float)(Game1.player.getStandingX() + 8), (float)Game1.player.getStandingY()), Color.Green, 1f, (Character)Game1.player));
            Game1.playSound("healSound");
            player.addMagicExp(health / 2);
        }
        public override void onCast(SFarmer player, int level, int targetX, int targetY)
        {
            Log.debug(player.Name + " casted Luck Steal.");
            var num            = Game1.random.Next(player.friendshipData.Count());
            var friendshipData = player.friendshipData[new List <string>(player.friendshipData.Keys)[num]];

            friendshipData.Points = Math.Max(0, friendshipData.Points - 250);
            Game1.dailyLuck       = 0.12;
            Game1.playSound("death");
            player.addMagicExp(50);
        }
Example #6
0
        public override void onCast(SFarmer player, int level, int targetX, int targetY)
        {
            Log.debug(player.Name + " casted Blood Mana.");

            int health = 10 + 10 * level;

            player.health -= health;
            player.currentLocation.debris.Add(new Debris(health, new Vector2((float)(Game1.player.getStandingX() + 8), (float)Game1.player.getStandingY()), Color.Red, 1f, (Character)Game1.player));
            Game1.playSound("ow");
            Game1.hitShakeTimer = 100 * health;

            int mana = (int)(health * (MANA_RATIO_BASE + MANA_RATIO_INCR * level));

            player.addMana(mana);
            player.currentLocation.debris.Add(new Debris(mana, new Vector2((float)(Game1.player.getStandingX() + 8), (float)Game1.player.getStandingY()), Color.Blue, 1f, (Character)Game1.player));
            Game1.playSound("powerup");
            player.addMagicExp(-mana);
            if (player.getMagicExp() < 0)
            {
                player.addMagicExp(-player.getMagicExp());
            }
        }
        public override void behaviorOnCollisionWithMonster(NPC npc, GameLocation loc)
        {
            if (!(npc is Monster))
            {
                return;
            }

            loc.damageMonster(npc.GetBoundingBox(), damage, damage + 1, false, source);
            if (source != null)
            {
                source.addMagicExp(damage);
            }
            disappear(loc);
        }
            private void update(object sender, EventArgs args)
            {
                if (jumping)
                {
                    if (player.yJumpVelocity == 0 && prevJumpVel < 0)
                    {
                        landX   = player.position.X;
                        landY   = player.position.Y;
                        jumping = false;
                    }
                    prevJumpVel = player.yJumpVelocity;
                }
                if (!jumping)
                {
                    if (--timer > 0)
                    {
                        return;
                    }
                    timer = 10;

                    int spotsForCurrRadius = 1 + currRad * 7;
                    for (int i = 0; i < spotsForCurrRadius; ++i)
                    {
                        Game1.playSound("hoeHit");
                        float ix = landX + (float)Math.Cos(Math.PI * 2 / spotsForCurrRadius * i) * currRad * Game1.tileSize;
                        float iy = landY + (float)Math.Sin(Math.PI * 2 / spotsForCurrRadius * i) * currRad * Game1.tileSize;
                        player.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(6, new Vector2(ix, iy), Color.White, 8, Game1.random.NextDouble() < 0.5, 30, 0, -1, -1f, -1, 0));
                        player.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(12, new Vector2(ix, iy), Color.White, 8, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, -1, 0));
                    }
                    ++currRad;

                    foreach (var character in player.currentLocation.characters)
                    {
                        if (character is Monster mob)
                        {
                            if (Vector2.Distance(new Vector2(landX, landY), mob.position) < currRad * Game1.tileSize)
                            {
                                mob.takeDamage((level + 1) * 5, 0, 0, false, 0, player);
                                player.addMagicExp(3);
                            }
                        }
                    }

                    if (currRad >= 1 + (level + 1) * 2)
                    {
                        GameEvents.UpdateTick -= update;
                    }
                }
            }
Example #9
0
        public override void onCast(StardewValley.Farmer player, int level, int targetX, int targetY)
        {
            level   += 1;
            targetX /= Game1.tileSize;
            targetY /= Game1.tileSize;
            Vector2 target = new Vector2(targetX, targetY);

            int num = 0;

            GameLocation loc = player.currentLocation;

            for (int ix = targetX - level; ix <= targetX + level; ++ix)
            {
                for (int iy = targetY - level; iy <= targetY + level; ++iy)
                {
                    if (player.getCurrentMana() <= 0)
                    {
                        return;
                    }

                    Vector2 pos = new Vector2(ix, iy);
                    if (!loc.terrainFeatures.ContainsKey(pos))
                    {
                        continue;
                    }

                    HoeDirt dirt = loc.terrainFeatures[pos] as HoeDirt;
                    if (dirt == null || dirt.state.Value != HoeDirt.dry)
                    {
                        continue;
                    }

                    dirt.state.Value = HoeDirt.watered;

                    loc.temporarySprites.Add(new TemporaryAnimatedSprite(13, new Vector2(ix * (float)Game1.tileSize, iy * (float)Game1.tileSize), Color.White, 10, Game1.random.NextDouble() < 0.5, 70f, 0, Game1.tileSize, (float)(((double)iy * (double)Game1.tileSize + (double)(Game1.tileSize / 2)) / 10000.0 - 0.00999999977648258), -1, 0)
                    {
                        delayBeforeAnimationStart = num * 10
                    });
                    num++;

                    player.addMana(-1);
                    player.addMagicExp(1);
                    Game1.playSound("wateringCan");
                }
            }
        }
Example #10
0
        public override void onCast(StardewValley.Farmer player, int level, int targetX, int targetY)
        {
            if (player != Game1.player)
            {
                return;
            }

            foreach (var buff in Game1.buffsDisplay.otherBuffs)
            {
                if (buff.source == "spell:life:haste")
                {
                    return;
                }
            }

            Game1.buffsDisplay.addOtherBuff(new Buff(0, 0, 0, 0, 0, 0, 0, 0, 0, level + 1, 0, 0, 60 + level * 120, "spell:air:haste", "Haste (spell)"));
            player.addMagicExp(10);
        }
Example #11
0
        public override void onCast(StardewValley.Farmer player, int level, int targetX, int targetY)
        {
            if (player != Game1.player)
            {
                return;
            }

            int power = 4;

            if (level == 1)
            {
                power = 8;
            }
            else if (level == 2)
            {
                power = 16;
            }
            player.currentLocation.sharedLights.Add(new LightSource(1, Game1.player.position, power));
            player.addMagicExp(level);
        }
Example #12
0
        public override void onCast(StardewValley.Farmer player, int level, int targetX, int targetY)
        {
            if (player != Game1.player)
            {
                return;
            }

            foreach (var buff in Game1.buffsDisplay.otherBuffs)
            {
                if (buff.source == "spell:life:buff")
                {
                    return;
                }
            }

            Game1.buffsDisplay.clearAllBuffs();
            Mod.instance.Helper.Reflection.GetField <NetArray <int, NetInt> >(Game1.player, "appliedBuffs").GetValue().Clear();
            Game1.player.attack = 0;

            int l = level + 1;
            int farm = l, fish = l, mine = l, luck = l, forage = l, def = l, atk = 2;

            if (l == 2)
            {
                def = 3;
                atk = 5;
            }
            else if (l == 3)
            {
                def = 5;
                atk = 10;
            }

            Game1.buffsDisplay.addOtherBuff(new Buff(farm, fish, mine, 0, luck, forage, 0, 0, 0, 0, def, atk, 60 + level * 120, "spell:light:buff", "Buff (spell)"));
            player.addMagicExp(10);
        }
Example #13
0
        public override void onCast(StardewValley.Farmer player, int level, int targetX, int targetY)
        {
            level   += 1;
            targetX /= Game1.tileSize;
            targetY /= Game1.tileSize;
            Vector2 target = new Vector2(targetX, targetY);

            Tool dummyHoe = new Hoe();

            Mod.instance.Helper.Reflection.GetField <Farmer>(dummyHoe, "lastUser").SetValue(player);

            GameLocation loc = player.currentLocation;

            for (int ix = targetX - level; ix <= targetX + level; ++ix)
            {
                for (int iy = targetY - level; iy <= targetY + level; ++iy)
                {
                    if (player.getCurrentMana() <= 0)
                    {
                        return;
                    }

                    Vector2 pos = new Vector2(ix, iy);
                    if (loc.terrainFeatures.ContainsKey(pos))
                    {
                        continue; // ?
                    }
                    if (loc.objects.ContainsKey(pos))
                    {
                        var obj = loc.objects[pos];
                        if (obj.ParentSheetIndex == 590)
                        {
                            loc.digUpArtifactSpot(ix, iy, player);
                            loc.objects.Remove(pos);
                            player.addMana(-1);
                        }
                        else if (obj.performToolAction(dummyHoe, loc))
                        {
                            if (obj.Type == "Crafting" && obj.Fragility != 2)
                            {
                                loc.debris.Add(new Debris(obj.bigCraftable.Value ? -obj.ParentSheetIndex : obj.ParentSheetIndex, pos, pos));
                            }
                            obj.performRemoveAction(pos, loc);
                            loc.objects.Remove(pos);
                            player.addMana(-1);
                        }
                    }

                    if (loc.terrainFeatures.ContainsKey(pos))
                    {
                        if (loc.terrainFeatures[pos].performToolAction(dummyHoe, 0, pos, loc))
                        {
                            loc.terrainFeatures.Remove(pos);
                            player.addMana(-1);
                        }
                    }

                    if (loc.doesTileHaveProperty(ix, iy, "Diggable", "Back") != null && !loc.isTileOccupied(pos, ""))
                    {
                        loc.makeHoeDirt(pos);
                        Game1.playSound("hoeHit");
                        Game1.removeSquareDebrisFromTile(ix, iy);
                        loc.temporarySprites.Add(new TemporaryAnimatedSprite(12, new Vector2(ix * (float)Game1.tileSize, iy * (float)Game1.tileSize), Color.White, 8, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, -1, 0));
                        loc.temporarySprites.Add(new TemporaryAnimatedSprite(6, new Vector2(ix * (float)Game1.tileSize, iy * (float)Game1.tileSize), Color.White, 8, Game1.random.NextDouble() < 0.5, Vector2.Distance(pos, target) * 30f, 0, -1, -1f, -1, 0));
                        loc.checkForBuriedItem(ix, iy, false, false);
                        player.addMana(-1);
                        player.addMagicExp(2);
                    }
                }
            }
        }
Example #14
0
 public override void onCast(StardewValley.Farmer player, int level, int targetX, int targetY)
 {
     player.position.X = enterX;
     player.position.Y = enterY;
     player.addMagicExp(5);
 }
        public override void onCast(StardewValley.Farmer player, int level, int targetX, int targetY)
        {
            level   += 1;
            targetX /= Game1.tileSize;
            targetY /= Game1.tileSize;
            Vector2 target = new Vector2(targetX, targetY);

            Tool dummyAxe  = new Axe(); dummyAxe.UpgradeLevel = level;
            Tool dummyPick = new Pickaxe(); dummyPick.UpgradeLevel = level;

            Mod.instance.Helper.Reflection.GetField <Farmer>(dummyAxe, "lastUser").SetValue(player);
            Mod.instance.Helper.Reflection.GetField <Farmer>(dummyPick, "lastUser").SetValue(player);

            GameLocation loc = player.currentLocation;

            for (int ix = targetX - level; ix <= targetX + level; ++ix)
            {
                for (int iy = targetY - level; iy <= targetY + level; ++iy)
                {
                    if (player.getCurrentMana() <= 0)
                    {
                        return;
                    }

                    Vector2 pos = new Vector2(ix, iy);

                    if (loc.objects.ContainsKey(pos))
                    {
                        var obj = loc.objects[pos];
                        if (obj.performToolAction(dummyAxe, loc))
                        {
                            if (obj.Type == "Crafting" && obj.Fragility != 2)
                            {
                                loc.debris.Add(new Debris(obj.bigCraftable.Value ? -obj.ParentSheetIndex : obj.ParentSheetIndex, pos, pos));
                            }
                            obj.performRemoveAction(pos, loc);
                            loc.objects.Remove(pos);
                            player.addMana(-1);
                            player.addMagicExp(1);
                        }
                        else
                        {
                            var oldStam = player.stamina;
                            dummyPick.DoFunction(loc, ix * Game1.tileSize, iy * Game1.tileSize, 0, player);
                            player.stamina = oldStam;
                            player.addMana(-1);
                            player.addMagicExp(1);
                        }
                    }

                    // Trees
                    if (level >= 2)
                    {
                        if (loc.terrainFeatures.ContainsKey(pos) && !(loc.terrainFeatures[pos] is HoeDirt))
                        {
                            TerrainFeature tf = loc.terrainFeatures[pos];
                            if (tf is Tree)
                            {
                                player.addMana(-1);
                            }
                            if (tf.performToolAction(dummyAxe, 0, pos, loc) || tf is Grass || (tf is Tree && tf.performToolAction(dummyAxe, 0, pos, loc)))
                            {
                                if (tf is Tree)
                                {
                                    player.addMagicExp(10);
                                }
                                loc.terrainFeatures.Remove(pos);
                            }
                            if (tf is Grass && loc is Farm)
                            {
                                (loc as Farm).tryToAddHay(1);
                                Game1.playSound("swordswipe");
                                loc.temporarySprites.Add(new TemporaryAnimatedSprite(28, pos * (float)Game1.tileSize + new Vector2((float)Game1.random.Next(-Game1.pixelZoom * 4, Game1.pixelZoom * 4), (float)Game1.random.Next(-Game1.pixelZoom * 4, Game1.pixelZoom * 4)), Color.Green, 8, Game1.random.NextDouble() < 0.5, (float)Game1.random.Next(60, 100), 0, -1, -1f, -1, 0));
                                loc.temporarySprites.Add(new TemporaryAnimatedSprite(Game1.objectSpriteSheetName, Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, 178, 16, 16), 750f, 1, 0, player.position - new Vector2(0.0f, (float)(Game1.tileSize * 2)), false, false, player.position.Y / 10000f, 0.005f, Color.White, (float)Game1.pixelZoom, -0.005f, 0.0f, 0.0f, false)
                                {
                                    motion     = { Y = -1f },
                                    layerDepth = (float)(1.0 - (double)Game1.random.Next(100) / 10000.0),
                                    delayBeforeAnimationStart = Game1.random.Next(350)
                                });
                            }
                        }
                    }

                    if (level >= 3)
                    {
                        ICollection <ResourceClump> clumps = (NetCollection <ResourceClump>)loc.GetType().GetField("resourceClumps", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance).GetValue(loc);
                        if (loc is Woods)
                        {
                            clumps = (loc as Woods).stumps;
                        }
                        if (clumps != null)
                        {
                            foreach (var rc in clumps)
                            {
                                if (new Rectangle((int)rc.tile.X, (int)rc.tile.Y, rc.width.Value, rc.height.Value).Contains(ix, iy))
                                {
                                    player.addMana(-1);
                                    if (rc.performToolAction(dummyAxe, 1, pos, loc) || rc.performToolAction(dummyPick, 1, pos, loc))
                                    {
                                        clumps.Remove(rc);
                                        player.addMagicExp(25);
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }