Files
CalamityModPublic/NPCs/SlimeGod/SlimeSpawnCorrupt2.cs
T
2022-04-21 23:31:19 -05:00

75 lines
2.4 KiB
C#

using CalamityMod.Events;
using CalamityMod.World;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.NPCs.SlimeGod
{
public class SlimeSpawnCorrupt2 : ModNPC
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Corrupt Slime Spawn");
Main.npcFrameCount[NPC.type] = 2;
}
public override void SetDefaults()
{
NPC.aiStyle = 1;
NPC.GetNPCDamage();
NPC.width = 40;
NPC.height = 30;
NPC.defense = 4;
NPC.lifeMax = 90;
if (BossRushEvent.BossRushActive)
{
NPC.lifeMax = 5000;
}
NPC.knockBackResist = 0f;
AnimationType = NPCID.CorruptSlime;
NPC.alpha = 55;
NPC.lavaImmune = false;
NPC.noGravity = false;
NPC.noTileCollide = false;
NPC.canGhostHeal = false;
NPC.HitSound = SoundID.NPCHit1;
NPC.DeathSound = SoundID.NPCDeath1;
NPC.Calamity().VulnerableToHeat = true;
NPC.Calamity().VulnerableToSickness = false;
}
public override void HitEffect(int hitDirection, double damage)
{
for (int k = 0; k < 5; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, hitDirection, -1f, 0, default, 1f);
}
if (NPC.life <= 0)
{
for (int k = 0; k < 20; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, hitDirection, -1f, 0, default, 1f);
}
}
}
public override void OnKill()
{
if (!CalamityWorld.revenge)
{
int closestPlayer = Player.FindClosest(NPC.Center, 1, 1);
if (Main.rand.Next(8) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2)
Item.NewItem(NPC.GetSource_Loot(), (int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart);
}
}
public override void ModifyNPCLoot(NPCLoot npcLoot) => npcLoot.Add(ItemID.Vitamins, 50);
public override void OnHitPlayer(Player player, int damage, bool crit)
{
player.AddBuff(BuffID.Weak, 90, true);
}
}
}