Files
CalamityModPublic/NPCs/NormalNPCs/Parasea.cs
T

99 lines
3.5 KiB
C#

using CalamityMod.Items.Placeables.Banners;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.GameContent;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ModLoader.Utilities;
namespace CalamityMod.NPCs.NormalNPCs
{
public class Parasea : ModNPC
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Parasea");
Main.npcFrameCount[NPC.type] = 4;
}
public override void SetDefaults()
{
NPC.aiStyle = -1;
AIType = -1;
NPC.noGravity = true;
NPC.damage = 50;
NPC.width = NPC.height = 30;
NPC.defense = 8;
NPC.lifeMax = 400;
NPC.knockBackResist = 0f;
NPC.value = Item.buyPrice(0, 0, 6, 0);
NPC.HitSound = SoundID.NPCHit1;
NPC.DeathSound = SoundID.NPCDeath1;
Banner = NPC.type;
BannerItem = ModContent.ItemType<ParaseaBanner>();
NPC.Calamity().VulnerableToHeat = false;
NPC.Calamity().VulnerableToSickness = true;
NPC.Calamity().VulnerableToElectricity = true;
NPC.Calamity().VulnerableToWater = false;
}
public override void AI()
{
bool death = CalamityWorld.death;
float speed = death ? 16f : 13f;
CalamityAI.DungeonSpiritAI(NPC, Mod, speed, MathHelper.Pi);
}
public override float SpawnChance(NPCSpawnInfo spawnInfo)
{
if (spawnInfo.PlayerSafe || spawnInfo.Player.Calamity().ZoneSulphur || (!NPC.downedPlantBoss && !DownedBossSystem.downedCalamitas))
{
return 0f;
}
return SpawnCondition.OceanMonster.Chance * 0.06f;
}
public override void FindFrame(int frameHeight)
{
NPC.frameCounter += 0.15f;
NPC.frameCounter %= Main.npcFrameCount[NPC.type];
int frame = (int)NPC.frameCounter;
NPC.frame.Y = frame * frameHeight;
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
{
Texture2D texture = TextureAssets.Npc[NPC.type].Value;
int height = texture.Height / Main.npcFrameCount[NPC.type];
int width = texture.Width;
SpriteEffects spriteEffects = SpriteEffects.FlipHorizontally;
if (NPC.spriteDirection == -1)
spriteEffects = SpriteEffects.None;
Main.spriteBatch.Draw(texture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY), NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, new Vector2((float)width / 2f, (float)height / 2f), NPC.scale, spriteEffects, 0f);
return false;
}
public override void OnHitPlayer(Player player, int damage, bool crit)
{
player.AddBuff(BuffID.Bleeding, 60, true);
}
public override void HitEffect(int hitDirection, double damage)
{
for (int k = 0; k < 3; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, hitDirection, -1f, 0, default, 1f);
}
if (NPC.life <= 0)
{
for (int k = 0; k < 10; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, hitDirection, -1f, 0, default, 1f);
}
}
}
}
}