New Laser Walls

Wowza, these sure are new laser walls
This commit is contained in:
Xyk committed 2025-06-18 02:37:51 -07:00
1 parent 591ec0342b
commit 1e855d3cb4
7 files changed
+332 -362

No files matched your search

@@ -52,6 +52,8 @@ DoGBeamPortal.DisplayName: Beam Portal
DoGDeath.DisplayName: Death Beam
DoGDeathBoom.DisplayName: Cosmic Explosion
DoGFire.DisplayName: Death Fire
DoGLaserWalls.DisplayName: God's Bane Doombeam Array
DoGLaserWallsBigBeam.DisplayName: Hyperdeath Rift Ripper
DoGP1EndPortal.DisplayName: Portal
DoGTeleportRift.DisplayName: Rift
DoGWingdings.DisplayName: Ramblings of Wing DoGster
+11 -362
View File
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.Eventing.Reader;
using System.IO;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.Dusts;
using CalamityMod.Events;
@@ -10,12 +8,10 @@ using CalamityMod.Items.Accessories;
using CalamityMod.Items.Armor.Vanity;
using CalamityMod.Items.LoreItems;
using CalamityMod.Items.Materials;
using CalamityMod.Items.Mounts;
using CalamityMod.Items.Placeables.Furniture;
using CalamityMod.Items.Placeables.Furniture.BossRelics;
using CalamityMod.Items.Placeables.Furniture.DevPaintings;
using CalamityMod.Items.Placeables.Furniture.Trophies;
using CalamityMod.Items.Placeables.FurnitureAbyss;
using CalamityMod.Items.Placeables.FurnitureCosmilite;
using CalamityMod.Items.Potions;
using CalamityMod.Items.TreasureBags;
@@ -32,7 +28,6 @@ using CalamityMod.Sounds;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using ReLogic.Content;
using Terraria;
using Terraria.Audio;
@@ -40,7 +35,6 @@ using Terraria.GameContent;
using Terraria.GameContent.Bestiary;
using Terraria.GameContent.Events;
using Terraria.GameContent.ItemDropRules;
using Terraria.Graphics;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.Localization;
@@ -74,22 +68,8 @@ namespace CalamityMod.NPCs.DevourerofGods
// Phase 1 variables
// Enums
private enum LaserWallType
{
DiagonalRight = 0,
DiagonalLeft = 1,
DiagonalHorizontal = 2,
DiagonalCross = 3
}
// Laser spread variables
private const int shotSpacingMax = 1440;
private int shotSpacing = shotSpacingMax;
private const int totalShots = 10;
private const int spacingVar = shotSpacingMax / totalShots * 2;
private int laserWallType = 0;
private const float laserWallSpacingOffset = 16f;
// Continuously reset variables
public bool AttemptingToEnterPortal = false;
@@ -117,23 +97,8 @@ namespace CalamityMod.NPCs.DevourerofGods
FireLaserWalls = 1,
End = 2
}
private enum LaserWallType_Phase2
{
Normal = 0,
Offset = 1,
DiagonalHorizontal = 2,
MultiLayered = 3,
DiagonalVertical = 4
}
// Laser wall variables
private const int shotSpacingMax_Phase2 = 1440;
private int[] shotSpacing_Phase2 = new int[4] { shotSpacingMax_Phase2, shotSpacingMax_Phase2, shotSpacingMax_Phase2, shotSpacingMax_Phase2 };
private const int spacingVar_Phase2 = 120;
private const int totalShots_Phase2 = 24;
private const int totalDiagonalShots = 6;
private const int diagonalSpacingVar = shotSpacingMax_Phase2 / totalDiagonalShots * 2;
private int laserWallType_Phase2 = 0;
public int laserWallPhase = 0;
// Phase variables
@@ -304,8 +269,6 @@ namespace CalamityMod.NPCs.DevourerofGods
writer.Write(hasCreatedPhase1Portal);
writer.Write(AwaitingPhase2Teleport);
writer.Write(spawnDoGCountdown);
writer.Write(shotSpacing);
writer.Write(laserWallType);
writer.Write(PortalIndex);
for (int i = 0; i < 4; i++)
writer.Write(NPC.Calamity().newAI[i]);
@@ -313,13 +276,8 @@ namespace CalamityMod.NPCs.DevourerofGods
// Phase 2 syncs
writer.Write(NPC.localAI[2]);
writer.Write(NPC.localAI[3]);
writer.Write(shotSpacing_Phase2[0]);
writer.Write(shotSpacing_Phase2[1]);
writer.Write(shotSpacing_Phase2[2]);
writer.Write(shotSpacing_Phase2[3]);
writer.Write(idleCounter);
writer.Write(laserWallPhase);
writer.Write(laserWallType_Phase2);
writer.Write(postTeleportTimer);
writer.Write(teleportTimer);
writer.Write(NPC.Opacity);
@@ -357,8 +315,6 @@ namespace CalamityMod.NPCs.DevourerofGods
hasCreatedPhase1Portal = reader.ReadBoolean();
AwaitingPhase2Teleport = reader.ReadBoolean();
spawnDoGCountdown = reader.ReadInt32();
shotSpacing = reader.ReadInt32();
laserWallType = reader.ReadInt32();
PortalIndex = reader.ReadInt32();
for (int i = 0; i < 4; i++)
NPC.Calamity().newAI[i] = reader.ReadSingle();
@@ -366,13 +322,8 @@ namespace CalamityMod.NPCs.DevourerofGods
// Phase 2 syncs
NPC.localAI[2] = reader.ReadSingle();
NPC.localAI[3] = reader.ReadSingle();
shotSpacing_Phase2[0] = reader.ReadInt32();
shotSpacing_Phase2[1] = reader.ReadInt32();
shotSpacing_Phase2[2] = reader.ReadInt32();
shotSpacing_Phase2[3] = reader.ReadInt32();
idleCounter = reader.ReadInt32();
laserWallPhase = reader.ReadInt32();
laserWallType_Phase2 = reader.ReadInt32();
postTeleportTimer = reader.ReadInt32();
teleportTimer = reader.ReadInt32();
NPC.Opacity = reader.ReadSingle();
@@ -892,197 +843,21 @@ namespace CalamityMod.NPCs.DevourerofGods
// Laser walls
if (laserWallPhase == (int)LaserWallPhase.FireLaserWalls)
{
float spawnOffset = 1200f;
float divisor = bossRush || death ? 125f : 150f;
float divisor = bossRush || death ? 100f : 120f;
if (phase6)
divisor -= 50;
divisor -= 15;
if (calamityGlobalNPC.newAI[1] % divisor == 0f)
{
int bonusLenience = 0;
if (calamityGlobalNPC.newAI[1] == 0 || phase6)
{
bonusLenience = 16;
}
SoundEngine.PlaySound(SoundID.Item12, player.Center);
// Side walls
float targetPosY = player.position.Y;
int type = ModContent.ProjectileType<DoGDeath>();
int damage = NPC.GetProjectileDamage(type);
int halfTotalDiagonalShots = totalDiagonalShots / 2;
Vector2 start = default;
Vector2 velocity = default;
Vector2 aim = expertMode ? player.Center + player.velocity * 20f : Vector2.Zero;
switch (laserWallType_Phase2)
if (Main.netMode != NetmodeID.MultiplayerClient)
{
case (int)LaserWallType_Phase2.Normal:
for (int x = 0; x < totalShots_Phase2; x++)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[0], -laserVelocity, 0f, type, damage, 0f, Main.myPlayer);
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[0], laserVelocity, 0f, type, damage, 0f, Main.myPlayer);
}
shotSpacing_Phase2[0] -= spacingVar_Phase2+ bonusLenience;
}
if (expertMode && Main.netMode != NetmodeID.MultiplayerClient)
{
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer);
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer);
}
break;
case (int)LaserWallType_Phase2.Offset:
targetPosY += 50f;
for (int x = 0; x < totalShots_Phase2; x++)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[0], -laserVelocity, 0f, type, damage, 0f, Main.myPlayer);
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[0], laserVelocity, 0f, type, damage, 0f, Main.myPlayer);
}
shotSpacing_Phase2[0] -= spacingVar_Phase2 + bonusLenience;
}
if (expertMode && Main.netMode != NetmodeID.MultiplayerClient)
{
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer);
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer);
}
break;
case (int)LaserWallType_Phase2.DiagonalHorizontal:
for (int x = 0; x < totalDiagonalShots + 1; x++)
{
start = new Vector2(player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[0]);
aim.Y += laserWallSpacingOffset * (x - halfTotalDiagonalShots);
velocity = Vector2.Normalize(aim - start) * laserVelocity;
if (Main.netMode != NetmodeID.MultiplayerClient)
Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer);
start = new Vector2(player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[0]);
velocity = Vector2.Normalize(aim - start) * laserVelocity;
if (Main.netMode != NetmodeID.MultiplayerClient)
Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer);
shotSpacing_Phase2[0] -= diagonalSpacingVar + bonusLenience;
}
if (Main.netMode != NetmodeID.MultiplayerClient)
{
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center.X, targetPosY + spawnOffset, 0f, -laserVelocity, type, damage, 0f, Main.myPlayer);
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center.X, targetPosY - spawnOffset, 0f, laserVelocity, type, damage, 0f, Main.myPlayer);
}
break;
case (int)LaserWallType_Phase2.MultiLayered:
for (int x = 0; x < totalShots_Phase2; x++)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[0], -laserVelocity, 0f, type, damage, 0f, Main.myPlayer);
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[0], laserVelocity, 0f, type, damage, 0f, Main.myPlayer);
}
shotSpacing_Phase2[0] -= spacingVar_Phase2 + bonusLenience;
}
int totalBonusLasers = totalShots_Phase2 / 2;
for (int x = 0; x < totalBonusLasers; x++)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[3], -laserVelocity, 0f, type, damage, 0f, Main.myPlayer);
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[3], laserVelocity, 0f, type, damage, 0f, Main.myPlayer);
}
shotSpacing_Phase2[3] -= Main.rand.NextBool() ? 215 : 235;
}
if (Main.netMode != NetmodeID.MultiplayerClient)
{
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer);
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer);
}
break;
case (int)LaserWallType_Phase2.DiagonalVertical:
for (int x = 0; x < totalDiagonalShots + 1; x++)
{
start = new Vector2(player.position.X + shotSpacing_Phase2[0], targetPosY + spawnOffset);
aim.X += laserWallSpacingOffset * (x - halfTotalDiagonalShots);
velocity = Vector2.Normalize(aim - start) * laserVelocity;
if (Main.netMode != NetmodeID.MultiplayerClient)
Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer);
start = new Vector2(player.position.X + shotSpacing_Phase2[0], targetPosY - spawnOffset);
velocity = Vector2.Normalize(aim - start) * laserVelocity;
if (Main.netMode != NetmodeID.MultiplayerClient)
Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer);
shotSpacing_Phase2[0] -= diagonalSpacingVar + bonusLenience;
}
if (Main.netMode != NetmodeID.MultiplayerClient)
{
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer);
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer);
}
break;
int bType = Main.rand.Next(0, 5 + 1);
Projectile.NewProjectileDirect(NPC.GetSource_FromAI(), player.Center, Vector2.Zero, ModContent.ProjectileType<DoGLaserWalls>(), damage, 0, Main.myPlayer, (bossRush || death) ? 0.55f : 0.5f, 250, bType);
Projectile.NewProjectileDirect(NPC.GetSource_FromAI(), player.Center, Vector2.Zero, ModContent.ProjectileType<DoGLaserWallsBigBeam>(), damage, 0, Main.myPlayer, (bossRush || death) ? 0.55f : 0.5f, 0, bType);
}
// Pick a random laser wall phase in expert+
if (expertMode)
{
int laserWallPhase;
int choices = revenge ? 5 : 3;
do laserWallPhase = Main.rand.Next(choices);
while (laserWallPhase == laserWallType_Phase2);
laserWallType_Phase2 = laserWallPhase;
}
else
laserWallType_Phase2 = laserWallType_Phase2 == (int)LaserWallType_Phase2.Normal ? (int)LaserWallType_Phase2.Offset : (int)LaserWallType_Phase2.Normal;
// Lower wall
for (int x = 0; x < totalShots_Phase2; x++)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + shotSpacing_Phase2[1], player.position.Y + spawnOffset, 0f, -laserVelocity, type, damage, 0f, Main.myPlayer);
shotSpacing_Phase2[1] -= spacingVar_Phase2 + bonusLenience;
}
// Upper wall
for (int x = 0; x < totalShots_Phase2; x++)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + shotSpacing_Phase2[2], player.position.Y - spawnOffset, 0f, laserVelocity, type, damage, 0f, Main.myPlayer);
shotSpacing_Phase2[2] -= spacingVar_Phase2 + bonusLenience;
}
for (int i = 0; i < shotSpacing_Phase2.Length; i++)
shotSpacing_Phase2[i] = shotSpacingMax_Phase2;
}
calamityGlobalNPC.newAI[1] += 1f;
}
@@ -1798,143 +1573,17 @@ namespace CalamityMod.NPCs.DevourerofGods
if (calamityGlobalNPC.newAI[1] % (int)(laserBarrageShootGateValue * (death ? 0.33f : 0.5f)) == 0f && calamityGlobalNPC.newAI[1] > 0f)
{
SoundEngine.PlaySound(SoundID.Item12, player.Center);
// Side walls
int type = ModContent.ProjectileType<DoGDeath>();
int damage = NPC.GetProjectileDamage(type);
Vector2 start = default;
Vector2 velocity = default;
Vector2 aim = expertMode ? player.Center + player.velocity * 20f : Vector2.Zero;
Vector2 aimClone = aim;
switch (laserWallType)
if (Main.netMode != NetmodeID.MultiplayerClient)
{
case (int)LaserWallType.DiagonalRight:
for (int x = 0; x < totalShots + 1; x++)
{
start = new Vector2(player.position.X + spawnOffset, player.position.Y + shotSpacing);
aim.Y += laserWallSpacingOffset * (x - 3);
velocity = Vector2.Normalize(aim - start) * laserVelocity;
if (Main.netMode != NetmodeID.MultiplayerClient)
Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer);
shotSpacing -= spacingVar;
}
if (expertMode && Main.netMode != NetmodeID.MultiplayerClient)
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer);
break;
case (int)LaserWallType.DiagonalLeft:
for (int x = 0; x < totalShots + 1; x++)
{
start = new Vector2(player.position.X - spawnOffset, player.position.Y + shotSpacing);
aim.Y += laserWallSpacingOffset * (x - 3);
velocity = Vector2.Normalize(aim - start) * laserVelocity;
if (Main.netMode != NetmodeID.MultiplayerClient)
Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer);
shotSpacing -= spacingVar;
}
if (expertMode && Main.netMode != NetmodeID.MultiplayerClient)
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer);
break;
case (int)LaserWallType.DiagonalHorizontal:
for (int x = 0; x < totalShots + 1; x++)
{
start = new Vector2(player.position.X + spawnOffset, player.position.Y + shotSpacing);
aim.Y += laserWallSpacingOffset * (x - 3);
velocity = Vector2.Normalize(aim - start) * laserVelocity;
if (Main.netMode != NetmodeID.MultiplayerClient)
Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer);
start = new Vector2(player.position.X - spawnOffset, player.position.Y + shotSpacing);
velocity = Vector2.Normalize(aim - start) * laserVelocity;
if (Main.netMode != NetmodeID.MultiplayerClient)
Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer);
shotSpacing -= spacingVar;
}
if (expertMode && Main.netMode != NetmodeID.MultiplayerClient)
{
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer);
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer);
}
break;
case (int)LaserWallType.DiagonalCross:
int randomLaserGap = Main.rand.Next(3) + 3; // 3, 4, 5, 6
for (int x = 0; x < totalShots + 1; x++)
{
if (x != randomLaserGap && x != randomLaserGap + 1)
{
start = new Vector2(player.position.X + spawnOffset, player.position.Y + shotSpacing);
aim.Y += laserWallSpacingOffset * (x - 3);
velocity = Vector2.Normalize(aim - start) * laserVelocity;
if (Main.netMode != NetmodeID.MultiplayerClient)
Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer);
start = new Vector2(player.position.X - spawnOffset, player.position.Y + shotSpacing);
velocity = Vector2.Normalize(aim - start) * laserVelocity;
if (Main.netMode != NetmodeID.MultiplayerClient)
Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer);
start = new Vector2(player.position.X + shotSpacing, player.position.Y + spawnOffset);
aimClone.X += laserWallSpacingOffset * (x - 3);
velocity = Vector2.Normalize(aimClone - start) * laserVelocity;
if (Main.netMode != NetmodeID.MultiplayerClient)
Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer);
start = new Vector2(player.position.X + shotSpacing, player.position.Y - spawnOffset);
velocity = Vector2.Normalize(aimClone - start) * laserVelocity;
if (Main.netMode != NetmodeID.MultiplayerClient)
Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer);
}
shotSpacing -= spacingVar;
}
if (expertMode && Main.netMode != NetmodeID.MultiplayerClient)
{
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer);
Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer);
}
break;
int bType = Main.rand.Next(0, 5 + 1);
Projectile.NewProjectileDirect(NPC.GetSource_FromAI(), player.Center, Vector2.Zero, ModContent.ProjectileType<DoGLaserWalls>(), damage, 0, Main.myPlayer, (bossRush || death) ? 0.4f : 0.45f, 250, bType);
//Projectile.NewProjectileDirect(NPC.GetSource_FromAI(), player.Center, Vector2.Zero, ModContent.ProjectileType<DoGLaserWallsBigBeam>(), damage, 0, Main.myPlayer, (bossRush || death) ? 0.3f : 0.4f, 250, bType);
}
// Pick a random laser wall phase in expert+
if (expertMode)
{
int laserWallPhase;
int choices = revenge ? 4 : 3;
do laserWallPhase = Main.rand.Next(choices);
while (laserWallPhase == laserWallType);
laserWallType = laserWallPhase;
}
else
laserWallType = laserWallType == (int)LaserWallType.DiagonalRight ? (int)LaserWallType.DiagonalLeft : (int)LaserWallType.DiagonalRight;
shotSpacing = shotSpacingMax;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

+180
View File
@@ -0,0 +1,180 @@
using System;
using System.Net;
using CalamityMod.Items.Weapons.Rogue;
using CalamityMod.Particles;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace CalamityMod.Projectiles.Boss
{
public class DoGLaserWalls : ModProjectile, ILocalizedModType
{
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public new string LocalizationCategory => "Projectiles.Boss";
public float time = 0;
public ref float attackSpeed => ref Projectile.ai[0]; // How fast the attack goes, higher is faster
public ref float laserDist => ref Projectile.ai[1]; // The spacing between lasers
public ref float laserType => ref Projectile.ai[2]; // The style of laser wall, ranging from 0 - 5
public bool canDamage => doneAttack && laserFX >= 1f;
public bool doneAttack = false;
public int attackTime = 30;
public int laserCount => (int)(6000 / Math.Max(laserDist, 1));
public float laserLength => laserDist * laserCount / 2;
public float laserFX = 0;
public float storedTime = 0;
public Color drawColor = Color.Cyan;
public float sine = 0;
public Vector2 storedTargetPos;
public Player targeted;
public Vector2 targetPos => (targeted == null ? Projectile.Center : targeted.Center);
public override void SetStaticDefaults()
{
ProjectileID.Sets.DrawScreenCheckFluff[Type] = 10000;
}
public override void SetDefaults()
{
Projectile.width = 1;
Projectile.height = 1;
Projectile.hostile = true;
Projectile.ignoreWater = true;
Projectile.tileCollide = false;
Projectile.penetrate = -1;
Projectile.timeLeft = 6000;
}
public override void AI()
{
if (laserFX > 0)
laserFX = MathHelper.Lerp(laserFX, 0, time > 15 ? 0.12f : 0.01f);
sine = (float)Math.Sin(time * 4f / MathHelper.Pi);
if (time == 0)
{
targeted = Main.player[Player.FindClosest(Projectile.Center, 1, 1)];
Projectile.Center += Main.rand.NextVector2CircularEdge(400, 400);
// Some default values for if the projectile spawns without them set
if (attackSpeed == 0)
attackSpeed = 0.5f;
if (laserDist == 0)
laserDist = 250;
Projectile.velocity = Vector2.Zero;
laserFX = 1f;
SoundStyle appear = new("CalamityMod/Sounds/Custom/DoGLaserWallSpawn");
SoundEngine.PlaySound(appear with { Volume = 1f, Pitch = 0f, MaxInstances = -1 }, targetPos);
storedTargetPos = targetPos;
Projectile.ForceNetUpdate();
}
if (time >= attackTime && !doneAttack)
{
SoundStyle attack = new("CalamityMod/Sounds/Custom/DoGLaserWallAttack");
for (int i = 0; i < 2; i++)
SoundEngine.PlaySound(attack with { Volume = 0.9f, Pitch = Main.rand.NextFloat(-0.1f, 0.1f), MaxInstances = -1 }, targetPos);
laserFX = 3;
doneAttack = true;
storedTime = time;
Projectile.ForceNetUpdate();
}
float endTime = storedTime + 10;
if (time >= endTime && doneAttack)
{
Projectile.Kill();
return;
}
else if (doneAttack)
{
drawColor = Color.Lerp(Color.Cyan, Color.Magenta, (float)Math.Pow(Utils.GetLerpValue(endTime, storedTime, time, true), 2));
}
time += attackSpeed;
}
public override bool CanHitPlayer(Player target)
{
if (canDamage)
return true;
return false;
}
public override void OnHitPlayer(Player target, Player.HurtInfo info)
{
base.OnHitPlayer(target, info);
}
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
{
if (!canDamage)
return false;
else
{
float _ = float.NaN;
bool hit = false;
Vector2 X = Vector2.UnitX.RotatedBy((laserType == 1 || laserType == 3 || laserType == 5) ? MathHelper.PiOver4 : 0);
Vector2 Y = Vector2.UnitY.RotatedBy((laserType == 1 || laserType == 3 || laserType == 5) ? MathHelper.PiOver4 : 0);
for (int l = 0; l < 2; l++)
{
bool horizontal = (l != 0);
bool crossLasers = ((laserType == 2 && !horizontal) || (laserType == 3 && !horizontal) || (laserType == 4 && horizontal) || (laserType == 5 && horizontal));
float length = laserLength * (horizontal ? 1f : 1f);
for (int i = 0; i < laserCount; i += (crossLasers ? 2 : 1))
{
Vector2 startPoint = Projectile.Center - (horizontal ? Y : X) * (length);
Vector2 laserPoint = startPoint + (horizontal ? X : Y) * (laserDist * i) - (horizontal ? X : Y) * (laserDist * laserCount / 2);
Vector2 rot = laserPoint.DirectionTo(storedTargetPos);
Vector2 start = laserPoint;
Vector2 end = laserPoint + (crossLasers ? rot : (horizontal ? Y : X)) * laserLength * 2;
bool hitCheck = Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), start, end, 10, ref _);
if (hitCheck)
{
hit = true;
i = laserCount;
}
}
}
return hit;
}
}
public override bool PreDraw(ref Color lightColor)
{
if (laserFX == 0)
return false;
Texture2D beam = ModContent.Request<Texture2D>("CalamityMod/Particles/BloomLineThick").Value;
Texture2D bBeam = ModContent.Request<Texture2D>("CalamityMod/Particles/LineThick").Value;
Texture2D bloom = ModContent.Request<Texture2D>("CalamityMod/Particles/BloomCircle").Value;
float opacity = (doneAttack ? 1 : 0.3f) * (float)Math.Pow(Math.Min(laserFX, 1), 2);
Color beamColor = drawColor with { A = 0 };
Vector2 X = Vector2.UnitX.RotatedBy((laserType == 1 || laserType == 3 || laserType == 5) ? MathHelper.PiOver4 : 0);
Vector2 Y = Vector2.UnitY.RotatedBy((laserType == 1 || laserType == 3 || laserType == 5) ? MathHelper.PiOver4 : 0);
for (int l = 0; l < 2; l++)
{
bool horizontal = (l != 0);
float length = laserLength;
bool crossLasers = ((laserType == 2 && !horizontal) || (laserType == 3 && !horizontal) || (laserType == 4 && horizontal) || (laserType == 5 && horizontal));
for (int i = 0; i < laserCount; i += (crossLasers ? 2 : 1))
{
Vector2 startPoint = Projectile.Center - (horizontal ? Y : X) * (length);
Vector2 laserPoint = startPoint + (horizontal ? X : Y) * (laserDist * i) - (horizontal ? X : Y) * (laserDist * laserCount / 2);
if (CalamityClientConfig.Instance.Photosensitivity)
opacity = 0.2f;
for (int t = 0; t < (!doneAttack ? 1 : 5); t++)
{
bool black = (t > 0);
Texture2D usedTex = (black ? bBeam : beam);
float beamThickness = 0.03f * (black ? (0.8f - 0.15f * t) : 1f) * (laserFX <= 1 ? (float)Math.Pow(Math.Min(laserFX, 1), 2) : laserFX) * Utils.Remap(sine, -1, 1, 0.8f, 1.1f);
float rot = (horizontal ? MathHelper.Pi : MathHelper.PiOver2) + ((laserType == 1 || laserType == 3 || laserType == 5) ? MathHelper.PiOver4 : 0);
if (crossLasers)
rot = laserPoint.DirectionTo(storedTargetPos).ToRotation() + (MathHelper.PiOver2);
Main.EntitySpriteDraw(usedTex, laserPoint - Main.screenPosition, null, (black ? Color.Black * opacity : beamColor * opacity) * (black ? (0.2f + 0.15f * t) : 1), rot, new Vector2(beam.Width / 2, beam.Height), new Vector2(beamThickness, length / 975) * Projectile.scale, SpriteEffects.None);
}
}
}
return false;
}
}
}
+139
View File
@@ -0,0 +1,139 @@
using System;
using CalamityMod.Projectiles.Rogue;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Boss
{
public class DoGLaserWallsBigBeam : ModProjectile, ILocalizedModType
{
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public new string LocalizationCategory => "Projectiles.Boss";
public float time = 0;
public ref float attackSpeed => ref Projectile.ai[0];
public ref float laserType => ref Projectile.ai[2];
public bool canDamage => doneAttack && laserFX >= 1f;
public bool doneAttack = false;
public int attackTime = 30;
public float laserLength => 3000;
public float laserFX = 0;
public float storedTime = 0;
public Color drawColor = Color.Magenta;
public float sine = 0;
public float laserRot = 0;
Vector2 beamStart = Vector2.Zero;
Vector2 directionToTarget = Vector2.Zero;
public Player targeted;
public Vector2 targetPos => (targeted == null ? Projectile.Center : targeted.Center);
public override void SetStaticDefaults()
{
ProjectileID.Sets.DrawScreenCheckFluff[Type] = 10000;
}
public override void SetDefaults()
{
Projectile.width = 1;
Projectile.height = 1;
Projectile.hostile = true;
Projectile.ignoreWater = true;
Projectile.tileCollide = false;
Projectile.penetrate = -1;
Projectile.timeLeft = 6000;
Projectile.scale = 2;
}
public override void AI()
{
if (laserFX > 0)
laserFX = MathHelper.Lerp(laserFX, 0, time > 15 ? 0.07f : 0.01f);
sine = (float)Math.Sin(time * 4f / MathHelper.Pi);
if (time == 0)
{
targeted = Main.player[Player.FindClosest(Projectile.Center, 1, 1)];
if (CalamityWorld.LegendaryMode)
Projectile.scale = 6;
laserRot = Main.rand.NextFloat(-0.4f, 0.4f);
beamStart = targetPos + ((laserType == 0 || laserType == 4 || laserType == 5) ? Vector2.UnitX : Vector2.UnitY).RotatedBy(laserRot) * laserLength;
directionToTarget = beamStart.DirectionTo(targetPos);
Projectile.Center += Main.rand.NextVector2CircularEdge(400, 400);
// Some default values for if the projectile spawns without them set
if (attackSpeed == 0)
attackSpeed = 0.5f;
Projectile.velocity = Vector2.Zero;
laserFX = 1f;
Projectile.ForceNetUpdate();
}
if (time >= attackTime && !doneAttack)
{
laserFX = 2.5f;
doneAttack = true;
storedTime = time;
Projectile.ForceNetUpdate();
}
float endTime = storedTime + 10;
if (time >= endTime && doneAttack)
{
Projectile.Kill();
return;
}
else if (doneAttack)
{
drawColor = Color.Lerp(Color.Magenta, Color.Cyan, (float)Math.Pow(Utils.GetLerpValue(endTime, storedTime, time, true), 2));
}
time += attackSpeed;
}
public override bool CanHitPlayer(Player target)
{
if (canDamage)
return true;
return false;
}
public override void OnHitPlayer(Player target, Player.HurtInfo info)
{
base.OnHitPlayer(target, info);
}
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
{
if (!canDamage)
return false;
else
{
float _ = float.NaN;
Vector2 start = beamStart;
Vector2 end = beamStart + directionToTarget * laserLength * 2;
bool hitCheck = Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), start, end, 30 * Projectile.scale, ref _);
return hitCheck;
}
}
public override bool PreDraw(ref Color lightColor)
{
if (laserFX == 0)
return false;
Texture2D beam = ModContent.Request<Texture2D>("CalamityMod/Particles/BloomLineThick").Value;
Texture2D bBeam = ModContent.Request<Texture2D>("CalamityMod/Particles/LineThick").Value;
Texture2D bloom = ModContent.Request<Texture2D>("CalamityMod/Particles/BloomCircle").Value;
float opacity = (doneAttack ? 1 : 0.45f) * (float)Math.Pow(Math.Min(laserFX, 1), 2);
Color beamColor = drawColor with { A = 0 };
if (CalamityClientConfig.Instance.Photosensitivity)
opacity = 0.2f;
for (int t = 0; t < (!doneAttack ? 1 : 4 * Projectile.scale); t ++)
{
bool black = (t > 0 + (Projectile.scale - 1));
if (black)
beam = bBeam;
float beamThickness = 0.09f * (black ? (0.8f - 0.15f * t / Projectile.scale) : 1f) * (laserFX <= 1 ? (float)Math.Pow(Math.Min(laserFX, 1), 2) : laserFX) * Utils.Remap(sine, -1, 1, 0.8f, 1.1f);
Main.EntitySpriteDraw(beam, beamStart - Main.screenPosition, null, (black ? Color.Black * opacity : beamColor * (1 - t * 0.3f) * opacity) * (black ? (0.2f + 0.15f * t / Projectile.scale) : 1), directionToTarget.ToRotation() + MathHelper.PiOver2, new Vector2(beam.Width / 2, beam.Height), new Vector2(beamThickness, laserLength / 975) * Projectile.scale, SpriteEffects.None);
}
//Main.EntitySpriteDraw(bloom, Projectile.Center - Main.screenPosition, null, Color.Red with { A = 0 }, 0, bloom.Size() / 2, 0.3f, SpriteEffects.None);
return false;
}
}
}
Binary file not shown.
Binary file not shown.