T1000 rework. It is now the Auric Wave Beam.

This commit is contained in:
Ozzatron committed 2021-11-07 03:02:00 -05:00
1 parent 979ca98e8d
commit 60f62a185c
3 files changed
+224 -122

No files matched your search

+18 -10
View File
@@ -10,32 +10,35 @@ namespace CalamityMod.Items.Weapons.Magic
{
public class T1000 : ModItem
{
public const int UseTime = 36;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("T1000");
Tooltip.SetDefault("Fires a spread of rainbow lasers");
Tooltip.SetDefault("Fires a barrage of phased god rays that pass through terrain\n" +
"God rays pierce once without triggering pierce resistances");
}
public override void SetDefaults()
{
item.damage = 250;
item.damage = 227;
item.magic = true;
item.mana = 10;
item.width = 20;
item.height = 12;
item.useTime = 12;
item.useAnimation = 12;
item.mana = 8;
item.width = 94;
item.height = 54;
item.useTime = item.useAnimation = UseTime;
item.useStyle = ItemUseStyleID.HoldingOut;
item.noMelee = true;
item.noUseGraphic = true;
item.channel = true;
item.knockBack = 4f;
item.value = CalamityGlobalItem.Rarity15BuyPrice;
item.rare = ItemRarityID.Purple;
item.autoReuse = true;
item.shoot = ModContent.ProjectileType<T1000Holdout>();
item.shootSpeed = 24f;
item.rare = ItemRarityID.Purple;
item.Calamity().customRarity = CalamityRarity.Violet;
item.value = CalamityGlobalItem.Rarity15BuyPrice;
}
public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0;
@@ -44,7 +47,10 @@ namespace CalamityMod.Items.Weapons.Magic
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ModContent.ItemType<Purge>());
recipe.AddIngredient(ModContent.ItemType<PurgeGuzzler>());
recipe.AddIngredient(ModContent.ItemType<AuricBar>(), 5);
recipe.AddIngredient(ModContent.ItemType<UeliaceBar>(), 12);
recipe.AddIngredient(ModContent.ItemType<DivineGeode>(), 8);
recipe.AddTile(ModContent.TileType<CosmicAnvil>());
recipe.SetResult(this);
recipe.AddRecipe();
@@ -52,7 +58,9 @@ namespace CalamityMod.Items.Weapons.Magic
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType<T1000Holdout>(), damage, knockBack, player.whoAmI, 0.0f, 0.0f);
Vector2 shootVelocity = new Vector2(speedX, speedY);
Vector2 shootDirection = shootVelocity.SafeNormalize(Vector2.UnitX * player.direction);
Projectile.NewProjectile(position, shootDirection, type, damage, knockBack, player.whoAmI);
return false;
}
}
+129 -88
View File
@@ -1,3 +1,4 @@
using CalamityMod.Items.Weapons.Magic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
@@ -8,6 +9,16 @@ namespace CalamityMod.Projectiles.Magic
{
public class T1000Holdout : ModProjectile
{
private const int FramesPerFireRateIncrease = 36;
private Player Owner => Main.player[projectile.owner];
private bool OwnerCanShoot => Owner.channel && Owner.HasAmmo(Owner.ActiveItem(), true) && !Owner.noItems && !Owner.CCed;
private ref float DeployedFrames => ref projectile.ai[0];
private ref float AnimationRate => ref projectile.ai[1];
private ref float LastShootAttemptTime => ref projectile.localAI[0];
private ref float LastAnimationTime => ref projectile.localAI[1];
public override void SetStaticDefaults()
{
DisplayName.SetDefault("T1000");
@@ -27,105 +38,135 @@ namespace CalamityMod.Projectiles.Magic
public override void AI()
{
Player player = Main.player[projectile.owner];
Vector2 playerPos = player.RotatedRelativePoint(player.MountedCenter, true);
if (projectile.type == ModContent.ProjectileType<T1000Holdout>())
{
projectile.ai[0] += 1f;
int num2 = 0;
if (projectile.ai[0] >= 20f)
{
num2++;
}
if (projectile.ai[0] >= 40f)
{
num2++;
}
if (projectile.ai[0] >= 60f)
{
num2++;
}
int num3 = 24;
int num4 = 6;
projectile.ai[1] += 1f;
bool flag = false;
if (projectile.ai[1] >= (float)(num3 - num4 * num2))
{
projectile.ai[1] = 0f;
flag = true;
}
if (projectile.soundDelay <= 0)
{
projectile.soundDelay = num3 - num4 * num2;
if (projectile.ai[0] != 1f)
{
Main.PlaySound(SoundID.Item91, projectile.position);
}
projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type];
}
if (projectile.ai[1] == 1f && projectile.ai[0] != 1f)
{
Vector2 vector2 = Vector2.UnitX * 24f;
vector2 = vector2.RotatedBy((double)(projectile.rotation - MathHelper.PiOver2), default);
Vector2 value = projectile.Center + vector2;
for (int i = 0; i < 2; i++)
{
int num5 = Dust.NewDust(value - Vector2.One * 8f, 16, 16, 66, projectile.velocity.X / 2f, projectile.velocity.Y / 2f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f);
Main.dust[num5].velocity *= 0.66f;
Main.dust[num5].noGravity = true;
Main.dust[num5].scale = 1.4f;
}
}
if (flag && Main.myPlayer == projectile.owner)
{
int weaponDamage2 = player.GetWeaponDamage(player.ActiveItem());
bool flag2 = player.channel && player.CheckMana(player.ActiveItem(), -1, true, false) && !player.noItems && !player.CCed;
if (flag2)
{
float speed = player.ActiveItem().shootSpeed * projectile.scale;
Vector2 spawnPos = playerPos + projectile.velocity * 0.75f;
Vector2 velocity = (Main.MouseWorld - projectile.Center).SafeNormalize(-Vector2.UnitY) * speed;
if (projectile.WithinRange(Main.MouseWorld, 50f))
velocity = projectile.velocity;
if (velocity.X != projectile.velocity.X || velocity.Y != projectile.velocity.Y)
projectile.netUpdate = true;
Vector2 armPosition = Owner.RotatedRelativePoint(Owner.MountedCenter, true);
Vector2 gunBarrelPos = armPosition + projectile.velocity * projectile.height * 0.4f;
projectile.velocity = velocity;
int projType = ModContent.ProjectileType<T1000Laser>();
float velocityMult = 21f;
float randNum = 4f;
for (int j = 0; j < 4; j++)
{
spawnPos += new Vector2(Main.rand.NextFloat(-randNum, randNum), Main.rand.NextFloat(-randNum, randNum));
Vector2 spinningpoint = Vector2.Normalize(projectile.velocity) * velocityMult;
spinningpoint = spinningpoint.RotatedBy(Main.rand.NextDouble() * 0.2 - 0.1, default);
if (float.IsNaN(spinningpoint.X) || float.IsNaN(spinningpoint.Y))
{
spinningpoint = -Vector2.UnitY;
}
Projectile.NewProjectile(spawnPos, spinningpoint, projType, weaponDamage2, projectile.knockBack, projectile.owner, 0f, 0f);
}
}
else
// If the player is unable to continue using the holdout, delete it.
if (!OwnerCanShoot)
{
projectile.Kill();
return;
}
// Play a sound frame 1.
if (DeployedFrames <= 0f)
{
var sound = Main.PlaySound(SoundID.DD2_DarkMageCastHeal, projectile.Center);
if (sound != null)
sound.Volume *= 1.5f;
}
// Update damage based on curent magic damage stat (so Mana Sickness affects it)
Item t1000Item = Owner.ActiveItem();
projectile.damage = (int)((t1000Item?.damage ?? 0) * Owner.MagicDamage());
// Get the original weapon's use time.
int itemUseTime = t1000Item?.useAnimation ?? T1000.UseTime;
// 36, base use time, will result in 5. Speed increasing reforges push it to 4.
int framesPerShot = itemUseTime / 7;
// Update time.
DeployedFrames += 1f;
// Determine animation rate. If the gun is spinning up, it increases linearly. Otherwise it's maxed.
AnimationRate = DeployedFrames >= itemUseTime ? 2f : MathHelper.Lerp(7f, 2f, DeployedFrames / itemUseTime);
// Update the animation. This occurs even when firing is not occurring.
if (DeployedFrames - LastAnimationTime >= AnimationRate)
{
LastAnimationTime = DeployedFrames;
projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type];
}
// Once past the initial spin-up time, fire constantly as long as mana is available.
// Before the spin-up is done, sparks are produced but no lasers come out (and no mana is consumed).
if (DeployedFrames - LastShootAttemptTime >= framesPerShot)
{
LastShootAttemptTime = DeployedFrames;
bool actuallyShoot = DeployedFrames >= itemUseTime;
bool manaOK = !actuallyShoot || Owner.CheckMana(Owner.ActiveItem(), -1, true, false);
if (manaOK)
{
if (actuallyShoot)
Main.PlaySound(SoundID.Item91, projectile.Center);
int projID = ModContent.ProjectileType<T1000Laser>();
float shootSpeed = t1000Item.shootSpeed;
Vector2 shootVelocity = projectile.velocity.SafeNormalize(Vector2.UnitY) * shootSpeed;
float dustInaccuracy = 0.045f;
for (int i = 0; i < 3; ++i)
{
projectile.Kill();
Vector2 laserStartPos = gunBarrelPos + Main.rand.NextVector2CircularEdge(6f, 6f);
Vector2 dustOnlySpread = Main.rand.NextVector2Circular(shootSpeed, shootSpeed);
Vector2 dustVelocity = shootVelocity + dustInaccuracy * dustOnlySpread;
if (actuallyShoot)
Projectile.NewProjectile(laserStartPos, shootVelocity, projID, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
SpawnFiringDust(gunBarrelPos, dustVelocity);
}
}
// Delete the laser gun if a mana cost cannot be paid.
else
{
projectile.Kill();
return;
}
}
UpdateProjectileHeldVariables(armPosition);
ManipulatePlayerVariables();
}
private void UpdateProjectileHeldVariables(Vector2 armPosition)
{
if (Main.myPlayer == projectile.owner)
{
float interpolant = Utils.InverseLerp(5f, 25f, projectile.Distance(Main.MouseWorld), true);
Vector2 oldVelocity = projectile.velocity;
projectile.velocity = Vector2.Lerp(projectile.velocity, projectile.SafeDirectionTo(Main.MouseWorld), interpolant);
if (projectile.velocity != oldVelocity)
{
projectile.netSpam = 0;
projectile.netUpdate = true;
}
}
projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2;
projectile.Center = player.RotatedRelativePoint(player.MountedCenter, true) + projectile.velocity.SafeNormalize(Vector2.UnitX * player.direction) * 8f;
projectile.position.Y -= 8f;
projectile.Center = armPosition + projectile.velocity.SafeNormalize(Vector2.UnitX * Owner.direction) * 8f;
projectile.spriteDirection = projectile.direction;
projectile.timeLeft = 2;
player.ChangeDir(projectile.direction);
player.heldProj = projectile.whoAmI;
player.itemTime = 2;
player.itemAnimation = 2;
player.itemRotation = (projectile.velocity * projectile.direction).ToRotation();
}
private void ManipulatePlayerVariables()
{
Owner.ChangeDir(projectile.direction);
Owner.heldProj = projectile.whoAmI;
Owner.itemTime = 2;
Owner.itemAnimation = 2;
Owner.itemRotation = (projectile.velocity * projectile.direction).ToRotation();
}
private void SpawnFiringDust(Vector2 gunBarrelPos, Vector2 laserVelocity)
{
int dustID = 133;
int dustRadius = 12;
float dustRandomness = 11f;
int dustDiameter = 2 * dustRadius;
Vector2 dustCorner = gunBarrelPos - Vector2.One * dustRadius;
for (int i = 0; i < 2; i++)
{
Vector2 dustVel = laserVelocity + Main.rand.NextVector2Circular(dustRandomness, dustRandomness);
Dust d = Dust.NewDustDirect(dustCorner, dustDiameter, dustDiameter, dustID, dustVel.X, dustVel.Y);
d.velocity *= 0.18f;
d.noGravity = true;
d.scale = 0.6f;
}
}
public override bool CanDamage() => false;
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => projectile.ai[0] > 0f;
// prevents the item from appearing backwards frame 1
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => FramesPerFireRateIncrease > 0f;
}
}
+77 -24
View File
@@ -1,16 +1,23 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Magic
{
public class T1000Laser : ModProjectile
{
private const float LaserLength = 80f;
private const float LaserLengthChangeRate = 2f;
public override string Texture => "CalamityMod/Projectiles/LaserProj";
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Laser");
DisplayName.SetDefault("Phased God Ray");
ProjectileID.Sets.TrailCacheLength[projectile.type] = 10;
ProjectileID.Sets.TrailingMode[projectile.type] = 2;
}
public override void SetDefaults()
@@ -20,54 +27,100 @@ namespace CalamityMod.Projectiles.Magic
projectile.friendly = true;
projectile.alpha = 255;
projectile.penetrate = 1;
projectile.extraUpdates = 2;
projectile.timeLeft = 600;
projectile.extraUpdates = 3;
projectile.timeLeft = 300;
projectile.magic = true;
projectile.tileCollide = false;
projectile.ignoreWater = true;
}
public override void AI()
{
// Very rapidly fade into existence.
if (projectile.alpha > 0)
{
projectile.alpha -= 25;
}
if (projectile.alpha < 0)
{
projectile.alpha = 0;
float theta = 0.09f;
float maxWaveFrames = 9f;
float waveSign = projectile.localAI[1] < 0f ? -1f : 1f;
// Choose a waving direction initially at random.
if (projectile.localAI[1] == 0f)
{
float coinflip = Main.rand.NextBool() ? -1f : 1f;
waveSign = -coinflip;
projectile.localAI[1] = coinflip * maxWaveFrames * 0.5f;
// Backfill old rotations to prevent visual glitches.
float startingRotation = projectile.velocity.ToRotation();
for (int i = 0; i < projectile.oldRot.Length; ++i)
projectile.oldRot[i] = startingRotation;
// Adjust initial position to prevent ugly splitting.
Vector2 perp = projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedBy(MathHelper.PiOver2);
float distance = Main.rand.NextFloat(13f, 30f);
projectile.position -= coinflip * distance * perp;
}
Lighting.AddLight((int)projectile.Center.X / 16, (int)projectile.Center.Y / 16, 0f, 0.7f, 0.1f);
float num55 = 100f;
float num56 = 3f;
// Switch waving directions as necessary.
else if (Math.Abs(projectile.localAI[1]) > maxWaveFrames)
projectile.localAI[1] = -waveSign;
else
projectile.localAI[1] += waveSign;
// Apply a constant, rapid wave to the laser's motion.
projectile.velocity = projectile.velocity.RotatedBy(waveSign * theta);
projectile.rotation = projectile.velocity.ToRotation();
// Emit light.
Lighting.AddLight(projectile.Center, 0.87f, 0.65f, 0.1725f);
// Laser length shenanigans. If the laser is still growing, increase localAI 0 to indicate it is getting longer.
if (projectile.ai[1] == 0f)
{
projectile.localAI[0] += num56;
if (projectile.localAI[0] > num55)
{
projectile.localAI[0] = num55;
}
projectile.localAI[0] += 10f; // LaserLengthChangeRate;
// Cap it at max length.
if (projectile.localAI[0] > LaserLength)
projectile.localAI[0] = LaserLength;
}
// Otherwise it's shrinking. Once it reaches zero length it dies for good.
else
{
projectile.localAI[0] -= num56;
projectile.localAI[0] -= LaserLengthChangeRate;
if (projectile.localAI[0] <= 0f)
{
projectile.Kill();
}
}
}
public override Color? GetAlpha(Color lightColor) => new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, 0);
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
// Get an extra hit in despite not being officially piercing.
if (projectile.ai[0] == 0f)
{
++projectile.penetrate;
projectile.ai[0] += 1f;
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => projectile.DrawBeam(100f, 3f, lightColor);
public override Color? GetAlpha(Color lightColor) => new Color(222, 166, 44, 0);
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => projectile.DrawBeam(LaserLength, 2f, lightColor, curve: true);
public override void Kill(int timeLeft)
{
int dustAmt = Main.rand.Next(3, 7);
for (int d = 0; d < dustAmt; d++)
int dustID = 269;
int dustAmt = 4;
Vector2 dustPos = projectile.Center - projectile.velocity / 2f;
Vector2 dustVel = projectile.velocity / 4f;
for (int i = 0; i < dustAmt; ++i)
{
int rainbow = Dust.NewDust(projectile.Center - projectile.velocity / 2f, 0, 0, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 2.1f);
Main.dust[rainbow].velocity *= 2f;
Main.dust[rainbow].noGravity = true;
Dust d = Dust.NewDustDirect(dustPos, 0, 0, dustID, 0f, 0f, Scale: 2.5f);
d.velocity += dustVel;
d.velocity *= Main.rand.NextFloat(0.4f, 1f);
d.noGravity = true;
}
}
}