Revert "Ghost Bell changes"

This reverts commit ac94f5a91cef1a5c7b5ea4e7e5eadcd93f99cfbb.
This commit is contained in:
GinYuH authored and Cameron Ewell committed 2025-05-22 15:43:23 -04:00
1 parent 9e2ab28360
commit 712176d752
8 files changed
+30 -213

No files matched your search

+29 -212
View File
@@ -1,16 +1,12 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO;
using CalamityMod.BiomeManagers;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Enums;
using CalamityMod.Items.Accessories;
using CalamityMod.Items.Placeables.Banners;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.DataStructures;
using Terraria.GameContent;
using Terraria.GameContent.Bestiary;
using Terraria.GameContent.ItemDropRules;
@@ -20,58 +16,23 @@ using Terraria.ModLoader.Utilities;
namespace CalamityMod.NPCs.SunkenSea
{
public class GhostBell : SunkenSeaNPC
public class GhostBell : ModNPC
{
public enum JellyColor
{
Blue = 0,
Pink = 1,
Green = 2
}
public bool hasBeenHit = false;
public static Asset<Texture2D> PinkTexture;
public static Asset<Texture2D> GreenTexture;
public static Asset<Texture2D> GlowTexture;
public static Asset<Texture2D> PinkGlowTexture;
public static Asset<Texture2D> GreenGlowTexture;
public ref float Variant => ref NPC.ai[1];
public ref float Role => ref NPC.ai[2];
public ref float Aggro => ref NPC.ai[3];
protected override List<int> PreyIDs => new List<int>()
{
ModContent.NPCType<PolypPanasea>(),
ModContent.NPCType<PrismaticGuppy>(),
ModContent.NPCType<SeaMinnow>(),
ModContent.NPCType<SeaMinnowGold>(),
ModContent.NPCType<AlphaSeaMinnow>(),
ModContent.NPCType<AlphaSeaMinnowGold>(),
};
protected override List<int> PredatorIDs => new List<int>();
protected override SunkenSeaBiomeFlags BiomeDesignation => SunkenSeaBiomeFlags.GleamingBurrows | SunkenSeaBiomeFlags.PolypForest;
public override void SetStaticDefaults()
{
Main.npcFrameCount[Type] = 1;
Main.npcFrameCount[Type] = 6;
if (!Main.dedServ)
{
PinkTexture = ModContent.Request<Texture2D>(Texture + "Pink");
GreenTexture = ModContent.Request<Texture2D>(Texture + "Green");
GlowTexture = ModContent.Request<Texture2D>(Texture + "Glow");
PinkGlowTexture = ModContent.Request<Texture2D>(Texture + "PinkGlow");
GreenGlowTexture = ModContent.Request<Texture2D>(Texture + "GreenGlow");
GlowTexture = ModContent.Request<Texture2D>(Texture + "Glow", AssetRequestMode.AsyncLoad);
}
base.SetStaticDefaults();
}
public override void SetDefaults()
{
base.SetDefaults();
NPC.noGravity = true;
NPC.aiStyle = -1;
AIType = -1;
@@ -109,80 +70,23 @@ namespace CalamityMod.NPCs.SunkenSea
public override void SendExtraAI(BinaryWriter writer)
{
writer.Write(NPC.chaseable);
writer.Write(hasBeenHit);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
NPC.chaseable = reader.ReadBoolean();
}
public override void OnSpawn(IEntitySource source)
{
Variant = Main.rand.Next(0, 3);
pathfinding = new PathfindingManager(NPC)
{
Acceleration = 0.1f,
MaxSpeed = 3f,
};
if (Role == 0)
{
NPC.TargetClosest();
int jellyAmt;
// Large swarm in polyp forest ft babies, otherwise just a few
if (Main.player[NPC.target].Calamity().ZonePolypForest)
{
jellyAmt = Main.rand.Next(3, 6);
// Spawn a bunch of babies too
for (int i = 0; i < Main.rand.Next(4, 8); i++)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
NPC.NewNPC(NPC.GetSource_FromThis(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType<BabyGhostBell>());
}
}
}
else
{
jellyAmt = Main.rand.Next(1, 3);
}
// Spawn more Ghost Bells
// Newly spawned Ghost Bells have their Role set to 1 as to not spawn further Ghost Bells
for (int i = 0; i < jellyAmt; i++)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
NPC.NewNPC(NPC.GetSource_FromThis(), (int)NPC.Center.X, (int)NPC.Center.Y, Type, ai2: 1);
}
}
}
hasBeenHit = reader.ReadBoolean();
}
public override void AI()
{
// Lite
Color lightColor = Color.LightBlue;
switch (Variant)
Lighting.AddLight(NPC.Center, 0f, (255 - NPC.alpha) * 1.5f / 255f, (255 - NPC.alpha) * 1.5f / 255f);
if (NPC.justHit)
{
case (int)JellyColor.Pink:
lightColor = Color.Pink;
break;
case (int)JellyColor.Green:
lightColor = Color.LightGreen;
break;
}
Lighting.AddLight(NPC.Center, (lightColor.R - NPC.alpha) * 1f / 255f, (lightColor.G - NPC.alpha) * 1f / 255f, (lightColor.B - NPC.alpha) * 1f / 255f);
NPC.chaseable = Aggro == 1;
// De-aggro
if (Aggro == 1)
{
if (Main.player[NPC.target] != null)
{
if (Main.player[NPC.target].dead)
{
Aggro = 0;
}
}
hasBeenHit = true;
}
NPC.chaseable = hasBeenHit;
if (NPC.localAI[0] == 0f)
{
NPC.localAI[0] = 1f;
@@ -192,35 +96,25 @@ namespace CalamityMod.NPCs.SunkenSea
if (NPC.wet)
{
NPC.noGravity = true;
bool hasTarget = CurrentPrey != null || (Aggro == 1 && Main.player[NPC.target] != null);
if (hasTarget)
if (NPC.localAI[2] > 0f)
{
Entity target = CurrentPrey != null ? CurrentPrey : Main.player[NPC.target];
pathfinding.DoPathfinding(new PathfindingParameters(NPC.Center, target.Center, SunkenSeaTileValidity));
NPC.localAI[2] -= 1f;
}
else
if (NPC.localAI[2] <= 0f)
{
if (NPC.localAI[2] > 0f)
if (NPC.velocity.Y == 0f)
{
NPC.localAI[2] -= 1f;
NPC.localAI[1] += 1f;
}
if (NPC.localAI[2] <= 0f)
else
{
if (NPC.velocity.Y == 0f)
{
NPC.localAI[1] += 1f;
}
else
{
NPC.localAI[1] = 0f;
}
NPC.velocity.Y += 0.1f;
if (NPC.velocity.Y > 3f || NPC.localAI[1] >= 6f)
{
NPC.velocity.Y = -3f;
}
NPC.localAI[1] = 0f;
}
NPC.velocity.Y += 0.1f;
if (NPC.velocity.Y > 3f || NPC.localAI[1] >= 6f)
{
NPC.velocity.Y = -3f;
}
NPC.velocity.X *= 0.95f;
}
}
else
@@ -230,29 +124,6 @@ namespace CalamityMod.NPCs.SunkenSea
NPC.localAI[2] = 75f;
NPC.netUpdate = true;
}
float SAImovement = 0.05f;
for (int k = 0; k < Main.maxNPCs; k++)
{
NPC otherJelly = Main.npc[k];
// Short circuits to make the loop as fast as possible
if (!otherJelly.active || k == NPC.whoAmI || (otherJelly.type != ModContent.NPCType<GhostBell>()))
continue;
float taxicabDist = Math.Abs(NPC.position.X - otherJelly.position.X) + Math.Abs(NPC.position.Y - otherJelly.position.Y);
if (taxicabDist < NPC.width * 2f)
{
if (NPC.position.X < otherJelly.position.X)
NPC.velocity.X -= SAImovement;
else
NPC.velocity.X += SAImovement;
if (NPC.position.Y < otherJelly.position.Y)
NPC.velocity.Y -= SAImovement;
else
NPC.velocity.Y += SAImovement;
}
}
}
public override void FindFrame(int frameHeight)
@@ -267,14 +138,12 @@ namespace CalamityMod.NPCs.SunkenSea
{
if (spawnInfo.Player.Calamity().ZoneSunkenSea && spawnInfo.Water && !spawnInfo.Player.Calamity().clamity)
{
// Drastically smaller in the Polyp Forest due to a bunch spawning at once
float multiplier = spawnInfo.Player.Calamity().ZonePolypForest ? 0.1f : 0.9f;
return SpawnCondition.CaveJellyfish.Chance * multiplier;
return SpawnCondition.CaveJellyfish.Chance * 0.9f;
}
return 0f;
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
{
SpriteEffects spriteEffects = SpriteEffects.None;
if (NPC.spriteDirection == 1)
@@ -284,32 +153,11 @@ namespace CalamityMod.NPCs.SunkenSea
Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y);
Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[Type].Value.Width / 2), (float)(TextureAssets.Npc[Type].Value.Height / Main.npcFrameCount[Type] / 2));
Vector2 vector = center - screenPos;
vector -= new Vector2((float)GlowTexture.Value.Width, (float)(GlowTexture.Value.Height / Main.npcFrameCount[Type])) / 2f;
vector -= new Vector2((float)GlowTexture.Value.Width, (float)(GlowTexture.Value.Height / Main.npcFrameCount[Type])) * 1f / 2f;
vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY);
Texture2D tex = TextureAssets.Npc[NPC.type].Value;
Texture2D glowTex = GlowTexture.Value;
Color color = Color.LightBlue;
switch (Variant)
{
case (int)JellyColor.Pink:
tex = PinkTexture.Value;
glowTex = PinkGlowTexture.Value;
color = Color.LightPink;
break;
case (int)JellyColor.Green:
tex = GreenTexture.Value;
glowTex = GreenGlowTexture.Value;
color = Color.SeaGreen;
break;
}
color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(color);
Main.spriteBatch.Draw(tex, vector, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f);
Main.spriteBatch.Draw(glowTex, vector, NPC.frame, color, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f);
return false;
Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightBlue);
Main.spriteBatch.Draw(GlowTexture.Value, vector,
new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f);
}
// Can only hit the target if they're touching the tentacles
@@ -351,36 +199,5 @@ namespace CalamityMod.NPCs.SunkenSea
LeadingConditionRule postDS = npcLoot.DefineConditionalDropSet(DropHelper.PostDS());
postDS.Add(ModContent.ItemType<VoltaicJelly>(), 5);
}
public override bool CanBeHitByNPC(NPC attacker) => PredatorIDs.Contains(attacker.type);
public override void OnHitByProjectile(Projectile projectile, NPC.HitInfo hit, int damageDone)
{
if (projectile.friendly)
{
if (projectile.owner != -1)
{
BecomeHostile(projectile.owner);
}
}
}
public override void OnHitByItem(Player player, Item item, NPC.HitInfo hit, int damageDone)
{
BecomeHostile(player.whoAmI);
}
public void BecomeHostile(int player)
{
NPC.target = player;
Aggro = 1;
foreach (NPC n in Main.ActiveNPCs)
{
if (n.type == Type && n.whoAmI != NPC.whoAmI)
{
n.ai[3] = 1;
n.target = player;
}
}
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 477 B

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 475 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 457 B

+1 -1
View File
@@ -206,7 +206,6 @@ namespace CalamityMod.NPCs.SunkenSea
{
return;
}
NPC.TargetClosest();
// Red/Green in reefs, Green/Blue elsewhere
if (Main.player[NPC.target].Calamity().ZoneRadiantReefs)
{
@@ -216,6 +215,7 @@ namespace CalamityMod.NPCs.SunkenSea
{
CurrentColor = Main.rand.Next(0, 2);
}
NPC.TargetClosest();
// 1 in 30 chance for a rare fish variant (rfv)
if (Main.rand.NextBool(30))
{