Files
CalamityModPublic/NPCs/NormalNPCs/MantisShrimp.cs
T
mountaindrew10 2d1d2b352b 1 - Rev changes enemy AIs now.
2 - Death changes some enemies to be harder than current Death.
3 - Added buff for Trinket of Chi team regen.
2022-12-20 02:17:06 -06:00

145 lines
5.0 KiB
C#

using CalamityMod.Items.Placeables.Banners;
using CalamityMod.Items.Weapons.Melee;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.GameContent.Bestiary;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ModLoader.Utilities;
namespace CalamityMod.NPCs.NormalNPCs
{
public class MantisShrimp : ModNPC
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Mantis Shrimp");
Main.npcFrameCount[NPC.type] = 6;
NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0)
{
SpriteDirection = 1
};
NPCID.Sets.NPCBestiaryDrawOffset[Type] = value;
}
public override void SetDefaults()
{
NPC.damage = 200;
NPC.width = 40;
NPC.height = 24;
NPC.defense = 10;
NPC.DR_NERD(0.1f);
NPC.lifeMax = 30;
NPC.aiStyle = NPCAIStyleID.Fighter;
AIType = NPCID.Crab;
NPC.value = Item.buyPrice(0, 0, 1, 0);
NPC.HitSound = SoundID.NPCHit1;
NPC.DeathSound = SoundID.NPCDeath1;
Banner = NPC.type;
BannerItem = ModContent.ItemType<MantisShrimpBanner>();
NPC.Calamity().VulnerableToHeat = false;
NPC.Calamity().VulnerableToSickness = true;
NPC.Calamity().VulnerableToElectricity = true;
NPC.Calamity().VulnerableToWater = false;
}
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
{
bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] {
BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Ocean,
// Will move to localization whenever that is cleaned up.
new FlavorTextBestiaryInfoElement("Should it land a blow with its rounded front claws, it will tear your flesh and shatter your bones. Needless to say, avoid this at all costs.")
});
}
public override void AI()
{
NPC.spriteDirection = (NPC.direction > 0) ? -1 : 1;
float num79 = (Main.player[NPC.target].Center - NPC.Center).Length();
num79 *= 0.0025f;
if ((double)num79 > 1.5)
{
num79 = 1.5f;
}
float num78;
if (Main.expertMode)
{
num78 = 3f - num79;
}
else
{
num78 = 2.5f - num79;
}
num78 *= (CalamityWorld.death ? 1.2f : CalamityWorld.revenge ? 1f : 0.8f);
if (NPC.velocity.X < -num78 || NPC.velocity.X > num78)
{
if (NPC.velocity.Y == 0f)
{
NPC.velocity *= 0.8f;
}
}
else if (NPC.velocity.X < num78 && NPC.direction == 1)
{
NPC.velocity.X = NPC.velocity.X + 1f;
if (NPC.velocity.X > num78)
{
NPC.velocity.X = num78;
}
}
else if (NPC.velocity.X > -num78 && NPC.direction == -1)
{
NPC.velocity.X = NPC.velocity.X - 1f;
if (NPC.velocity.X < -num78)
{
NPC.velocity.X = -num78;
}
}
}
public override void OnHitPlayer(Player player, int damage, bool crit)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center, Vector2.Zero, ProjectileID.SolarWhipSwordExplosion, 0, 0f, Main.myPlayer);
}
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 float SpawnChance(NPCSpawnInfo spawnInfo)
{
if (spawnInfo.PlayerSafe || !Main.hardMode || spawnInfo.Player.Calamity().ZoneSulphur)
return 0f;
return SpawnCondition.OceanMonster.Chance * 0.2f;
}
public override void ModifyNPCLoot(NPCLoot npcLoot)
{
npcLoot.Add(ItemID.ShrimpPoBoy, 50);
npcLoot.AddIf(() => NPC.downedPlantBoss, ModContent.ItemType<MantisClaws>(), 5);
}
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 < 15; k++)
{
Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, hitDirection, -1f, 0, default, 1f);
}
}
}
}
}