Files
CalamityModPublic/Projectiles/Boss/AresLaserBeamStart.cs
T
Andrew Marheine 5019a0680a 1 - Reduced Rage damage from 50% to 35%.
2 - Increased God Slayer Dash cooldown from 15 to 20 seconds.
3 - Fixed Amalgam issue where buffs would persist even if Amalgam was taken off.
4 - Exoblade no longer has weird HP damage scaling.
5 - Nerfed Celestus stealth strike damage from 65% to 40%.
6 - Moved Consecrated and Desecrated Water and Nycthemeron to post-2 mechs.
7 - Exorcism now requires 6 of each mech boss soul.
8 - Thanatos laser noise.
9 - Slowing debuffs now have a 30 second cooldown on bosses instead of 20 seconds.
10 - Adjusted the drop rates for various items.
11 - Genisis and Alpha Ray big Y laser uses ID static i-frames instead of local.
2021-08-08 01:03:03 -05:00

247 lines
9.6 KiB
C#

using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.NPCs.ExoMechs.Ares;
using CalamityMod.Dusts;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.IO;
using Terraria;
using Terraria.Enums;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Boss
{
public class AresLaserBeamStart : ModProjectile
{
private int frameDrawn = 0;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Laser Beam");
}
public override void SetDefaults()
{
projectile.Calamity().canBreakPlayerDefense = true;
projectile.width = 30;
projectile.height = 30;
projectile.hostile = true;
projectile.alpha = 255;
projectile.penetrate = -1;
projectile.tileCollide = false;
projectile.timeLeft = 600;
cooldownSlot = 1;
}
public override void SendExtraAI(BinaryWriter writer)
{
writer.Write(frameDrawn);
writer.Write(projectile.localAI[0]);
writer.Write(projectile.localAI[1]);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
frameDrawn = reader.ReadInt32();
projectile.localAI[0] = reader.ReadSingle();
projectile.localAI[1] = reader.ReadSingle();
}
public override void AI()
{
Vector2? vector78 = null;
if (projectile.velocity.HasNaNs() || projectile.velocity == Vector2.Zero)
projectile.velocity = -Vector2.UnitY;
if (Main.npc[(int)projectile.ai[1]].active && Main.npc[(int)projectile.ai[1]].type == ModContent.NPCType<AresLaserCannon>())
{
float offset = 40f;
Vector2 fireFrom = Main.npc[(int)projectile.ai[1]].Calamity().newAI[3] == 0f ? new Vector2(Main.npc[(int)projectile.ai[1]].Center.X, Main.npc[(int)projectile.ai[1]].Center.Y + offset) : new Vector2(Main.npc[(int)projectile.ai[1]].Center.X + offset, Main.npc[(int)projectile.ai[1]].Center.Y);
projectile.position = fireFrom - new Vector2(projectile.width, projectile.height) / 2f;
}
else
projectile.Kill();
float num801 = 1f;
projectile.localAI[0] += 1f;
if (projectile.localAI[0] >= 60f)
{
projectile.Kill();
return;
}
if (projectile.localAI[0] % 5f == 0f)
{
frameDrawn++;
if (frameDrawn >= 5)
frameDrawn = 0;
}
projectile.scale = (float)Math.Sin(projectile.localAI[0] * (float)Math.PI / 60f) * 10f * num801;
if (projectile.scale > num801)
projectile.scale = num801;
float num804 = projectile.velocity.ToRotation();
projectile.rotation = num804 - MathHelper.PiOver2;
projectile.velocity = num804.ToRotationVector2();
float num805 = 3f; //3f
float num806 = projectile.width;
Vector2 samplingPoint = projectile.Center;
if (vector78.HasValue)
samplingPoint = vector78.Value;
float[] array3 = new float[(int)num805];
Collision.LaserScan(samplingPoint, projectile.velocity, num806 * projectile.scale, 2400f, array3);
float num807 = 0f;
for (int num808 = 0; num808 < array3.Length; num808++)
{
num807 += array3[num808];
}
num807 /= num805;
// Fire laser through walls at max length if target cannot be seen
if (!Collision.CanHitLine(Main.npc[(int)projectile.ai[1]].Center, 1, 1, Main.player[Main.npc[(int)projectile.ai[1]].target].Center, 1, 1))
{
num807 = 2400f;
}
float amount = 0.5f;
projectile.localAI[1] = MathHelper.Lerp(projectile.localAI[1], num807, amount); //length of laser, linear interpolation
Vector2 vector79 = projectile.Center + projectile.velocity * (projectile.localAI[1] - 14f);
int dustType = (int)CalamityDusts.Brimstone;
// Spawn dust at the start of the beam
Vector2 dustPos = projectile.Center + projectile.velocity * 14f;
for (int i = 0; i < 2; i++)
{
float dustRot = projectile.velocity.ToRotation() + ((Main.rand.Next(2) == 1) ? -1f : 1f) * MathHelper.PiOver2;
float dustVelMult = (float)Main.rand.NextDouble() * 2f + 2f;
Vector2 dustVel = new Vector2((float)Math.Cos(dustRot) * dustVelMult, (float)Math.Sin(dustRot) * dustVelMult);
int dust = Dust.NewDust(dustPos, 0, 0, dustType, -dustVel.X, -dustVel.Y, 0, default, 1f);
Main.dust[dust].noGravity = true;
Main.dust[dust].scale = 1.7f;
}
if (Main.rand.NextBool(5))
{
Vector2 dustRot = projectile.velocity.RotatedBy(MathHelper.PiOver2, default) * ((float)Main.rand.NextDouble() - 0.5f) * projectile.width;
int dust = Dust.NewDust(dustPos + dustRot - Vector2.One * 4f, 8, 8, dustType, 0f, 0f, 100, default, 1.5f);
Main.dust[dust].velocity *= 0.5f;
Main.dust[dust].velocity.Y = Math.Abs(Main.dust[dust].velocity.Y);
}
// Spawn dust at the end of the beam
dustPos = projectile.Center + projectile.velocity * (projectile.localAI[1] - 14f);
for (int i = 0; i < 2; i++)
{
float dustRot = projectile.velocity.ToRotation() + ((Main.rand.Next(2) == 1) ? -1f : 1f) * MathHelper.PiOver2;
float dustVelMult = (float)Main.rand.NextDouble() * 2f + 2f;
Vector2 dustVel = new Vector2((float)Math.Cos(dustRot) * dustVelMult, (float)Math.Sin(dustRot) * dustVelMult);
int dust = Dust.NewDust(dustPos, 0, 0, dustType, dustVel.X, dustVel.Y, 0, default, 1f);
Main.dust[dust].noGravity = true;
Main.dust[dust].scale = 1.7f;
}
if (Main.rand.NextBool(5))
{
Vector2 dustRot = projectile.velocity.RotatedBy(MathHelper.PiOver2, default) * ((float)Main.rand.NextDouble() - 0.5f) * projectile.width;
int dust = Dust.NewDust(dustPos + dustRot - Vector2.One * 4f, 8, 8, dustType, 0f, 0f, 100, default, 1.5f);
Main.dust[dust].velocity *= 0.5f;
Main.dust[dust].velocity.Y = -Math.Abs(Main.dust[dust].velocity.Y);
}
DelegateMethods.v3_1 = new Vector3(0.9f, 0.3f, 0.3f);
Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CastLight));
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
if (projectile.velocity == Vector2.Zero)
return false;
Texture2D beamStart = Main.projectileTexture[projectile.type];
Texture2D beamMiddle = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/AresLaserBeamMiddle");
Texture2D beamEnd = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/AresLaserBeamEnd");
float drawLength = projectile.localAI[1];
Color color = new Color(250, 100, 100, 0);
// Draw start of beam
Vector2 vector = projectile.Center - Main.screenPosition;
Rectangle? sourceRectangle = new Rectangle(0, beamStart.Height / 5 * frameDrawn, beamStart.Width, beamStart.Height / 5);
spriteBatch.Draw(beamStart, vector, sourceRectangle, color, projectile.rotation, new Vector2(beamStart.Width, beamStart.Height / 5) / 2f, projectile.scale, SpriteEffects.None, 0f);
// Draw middle of beam
drawLength -= (beamStart.Height / 5 / 2 + beamEnd.Height / 5) * projectile.scale;
Vector2 center = projectile.Center;
center += projectile.velocity * projectile.scale * beamStart.Height / 5f / 2f;
if (drawLength > 0f)
{
float i = 0f;
int middleFrameDrawn = frameDrawn;
Rectangle rectangle = new Rectangle(0, beamMiddle.Height / 5 * middleFrameDrawn, beamMiddle.Width, beamMiddle.Height / 5);
while (i + 1f < drawLength)
{
if (drawLength - i < rectangle.Height)
rectangle.Height = (int)(drawLength - i);
spriteBatch.Draw(beamMiddle, center - Main.screenPosition, rectangle, color, projectile.rotation, new Vector2(rectangle.Width / 2f, 0f), projectile.scale, SpriteEffects.None, 0f);
middleFrameDrawn++;
if (middleFrameDrawn >= 5)
middleFrameDrawn = 0;
i += rectangle.Height * projectile.scale;
center += projectile.velocity * rectangle.Height * projectile.scale;
rectangle.Y += beamMiddle.Height / 5;
if (rectangle.Y + rectangle.Height > beamMiddle.Height / 5)
rectangle.Y = 0;
}
}
// Draw end of beam
Vector2 vector2 = center - Main.screenPosition;
sourceRectangle = new Rectangle(0, beamEnd.Height / 5 * frameDrawn, beamEnd.Width, beamEnd.Height / 5);
spriteBatch.Draw(beamEnd, vector2, sourceRectangle, color, projectile.rotation, new Vector2(beamEnd.Width, beamEnd.Height / 5) / 2f, projectile.scale, SpriteEffects.None, 0f);
return false;
}
public override void CutTiles()
{
DelegateMethods.tilecut_0 = TileCuttingContext.AttackProjectile;
Vector2 unit = projectile.velocity;
Utils.PlotTileLine(projectile.Center, projectile.Center + unit * projectile.localAI[1], projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CutTiles));
}
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
{
if (projHitbox.Intersects(targetHitbox))
{
return true;
}
float num6 = 0f;
if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], 30f * projectile.scale, ref num6))
{
return true;
}
return false;
}
public override void OnHitPlayer(Player target, int damage, bool crit)
{
target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 300);
}
public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit)
{
target.Calamity().lastProjectileHit = projectile;
}
}
}