chum chain

This commit is contained in:
GinYuH authored and Cameron Ewell committed 2024-07-30 18:27:16 -04:00
1 parent 554f5f678a
commit 583f7f38c9
2 files changed
+94 -3

No files matched your search

+34
View File
@@ -2,6 +2,7 @@
using CalamityMod.Particles;
using CalamityMod.Items.Placeables.Banners;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Collections.Generic;
using Terraria;
using Terraria.Audio;
@@ -26,6 +27,7 @@ namespace CalamityMod.NPCs.SunkenSea
AIType = -1;
NPC.HitSound = SoundID.NPCHit1;
NPC.DeathSound = SoundID.NPCDeath1;
NPC.knockBackResist = 0f;
//Banner = NPC.type;
//BannerItem = ModContent.ItemType<AlphaSeaMinnowBanner>();
NPC.chaseable = false;
@@ -87,6 +89,13 @@ namespace CalamityMod.NPCs.SunkenSea
Main.npc[head].localAI[0] = -MathHelper.PiOver4;
}
}
else
{
if (NPC.ai[0] > 0)
{
NPC.ai[0]--;
}
}
}
NPC spawnedHead = Main.npc[(int)NPC.ai[2]];
// If the head has already been spawned but there is no more head (no head?) start a countdown, once the countdown reaches full, the head respawns
@@ -105,6 +114,10 @@ namespace CalamityMod.NPCs.SunkenSea
}
NPC.ai[3]++;
}
if (NPC.ai[0] > 0)
{
NPC.ai[0]--;
}
}
// Keep the bones alive
for (int i = 0; i < bones.Count; i++)
@@ -129,5 +142,26 @@ namespace CalamityMod.NPCs.SunkenSea
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, hit.HitDirection, -1f, 0, default, 1f);
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
{
// Spooky glowey aura effect
if (NPC.ai[0] > 0)
{
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
Texture2D bloom = ModContent.Request<Texture2D>("CalamityMod/Particles/BloomCircle").Value;
Color glowColor = Color.Red;
int xOffset = NPC.spriteDirection == 1 ? 16 : 22;
spriteBatch.Draw(bloom, NPC.position - Main.screenPosition + new Vector2(xOffset, 28), null, glowColor * (NPC.ai[0] / 120), 0f, bloom.Size() / 2f, 1f, SpriteEffects.None, 0);
foreach (ChumBone bone in bones)
{
spriteBatch.Draw(bloom, bone.Position - Main.screenPosition, null, glowColor * (NPC.ai[0] / 210), 0f, bloom.Size() / 2f, 0.4f * bone.Scale, SpriteEffects.None, 0);
}
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
}
return true;
}
}
}
+60 -3
View File
@@ -1,5 +1,8 @@
using CalamityMod.BiomeManagers;
using System.Collections.Generic;
using CalamityMod.BiomeManagers;
using CalamityMod.DataStructures;
using CalamityMod.Items.Placeables.Banners;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
@@ -14,6 +17,7 @@ namespace CalamityMod.NPCs.SunkenSea
public class HauntedChum : ModNPC
{
public static Texture2D jawTexture;
public List<VerletSimulatedSegment> Segments;
public override void SetStaticDefaults()
{
this.HideFromBestiary();
@@ -28,6 +32,7 @@ namespace CalamityMod.NPCs.SunkenSea
NPC.height = 50;
NPC.defense = 5;
NPC.lifeMax = 60;
NPC.damage = 20;
NPC.aiStyle = -1;
NPC.alpha = 255;
AIType = -1;
@@ -40,13 +45,25 @@ namespace CalamityMod.NPCs.SunkenSea
public override void AI()
{
int aggroRange = 800;
int aggroRange = 600;
if (NPC.direction == 0)
{
NPC.TargetClosest();
}
Player target = Main.player[NPC.target];
NPC body = Main.npc[(int)NPC.ai[3]];
if (Segments == null || Segments.Count < 10)
{
Segments = new List<VerletSimulatedSegment>(10);
for (int i = 0; i < 10; i++)
{
VerletSimulatedSegment segment = new VerletSimulatedSegment(body.Center + Vector2.UnitY * i * 10);
Segments.Add(segment);
}
Segments[0].locked = true;
Segments[Segments.Count - 1].locked = true;
}
if (body == null || !body.active || body.type != ModContent.NPCType<FesteringRemains>())
{
NPC.StrikeInstantKill();
@@ -152,8 +169,20 @@ namespace CalamityMod.NPCs.SunkenSea
}
for (int i = 0; i < 2; i++)
{
Dust.NewDust(new Vector2(NPC.Center.X - NPC.width / 2.4f * NPC.spriteDirection, NPC.position.Y + NPC.height / 4), 0, NPC.height / 2, DustID.Blood, -NPC.spriteDirection * 5, Main.rand.NextFloat(-3, 3), Scale: Main.rand.NextFloat(0.8f, 1.2f));
int dustPos = NPC.spriteDirection == 1 ? 0 : 10;
Dust.NewDust(new Vector2(NPC.Center.X + dustPos, NPC.position.Y + NPC.height / 4), 0, NPC.height / 2, DustID.Blood, -NPC.spriteDirection * Main.rand.NextFloat(4f, 5f), Main.rand.NextFloat(-3, 3), Scale: Main.rand.NextFloat(0.6f, 1f));
}
Segments[0].oldPosition = Segments[0].position;
Segments[0].position = body.Center + new Vector2(body.direction * 10, 8);
Segments[Segments.Count - 1].oldPosition = Segments[Segments.Count - 1].position;
Segments[Segments.Count - 1].position = body.active ? NPC.Center : body.Center;
Segments = VerletSimulatedSegment.SimpleSimulation(Segments, 10, loops: 100, gravity: 0.3f);
NPC.netUpdate = true;
NPC.netSpam = 0;
}
public override void HitEffect(NPC.HitInfo hit)
@@ -175,6 +204,34 @@ namespace CalamityMod.NPCs.SunkenSea
if (NPC.spriteDirection == 1)
spriteEffects = SpriteEffects.FlipHorizontally;
NPC body = Main.npc[(int)NPC.ai[3]];
// Draw a physiques chain
if (body != null && body.active && body.type == ModContent.NPCType<FesteringRemains>())
{
if (Segments == null || Segments.Count <= 0)
{
return true;
}
for (int i = 0; i < Segments.Count - 1; i++)
{
VerletSimulatedSegment seg = Segments[i];
float dist = i > 0 ? Vector2.Distance(seg.position, Segments[i - 1].position) : 0;
if (dist <= 2)
dist = 2;
dist += 2;
if (i == Segments.Count - 1)
{
dist = Vector2.Distance(seg.position, body.Center) + 2;
}
float rot = 0f;
if (i > 0)
rot = seg.position.DirectionTo(Segments[i - 1].position).ToRotation();
SpriteEffects dir = NPC.Center.X > body.Center.X ? SpriteEffects.FlipVertically : SpriteEffects.None;
Texture2D bone = i < Segments.Count / 2 ? ModContent.Request<Texture2D>(ChumBone.Texture2).Value : ModContent.Request<Texture2D>("CalamityMod/Particles/ChumBone1").Value;
Main.EntitySpriteDraw(bone, seg.position - Main.screenPosition, null, Lighting.GetColor((int)(seg.position.X / 16), (int)(seg.position.Y / 16)) * NPC.Opacity, rot, bone.Size() / 2, 1f, dir, 0);
}
}
// Spooky glowey aura effect
if (NPC.ai[0] == 2 && NPC.ai[1] < 50)
{