144 lines
5.4 KiB
C#
144 lines
5.4 KiB
C#
using CalamityMod.Buffs.DamageOverTime;
|
|
using CalamityMod.Items.Materials;
|
|
using CalamityMod.Items.Placeables.Banners;
|
|
using CalamityMod.Items.Weapons.Ranged;
|
|
using CalamityMod.World;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using System.IO;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.NPCs.Abyss
|
|
{
|
|
public class Laserfish : ModNPC
|
|
{
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Laserfish");
|
|
Main.npcFrameCount[npc.type] = 6;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
npc.noGravity = true;
|
|
npc.damage = 40;
|
|
npc.width = 60;
|
|
npc.height = 26;
|
|
npc.defense = 25;
|
|
npc.lifeMax = 480;
|
|
npc.aiStyle = -1;
|
|
aiType = -1;
|
|
npc.buffImmune[ModContent.BuffType<CrushDepth>()] = true;
|
|
npc.value = Item.buyPrice(0, 0, 10, 0);
|
|
npc.HitSound = SoundID.NPCHit51;
|
|
npc.DeathSound = SoundID.NPCDeath26;
|
|
npc.knockBackResist = 0.65f;
|
|
banner = npc.type;
|
|
bannerItem = ModContent.ItemType<LaserfishBanner>();
|
|
npc.chaseable = false;
|
|
}
|
|
|
|
public override void SendExtraAI(BinaryWriter writer)
|
|
{
|
|
writer.Write(npc.chaseable);
|
|
}
|
|
|
|
public override void ReceiveExtraAI(BinaryReader reader)
|
|
{
|
|
npc.chaseable = reader.ReadBoolean();
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
CalamityAI.PassiveSwimmingAI(npc, mod, 0, Main.player[npc.target].Calamity().GetAbyssAggro(400f, 200f), 0.15f, 0.15f, 4f, 4f, 0.1f);
|
|
}
|
|
|
|
public override bool? CanBeHitByProjectile(Projectile projectile)
|
|
{
|
|
if (projectile.minion && !projectile.Calamity().overridesMinionDamagePrevention)
|
|
{
|
|
return npc.chaseable;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public override void FindFrame(int frameHeight)
|
|
{
|
|
if (!npc.wet)
|
|
{
|
|
npc.frameCounter = 0.0;
|
|
return;
|
|
}
|
|
npc.frameCounter += npc.chaseable ? 0.15f : 0.075f;
|
|
npc.frameCounter %= Main.npcFrameCount[npc.type];
|
|
int frame = (int)npc.frameCounter;
|
|
npc.frame.Y = frame * frameHeight;
|
|
}
|
|
|
|
public override void PostDraw(SpriteBatch spriteBatch, Color drawColor)
|
|
{
|
|
SpriteEffects spriteEffects = SpriteEffects.None;
|
|
if (npc.spriteDirection == 1)
|
|
{
|
|
spriteEffects = SpriteEffects.FlipHorizontally;
|
|
}
|
|
Vector2 center = new Vector2(npc.Center.X, npc.Center.Y);
|
|
Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2));
|
|
Vector2 vector = center - Main.screenPosition;
|
|
vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/Abyss/LaserfishGlow").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/Abyss/LaserfishGlow").Height / Main.npcFrameCount[npc.type])) * 1f / 2f;
|
|
vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY);
|
|
Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.Yellow);
|
|
Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Abyss/LaserfishGlow"), vector,
|
|
new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f);
|
|
}
|
|
|
|
public override float SpawnChance(NPCSpawnInfo spawnInfo)
|
|
{
|
|
if (spawnInfo.player.Calamity().ZoneAbyssLayer2 && spawnInfo.water)
|
|
{
|
|
return SpawnCondition.CaveJellyfish.Chance * 0.6f;
|
|
}
|
|
if (spawnInfo.player.Calamity().ZoneAbyssLayer3 && spawnInfo.water)
|
|
{
|
|
return SpawnCondition.CaveJellyfish.Chance * 1.2f;
|
|
}
|
|
return 0f;
|
|
}
|
|
|
|
public override void NPCLoot()
|
|
{
|
|
if (Main.rand.NextBool(1000000) && CalamityWorld.revenge)
|
|
{
|
|
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ModContent.ItemType<HalibutCannon>());
|
|
}
|
|
if (CalamityWorld.downedCalamitas)
|
|
{
|
|
if (Main.rand.NextBool(2))
|
|
{
|
|
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ModContent.ItemType<Lumenite>());
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void HitEffect(int hitDirection, double damage)
|
|
{
|
|
for (int k = 0; k < 5; k++)
|
|
{
|
|
Dust.NewDust(npc.position, npc.width, npc.height, 5, hitDirection, -1f, 0, default, 1f);
|
|
}
|
|
if (npc.life <= 0)
|
|
{
|
|
for (int k = 0; k < 25; k++)
|
|
{
|
|
Dust.NewDust(npc.position, npc.width, npc.height, 5, hitDirection, -1f, 0, default, 1f);
|
|
}
|
|
Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Laserfish"), 1f);
|
|
Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Laserfish2"), 1f);
|
|
Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Laserfish3"), 1f);
|
|
}
|
|
}
|
|
}
|
|
}
|