2 - Fixed Skeletron Prime charge speed bug. 3 - Fixed stat config bugs with Cal Clone phase 2, Dragonfolly and Yharon phase 2.
223 lines
7.3 KiB
C#
223 lines
7.3 KiB
C#
using CalamityMod.Dusts;
|
|
using CalamityMod.Events;
|
|
using CalamityMod.World;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using System;
|
|
using System.IO;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.NPCs.Signus
|
|
{
|
|
public class SignusBomb : ModNPC
|
|
{
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Cosmic Mine");
|
|
NPCID.Sets.TrailingMode[npc.type] = 1;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
npc.GetNPCDamage();
|
|
npc.width = 30;
|
|
npc.height = 30;
|
|
npc.lifeMax = 6000;
|
|
npc.aiStyle = -1;
|
|
aiType = -1;
|
|
npc.knockBackResist = 0f;
|
|
npc.noGravity = true;
|
|
npc.noTileCollide = true;
|
|
npc.dontTakeDamage = true;
|
|
npc.HitSound = SoundID.NPCHit53;
|
|
npc.DeathSound = SoundID.NPCDeath44;
|
|
}
|
|
|
|
public override void SendExtraAI(BinaryWriter writer)
|
|
{
|
|
writer.Write(npc.dontTakeDamage);
|
|
}
|
|
|
|
public override void ReceiveExtraAI(BinaryReader reader)
|
|
{
|
|
npc.dontTakeDamage = reader.ReadBoolean();
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
if (CalamityGlobalNPC.signus < 0 || !Main.npc[CalamityGlobalNPC.signus].active)
|
|
{
|
|
npc.active = false;
|
|
npc.netUpdate = true;
|
|
return;
|
|
}
|
|
|
|
bool death = CalamityWorld.death || BossRushEvent.BossRushActive;
|
|
|
|
Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.7f, 0.2f, 1.1f);
|
|
|
|
npc.rotation = npc.velocity.X * 0.04f;
|
|
|
|
npc.TargetClosest(true);
|
|
Player player = Main.player[npc.target];
|
|
Vector2 vector = player.Center - npc.Center;
|
|
npc.ai[2] = vector.Length();
|
|
|
|
npc.damage = 0;
|
|
npc.ai[3] += 1f;
|
|
if (npc.ai[2] < 90f || npc.ai[3] >= 300f || npc.Calamity().newAI[0] > 0f)
|
|
{
|
|
npc.Calamity().newAI[0] += 1f;
|
|
npc.velocity *= 0.98f;
|
|
npc.dontTakeDamage = false;
|
|
npc.scale = MathHelper.Lerp(1f, 3f, npc.Calamity().newAI[0] / 45f);
|
|
|
|
if (npc.Calamity().newAI[0] >= 45f)
|
|
{
|
|
CheckDead();
|
|
npc.life = 0;
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
if (npc.ai[1] == 0f)
|
|
{
|
|
npc.scale -= 0.02f;
|
|
npc.alpha += 30;
|
|
if (npc.alpha >= 250)
|
|
{
|
|
npc.alpha = 255;
|
|
npc.ai[1] = 1f;
|
|
}
|
|
}
|
|
else if (npc.ai[1] == 1f)
|
|
{
|
|
npc.scale += 0.02f;
|
|
npc.alpha -= 30;
|
|
if (npc.alpha <= 0)
|
|
{
|
|
npc.alpha = 0;
|
|
npc.ai[1] = 0f;
|
|
}
|
|
}
|
|
|
|
float num1372 = death ? 16f : 14f;
|
|
Vector2 vector167 = new Vector2(npc.Center.X + (npc.direction * 20), npc.Center.Y + 6f);
|
|
float num1373 = player.position.X + player.width * 0.5f - vector167.X;
|
|
float num1374 = player.Center.Y - vector167.Y;
|
|
float num1375 = (float)Math.Sqrt(num1373 * num1373 + num1374 * num1374);
|
|
float num1376 = num1372 / num1375;
|
|
num1373 *= num1376;
|
|
num1374 *= num1376;
|
|
npc.ai[0] -= 1f;
|
|
if (num1375 < 200f || npc.ai[0] > 0f)
|
|
{
|
|
if (num1375 < 200f)
|
|
{
|
|
npc.ai[0] = 20f;
|
|
}
|
|
if (npc.velocity.X < 0f)
|
|
{
|
|
npc.direction = -1;
|
|
}
|
|
else
|
|
{
|
|
npc.direction = 1;
|
|
}
|
|
return;
|
|
}
|
|
|
|
npc.velocity.X = (npc.velocity.X * 50f + num1373) / 51f;
|
|
npc.velocity.Y = (npc.velocity.Y * 50f + num1374) / 51f;
|
|
if (num1375 < 350f)
|
|
{
|
|
npc.velocity.X = (npc.velocity.X * 10f + num1373) / 11f;
|
|
npc.velocity.Y = (npc.velocity.Y * 10f + num1374) / 11f;
|
|
}
|
|
if (num1375 < 300f)
|
|
{
|
|
npc.velocity.X = (npc.velocity.X * 7f + num1373) / 8f;
|
|
npc.velocity.Y = (npc.velocity.Y * 7f + num1374) / 8f;
|
|
}
|
|
}
|
|
|
|
public override Color? GetAlpha(Color drawColor)
|
|
{
|
|
return new Color(200, Main.DiscoG, 255, 0);
|
|
}
|
|
|
|
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
|
{
|
|
if (npc.Calamity().newAI[0] >= 45f)
|
|
return false;
|
|
|
|
SpriteEffects spriteEffects = SpriteEffects.None;
|
|
if (npc.spriteDirection == 1)
|
|
spriteEffects = SpriteEffects.FlipHorizontally;
|
|
|
|
Texture2D texture2D15 = Main.npcTexture[npc.type];
|
|
Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2);
|
|
Color color36 = Color.White;
|
|
float amount9 = 0.5f;
|
|
int num153 = 5;
|
|
|
|
if (CalamityConfig.Instance.Afterimages)
|
|
{
|
|
for (int num155 = 1; num155 < num153; num155 += 2)
|
|
{
|
|
Color color38 = lightColor;
|
|
color38 = Color.Lerp(color38, color36, amount9);
|
|
color38 = npc.GetAlpha(color38);
|
|
color38 *= (num153 - num155) / 15f;
|
|
Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition;
|
|
vector41 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f;
|
|
vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY);
|
|
spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f);
|
|
}
|
|
}
|
|
|
|
Vector2 vector43 = npc.Center - Main.screenPosition;
|
|
vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f;
|
|
vector43 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY);
|
|
spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f);
|
|
|
|
return false;
|
|
}
|
|
|
|
public override bool CheckDead()
|
|
{
|
|
Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 14);
|
|
npc.position.X = npc.position.X + (npc.width / 2);
|
|
npc.position.Y = npc.position.Y + (npc.height / 2);
|
|
npc.damage = npc.defDamage;
|
|
npc.width = npc.height = 256;
|
|
npc.position.X = npc.position.X - (npc.width / 2);
|
|
npc.position.Y = npc.position.Y - (npc.height / 2);
|
|
for (int num621 = 0; num621 < 10; num621++)
|
|
{
|
|
int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmolite, 0f, 0f, 100, default, 2f);
|
|
Main.dust[num622].velocity *= 3f;
|
|
if (Main.rand.NextBool(2))
|
|
{
|
|
Main.dust[num622].scale = 0.5f;
|
|
Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f;
|
|
}
|
|
Main.dust[num622].noGravity = true;
|
|
}
|
|
for (int num623 = 0; num623 < 20; num623++)
|
|
{
|
|
int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmolite, 0f, 0f, 100, default, 3f);
|
|
Main.dust[num624].noGravity = true;
|
|
Main.dust[num624].velocity *= 5f;
|
|
num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmolite, 0f, 0f, 100, default, 2f);
|
|
Main.dust[num624].velocity *= 2f;
|
|
Main.dust[num624].noGravity = true;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
}
|