155 lines
5.7 KiB
C#
155 lines
5.7 KiB
C#
using System.IO;
|
|
using CalamityMod.BiomeManagers;
|
|
using CalamityMod.Items.Materials;
|
|
using CalamityMod.Items.Placeables.Banners;
|
|
using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using ReLogic.Content;
|
|
using Terraria;
|
|
using Terraria.GameContent;
|
|
using Terraria.GameContent.Bestiary;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
using Terraria.ModLoader.Utilities;
|
|
|
|
namespace CalamityMod.NPCs.Abyss
|
|
{
|
|
public class Laserfish : ModNPC
|
|
{
|
|
public static Asset<Texture2D> GlowTexture;
|
|
public override void SetStaticDefaults()
|
|
{
|
|
NPCID.Sets.NeedsExpertScaling[NPC.type] = true;
|
|
Main.npcFrameCount[NPC.type] = 6;
|
|
if (!Main.dedServ)
|
|
{
|
|
GlowTexture = ModContent.Request<Texture2D>(Texture + "Glow", AssetRequestMode.AsyncLoad);
|
|
}
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
NPC.noGravity = true;
|
|
NPC.damage = 0; // 0 contact damage, laser damage is handled in the general swimming AI
|
|
NPC.width = 58;
|
|
NPC.height = 32;
|
|
NPC.defense = 15;
|
|
NPC.lifeMax = 600;
|
|
NPC.aiStyle = -1;
|
|
AIType = -1;
|
|
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;
|
|
NPC.Calamity().VulnerableToHeat = false;
|
|
NPC.Calamity().VulnerableToSickness = true;
|
|
NPC.Calamity().VulnerableToElectricity = true;
|
|
NPC.Calamity().VulnerableToWater = false;
|
|
SpawnModBiomes = new int[2] { ModContent.GetInstance<AbyssLayer2Biome>().Type, ModContent.GetInstance<AbyssLayer3Biome>().Type };
|
|
|
|
// 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[]
|
|
{
|
|
new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.Laserfish")
|
|
});
|
|
}
|
|
|
|
public override void SendExtraAI(BinaryWriter writer)
|
|
{
|
|
writer.Write(NPC.chaseable);
|
|
}
|
|
|
|
public override void ReceiveExtraAI(BinaryReader reader)
|
|
{
|
|
NPC.chaseable = reader.ReadBoolean();
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
CalamityRegularEnemyAI.PassiveSwimmingAI(NPC, Mod, 0, Main.player[NPC.target].Calamity().GetAbyssAggro(160f), 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.IsABestiaryIconDummy)
|
|
{
|
|
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, Vector2 screenPos, Color drawColor)
|
|
{
|
|
if (!NPC.IsABestiaryIconDummy)
|
|
{
|
|
var effects = NPC.direction == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
|
|
|
|
Main.EntitySpriteDraw(GlowTexture.Value, NPC.Center - Main.screenPosition + new Vector2(0, NPC.gfxOffY + 4),
|
|
NPC.frame, Color.White * 0.5f, NPC.rotation, NPC.frame.Size() / 2f, NPC.scale, effects, 0);
|
|
}
|
|
}
|
|
|
|
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 Main.remixWorld ? 10.8f : SpawnCondition.CaveJellyfish.Chance * 1.2f;
|
|
}
|
|
return 0f;
|
|
}
|
|
|
|
public override void ModifyNPCLoot(NPCLoot npcLoot)
|
|
{
|
|
npcLoot.AddIf(DropHelper.PostLevi(), ModContent.ItemType<Lumenyl>(), 2);
|
|
}
|
|
|
|
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 < 25; 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>("Laserfish").Type, 1f);
|
|
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("Laserfish2").Type, 1f);
|
|
Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find<ModGore>("Laserfish3").Type, 1f);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|