diff --git a/NPCs/SunkenSea/Sharkoon.cs b/NPCs/SunkenSea/Sharkoon.cs
index a21b583ac7..f8c868b411 100644
--- a/NPCs/SunkenSea/Sharkoon.cs
+++ b/NPCs/SunkenSea/Sharkoon.cs
@@ -212,7 +212,17 @@ namespace CalamityMod.NPCs.SunkenSea
return true;
}
- public override void OnHitByProjectile(Projectile projectile, NPC.HitInfo hit, int damageDone) => CurrentBehavior = ExplodingBehavior;
+ public override void OnHitByProjectile(Projectile projectile, NPC.HitInfo hit, int damageDone)
+ {
+ if (IsBig)
+ CurrentBehavior = ExplodingBehavior;
+ }
+
+ public override void OnHitNPC(NPC target, NPC.HitInfo hit)
+ {
+ if (IsBig)
+ CurrentBehavior = ExplodingBehavior;
+ }
#endregion
@@ -253,7 +263,7 @@ namespace CalamityMod.NPCs.SunkenSea
if (!NPC.velocity.HasNaNs())
ConeDetectionDirection = (NPC.rotation * MathF.Sign(NPC.velocity.Y) + (NPC.spriteDirection == -1 ? MathHelper.Pi : 0f)).ToRotationVector2();
- NPC.rotation = MathHelper.ToRadians(NPC.velocity.LengthSquared()) * MathF.Sign(NPC.velocity.X);
+ NPC.rotation = MathHelper.ToRadians(NPC.velocity.Length() * 3f) * MathF.Sign(NPC.velocity.X);
if (MathF.Abs(NPC.velocity.X) > 2f)
NPC.spriteDirection = NPC.direction = MathF.Sign(NPC.velocity.X);
@@ -297,9 +307,6 @@ namespace CalamityMod.NPCs.SunkenSea
if (PreviousBehavior == RecoveringBehavior)
RecoverTimer = 0f;
- if (newBehavior == HuntBehavior || newBehavior == AvoidBehavior)
- ScaleSquish.Y += 0.4f;
-
NPC.noGravity = newBehavior != OutsideWaterBehavior;
}
@@ -307,20 +314,39 @@ namespace CalamityMod.NPCs.SunkenSea
{
// If it's not a small fish and it's not being chased by a predator, the Sharkoon may hunt.
if (IsBig && CurrentPredator is null)
+ {
CurrentBehavior = HuntBehavior;
+ React(Color.Orange * 0.6f, EmoteExpressionParticle.EmoteType.Exclamation, new("CalamityMod/Sounds/Custom/ur") { PitchVariance = 0.2f });
+ }
+
+ ScaleSquish.Y += 1.4f;
}
protected override void OnPredatorDetection(NPC predator)
{
// Regardless of anything, if it detects a predator, time to run.
CurrentBehavior = AvoidBehavior;
+
+ MaximumSpeed *= 1.2f;
+
+ React(Color.Red * 0.6f, EmoteExpressionParticle.EmoteType.DoubleExclamation, new("CalamityMod/Sounds/Custom/ur") { PitchVariance = 0.2f });
+
+ ScaleSquish.Y += 1.4f;
}
protected override void OnPlayerDetection(Player player)
{
// If the Sharkoon is shy, it'll run away from the player.
if (Personality == PersonalityType.Shy)
+ {
CurrentBehavior = AvoidBehavior;
+ React(Color.Orange, EmoteExpressionParticle.EmoteType.QuestionExclamation, new("CalamityMod/Sounds/Custom/ur") { PitchVariance = 0.2f });
+ }
+
+ if (Personality == PersonalityType.Curious)
+ React(Color.Green, EmoteExpressionParticle.EmoteType.Question, new("CalamityMod/Sounds/Custom/ur") { PitchVariance = 0.2f });
+
+ ScaleSquish.Y += 0.4f;
}
private void IdlingBehavior()
@@ -379,24 +405,27 @@ namespace CalamityMod.NPCs.SunkenSea
if (entityToAvoid is null)
{
CurrentBehavior = IdlingBehavior;
+ MaximumSpeed /= MaximumSpeed % 1.2f == 0f ? 1.2f : 1f;
return;
}
+ bool isAvoidingPredator = entityToAvoid is NPC && (entityToAvoid as NPC).whoAmI == CurrentPredator.whoAmI;
+
if (PathfindingPoints is null)
{
- Point randomEscapePoint = (NPC.Center + NPC.DirectionFrom(entityToAvoid.Center).RotatedByRandom(MathHelper.PiOver2) * Main.rand.NextFloat(300f, 400f)).ToSafeTileCoordinates();
+ float fleeingDistance = isAvoidingPredator ? 600f : 300f;
- var grid = CalamityUtils.AStar.MakeGenericGrid(NPC.Center, 300f);
+ Point randomEscapePoint = (NPC.Center + NPC.DirectionFrom(entityToAvoid.Center).RotatedByRandom(MathHelper.PiOver2) * Main.rand.NextFloat(fleeingDistance, fleeingDistance + 100f)).ToSafeTileCoordinates();
+
+ var grid = CalamityUtils.AStar.MakeGenericGrid(NPC.Center, fleeingDistance);
while (!grid.Contains(randomEscapePoint))
- {
- randomEscapePoint = (NPC.Center + NPC.DirectionFrom(entityToAvoid.Center).RotatedByRandom(MathHelper.PiOver2) * Main.rand.NextFloat(300f, 400f)).ToSafeTileCoordinates();
- }
+ randomEscapePoint = (NPC.Center + NPC.DirectionFrom(entityToAvoid.Center).RotatedByRandom(MathHelper.PiOver2) * Main.rand.NextFloat(fleeingDistance, fleeingDistance + 100f)).ToSafeTileCoordinates();
MakePath(randomEscapePoint.ToWorldCoordinates(), grid);
}
else
- GenericPathFollowing(acceleration: 0.14f, pathFollowingSpeed: 0.07f, conditionToFinishFollowing: FinishedPathfinding());
+ GenericPathFollowing(acceleration: 0.14f * (isAvoidingPredator ? 2f : 1f), pathFollowingSpeed: 0.07f * (isAvoidingPredator ? 2.2f : 1f), conditionToFinishFollowing: FinishedPathfinding());
// If it's capable of exploding and the predator's within distance, kaboom.
if (IsBig && NPC.DistanceSQ(entityToAvoid.Center) < DistanceToKaboom * DistanceToKaboom && entityToAvoid is NPC && AvoidNPCs.Contains((entityToAvoid as NPC).type))
diff --git a/NPCs/SunkenSea/SunkenSeaNPC.cs b/NPCs/SunkenSea/SunkenSeaNPC.cs
index 9360ea5eb0..83f0163539 100644
--- a/NPCs/SunkenSea/SunkenSeaNPC.cs
+++ b/NPCs/SunkenSea/SunkenSeaNPC.cs
@@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
using System.IO;
+using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Terraria;
+using Terraria.Audio;
using Terraria.DataStructures;
using Terraria.GameContent.Bestiary;
using Terraria.ID;
@@ -375,6 +377,28 @@ namespace CalamityMod.NPCs.SunkenSea
NPC.DistanceSQ(CurrentlyFollowedPathPoint) > 240f * 240f ||
PathfindingPoints[^1] == CurrentlyFollowedPathPoint && NPC.velocity == Vector2.Zero;
+ ///
+ /// Spawns an emote particle.
+ ///
+ protected void React(Color emoteColor, EmoteExpressionParticle.EmoteType emoteImage, SoundStyle? sound = null)
+ {
+ if (!Main.dedServ)
+ {
+ var emoteDirection = -Vector2.UnitY.RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(2f, 3f);
+ Particle emote = new EmoteExpressionParticle(
+ NPC.Center + emoteDirection * 2f,
+ emoteDirection,
+ 2.2f,
+ emoteColor,
+ Main.rand.Next(30, 46),
+ emoteImage);
+ GeneralParticleHandler.SpawnParticle(emote);
+
+ if (sound is not null)
+ SoundEngine.PlaySound(sound, NPC.Center);
+ }
+ }
+
#endregion
#region Syncing
diff --git a/Particles/EmoteExpressionParticle.cs b/Particles/EmoteExpressionParticle.cs
new file mode 100644
index 0000000000..4e9de2e4e0
--- /dev/null
+++ b/Particles/EmoteExpressionParticle.cs
@@ -0,0 +1,57 @@
+using System;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
+using Terraria;
+using Terraria.ModLoader;
+
+namespace CalamityMod.Particles
+{
+ public class EmoteExpressionParticle : Particle
+ {
+ public override string Texture => "CalamityMod/Particles/EmoteExpressions";
+
+ public override bool UseCustomDraw => true;
+
+ public override bool SetLifetime => true;
+
+ public enum EmoteType
+ {
+ Exclamation,
+ DoubleExclamation,
+ QuestionExclamation,
+ Question,
+ Note,
+ DoubleNote,
+ Smile,
+ BigSmile
+ }
+
+ private Rectangle Frame;
+
+ public EmoteExpressionParticle(Vector2 position, Vector2 velocity, float scale, Color color, int lifeTime, EmoteType emote)
+ {
+ Position = position;
+ Scale = scale;
+ Velocity = velocity;
+ Color = color;
+ Lifetime = lifeTime;
+ Frame = ModContent.Request(Texture).Value.Frame(horizontalFrames: 8, verticalFrames: 1, frameX: (int)emote);
+ Rotation = velocity.ToRotation() + MathHelper.PiOver2;
+ }
+
+ public override void Update()
+ {
+ Velocity *= 0.96f;
+ Scale *= 0.97f;
+ }
+
+ public override void CustomDraw(SpriteBatch spriteBatch)
+ {
+ Texture2D emoteTexture = ModContent.Request(Texture).Value;
+ Vector2 origin = new Vector2(Frame.Width / 2f, Frame.Height);
+ float opacity = 1 - (float)Math.Pow(LifetimeCompletion, 4f);
+
+ spriteBatch.Draw(emoteTexture, Position - Main.screenPosition, Frame, Color * opacity, Rotation, origin, Scale, SpriteEffects.None, 0);
+ }
+ }
+}
diff --git a/Particles/EmoteExpressions.png b/Particles/EmoteExpressions.png
new file mode 100644
index 0000000000..3c08c3cce8
Binary files /dev/null and b/Particles/EmoteExpressions.png differ
diff --git a/Sounds/Custom/ur.ogg b/Sounds/Custom/ur.ogg
new file mode 100644
index 0000000000..d8c84eb7b8
Binary files /dev/null and b/Sounds/Custom/ur.ogg differ