Files
CalamityModPublic/NPCs/NormalNPCs/PerennialSlime.cs
T

82 lines
3.0 KiB
C#

using CalamityMod.Items.Placeables.Banners;
using CalamityMod.Items.Placeables.Ores;
using Terraria;
using Terraria.GameContent.Bestiary;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ModLoader.Utilities;
namespace CalamityMod.NPCs.NormalNPCs
{
public class PerennialSlime : ModNPC
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Perennial Slime");
Main.npcFrameCount[NPC.type] = 2;
}
public override void SetDefaults()
{
NPC.aiStyle = NPCAIStyleID.Slime;
AIType = NPCID.ToxicSludge;
NPC.damage = 35;
NPC.width = 40;
NPC.height = 30;
NPC.defense = 12;
NPC.lifeMax = 150;
NPC.knockBackResist = 0f;
AnimationType = NPCID.CorruptSlime;
NPC.value = Item.buyPrice(0, 0, 10, 0);
NPC.alpha = 50;
NPC.lavaImmune = false;
NPC.noGravity = false;
NPC.noTileCollide = false;
NPC.HitSound = SoundID.NPCHit1;
NPC.DeathSound = SoundID.NPCDeath1;
Banner = NPC.type;
BannerItem = ModContent.ItemType<PerennialSlimeBanner>();
NPC.Calamity().VulnerableToHeat = true;
NPC.Calamity().VulnerableToSickness = false;
}
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
{
bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] {
BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Caverns,
// Will move to localization whenever that is cleaned up.
new FlavorTextBestiaryInfoElement("Slimes, from their time spent wobbling about the undergrowth, are full of nutrients, which would well support plant life. Many accept these growths and have been seen to carry blossoms.")
});
}
public override float SpawnChance(NPCSpawnInfo spawnInfo)
{
if (spawnInfo.PlayerSafe || !NPC.downedPlantBoss || spawnInfo.Player.Calamity().ZoneAbyss ||
spawnInfo.Player.Calamity().ZoneSunkenSea)
{
return 0f;
}
return SpawnCondition.Cavern.Chance * 0.08f;
}
public override void HitEffect(int hitDirection, double damage)
{
// TODO -- This dust was an invalid dust. Replaced with a random dust.
int dustType = 115;
for (int k = 0; k < 5; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, dustType, hitDirection, -1f, 0, default, 1f);
}
if (NPC.life <= 0)
{
for (int k = 0; k < 20; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, dustType, hitDirection, -1f, 0, default, 1f);
}
}
}
public override void ModifyNPCLoot(NPCLoot npcLoot) => npcLoot.Add(ModContent.ItemType<PerennialOre>(), 1, 10, 26);
}
}