DoG Laser wall telegraph thing

This commit is contained in:
DominicKarma42 committed 2020-06-09 15:40:26 -05:00
1 parent c5da3dce00
commit 0e386da4d8
3 files changed
+92 -12

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

+9 -7
View File
@@ -310,7 +310,9 @@ namespace CalamityMod.NPCs.DevourerofGods
{
laserShoot += 1;
float speed = 4f;
float speed = 10.5f;
float spawnOffsetX = 1900f;
float spawnOffsetY = 1000f;
int divisor = CalamityWorld.bossRushActive ? 90 : 120;
if (laserShoot % divisor == 0)
@@ -322,8 +324,8 @@ namespace CalamityMod.NPCs.DevourerofGods
// Side walls
for (int x = 0; x < totalShots; x++)
{
Projectile.NewProjectile(player.position.X + 1000f, targetPosY + (float)shotSpacing[0], -speed, 0f, ModContent.ProjectileType<DoGDeath>(), projectileDamage, 0f, Main.myPlayer, 0f, 0f);
Projectile.NewProjectile(player.position.X - 1000f, targetPosY + (float)shotSpacing[0], speed, 0f, ModContent.ProjectileType<DoGDeath>(), projectileDamage, 0f, Main.myPlayer, 0f, 0f);
Projectile.NewProjectile(player.position.X + spawnOffsetX, targetPosY + (float)shotSpacing[0], -speed, 0f, ModContent.ProjectileType<DoGDeath>(), projectileDamage, 0f, Main.myPlayer, 0f, 0f);
Projectile.NewProjectile(player.position.X - spawnOffsetX, targetPosY + (float)shotSpacing[0], speed, 0f, ModContent.ProjectileType<DoGDeath>(), projectileDamage, 0f, Main.myPlayer, 0f, 0f);
shotSpacing[0] -= spacingVar;
}
@@ -331,8 +333,8 @@ namespace CalamityMod.NPCs.DevourerofGods
{
for (int x = 0; x < 10; x++)
{
Projectile.NewProjectile(player.position.X + 1000f, targetPosY + (float)shotSpacing[3], -speed, 0f, ModContent.ProjectileType<DoGDeath>(), projectileDamage, 0f, Main.myPlayer, 0f, 0f);
Projectile.NewProjectile(player.position.X - 1000f, targetPosY + (float)shotSpacing[3], speed, 0f, ModContent.ProjectileType<DoGDeath>(), projectileDamage, 0f, Main.myPlayer, 0f, 0f);
Projectile.NewProjectile(player.position.X + spawnOffsetX, targetPosY + (float)shotSpacing[3], -speed, 0f, ModContent.ProjectileType<DoGDeath>(), projectileDamage, 0f, Main.myPlayer, 0f, 0f);
Projectile.NewProjectile(player.position.X - spawnOffsetX, targetPosY + (float)shotSpacing[3], speed, 0f, ModContent.ProjectileType<DoGDeath>(), projectileDamage, 0f, Main.myPlayer, 0f, 0f);
shotSpacing[3] -= Main.rand.NextBool(2) ? 180 : 200;
}
shotSpacing[3] = 1050;
@@ -342,7 +344,7 @@ namespace CalamityMod.NPCs.DevourerofGods
// Lower wall
for (int x = 0; x < totalShots; x++)
{
Projectile.NewProjectile(player.position.X + (float)shotSpacing[1], player.position.Y + 1000f, 0f, -speed, ModContent.ProjectileType<DoGDeath>(), projectileDamage, 0f, Main.myPlayer, 0f, 0f);
Projectile.NewProjectile(player.position.X + (float)shotSpacing[1], player.position.Y + spawnOffsetY, 0f, -speed, ModContent.ProjectileType<DoGDeath>(), projectileDamage, 0f, Main.myPlayer, 0f, 0f);
shotSpacing[1] -= spacingVar;
}
shotSpacing[1] = 1050;
@@ -350,7 +352,7 @@ namespace CalamityMod.NPCs.DevourerofGods
// Upper wall
for (int x = 0; x < totalShots; x++)
{
Projectile.NewProjectile(player.position.X + (float)shotSpacing[2], player.position.Y - 1000f, 0f, speed, ModContent.ProjectileType<DoGDeath>(), projectileDamage, 0f, Main.myPlayer, 0f, 0f);
Projectile.NewProjectile(player.position.X + (float)shotSpacing[2], player.position.Y - spawnOffsetY, 0f, speed, ModContent.ProjectileType<DoGDeath>(), projectileDamage, 0f, Main.myPlayer, 0f, 0f);
shotSpacing[2] -= spacingVar;
}
shotSpacing[2] = 1050;
+83 -5
View File
@@ -1,12 +1,23 @@
using CalamityMod.Buffs.DamageOverTime;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.IO;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Boss
{
public class DoGDeath : ModProjectile
{
public float TelegraphDelay
{
get => projectile.ai[0];
set => projectile.ai[0] = value;
}
public Vector2 OldVelocity;
public const float TelegraphTotalTime = 75f;
public const float TelegraphFadeTime = 15f;
public const float TelegraphWidth = 4200f;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Death Beam");
@@ -26,19 +37,57 @@ namespace CalamityMod.Projectiles.Boss
cooldownSlot = 1;
}
public override void SendExtraAI(BinaryWriter writer)
{
writer.WriteVector2(OldVelocity);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
OldVelocity = reader.ReadVector2();
}
public override void AI()
{
if (projectile.alpha > 0)
// Determine the relative opacities for each player based on their distance.
// This has a lower bound of 0.35 to prevent the laser from going completely invisible and players getting hit by cheap shots.
if (projectile.localAI[0] == 0f)
{
projectile.alpha -= 25;
projectile.localAI[0] = 1f;
projectile.netUpdate = true;
}
if (projectile.alpha < 0)
// Fade in after telegraphs have faded.
if (TelegraphDelay > TelegraphTotalTime)
{
projectile.alpha = 0;
if (projectile.alpha > 0)
{
projectile.alpha -= 25;
}
if (projectile.alpha < 0)
{
projectile.alpha = 0;
}
// If an old velocity is in reserve, set the true velocity to it and make it as "taken" by setting it to <0,0>
if (OldVelocity != Vector2.Zero)
{
projectile.velocity = OldVelocity;
OldVelocity = Vector2.Zero;
projectile.netUpdate = true;
}
projectile.rotation = projectile.velocity.ToRotation() + 1.57f;
}
projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f;
// Otherwise, be sure to save the velocity the projectile started with. It will be set again when the telegraph is over.
else if (OldVelocity == Vector2.Zero)
{
OldVelocity = projectile.velocity;
projectile.velocity = Vector2.Zero;
projectile.netUpdate = true;
projectile.rotation = OldVelocity.ToRotation() + 1.57f;
}
TelegraphDelay++;
}
public override bool CanDamage() => TelegraphDelay > TelegraphTotalTime;
public override void OnHitPlayer(Player target, int damage, bool crit)
{
target.AddBuff(ModContent.BuffType<GodSlayerInferno>(), 180);
@@ -53,5 +102,34 @@ namespace CalamityMod.Projectiles.Boss
{
target.Calamity().lastProjectileHit = projectile;
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
if (TelegraphDelay >= TelegraphTotalTime)
return true;
Texture2D laserTelegraph = ModContent.GetTexture("CalamityMod/ExtraTextures/LaserWallTelegraphBeam");
float yScale = 2f;
if (TelegraphDelay < TelegraphFadeTime)
{
yScale = MathHelper.Lerp(0f, 2f, TelegraphDelay / 15f);
}
if (TelegraphDelay > TelegraphTotalTime - TelegraphFadeTime)
{
yScale = MathHelper.Lerp(2f, 0f, (TelegraphDelay - (TelegraphTotalTime - TelegraphFadeTime)) / 15f);
}
Vector2 scaleInner = new Vector2(TelegraphWidth / laserTelegraph.Width, yScale);
Vector2 origin = laserTelegraph.Size() * new Vector2(0f, 0.5f);
Vector2 scaleOuter = scaleInner * new Vector2(1f, 1.6f);
Color colorOuter = Color.Lerp(Color.Cyan, Color.Purple, TelegraphDelay / TelegraphTotalTime * 2f % 1f); // Iterate through purple and cyan once and then flash.
Color colorInner = Color.Lerp(colorOuter, Color.White, 0.75f);
colorOuter *= 0.7f;
colorInner *= 0.7f;
spriteBatch.Draw(laserTelegraph, projectile.Center - Main.screenPosition, null, colorInner, OldVelocity.ToRotation(), origin, scaleInner, SpriteEffects.None, 0f);
spriteBatch.Draw(laserTelegraph, projectile.Center - Main.screenPosition, null, colorOuter, OldVelocity.ToRotation(), origin, scaleOuter, SpriteEffects.None, 0f);
return false;
}
}
}