Files
CalamityModPublic/NPCs/Perforator/PerforatorBodyLarge.cs
T
ben-tk b745894036 Almost all debuff immunities/vulnerabilities are now centralized in NPCStats.cs
This is called in GlobalNPC SetDefaults.
Added a few comments explaining some stuff.
Created a list for confusion weak enemies so they are also initialized in GlobalNPC SetDefaults.
2020-12-14 22:44:26 -05:00

141 lines
4.8 KiB
C#

using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.Events;
using CalamityMod.Projectiles.Boss;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.NPCs.Perforator
{
public class PerforatorBodyLarge : ModNPC
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("The Perforator");
}
public override void SetDefaults()
{
npc.GetNPCDamage();
npc.npcSlots = 5f;
npc.width = 60;
npc.height = 60;
npc.defense = 8;
npc.LifeMaxNERB(2500, 2700, 800000);
double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01;
npc.lifeMax += (int)(npc.lifeMax * HPBoost);
npc.aiStyle = 6;
aiType = -1;
npc.knockBackResist = 0f;
npc.alpha = 255;
npc.behindTiles = true;
npc.noGravity = true;
npc.noTileCollide = true;
npc.canGhostHeal = false;
npc.HitSound = SoundID.NPCHit1;
npc.DeathSound = SoundID.NPCDeath1;
npc.netAlways = true;
npc.dontCountMe = true;
if (CalamityWorld.death || BossRushEvent.BossRushActive)
npc.scale = 1.25f;
else if (CalamityWorld.revenge)
npc.scale = 1.15f;
else if (Main.expertMode)
npc.scale = 1.1f;
}
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
{
return false;
}
public override void AI()
{
// Target
if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active)
npc.TargetClosest(true);
Player player = Main.player[npc.target];
if (player.dead)
{
npc.TargetClosest(false);
}
if (!Main.npc[(int)npc.ai[1]].active)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
SpriteEffects spriteEffects = SpriteEffects.None;
if (npc.spriteDirection == 1)
spriteEffects = SpriteEffects.FlipHorizontally;
Texture2D texture2D15 = npc.localAI[3] == 1f ? ModContent.GetTexture("CalamityMod/NPCs/Perforator/PerforatorBodyLargeAlt") : Main.npcTexture[npc.type];
Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / 2));
Vector2 vector43 = npc.Center - Main.screenPosition;
vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f;
vector43 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY);
spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f);
texture2D15 = npc.localAI[3] == 1f ? ModContent.GetTexture("CalamityMod/NPCs/Perforator/PerforatorBodyLargeAltGlow") : ModContent.GetTexture("CalamityMod/NPCs/Perforator/PerforatorBodyLargeGlow");
Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f);
spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f);
return false;
}
public override bool CheckActive()
{
return false;
}
public override bool PreNPCLoot()
{
return false;
}
public override void HitEffect(int hitDirection, double damage)
{
for (int k = 0; k < 5; 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 < 20; k++)
{
Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, hitDirection, -1f, 0, default, 1f);
}
Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/LargePerf2"), 1f);
Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/LargePerf3"), 1f);
Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/LargePerf4"), 1f);
}
}
public override void OnHitPlayer(Player player, int damage, bool crit)
{
player.AddBuff(ModContent.BuffType<BurningBlood>(), 180, true);
player.AddBuff(BuffID.Bleeding, 180, true);
}
}
}