uncompiles your error
start of angelic shotgun + new player util for clamped mouse world
This commit is contained in:
1 parent
4b84bcc760
commit
585dca2a65
6 files changed
+114
-90
No files matched your search
@@ -46,8 +46,8 @@ namespace CalamityMod.Items.Weapons.Magic
|
||||
// 5 projectiles total
|
||||
for (int i = -2; i < 3; i++)
|
||||
{
|
||||
Vector2 newPos = new Vector2(Main.MouseWorld.X + Main.rand.NextFloat(8f, 64f) * i, player.MountedCenter.Y + Main.rand.NextFloat(640f, 800f));
|
||||
Vector2 newVel = (Main.MouseWorld + Main.rand.NextVector2CircularEdge(4f, 4f) - newPos).SafeNormalize(Vector2.Zero) * velocity.Length() * Main.rand.NextFloat(1f, 1.25f);
|
||||
Vector2 newPos = new Vector2(player.ClampedMouseWorld().X + Main.rand.NextFloat(8f, 64f) * i, player.MountedCenter.Y + Main.rand.NextFloat(640f, 800f));
|
||||
Vector2 newVel = (player.ClampedMouseWorld() + Main.rand.NextVector2CircularEdge(4f, 4f) - newPos).SafeNormalize(Vector2.Zero) * velocity.Length() * Main.rand.NextFloat(1f, 1.25f);
|
||||
float velScale = 1f + Main.rand.NextFloat(0.02f, 0.08f) * i;
|
||||
Projectile.NewProjectile(source, newPos, newVel, type, damage, knockback, player.whoAmI, velScale);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace CalamityMod.Items.Weapons.Ranged
|
||||
public class AngelicShotgun : ModItem, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Items.Weapons.Ranged";
|
||||
private static float BulletSpeed = 12f;
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
@@ -36,8 +35,8 @@ namespace CalamityMod.Items.Weapons.Ranged
|
||||
Item.rare = ModContent.RarityType<Turquoise>();
|
||||
Item.Calamity().donorItem = true;
|
||||
|
||||
Item.shootSpeed = BulletSpeed;
|
||||
Item.shoot = ModContent.ProjectileType<HallowPointRoundProj>();
|
||||
Item.shootSpeed = 12f;
|
||||
Item.shoot = ModContent.ProjectileType<AngelicBeam>();
|
||||
Item.useAmmo = AmmoID.Bullet;
|
||||
Item.Calamity().canFirePointBlankShots = true;
|
||||
}
|
||||
@@ -49,68 +48,32 @@ namespace CalamityMod.Items.Weapons.Ranged
|
||||
|
||||
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
|
||||
{
|
||||
int NumBullets = Main.rand.Next(5, 6+1);
|
||||
Vector2 baseVelocity = velocity.SafeNormalize(Vector2.Zero) * BulletSpeed;
|
||||
|
||||
// If Musket Balls are used, damage is set to match Hallow-Point Rounds for both bullets and lasers
|
||||
if (type == ProjectileID.Bullet)
|
||||
{
|
||||
type = ModContent.ProjectileType<HallowPointRoundProj>();
|
||||
damage += HallowPointRound.BaseDamage - 7;
|
||||
}
|
||||
|
||||
// Fire a shotgun spread of bullets.
|
||||
int NumBullets = Main.rand.Next(5, 6 + 1);
|
||||
Vector2 baseVelocity = velocity.SafeNormalize(Vector2.Zero) * velocity.Length();
|
||||
for (int i = 0; i < NumBullets; ++i)
|
||||
{
|
||||
float dx = Main.rand.NextFloat(-1.3f, 1.3f);
|
||||
float dy = Main.rand.NextFloat(-1.3f, 1.3f);
|
||||
Vector2 randomVelocity = baseVelocity + new Vector2(dx, dy);
|
||||
|
||||
if (type == ProjectileID.Bullet)
|
||||
Projectile.NewProjectile(source, position, randomVelocity, Item.shoot, damage, knockback, player.whoAmI);
|
||||
else
|
||||
Projectile.NewProjectile(source, position, randomVelocity, type, damage, knockback, player.whoAmI);
|
||||
Vector2 randomVelocity = baseVelocity.RotatedByRandom(MathHelper.ToRadians(12.5f)) * Main.rand.NextFloat(0.88f, 1.12f);
|
||||
Projectile.NewProjectile(source, position, randomVelocity, type, damage, knockback, player.whoAmI);
|
||||
}
|
||||
|
||||
// Spawn a beam from the sky ala Deathhail Staff or Lunar Flare
|
||||
bool empowered = type == ModContent.ProjectileType<HallowPointRoundProj>();
|
||||
float laserSpeed = 8f;
|
||||
int laserDamage = (int)(damage * 2.5f);
|
||||
float laserKB = 5f;
|
||||
int laserDamage = (int)(damage * (empowered ? 4f : 2.5f));
|
||||
float laserKB = knockback * 1.6f;
|
||||
|
||||
Vector2 rrp = player.RotatedRelativePoint(player.MountedCenter, true);
|
||||
float mouseDX = (float)Main.mouseX - Main.screenPosition.X - rrp.X;
|
||||
float mouseDY = (float)Main.mouseY - Main.screenPosition.Y - rrp.Y;
|
||||
|
||||
// Correct for grav potion
|
||||
if (player.gravDir == -1f)
|
||||
mouseDY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - rrp.Y;
|
||||
|
||||
// Unnecessary NaN checks
|
||||
float mouseDist = (float)Math.Sqrt((double)(mouseDX * mouseDX + mouseDY * mouseDY));
|
||||
if ((float.IsNaN(mouseDX) && float.IsNaN(mouseDY)) || (mouseDX == 0f && mouseDY == 0f))
|
||||
{
|
||||
mouseDX = (float)player.direction;
|
||||
}
|
||||
else
|
||||
{
|
||||
mouseDist = laserSpeed / mouseDist;
|
||||
}
|
||||
|
||||
rrp = new Vector2(player.Center.X + (Main.rand.NextFloat(200f) * -player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f);
|
||||
rrp.X = (rrp.X + player.Center.X) / 2f + Main.rand.NextFloat(-200f, 200f);
|
||||
rrp.Y -= 100f;
|
||||
mouseDX = (float)Main.mouseX + Main.screenPosition.X - rrp.X;
|
||||
mouseDY = (float)Main.mouseY + Main.screenPosition.Y - rrp.Y;
|
||||
if (mouseDY < 0f)
|
||||
{
|
||||
mouseDY *= -1f;
|
||||
}
|
||||
if (mouseDY < 20f)
|
||||
{
|
||||
mouseDY = 20f;
|
||||
}
|
||||
mouseDist = (float)Math.Sqrt((double)(mouseDX * mouseDX + mouseDY * mouseDY));
|
||||
mouseDist = laserSpeed / mouseDist;
|
||||
mouseDX *= mouseDist;
|
||||
mouseDY *= mouseDist;
|
||||
Projectile.NewProjectile(source, rrp, new Vector2(mouseDX, mouseDY + Main.rand.NextFloat(-0.8f, 0.8f)), ModContent.ProjectileType<AngelicBeam>(), laserDamage, laserKB, player.whoAmI);
|
||||
Vector2 newPos = new Vector2(player.ClampedMouseWorld().X + Main.rand.NextFloat(-160f, 160f), player.MountedCenter.Y - 1200f);
|
||||
Vector2 newVel = (player.ClampedMouseWorld() + Main.rand.NextVector2CircularEdge(8f, 8f) - newPos).SafeNormalize(Vector2.Zero) * laserSpeed;
|
||||
Projectile laser = Projectile.NewProjectileDirect(source, newPos, newVel, Item.shoot, laserDamage, laserKB, player.whoAmI);
|
||||
laser.scale = empowered ? 2f : 1f;
|
||||
|
||||
// Play the sound of the laser beam
|
||||
SoundEngine.PlaySound(SoundID.Item72, player.Center);
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace CalamityMod.Projectiles.Magic
|
||||
Vector2 velocity = (i + offsetAngle + MathHelper.ToRadians(45f)).ToRotationVector2() * (0.5f + (MathF.Sin(6f * i) + 1f) * 8f);
|
||||
Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType<LightDust>(), velocity);
|
||||
dust.noGravity = true;
|
||||
dust.color = Main.hslToRgb(Main.rand.NextFloat(0.08f, 0.12f), 1f, 0.66f);
|
||||
dust.color = Main.hslToRgb(Main.rand.NextFloat(0.05f, 0.15f), 1f, 0.66f);
|
||||
}
|
||||
for (int i = 0; i < ThePrince.FlameSplitCount; i++)
|
||||
{
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace CalamityMod.Projectiles.Magic
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
lightColor = Color.Lerp(lightColor, Color.White, 0.8f);
|
||||
lightColor.A *= 0.5f;
|
||||
lightColor.A /= 2;
|
||||
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1);
|
||||
return false;
|
||||
}
|
||||
@@ -69,16 +69,16 @@ namespace CalamityMod.Projectiles.Magic
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
||||
{
|
||||
target.AddBuff(ModContent.BuffType<HolyFlames>(), 60);
|
||||
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType<HolyFlames>(), 60);
|
||||
|
||||
public override void OnKill(int timeLeft)
|
||||
{
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType<LightDust>(), (Vector2.UnitX).RotatedByRandom(MathHelper.Pi) * Main.rand.NextFloat(2f, 12f));
|
||||
dust.noGravity = true;
|
||||
dust.scale = Main.rand.NextFloat(0.8f, 1.5f);
|
||||
dust.color = Main.hslToRgb(Main.rand.NextFloat(0.05f, 0.15f), 1f, 0.66f);
|
||||
dust.color = Main.hslToRgb(Main.rand.NextFloat(0.033f, 0.167f), 1f, 0.66f);
|
||||
dust.noLightEmittence = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
using CalamityMod.Buffs.DamageOverTime;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using CalamityMod.Buffs.DamageOverTime;
|
||||
using CalamityMod.Dusts;
|
||||
using CalamityMod.Graphics.Primitives;
|
||||
using CalamityMod.Particles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.Graphics.Shaders;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Ranged
|
||||
{
|
||||
public class AngelicBeam : ModProjectile, ILocalizedModType
|
||||
@@ -8,57 +18,92 @@ namespace CalamityMod.Projectiles.Ranged
|
||||
public new string LocalizationCategory => "Projectiles.Ranged";
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
|
||||
// Due to how far/fast this thing moves, it'd require way too many points for a smooth long trail using oldPos
|
||||
public List<Vector2> TrailPos = new List<Vector2>();
|
||||
public static int Lifetime = 300;
|
||||
public static int Fadetime = 60;
|
||||
|
||||
public override void SetStaticDefaults() => ProjectileID.Sets.DrawScreenCheckFluff[Type] = 2000;
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 4;
|
||||
Projectile.height = 4;
|
||||
Projectile.width = Projectile.height = 32;
|
||||
Projectile.friendly = true;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.DamageType = DamageClass.Ranged;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.alpha = 255;
|
||||
|
||||
// Hitscan laser with a long range
|
||||
Projectile.timeLeft = 200;
|
||||
Projectile.extraUpdates = 200;
|
||||
// Effectively hitscan
|
||||
Projectile.timeLeft = Lifetime;
|
||||
Projectile.MaxUpdates = Lifetime;
|
||||
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.usesIDStaticNPCImmunity = true;
|
||||
Projectile.idStaticNPCHitCooldown = 20;
|
||||
Projectile.usesLocalNPCImmunity = true;
|
||||
Projectile.localNPCHitCooldown = -1;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
// Actual laser dust
|
||||
for (int i = 0; i < 7; ++i)
|
||||
// Begin fading once the laser is fully spawned in
|
||||
if (Projectile.ai[0] > 0f)
|
||||
{
|
||||
int dustType = 262; // Main.rand.NextBool() ? 244 : 246;
|
||||
int idx = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType);
|
||||
|
||||
Main.dust[idx].noGravity = true;
|
||||
Main.dust[idx].position -= i * 0.1666f * Projectile.velocity;
|
||||
Main.dust[idx].velocity *= 1f;
|
||||
float scale = Main.rand.NextFloat(0.8f, 1.4f);
|
||||
Main.dust[idx].scale = scale;
|
||||
Projectile.Opacity = Utils.GetLerpValue(0f, Fadetime, Projectile.timeLeft, true);
|
||||
return;
|
||||
}
|
||||
else if (Projectile.timeLeft == 1)
|
||||
{
|
||||
Projectile.ai[0] = 1f;
|
||||
Projectile.MaxUpdates = 1;
|
||||
Projectile.timeLeft = Fadetime;
|
||||
}
|
||||
|
||||
// Sparkles "burning off" of the laser beam
|
||||
if (Main.rand.NextBool())
|
||||
if (Projectile.FinalExtraUpdate() || Projectile.numUpdates % 30 == 29 || TrailPos == null)
|
||||
{
|
||||
int dustType = Main.rand.NextBool() ? 244 : 246;
|
||||
int idx = Dust.NewDust(Projectile.position, 1, 1, dustType);
|
||||
// Initialize 10 points immediately
|
||||
if (TrailPos == null)
|
||||
{
|
||||
TrailPos = new List<Vector2>(10);
|
||||
for (int i = 0; i < 10; ++i)
|
||||
TrailPos.Add(Projectile.Center);
|
||||
}
|
||||
|
||||
Main.dust[idx].noGravity = true;
|
||||
float ySpeed = Main.rand.NextFloat(3.0f, 5.6f);
|
||||
Main.dust[idx].velocity.Y -= ySpeed;
|
||||
float scale = Main.rand.NextFloat(0.4f, 0.8f);
|
||||
Main.dust[idx].scale = scale;
|
||||
TrailPos.Insert(0, Projectile.Center);
|
||||
|
||||
while (TrailPos.Count > 10)
|
||||
TrailPos.RemoveAt(TrailPos.Count - 1);
|
||||
}
|
||||
|
||||
// Trail sparks in the laser's path
|
||||
Particle spark = new SparkParticle(Projectile.Center + Main.rand.NextVector2Circular(12f * Projectile.scale, 12f * Projectile.scale), Projectile.velocity * 4f, false, 5, Main.rand.NextFloat(0.5f, 1.5f), LaserColor(Projectile.timeLeft / (float)Lifetime));
|
||||
GeneralParticleHandler.SpawnParticle(spark);
|
||||
}
|
||||
|
||||
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
||||
{
|
||||
target.AddBuff(ModContent.BuffType<HolyFlames>(), 180);
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType<LightDust>(), (Vector2.UnitX).RotatedByRandom(MathHelper.Pi) * Main.rand.NextFloat(2f, 12f));
|
||||
dust.noGravity = true;
|
||||
dust.scale = Main.rand.NextFloat(1.2f, 2.5f);
|
||||
dust.color = Main.hslToRgb(Main.rand.NextFloat(0.033f, 0.167f), 1f, 0.66f);
|
||||
dust.noLightEmittence = true;
|
||||
}
|
||||
}
|
||||
|
||||
public Color LaserColor(float completionRatio) => Main.hslToRgb(0.08f + 0.05f * completionRatio + 0.05f * MathF.Sin(Main.GlobalTimeWrappedHourly * 5f), 1f, 0.7f) * Projectile.Opacity;
|
||||
public float LaserWidth(float completionRatio) => 32f * Projectile.Opacity * Projectile.scale;
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
if (TrailPos == null)
|
||||
return false;
|
||||
|
||||
GameShaders.Misc["CalamityMod:Flame"].UseImage1("Images/Misc/Perlin");
|
||||
GameShaders.Misc["CalamityMod:Flame"].UseSaturation(0.5f);
|
||||
PrimitiveRenderer.RenderTrail(TrailPos, new(LaserWidth, LaserColor, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:Flame"]), 20);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using CalamityMod.Balancing;
|
||||
@@ -887,6 +888,21 @@ namespace CalamityMod
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Used to limit the cursor up to a 1080p monitor. A similar method is used for items such as Zenith in vanilla.
|
||||
/// </summary>
|
||||
/// <param name="player">The player to check.</param>
|
||||
/// <returns>The current position of the player's mouse, clamped to a 1920x1080 screen.</returns>
|
||||
public static Vector2 ClampedMouseWorld(this Player player)
|
||||
{
|
||||
Vector2 mouseWorld = player.Calamity().mouseWorld;
|
||||
|
||||
// Clamp each axis
|
||||
mouseWorld.X = mouseWorld.X >= player.MountedCenter.X ? MathF.Min(mouseWorld.X, player.MountedCenter.X + 960f) : MathF.Max(mouseWorld.X, player.MountedCenter.X - 960f);
|
||||
mouseWorld.Y = mouseWorld.Y >= player.MountedCenter.Y ? MathF.Min(mouseWorld.Y, player.MountedCenter.Y + 540f) : MathF.Max(mouseWorld.Y, player.MountedCenter.Y - 540f);
|
||||
return mouseWorld;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A shorthand bool to check if the player can continue using the holdout or not.
|
||||
/// </summary>
|
||||
|
||||
Reference in new issue
Block a user