sea serpent -> sand prowler
No files matched your search
@@ -275,9 +275,10 @@ PearlpodPink.DisplayName: Pearlpod
|
||||
PearlpodWhite.DisplayName: Pearlpod
|
||||
PolypPanasea.DisplayName: Polyp Panasea
|
||||
PrismBack.DisplayName: Prism-Back
|
||||
SandProwler.DisplayName: Sand Prowler
|
||||
SandProwlerNested.DisplayName: Sand Prowler
|
||||
SeaFloaty.DisplayName: Sea Floaty
|
||||
SeaMinnow.DisplayName: Sea Minnow
|
||||
SeaSerpent1.DisplayName: Sea Serpent
|
||||
BrimstoneHeart.DisplayName: Brimstone Heart
|
||||
SepulcherHead.DisplayName: Sepulcher
|
||||
SoulSeekerSupreme.DisplayName: Soul Seeker
|
||||
|
||||
@@ -0,0 +1,494 @@
|
||||
using CalamityMod.BiomeManagers;
|
||||
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 Terraria;
|
||||
using Terraria.GameContent;
|
||||
using Terraria.GameContent.Bestiary;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.ModLoader.Utilities;
|
||||
namespace CalamityMod.NPCs.SunkenSea
|
||||
{
|
||||
public class SandProwler : ModNPC
|
||||
{
|
||||
public const int maxLength = 9;
|
||||
public float speed = 3f;
|
||||
public float turnSpeed = 0.0625f;
|
||||
bool TailSpawned = false;
|
||||
#region Textures
|
||||
public static Texture2D BodySprite1;
|
||||
public static Texture2D BodySprite2;
|
||||
public static Texture2D BodySprite3;
|
||||
public static Texture2D BodySprite4;
|
||||
public static Texture2D BodySprite5;
|
||||
public static Texture2D BodySprite6;
|
||||
public static Texture2D BodySprite7;
|
||||
public static Texture2D TailSprite;
|
||||
#endregion
|
||||
public override string Texture => "CalamityMod/NPCs/SunkenSea/SandProwler1";
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0)
|
||||
{
|
||||
CustomTexturePath = "CalamityMod/ExtraTextures/Bestiary/SeaSerpent_Bestiary",
|
||||
PortraitPositionXOverride = 40,
|
||||
PortraitPositionYOverride = 20
|
||||
};
|
||||
value.Position.Y += 20;
|
||||
value.Position.X += 40;
|
||||
NPCID.Sets.NPCBestiaryDrawOffset[Type] = value;
|
||||
if (!Main.dedServ)
|
||||
{
|
||||
BodySprite1 = ModContent.Request<Texture2D>("CalamityMod/NPCs/SunkenSea/SandProwler2", AssetRequestMode.ImmediateLoad).Value;
|
||||
BodySprite2 = ModContent.Request<Texture2D>("CalamityMod/NPCs/SunkenSea/SandProwler3", AssetRequestMode.ImmediateLoad).Value;
|
||||
BodySprite3 = ModContent.Request<Texture2D>("CalamityMod/NPCs/SunkenSea/SandProwler4", AssetRequestMode.ImmediateLoad).Value;
|
||||
BodySprite4 = ModContent.Request<Texture2D>("CalamityMod/NPCs/SunkenSea/SandProwler5", AssetRequestMode.ImmediateLoad).Value;
|
||||
BodySprite5 = ModContent.Request<Texture2D>("CalamityMod/NPCs/SunkenSea/SandProwler6", AssetRequestMode.ImmediateLoad).Value;
|
||||
BodySprite6 = ModContent.Request<Texture2D>("CalamityMod/NPCs/SunkenSea/SandProwler7", AssetRequestMode.ImmediateLoad).Value;
|
||||
BodySprite7 = ModContent.Request<Texture2D>("CalamityMod/NPCs/SunkenSea/SandProwler8", AssetRequestMode.ImmediateLoad).Value;
|
||||
TailSprite = ModContent.Request<Texture2D>("CalamityMod/NPCs/SunkenSea/SandProwler9", AssetRequestMode.ImmediateLoad).Value;
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
NPC.damage = 50;
|
||||
NPC.width = 30;
|
||||
NPC.height = 24;
|
||||
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 bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
|
||||
{
|
||||
// only the head gets a healthbar
|
||||
return NPC.ai[3] == 0;
|
||||
}
|
||||
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
if (NPC.ai[3] == 0)
|
||||
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, 204, 0f, 0f, 150, default(Color), 0.3f);
|
||||
dust.fadeIn = 0.75f;
|
||||
dust.velocity *= 0.1f;
|
||||
dust.noLight = true;
|
||||
}
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
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
|
||||
break;
|
||||
case maxLength - 3:
|
||||
spriteUse = 6; // Body 6
|
||||
width = 14;
|
||||
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);
|
||||
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 void SegmentAI()
|
||||
{
|
||||
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 = true;
|
||||
for (int i = 0; i < Main.maxNPCs; i++)
|
||||
{
|
||||
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<SandProwler>())
|
||||
{
|
||||
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 = NPC.ai[3] == 1 ? (float)(Main.npc[(int)NPC.ai[1]].width / 2) : 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 float SpawnChance(NPCSpawnInfo spawnInfo)
|
||||
{
|
||||
if (Main.hardMode && spawnInfo.Player.Calamity().ZoneSunkenSea && 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 NPC.ai[3] == 0;
|
||||
}
|
||||
|
||||
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.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.netMode != NetmodeID.Server)
|
||||
{
|
||||
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;
|
||||
switch (NPC.ai[3])
|
||||
{
|
||||
case 1:
|
||||
segmentSprite = BodySprite1;
|
||||
break;
|
||||
case 2:
|
||||
segmentSprite = BodySprite2;
|
||||
break;
|
||||
case 3:
|
||||
segmentSprite = BodySprite3;
|
||||
break;
|
||||
case 4:
|
||||
segmentSprite = BodySprite4;
|
||||
break;
|
||||
case 5:
|
||||
segmentSprite = BodySprite5;
|
||||
break;
|
||||
case 6:
|
||||
segmentSprite = BodySprite6;
|
||||
break;
|
||||
case 7:
|
||||
segmentSprite = BodySprite7;
|
||||
break;
|
||||
case 8:
|
||||
segmentSprite = TailSprite;
|
||||
break;
|
||||
}
|
||||
SpriteEffects fx = NPC.direction == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
|
||||
spriteBatch.Draw(segmentSprite, NPC.position - Main.screenPosition, null, NPC.GetAlpha(drawColor), NPC.rotation, segmentSprite.Size(), NPC.scale, fx, 0f);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 471 B After Width: | Height: | Size: 471 B |
|
Before Width: | Height: | Size: 287 B After Width: | Height: | Size: 287 B |
|
Before Width: | Height: | Size: 318 B After Width: | Height: | Size: 318 B |
|
Before Width: | Height: | Size: 328 B After Width: | Height: | Size: 328 B |
|
Before Width: | Height: | Size: 345 B After Width: | Height: | Size: 345 B |
|
Before Width: | Height: | Size: 345 B After Width: | Height: | Size: 345 B |
|
Before Width: | Height: | Size: 242 B After Width: | Height: | Size: 242 B |
|
Before Width: | Height: | Size: 236 B After Width: | Height: | Size: 236 B |
|
Before Width: | Height: | Size: 366 B After Width: | Height: | Size: 366 B |
@@ -18,7 +18,7 @@ using Terraria.ModLoader.Utilities;
|
||||
|
||||
namespace CalamityMod.NPCs.SunkenSea
|
||||
{
|
||||
public class SeaSerpent1 : ModNPC
|
||||
public class SandProwlerNested : ModNPC
|
||||
{
|
||||
public bool PeekingOut;
|
||||
public bool HasChosenSpotToHideIn => SpotToHideIn != Vector2.Zero;
|
||||
@@ -49,6 +49,7 @@ namespace CalamityMod.NPCs.SunkenSea
|
||||
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/SandProwler1";
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
@@ -300,14 +301,10 @@ namespace CalamityMod.NPCs.SunkenSea
|
||||
return false;
|
||||
|
||||
Texture2D headTexture = ModContent.Request<Texture2D>(Texture).Value;
|
||||
Texture2D body1Texture = ModContent.Request<Texture2D>("CalamityMod/NPCs/SunkenSea/SeaSerpent2").Value;
|
||||
Texture2D body2Texture = ModContent.Request<Texture2D>("CalamityMod/NPCs/SunkenSea/SeaSerpent3").Value;
|
||||
Texture2D body3Texture = ModContent.Request<Texture2D>("CalamityMod/NPCs/SunkenSea/SeaSerpent4").Value;
|
||||
Texture2D body4Texture = ModContent.Request<Texture2D>("CalamityMod/NPCs/SunkenSea/SeaSerpent5").Value;
|
||||
Texture2D body5Texture = ModContent.Request<Texture2D>("CalamityMod/NPCs/SunkenSea/SeaSerpent6").Value;
|
||||
Texture2D body6Texture = ModContent.Request<Texture2D>("CalamityMod/NPCs/SunkenSea/SeaSerpent7").Value;
|
||||
Texture2D body7Texture = ModContent.Request<Texture2D>("CalamityMod/NPCs/SunkenSea/SeaSerpent8").Value;
|
||||
Texture2D tailTexture = ModContent.Request<Texture2D>("CalamityMod/NPCs/SunkenSea/SeaSerpent9").Value;
|
||||
Texture2D body1Texture = SandProwler.BodySprite1;
|
||||
Texture2D body2Texture = SandProwler.BodySprite2;
|
||||
Texture2D body3Texture = SandProwler.BodySprite3;
|
||||
Texture2D body4Texture = SandProwler.BodySprite4;
|
||||
|
||||
Vector2 idealDrawPosition = SpotToHideIn;
|
||||
Vector2 backOffset = (NPC.rotation - MathHelper.PiOver2).ToRotationVector2() * -18f;
|
||||
@@ -1,151 +0,0 @@
|
||||
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;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,149 +0,0 @@
|
||||
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;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,149 +0,0 @@
|
||||
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;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,149 +0,0 @@
|
||||
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;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -361,7 +361,7 @@ namespace CalamityMod.Tiles
|
||||
npc = NPCType<SeaMinnow>();
|
||||
break;
|
||||
case 106:
|
||||
npc = NPCType<SeaSerpent1>();
|
||||
npc = NPCType<SandProwlerNested>();
|
||||
break;
|
||||
case 108:
|
||||
npc = NPCType<Piggy>();
|
||||
|
||||
@@ -340,11 +340,8 @@ namespace CalamityMod
|
||||
{ ModContent.NPCType<GhostBell>(), sunkenSea },
|
||||
{ ModContent.NPCType<GiantClam>(), sunkenSea },
|
||||
{ ModContent.NPCType<PrismBack>(), sunkenSea },
|
||||
{ ModContent.NPCType<SeaSerpent1>(), sunkenSea },
|
||||
{ ModContent.NPCType<SeaSerpent2>(), sunkenSea },
|
||||
{ ModContent.NPCType<SeaSerpent3>(), sunkenSea },
|
||||
{ ModContent.NPCType<SeaSerpent4>(), sunkenSea },
|
||||
{ ModContent.NPCType<SeaSerpent5>(), sunkenSea },
|
||||
{ ModContent.NPCType<SandProwler>(), sunkenSea },
|
||||
{ ModContent.NPCType<SandProwlerNested>(), sunkenSea },
|
||||
|
||||
{ ModContent.NPCType<BabyCannonballJellyfish>(), abyss },
|
||||
{ ModContent.NPCType<CannonballJellyfish>(), abyss },
|
||||
|
||||