using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.Utilities; namespace CalamityMod.NPCs.NormalNPCs { public class SunBat : ModNPC { public override void SetStaticDefaults() { DisplayName.SetDefault("Sun Bat"); Main.npcFrameCount[NPC.type] = 7; } public override void SetDefaults() { NPC.lavaImmune = true; NPC.aiStyle = -1; AIType = -1; NPC.damage = 35; NPC.width = 26; NPC.height = 20; NPC.defense = 10; NPC.lifeMax = 200; NPC.knockBackResist = 0.65f; NPC.value = Item.buyPrice(0, 0, 5, 0); NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath4; Banner = NPC.type; BannerItem = ModContent.ItemType(); NPC.Calamity().VulnerableToHeat = false; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToWater = true; } public override void AI() { CalamityGlobalAI.BuffedBatAI(NPC, Mod); } public override void FindFrame(int frameHeight) { if (NPC.velocity.X > 0f) NPC.spriteDirection = 1; if (NPC.velocity.X < 0f) NPC.spriteDirection = -1; NPC.rotation = NPC.velocity.X * 0.1f; NPC.frameCounter += 0.15f; NPC.frameCounter %= Main.npcFrameCount[NPC.type]; int frame = (int)NPC.frameCounter; NPC.frame.Y = frame * frameHeight; } public override float SpawnChance(NPCSpawnInfo spawnInfo) { if (spawnInfo.PlayerSafe || !Main.hardMode || spawnInfo.Player.Calamity().ZoneAbyss || spawnInfo.Player.Calamity().ZoneSunkenSea) { return 0f; } return SpawnCondition.Underground.Chance * 0.12f; } public override void OnHitPlayer(Player player, int damage, bool crit) { player.AddBuff(ModContent.BuffType(), 120, true); } public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 5; k++) { Dust.NewDust(NPC.position, NPC.width, NPC.height, 64, hitDirection, -1f, 0, default, 1f); } if (NPC.life <= 0) { for (int k = 0; k < 20; k++) { Dust.NewDust(NPC.position, NPC.width, NPC.height, 64, hitDirection, -1f, 0, default, 1f); } } } public override void ModifyNPCLoot(NPCLoot npcLoot) => npcLoot.Add(ModContent.ItemType(), 3); } }