diff --git a/Items/Tools/TheGift.cs b/Items/Tools/TheGift.cs index 6a24c27213..0b77753bfb 100644 --- a/Items/Tools/TheGift.cs +++ b/Items/Tools/TheGift.cs @@ -3,6 +3,7 @@ using CalamityMod.NPCs; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.GameContent; using Terraria.ID; using Terraria.Localization; @@ -14,7 +15,7 @@ namespace CalamityMod.Items.Tools { public new string LocalizationCategory => "Items.Tools"; public override string Texture => "Terraria/Images/Item_601"; //Placeholder - + public static readonly SoundStyle BadBuzzer = new SoundStyle("CalamityMod/Sounds/Custom/BadGiftBuzzer") with { Volume = 0.85f }; public override void SetDefaults() { Item.width = Item.height = 20; @@ -44,26 +45,42 @@ namespace CalamityMod.Items.Tools { // Don't run this code for NPCs that aren't affected by happiness // Also don't run this if The Gift has already been used on this NPC; they all will hold grudges against you :) - if (!n.isLikeATownNPC || NPCID.Sets.NoTownNPCHappiness[n.type] || NPCID.Sets.IsTownPet[n.type] || - n.GetGlobalNPC().TheGiftStatus.HasValue) + if (!n.isLikeATownNPC || NPCID.Sets.NoTownNPCHappiness[n.type] || NPCID.Sets.IsTownPet[n.type] || n.GetGlobalNPC().TheGiftStatus.HasValue) continue; if (Item.Hitbox.Intersects(n.Hitbox)) { + bool positive = Main.rand.NextBool(); + Color c = positive ? Color.Green : Color.Red; + SoundEngine.PlaySound(positive ? SoundID.ResearchComplete : BadBuzzer, n.Center); + n.GetGlobalNPC().TheGiftStatus = positive; + n.GetGlobalNPC().TheGiftReset = 0.0; + + // Visual effect to demonstrate that something happened + for (int i = 0; i < 6; i++) + { + Vector2 spawnPos = n.Center + Main.rand.NextVector2Circular(30f, 30f); + HealingPlus s = new(spawnPos, 0.5f, (spawnPos - n.Center).SafeNormalize(Vector2.Zero) * 0.65f, c, c * 0.2f, 25) + { + Rotation = positive ? 0f : MathHelper.PiOver4 + }; + GeneralParticleHandler.SpawnParticle(s); + } + for (int j = 0; j < 4; j++) + { + Vector2 spawnPos = n.Center + Main.rand.NextVector2Circular(50f, 50f); + Vector2 arrVel = -Vector2.UnitY * 0.6f * positive.ToDirectionInt(); + StatChangeArrow arr = new(spawnPos, arrVel, -MathHelper.PiOver2 * positive.ToDirectionInt(), c, c * 0.1f, 0.7f, 40); + GeneralParticleHandler.SpawnParticle(arr); + } + Item.active = false; Item.type = ItemID.None; Item.stack = 0; if (Main.dedServ) NetMessage.SendData(MessageID.SyncItem, -1, -1, null, Item.whoAmI); - - bool positive = Main.rand.NextBool(); - Color c = positive ? Color.Green : Color.Red; - n.GetGlobalNPC().TheGiftStatus = positive; - n.GetGlobalNPC().TheGiftReset = 0.0; - - // Placeholder visual effect - HealingPlus s = new(n.Center, 2f, Vector2.Zero, c, c, 40); - GeneralParticleHandler.SpawnParticle(s); + // Make sure it can't apply to multiple NPCs at once + break; } } } diff --git a/Particles/HealingPlus.cs b/Particles/HealingPlus.cs index 4a4de6232b..fbb88cf9f1 100644 --- a/Particles/HealingPlus.cs +++ b/Particles/HealingPlus.cs @@ -12,11 +12,8 @@ namespace CalamityMod.Particles public override bool UseCustomDraw => true; public override bool SetLifetime => true; - public Player Owner; public Color StartColor; public Color EndColor; - public Vector2 OverridePosition; - public float Opacity; public HealingPlus(Vector2 position, float scale, Vector2 velocity, Color colorStart, Color colorEnd, int lifetime) { @@ -34,20 +31,15 @@ namespace CalamityMod.Particles { Color = Color.Lerp(StartColor, EndColor, LifetimeCompletion); Lighting.AddLight(Position, Color.ToVector3() * 0.2f); - Opacity -= 0.5f; } public override void CustomDraw(SpriteBatch spriteBatch) { Texture2D tex = ModContent.Request(Texture).Value; - Vector2 Size = new Vector2(Scale); + Vector2 origin = new Vector2(tex.Width, tex.Height) * 0.5f; - Vector2 origin = new Vector2(tex.Width, tex.Height); - - Vector2 PositionAdjust = new Vector2(-16, -40); - - spriteBatch.Draw(tex, Position - Main.screenPosition - PositionAdjust, null, Color, Rotation, origin, Size, SpriteEffects.None, 0); + spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color, Rotation, origin, Size, SpriteEffects.None, 0); } } diff --git a/Sounds/Custom/BadGiftBuzzer.ogg b/Sounds/Custom/BadGiftBuzzer.ogg new file mode 100644 index 0000000000..16cb4134e4 Binary files /dev/null and b/Sounds/Custom/BadGiftBuzzer.ogg differ