124 lines
4.2 KiB
C#
124 lines
4.2 KiB
C#
using CalamityMod.World;
|
|
using Microsoft.Xna.Framework;
|
|
using System;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.NPCs.Cryogen
|
|
{
|
|
public class Cryocore2 : ModNPC
|
|
{
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Cryocore");
|
|
Main.npcFrameCount[npc.type] = 6;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
npc.damage = 40;
|
|
npc.width = 66;
|
|
npc.height = 66;
|
|
npc.defense = 10;
|
|
npc.lifeMax = 300;
|
|
if (CalamityWorld.bossRushActive)
|
|
{
|
|
npc.lifeMax = 40000;
|
|
}
|
|
npc.aiStyle = -1;
|
|
aiType = -1;
|
|
npc.knockBackResist = CalamityWorld.bossRushActive ? 0f : 0.5f;
|
|
npc.noGravity = true;
|
|
npc.noTileCollide = true;
|
|
npc.canGhostHeal = false;
|
|
npc.HitSound = SoundID.NPCHit5;
|
|
npc.DeathSound = SoundID.NPCDeath15;
|
|
npc.coldDamage = true;
|
|
}
|
|
|
|
public override void FindFrame(int frameHeight)
|
|
{
|
|
npc.frameCounter += 0.15f;
|
|
npc.frameCounter %= Main.npcFrameCount[npc.type];
|
|
int frame = (int)npc.frameCounter;
|
|
npc.frame.Y = frame * frameHeight;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
bool revenge = CalamityWorld.revenge;
|
|
Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.01f, 0.25f, 0.25f);
|
|
npc.TargetClosest(true);
|
|
float num1372 = revenge ? 14f : 12f;
|
|
if (CalamityWorld.bossRushActive)
|
|
num1372 = 28f;
|
|
Vector2 vector167 = new Vector2(npc.Center.X + (float)(npc.direction * 20), npc.Center.Y + 6f);
|
|
float num1373 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector167.X;
|
|
float num1374 = Main.player[npc.target].Center.Y - vector167.Y;
|
|
float num1375 = (float)Math.Sqrt((double)(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;
|
|
}
|
|
npc.rotation += (float)npc.direction * 0.3f;
|
|
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;
|
|
}
|
|
npc.rotation = npc.velocity.X * 0.15f;
|
|
}
|
|
|
|
public override void OnHitPlayer(Player player, int damage, bool crit)
|
|
{
|
|
player.AddBuff(BuffID.Frostburn, 90, true);
|
|
player.AddBuff(BuffID.Chilled, 60, true);
|
|
}
|
|
|
|
public override bool PreNPCLoot()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public override void HitEffect(int hitDirection, double damage)
|
|
{
|
|
for (int k = 0; k < 5; k++)
|
|
{
|
|
Dust.NewDust(npc.position, npc.width, npc.height, 67, hitDirection, -1f, 0, default, 1f);
|
|
}
|
|
if (npc.life <= 0)
|
|
{
|
|
for (int k = 0; k < 20; k++)
|
|
{
|
|
Dust.NewDust(npc.position, npc.width, npc.height, 67, hitDirection, -1f, 0, default, 1f);
|
|
}
|
|
Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Cryocore2"), 1f);
|
|
}
|
|
}
|
|
}
|
|
}
|