requested Lost Shoal changes

This commit is contained in:
GinYuH authored and Cameron Ewell committed 2024-07-30 18:27:16 -04:00
1 parent b096080721
commit 4bf7ecdd03
3 files changed
+88 -26

No files matched your search

+37 -26
View File
@@ -196,39 +196,30 @@ namespace CalamityMod.NPCs.SunkenSea
break;
}
Lighting.AddLight(NPC.Center, glowColor.R * intensity, glowColor.G * intensity, glowColor.B * intensity);
NPC.position += NPC.netOffset;
Color color = Lighting.GetColor((int)NPC.Center.X / 16, (int)NPC.Center.Y / 16);
if (color.R > 20 || color.B > 20 || color.G > 20)
{
int colorVal = color.R;
if (color.G > colorVal)
{
colorVal = color.G;
}
if (color.B > colorVal)
{
colorVal = color.B;
}
colorVal /= 30;
if (Main.rand.Next(300) < colorVal)
{
//int golddust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.SilverCoin, 0f, 0f, 254, new Color(255, 255, 0), 0.5f);
//Main.dust[golddust].velocity *= 0f;
}
}
// Sprinkle down ash particles
if (Main.rand.NextBool(120))
{
Particle nanoDust = new SquareParticle(NPC.Center, new Vector2(Main.rand.NextFloat(-1, 2), 4), false, 300, Main.rand.NextFloat(0.65f, 0.9f), Color.White);
GeneralParticleHandler.SpawnParticle(nanoDust);
Color ashColor = new(40, 48, 41);
switch (Variant)
{
case (int)ShoalColor.Blue:
ashColor = new(44, 63, 66);
break;
case (int)ShoalColor.Red:
ashColor = new(79, 41, 42);
break;
}
Particle ash = new SquareAshParticle(NPC.Center, new Vector2(0, 4), 150, Main.rand.NextFloat(0.85f, 1f), ashColor);
GeneralParticleHandler.SpawnParticle(ash);
}
NPC.position -= NPC.netOffset;
}
public void LeaderMovement()
{
// This is just usual swimmer ai with some modifications
NPC.spriteDirection = (NPC.direction > 0) ? -1 : 1;
NPC.velocity.X = NPC.velocity.X - (float)NPC.direction * 0.25f;
NPC.velocity.X = NPC.velocity.X - (float)NPC.direction * 0.2f;
NPC.noGravity = true;
if (NPC.collideX)
{
@@ -253,8 +244,8 @@ namespace CalamityMod.NPCs.SunkenSea
}
}
// No target behavior
NPC.velocity.X += (float)NPC.direction * 0.1f;
if (NPC.velocity.X < -2.5f || NPC.velocity.X > 2.5f)
NPC.velocity.X += (float)NPC.direction * 0.05f;
if (NPC.velocity.X < -2f || NPC.velocity.X > 2f)
{
NPC.velocity.X *= 0.95f;
}
@@ -318,12 +309,32 @@ namespace CalamityMod.NPCs.SunkenSea
Gore.NewGore(NPC.GetSource_FromAI(), NPC.position, new Vector2(Main.rand.Next(-10, 11) * 0.2f, Main.rand.Next(-10, 11) * 0.2f), goreType, 0.2f);
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
{
SpriteEffects spriteEffects = SpriteEffects.None;
if (NPC.spriteDirection == 1)
spriteEffects = SpriteEffects.FlipHorizontally;
// Spooky glowey aura effect
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.SeaGreen;
switch (Variant)
{
case (int)ShoalColor.Blue:
glowColor = Color.Cyan;
break;
case (int)ShoalColor.Red:
glowColor = Color.Pink;
break;
}
spriteBatch.Draw(bloom, NPC.position - Main.screenPosition + new Vector2(20, 5), null, glowColor * 0.4f, 0f, bloom.Size() / 2f, 0.5f, SpriteEffects.None, 0);
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
// Regular stuff for drawing the actual fish and its afterimages
Texture2D texture = TextureAssets.Npc[NPC.type].Value;
switch (Variant)
{
+5
View File
@@ -68,18 +68,22 @@ namespace CalamityMod.NPCs.SunkenSea
public override void AI()
{
Tile vine = Main.tile[(int)NPC.position.X / 16, (int)NPC.position.Y / 16];
// Set newAI[0] to 1 if the Pearlpod is inside of a vine
if (vine.TileType == ModContent.TileType<DepthVines>() && !NPC.justHit)
{
NPC.Calamity().newAI[0] = 1;
}
// Otherwise reset eating-related variables
else
{
NPC.Calamity().newAI[1] = 0;
NPC.Calamity().newAI[0] = 0;
}
// Eating behavior
if (NPC.Calamity().newAI[0] == 1)
{
NPC.velocity.X *= 0.1f;
// Play a crunch sound and spawn some grass dust randomly
if (Main.rand.NextBool(20))
{
SoundEngine.PlaySound(SoundID.Item2 with { Volume = 0.4f, Pitch = 1.2f }, NPC.Center);
@@ -89,6 +93,7 @@ namespace CalamityMod.NPCs.SunkenSea
}
NPC.Calamity().newAI[1]++;
}
// After munching 10 times, the vine is broken and the Pearlpod continues about its day
if (NPC.Calamity().newAI[1] == 10)
{
if (vine.TileType == ModContent.TileType<DepthVines>())
+46
View File
@@ -0,0 +1,46 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class SquareAshParticle : Particle
{
public Color InitialColor;
public override bool SetLifetime => true;
public override bool UseCustomDraw => true;
public override bool UseAdditiveBlend => false;
public override string Texture => "CalamityMod/Particles/Square";
public SquareAshParticle(Vector2 relativePosition, Vector2 velocity, int lifetime, float scale, Color color)
{
Position = relativePosition;
Velocity = velocity;
Scale = scale;
Lifetime = lifetime;
Color = InitialColor = color;
}
public override void Update()
{
// Shrink to nothing near end of lifetime
if (Time > Lifetime - 60)
{
Scale *= 0.95f;
}
Color = Color.Lerp(InitialColor, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D));
Rotation += Velocity.X > 0 ? 0.8f : -0.8f;
}
public override void CustomDraw(SpriteBatch spriteBatch)
{
Vector2 scale = new Vector2(0.8f, 1.2f) * Scale;
Texture2D texture = ModContent.Request<Texture2D>(Texture).Value;
spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, Rotation, texture.Size() * 0.5f, scale, 0, 0f);
}
}
}