Stormlion Sentry

Sniper like antlion, charges and fires a fast electric projectile, but can't update it's aim very fast.
These guys love music and will dance if you play any for them.
This commit is contained in:
Xyk committed 2025-04-30 02:28:45 -07:00
1 parent 8fb8bba11c
commit 15ce3e77c9
16 files changed
+421 -3

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
using CalamityMod.Dusts;
using Microsoft.Xna.Framework;
using Terraria.Audio;
using Terraria.ModLoader;
namespace CalamityMod.Effects
{
public class StormlionEffects
{
// Energy
public static int EnergyDust = ModContent.DustType<LightDust>();
public static Color EnergyColor = new Color(5, 187, 177);
// Flesh
public static int FleshDust = 192;
public static Color FleshColor = new Color(171, 113, 91);
// Sounds
public static readonly SoundStyle Hit = new("CalamityMod/Sounds/NPCHit/StormlionAltHit");
public static readonly SoundStyle Killed = new("CalamityMod/Sounds/NPCKilled/StormlionAltDeath");
public static readonly SoundStyle Attack = new("CalamityMod/Sounds/Custom/StormlionAltShoot");
public static readonly SoundStyle Idle1 = new("CalamityMod/Sounds/Custom/StormlionAltIdle1");
public static readonly SoundStyle Idle2 = new("CalamityMod/Sounds/Custom/StormlionAltIdle2");
}
}
@@ -142,6 +142,7 @@ Searslug: A distant cousin of the Slugbuns which can withstand the extreme heat
Sharkoon: The bulbous Sharkoon wanders the reefs on the outskirts of the Sunken Sea. It retaliates against threats through the unusual method of exploding a sac on its body that stores highly reactive chemicals, fleeing in the confusion caused by its shockwave.
Slugbun: The name of these cute sea dwellers is actually a misnomer given to them by outside visitors of the sea kingdom, who often sold them as exotic pets. In fact, their "bunny ear" appendages are actually their antennae taking on the appearance of the various sea prisms scattered throughout their home.
Stormlion: Some Ilmerian survivors claim that enough magical lightning surged through the sea during its final days that there existed not a single drop of water without levin coursing through it. Even now, electricity remains buried in the sands, with several antlion species having learned to channel the former kingdom's power.
StormlionSentry: Some Ilmeran survivors claim that enough magical lightning surged through the sea during its final days that there existed not a single drop of water without levin coursing through it. Even now, electricity remains buried in the sands, with several antlion species having learned to channel the former kingdom's power.
//Town NPCs
AndroombaFriendly: Reverse-engineered Androombas that have been retrofitted to spread the Steampunker's solutions rather than clean dust and debris off of floors. They can be used to purify the world– or ruin it further, if one so desires.
Archmage: One of the world's foremost experts on magical theory, he is renowned for his skill with the arcane arts. In his days when he traveled with Yharim's entourage, he acted as the Godseeker's advisor, due to both his status and his distaste for actively participating in battle.
@@ -196,6 +196,7 @@ SkeletronPrime2.DisplayName: Skeletron Alpha
AlphaVice.DisplayName: Alpha Vice
AlphaCannon.DisplayName: Alpha Cannon
Stormlion.DisplayName: Stormlion
StormlionSentry.DisplayName: Stormlion Sentry
Sunskater.DisplayName: Sunskater
SuperDummyNPC.DisplayName: Super Dummy
WildBumblefuck.DisplayName: Draconic Swarmer
@@ -40,6 +40,7 @@ PodobooSpitUltima.DisplayName: Ultima Podoboo Spit
PrismBackCrystal.DisplayName: Prism-Back Shard
PufferExplosion.DisplayName: Explosion
SharkoonExplosion.DisplayName: Sharkoon Explosion
StormlionSentryBullet.DisplayName: Stormlion Sentry Bullet
StormMarkHostile.DisplayName: Mark
SulphuricAcidBubble.DisplayName: Acid Bubble
SulphuricAcidMist.DisplayName: Acid Mist
@@ -470,6 +470,4 @@ WitchDoctorChat: {
Jungle: I wonder how my relatives are doing, last time I checked on them they were too busy praising the... Sun, I think.
}
WizardChat: {
Hardmode: Space just got way too close for comfort.
}
WizardChat.Hardmode: Space just got way too close for comfort.
+329
View File
@@ -0,0 +1,329 @@
using System;
using System.IO;
using CalamityMod.BiomeManagers;
using CalamityMod.Dusts;
using CalamityMod.Items.Materials;
using CalamityMod.Items.Weapons.Summon;
using CalamityMod.Projectiles.Enemy;
using CalamityMod.Projectiles.Magic;
using CalamityMod.Projectiles.Rogue;
using CalamityMod.Projectiles.Summon;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Audio;
using Terraria.GameContent;
using Terraria.GameContent.Bestiary;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ModLoader.Utilities;
namespace CalamityMod.NPCs.SunkenSea
{
public class StormlionSentry : ModNPC
{
public ref float time => ref NPC.ai[0];
public ref float attackTimer => ref NPC.ai[1];
public ref float jitter => ref NPC.ai[2];
public ref float jitterRate => ref NPC.localAI[0];
public ref float headRot => ref NPC.localAI[1];
public ref float attackFeedback => ref NPC.localAI[2];
public bool canBeMoved => NPC.localAI[3] == 0;
public enum Mode
{
Idle,
Agressive,
Leaping,
Digging
}
public Mode AIState
{
get => (Mode)(int)NPC.ai[3];
set => NPC.ai[3] = (int)value;
}
public float fxFade = 1;
public float fxFadeInv => attackFeedback - 1;
public float targetRange = 830;
public int attackRate = 180;
public int digDir = 1;
public Vector2 headPosition;
public Vector2 attackPosition;
public override void SetStaticDefaults()
{
NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() { PortraitPositionXOverride = 20f };
NPCID.Sets.NPCBestiaryDrawOffset[Type] = value;
}
public override void SetDefaults()
{
NPC.width = 50;
NPC.height = 108;
NPC.lifeMax = 60;
NPC.damage = 15;
NPC.defense = 3;
NPC.knockBackResist = 0f;
NPC.HitSound = Effects.StormlionEffects.Hit;
NPC.DeathSound = Effects.StormlionEffects.Killed;
NPC.noGravity = true;
NPC.noTileCollide = true; // Custom tile collision
AIState = Mode.Idle;
attackFeedback = 1;
headRot = -MathHelper.PiOver2;
SpawnModBiomes = new int[1] { ModContent.GetInstance<SunkenSeaBiome>().Type };
//Banner = NPC.type;
//BannerItem = ModContent.ItemType<StormlionSentryBanner>();
}
public override void SendExtraAI(BinaryWriter writer)
{
writer.Write(NPC.localAI[0]);
writer.Write(NPC.localAI[1]);
writer.Write(NPC.localAI[2]);
writer.Write(NPC.localAI[3]);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
NPC.localAI[0] = reader.ReadSingle();
NPC.localAI[1] = reader.ReadSingle();
NPC.localAI[2] = reader.ReadSingle();
NPC.localAI[3] = reader.ReadSingle();
}
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
{
bestiaryEntry.Info.AddRange(
[
new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.StormlionSentry")
]);
}
public override void AI()
{
NPC.TargetClosest(false);
Player target = Main.player[NPC.target];
NPC.spriteDirection = NPC.direction;
bool npcFullyInTiles = Collision.SolidCollision(NPC.Center - Vector2.UnitY * 13, 15, 15);
bool npcOnTiles = Collision.SolidCollision(NPC.Center + Vector2.UnitY * 10, 15, 15);
bool targetInRange = Utils.Distance(target.Center, NPC.Center) <= targetRange && Collision.CanHit(headPosition, 1, 1, target.Center, 1, 1);
attackFeedback = MathHelper.Lerp(attackFeedback, 1, 0.025f);
fxFade = Utils.GetLerpValue(0, attackRate, attackTimer, true);
if (!npcOnTiles)
{
if (NPC.velocity.Y < 0)
NPC.velocity.Y *= 0.97f;
if (NPC.velocity.Y < 20)
NPC.velocity.Y += 0.5f;
NPC.velocity.X *= 0.97f;
}
if (!npcFullyInTiles && npcOnTiles && AIState != Mode.Digging)
{
NPC.localAI[3] = 5;
AIState = Mode.Digging;
}
if (AIState == Mode.Idle)
{
attackTimer = (int)MathHelper.Lerp(attackTimer, 0, 0.01f);
jitterRate = MathHelper.Lerp(jitterRate, 0.1f, 0.05f);
headRot = headRot.AngleLerp(-Vector2.UnitY.ToRotation(), 0.02f);
if (targetInRange && !canBeMoved)
AIState = Mode.Agressive;
if (Main.rand.NextBool(15) && time % 60 == 0)
{
jitterRate = 4.7f;
SoundEngine.PlaySound((Main.rand.NextBool() ? Effects.StormlionEffects.Idle1 : Effects.StormlionEffects.Idle2) with { Volume = 1f, Pitch = Main.rand.NextFloat(-0.2f, 0.1f) }, NPC.Center);
}
}
if (AIState == Mode.Agressive)
{
if (!targetInRange && attackTimer >= 0)
AIState = Mode.Idle;
if (attackTimer >= 0)
{
jitterRate = MathHelper.Lerp(jitterRate, 1f + 3f * Utils.GetLerpValue(0, attackRate, attackTimer), 0.035f);
headRot = headRot.AngleLerp(NPC.Center.DirectionTo(target.Center).ToRotation(), 0.035f);
}
else
headRot = headRot.AngleLerp(NPC.Center.DirectionTo(target.Center).ToRotation(), 0.01f);
if (attackTimer == attackRate)
{
SoundEngine.PlaySound(Effects.StormlionEffects.Attack with { Volume = 1f, Pitch = Main.rand.NextFloat(-0.1f, 0.1f) }, NPC.Center);
Projectile.NewProjectile(NPC.GetSource_FromThis(), attackPosition, (headRot.ToRotationVector2() * 12), ModContent.ProjectileType<StormlionSentryBullet>(), NPC.damage, 0f, Main.myPlayer);
for (int i = 0; i <= 12; i++)
{
float variance = Main.rand.NextFloat(-0.6f, 0.6f);
int dustStyle = Effects.StormlionEffects.EnergyDust;
Dust dust2 = Dust.NewDustPerfect(attackPosition, dustStyle);
dust2.scale = Main.rand.NextFloat(1.5f, 1.7f) - Math.Abs(variance);
dust2.velocity = (headRot.ToRotationVector2() * 15).RotatedBy(variance) * Main.rand.NextFloat(0.3f, 1f) * (1 - Math.Abs(variance));
dust2.noGravity = true;
dust2.color = Effects.StormlionEffects.EnergyColor;
}
attackFeedback = 2;
attackTimer = -60;
jitterRate = 0;
NPC.ForceNetUpdate();
}
attackTimer++;
}
if (AIState == Mode.Digging)
{
if (time % 10 == 0)
{
NPC.velocity = Vector2.Zero;
headRot = MathHelper.ToRadians(4 * digDir) - MathHelper.PiOver2;
SoundEngine.PlaySound(SoundID.WormDig with { Volume = 1f, Pitch = Main.rand.NextFloat(-0.1f, 0.1f) }, NPC.Center);
NPC.Center += Vector2.UnitY * 2;
digDir *= -1;
}
if (npcFullyInTiles)
AIState = Mode.Idle;
}
if (!canBeMoved)
NPC.velocity = Vector2.Zero;
bool dancing = false; // They will dance if a "music projectile" is on screen of if the player is using an instrument (except drums because that would be annoying to make work)
for (int x = 0; x < Main.maxProjectiles; x++)
{
if (Main.mouseLeft && (target.HeldItem.type == ItemID.Bell || target.HeldItem.type == ItemID.CarbonGuitar || target.HeldItem.type == ItemID.IvyGuitar || target.HeldItem.type == ItemID.Harp || target.HeldItem.type == ItemID.TheAxe))
{
dancing = true;
}
Projectile projectile = Main.projectile[x];
if (!dancing && projectile.active && (projectile.type == ModContent.ProjectileType<AnahitasArpeggioNote>() || projectile.type == ModContent.ProjectileType<MelterNote1>() || projectile.type == ModContent.ProjectileType<MelterNote2>() || projectile.type == ModContent.ProjectileType<AmphibiansGuitarHoldout>() || projectile.type == ProjectileID.SparkleGuitar || projectile.type == ProjectileID.EighthNote || projectile.type == ProjectileID.QuarterNote || projectile.type == ProjectileID.TiedEighthNote))
{
dancing = true;
}
}
if (dancing)
{
float sine = (float)Math.Sin(Main.GlobalTimeWrappedHourly * 14.37f / MathHelper.Pi);
if (Main.zenithWorld)
{
if (time % 2 == 0)
{
SoundEngine.PlaySound(Effects.StormlionEffects.Attack with { Volume = 0.2f, Pitch = 0.4f * sine, MaxInstances = 30 }, NPC.Center);
Projectile proj = Projectile.NewProjectileDirect(NPC.GetSource_FromThis(), attackPosition, (headRot.ToRotationVector2() * 6), ModContent.ProjectileType<StormlionSentryBullet>(), NPC.damage * target.statLifeMax2, 0f, Main.myPlayer);
proj.friendly = true;
proj.hostile = false;
}
fxFade = 1;
attackTimer = attackRate * 0.9f;
}
else
attackTimer = 0;
jitterRate = 1;
NPC.dontTakeDamage = true;
headRot = MathHelper.ToRadians(100 * sine) - MathHelper.PiOver2;
AIState = Mode.Idle;
}
else
NPC.dontTakeDamage = false;
float orbSine = (float)Math.Sin(time * 0.575f / MathHelper.Pi) * Utils.GetLerpValue(attackRate * 1.1f, 0, attackTimer);
headPosition = NPC.Center - (Vector2.UnitY * 27).RotatedBy(NPC.rotation) + headRot.ToRotationVector2() * 12 + NPC.velocity;
attackPosition = headPosition + headRot.ToRotationVector2() * (25 + 8 * orbSine);
NPC.rotation = Utils.AngleLerp(0, headRot + MathHelper.PiOver2, 0.35f);
if (fxFade > 0)
{
Lighting.AddLight(attackPosition, Effects.StormlionEffects.EnergyColor.ToVector3() * 0.7f * fxFade);
}
time++;
jitter += jitterRate;
}
public override void HitEffect(NPC.HitInfo hit)
{
for (int k = 0; k < 5; k++)
{
int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, Effects.StormlionEffects.FleshDust, hit.HitDirection, -1f, 0, Effects.StormlionEffects.FleshColor, Main.rand.NextFloat(0.7f, 1.1f));
}
if (NPC.life <= 0)
{
for (int k = 0; k < 35; k++)
{
bool type = !Main.rand.NextBool(3);
int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, type ? Effects.StormlionEffects.EnergyDust : Effects.StormlionEffects.FleshDust, hit.HitDirection, -1f, 0, type ? Effects.StormlionEffects.EnergyColor : Effects.StormlionEffects.FleshColor, Main.rand.NextFloat(0.7f, 1.1f));
}
// Gores go here once they're done
/*
if (!Main.dedServ)
{
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("StormlionSentry").Type, 1f);
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("StormlionSentry2").Type, 1f);
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("StormlionSentry3").Type, 1f);
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("StormlionSentry4").Type, 1f);
}
*/
}
}
public override bool CanHitPlayer(Player target, ref int cooldownSlot)
{
return false;
}
public override float SpawnChance(NPCSpawnInfo spawnInfo)
{
if (spawnInfo.Player.Calamity().ZoneTimelessShores && !spawnInfo.Water && !spawnInfo.Player.Calamity().clamity)
{
return SpawnCondition.Cavern.Chance * 0.5f;
}
return 0f;
}
public override void ModifyNPCLoot(NPCLoot npcLoot)
{
npcLoot.Add(ModContent.ItemType<StormlionMandible>());
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
{
Texture2D tex = TextureAssets.Npc[Type].Value;
if (NPC.IsABestiaryIconDummy)
{
spriteBatch.Draw(tex, NPC.Center - screenPos, null, drawColor, NPC.rotation, tex.Size() / 2f, NPC.scale, NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0f);
return false;
}
if (time == 0)
return false;
Texture2D body = ModContent.Request<Texture2D>("CalamityMod/NPCs/SunkenSea/StormlionSentryBody").Value;
Texture2D head = ModContent.Request<Texture2D>("CalamityMod/NPCs/SunkenSea/StormlionSentryHead").Value;
Texture2D mandible = ModContent.Request<Texture2D>("CalamityMod/NPCs/SunkenSea/StormlionSentryMandible").Value;
Texture2D attack = ModContent.Request<Texture2D>("CalamityMod/Particles/BloomCircle").Value;
spriteBatch.Draw(body, NPC.Center - screenPos, null, drawColor, NPC.rotation, body.Size() / 2f, NPC.scale, SpriteEffects.None, 0f);
spriteBatch.Draw(head, headPosition - screenPos, null, drawColor, headRot + MathHelper.PiOver2, head.Size() / 2f, NPC.scale, SpriteEffects.None, 0f);
for (int i = -1; i <= 1; i += 2)
{
float sine = (float)Math.Sin(jitter * 0.575f / MathHelper.Pi) * Utils.GetLerpValue(4.8f, 0, jitterRate);
Vector2 madiblePos = headPosition + (Vector2.UnitX * 10 * i).RotatedBy(headRot + MathHelper.PiOver2);
Vector2 madibleOrigin = (new Vector2(i == 1 ? 0 : mandible.Width, mandible.Height));
float mandibleRot = MathHelper.ToRadians(5 * i) + MathHelper.Lerp(MathHelper.ToRadians(20) * sine * i, MathHelper.ToRadians(50) * i * fxFadeInv, fxFadeInv);
spriteBatch.Draw(mandible, madiblePos - screenPos, null, drawColor, headRot + mandibleRot + MathHelper.PiOver2, madibleOrigin, NPC.scale, i == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0f);
}
if (attackTimer > 0)
{
float fade = (float)Math.Pow(fxFade, 2);
for (int i = 0; i < 3; i++)
spriteBatch.Draw(attack, attackPosition - screenPos, null, Color.Lerp(Effects.StormlionEffects.EnergyColor, Color.White, i * 0.3f) with { A = 0 } * fade, headRot, attack.Size() / 2f, (NPC.scale * 0.3f - (i * 0.08f)) * fade * Main.rand.NextFloat(0.8f, 1.1f), SpriteEffects.None, 0f);
}
return false;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

@@ -0,0 +1,64 @@
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Dusts;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Enemy
{
public class StormlionSentryBullet : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Enemy";
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public override void SetDefaults()
{
Projectile.width = 8;
Projectile.height = 8;
Projectile.hostile = true;
Projectile.timeLeft = 160;
Projectile.extraUpdates = 6;
Projectile.tileCollide = true;
Projectile.penetrate = -1;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = -1;
}
public override void AI()
{
Lighting.AddLight(Projectile.Center, Effects.StormlionEffects.EnergyColor.ToVector3() * 0.3f);
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
if (Main.rand.NextBool())
{
int dustStyle = ModContent.DustType<LightDust>();
Dust dust2 = Dust.NewDustPerfect(Projectile.Center, dustStyle);
dust2.scale = Main.rand.NextFloat(0.4f, 0.7f);
dust2.velocity = Projectile.velocity * Main.rand.NextFloat(0.6f, 1f);
dust2.noGravity = true;
dust2.color = Effects.StormlionEffects.EnergyColor;
}
}
public override void OnHitPlayer(Player target, Player.HurtInfo info)
{
if (info.Damage <= 0)
return;
target.AddBuff(ModContent.BuffType<StaticDischarge>(), 60);
}
public override void OnKill(int timeLeft)
{
}
public override bool PreDraw(ref Color lightColor)
{
Asset<Texture2D> orb = ModContent.Request<Texture2D>("CalamityMod/Particles/BloomCircle");
for (int i = 0; i < 4; i++)
{
Vector2 scale = Projectile.scale * new Vector2(0.2f, 1.4f) * (0.05f + i * 0.02f) * 4;
Main.EntitySpriteDraw(orb.Value, Projectile.Center - Main.screenPosition, null, Effects.StormlionEffects.EnergyColor with { A = 0 }, Projectile.rotation, orb.Size() * 0.5f, scale, SpriteEffects.None);
}
return false;
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.