when the throne is nuclear

This commit is contained in:
GinYuH committed 2023-01-13 20:41:42 -08:00
1 parent 93f935dba5
commit 37f1f491a9
2 files changed
+196

No files matched your search

+55
View File
@@ -30,8 +30,10 @@ namespace CalamityMod.NPCs.AcidRain
public int AttackIndex = 0;
public int DelayTime = 0;
public int DeathrayTime = 0;
public bool Dying = false;
public bool Walking = false;
public bool hasDoneDeathray = false;
public float JumpTimer = 0f;
public Vector2 ShootPosition;
public Player Target => Main.player[NPC.target];
@@ -135,9 +137,11 @@ namespace CalamityMod.NPCs.AcidRain
writer.Write(NPC.dontTakeDamage);
writer.Write(Dying);
writer.Write(Walking);
writer.Write(hasDoneDeathray);
writer.Write(AttackIndex);
writer.Write(DelayTime);
writer.Write(JumpTimer);
writer.Write(DeathrayTime);
writer.WriteVector2(ShootPosition);
}
public override void ReceiveExtraAI(BinaryReader reader)
@@ -145,8 +149,10 @@ namespace CalamityMod.NPCs.AcidRain
NPC.dontTakeDamage = reader.ReadBoolean();
Dying = reader.ReadBoolean();
Walking = reader.ReadBoolean();
hasDoneDeathray = reader.ReadBoolean();
AttackIndex = reader.ReadInt32();
DelayTime = reader.ReadInt32();
DeathrayTime = reader.ReadInt32();
JumpTimer = reader.ReadSingle();
ShootPosition = reader.ReadVector2();
}
@@ -188,6 +194,13 @@ namespace CalamityMod.NPCs.AcidRain
Walking = false;
if (Main.getGoodWorld && !hasDoneDeathray && NPC.life <= NPC.lifeMax * 0.1f) // move to zenith seed later
{
DeathrayTime++;
MasterSpark();
return;
}
// Teleport if spam-collisions are done, they are pretty good indicators of being stuck.
if (NPC.collideX)
{
@@ -446,6 +459,48 @@ namespace CalamityMod.NPCs.AcidRain
}
}
// Legendary Mode deathray attack
public void MasterSpark()
{
NPC.dontTakeDamage = true;
NPC.velocity.X *= 0.5f;
NPC.alpha = 0;
if (DeathrayTime < 240f)
{
int num5 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 200, default, 1.5f);
Main.dust[num5].noGravity = true;
Main.dust[num5].velocity *= 0.75f;
Main.dust[num5].fadeIn = 1.3f;
Vector2 vector = new Vector2((float)Main.rand.Next(-200, 201), (float)Main.rand.Next(-200, 201));
vector.Normalize();
vector *= (float)Main.rand.Next(100, 200) * 0.04f;
Main.dust[num5].velocity = vector;
vector.Normalize();
vector *= 34f;
Main.dust[num5].position = NPC.Center - vector;
}
else if (DeathrayTime == 240f)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
SoundEngine.PlaySound(SoundID.Zombie104, NPC.position);
int p = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Zero, ModContent.ProjectileType<GammaRayBurst>(), 250, 0f, Main.myPlayer, NPC.whoAmI);
if (p.WithinBounds(Main.maxProjectiles))
{
Main.projectile[p].rotation = NPC.spriteDirection * -MathHelper.PiOver2;
}
}
float screenShakePower = 20 * Utils.GetLerpValue(1300f, 0f, NPC.Distance(Main.LocalPlayer.Center), true);
if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < screenShakePower)
Main.LocalPlayer.Calamity().GeneralScreenShakePower = screenShakePower;
}
else if (DeathrayTime >= 630f)
{
NPC.dontTakeDamage = false;
hasDoneDeathray = true;
}
}
public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
{
NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * bossLifeScale);
+141
View File
@@ -0,0 +1,141 @@
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.NPCs.AcidRain;
using CalamityMod.Projectiles.BaseProjectiles;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using System;
using System.IO;
using System.Linq;
using Terraria;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Enemy
{
public class GammaRayBurst : BaseLaserbeamProjectile
{
public PrimitiveTrail LaserDrawer
{
get;
set;
} = null;
public int OwnerIndex
{
get => (int)Projectile.ai[0];
set => Projectile.ai[0] = value;
}
public override float MaxScale => 10f;
public override float MaxLaserLength => 4800f;
public override float Lifetime => 300;
public override Color LaserOverlayColor => new Color(0, 200, 50, 100);
public override Color LightCastColor => Color.White;
public override Texture2D LaserBeginTexture => ModContent.Request<Texture2D>(Texture).Value;
public override Texture2D LaserMiddleTexture => ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Lasers/AresLaserBeamMiddle", AssetRequestMode.ImmediateLoad).Value;
public override Texture2D LaserEndTexture => ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Lasers/AresLaserBeamEnd", AssetRequestMode.ImmediateLoad).Value;
public override string Texture => "CalamityMod/Projectiles/Boss/AresLaserBeamStart";
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Gamma Ray Burst");
Main.projFrames[Projectile.type] = 5;
ProjectileID.Sets.DrawScreenCheckFluff[Projectile.type] = 10000;
}
public override void SetDefaults()
{
Projectile.Calamity().DealsDefenseDamage = true;
Projectile.width = 30;
Projectile.height = 30;
Projectile.hostile = true;
Projectile.alpha = 255;
Projectile.penetrate = -1;
Projectile.tileCollide = false;
Projectile.timeLeft = 630;
CooldownSlot = ImmunityCooldownID.Bosses;
}
public override void SendExtraAI(BinaryWriter writer)
{
writer.Write(Projectile.localAI[0]);
writer.Write(Projectile.localAI[1]);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
Projectile.localAI[0] = reader.ReadSingle();
Projectile.localAI[1] = reader.ReadSingle();
}
public override void AttachToSomething()
{
if (Main.npc[OwnerIndex].active && Main.npc[OwnerIndex].type == ModContent.NPCType<NuclearTerror>())
{
Projectile.Center = Main.npc[OwnerIndex].Center;
}
// Die of the owner is invalid in some way.
else
{
Projectile.Kill();
return;
}
}
public override void UpdateLaserMotion()
{
Projectile.rotation += Main.npc[OwnerIndex].spriteDirection * 0.005f;
Projectile.velocity = (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2();
}
public override void PostAI()
{
// Determine frames.
Projectile.frameCounter++;
if (Projectile.frameCounter % 5f == 0f)
Projectile.frame = (Projectile.frame + 1) % Main.projFrames[Projectile.type];
}
public float LaserWidthFunction(float _) => Projectile.scale * Projectile.width;
public static Color LaserColorFunction(float completionRatio)
{
float colorInterpolant = (float)Math.Sin(Main.GlobalTimeWrappedHourly * -3.2f + completionRatio * 23f) * 0.5f + 0.5f;
return Color.Lerp(Color.LightGreen, Color.Lime, colorInterpolant * 0.67f);
}
public override bool PreDraw(ref Color lightColor)
{
// This should never happen, but just in case.
if (Projectile.velocity == Vector2.Zero)
return false;
LaserDrawer ??= new(LaserWidthFunction, LaserColorFunction, null, GameShaders.Misc["CalamityMod:ArtemisLaser"]);
Vector2 laserEnd = Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.UnitY) * LaserLength;
Vector2[] baseDrawPoints = new Vector2[8];
for (int i = 0; i < baseDrawPoints.Length; i++)
baseDrawPoints[i] = Vector2.Lerp(Projectile.Center, laserEnd, i / (float)(baseDrawPoints.Length - 1f));
// Select textures to pass to the shader, along with the electricity color.
GameShaders.Misc["CalamityMod:ArtemisLaser"].UseColor(Color.Cyan);
GameShaders.Misc["CalamityMod:ArtemisLaser"].UseImage1("Images/Extra_189");
GameShaders.Misc["CalamityMod:ArtemisLaser"].UseImage2("Images/Misc/Perlin");
LaserDrawer.Draw(baseDrawPoints, -Main.screenPosition, 64);
return false;
}
public override void OnHitPlayer(Player target, int damage, bool crit)
{
if (damage <= 0)
return;
target.AddBuff(ModContent.BuffType<SulphuricPoisoning>(), 300);
}
public override bool CanHitPlayer(Player target) => Projectile.scale >= 0.5f;
}
}