Files
CalamityModPublic/NPCs/Astral/SightseerCollider.cs
T
Mortis3 4a856851d1 Localization stuffs
localized (hopefully) every npc in calamity that needs it
2023-07-20 10:11:57 -04:00

160 lines
5.7 KiB
C#

using CalamityMod.BiomeManagers;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Dusts;
using CalamityMod.Items.Materials;
using CalamityMod.Items.Placeables.Banners;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.GameContent.Bestiary;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.Audio;
using ReLogic.Content;
using CalamityMod.Sounds;
namespace CalamityMod.NPCs.Astral
{
public class SightseerCollider : ModNPC
{
private static Texture2D glowmask;
public override void SetStaticDefaults()
{
Main.npcFrameCount[NPC.type] = 4;
if (!Main.dedServ)
glowmask = ModContent.Request<Texture2D>("CalamityMod/NPCs/Astral/SightseerColliderGlow", AssetRequestMode.ImmediateLoad).Value;
NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0)
{
PortraitPositionXOverride = 0
};
value.Position.X += 15;
NPCID.Sets.NPCBestiaryDrawOffset[Type] = value;
}
public override void SetDefaults()
{
NPC.width = 48;
NPC.height = 40;
NPC.damage = 38;
NPC.defense = 16;
NPC.DR_NERD(0.15f);
NPC.lifeMax = 310;
NPC.DeathSound = CommonCalamitySounds.AstralNPCDeathSound;
NPC.noGravity = true;
NPC.knockBackResist = 0.58f;
NPC.value = Item.buyPrice(0, 0, 10, 0);
NPC.aiStyle = -1;
Banner = NPC.type;
BannerItem = ModContent.ItemType<SightseerColliderBanner>();
if (DownedBossSystem.downedAstrumAureus)
{
NPC.damage = 58;
NPC.defense = 26;
NPC.knockBackResist = 0.48f;
NPC.lifeMax = 460;
}
NPC.Calamity().VulnerableToHeat = true;
NPC.Calamity().VulnerableToSickness = false;
SpawnModBiomes = new int[1] { ModContent.GetInstance<AbovegroundAstralBiome>().Type };
}
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
{
bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[]
{
new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.SightseerCollider")
});
}
public override void FindFrame(int frameHeight)
{
if (NPC.IsABestiaryIconDummy)
{
NPC.frameCounter += 2;
}
else
{
NPC.frameCounter += 0.05f + NPC.velocity.Length() * 0.667f;
}
if (NPC.frameCounter >= 8)
{
NPC.frameCounter = 0;
NPC.frame.Y += frameHeight;
if (NPC.frame.Y > NPC.height * 2)
{
NPC.frame.Y = 0;
}
}
//DO DUST
Dust d = CalamityGlobalNPC.SpawnDustOnNPC(NPC, 80, frameHeight, ModContent.DustType<AstralOrange>(), new Rectangle(16, 8, 6, 6), Vector2.Zero, 0.45f, true);
if (d != null)
{
d.customData = 0.04f;
}
}
public override void AI()
{
CalamityGlobalNPC.DoFlyingAI(NPC, (CalamityWorld.death ? 9.8f : CalamityWorld.revenge ? 7.8f : 5.8f), (CalamityWorld.death ? 0.05f : CalamityWorld.revenge ? 0.04f : 0.03f), 350f);
}
public override void HitEffect(NPC.HitInfo hit)
{
if (NPC.soundDelay == 0)
{
NPC.soundDelay = 15;
SoundEngine.PlaySound(CommonCalamitySounds.AstralNPCHitSound, NPC.Center);
}
CalamityGlobalNPC.DoHitDust(NPC, hit.HitDirection, (Main.rand.Next(0, Math.Max(0, NPC.life)) == 0) ? 5 : ModContent.DustType<AstralEnemy>(), 1f, 4, 22);
//if dead do gores
if (NPC.life <= 0)
{
if (Main.netMode != NetmodeID.Server)
{
for (int i = 0; i < 5; i++)
{
float rand = Main.rand.NextFloat(-0.18f, 0.18f);
Gore.NewGore(NPC.GetSource_Death(), NPC.position + new Vector2(Main.rand.NextFloat(0f, NPC.width), Main.rand.NextFloat(0f, NPC.height)), NPC.velocity * rand, Mod.Find<ModGore>("SightseerColliderGore" + i).Type);
}
}
}
}
public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
{
spriteBatch.Draw(glowmask, NPC.Center - screenPos + new Vector2(0, 4f), new Rectangle(0, NPC.frame.Y, 80, NPC.frame.Height), Color.White * 0.75f, NPC.rotation, new Vector2(40f, 20f), NPC.scale, NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0f);
}
public override float SpawnChance(NPCSpawnInfo spawnInfo)
{
if (CalamityGlobalNPC.AnyEvents(spawnInfo.Player))
{
return 0f;
}
else if (spawnInfo.Player.InAstral(1))
{
return spawnInfo.Player.ZoneDesert ? 0.16f : 0.2f;
}
return 0f;
}
public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo)
{
if (hurtInfo.Damage > 0)
target.AddBuff(ModContent.BuffType<AstralInfectionDebuff>(), 60, true);
}
public override void ModifyNPCLoot(NPCLoot npcLoot)
{
npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType<Stardust>(), 1, 1, 2, 1, 3));
}
}
}