Files
CalamityModPublic/NPCs/Yharon/DetonatingFlare.cs
T
Andrew Marheine 3981fe1e24 1 - New goblin weapon reforge system.
2 - Abyssal Diving Suit allows you to move faster as the armor plates get closer to breaking.
3 - Fabled Tortoise Shell gives 36 defense, this gets cut in half but restores most movement speed for 3 seconds if you get hit.
4 - Rev+ Moon Lord projectiles inflict Nightwither.
5 - Celestial Jewel defense boost reduced from 20 to 15 when affected by a damaging debuff.
6 - Affliction now gives 10 defense instead of 20.
7 - Dark Sun Ring gives 15 defense instead of 30 during night/solar eclipse.
8 - Giant Tortoise Shell gives 12 defense instead of 8.
9 - Amalgam gives 20 defense instead of 40 while underwater.
10 - Increased buff durations of alchols and buff potions.
11 - Reduced Tarragon Rogue bonus immunity frames from 5 to 3.
12 - Reduced Cirrus candle price.
13 - Mariana spawns orbs on hit instead of on enemy death.
14 - Colossal Squids spawn in layer 4 as well as 3.
15 - Yharon and Flares inflict Lethal Lava Burn.
16 - Spiteful Candle no longer ignores timed DR.
17 - Moon Lord spawns Luminite Ore on first kill.
18 - Providence anti-heal orbs kill adrenaline.
19 - Submarine Shocker nerfed.
20 - All vanilla spears autoswing.
2020-11-25 17:59:05 -06:00

303 lines
11 KiB
C#

using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Events;
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.Yharon
{
public class DetonatingFlare : ModNPC
{
float num = 0f;
float num2 = 0f;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Detonating Flame");
Main.npcFrameCount[npc.type] = 5;
}
public override void SetDefaults()
{
npc.aiStyle = -1;
aiType = -1;
npc.GetNPCDamage();
npc.width = 50;
npc.height = 50;
npc.defense = 50;
npc.lifeMax = 10000;
npc.knockBackResist = 0f;
npc.noGravity = true;
npc.noTileCollide = true;
npc.canGhostHeal = false;
npc.HitSound = SoundID.NPCHit52;
npc.DeathSound = SoundID.NPCDeath55;
npc.alpha = 255;
}
public override void AI()
{
bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive;
npc.alpha -= 3;
if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead)
{
npc.TargetClosest(true);
}
if (npc.localAI[1] == 0f)
{
switch (Main.rand.Next(8))
{
case 0:
num = 5f;
num2 = 0.15f;
break;
case 1:
num = 5.5f;
num2 = 0.16f;
break;
case 2:
num = 6f;
num2 = 0.17f;
break;
case 3:
num = 6.5f;
num2 = 0.18f;
break;
case 4:
num = 7f;
num2 = 0.19f;
break;
case 5:
num = 7.5f;
num2 = 0.20f;
break;
case 6:
num = 8f;
num2 = 0.21f;
break;
case 7:
num = 8.5f;
num2 = 0.22f;
break;
}
npc.localAI[1] = 1f;
}
Vector2 vector = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
float num4 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2);
float num5 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2);
num4 = (float)((int)(num4 / 8f) * 8);
num5 = (float)((int)(num5 / 8f) * 8);
vector.X = (float)((int)(vector.X / 8f) * 8);
vector.Y = (float)((int)(vector.Y / 8f) * 8);
num4 -= vector.X;
num5 -= vector.Y;
float num6 = (float)Math.Sqrt((double)(num4 * num4 + num5 * num5));
float num7 = num6;
bool flag = false;
if (num6 > 600f)
{
flag = true;
}
if (num6 == 0f)
{
num4 = npc.velocity.X;
num5 = npc.velocity.Y;
}
else
{
num6 = num / num6;
num4 *= num6;
num5 *= num6;
}
if (num7 > 100f)
{
npc.ai[0] += 1f;
if (npc.ai[0] > 0f)
{
npc.velocity.Y = npc.velocity.Y + 0.023f;
}
else
{
npc.velocity.Y = npc.velocity.Y - 0.023f;
}
if (npc.ai[0] < -100f || npc.ai[0] > 100f)
{
npc.velocity.X = npc.velocity.X + 0.023f;
}
else
{
npc.velocity.X = npc.velocity.X - 0.023f;
}
if (npc.ai[0] > 200f)
{
npc.ai[0] = -200f;
}
}
if (Main.player[npc.target].dead)
{
num4 = (float)npc.direction * num / 2f;
num5 = -num / 2f;
}
if (npc.velocity.X < num4)
{
npc.velocity.X = npc.velocity.X + num2;
}
else if (npc.velocity.X > num4)
{
npc.velocity.X = npc.velocity.X - num2;
}
if (npc.velocity.Y < num5)
{
npc.velocity.Y = npc.velocity.Y + num2;
}
else if (npc.velocity.Y > num5)
{
npc.velocity.Y = npc.velocity.Y - num2;
}
int shoot = revenge ? 4 : 3;
npc.localAI[0] += (float)Main.rand.Next(shoot);
if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] >= 300f)
{
npc.localAI[0] = 0f;
if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height))
{
int type = ProjectileID.CultistBossFireBall;
int damage = npc.GetProjectileDamage(type);
Projectile.NewProjectile(vector.X, vector.Y, num4, num5, type, damage, 0f, Main.myPlayer, 0f, 0f);
}
}
int num10 = (int)npc.position.X + npc.width / 2;
int num11 = (int)npc.position.Y + npc.height / 2;
num10 /= 16;
num11 /= 16;
if (!WorldGen.SolidTile(num10, num11))
{
Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.3f, 0f, 0.25f);
}
if (num4 > 0f)
{
npc.spriteDirection = 1;
npc.rotation = (float)Math.Atan2((double)num5, (double)num4);
}
if (num4 < 0f)
{
npc.spriteDirection = -1;
npc.rotation = (float)Math.Atan2((double)num5, (double)num4) + 3.14f;
}
float num12 = 0.7f;
if (npc.collideX)
{
npc.netUpdate = true;
npc.velocity.X = npc.oldVelocity.X * -num12;
if (npc.direction == -1 && npc.velocity.X > 0f && npc.velocity.X < 2f)
{
npc.velocity.X = 2f;
}
if (npc.direction == 1 && npc.velocity.X < 0f && npc.velocity.X > -2f)
{
npc.velocity.X = -2f;
}
}
if (npc.collideY)
{
npc.netUpdate = true;
npc.velocity.Y = npc.oldVelocity.Y * -num12;
if (npc.velocity.Y > 0f && (double)npc.velocity.Y < 1.5)
{
npc.velocity.Y = 2f;
}
if (npc.velocity.Y < 0f && (double)npc.velocity.Y > -1.5)
{
npc.velocity.Y = -2f;
}
}
if (flag)
{
if ((npc.velocity.X > 0f && num4 > 0f) || (npc.velocity.X < 0f && num4 < 0f))
{
if (Math.Abs(npc.velocity.X) < 12f)
{
npc.velocity.X = npc.velocity.X * 1.05f;
}
}
else
{
npc.velocity.X = npc.velocity.X * 0.9f;
}
}
if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit)
{
npc.netUpdate = true;
}
}
public override Color? GetAlpha(Color drawColor)
{
return new Color(255, Main.DiscoG, 53, 0);
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
SpriteEffects spriteEffects = SpriteEffects.None;
if (npc.spriteDirection == 1)
spriteEffects = SpriteEffects.FlipHorizontally;
Texture2D texture2D15 = Main.npcTexture[npc.type];
Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2));
Color color36 = new Color(255, Main.DiscoG, 53, 0);
float amount9 = 0.5f;
int num153 = 10;
if (CalamityConfig.Instance.Afterimages)
{
for (int num155 = 1; num155 < num153; num155 += 2)
{
Color color38 = lightColor;
color38 = Color.Lerp(color38, color36, amount9);
color38 = npc.GetAlpha(color38);
color38 *= (float)(num153 - num155) / 15f;
Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition;
vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f;
vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY);
spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f);
}
}
Vector2 vector43 = npc.Center - Main.screenPosition;
vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * 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);
return false;
}
public override bool CanHitPlayer(Player target, ref int cooldownSlot)
{
cooldownSlot = 1;
return true;
}
public override void OnHitPlayer(Player player, int damage, bool crit)
{
player.AddBuff(ModContent.BuffType<LethalLavaBurn>(), 240, true);
}
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 bool PreNPCLoot()
{
return false;
}
}
}