diff --git a/Buffs/Pets/BendyBuff.cs b/Buffs/Pets/BendyBuff.cs new file mode 100644 index 0000000000..9acece95d2 --- /dev/null +++ b/Buffs/Pets/BendyBuff.cs @@ -0,0 +1,28 @@ +using CalamityMod.Projectiles.Pets; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Pets +{ + public class BendyBuff : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Dreamfog"); + Description.SetDefault("Xi believes in Yuu"); + Main.buffNoTimeDisplay[Type] = true; + Main.lightPet[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + player.buffTime[buffIndex] = 18000; + player.Calamity().bendyPet = true; + bool petProjectileNotSpawned = player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0; + if (petProjectileNotSpawned && player.whoAmI == Main.myPlayer) + { + Projectile.NewProjectile(player.position.X + (float)(player.width / 2), player.position.Y + (float)(player.height / 2), 0f, 0f, ModContent.ProjectileType(), 0, 0f, player.whoAmI, 0f, 0f); + } + } + } +} diff --git a/Buffs/Pets/BendyBuff.png b/Buffs/Pets/BendyBuff.png new file mode 100644 index 0000000000..e1606a6350 Binary files /dev/null and b/Buffs/Pets/BendyBuff.png differ diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 47d8968b7a..3b80193602 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -289,6 +289,7 @@ namespace CalamityMod.CalPlayer public bool babyGhostBell = false; public bool radiator = false; public bool scalPet = false; + public bool bendyPet = false; #endregion #region Rage @@ -1338,6 +1339,7 @@ namespace CalamityMod.CalPlayer babyGhostBell = false; radiator = false; scalPet = false; + bendyPet = false; onyxExcavator = false; angryDog = false; fab = false; @@ -11842,6 +11844,8 @@ namespace CalamityMod.CalPlayer light += 1; if (radiator) light += 1; + if (bendyPet) + light += 1; if (sparks) light += 1; if (fathomSwarmerVisage) diff --git a/Items/Pets/ChromaticOrb.cs b/Items/Pets/ChromaticOrb.cs new file mode 100644 index 0000000000..2880f8a9a3 --- /dev/null +++ b/Items/Pets/ChromaticOrb.cs @@ -0,0 +1,35 @@ +using CalamityMod.Buffs.Pets; +using CalamityMod.Projectiles.Pets; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Pets +{ + public class ChromaticOrb : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Chromatic Orb"); + Tooltip.SetDefault("It glows warmly in your hand\n" + + "Summons an ancient dragon light pet that highlights nearby enemies and danger sources\n" + + "Provides a small amount of light in the abyss"); + } + + public override void SetDefaults() + { + item.CloneDefaults(ItemID.WispinaBottle); + item.shoot = ModContent.ProjectileType(); + item.buffType = ModContent.BuffType(); + item.Calamity().customRarity = CalamityRarity.Dedicated; + } + + public override void UseStyle(Player player) + { + if (player.whoAmI == Main.myPlayer && player.itemTime == 0) + { + player.AddBuff(item.buffType, 3600, true); + } + } + } +} diff --git a/Items/Pets/ChromaticOrb.png b/Items/Pets/ChromaticOrb.png new file mode 100644 index 0000000000..71b117535b Binary files /dev/null and b/Items/Pets/ChromaticOrb.png differ diff --git a/Items/TreasureBags/AstrumDeusBag.cs b/Items/TreasureBags/AstrumDeusBag.cs index 67c8777c76..528c3942da 100644 --- a/Items/TreasureBags/AstrumDeusBag.cs +++ b/Items/TreasureBags/AstrumDeusBag.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.Materials; +using CalamityMod.Items.Pets; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Magic; @@ -33,10 +34,7 @@ namespace CalamityMod.Items.TreasureBags item.rare = 9; } - public override bool CanRightClick() - { - return true; - } + public override bool CanRightClick() => true; public override void PostUpdate() => CalamityUtils.ForceItemIntoWorld(item); @@ -58,6 +56,7 @@ namespace CalamityMod.Items.TreasureBags // Equipment DropHelper.DropItemRIV(player, ModContent.ItemType(), ModContent.ItemType(), 1f, DropHelper.RareVariantDropRateFloat); + DropHelper.DropItemChance(player, ModContent.ItemType(), 5); // Vanity DropHelper.DropItemChance(player, ModContent.ItemType(), 7); diff --git a/ModSupport/WeakReferenceSupport.cs b/ModSupport/WeakReferenceSupport.cs index 23b6437d50..ee867273d1 100644 --- a/ModSupport/WeakReferenceSupport.cs +++ b/ModSupport/WeakReferenceSupport.cs @@ -397,7 +397,7 @@ namespace CalamityMod List segments = new List() { NPCType(), NPCType(), NPCType() }; int summon = ItemType(); List loot = new List() { ItemType(), ItemType(), ItemID.FallenStar, ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.FragmentSolar, ItemID.FragmentVortex, ItemID.FragmentNebula, ItemID.FragmentStardust, ItemID.GreaterHealingPotion }; - List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType() }; + List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; string instructions = $"Defeat 3 empowered astral titans or use a [i:{summon}] at Night"; string despawn = CalamityUtils.ColorMessage("The infected deity retreats to the heavens.", new Color(0xFF, 0xD7, 0x00)); string bossLogTex = "CalamityMod/NPCs/AstrumDeus/AstrumDeus_BossChecklist"; diff --git a/NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs b/NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs index 87344adca7..5b8ba067ce 100644 --- a/NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs +++ b/NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs @@ -4,6 +4,7 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.LoreItems; using CalamityMod.Items.Materials; +using CalamityMod.Items.Pets; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.TreasureBags; using CalamityMod.Items.Weapons.Melee; @@ -233,6 +234,7 @@ namespace CalamityMod.NPCs.AstrumDeus // Equipment DropHelper.DropItemChance(npc, ModContent.ItemType(), DropHelper.RareVariantDropRateInt); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 5); // Vanity DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); diff --git a/Projectiles/Pets/BendyPet.cs b/Projectiles/Pets/BendyPet.cs new file mode 100644 index 0000000000..62b0184678 --- /dev/null +++ b/Projectiles/Pets/BendyPet.cs @@ -0,0 +1,257 @@ +using CalamityMod.CalPlayer; +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 BendyPet : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Dreamfog Dragon"); + Main.projFrames[projectile.type] = 5; + Main.projPet[projectile.type] = true; + ProjectileID.Sets.LightPet[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.netImportant = true; + projectile.width = 38; + projectile.height = 56; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.timeLeft *= 5; + projectile.ignoreWater = true; + projectile.tileCollide = false; + } + + public override void AI() + { + //Set up namespaces + Player player = Main.player[projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); + + //If the player dies or something, kill thte projectile + if (!player.active) + { + projectile.active = false; + return; + } + if (player.dead) + { + modPlayer.bendyPet = false; + } + + //Prevent the projectile from losing its timeLeft + if (modPlayer.bendyPet) + { + projectile.timeLeft = 2; + } + + //Update frames + projectile.frameCounter++; + if (projectile.frameCounter > 6) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= Main.projFrames[projectile.type]) + { + projectile.frame = 0; + } + + //Highlight nearby danger sources + player.dangerSense = true; + player.detectCreature = true; + + //Generate less light if returning to the player + if (projectile.localAI[0] == 0f) + { + Lighting.AddLight(projectile.Center, 0.8118f, 0.2529f, 1.3294f); //138, 43, 226 + } + else + { + Lighting.AddLight(projectile.Center, 0.4329f, 0.1349f, 0.709f); + } + + float idleMvt = 0.2f; + float projSpeed = 5f; + //Calculate where the pet should reside based on pressed controls + Vector2 projVec = player.Center - projectile.Center; + projVec.Y += player.gfxOffY; + if (player.controlLeft) + { + projVec.X -= 120f; + } + else if (player.controlRight) + { + projVec.X += 120f; + } + if (player.controlDown) + { + projVec.Y += 120f; + } + else + { + if (player.controlUp) + { + projVec.Y -= 120f; + } + projVec.Y -= 60f; + } + float playerDist = projVec.Length(); + if (playerDist > 1000f) + { + projectile.position.X += projVec.X; + projectile.position.Y += projVec.Y; + } + + //Returning to player AI + if (projectile.localAI[0] == 1f) + { + //If close enough, the player isn't moving too much, and isn't moving vertically, return to normal + if (playerDist < 10f && Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y) < projSpeed && player.velocity.Y == 0f) + { + projectile.localAI[0] = 0f; + } + + //Go faster + projSpeed = 12f; + if (playerDist < projSpeed) + { + projectile.velocity.X = projVec.X; + projectile.velocity.Y = projVec.Y; + } + else + { + playerDist = projSpeed / playerDist; + projectile.velocity.X = projVec.X * playerDist; + projectile.velocity.Y = projVec.Y * playerDist; + } + + //Set projectile direction and rotation + if (projectile.velocity.X > 0.5f) + { + projectile.direction = -1; + } + else if (projectile.velocity.X < -0.5f) + { + projectile.direction = 1; + } + projectile.spriteDirection = projectile.direction; + projectile.rotation = projectile.velocity.X * 0.05f; + return; + } + + //If too far, return to the player + if (playerDist > 200f) + { + projectile.localAI[0] = 1f; + } + + //Set projectile direction and rotation + if (projectile.velocity.X > 0.5f) + { + projectile.direction = -1; + } + else if (projectile.velocity.X < -0.5f) + { + projectile.direction = 1; + } + projectile.spriteDirection = projectile.direction; + + if (playerDist < 10f) + { + projectile.velocity.X = projVec.X; + projectile.velocity.Y = projVec.Y; + projectile.rotation = projectile.velocity.X * 0.05f; + if (playerDist < projSpeed) + { + projectile.position += projectile.velocity; + projectile.velocity *= 0f; + idleMvt = 0f; + } + projectile.direction = -player.direction; + } + playerDist = projSpeed / playerDist; + projVec.X *= playerDist; + projVec.Y *= playerDist; + if (projectile.velocity.X < projVec.X) + { + projectile.velocity.X += idleMvt; + if (projectile.velocity.X < 0f) + { + projectile.velocity.X *= 0.99f; + } + } + if (projectile.velocity.X > projVec.X) + { + projectile.velocity.X -= idleMvt; + if (projectile.velocity.X > 0f) + { + projectile.velocity.X *= 0.99f; + } + } + if (projectile.velocity.Y < projVec.Y) + { + projectile.velocity.Y += idleMvt; + if (projectile.velocity.Y < 0f) + { + projectile.velocity.Y *= 0.99f; + } + } + if (projectile.velocity.Y > projVec.Y) + { + projectile.velocity.Y -= idleMvt; + if (projectile.velocity.Y > 0f) + { + projectile.velocity.Y *= 0.99f; + } + } + + //Rotation if moving + if (projectile.velocity.X != 0f || projectile.velocity.Y != 0f) + { + projectile.rotation = projectile.velocity.X * 0.05f; + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + int height = texture.Height / Main.projFrames[projectile.type]; + int frameHeight = height * projectile.frame; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameHeight, texture.Width, height)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture.Width / 2f, (float)height / 2f), projectile.scale, spriteEffects, 0f); + return false; + } + + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = ModContent.GetTexture("CalamityMod/Projectiles/Pets/BendyPetGlow"); + int height = texture.Height / Main.projFrames[projectile.type]; + int frameHeight = height * projectile.frame; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + Color rainbow = CalamityUtils.MulticolorLerp(Main.GlobalTime / 2f % 1f, new Color[] + { + new Color(255, 0, 0, 50), //Red + new Color(255, 255, 0, 50), //Yellow + new Color(0, 255, 0, 50), //Green + new Color(0, 255, 255, 50), //Cyan + new Color(0, 0, 255, 50), //Blue + new Color(255, 0, 255, 50), //Fuschia + }); + + spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameHeight, texture.Width, height)), rainbow, projectile.rotation, new Vector2((float)texture.Width / 2f, (float)height / 2f), projectile.scale, spriteEffects, 0f); + } + } +} diff --git a/Projectiles/Pets/BendyPet.png b/Projectiles/Pets/BendyPet.png new file mode 100644 index 0000000000..5f6a240c6d Binary files /dev/null and b/Projectiles/Pets/BendyPet.png differ diff --git a/Projectiles/Pets/BendyPetGlow.png b/Projectiles/Pets/BendyPetGlow.png new file mode 100644 index 0000000000..8a154743f9 Binary files /dev/null and b/Projectiles/Pets/BendyPetGlow.png differ