256 lines
9.9 KiB
C#
256 lines
9.9 KiB
C#
using CalamityMod.World;
|
|
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.NPCs.StormWeaver
|
|
{
|
|
public class StormWeaverBody : ModNPC
|
|
{
|
|
private int spawn = 0;
|
|
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Storm Weaver");
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
npc.damage = 100;
|
|
npc.npcSlots = 5f;
|
|
npc.width = 40;
|
|
npc.height = 40;
|
|
npc.defense = 0;
|
|
CalamityGlobalNPC global = npc.Calamity();
|
|
global.DR = 0.999999f;
|
|
global.unbreakableDR = true;
|
|
npc.lifeMax = 20000;
|
|
Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic");
|
|
if (calamityModMusic != null)
|
|
music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/ScourgeofTheUniverse");
|
|
else
|
|
music = MusicID.Boss3;
|
|
if (CalamityWorld.DoGSecondStageCountdown <= 0)
|
|
{
|
|
if (calamityModMusic != null)
|
|
music = calamityModMusic.GetSoundSlot(SoundType.Music, "Sounds/Music/Weaver");
|
|
else
|
|
music = MusicID.Boss3;
|
|
npc.lifeMax = 100000;
|
|
}
|
|
if (CalamityWorld.bossRushActive)
|
|
{
|
|
npc.lifeMax = 170000;
|
|
}
|
|
double HPBoost = (double)Config.BossHealthPercentageBoost * 0.01;
|
|
npc.lifeMax += (int)((double)npc.lifeMax * HPBoost);
|
|
npc.aiStyle = -1;
|
|
aiType = -1;
|
|
npc.knockBackResist = 0f;
|
|
npc.alpha = 255;
|
|
npc.boss = true;
|
|
npc.behindTiles = true;
|
|
npc.noGravity = true;
|
|
npc.noTileCollide = true;
|
|
npc.canGhostHeal = false;
|
|
npc.HitSound = SoundID.NPCHit4;
|
|
npc.DeathSound = SoundID.NPCDeath14;
|
|
npc.netAlways = true;
|
|
npc.chaseable = false;
|
|
for (int k = 0; k < npc.buffImmune.Length; k++)
|
|
{
|
|
npc.buffImmune[k] = true;
|
|
}
|
|
npc.dontCountMe = true;
|
|
}
|
|
|
|
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
if (npc.defense < 99999 && CalamityWorld.DoGSecondStageCountdown <= 0)
|
|
npc.defense = 99999;
|
|
else
|
|
npc.defense = 0;
|
|
|
|
Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f);
|
|
if (npc.ai[3] > 0f)
|
|
{
|
|
npc.realLife = (int)npc.ai[3];
|
|
}
|
|
if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead)
|
|
{
|
|
npc.TargetClosest(true);
|
|
}
|
|
npc.velocity.Length();
|
|
if (npc.velocity.X < 0f)
|
|
{
|
|
npc.spriteDirection = -1;
|
|
}
|
|
else if (npc.velocity.X > 0f)
|
|
{
|
|
npc.spriteDirection = 1;
|
|
}
|
|
bool flag = false;
|
|
if (npc.ai[1] <= 0f)
|
|
{
|
|
flag = true;
|
|
}
|
|
else if (Main.npc[(int)npc.ai[1]].life <= 0)
|
|
{
|
|
flag = true;
|
|
}
|
|
if (flag)
|
|
{
|
|
npc.life = 0;
|
|
npc.HitEffect(0, 10.0);
|
|
npc.checkDead();
|
|
}
|
|
if (Main.npc[(int)npc.ai[1]].alpha < 128)
|
|
{
|
|
if (npc.alpha != 0)
|
|
{
|
|
for (int num934 = 0; num934 < 2; num934++)
|
|
{
|
|
int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 182, 0f, 0f, 100, default, 2f);
|
|
Main.dust[num935].noGravity = true;
|
|
Main.dust[num935].noLight = true;
|
|
}
|
|
}
|
|
npc.alpha -= 42;
|
|
if (npc.alpha < 0)
|
|
{
|
|
npc.alpha = 0;
|
|
}
|
|
}
|
|
if (Main.player[npc.target].dead)
|
|
{
|
|
npc.TargetClosest(false);
|
|
}
|
|
Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
|
|
float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2);
|
|
float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2);
|
|
num191 = (float)((int)(num191 / 16f) * 16);
|
|
num192 = (float)((int)(num192 / 16f) * 16);
|
|
vector18.X = (float)((int)(vector18.X / 16f) * 16);
|
|
vector18.Y = (float)((int)(vector18.Y / 16f) * 16);
|
|
num191 -= vector18.X;
|
|
num192 -= vector18.Y;
|
|
float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192));
|
|
if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length)
|
|
{
|
|
try
|
|
{
|
|
vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
|
|
num191 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - vector18.X;
|
|
num192 = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y;
|
|
} catch
|
|
{
|
|
}
|
|
npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f;
|
|
num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192));
|
|
int num194 = npc.width;
|
|
num193 = (num193 - (float)num194) / num193;
|
|
num191 *= num193;
|
|
num192 *= num193;
|
|
npc.velocity = Vector2.Zero;
|
|
npc.position.X = npc.position.X + num191;
|
|
npc.position.Y = npc.position.Y + num192;
|
|
if (num191 < 0f)
|
|
{
|
|
npc.spriteDirection = -1;
|
|
}
|
|
else if (num191 > 0f)
|
|
{
|
|
npc.spriteDirection = 1;
|
|
}
|
|
}
|
|
}
|
|
|
|
public override bool CanHitPlayer(Player target, ref int cooldownSlot)
|
|
{
|
|
cooldownSlot = 1;
|
|
return true;
|
|
}
|
|
|
|
public override bool CheckActive()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public override bool PreNPCLoot()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
|
|
{
|
|
if (projectile.penetrate == -1 && !projectile.minion)
|
|
{
|
|
projectile.penetrate = 1;
|
|
}
|
|
else if (projectile.penetrate >= 1)
|
|
{
|
|
projectile.penetrate = 1;
|
|
}
|
|
}
|
|
|
|
public override void HitEffect(int hitDirection, double damage)
|
|
{
|
|
if (npc.life <= 0)
|
|
{
|
|
Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmor2"), 1f);
|
|
Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmor3"), 1f);
|
|
Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmor4"), 1f);
|
|
npc.position.X = npc.position.X + (float)(npc.width / 2);
|
|
npc.position.Y = npc.position.Y + (float)(npc.height / 2);
|
|
npc.width = 30;
|
|
npc.height = 30;
|
|
npc.position.X = npc.position.X - (float)(npc.width / 2);
|
|
npc.position.Y = npc.position.Y - (float)(npc.height / 2);
|
|
for (int num621 = 0; num621 < 20; num621++)
|
|
{
|
|
int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 173, 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 + (float)Main.rand.Next(10) * 0.1f;
|
|
}
|
|
}
|
|
for (int num623 = 0; num623 < 40; num623++)
|
|
{
|
|
int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 173, 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, 173, 0f, 0f, 100, default, 2f);
|
|
Main.dust[num624].velocity *= 2f;
|
|
}
|
|
}
|
|
if (NPC.CountNPCS(ModContent.NPCType<StasisProbe>()) < 3)
|
|
{
|
|
if (npc.life > 0 && Main.netMode != NetmodeID.MultiplayerClient && spawn == 0 && Main.rand.NextBool(15))
|
|
{
|
|
spawn = 1;
|
|
int num660 = NPC.NewNPC((int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), ModContent.NPCType<StasisProbe>(), 0, 0f, 0f, 0f, 0f, 255);
|
|
if (Main.netMode == NetmodeID.Server)
|
|
{
|
|
NetMessage.SendData(23, -1, -1, null, num660, 0f, 0f, 0f, 0, 0, 0);
|
|
}
|
|
npc.netUpdate = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
|
|
{
|
|
npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale);
|
|
npc.damage = (int)(npc.damage * 0.85f);
|
|
}
|
|
}
|
|
}
|