Files
CalamityModPublic/NPCs/DevourerofGods/DevourerofGodsBody2.cs
T

160 lines
5.8 KiB
C#

using CalamityMod.Buffs.DamageOverTime;
using Microsoft.Xna.Framework;
using System.IO;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.NPCs.DevourerofGods
{
public class DevourerofGodsBody2 : ModNPC
{
public int invinceTime = 180;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Cosmic Guardian");
}
public override void SetDefaults()
{
npc.damage = 130;
npc.npcSlots = 5f;
npc.width = 34;
npc.height = 34;
npc.defense = 60;
CalamityGlobalNPC global = npc.Calamity();
global.DR = 0.5f;
global.unbreakableDR = true;
npc.lifeMax = 100000;
npc.aiStyle = 6;
aiType = -1;
npc.knockBackResist = 0f;
npc.alpha = 255;
npc.behindTiles = true;
npc.noGravity = true;
npc.noTileCollide = true;
npc.canGhostHeal = false;
npc.HitSound = SoundID.NPCHit4;
npc.DeathSound = SoundID.NPCDeath14;
npc.netAlways = true;
for (int k = 0; k < npc.buffImmune.Length; k++)
{
npc.buffImmune[k] = true;
}
npc.dontCountMe = true;
}
public override void SendExtraAI(BinaryWriter writer)
{
writer.Write(invinceTime);
writer.Write(npc.dontTakeDamage);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
invinceTime = reader.ReadInt32();
npc.dontTakeDamage = reader.ReadBoolean();
}
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
{
return false;
}
public override void AI()
{
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 (invinceTime > 0)
{
invinceTime--;
npc.damage = 0;
npc.dontTakeDamage = true;
}
else
{
npc.damage = npc.defDamage;
npc.dontTakeDamage = false;
}
if (!Main.npc[(int)npc.ai[1]].active)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
if (npc.alpha != 0)
{
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;
}
}
}
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 HitEffect(int hitDirection, double damage)
{
if (npc.life <= 0)
{
float randomSpread = (float)(Main.rand.Next(-100, 100) / 100);
Gore.NewGore(npc.position, npc.velocity * randomSpread * Main.rand.NextFloat(), mod.GetGoreSlot("Gores/DoT2"), 1f);
Gore.NewGore(npc.position, npc.velocity * randomSpread * Main.rand.NextFloat(), mod.GetGoreSlot("Gores/DoT3"), 1f);
Gore.NewGore(npc.position, npc.velocity * randomSpread * Main.rand.NextFloat(), mod.GetGoreSlot("Gores/DoT4"), 1f);
Gore.NewGore(npc.position, npc.velocity * randomSpread * Main.rand.NextFloat(), mod.GetGoreSlot("Gores/DoT5"), 1f);
npc.position.X = npc.position.X + (float)(npc.width / 2);
npc.position.Y = npc.position.Y + (float)(npc.height / 2);
npc.width = 50;
npc.height = 50;
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 < 10; 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 < 20; 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;
}
}
}
public override void OnHitPlayer(Player player, int damage, bool crit)
{
player.AddBuff(ModContent.BuffType<GodSlayerInferno>(), 120, true);
player.AddBuff(BuffID.Frostburn, 120, true);
player.AddBuff(BuffID.Darkness, 120, true);
}
}
}