From 818ace0aecb67094d4efe43643db5b9b7d5cf642 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Thu, 7 Nov 2019 21:09:10 -0500 Subject: [PATCH] added baby ghost bell light pet --- Buffs/Pets/BabyGhostBellBuff.cs | 28 +++ Buffs/Pets/BabyGhostBellBuff.png | Bin 0 -> 568 bytes CalPlayer/CalamityPlayer.cs | 9 +- .../SunkenSeaCatches/RustedJingleBell.cs | 35 ++++ Projectiles/Pets/BabyGhostBell.cs | 162 ++++++++++++++++++ 5 files changed, 231 insertions(+), 3 deletions(-) create mode 100644 Buffs/Pets/BabyGhostBellBuff.cs create mode 100644 Buffs/Pets/BabyGhostBellBuff.png create mode 100644 Items/Fishing/SunkenSeaCatches/RustedJingleBell.cs create mode 100644 Projectiles/Pets/BabyGhostBell.cs diff --git a/Buffs/Pets/BabyGhostBellBuff.cs b/Buffs/Pets/BabyGhostBellBuff.cs new file mode 100644 index 0000000000..53c2d67460 --- /dev/null +++ b/Buffs/Pets/BabyGhostBellBuff.cs @@ -0,0 +1,28 @@ +using CalamityMod.Projectiles.Pets; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Pets +{ + public class BabyGhostBellBuff : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Baby Ghost Bell"); + Description.SetDefault("Be careful not to pop the bubble"); + Main.buffNoTimeDisplay[Type] = true; + Main.lightPet[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + player.buffTime[buffIndex] = 18000; + player.Calamity().babyGhostBell = 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/BabyGhostBellBuff.png b/Buffs/Pets/BabyGhostBellBuff.png new file mode 100644 index 0000000000000000000000000000000000000000..8da6514bc48ad37d4339fa1db5cc5533d048ec88 GIT binary patch literal 568 zcmV-80>}M{P)Px$@<~KNR9J=0moZ4&K@`S+soKG%AS#JS+oe>jNLvsQQip;RoQhN^S_)1U7eyRg zgo02UN^#UxtO%Ck6zC#B1aVOavDi(ekRm~FDHIVM{`vUluDRq7LUP{{a_`+G-}m0V z_b%2Je*wVd`JZd5h?b{4F@QVO{LxaV7xR0)gNET^F9pEg!~+0kj(-^Tul>_y56+z) z0?__?2!QU6Zo{6Q9J>Y|6mS`C%Y1P5W28Uej{;F+KDzzISYMx72HU~R)#w=1Cye-uzR zgrM>%mUYh`8yj5rT~Osz?x^;wJ7$hDhQB`wxVoW~u%WDPH3i^oX9oylF6J)OT!C22 z-ABfI!0v|j45*n;(A4Y7@|Ab()); break; }*/ + rareItemList.Add(ModContent.ItemType()); if (Main.hardMode) { rareItemList.Add(ModContent.ItemType()); @@ -7609,11 +7612,11 @@ namespace CalamityMod.CalPlayer { caughtType = ModContent.ItemType(); } - /*else if (sunkenFish <= 3 && sunkenFish >= 5) //3% + else if (sunkenFish <= 3 && sunkenFish >= 5) //3% { caughtType = ModContent.ItemType(); } - else if (sunkenFish <= 2 && sunkenFish >= 0) //3% + /*else if (sunkenFish <= 2 && sunkenFish >= 0) //3% { caughtType = ModContent.ItemType(); }*/ diff --git a/Items/Fishing/SunkenSeaCatches/RustedJingleBell.cs b/Items/Fishing/SunkenSeaCatches/RustedJingleBell.cs new file mode 100644 index 0000000000..fc75ce689e --- /dev/null +++ b/Items/Fishing/SunkenSeaCatches/RustedJingleBell.cs @@ -0,0 +1,35 @@ +using CalamityMod.Buffs.Pets; +using CalamityMod.Projectiles.Pets; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Fishing.SunkenSeaCatches +{ + public class RustedJingleBell : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Rusted Jingle Bell"); + Tooltip.SetDefault("Summons a baby ghost bell light pet\n" + + "Provides a good amount of light while underwater"); + } + + public override void SetDefaults() + { + item.CloneDefaults(ItemID.WispinaBottle); + item.shoot = ModContent.ProjectileType(); + item.buffType = ModContent.BuffType(); + item.value = Item.sellPrice(gold: 5); + item.rare = 3; + } + + public override void UseStyle(Player player) + { + if (player.whoAmI == Main.myPlayer && player.itemTime == 0) + { + player.AddBuff(item.buffType, 3600, true); + } + } + } +} diff --git a/Projectiles/Pets/BabyGhostBell.cs b/Projectiles/Pets/BabyGhostBell.cs new file mode 100644 index 0000000000..7e25be47cb --- /dev/null +++ b/Projectiles/Pets/BabyGhostBell.cs @@ -0,0 +1,162 @@ +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 BabyGhostBell : ModProjectile + { + private bool underwater = false; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Baby Ghost Bell"); + Main.projFrames[projectile.type] = 4; + Main.projPet[projectile.type] = true; + ProjectileID.Sets.LightPet[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.netImportant = true; + projectile.width = 30; + projectile.height = 30; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.timeLeft *= 5; + } + + public override void AI() + { + Player player = Main.player[projectile.owner]; + if (!player.active) + { + projectile.active = false; + return; + } + CalamityPlayer modPlayer = player.Calamity(); + if (player.dead) + { + modPlayer.babyGhostBell = false; + } + if (modPlayer.babyGhostBell) + { + projectile.timeLeft = 2; + } + underwater = Collision.DrownCollision(player.position, player.width, player.height, player.gravDir); + if (underwater) + { + Lighting.AddLight(projectile.Center, 0.3f, 0.9f, 1.5f); + } + else + { + Lighting.AddLight(projectile.Center, 0.1f, 0.3f, 0.5f); + } + float num16 = 0.5f; + projectile.tileCollide = false; + int num17 = 100; + Vector2 vector3 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); + float num18 = Main.player[projectile.owner].position.X + (float)(Main.player[projectile.owner].width / 2) - vector3.X; + float num19 = Main.player[projectile.owner].position.Y + (float)(Main.player[projectile.owner].height / 2) - vector3.Y; + num19 += (float)Main.rand.Next(-10, 21); + num18 += (float)Main.rand.Next(-10, 21); + num18 += (float)(60 * -(float)Main.player[projectile.owner].direction); + num19 -= 60f; + float num20 = (float)Math.Sqrt((double)(num18 * num18 + num19 * num19)); + float num21 = 18f; + if (num20 < (float)num17 && Main.player[projectile.owner].velocity.Y == 0f && + projectile.position.Y + (float)projectile.height <= Main.player[projectile.owner].position.Y + (float)Main.player[projectile.owner].height && + !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) + { + projectile.ai[0] = 0f; + if (projectile.velocity.Y < -6f) + { + projectile.velocity.Y = -6f; + } + } + if (num20 > 2000f) + { + projectile.position.X = Main.player[projectile.owner].Center.X - (float)(projectile.width / 2); + projectile.position.Y = Main.player[projectile.owner].Center.Y - (float)(projectile.height / 2); + projectile.netUpdate = true; + } + if (num20 < 50f) + { + if (Math.Abs(projectile.velocity.X) > 2f || Math.Abs(projectile.velocity.Y) > 2f) + { + projectile.velocity *= 0.99f; + } + num16 = 0.01f; + } + else + { + if (num20 < 100f) + { + num16 = 0.1f; + } + if (num20 > 300f) + { + num16 = 1f; + } + num20 = num21 / num20; + num18 *= num20; + num19 *= num20; + } + if (projectile.velocity.X < num18) + { + projectile.velocity.X = projectile.velocity.X + num16; + if (num16 > 0.05f && projectile.velocity.X < 0f) + { + projectile.velocity.X = projectile.velocity.X + num16; + } + } + if (projectile.velocity.X > num18) + { + projectile.velocity.X = projectile.velocity.X - num16; + if (num16 > 0.05f && projectile.velocity.X > 0f) + { + projectile.velocity.X = projectile.velocity.X - num16; + } + } + if (projectile.velocity.Y < num19) + { + projectile.velocity.Y = projectile.velocity.Y + num16; + if (num16 > 0.05f && projectile.velocity.Y < 0f) + { + projectile.velocity.Y = projectile.velocity.Y + num16 * 2f; + } + } + if (projectile.velocity.Y > num19) + { + projectile.velocity.Y = projectile.velocity.Y - num16; + if (num16 > 0.05f && projectile.velocity.Y > 0f) + { + projectile.velocity.Y = projectile.velocity.Y - num16 * 2f; + } + } + if ((double)projectile.velocity.X >= 0.25) + { + projectile.direction = -1; + } + else if ((double)projectile.velocity.X < -0.25) + { + projectile.direction = 1; + } + projectile.spriteDirection = projectile.direction; + projectile.rotation = projectile.velocity.X * 0.05f; + projectile.frameCounter++; + if (projectile.frameCounter > 6) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame > 3) + { + projectile.frame = 0; + } + } + } +}