Files
CalamityModPublic/NPCs/NormalNPCs/Stormlion.cs
T

125 lines
4.8 KiB
C#

using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Items.Materials;
using CalamityMod.Items.Placeables.Banners;
using CalamityMod.Items.Weapons.Summon;
using Terraria;
using Terraria.Audio;
using Terraria.GameContent.Bestiary;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ModLoader.Utilities;
namespace CalamityMod.NPCs.NormalNPCs
{
public class Stormlion : ModNPC
{
public static readonly SoundStyle IdleSound = new("CalamityMod/Sounds/Custom/StormlionIdle");
public static readonly SoundStyle HitSound = new("CalamityMod/Sounds/NPCHit/StormlionHit");
public static readonly SoundStyle DeathSound = new("CalamityMod/Sounds/NPCKilled/StormlionDeath");
public override void SetStaticDefaults()
{
Main.npcFrameCount[NPC.type] = 6;
}
public override void SetDefaults()
{
NPC.damage = 20;
NPC.aiStyle = NPCAIStyleID.Fighter;
NPC.width = 33;
NPC.height = 31;
NPC.defense = 8;
NPC.lifeMax = 100;
NPC.knockBackResist = 0.2f;
AnimationType = NPCID.WalkingAntlion;
NPC.value = Item.buyPrice(0, 0, 2, 0);
NPC.HitSound = HitSound;
NPC.DeathSound = DeathSound;
Banner = NPC.type;
BannerItem = ModContent.ItemType<StormlionBanner>();
NPC.Calamity().VulnerableToCold = true;
NPC.Calamity().VulnerableToSickness = true;
NPC.Calamity().VulnerableToElectricity = false;
NPC.Calamity().VulnerableToWater = true;
// Scale stats in Expert and Master
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
}
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
{
bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[]
{
BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.UndergroundDesert,
new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.Stormlion")
});
}
public override void AI()
{
if (Main.rand.NextBool(800))
{
SoundEngine.PlaySound(IdleSound, NPC.Center);
}
}
public override void HitEffect(NPC.HitInfo hit)
{
for (int k = 0; k < 5; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, hit.HitDirection, -1f, 0, default, 1f);
}
if (NPC.life <= 0)
{
for (int k = 0; k < 20; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, hit.HitDirection, -1f, 0, default, 1f);
}
if (Main.netMode != NetmodeID.Server)
{
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("Stormlion").Type, NPC.scale);
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("Stormlion2").Type, NPC.scale);
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("Stormlion3").Type, NPC.scale);
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("Stormlion4").Type, NPC.scale);
}
}
}
public override float SpawnChance(NPCSpawnInfo spawnInfo)
{
if (spawnInfo.PlayerSafe ||
spawnInfo.Player.Calamity().ZoneSunkenSea ||
spawnInfo.Player.PillarZone() ||
spawnInfo.Player.InAstral() ||
spawnInfo.Player.ZoneCorrupt ||
spawnInfo.Player.ZoneCrimson ||
spawnInfo.Player.ZoneOldOneArmy ||
Main.eclipse ||
Main.snowMoon ||
Main.pumpkinMoon ||
Main.invasionType != InvasionID.None)
{
return 0f;
}
if (Main.IsItStorming && spawnInfo.Player.ZoneDesert)
{
return SpawnCondition.OverworldDayDesert.Chance;
}
return SpawnCondition.DesertCave.Chance * 0.3f;
}
public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo)
{
if (hurtInfo.Damage > 0)
target.AddBuff(ModContent.BuffType<StaticDischarge>(), 60, true);
}
public override void ModifyNPCLoot(NPCLoot npcLoot)
{
npcLoot.Add(ModContent.ItemType<StormlionMandible>());
npcLoot.Add(ModContent.ItemType<StormjawStaff>(), 5);
npcLoot.Add(ItemID.ThunderSpear, 25);
npcLoot.Add(ItemID.ThunderStaff, 25);
}
}
}