diff --git a/Buffs/Pets/GoldieBuff.cs b/Buffs/Pets/GoldieBuff.cs new file mode 100644 index 0000000000..df6234255e --- /dev/null +++ b/Buffs/Pets/GoldieBuff.cs @@ -0,0 +1,27 @@ +using CalamityMod.Projectiles.Pets; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Pets +{ + public class GoldieBuff : ModBuff + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Goldie"); + Description.SetDefault("All that glitters is gold"); + Main.buffNoTimeDisplay[Type] = true; + Main.lightPet[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + player.buffTime[buffIndex] = 18000; + player.Calamity().thiefsDime = true; + bool PetProjectileNotSpawned = player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0; + if (PetProjectileNotSpawned && player.whoAmI == Main.myPlayer) + Projectile.NewProjectile(player.GetSource_Buff(buffIndex), player.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, player.whoAmI, 50f, 0f); + } + } +} diff --git a/Buffs/Pets/GoldieBuff.png b/Buffs/Pets/GoldieBuff.png new file mode 100644 index 0000000000..588b4378f9 Binary files /dev/null and b/Buffs/Pets/GoldieBuff.png differ diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index c62c160576..6ab33b3ae0 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -912,7 +912,6 @@ namespace CalamityMod.CalPlayer public int healCounter = 300; public bool shellfish = false; public bool hCrab = false; - public bool tDime = false; public bool allWaifus = false; public bool allWaifusVanity = false; public bool sCrystal = false; @@ -1975,7 +1974,6 @@ namespace CalamityMod.CalPlayer daedalusCrystal = false; shellfish = false; hCrab = false; - tDime = false; endoHydra = false; powerfulRaven = false; dragonFamily = false; diff --git a/Items/Accessories/ThiefsDime.cs b/Items/Accessories/ThiefsDime.cs deleted file mode 100644 index 4dcbe6fcfe..0000000000 --- a/Items/Accessories/ThiefsDime.cs +++ /dev/null @@ -1,46 +0,0 @@ -using CalamityMod.Projectiles.Rogue; -using Terraria; -using Terraria.ModLoader; -using Terraria.ID; - -namespace CalamityMod.Items.Accessories -{ - public class ThiefsDime : ModItem - { - public override void SetStaticDefaults() - { - SacrificeTotal = 1; - DisplayName.SetDefault("Thief's Dime"); - Tooltip.SetDefault("Those scurvy dogs don’t know the first thing about making bank\n" + - "Summons a coin that revolves around you and steals money from enemies"); - } - - public override void SetDefaults() - { - Item.width = 20; - Item.height = 20; - Item.value = CalamityGlobalItem.Rarity5BuyPrice; - Item.rare = ItemRarityID.Pink; - Item.accessory = true; - } - - public override bool CanEquipAccessory(Player player, int slot, bool modded) - { - return !player.Calamity().thiefsDime; - } - - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.Calamity().thiefsDime = true; - if (player.whoAmI == Main.myPlayer) - { - if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) - { - var source = player.GetSource_Accessory(Item); - int damage = (int)player.GetTotalDamage().ApplyTo(100); - Projectile.NewProjectile(source, player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), damage, 6f, Main.myPlayer, 0f, 0f); - } - } - } - } -} diff --git a/Items/Pets/ThiefsDime.cs b/Items/Pets/ThiefsDime.cs new file mode 100644 index 0000000000..1d0c4023eb --- /dev/null +++ b/Items/Pets/ThiefsDime.cs @@ -0,0 +1,38 @@ +using CalamityMod.Buffs.Pets; +using CalamityMod.Projectiles.Pets; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +using Terraria.ID; + +namespace CalamityMod.Items.Pets +{ + public class ThiefsDime : ModItem + { + public override void SetStaticDefaults() + { + SacrificeTotal = 1; + DisplayName.SetDefault("Thief's Dime"); + Tooltip.SetDefault("Once worthless treasure, now a relic of a thief's companionship\n" + + "Summons Goldie the coin to light your way and collects nearby coins\n" + + "Provides a small amount of light in the abyss"); + } + + public override void SetDefaults() + { + Item.CloneDefaults(ItemID.WispinaBottle); + Item.UseSound = SoundID.CoinPickup; + Item.shoot = ModContent.ProjectileType(); + Item.buffType = ModContent.BuffType(); + + Item.value = Item.sellPrice(gold: 20); //Buy price of 1 Platinum + Item.rare = ItemRarityID.Pink; + } + + public override void UseStyle(Player player, Rectangle heldItemFrame) + { + if (player.whoAmI == Main.myPlayer && player.itemTime == 0) + player.AddBuff(Item.buffType, 3600, true); + } + } +} diff --git a/Items/Accessories/ThiefsDime.png b/Items/Pets/ThiefsDime.png similarity index 100% rename from Items/Accessories/ThiefsDime.png rename to Items/Pets/ThiefsDime.png diff --git a/NPCs/TownNPCs/THIEF.cs b/NPCs/TownNPCs/THIEF.cs index a2a6f2aebc..73404c5354 100644 --- a/NPCs/TownNPCs/THIEF.cs +++ b/NPCs/TownNPCs/THIEF.cs @@ -310,7 +310,6 @@ namespace CalamityMod.NPCs.TownNPCs if (NPC.downedPirates) { shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(1, 0, 0, 0); nextSlot++; } if (NPC.downedMechBoss1 && NPC.downedMechBoss2 && NPC.downedMechBoss3) diff --git a/Projectiles/Pets/GoldiePet.cs b/Projectiles/Pets/GoldiePet.cs new file mode 100644 index 0000000000..97d74a5bf0 --- /dev/null +++ b/Projectiles/Pets/GoldiePet.cs @@ -0,0 +1,162 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Pets +{ + public class GoldiePet : ModProjectile + { + public Player Owner => Main.player[Projectile.owner]; + + public ref float MovementTimer => ref Projectile.ai[0]; + public ref float ShineLevel => ref Projectile.ai[1]; + public float MaxShineTime = 30f; + public static Color GoldColor = Color.Goldenrod; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Goldie"); + Main.projFrames[Projectile.type] = 5; + Main.projPet[Projectile.type] = true; + ProjectileID.Sets.LightPet[Projectile.type] = true; + } + + public override void SetDefaults() + { + Projectile.width = 14; + Projectile.height = 16; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.friendly = true; + Projectile.netImportant = true; + } + + public override void AI() + { + if (OwnerCheck()) + return; + + Projectile.frameCounter++; + Projectile.frame = Projectile.frameCounter / 5 % Main.projFrames[Projectile.type]; + Lighting.AddLight(Projectile.Center, GoldColor.ToVector3() * 0.9f); + + if (ShineLevel < MaxShineTime) + ShineLevel++; + else if (ShineLevel > MaxShineTime) + ShineLevel--; + + if (Main.rand.NextBool(6)) + Dust.QuickDust(Projectile.Center, GoldColor); + + //Find coins + Vector2 targetLocation = Projectile.position; + bool foundCoin = false; + float range = 800f; //50 block range + + for (int itemIndex = 0; itemIndex < Main.maxItems; itemIndex++) + { + Item item = Main.item[itemIndex]; + if (item.active && ItemID.Sets.CommonCoin[item.type] && item.noGrabDelay == 0 && item.playerIndexTheItemIsReservedFor == Projectile.owner && + ItemLoader.CanPickup(item, Main.player[item.playerIndexTheItemIsReservedFor]) && Main.player[item.playerIndexTheItemIsReservedFor].ItemSpace(item).CanTakeItemToPersonalInventory) + { + float itemDist = Vector2.Distance(item.Center, Projectile.Center); + float distanceToPotential = Vector2.Distance(Projectile.Center, targetLocation); + //Pick it up + if (Projectile.owner == Main.myPlayer && Projectile.getRect().Intersects(new Rectangle((int)item.position.X, (int)item.position.Y, item.width, item.height))) + { + Main.item[itemIndex] = Owner.GetItem(Projectile.owner, item, new GetItemSettings()); + if (Main.netMode == NetmodeID.MultiplayerClient) + { + NetMessage.SendData(MessageID.SyncItem, -1, -1, null, itemIndex, 0f, 0f, 0f, 0, 0, 0); + } + + //Big shine boost on collect + ShineLevel += 30f; + } + //Otherwise, start chasing + if (distanceToPotential < itemDist && itemDist < range) + { + range = itemDist; + targetLocation = item.Center; + foundCoin = true; + } + } + } + + //Chase after coins + if (foundCoin) + { + float itemDist = Vector2.Distance(targetLocation, Projectile.Center); + Vector2 destination = Projectile.SafeDirectionTo(targetLocation); + destination *= 12f; + Projectile.velocity = (Projectile.velocity * 40f + destination) / 41f; + Projectile.rotation = Projectile.velocity.X * 0.05f; + MovementTimer = -1f; + } + //Return to resting position + else if (MovementTimer == -1f) + { + Vector2 restingSpot = Owner.Center + Vector2.UnitY * -80f; + Projectile.velocity = (restingSpot - Projectile.Center) / 10f; + Projectile.rotation = Projectile.velocity.X * 0.05f; + + //Start spinning again when rested + if (Vector2.Distance(restingSpot, Projectile.Center) <= 2f) + MovementTimer++; + } + //Rotate + else + { + Vector2 playerDist = Owner.Center - Projectile.Center; + Projectile.rotation = playerDist.ToRotation() - MathHelper.PiOver2; + Projectile.Center = Owner.Center + Vector2.UnitY.RotatedBy(MovementTimer) * -80f; + MovementTimer += MathHelper.ToRadians(4f); + } + } + + public bool OwnerCheck() + { + // No logic should be run if the player is no longer active in the game. + if (!Owner.active) + { + Projectile.Kill(); + return true; + } + + if (Owner.dead) + Owner.Calamity().thiefsDime = false; + if (Owner.Calamity().thiefsDime) + Projectile.timeLeft = 2; + + return false; + } + + public override bool PreDraw(ref Color lightColor) + { + //Similar coin shining to Midas Prime coins. Thought it'd look pretty neat for a light pet. + Texture2D shineTex = ModContent.Request("CalamityMod/Particles/Sparkle").Value; + Texture2D bloomTex = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + + float shinePercent = Math.Clamp(ShineLevel / MaxShineTime, 0f, 3f); //Max of 300% when collecting coins + Vector2 shineScale = new Vector2(1f, 3f - shinePercent * 2f); + Color shineColor = GoldColor; + + if (shinePercent > 0f) + { + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + + Main.EntitySpriteDraw(bloomTex, Projectile.Center - Main.screenPosition, null, shineColor * shinePercent * 0.15f, Projectile.rotation, bloomTex.Size() / 2f, shineScale * Projectile.scale * 0.6f, SpriteEffects.None, 0); + Main.EntitySpriteDraw(shineTex, Projectile.Center - Main.screenPosition, null, shineColor * shinePercent * 0.6f, Projectile.rotation, shineTex.Size() / 2f, shineScale * Projectile.scale, SpriteEffects.None, 0); + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + } + + return true; + } + } +} diff --git a/Projectiles/Rogue/ThiefsDimeProj.png b/Projectiles/Pets/GoldiePet.png similarity index 100% rename from Projectiles/Rogue/ThiefsDimeProj.png rename to Projectiles/Pets/GoldiePet.png diff --git a/Projectiles/Rogue/ThiefsDimeProj.cs b/Projectiles/Rogue/ThiefsDimeProj.cs deleted file mode 100644 index a1020b0580..0000000000 --- a/Projectiles/Rogue/ThiefsDimeProj.cs +++ /dev/null @@ -1,99 +0,0 @@ -using CalamityMod.CalPlayer; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Rogue -{ - public class ThiefsDimeProj : ModProjectile - { - private double rotation = 0; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Thief's Dime"); - Main.projFrames[Projectile.type] = 5; - ProjectileID.Sets.MinionSacrificable[Projectile.type] = true; - } - - public override void SetDefaults() - { - Projectile.width = 20; - Projectile.height = 20; - Projectile.ignoreWater = true; - Projectile.minionSlots = 0f; - Projectile.DamageType = RogueDamageClass.Instance; - Projectile.timeLeft = 18000; - Projectile.tileCollide = false; - Projectile.friendly = true; - Projectile.timeLeft *= 5; - Projectile.penetrate = -1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; - } - - public override void AI() - { - Projectile.frameCounter++; - if (Projectile.frameCounter > 6) - { - Projectile.frame++; - Projectile.frameCounter = 0; - } - if (Projectile.frame > 4) - { - Projectile.frame = 0; - } - bool flag64 = Projectile.type == ModContent.ProjectileType(); - Player player = Main.player[Projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); - if (!modPlayer.thiefsDime) - { - Projectile.active = false; - return; - } - if (flag64) - { - if (player.dead) - { - modPlayer.tDime = false; - } - if (modPlayer.tDime) - { - Projectile.timeLeft = 2; - } - } - Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.15f / 255f, (255 - Projectile.alpha) * 0.15f / 255f, (255 - Projectile.alpha) * 0.01f / 255f); - Vector2 vector = player.Center - Projectile.Center; - Projectile.rotation = vector.ToRotation() - 1.57f; - Projectile.Center = player.Center + new Vector2(80, 0).RotatedBy(rotation); - rotation += 0.03; - if (rotation >= 360) - { - rotation = 0; - } - Projectile.velocity.X = (vector.X > 0f) ? -0.000001f : 0f; - } - - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(BuffID.Midas, 360); - Player player = Main.player[Projectile.owner]; - if ((target.damage > 5 || target.boss) && player.whoAmI == Main.myPlayer && !target.SpawnedFromStatue) - { - if (Main.rand.NextBool(5)) - { - Item.NewItem(Projectile.GetSource_FromThis(), (int)target.position.X, (int)target.position.Y, target.width, target.height, ItemID.SilverCoin, Main.rand.Next(10, 21)); - } - if (Main.rand.NextBool(10)) - { - Item.NewItem(Projectile.GetSource_FromThis(), (int)target.position.X, (int)target.position.Y, target.width, target.height, ItemID.GoldCoin); - } - } - else - { - return; - } - } - } -} diff --git a/Utilities/PlayerUtils.cs b/Utilities/PlayerUtils.cs index bdb831fafd..971bf7e39e 100644 --- a/Utilities/PlayerUtils.cs +++ b/Utilities/PlayerUtils.cs @@ -167,6 +167,8 @@ namespace CalamityMod light += 1; if (mp.sparks) light += 1; + if (mp.thiefsDime) + light += 1; if (mp.fathomSwarmerVisage) light += 1; if (mp.aquaticHeart) diff --git a/Utilities/WorldgenUtils.cs b/Utilities/WorldgenUtils.cs index 87cd55f6fa..38ddfa3c41 100644 --- a/Utilities/WorldgenUtils.cs +++ b/Utilities/WorldgenUtils.cs @@ -2,10 +2,14 @@ using Terraria.ID; using Terraria.ModLoader; using Terraria.DataStructures; +using Terraria.GameContent.Generation; +using Terraria.WorldBuilding; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using System.Linq; +using System.Collections.Generic; +using CalamityMod.DataStructures; namespace CalamityMod { @@ -38,7 +42,7 @@ namespace CalamityMod } //place a circular clump of tiles - public static void NaturalCircle(int i, int j, int size, int tileType) + public static void NaturalCircle(int i, int j, int size, int tileType, bool hasRandomness = false) { int BaseRadius = size; int radius = BaseRadius; @@ -57,7 +61,7 @@ namespace CalamityMod } } - radius = BaseRadius - WorldGen.genRand.Next(-1, 2); + radius = BaseRadius - (hasRandomness ? WorldGen.genRand.Next(-1, 2) : 0); } } @@ -70,9 +74,23 @@ namespace CalamityMod { for (int y = 5; y < 300; y++) { - if (WorldGen.genRand.Next(350) == 0 && Main.tile[x, y].TileType == TileID.Cloud) + if (WorldGen.genRand.Next(365) == 0 && Main.tile[x, y].TileType == TileID.Cloud) { - NaturalCircle(x, y, WorldGen.genRand.Next(1, 4), ModContent.TileType()); + ShapeData circle = new ShapeData(); + GenAction blotchMod = new Modifiers.Blotches(2, 0.4); + + int outerRadius = (int)(WorldGen.genRand.Next(3, 5) * WorldGen.genRand.NextFloat(0.74f, 0.82f)); + + WorldUtils.Gen(new Point(x, y), new Shapes.Circle(outerRadius), Actions.Chain(new GenAction[] + { + blotchMod.Output(circle) + })); + + WorldUtils.Gen(new Point(x, y), new ModShapes.All(circle), Actions.Chain(new GenAction[] + { + new Actions.ClearTile(), + new Actions.PlaceTile((ushort)ModContent.TileType()) + })); } } } diff --git a/World/BrimstoneCrag.cs b/World/BrimstoneCrag.cs index 25c8d42f60..59bcac1dd0 100644 --- a/World/BrimstoneCrag.cs +++ b/World/BrimstoneCrag.cs @@ -77,7 +77,7 @@ namespace CalamityMod.World tileDown.TileType != ModContent.TileType() || tileLeft.TileType != ModContent.TileType() || tileRight.TileType != ModContent.TileType())) { - CalamityUtils.NaturalCircle(x, y, WorldGen.genRand.Next(5, 22), ModContent.TileType()); + CalamityUtils.NaturalCircle(x, y, WorldGen.genRand.Next(5, 22), ModContent.TileType(), true); } } } @@ -98,7 +98,7 @@ namespace CalamityMod.World { if (WorldGen.genRand.Next(25) == 0) { - CalamityUtils.NaturalCircle(x, y, WorldGen.genRand.Next(5, 15), ModContent.TileType()); + CalamityUtils.NaturalCircle(x, y, WorldGen.genRand.Next(5, 15), ModContent.TileType(), true); } } }