1 - Re-added Blinded Angler

2 - Reverted Sand Prowler to Sea Serpent

The mod now compiles, have not tested everything at runtime
This commit is contained in:
CongratsIsTrash committed 2025-12-15 18:52:06 -05:00
1 parent a697498589
commit f035ae17a6
56 files changed
+1080 -1638

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 642 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 337 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 440 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 554 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 867 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 872 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 650 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 585 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 747 B

-23
View File
@@ -1,23 +0,0 @@
using CalamityMod.NPCs.SunkenSea;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Critters
{
public class SeaFloatyItem : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Misc";
public override void SetStaticDefaults()
{
Item.ResearchUnlockCount = 5;
}
public override void SetDefaults()
{
Item.DefaultToCapturedCritter(ModContent.NPCType<SeaFloaty>());
Item.value = Item.sellPrice(gold: 3); // These things are actually painful to catch, they can get a 300% value boost
Item.rare = ItemRarityID.Green;
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 344 B

-24
View File
@@ -1,24 +0,0 @@
using CalamityMod.NPCs.SunkenSea;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Critters
{
public class SeaMinnowGoldItem : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Misc";
public override void SetStaticDefaults()
{
Item.ResearchUnlockCount = 5;
}
public override void SetDefaults()
{
Item.DefaultToCapturedCritter(ModContent.NPCType<SeaMinnowGold>());
Item.bait = 50;
Item.value = Item.sellPrice(gold: 10);
Item.rare = ItemRarityID.Green;
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 309 B

@@ -0,0 +1,7 @@
namespace CalamityMod.Items.Placeables.Banners
{
public class BlindedAnglerBanner : BaseBanner
{
public override int BannerTileStyle => 104;
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 348 B

@@ -1,7 +0,0 @@
namespace CalamityMod.Items.Placeables.Banners
{
public class PodobooKoiBanner : BaseBanner
{
public override int BannerTileStyle => 143;
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 418 B

@@ -1,10 +0,0 @@
using Terraria.ModLoader;
namespace CalamityMod.Items.Placeables.Banners
{
[LegacyName("SeaSerpentBanner")]
public class SandProwlerBanner : BaseBanner
{
public override int BannerTileStyle => 106;
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 411 B

@@ -0,0 +1,7 @@
namespace CalamityMod.Items.Placeables.Banners
{
public class SeaSerpentBanner : BaseBanner
{
public override int BannerTileStyle => 106;
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 300 B

@@ -117,6 +117,7 @@ Toxicatfish: Though these fish once threatened none other than their prey, the r
Trasher: Despite being equipped with a mouth large enough to swallow a child whole, these crocodiles simply act as scavengers, devouring scraps and bones left over from predators' meals. Needing to conserve energy due to eating relatively little, they rarely move at their full speed unless they feel threatened.
//Sunken Sea Enemies
BabyGhostBell: Despite their decidedly lower size and development, infant Ghost Bells can deliver just as many volts to unsuspecting creatures. The Ilmerian army bred thousands of Ghost Bells to maintain the lethal electric field around the sea kingdom, but all their efforts were consumed by ash in a single burning moment.
BlindedAngler: Lacking most normal senses, these predators use a form of biological sonar to 'see' their surroundings. The glowing crystals on their backs draw in prey that use the sea's shimmering prisms as their guiding light, like a moth to the flame.
CarrionSwallower: Of all the species of fish rendered extinct by the Great Incineration, few were lucky enough to even have their corpses remain in one piece. Those that did had their souls infused with trace amounts of brimstone, which they use to hunt any that dare trespass on the old sea.
Clam: Despite having the same filter feeder appetite of the common clam, the Ilmeran species adopted defensive mechanisms against macrofauna due to their forced relocation by the Incineration. Almost all of the remaining Clams have congregated in a small den at the bottom of the sea; what makes this place unique is unknown, as few divers can withstand the ferocity of the clams in their natural abode.
Cnidrion: Once trained to be the steeds of honored Ilmerian warriors, Cnidrions fought valiantly alongside their masters during the Incineration. Though many perished unceremoniously with the warriors that commanded them, one managed to escape a fiery demise, continuing to defend what was once the heart of the sea kingdom with a fierce loyalty.
@@ -19,6 +19,7 @@ BabyCannonballJellyfishBanner.DisplayName: "{$Items.Placeables.FormattedBannerNa
BabyFlakCrabBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
BabyGhostBellBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
BelchingCoralBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
BlindedAnglerBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
BloatfishBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
BloomSlimeBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
BobbitWormBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
@@ -26,7 +27,6 @@ BohldohrBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
BoxJellyfishBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
CalamityEyeBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
CannonballJellyfishBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
CarrionSwallowerBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
ChaoticPufferBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
CladCrabBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
ClamBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
@@ -55,22 +55,15 @@ FusionFeederBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
GammaSlimeBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
GhostBellBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
GiantSquidBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
GildedAxolotlBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
GnasherBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
GulperEelBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
HadarianBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
HauntedChumBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
HeatSpiritBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
IceClasperBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
ImpiousImmolatorBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
InfernalCongealmentBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
IrradiatedSlimeBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
JellyghoulBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
KelpieSeadragonBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
LaserfishBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
LazarusLampfishBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
LeerslugBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
LostShoalBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
LuminousCorvinaBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
MantisBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
MantisShrimpBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
@@ -82,7 +75,6 @@ NuclearToadBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
OarfishBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
OrthoceraBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
OverloadedSoldierBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
PearlpodBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
PerennialSlimeBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
PestilentSlimeBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
PhantomSpiritBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
@@ -90,11 +82,7 @@ PiggyBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
PlaguebringerBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
PlagueChargerBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
PlagueshellBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
PodobooKoiBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
PolyperilBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
PrismBackBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
PrismaticGuppyBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
ProbesnoutBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
ProfanedEnergyBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
RadiatorBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
ReaperSharkBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
@@ -103,28 +91,21 @@ RepairUnitBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
RimehoundBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
RotdogBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
RubyCrawlerBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
SandProwlerBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
SeaSerpentBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
SapphireCrawlerBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
ScavengerBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
ScornEaterBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
ScryllarBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
SeaFloatyBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
SeaMinnowBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
SearslugBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
SharkoonBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
ShockstormShuttleBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
ShoreskipperBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
ShroombleBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
SightseerColliderBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
SightseerSpitterBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
SkyfinBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
SlabCrabBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
SlugbunBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
SoulSlurperBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
SteampodBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
StellarCulexBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
StormlionBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
StormlionSentryBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
SulflounderBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
SulphurousSkaterBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
SunskaterBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}"
@@ -258,20 +258,17 @@ Sulflounder.DisplayName: Sulflounder
Toxicatfish.DisplayName: Toxicatfish
Trasher.DisplayName: Trasher
BabyGhostBell.DisplayName: Baby Ghost Bell
BlindedAngler.DisplayName: Blinded Angler
Clam.DisplayName: Clam
EutrophicRay.DisplayName: Eutrophic Ray
GhostBell.DisplayName: Ghost Bell
GiantClam.DisplayName: Giant Clam
Clamitas: Clamitas
SupremeClamitas: Supreme Clamitas
GoldBabyGhostBell: Gold Baby Ghost Bell
PrismBack.DisplayName: Prism-Back
RadiantBabyGhostBell: Radiant Baby Ghost Bell
SandProwler.DisplayName: Sand Prowler
SandProwlerNested.DisplayName: Sand Prowler
SeaFloaty.DisplayName: Sea Floaty
SeaMinnow.DisplayName: Sea Minnow
SeaMinnowGold.DisplayName: Gold Sea Minnow
SeaSerpent1.DisplayName: Sea Serpent
BrimstoneHeart.DisplayName: Brimstone Heart
SepulcherHead.DisplayName: Sepulcher
SoulSeekerSupreme.DisplayName: Soul Seeker
+1 -1
View File
@@ -663,7 +663,7 @@ namespace CalamityMod.NPCs.NormalNPCs
}
// Sea Minnows face away from the player
if (npc.type == ModContent.NPCType<SeaMinnow>() || npc.type == ModContent.NPCType<SeaMinnowGold>())
if (npc.type == ModContent.NPCType<SeaMinnow>())
npc.direction *= -1;
}
else
+150
View File
@@ -0,0 +1,150 @@
using System.IO;
using CalamityMod.BiomeManagers;
using CalamityMod.Items.Placeables;
using CalamityMod.Items.Placeables.Banners;
using CalamityMod.Items.Placeables.SunkenSea;
using CalamityMod.Items.Weapons.Melee;
using CalamityMod.NPCs.NormalNPCs;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.GameContent;
using Terraria.GameContent.Bestiary;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ModLoader.Utilities;
namespace CalamityMod.NPCs.SunkenSea
{
public class BlindedAngler : ModNPC
{
public static Asset<Texture2D> GlowTexture;
public override void SetStaticDefaults()
{
Main.npcFrameCount[NPC.type] = 6;
if (!Main.dedServ)
{
GlowTexture = ModContent.Request<Texture2D>(Texture + "Glow", AssetRequestMode.AsyncLoad);
}
}
public override void SetDefaults()
{
NPC.noGravity = true;
NPC.damage = 150;
NPC.width = 56;
NPC.height = 44;
NPC.defense = 30;
NPC.lifeMax = 750;
NPC.aiStyle = -1;
AIType = -1;
NPC.value = Item.buyPrice(0, 0, 40, 0);
NPC.HitSound = SoundID.NPCHit1;
NPC.DeathSound = SoundID.NPCDeath1;
NPC.knockBackResist = 0.1f;
Banner = NPC.type;
BannerItem = ModContent.ItemType<BlindedAnglerBanner>();
NPC.chaseable = false;
NPC.Calamity().VulnerableToHeat = false;
NPC.Calamity().VulnerableToSickness = true;
NPC.Calamity().VulnerableToElectricity = true;
NPC.Calamity().VulnerableToWater = false;
SpawnModBiomes = new int[1] { ModContent.GetInstance<SunkenSeaBiome>().Type };
}
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
{
bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[]
{
new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.BlindedAngler")
});
}
public override void SendExtraAI(BinaryWriter writer)
{
writer.Write(NPC.chaseable);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
NPC.chaseable = reader.ReadBoolean();
}
public override void AI()
{
Lighting.AddLight(NPC.Center, (255 - NPC.alpha) * 0f / 255f, (255 - NPC.alpha) * 0.75f / 255f, (255 - NPC.alpha) * 0.75f / 255f);
CalamityRegularEnemyAI.PassiveSwimmingAI(NPC, Mod, 1, 100f, 0.1f, 0.1f, 3f, 3f, 0.1f);
}
public override void FindFrame(int frameHeight)
{
NPC.frameCounter += (NPC.wet || NPC.IsABestiaryIconDummy) ? 0.15f : 0f;
NPC.frameCounter %= Main.npcFrameCount[NPC.type];
int frame = (int)NPC.frameCounter;
NPC.frame.Y = frame * frameHeight;
}
public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
{
SpriteEffects spriteEffects = SpriteEffects.None;
if (NPC.spriteDirection == 1)
{
spriteEffects = SpriteEffects.FlipHorizontally;
}
Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y);
Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2));
Vector2 vector = center - screenPos;
vector -= new Vector2((float)GlowTexture.Value.Width, (float)(GlowTexture.Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f;
vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY);
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);
}
public override bool? CanBeHitByProjectile(Projectile projectile)
{
if (projectile.minion && !projectile.Calamity().overridesMinionDamagePrevention)
{
return NPC.chaseable;
}
return null;
}
public override float SpawnChance(NPCSpawnInfo spawnInfo)
{
if (Main.hardMode && spawnInfo.Player.Calamity().ZoneSunkenSea && spawnInfo.Water && !spawnInfo.Player.Calamity().clamity)
{
return SpawnCondition.CaveJellyfish.Chance * 0.45f;
}
return 0f;
}
public override void ModifyNPCLoot(NPCLoot npcLoot)
{
npcLoot.Add(ModContent.ItemType<PrismShard>(), 1, 5, 9);
}
public override void HitEffect(NPC.HitInfo hit)
{
for (int k = 0; k < 5; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.BlueCrystalShard, hit.HitDirection, -1f, 0, default, 1f);
}
if (NPC.life <= 0)
{
for (int k = 0; k < 25; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.BlueCrystalShard, hit.HitDirection, -1f, 0, default, 1f);
}
if (Main.netMode != NetmodeID.Server)
{
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("BlindAnglerGore1").Type, 1f);
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("BlindAnglerGore2").Type, 1f);
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("BlindAnglerGore3").Type, 1f);
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("BlindAnglerGore4").Type, 1f);
}
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

+1 -1
View File
@@ -1,7 +1,7 @@
using System.IO;
using CalamityMod.BiomeManagers;
using CalamityMod.Items.Materials;
using CalamityMod.Items.Placeables;
using CalamityMod.Items.Placeables.SunkenSea;
using CalamityMod.Items.Placeables.Banners;
using Terraria;
using Terraria.GameContent.Bestiary;
-1
View File
@@ -4,7 +4,6 @@ using CalamityMod.BiomeManagers;
using CalamityMod.Items.Placeables;
using CalamityMod.Items.Placeables.Banners;
using CalamityMod.Items.Placeables.SunkenSea;
using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs;
using CalamityMod.NPCs.NormalNPCs;
using CalamityMod.World;
using Microsoft.Xna.Framework;
-724
View File
@@ -1,724 +0,0 @@
using CalamityMod.Enums;
using CalamityMod.Items.Placeables.Banners;
using CalamityMod.Items.Weapons.Magic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using System;
using System.Collections.Generic;
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 SandProwler : SunkenSeaNPC
{
public const int maxLength = 14;
public float speed = 3f;
public float turnSpeed = 0.0625f;
bool TailSpawned = false;
#region Textures
public static Asset<Texture2D> BodySprite1;
public static Asset<Texture2D> BodySprite2;
public static Asset<Texture2D> BodySprite3;
public static Asset<Texture2D> BodySprite4;
public static Asset<Texture2D> BodySprite5;
public static Asset<Texture2D> BodySprite6;
public static Asset<Texture2D> BodySprite7;
public static Asset<Texture2D> TailSprite;
#endregion
public enum AnimType
{
None = 0,
Blink = 1,
Bite = 2
}
public bool IsHead => NPC.ai[3] == 0;
public bool IsTail => NPC.ai[3] == 8;
public ref float CurrentAnimation => ref NPC.localAI[1];
public ref float CurrentFrame => ref NPC.localAI[0];
public ref float BlinkTimer => ref NPC.localAI[2];
protected override List<int> PreyIDs => new List<int>()
{
ModContent.NPCType<PolypPanasea>(),
ModContent.NPCType<Slugbun>(),
};
protected override List<int> PredatorIDs => new List<int>()
{
ModContent.NPCType<Polyperil>(),
ModContent.NPCType<PolyperilTentacle>()
};
protected override SunkenSeaBiomeFlags BiomeDesignation => SunkenSeaBiomeFlags.PolypForest;
public override void SetStaticDefaults()
{
NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers()
{
PortraitPositionXOverride = 40,
PortraitPositionYOverride = 20
};
value.Position.Y += 20;
value.Position.X += 40;
NPCID.Sets.NPCBestiaryDrawOffset[Type] = value;
NPCID.Sets.TrailingMode[Type] = 1;
NPCID.Sets.CantTakeLunchMoney[Type] = true; // It will only eat coins that the AI says it can, and when it does, you aren't getting them back
if (!Main.dedServ)
{
BodySprite1 = ModContent.Request<Texture2D>("CalamityMod/NPCs/SunkenSea/SandProwler2", AssetRequestMode.AsyncLoad);
BodySprite2 = ModContent.Request<Texture2D>("CalamityMod/NPCs/SunkenSea/SandProwler3", AssetRequestMode.AsyncLoad);
BodySprite3 = ModContent.Request<Texture2D>("CalamityMod/NPCs/SunkenSea/SandProwler4", AssetRequestMode.AsyncLoad);
BodySprite4 = ModContent.Request<Texture2D>("CalamityMod/NPCs/SunkenSea/SandProwler5", AssetRequestMode.AsyncLoad);
BodySprite5 = ModContent.Request<Texture2D>("CalamityMod/NPCs/SunkenSea/SandProwler6", AssetRequestMode.AsyncLoad);
BodySprite6 = ModContent.Request<Texture2D>("CalamityMod/NPCs/SunkenSea/SandProwler7", AssetRequestMode.AsyncLoad);
BodySprite7 = ModContent.Request<Texture2D>("CalamityMod/NPCs/SunkenSea/SandProwler8", AssetRequestMode.AsyncLoad);
TailSprite = ModContent.Request<Texture2D>("CalamityMod/NPCs/SunkenSea/SandProwler9", AssetRequestMode.AsyncLoad);
}
Main.npcFrameCount[Type] = 11;
base.SetStaticDefaults();
}
public override void SetDefaults()
{
base.SetDefaults();
NPC.damage = 50;
NPC.width = 30;
NPC.height = 24;
NPC.defense = 10;
NPC.lifeMax = 300;
NPC.aiStyle = -1;
AIType = -1;
NPC.knockBackResist = 0f;
NPC.value = Item.buyPrice(silver: 20);
NPC.behindTiles = true;
NPC.noGravity = true;
NPC.noTileCollide = true;
NPC.HitSound = SoundID.NPCHit1;
NPC.DeathSound = SoundID.NPCDeath1;
NPC.netAlways = true;
NPC.chaseable = false;
Banner = NPC.type;
BannerItem = ModContent.ItemType<SandProwlerBanner>();
NPC.Calamity().VulnerableToHeat = false;
NPC.Calamity().VulnerableToSickness = true;
NPC.Calamity().VulnerableToElectricity = true;
NPC.Calamity().VulnerableToWater = false;
NPC.waterMovementSpeed = 1;
NPC.GravityIgnoresLiquid = true;
}
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
{
bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[]
{
new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.SandProwler")
});
}
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
{
// only the head gets a healthbar
return IsHead;
}
public override void AI()
{
if (IsHead)
HeadAI();
else
SegmentAI();
}
public void HeadAI()
{
Point point = NPC.Center.ToTileCoordinates();
Tile tileSafely = Framing.GetTileSafely(point);
bool createDust = tileSafely.HasUnactuatedTile && NPC.Distance(Main.player[NPC.target].Center) < 800f;
if (createDust)
{
if (Main.rand.NextBool())
{
Dust dust = Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, DustID.TreasureSparkle, 0f, 0f, 150, default(Color), 0.3f);
dust.fadeIn = 0.75f;
dust.velocity *= 0.1f;
dust.noLight = true;
}
}
if (NPC.ai[2] > 0f)
{
NPC.realLife = (int)NPC.ai[2];
}
if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead)
{
NPC.TargetClosest(true);
}
if (Main.netMode != NetmodeID.MultiplayerClient)
{
if (!TailSpawned && NPC.ai[0] == 0f)
{
int Previous = NPC.whoAmI;
for (int segment = 0; segment < maxLength; segment++)
{
int lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType<SandProwler>(), NPC.whoAmI);
Main.npc[lol].realLife = NPC.whoAmI;
Main.npc[lol].ai[2] = (float)NPC.whoAmI;
Main.npc[lol].ai[1] = (float)Previous;
Main.npc[Previous].ai[0] = (float)lol;
float spriteUse = segment % 2 == 0 ? 3 : 4; // Looping body 3 and 4
int width = 18;
switch (segment)
{
case maxLength - 1:
spriteUse = 8; // Tail
break;
case maxLength - 2:
spriteUse = 7; // Body 7
width = 14 ;
break;
case maxLength - 3:
spriteUse = 6; // Body 6
width = 16;
break;
case maxLength - 4:
spriteUse = 5; // Body 5
break;
case 0:
spriteUse = 1; // Body 1
break;
case 1:
spriteUse = 2; // Body 2
break;
}
Main.npc[lol].ai[3] = spriteUse;
Main.npc[lol].npcSlots = 0;
Main.npc[lol].dontCountMe = true;
Main.npc[lol].width = width;
NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0);
Previous = lol;
}
TailSpawned = true;
}
}
if (NPC.velocity.X < 0f)
{
NPC.spriteDirection = -1;
}
else if (NPC.velocity.X > 0f)
{
NPC.spriteDirection = 1;
}
if (Main.player[NPC.target].dead)
{
NPC.TargetClosest(false);
}
NPC.alpha -= 42;
if (NPC.alpha < 0)
{
NPC.alpha = 0;
}
if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 5600f)
{
NPC.active = false;
}
float currentSpeed = speed;
float currentTurnSpeed = turnSpeed;
Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f);
Entity targ = CurrentPrey != null ? CurrentPrey : Main.player[NPC.target];
float targetXDist = targ.position.X + (float)(targ.width / 2);
float targetYDist = targ.position.Y + (float)(targ.height / 2);
bool coinTarget = false;
// fucking run if it notices a predator
if (CurrentPredator != null)
{
Vector2 dirToPred = NPC.DirectionTo(CurrentPredator.Center);
targetXDist = -dirToPred.X * 300;
targetYDist = -dirToPred.Y * 300;
currentSpeed *= 2f;
currentTurnSpeed *= 11.5f;
}
else
{
// Look for silver and gold coins to eat
for (int i = 0; i < Main.maxItems; i++)
{
Item item = Main.item[i];
// continue if not an active silver or gold coin
if (item == null || !item.active || (item.type != ItemID.SilverCoin && item.type != ItemID.GoldCoin))
continue;
// can only look for coins in a 75 tile radius
if (item.Distance(NPC.Center) > 1200)
continue;
// if its head touches the coin, eat it
if (item.getRect().Intersects(NPC.getRect()))
{
SoundEngine.PlaySound(SoundID.Item2 with { Pitch = 1.2f, Volume = 0.8f }, NPC.Center);
SoundEngine.PlaySound(SoundID.CoinPickup, NPC.Center);
int dustType = item.type == ItemID.SilverCoin ? DustID.SilverCoin : DustID.GoldCoin;
for (int j = 0; j < 4; j++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, dustType, Main.rand.NextFloat(-1, 1), Main.rand.NextFloat(-1, 1));
}
item.active = false;
break;
}
// if it isn't touching the coin, go to it
targetXDist = item.Center.X;
targetYDist = item.Center.Y;
coinTarget = true;
break;
}
}
// aggro on coins takes priority over players
if (CurrentPredator == null && (NPC.life > NPC.lifeMax * 0.99 && targ is Player) && !coinTarget)
{
targetYDist += 300;
if (Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) < 250f)
{
if (NPC.velocity.X > 0f)
{
targetXDist = Main.player[NPC.target].Center.X + 300f;
}
else
{
targetXDist = Main.player[NPC.target].Center.X - 300f;
}
}
// Blink every so often
if (Main.rand.NextBool(600) && CurrentAnimation == (int)AnimType.None && BlinkTimer <= 0)
{
CurrentAnimation = (int)AnimType.Blink;
BlinkTimer = Main.rand.NextBool(4) ? 48 : 24;
}
}
else if (CurrentPredator == null)
{
currentSpeed *= 1.5f;
currentTurnSpeed *= 1.5f;
}
float maxCurrentSpeed = currentSpeed * 1.3f;
float minCurrentSpeed = currentSpeed * 0.7f;
float speedCompare = NPC.velocity.Length();
if (speedCompare > 0f)
{
if (speedCompare > maxCurrentSpeed)
{
NPC.velocity.Normalize();
NPC.velocity *= maxCurrentSpeed;
}
else if (speedCompare < minCurrentSpeed)
{
NPC.velocity.Normalize();
NPC.velocity *= minCurrentSpeed;
}
}
targetXDist = (float)((int)(targetXDist / 16f) * 16);
targetYDist = (float)((int)(targetYDist / 16f) * 16);
segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16);
segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16);
targetXDist -= segmentPosition.X;
targetYDist -= segmentPosition.Y;
float targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist));
float absoluteTargetX = System.Math.Abs(targetXDist);
float absoluteTargetY = System.Math.Abs(targetYDist);
float timeToReachTarget = currentSpeed / targetDistance;
targetXDist *= timeToReachTarget;
targetYDist *= timeToReachTarget;
if (targetDistance < 128 && targ is NPC || (NPC.life <= NPC.lifeMax * 0.99 && targ is Player) || coinTarget)
{
CurrentAnimation = (int)AnimType.Bite;
}
else if (CurrentAnimation != (int)AnimType.Blink)
{
CurrentAnimation = (int)AnimType.None;
}
BlinkTimer--;
if (BlinkTimer <= 0)
{
BlinkTimer = 0;
if (CurrentAnimation == (int)AnimType.Blink)
{
CurrentAnimation = (int)AnimType.None;
}
}
if ((NPC.velocity.X > 0f && targetXDist > 0f) || (NPC.velocity.X < 0f && targetXDist < 0f) || (NPC.velocity.Y > 0f && targetYDist > 0f) || (NPC.velocity.Y < 0f && targetYDist < 0f))
{
if (NPC.velocity.X < targetXDist)
{
NPC.velocity.X = NPC.velocity.X + currentTurnSpeed;
}
else
{
if (NPC.velocity.X > targetXDist)
{
NPC.velocity.X = NPC.velocity.X - currentTurnSpeed;
}
}
if (NPC.velocity.Y < targetYDist)
{
NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed;
}
else
{
if (NPC.velocity.Y > targetYDist)
{
NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed;
}
}
if ((double)System.Math.Abs(targetYDist) < (double)currentSpeed * 0.2 && ((NPC.velocity.X > 0f && targetXDist < 0f) || (NPC.velocity.X < 0f && targetXDist > 0f)))
{
if (NPC.velocity.Y > 0f)
{
NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed * 2f;
}
else
{
NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed * 2f;
}
}
if ((double)System.Math.Abs(targetXDist) < (double)currentSpeed * 0.2 && ((NPC.velocity.Y > 0f && targetYDist < 0f) || (NPC.velocity.Y < 0f && targetYDist > 0f)))
{
if (NPC.velocity.X > 0f)
{
NPC.velocity.X = NPC.velocity.X + currentTurnSpeed * 2f; //changed from 2
}
else
{
NPC.velocity.X = NPC.velocity.X - currentTurnSpeed * 2f; //changed from 2
}
}
}
else
{
if (absoluteTargetX > absoluteTargetY)
{
if (NPC.velocity.X < targetXDist)
{
NPC.velocity.X = NPC.velocity.X + currentTurnSpeed * 1.1f; //changed from 1.1
}
else if (NPC.velocity.X > targetXDist)
{
NPC.velocity.X = NPC.velocity.X - currentTurnSpeed * 1.1f; //changed from 1.1
}
if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)currentSpeed * 0.5)
{
if (NPC.velocity.Y > 0f)
{
NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed;
}
else
{
NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed;
}
}
}
else
{
if (NPC.velocity.Y < targetYDist)
{
NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed * 1.1f;
}
else if (NPC.velocity.Y > targetYDist)
{
NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed * 1.1f;
}
if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)currentSpeed * 0.5)
{
if (NPC.velocity.X > 0f)
{
NPC.velocity.X = NPC.velocity.X + currentTurnSpeed;
}
else
{
NPC.velocity.X = NPC.velocity.X - currentTurnSpeed;
}
}
}
}
NPC.rotation = (float)System.Math.Atan2((double)NPC.velocity.Y, (double)NPC.velocity.X) + 1.57f;
}
public void SegmentAI()
{
if (NPC.ai[2] > 0f)
NPC.realLife = (int)NPC.ai[2];
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<SandProwler>() && Main.npc[i].ai[3] == 0)
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (NPC.ai[1] <= 0f)
shouldDespawn = true;
else if (Main.npc[(int)NPC.ai[1]].life <= 0)
shouldDespawn = true;
}
if (shouldDespawn)
{
NPC.life = 0;
NPC.HitEffect(0, 10.0);
NPC.checkDead();
NPC.active = false;
}
if (Main.npc[(int)NPC.ai[1]].alpha < 128)
{
NPC.alpha -= 42;
if (NPC.alpha < 0)
NPC.alpha = 0;
}
Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f);
float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2);
float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2);
targetXDist = (float)((int)(targetXDist / 16f) * 16);
targetYDist = (float)((int)(targetYDist / 16f) * 16);
segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16);
segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16);
targetXDist -= segmentPosition.X;
targetYDist -= segmentPosition.Y;
float targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist));
if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length)
{
try
{
segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f);
float headDivisor = 1;
targetXDist = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2 / headDivisor) - segmentPosition.X;
targetYDist = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y;
}
catch
{
}
NPC.rotation = (float)System.Math.Atan2((double)targetYDist, (double)targetXDist) + 1.57f;
targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist));
int segmentWidth = NPC.width;
targetDistance = (targetDistance - (float)segmentWidth) / targetDistance;
targetXDist *= targetDistance;
targetYDist *= targetDistance;
NPC.velocity = Vector2.Zero;
NPC.position.X = NPC.position.X + targetXDist;
NPC.position.Y = NPC.position.Y + targetYDist;
if (targetXDist < 0f)
NPC.spriteDirection = -1;
else if (targetXDist > 0f)
NPC.spriteDirection = 1;
}
}
public override void FindFrame(int frameHeight)
{
if (IsTail)
{
NPC.frameCounter++;
if (NPC.frameCounter > 6)
{
NPC.localAI[0]++;
NPC.frameCounter = 0;
}
if (NPC.localAI[0] > 7)
{
NPC.localAI[0] = 0;
}
}
if (IsHead)
{
NPC.frameCounter++;
if (NPC.frameCounter > 6)
{
NPC.frame.Y += frameHeight;
NPC.frameCounter = 0;
}
switch (CurrentAnimation)
{
case (int)AnimType.None:
NPC.frame.Y = 0;
break;
case (int)AnimType.Bite:
if (NPC.frame.Y < frameHeight * 5 || NPC.frame.Y > frameHeight * 10)
{
NPC.frame.Y = frameHeight * 5;
}
break;
case (int)AnimType.Blink:
if (NPC.frame.Y < frameHeight || NPC.frame.Y > frameHeight * 4)
{
NPC.frame.Y = frameHeight;
}
break;
}
}
}
public override float SpawnChance(NPCSpawnInfo spawnInfo)
{
if (Main.hardMode && spawnInfo.Player.Calamity().ZonePolypForest && spawnInfo.Water &&
!NPC.AnyNPCs(ModContent.NPCType<SandProwler>()) && !spawnInfo.Player.Calamity().clamity && !spawnInfo.PlayerSafe)
return SpawnCondition.CaveJellyfish.Chance * 0.3f;
return 0f;
}
public override bool CheckActive()
{
return IsHead;
}
protected override bool NPCSearchFilter(NPC n)
{
float huntRange = 600f;
float avoidRange = 200f;
bool preyFilter = Vector2.DistanceSquared(NPC.Center, n.Center) < huntRange * huntRange && PreyIDs.Contains(n.type);
bool predFilter = Vector2.DistanceSquared(NPC.Center, n.Center) < avoidRange * avoidRange && PredatorIDs.Contains(n.type);
bool hidingGuppy = n.type == ModContent.NPCType<PrismaticGuppy>() && n.alpha > 0;
return !hidingGuppy && (preyFilter || predFilter);
}
public override bool CanBeHitByNPC(NPC attacker) => PredatorIDs.Contains(attacker.type);
public override bool CanHitNPC(NPC target)
{
return IsHead;
}
public override void OnHitByProjectile(Projectile projectile, NPC.HitInfo hit, int damageDone)
{
PlayerHurt();
}
public override void OnHitByItem(Player player, Item item, NPC.HitInfo hit, int damageDone)
{
PlayerHurt();
}
public void PlayerHurt()
{
if (IsHead)
NPC.chaseable = true;
else
Main.npc[NPC.realLife].chaseable = true;
}
public override void ModifyNPCLoot(NPCLoot npcLoot) => DefineSandProwlerLoot(npcLoot);
public static void DefineSandProwlerLoot(NPCLoot npcLoot)
{
npcLoot.Add(ModContent.ItemType<Serpentine>(), 4);
}
public override void HitEffect(NPC.HitInfo hit)
{
for (int k = 0; k < 3; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Coralstone, hit.HitDirection, -1f, 0, default, 1f);
}
if (NPC.life <= 0)
{
for (int k = 0; k < 10; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Coralstone, hit.HitDirection, -1f, 0, default, 1f);
}
if (!Main.dedServ)
{
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("SeaSerpentGore1").Type, 1f);
}
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
{
Texture2D segmentSprite = TextureAssets.Npc[Type].Value;
if (NPC.IsABestiaryIconDummy)
{
NPC.frame = segmentSprite.Frame();
// Buffers the segment position and rotations
float offset = -0.2f;
float startX = 0;
float startY = 0;
int segmentSpacing = 16;
int animationSpeed = 5;
float wormTimer = NPC.Calamity().bestiaryWormTimer;
// Draw the body segments
for (int i = 7; i > 0; i--)
{
// The first segment is slightly closer to keep up with the head
float bodyOffset = i == 1 ? i * segmentSpacing * 0.4f : i * segmentSpacing - segmentSpacing * 0.5f;
Texture2D toUse = i == 1 ? BodySprite1.Value : i == 2 ? BodySprite2.Value : i % 2 == 0 ? BodySprite3.Value : BodySprite4.Value;
spriteBatch.Draw(toUse, NPC.position + new Vector2(startX + bodyOffset, MathF.Sin((wormTimer + offset * i) * animationSpeed) * 2 + startY), toUse.Frame(1, 1, 0, 0), NPC.GetAlpha(drawColor), NPC.rotation - MathHelper.PiOver2 - MathF.Cos((wormTimer + offset * i) * animationSpeed) * MathHelper.PiOver4 * 0.075f, new Vector2(toUse.Width / 2, toUse.Width / 2), NPC.scale, SpriteEffects.None, 0f);
}
// Draw the head
spriteBatch.Draw(segmentSprite, NPC.position + new Vector2(startX, MathF.Sin(wormTimer * animationSpeed) * 2 + startY), segmentSprite.Frame(1, 11, 0, 0), NPC.GetAlpha(drawColor), NPC.rotation - MathHelper.PiOver2 - MathF.Cos(wormTimer * animationSpeed) * MathHelper.PiOver4 * 0.075f, new Vector2(segmentSprite.Width * 0.5f, segmentSprite.Height / 11), NPC.scale, SpriteEffects.None, 0f);
return false;
}
switch (NPC.ai[3])
{
case 0:
break;
case 1:
segmentSprite = BodySprite1.Value;
break;
case 2:
segmentSprite = BodySprite2.Value;
break;
case 3:
segmentSprite = BodySprite3.Value;
break;
case 4:
segmentSprite = BodySprite4.Value;
break;
case 5:
segmentSprite = BodySprite5.Value;
break;
case 6:
segmentSprite = BodySprite6.Value;
break;
case 7:
segmentSprite = BodySprite7.Value;
break;
case 8:
segmentSprite = TailSprite.Value;
break;
default:
segmentSprite = NPC.ai[3] % 2 == 0 ? BodySprite4.Value : BodySprite3.Value;
break;
}
float frameDivisor = IsTail ? 8 : IsHead ? Main.npcFrameCount[Type] : 1;
Vector2 origin = new Vector2(segmentSprite.Width / 2, segmentSprite.Height / 2 / frameDivisor);
Vector2 npcOffset = NPC.Center - screenPos;
npcOffset -= new Vector2(segmentSprite.Width, segmentSprite.Height / frameDivisor) * NPC.scale / 2f;
npcOffset += origin * NPC.scale + new Vector2(0f, NPC.gfxOffY);
SpriteEffects fx = NPC.oldPos[1].X < NPC.position.X ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
Rectangle frame = segmentSprite.Frame(1, 1, 0, 0);
if (IsHead)
{
frame = NPC.frame;
}
else if (IsTail)
{
frame = segmentSprite.Frame(1, 8, 0, (int)NPC.localAI[0]);
}
spriteBatch.Draw(segmentSprite, npcOffset, frame, NPC.GetAlpha(drawColor), NPC.rotation, origin, NPC.scale, fx, 0f);
return false;
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 293 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 327 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 333 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 347 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

-504
View File
@@ -1,504 +0,0 @@
using CalamityMod.DataStructures;
using CalamityMod.Items.Placeables.Banners;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Collections.Generic;
using System.IO;
using Terraria;
using Terraria.Audio;
using Terraria.GameContent;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ModLoader.Utilities;
using Terraria.GameContent.Bestiary;
using CalamityMod.Enums;
namespace CalamityMod.NPCs.SunkenSea
{
public class SandProwlerNested : SunkenSeaNPC
{
public bool PeekingOut;
public bool HasChosenSpotToHideIn => SpotToHideIn != Vector2.Zero;
public Point TileCoordsToHideIn
{
get => SpotToHideIn.ToTileCoordinates();
set => SpotToHideIn = value.ToWorldCoordinates();
}
public Vector2 SpotToHideIn
{
get => new Vector2(NPC.ai[0], NPC.ai[1]);
set
{
NPC.ai[0] = value.X;
NPC.ai[1] = value.Y;
}
}
public bool InHidingSpot => NPC.WithinRange(SpotToHideIn, 8f);
public bool RetreatingToHidingSpot
{
get => NPC.ai[2] == 1f;
set => NPC.ai[2] = value.ToInt();
}
public ref float SnapTimer => ref NPC.ai[3];
public ref float SnapCooldown => ref NPC.localAI[0];
public ref float InitialSnapDirection => ref NPC.localAI[1];
public ref float CurrentSnapDirection => ref NPC.localAI[2];
public override string Texture => "CalamityMod/NPCs/SunkenSea/SandProwler";
protected override List<int> PreyIDs => new List<int>()
{
ModContent.NPCType<PolypPanasea>(),
ModContent.NPCType<PrismaticGuppy>(),
ModContent.NPCType<Slugbun>(),
};
protected override List<int> PredatorIDs => new List<int>()
{
ModContent.NPCType<Polyperil>()
};
protected override SunkenSeaBiomeFlags BiomeDesignation => SunkenSeaBiomeFlags.PolypForest;
public override void SetStaticDefaults()
{
this.HideFromBestiary();
NPCID.Sets.TrailingMode[Type] = 0;
NPCID.Sets.TrailCacheLength[Type] = 60;
NPCID.Sets.UsesNewTargetting[Type] = true;
NPCID.Sets.CantTakeLunchMoney[Type] = true;
Main.npcFrameCount[Type] = 11;
base.SetStaticDefaults();
}
public override void SetDefaults()
{
NPC.damage = 50;
NPC.width = 30;
NPC.height = 30; //32
NPC.defense = 10;
NPC.lifeMax = 300;
NPC.aiStyle = -1;
AIType = -1;
NPC.knockBackResist = 0f;
NPC.value = Item.buyPrice(silver: 20);
NPC.behindTiles = true;
NPC.noGravity = true;
NPC.noTileCollide = true;
NPC.HitSound = SoundID.NPCHit1;
NPC.DeathSound = SoundID.NPCDeath1;
NPC.chaseable = false;
NPC.netAlways = true;
Banner = ModContent.NPCType<SandProwler>();
BannerItem = ModContent.ItemType<SandProwlerBanner>();
NPC.Calamity().VulnerableToHeat = false;
NPC.Calamity().VulnerableToSickness = true;
NPC.Calamity().VulnerableToElectricity = true;
NPC.Calamity().VulnerableToWater = false;
NPC.waterMovementSpeed = 1f;
}
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
{
bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[]
{
new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.SeaSerpent")
});
}
public override void SendExtraAI(BinaryWriter writer)
{
writer.Write(PeekingOut);
writer.Write(SnapCooldown);
writer.Write(InitialSnapDirection);
writer.Write(CurrentSnapDirection);
writer.Write(NPC.Calamity().newAI[1]);
writer.Write(NPC.chaseable);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
PeekingOut = reader.ReadBoolean();
SnapCooldown = reader.ReadSingle();
InitialSnapDirection = reader.ReadSingle();
CurrentSnapDirection = reader.ReadSingle();
NPC.Calamity().newAI[1] = reader.ReadSingle();
NPC.chaseable = reader.ReadBoolean();
}
public override void AI()
{
// Choose an initial tile to hide in.
if (Main.netMode != NetmodeID.MultiplayerClient && !HasChosenSpotToHideIn)
{
int tries;
for (tries = 0; tries < 1800; tries++)
{
int x = (int)(NPC.Center.X / 16f) + Main.rand.Next(-25, 25);
int y = (int)(NPC.Center.Y / 16f) + Main.rand.Next(-25, 25);
Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y);
// Try again if the tile isn't solid or isn't exposed to air.
if (!WorldGen.SolidTile(tile) || !CalamityUtils.IsTileExposedToAir(x, y, out float? angleToOpenAir))
continue;
// Try again if there's no open water near the tile.
Vector2 moveDirection = angleToOpenAir.Value.ToRotationVector2();
Vector2 collisionCheckPosition = new Vector2(x * 16f + 8f, y * 16f + 8f) + moveDirection * 16f;
float collisionDistance = CalamityUtils.DistanceToTileCollisionHit(collisionCheckPosition, moveDirection, 20) ?? 20;
if (collisionDistance <= 10)
continue;
TileCoordsToHideIn = new Point(x, y);
break;
}
// Just die if no spot was suitable.
if (tries >= 1799)
NPC.active = false;
NPC.Center = SpotToHideIn;
NPC.netUpdate = true;
}
Entity target = null;
// Look for coins
for (int i = 0; i < Main.maxItems; i++)
{
Item n = Main.item[i];
if (n == null || !n.active || (n.type != ItemID.SilverCoin && n.type != ItemID.GoldCoin))
continue;
// if its head touches the coin, eat it
if (n.getRect().Intersects(NPC.getRect()))
{
SoundEngine.PlaySound(SoundID.Item2 with { Pitch = 1.2f, Volume = 0.8f }, NPC.Center);
SoundEngine.PlaySound(SoundID.CoinPickup, NPC.Center);
int dustType = n.type == ItemID.SilverCoin ? DustID.SilverCoin : DustID.GoldCoin;
for (int j = 0; j < 4; j++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, dustType, Main.rand.NextFloat(-1, 1), Main.rand.NextFloat(-1, 1));
}
n.active = false;
break;
}
// Set the coin as the target
if (n.Distance(NPC.Center) <= 300 && Collision.CheckAABBvLineCollision(NPC.Center, NPC.Size, NPC.Center, n.Center))
{
target = n;
}
}
// Go after sea minnows if not distracted by shiny coin
if (target == null)
{
if (NPC.life > NPC.lifeMax * 0.99f)
{
if (CurrentPrey != null)
target = CurrentPrey;
}
// If you've pissed it off, it now goes after YOU
else
{
NPC.TargetClosest(false);
target = Main.player[NPC.target];
}
}
// Open mouth when launching towards a target
if (SnapTimer > 0 && target != null && !PeekingOut)
{
NPC.Calamity().newAI[1] = 1;
}
else if (RetreatingToHidingSpot || InHidingSpot)
{
NPC.Calamity().newAI[1] = 0;
}
// Become invulnerable and mostly transparent if hiding in a tile.
NPC.dontTakeDamage = InHidingSpot;
NPC.Opacity = MathHelper.Clamp(NPC.Opacity - NPC.dontTakeDamage.ToDirectionInt(), 0.35f, 1f);
// Also emit some particle effects as an indicator.
if (InHidingSpot)
{
Dust sparkle = Dust.NewDustDirect(TileCoordsToHideIn.ToWorldCoordinates(0, 0), 16, 16, DustID.AncientLight);
sparkle.color = Color.Orange;
sparkle.velocity = Main.rand.NextVector2Circular(4f, 4f);
sparkle.noGravity = true;
}
// Decide rotation.
NPC.rotation = NPC.AngleFrom(SpotToHideIn) + MathHelper.PiOver2;
// Prevent the tile from being destroyed.
FixExploitManEaters.ProtectSpot(TileCoordsToHideIn.X, TileCoordsToHideIn.Y);
// Do nothing other than hiding if instructed to do so.
if (RetreatingToHidingSpot)
{
NPC.velocity = NPC.SafeDirectionTo(SpotToHideIn) * 0.002f;
NPC.position += NPC.velocity.SafeNormalize(Vector2.Zero) * 5f;
// Stop once the hiding spot has been reached.
if (InHidingSpot)
{
NPC.Center = SpotToHideIn;
NPC.velocity = Vector2.Zero;
RetreatingToHidingSpot = false;
NPC.netUpdate = true;
}
return;
}
// Don't do any snapping and such if the cooldown is active.
if (SnapCooldown > 0f)
{
SnapCooldown--;
if (SnapCooldown <= 0f)
NPC.netUpdate = true;
return;
}
if (SnapTimer > 0f)
{
int snapTime = PeekingOut ? 45 : 32;
float idealSpeed = PeekingOut ? 1.75f : 10f;
float newSpeed = MathHelper.Lerp(NPC.velocity.Length(), idealSpeed, 0.08f);
NPC.velocity = CurrentSnapDirection.ToRotationVector2() * newSpeed;
// Get closer to the target if one not peeking.
if (!PeekingOut && target != null)
CurrentSnapDirection = CurrentSnapDirection.AngleTowards(NPC.AngleTo(target.Center), 0.0125f);
// Retreat if velocity is zero for some reason.
if (NPC.velocity == Vector2.Zero)
{
SnapTimer = 0f;
RetreatingToHidingSpot = true;
NPC.netUpdate = true;
return;
}
SnapTimer++;
if (SnapTimer >= snapTime || (Collision.SolidCollision(NPC.Center, 1, 1) && SnapTimer > 5f))
{
SnapTimer = 0f;
SnapCooldown = 35f;
PeekingOut = false;
RetreatingToHidingSpot = true;
}
return;
}
Vector2 snapDirection = Vector2.UnitY.RotatedBy(MathHelper.PiOver2 * Main.rand.Next(4));
// Pick a potential direction to snap out.
// This is important for attacking.
int snapDirectionTries = 0;
float targetSnapAngularThreshold = 0.48f;
while ((CalamityUtils.DistanceToTileCollisionHit(SpotToHideIn, snapDirection, 50) ?? 50f) < 5f)
{
snapDirectionTries++;
snapDirection = snapDirection.RotatedBy(MathHelper.PiOver2);
if (snapDirectionTries >= 8)
return;
// Try again if there's a defined target and it isn't in the line of sight of the current direction.
if (target != null && snapDirection.AngleBetween(NPC.SafeDirectionTo(target.Center)) > targetSnapAngularThreshold)
continue;
}
// Snap out if a suitable target gets close.
// Otherwise, sometimes randomly peek out.
bool canSnapAtTarget =
target != null &&
snapDirection.AngleBetween(NPC.SafeDirectionTo(target.Center)) < targetSnapAngularThreshold &&
Collision.CanHit(NPC.Center + snapDirection * 12f, 1, 1, target.Center, 1, 1);
if (Main.rand.NextBool(30) && !canSnapAtTarget)
PeekingOut = true;
if (PeekingOut || canSnapAtTarget)
{
if (canSnapAtTarget)
SoundEngine.PlaySound(SoundID.Item96, NPC.Center);
else
SoundEngine.PlaySound(SoundID.Item95, NPC.Center);
// Add some randomness when peeking.
if (PeekingOut)
snapDirection = snapDirection.RotatedByRandom(MathHelper.Pi / 6f);
NPC.velocity = snapDirection * 4f;
InitialSnapDirection = CurrentSnapDirection = NPC.velocity.ToRotation();
SnapTimer = 1f;
NPC.netUpdate = true;
}
}
public override void OnHitByProjectile(Projectile projectile, NPC.HitInfo hit, int damageDone)
{
PlayerHurt();
}
public override void OnHitByItem(Player player, Item item, NPC.HitInfo hit, int damageDone)
{
PlayerHurt();
}
public void PlayerHurt()
{
NPC.chaseable = true;
}
public override void FindFrame(int frameHeight)
{
if (NPC.Calamity().newAI[1] == 1)
{
NPC.frameCounter++;
if (NPC.frameCounter > 3)
{
NPC.frameCounter = 0;
NPC.frame.Y += frameHeight;
}
if (NPC.frame.Y < frameHeight * 5 || NPC.frame.Y > frameHeight * 10)
{
NPC.frame.Y = frameHeight * 5;
}
}
else
{
NPC.frameCounter = 0;
NPC.frame.Y = 0;
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
{
if (InHidingSpot)
return false;
Texture2D headTexture = ModContent.Request<Texture2D>(Texture).Value;
Texture2D body1Texture = SandProwler.BodySprite1.Value;
Texture2D body2Texture = SandProwler.BodySprite2.Value;
Texture2D body3Texture = SandProwler.BodySprite3.Value;
Texture2D body4Texture = SandProwler.BodySprite4.Value;
Vector2 idealDrawPosition = SpotToHideIn;
Vector2 backOffset = (NPC.rotation - MathHelper.PiOver2).ToRotationVector2() * -18f;
if (Collision.SolidCollision(idealDrawPosition + backOffset, 4, 4))
idealDrawPosition += backOffset;
List<Vector2> bezierPoints = new List<Vector2>()
{
idealDrawPosition
};
// Calculate points to create segments at based on a catmull-rom spine.
float bendFactor = Utils.GetLerpValue(80f, 250f, NPC.Distance(idealDrawPosition), true);
for (int i = 0; i < 20; i++)
{
Vector2 leftEnd = idealDrawPosition - InitialSnapDirection.ToRotationVector2() * bendFactor * 450f;
Vector2 rightEnd = NPC.Center + CurrentSnapDirection.ToRotationVector2() * bendFactor * 450f;
bezierPoints.Add(Vector2.CatmullRom(leftEnd, idealDrawPosition, NPC.Center, rightEnd, i / 19f));
}
bezierPoints.Add(NPC.Center);
// And then generalize them with a bezier curve.
BezierCurve bezierCurve = new BezierCurve(bezierPoints.ToArray());
int totalChains = (int)(NPC.Distance(idealDrawPosition) / 16f);
totalChains = (int)MathHelper.Clamp(totalChains, 2f, 100f);
for (int i = 0; i < totalChains - 1; i++)
{
Texture2D textureToUse;
if (i % 2 == 0)
{
textureToUse = body3Texture;
}
else
{
textureToUse = body4Texture;
}
switch (totalChains - i - 1)
{
case 1:
textureToUse = headTexture;
break;
case 2:
textureToUse = body1Texture;
break;
case 3:
textureToUse = body2Texture;
break;
}
Vector2 drawPosition = bezierCurve.Evaluate(i / (float)totalChains);
Color lightColor = Lighting.GetColor((int)(drawPosition.X / 16f), (int)(drawPosition.Y / 16f));
float angle = (bezierCurve.Evaluate(i / (float)totalChains + 1f / totalChains) - drawPosition).ToRotation() + MathHelper.PiOver2;
Rectangle frame = textureToUse.Frame(1, 1, 0, 0);
if (textureToUse == headTexture)
{
frame = NPC.frame;
}
Vector2 origin = new Vector2(textureToUse.Width / 2, textureToUse.Height / (textureToUse == headTexture ? 22 : 2));
spriteBatch.Draw(textureToUse, drawPosition - Main.screenPosition, frame, lightColor, angle, origin, NPC.scale, SpriteEffects.None, 0f);
}
return false;
}
protected override bool NPCSearchFilter(NPC n)
{
return Vector2.DistanceSquared(NPC.Center, n.Center) < 200f * 200f && (PreyIDs.Contains(n.type) || PredatorIDs.Contains(n.type));
}
public override bool CanBeHitByNPC(NPC attacker) => PredatorIDs.Contains(attacker.type);
public override bool CanHitPlayer(Player target, ref int cooldownSlot)
{
return NPC.life < NPC.lifeMax * 0.99f;
}
public override float SpawnChance(NPCSpawnInfo spawnInfo)
{
if (spawnInfo.Player.Calamity().ZonePolypForest && spawnInfo.Water && !spawnInfo.Player.Calamity().clamity && !spawnInfo.PlayerSafe)
return SpawnCondition.CaveJellyfish.Chance * 0.3f;
return 0f;
}
public override void ModifyNPCLoot(NPCLoot npcLoot) => SandProwler.DefineSandProwlerLoot(npcLoot);
public override void HitEffect(NPC.HitInfo hit)
{
for (int k = 0; k < 3; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Coralstone, hit.HitDirection, -1f, 0, default, 1f);
}
if (NPC.life <= 0 && !Main.dedServ)
{
for (int k = 0; k < 10; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Coralstone, hit.HitDirection, -1f, 0, default, 1f);
}
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("SeaSerpentGore1").Type, NPC.scale);
}
}
public override void OnKill()
{
// Increase the kill count of Sand Prowlers for the Bestiary
if (NPC.GetWereThereAnyInteractions())
{
NPC nPC = new NPC();
nPC.SetDefaults(ModContent.NPCType<SandProwler>());
Main.BestiaryTracker.Kills.RegisterKill(nPC);
}
}
}
}
+319
View File
@@ -0,0 +1,319 @@
using System;
using CalamityMod.BiomeManagers;
using CalamityMod.Items.Placeables.Banners;
using CalamityMod.Items.Weapons.Magic;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.GameContent.Bestiary;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ModLoader.Utilities;
namespace CalamityMod.NPCs.SunkenSea
{
public class SeaSerpent1 : ModNPC
{
public const int maxLength = 9;
public float speed = 3f;
public float turnSpeed = 0.0625f;
bool TailSpawned = false;
public override void SetStaticDefaults()
{
NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers()
{
CustomTexturePath = "CalamityMod/ExtraTextures/Bestiary/SeaSerpent_Bestiary",
PortraitPositionXOverride = 40,
PortraitPositionYOverride = 20
};
value.Position.Y += 20;
value.Position.X += 40;
NPCID.Sets.NPCBestiaryDrawOffset[Type] = value;
}
public override void SetDefaults()
{
NPC.damage = 50;
NPC.width = 50; //42
NPC.height = 24; //32
NPC.defense = 10;
NPC.lifeMax = 3000;
NPC.aiStyle = -1;
AIType = -1;
NPC.knockBackResist = 0f;
NPC.value = Item.buyPrice(0, 0, 20, 0);
NPC.behindTiles = true;
NPC.noGravity = true;
NPC.noTileCollide = true;
NPC.HitSound = SoundID.NPCHit1;
NPC.DeathSound = SoundID.NPCDeath1;
NPC.netAlways = true;
Banner = NPC.type;
BannerItem = ModContent.ItemType<SeaSerpentBanner>();
NPC.Calamity().VulnerableToHeat = false;
NPC.Calamity().VulnerableToSickness = true;
NPC.Calamity().VulnerableToElectricity = true;
NPC.Calamity().VulnerableToWater = false;
SpawnModBiomes = new int[1] { ModContent.GetInstance<SunkenSeaBiome>().Type };
}
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
{
bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[]
{
new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.SeaSerpent")
});
}
public override void AI()
{
Point point = NPC.Center.ToTileCoordinates();
Tile tileSafely = Framing.GetTileSafely(point);
bool createDust = tileSafely.HasUnactuatedTile && NPC.Distance(Main.player[NPC.target].Center) < 800f;
if (createDust)
{
if (Main.rand.NextBool())
{
Dust dust = Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, DustID.TreasureSparkle, 0f, 0f, 150, default(Color), 0.3f);
dust.fadeIn = 0.75f;
dust.velocity *= 0.1f;
dust.noLight = true;
}
}
Lighting.AddLight(NPC.Center, 0f, (255 - NPC.alpha) * 0.3f / 255f, (255 - NPC.alpha) * 0.3f / 255f);
if (NPC.ai[2] > 0f)
NPC.realLife = (int)NPC.ai[2];
if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead)
NPC.TargetClosest(true);
if (Main.netMode != NetmodeID.MultiplayerClient)
{
if (!TailSpawned && NPC.ai[0] == 0f)
{
int Previous = NPC.whoAmI;
for (int segment = 0; segment < maxLength; segment++)
{
int lol = 0;
if (segment == 0 || segment == 1 || segment == 4 || segment == 5)
lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType<SeaSerpent2>(), NPC.whoAmI);
else if (segment == 2 || segment == 3 || segment == 6)
lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType<SeaSerpent3>(), NPC.whoAmI);
else if (segment == 7)
lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType<SeaSerpent4>(), NPC.whoAmI);
else if (segment == 8)
lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType<SeaSerpent5>(), NPC.whoAmI);
Main.npc[lol].realLife = NPC.whoAmI;
Main.npc[lol].ai[2] = (float)NPC.whoAmI;
Main.npc[lol].ai[1] = (float)Previous;
Main.npc[Previous].ai[0] = (float)lol;
NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0);
Previous = lol;
}
TailSpawned = true;
}
}
if (NPC.velocity.X < 0f)
NPC.spriteDirection = -1;
else if (NPC.velocity.X > 0f)
NPC.spriteDirection = 1;
if (Main.player[NPC.target].dead)
NPC.TargetClosest(false);
NPC.alpha -= 42;
if (NPC.alpha < 0)
NPC.alpha = 0;
if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 5600f)
{
NPC.TargetClosest(false);
if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 5600f)
NPC.active = false;
}
float currentSpeed = speed;
float currentTurnSpeed = turnSpeed;
Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f);
float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2);
float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2);
if (NPC.life > NPC.lifeMax * 0.99)
{
targetYDist += 300;
if (Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) < 250f)
{
if (NPC.velocity.X > 0f)
{
targetXDist = Main.player[NPC.target].Center.X + 300f;
}
else
{
targetXDist = Main.player[NPC.target].Center.X - 300f;
}
}
}
else
{
currentSpeed *= 1.5f;
currentTurnSpeed *= 1.5f;
}
float maxCurrentSpeed = currentSpeed * 1.3f;
float minCurrentSpeed = currentSpeed * 0.7f;
float speedCompare = NPC.velocity.Length();
if (speedCompare > 0f)
{
if (speedCompare > maxCurrentSpeed)
{
NPC.velocity.Normalize();
NPC.velocity *= maxCurrentSpeed;
}
else if (speedCompare < minCurrentSpeed)
{
NPC.velocity.Normalize();
NPC.velocity *= minCurrentSpeed;
}
}
targetXDist = (float)((int)(targetXDist / 16f) * 16);
targetYDist = (float)((int)(targetYDist / 16f) * 16);
segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16);
segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16);
targetXDist -= segmentPosition.X;
targetYDist -= segmentPosition.Y;
float targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist));
float absoluteTargetX = System.Math.Abs(targetXDist);
float absoluteTargetY = System.Math.Abs(targetYDist);
float timeToReachTarget = currentSpeed / targetDistance;
targetXDist *= timeToReachTarget;
targetYDist *= timeToReachTarget;
if ((NPC.velocity.X > 0f && targetXDist > 0f) || (NPC.velocity.X < 0f && targetXDist < 0f) || (NPC.velocity.Y > 0f && targetYDist > 0f) || (NPC.velocity.Y < 0f && targetYDist < 0f))
{
if (NPC.velocity.X < targetXDist)
{
NPC.velocity.X = NPC.velocity.X + currentTurnSpeed;
}
else
{
if (NPC.velocity.X > targetXDist)
{
NPC.velocity.X = NPC.velocity.X - currentTurnSpeed;
}
}
if (NPC.velocity.Y < targetYDist)
{
NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed;
}
else
{
if (NPC.velocity.Y > targetYDist)
{
NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed;
}
}
if ((double)System.Math.Abs(targetYDist) < (double)currentSpeed * 0.2 && ((NPC.velocity.X > 0f && targetXDist < 0f) || (NPC.velocity.X < 0f && targetXDist > 0f)))
{
if (NPC.velocity.Y > 0f)
{
NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed * 2f;
}
else
{
NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed * 2f;
}
}
if ((double)System.Math.Abs(targetXDist) < (double)currentSpeed * 0.2 && ((NPC.velocity.Y > 0f && targetYDist < 0f) || (NPC.velocity.Y < 0f && targetYDist > 0f)))
{
if (NPC.velocity.X > 0f)
{
NPC.velocity.X = NPC.velocity.X + currentTurnSpeed * 2f; //changed from 2
}
else
{
NPC.velocity.X = NPC.velocity.X - currentTurnSpeed * 2f; //changed from 2
}
}
}
else
{
if (absoluteTargetX > absoluteTargetY)
{
if (NPC.velocity.X < targetXDist)
{
NPC.velocity.X = NPC.velocity.X + currentTurnSpeed * 1.1f; //changed from 1.1
}
else if (NPC.velocity.X > targetXDist)
{
NPC.velocity.X = NPC.velocity.X - currentTurnSpeed * 1.1f; //changed from 1.1
}
if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)currentSpeed * 0.5)
{
if (NPC.velocity.Y > 0f)
{
NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed;
}
else
{
NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed;
}
}
}
else
{
if (NPC.velocity.Y < targetYDist)
{
NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed * 1.1f;
}
else if (NPC.velocity.Y > targetYDist)
{
NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed * 1.1f;
}
if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)currentSpeed * 0.5)
{
if (NPC.velocity.X > 0f)
{
NPC.velocity.X = NPC.velocity.X + currentTurnSpeed;
}
else
{
NPC.velocity.X = NPC.velocity.X - currentTurnSpeed;
}
}
}
}
NPC.rotation = (float)System.Math.Atan2((double)NPC.velocity.Y, (double)NPC.velocity.X) + 1.57f;
}
public override float SpawnChance(NPCSpawnInfo spawnInfo)
{
if (Main.hardMode && spawnInfo.Player.Calamity().ZoneSunkenSea && spawnInfo.Water &&
!NPC.AnyNPCs(ModContent.NPCType<SeaSerpent1>()) && !spawnInfo.Player.Calamity().clamity && !spawnInfo.PlayerSafe)
return SpawnCondition.CaveJellyfish.Chance * 0.3f;
return 0f;
}
public override void ModifyNPCLoot(NPCLoot npcLoot) => npcLoot.Add(ModContent.ItemType<Serpentine>(), 4);
public override void HitEffect(NPC.HitInfo hit)
{
for (int k = 0; k < 3; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Obsidian, hit.HitDirection, -1f, 0, default, 1f);
}
if (NPC.life <= 0)
{
for (int k = 0; k < 10; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Obsidian, hit.HitDirection, -1f, 0, default, 1f);
}
if (Main.netMode != NetmodeID.Server)
{
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("SeaSerpentGore1").Type, 1f);
}
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 730 B

+147
View File
@@ -0,0 +1,147 @@
using CalamityMod.Items.Placeables.Banners;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
namespace CalamityMod.NPCs.SunkenSea
{
public class SeaSerpent2 : ModNPC
{
public float speed = 6f;
public float turnSpeed = 0.125f;
public override LocalizedText DisplayName => CalamityUtils.GetText("NPCs.SeaSerpent1.DisplayName");
public override void SetStaticDefaults()
{
this.HideFromBestiary();
}
public override void SetDefaults()
{
NPC.damage = 40;
NPC.width = 24; //42
NPC.height = 16; //24
NPC.defense = 20;
NPC.lifeMax = 3000;
NPC.aiStyle = -1; //new
AIType = -1; //new
NPC.knockBackResist = 0f;
NPC.alpha = 255;
NPC.behindTiles = true;
NPC.noGravity = true;
NPC.noTileCollide = true;
NPC.HitSound = SoundID.NPCHit1;
NPC.DeathSound = SoundID.NPCDeath1;
NPC.netAlways = true;
NPC.dontCountMe = true;
NPC.chaseable = false;
Banner = ModContent.NPCType<SeaSerpent1>();
BannerItem = ModContent.ItemType<SeaSerpentBanner>();
NPC.Calamity().VulnerableToHeat = false;
NPC.Calamity().VulnerableToSickness = true;
NPC.Calamity().VulnerableToElectricity = true;
NPC.Calamity().VulnerableToWater = false;
}
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
{
return false;
}
public override void AI()
{
// Avoid cheap bullshit
NPC.damage = 0;
Lighting.AddLight(NPC.Center, (255 - NPC.alpha) * 0f / 255f, (255 - NPC.alpha) * 0.30f / 255f, (255 - NPC.alpha) * 0.30f / 255f);
if (NPC.ai[2] > 0f)
NPC.realLife = (int)NPC.ai[2];
// Check if other segments are still alive, if not, die
bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType<SeaSerpent1>());
if (!shouldDespawn)
{
if (NPC.ai[1] <= 0f)
shouldDespawn = true;
else if (Main.npc[(int)NPC.ai[1]].life <= 0)
shouldDespawn = true;
}
if (shouldDespawn)
{
NPC.life = 0;
NPC.HitEffect(0, 10.0);
NPC.checkDead();
NPC.active = false;
}
if (Main.npc[(int)NPC.ai[1]].alpha < 128)
{
NPC.alpha -= 42;
if (NPC.alpha < 0)
NPC.alpha = 0;
}
Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f);
float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2);
float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2);
targetXDist = (float)((int)(targetXDist / 16f) * 16);
targetYDist = (float)((int)(targetYDist / 16f) * 16);
segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16);
segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16);
targetXDist -= segmentPosition.X;
targetYDist -= segmentPosition.Y;
float targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist));
if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length)
{
try
{
segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f);
targetXDist = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X;
targetYDist = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y;
}
catch
{
}
NPC.rotation = (float)System.Math.Atan2((double)targetYDist, (double)targetXDist) + 1.57f;
targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist));
int segmentWidth = NPC.width;
targetDistance = (targetDistance - (float)segmentWidth) / targetDistance;
targetXDist *= targetDistance;
targetYDist *= targetDistance;
NPC.velocity = Vector2.Zero;
NPC.position.X = NPC.position.X + targetXDist;
NPC.position.Y = NPC.position.Y + targetYDist;
if (targetXDist < 0f)
NPC.spriteDirection = -1;
else if (targetXDist > 0f)
NPC.spriteDirection = 1;
}
}
public override bool CheckActive()
{
return false;
}
public override void HitEffect(NPC.HitInfo hit)
{
for (int k = 0; k < 3; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Obsidian, hit.HitDirection, -1f, 0, default, 1f);
}
if (NPC.life <= 0)
{
for (int k = 0; k < 10; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Obsidian, hit.HitDirection, -1f, 0, default, 1f);
}
if (Main.netMode != NetmodeID.Server)
{
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("SeaSerpentGore2").Type, 1f);
}
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 613 B

+145
View File
@@ -0,0 +1,145 @@
using CalamityMod.Items.Placeables.Banners;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
namespace CalamityMod.NPCs.SunkenSea
{
public class SeaSerpent3 : ModNPC
{
public override LocalizedText DisplayName => CalamityUtils.GetText("NPCs.SeaSerpent1.DisplayName");
public override void SetStaticDefaults()
{
this.HideFromBestiary();
}
public override void SetDefaults()
{
NPC.damage = 40;
NPC.width = 24; //42
NPC.height = 16; //24
NPC.defense = 20;
NPC.lifeMax = 3000;
NPC.aiStyle = -1; //new
AIType = -1; //new
NPC.knockBackResist = 0f;
NPC.alpha = 255;
NPC.behindTiles = true;
NPC.noGravity = true;
NPC.noTileCollide = true;
NPC.HitSound = SoundID.NPCHit1;
NPC.DeathSound = SoundID.NPCDeath1;
NPC.netAlways = true;
NPC.dontCountMe = true;
NPC.chaseable = false;
Banner = ModContent.NPCType<SeaSerpent1>();
BannerItem = ModContent.ItemType<SeaSerpentBanner>();
NPC.Calamity().VulnerableToHeat = false;
NPC.Calamity().VulnerableToSickness = true;
NPC.Calamity().VulnerableToElectricity = true;
NPC.Calamity().VulnerableToWater = false;
}
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
{
return false;
}
public override void AI()
{
// Avoid cheap bullshit
NPC.damage = 0;
Lighting.AddLight(NPC.Center, (255 - NPC.alpha) * 0f / 255f, (255 - NPC.alpha) * 0.30f / 255f, (255 - NPC.alpha) * 0.30f / 255f);
if (NPC.ai[2] > 0f)
NPC.realLife = (int)NPC.ai[2];
// Check if other segments are still alive, if not, die
bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType<SeaSerpent1>());
if (!shouldDespawn)
{
if (NPC.ai[1] <= 0f)
shouldDespawn = true;
else if (Main.npc[(int)NPC.ai[1]].life <= 0)
shouldDespawn = true;
}
if (shouldDespawn)
{
NPC.life = 0;
NPC.HitEffect(0, 10.0);
NPC.checkDead();
NPC.active = false;
}
if (Main.npc[(int)NPC.ai[1]].alpha < 128)
{
NPC.alpha -= 42;
if (NPC.alpha < 0)
NPC.alpha = 0;
}
Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f);
float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2);
float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2);
targetXDist = (float)((int)(targetXDist / 16f) * 16);
targetYDist = (float)((int)(targetYDist / 16f) * 16);
segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16);
segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16);
targetXDist -= segmentPosition.X;
targetYDist -= segmentPosition.Y;
float targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist));
if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length)
{
try
{
segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f);
targetXDist = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X;
targetYDist = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y;
}
catch
{
}
NPC.rotation = (float)System.Math.Atan2((double)targetYDist, (double)targetXDist) + 1.57f;
targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist));
int segmentWidth = NPC.width;
targetDistance = (targetDistance - (float)segmentWidth) / targetDistance;
targetXDist *= targetDistance;
targetYDist *= targetDistance;
NPC.velocity = Vector2.Zero;
NPC.position.X = NPC.position.X + targetXDist;
NPC.position.Y = NPC.position.Y + targetYDist;
if (targetXDist < 0f)
NPC.spriteDirection = -1;
else if (targetXDist > 0f)
NPC.spriteDirection = 1;
}
}
public override bool CheckActive()
{
return false;
}
public override void HitEffect(NPC.HitInfo hit)
{
for (int k = 0; k < 3; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Obsidian, hit.HitDirection, -1f, 0, default, 1f);
}
if (NPC.life <= 0)
{
for (int k = 0; k < 10; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Obsidian, hit.HitDirection, -1f, 0, default, 1f);
}
if (Main.netMode != NetmodeID.Server)
{
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("SeaSerpentGore3").Type, 1f);
}
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 466 B

+145
View File
@@ -0,0 +1,145 @@
using CalamityMod.Items.Placeables.Banners;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
namespace CalamityMod.NPCs.SunkenSea
{
public class SeaSerpent4 : ModNPC
{
public override LocalizedText DisplayName => CalamityUtils.GetText("NPCs.SeaSerpent1.DisplayName");
public override void SetStaticDefaults()
{
this.HideFromBestiary();
}
public override void SetDefaults()
{
NPC.damage = 30;
NPC.width = 28; //42
NPC.height = 24; //34
NPC.defense = 20;
NPC.lifeMax = 3000;
NPC.aiStyle = -1; //new
AIType = -1; //new
NPC.knockBackResist = 0f;
NPC.alpha = 255;
NPC.behindTiles = true;
NPC.noGravity = true;
NPC.noTileCollide = true;
NPC.HitSound = SoundID.NPCHit1;
NPC.DeathSound = SoundID.NPCDeath1;
NPC.netAlways = true;
NPC.dontCountMe = true;
NPC.chaseable = false;
Banner = ModContent.NPCType<SeaSerpent1>();
BannerItem = ModContent.ItemType<SeaSerpentBanner>();
NPC.Calamity().VulnerableToHeat = false;
NPC.Calamity().VulnerableToSickness = true;
NPC.Calamity().VulnerableToElectricity = true;
NPC.Calamity().VulnerableToWater = false;
}
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
{
return false;
}
public override void AI()
{
// Avoid cheap bullshit
NPC.damage = 0;
Lighting.AddLight(NPC.Center, (255 - NPC.alpha) * 0f / 255f, (255 - NPC.alpha) * 0.30f / 255f, (255 - NPC.alpha) * 0.30f / 255f);
if (NPC.ai[2] > 0f)
NPC.realLife = (int)NPC.ai[2];
// Check if other segments are still alive, if not, die
bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType<SeaSerpent1>());
if (!shouldDespawn)
{
if (NPC.ai[1] <= 0f)
shouldDespawn = true;
else if (Main.npc[(int)NPC.ai[1]].life <= 0)
shouldDespawn = true;
}
if (shouldDespawn)
{
NPC.life = 0;
NPC.HitEffect(0, 10.0);
NPC.checkDead();
NPC.active = false;
}
if (Main.npc[(int)NPC.ai[1]].alpha < 128)
{
NPC.alpha -= 42;
if (NPC.alpha < 0)
NPC.alpha = 0;
}
Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f);
float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2);
float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2);
targetXDist = (float)((int)(targetXDist / 16f) * 16);
targetYDist = (float)((int)(targetYDist / 16f) * 16);
segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16);
segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16);
targetXDist -= segmentPosition.X;
targetYDist -= segmentPosition.Y;
float targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist));
if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length)
{
try
{
segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f);
targetXDist = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X;
targetYDist = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y;
}
catch
{
}
NPC.rotation = (float)System.Math.Atan2((double)targetYDist, (double)targetXDist) + 1.57f;
targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist));
int segmentWidth = NPC.width;
targetDistance = (targetDistance - (float)segmentWidth) / targetDistance;
targetXDist *= targetDistance;
targetYDist *= targetDistance;
NPC.velocity = Vector2.Zero;
NPC.position.X = NPC.position.X + targetXDist;
NPC.position.Y = NPC.position.Y + targetYDist;
if (targetXDist < 0f)
NPC.spriteDirection = -1;
else if (targetXDist > 0f)
NPC.spriteDirection = 1;
}
}
public override bool CheckActive()
{
return false;
}
public override void HitEffect(NPC.HitInfo hit)
{
for (int k = 0; k < 3; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Obsidian, hit.HitDirection, -1f, 0, default, 1f);
}
if (NPC.life <= 0)
{
for (int k = 0; k < 10; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Obsidian, hit.HitDirection, -1f, 0, default, 1f);
}
if (Main.netMode != NetmodeID.Server)
{
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("SeaSerpentGore4").Type, 1f);
}
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 483 B

+145
View File
@@ -0,0 +1,145 @@
using CalamityMod.Items.Placeables.Banners;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
namespace CalamityMod.NPCs.SunkenSea
{
public class SeaSerpent5 : ModNPC
{
public override LocalizedText DisplayName => CalamityUtils.GetText("NPCs.SeaSerpent1.DisplayName");
public override void SetStaticDefaults()
{
this.HideFromBestiary();
}
public override void SetDefaults()
{
NPC.damage = 20;
NPC.width = 36; //42
NPC.height = 30; //40
NPC.defense = 30;
NPC.lifeMax = 3000;
NPC.aiStyle = -1; //new
AIType = -1; //new
NPC.knockBackResist = 0f;
NPC.alpha = 255;
NPC.behindTiles = true;
NPC.noGravity = true;
NPC.noTileCollide = true;
NPC.HitSound = SoundID.NPCHit1;
NPC.DeathSound = SoundID.NPCDeath1;
NPC.netAlways = true;
NPC.dontCountMe = true;
NPC.chaseable = false;
Banner = ModContent.NPCType<SeaSerpent1>();
BannerItem = ModContent.ItemType<SeaSerpentBanner>();
NPC.Calamity().VulnerableToHeat = false;
NPC.Calamity().VulnerableToSickness = true;
NPC.Calamity().VulnerableToElectricity = true;
NPC.Calamity().VulnerableToWater = false;
}
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
{
return false;
}
public override void AI()
{
// Avoid cheap bullshit
NPC.damage = 0;
Lighting.AddLight(NPC.Center, (255 - NPC.alpha) * 0f / 255f, (255 - NPC.alpha) * 0.30f / 255f, (255 - NPC.alpha) * 0.30f / 255f);
if (NPC.ai[2] > 0f)
NPC.realLife = (int)NPC.ai[2];
// Check if other segments are still alive, if not, die
bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType<SeaSerpent1>());
if (!shouldDespawn)
{
if (NPC.ai[1] <= 0f)
shouldDespawn = true;
else if (Main.npc[(int)NPC.ai[1]].life <= 0)
shouldDespawn = true;
}
if (shouldDespawn)
{
NPC.life = 0;
NPC.HitEffect(0, 10.0);
NPC.checkDead();
NPC.active = false;
}
if (Main.npc[(int)NPC.ai[1]].alpha < 128)
{
NPC.alpha -= 42;
if (NPC.alpha < 0)
NPC.alpha = 0;
}
Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f);
float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2);
float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2);
targetXDist = (float)((int)(targetXDist / 16f) * 16);
targetYDist = (float)((int)(targetYDist / 16f) * 16);
segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16);
segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16);
targetXDist -= segmentPosition.X;
targetYDist -= segmentPosition.Y;
float targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist));
if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length)
{
try
{
segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f);
targetXDist = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X;
targetYDist = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y;
}
catch
{
}
NPC.rotation = (float)System.Math.Atan2((double)targetYDist, (double)targetXDist) + 1.57f;
targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist));
int segmentWidth = NPC.width;
targetDistance = (targetDistance - (float)segmentWidth) / targetDistance;
targetXDist *= targetDistance;
targetYDist *= targetDistance;
NPC.velocity = Vector2.Zero;
NPC.position.X = NPC.position.X + targetXDist;
NPC.position.Y = NPC.position.Y + targetYDist;
if (targetXDist < 0f)
NPC.spriteDirection = -1;
else if (targetXDist > 0f)
NPC.spriteDirection = 1;
}
}
public override bool CheckActive()
{
return false;
}
public override void HitEffect(NPC.HitInfo hit)
{
for (int k = 0; k < 3; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Obsidian, hit.HitDirection, -1f, 0, default, 1f);
}
if (NPC.life <= 0)
{
for (int k = 0; k < 10; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Obsidian, hit.HitDirection, -1f, 0, default, 1f);
}
if (Main.netMode != NetmodeID.Server)
{
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("SeaSerpentGore5").Type, 1f);
}
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 760 B

+1 -1
View File
@@ -147,7 +147,7 @@ namespace CalamityMod.NPCs.SunkenSea
/// </summary>
/// <param name="n">The NPC to evaluate.</param>
/// <returns><see langword="true"/> if the NPC is a valid target; otherwise, <see langword="false"/>.</returns>
protected virtual bool NPCSearchFilter(NPC n) => NPC.HasSight(n.Center) && Vector2.DistanceSquared(NPC.Center, n.Center) < 72900f && (PreyIDs.Contains(n.type) || PredatorIDs.Contains(n.type)) && !(n.type == ModContent.NPCType<PrismaticGuppy>() && n.alpha > 0);
protected virtual bool NPCSearchFilter(NPC n) => NPC.HasSight(n.Center) && Vector2.DistanceSquared(NPC.Center, n.Center) < 72900f && (PreyIDs.Contains(n.type) || PredatorIDs.Contains(n.type));
/// <summary>
/// Updates the current targets of this creature, including prey, predators, and players, based on detection logic.
-262
View File
@@ -1,262 +0,0 @@
using System.Collections.Generic;
using System.IO;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Graphics.Primitives;
using CalamityMod.NPCs.SunkenSea;
using CalamityMod.Sounds;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Audio;
using Terraria.DataStructures;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Enemy
{
public class GhostBellShock : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Enemy";
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
// Max aura size not accounting for babies
public static int MaxDefaultRadius => 160;
// How much does each baby boost the size of the aura
public static int RadiusBoostPerBaby => 10;
// Stores the ring points
public List<Vector2> points = [];
// Stores the bolts which connect from the center to the ring
public List<List<Vector2>> bolts = [];
// Stores the bolts which connect to babies
public List<List<Vector2>> jellyBolts = [];
// Generic timer
public ref float Timer => ref Projectile.ai[0];
// The jelly
public ref float Parent => ref Projectile.ai[1];
// Size of the aura
public ref float CurrentRadius => ref Projectile.ai[2];
// How many valid babies exist
public ref float CurrentBabies => ref Projectile.localAI[0];
public override void SetDefaults()
{
Projectile.width = MaxDefaultRadius * 2;
Projectile.height = MaxDefaultRadius * 2;
Projectile.hostile = true;
Projectile.ignoreWater = true;
Projectile.penetrate = -1;
Projectile.tileCollide = false;
Projectile.alpha = 255;
}
public override void ReceiveExtraAI(BinaryReader reader)
{
CurrentBabies = reader.ReadSingle();
}
public override void SendExtraAI(BinaryWriter writer)
{
writer.Write(CurrentBabies);
}
public override void OnSpawn(IEntitySource source)
{
RecalculateLists();
}
public override void AI()
{
bool validOwner = true;
int impactMoment = GhostBell.ElectrifyingPhaseDischarge;
NPC n = Main.npc[(int)Parent - 1];
if (n == null || !n.active || n.life < 0)
{
validOwner = false;
}
else
{
Projectile.Center = n.Center;
}
// Recalculate the prims to animate the lightning
if (Projectile.ai[0] % 5 == 0)
{
RecalculateLists();
}
// Scale the aura size. More babies increases the size of the aura
CurrentRadius = MathHelper.Lerp(0, MaxDefaultRadius + (CurrentBabies * RadiusBoostPerBaby), Utils.GetLerpValue(impactMoment, impactMoment + 10, Timer, true));
if (Timer == 0 && CurrentBabies > 0)
{
SoundEngine.PlaySound(CommonCalamitySounds.LightningSound with { Pitch = 1f }, Projectile.Center);
}
Timer++;
float pitch = (CurrentBabies > 0 && Timer < impactMoment) ? 1f : 0.4f;
if (Timer % 10 == 0 && (Timer >= impactMoment || CurrentBabies > 0))
{
SoundEngine.PlaySound(SoundID.DD2_LightningBugZap with { Pitch = pitch }, Projectile.Center);
}
if (Timer == impactMoment)
{
SoundEngine.PlaySound(CommonCalamitySounds.LightningSound, Projectile.Center);
}
if (CurrentBabies > 0 || Timer >= impactMoment)
Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(CurrentRadius, CurrentRadius), DustID.Electric);
// Become opaque
if (Timer < (40 + impactMoment) && validOwner)
{
if (Projectile.alpha > 0)
Projectile.alpha -= 20;
if (Projectile.alpha < 0)
Projectile.alpha = 0;
}
// become transparent and die
else
{
Projectile.alpha += 20;
if (Projectile.alpha >= 255)
{
Projectile.Kill();
}
}
}
public void RecalculateLists()
{
int ringPoints = 60; // How many times can the ring bend
int boltPoints = 12; // How many times can a bolt bend
int minimumBolts = 6; // Minimum number of bolts
int maximumBolts = 12; // Maximum number of bolts
//int minimumSplits = 0; // Minimum number of split bolts
//int maximumSplits = 2; // Maximum number of split bolts
points.Clear();
bolts.Clear();
jellyBolts.Clear();
for (int i = 0; i < ringPoints; i++)
{
// The radius of the aura. Randomized to be electricky
float rad = CurrentRadius + Main.rand.Next(-20, 20);
// Determinte the end point
// This creates a circle with the given radius
Vector2 end = Vector2.UnitY.RotatedBy(MathHelper.Lerp(0, MathHelper.TwoPi + MathHelper.ToRadians(15), (i + 1) / (float)ringPoints)) * rad;
points.Add(Projectile.Center + end);
// Randomly create more electric bolts that connect from the center to the ring
if (Main.rand.NextBool(ringPoints / Main.rand.Next(minimumBolts, maximumBolts)))
{
List<Vector2> bolt = [];
Vector2 start = Projectile.Center;
Vector2 boltEnd = Projectile.Center + end.RotatedByRandom(MathHelper.PiOver4);
bolt.Add(start);
for (int j = 0; j < boltPoints; j++)
{
Vector2 dest = Vector2.Lerp(start, boltEnd, (j + 1) / (float)boltPoints);
Vector2 dif = dest - start;
Vector2 newPoint = start + dif.RotatedByRandom(MathHelper.ToRadians(10));
bolt.Add(newPoint);
// UNUSED code that occasionally gives bolts their own smaller bolts
/*if (Main.rand.NextBool(boltPoints / Main.rand.Next(minimumSplits + 1, maximumSplits + 1)) && j > boltPoints / 2)
{
Main.NewText("Made a bolt");
List<Vector2> boltSplit = [];
boltSplit.Add(newPoint);
for (int k = 0; k < boltPoints; k++)
{
Vector2 destSplit = Vector2.Lerp(newPoint, Projectile.Center + end.RotatedBy(MathHelper.PiOver4), (k + 1) / (float)boltPoints);
Vector2 difSplit = destSplit - newPoint;
Vector2 newPointSplit = newPoint + difSplit.RotatedByRandom(MathHelper.ToRadians(10));
boltSplit.Add(newPointSplit);
}
boltSplit.Add(Projectile.Center + end.RotatedBy(MathHelper.PiOver4));
bolts.Add(boltSplit);
}*/
}
bolt.Add(boltEnd);
bolts.Add(bolt);
}
// Re-add the first point so that the trail can form a full circle
if (i == ringPoints - 1)
{
points.Add(points[0]);
}
}
// Count how many baby jellies exist and tie lightning to them
CurrentBabies = 0;
foreach (NPC n in Main.ActiveNPCs)
{
if (n.type != ModContent.NPCType<BabyGhostBell>())
continue;
if (n.Distance(Projectile.Center) > 400)
continue;
CurrentBabies++;
List<Vector2> bolt = [];
Vector2 start = Projectile.Center;
Vector2 boltEnd = n.Center;
bolt.Add(start);
for (int i = 0; i < boltPoints; i++)
{
Vector2 dest = Vector2.Lerp(start, boltEnd, (i + 1) / (float)boltPoints);
Vector2 dif = dest - start;
Vector2 newPoint = start + dif.RotatedByRandom(MathHelper.ToRadians(4));
bolt.Add(newPoint);
}
bolt.Add(boltEnd);
jellyBolts.Add(bolt);
}
Projectile.netUpdate = true;
}
public override void OnHitPlayer(Player target, Player.HurtInfo info)
{
if (info.Damage <= 0)
return;
target.AddBuff(ModContent.BuffType<StaticDischarge>(), 60);
}
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => Projectile.alpha <= 0 && CalamityUtils.CircularHitboxCollision(Projectile.Center, CurrentRadius, targetHitbox);
public override bool PreDraw(ref Color lightColor)
{
Main.spriteBatch.EnterShaderRegion();
GameShaders.Misc["CalamityMod:TeslaTrail"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/ZapTrail"));
float opacity = 0.6f;
float jellyOpacity = 0.2f;
if (Timer >= GhostBell.ElectrifyingPhaseDischarge)
{
// The aura
PrimitiveRenderer.RenderTrail(points, new((float completion, Vector2 vertexPos) => 4, (float completion, Vector2 vertexPos) => Color.Cyan * Projectile.Opacity * opacity, smoothen: true, shader: GameShaders.Misc["CalamityMod:TeslaTrail"]));
PrimitiveRenderer.RenderTrail(points, new((float completion, Vector2 vertexPos) => 1, (float completion, Vector2 vertexPos) => Color.White * Projectile.Opacity * opacity, smoothen: true, shader: GameShaders.Misc["CalamityMod:TeslaTrail"]));
// Bolts inside of the aura
for (int i = 0; i < bolts.Count; i++)
{
List<Vector2> boltPoints = bolts[i];
PrimitiveRenderer.RenderTrail(boltPoints, new((float completion, Vector2 vertexPos) => 3, (float completion, Vector2 vertexPos) => Color.Cyan * Projectile.Opacity * opacity, smoothen: true, shader: GameShaders.Misc["CalamityMod:TeslaTrail"]));
PrimitiveRenderer.RenderTrail(boltPoints, new((float completion, Vector2 vertexPos) => 1, (float completion, Vector2 vertexPos) => Color.White * Projectile.Opacity * opacity, smoothen: true, shader: GameShaders.Misc["CalamityMod:TeslaTrail"]));
}
}
// Harmless bolts connecting to babies
for (int i = 0; i < jellyBolts.Count; i++)
{
List<Vector2> boltPoints = jellyBolts[i];
PrimitiveRenderer.RenderTrail(boltPoints, new((float completion, Vector2 vertexPos) => 2, (float completion, Vector2 vertexPos) => Color.Cyan * jellyOpacity, smoothen: true, shader: GameShaders.Misc["CalamityMod:TeslaTrail"]));
PrimitiveRenderer.RenderTrail(boltPoints, new((float completion, Vector2 vertexPos) => 1, (float completion, Vector2 vertexPos) => Color.White * jellyOpacity, smoothen: true, shader: GameShaders.Misc["CalamityMod:TeslaTrail"]));
}
Main.spriteBatch.ExitShaderRegion();
return false;
}
}
}
-51
View File
@@ -1142,13 +1142,6 @@ namespace CalamityMod.Systems
#endregion
#region Seafood Dinner
r = Recipe.Create(ItemID.SeafoodDinner);
r.AddIngredient<PrismaticGuppyRadiantItem>(); // Consistency would be 2, but considering you need only 1 for Golden Delight, I'm leaving this at 1
r.AddTile(TileID.CookingPots);
r.Register();
r.SortAfterFirstRecipesOf(ItemID.SeafoodDinner);
r.DisableDecraft();
r = Recipe.Create(ItemID.SeafoodDinner);
r.AddIngredient<AldebaranAlewife>(2);
r.AddTile(TileID.CookingPots);
@@ -1185,50 +1178,6 @@ namespace CalamityMod.Systems
r.DisableDecraft();
#endregion
#region Golden Delight
r = Recipe.Create(ItemID.GoldenDelight);
r.AddIngredient<PrismaticGuppyGoldItem>();
r.AddTile(TileID.CookingPots);
r.Register();
r.SortAfterFirstRecipesOf(ItemID.GoldenDelight);
r.DisableDecraft();
r = Recipe.Create(ItemID.GoldenDelight);
r.AddIngredient<BabyGhostBellGoldItem>();
r.AddTile(TileID.CookingPots);
r.Register();
r.SortAfterFirstRecipesOf(ItemID.GoldenDelight);
r.DisableDecraft();
r = Recipe.Create(ItemID.GoldenDelight);
r.AddIngredient<ProbesnoutGoldItem>();
r.AddTile(TileID.CookingPots);
r.Register();
r.SortAfterFirstRecipesOf(ItemID.GoldenDelight);
r.DisableDecraft();
r = Recipe.Create(ItemID.GoldenDelight);
r.AddIngredient<PolypPanaseaGoldItem>();
r.AddTile(TileID.CookingPots);
r.Register();
r.SortAfterFirstRecipesOf(ItemID.GoldenDelight);
r.DisableDecraft();
r = Recipe.Create(ItemID.GoldenDelight);
r.AddIngredient<SeaMinnowGoldItem>();
r.AddTile(TileID.CookingPots);
r.Register();
r.SortAfterFirstRecipesOf(ItemID.GoldenDelight);
r.DisableDecraft();
r = Recipe.Create(ItemID.GoldenDelight);
r.AddIngredient<AlphaSeaMinnowGoldItem>();
r.AddTile(TileID.CookingPots);
r.Register();
r.SortAfterFirstRecipesOf(ItemID.GoldenDelight);
r.DisableDecraft();
#endregion
r = Recipe.Create(ItemID.BowlofSoup);
r.AddIngredient(ItemID.Mushroom);
r.AddIngredient<SeaMinnowItem>();
+1 -1
View File
@@ -391,7 +391,7 @@ namespace CalamityMod.Tiles
npc = NPCType<SeaMinnow>();
break;
case 106:
npc = NPCType<SandProwler>();
npc = NPCType<SeaSerpent1>();
break;
/*case 107:
npc = NPCType<Unused>(); - Formerly Giant Clam
+6 -2
View File
@@ -326,13 +326,17 @@ namespace CalamityMod
{ ModContent.NPCType<MicrobialCluster>(), sulphur },
{ ModContent.NPCType<Trasher>(), sulphur },
{ ModContent.NPCType<BlindedAngler>(), sunkenSea },
{ ModContent.NPCType<Clam>(), sunkenSea },
{ ModContent.NPCType<EutrophicRay>(), sunkenSea },
{ ModContent.NPCType<GhostBell>(), sunkenSea },
{ ModContent.NPCType<GiantClam>(), sunkenSea },
{ ModContent.NPCType<PrismBack>(), sunkenSea },
{ ModContent.NPCType<SandProwler>(), sunkenSea },
{ ModContent.NPCType<SandProwlerNested>(), sunkenSea },
{ ModContent.NPCType<SeaSerpent1>(), sunkenSea },
{ ModContent.NPCType<SeaSerpent2>(), sunkenSea },
{ ModContent.NPCType<SeaSerpent3>(), sunkenSea },
{ ModContent.NPCType<SeaSerpent4>(), sunkenSea },
{ ModContent.NPCType<SeaSerpent5>(), sunkenSea },
{ ModContent.NPCType<BabyCannonballJellyfish>(), abyss },
{ ModContent.NPCType<CannonballJellyfish>(), abyss },