Dazzling Stabber

This commit is contained in:
Xyk committed 2024-10-15 16:05:31 -07:00
1 parent ec0f946ef9
commit 314beb33ea
7 files changed
+251 -79

No files matched your search

+15 -8
View File
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using CalamityMod.CalPlayer;
using CalamityMod.Items.Accessories.Vanity;
using CalamityMod.Particles;
using CalamityMod.Rarities;
using Microsoft.Xna.Framework;
@@ -28,7 +29,10 @@ namespace CalamityMod.Items.Accessories.Wings
Item.rare = ModContent.RarityType<Turquoise>();
Item.accessory = true;
}
public override void UpdateVanity(Player player)
{
DrawWingEffects(player);
}
public override void UpdateAccessory(Player player, bool hideVisual)
{
CalamityPlayer modPlayer = player.Calamity();
@@ -37,6 +41,11 @@ namespace CalamityMod.Items.Accessories.Wings
player.noFallDmg = true;
modPlayer.elysianWingsDust = false;
if (!hideVisual)
DrawWingEffects(player);
}
private void DrawWingEffects(Player player)
{
float rate = Main.GlobalTimeWrappedHourly * 2;
List<Color> eColors = new List<Color>()
{
@@ -50,14 +59,12 @@ namespace CalamityMod.Items.Accessories.Wings
Color usedColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f);
if (!hideVisual)
Vector2 spawnPos = player.Center + new Vector2(-25 * player.direction, 0);
Lighting.AddLight(spawnPos, usedColor.ToVector3() * 1.2f);
if (player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f)
{
Vector2 spawnPos = player.Center + new Vector2(-25 * player.direction, 0);
Lighting.AddLight(spawnPos, usedColor.ToVector3() * 1.2f);
}
if (player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual)
{
Vector2 spawnPos = player.Center + new Vector2(-25 * player.direction, 0) + Main.rand.NextVector2Circular(20, 20);
spawnPos = player.Center + new Vector2(-25 * player.direction, 0) + Main.rand.NextVector2Circular(20, 20);
Vector2 spawnPos2 = player.Center + new Vector2(15 * player.direction, 0) + Main.rand.NextVector2Circular(20, 20);
float partScale = Main.rand.NextFloat(0.3f, 0.8f);
+11 -7
View File
@@ -2,6 +2,7 @@
using CalamityMod.Rarities;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
@@ -35,19 +36,22 @@ namespace CalamityMod.Items.Weapons.Summon
{
if (player.altFunctionUse != 2)
{
int p = Projectile.NewProjectile(source, Main.MouseWorld, Vector2.Zero, type, damage, knockback, player.whoAmI);
if (Main.projectile.IndexInRange(p))
Main.projectile[p].originalDamage = Item.damage;
for (int i = 0; i < 3; i++)
{
int p = Projectile.NewProjectile(source, Main.MouseWorld, Vector2.Zero, type, damage, knockback, player.whoAmI, 0, 0, i + 1);
if (Main.projectile.IndexInRange(p))
Main.projectile[p].originalDamage = Item.damage;
}
}
float angleMax = MathHelper.ToRadians(45f);
float angleMax = MathHelper.ToRadians(360f);
if (CalamityUtils.CountProjectiles(type) == 1)
angleMax = 0f;
float index = 1f;
if (player.ownedProjectileCounts[Item.shoot] > 8)
if (player.ownedProjectileCounts[Item.shoot] > 30)
{
angleMax += MathHelper.ToRadians((player.ownedProjectileCounts[Item.shoot] - 8) * 2.5f);
angleMax += MathHelper.ToRadians((player.ownedProjectileCounts[Item.shoot] - 30) * 2.5f);
}
angleMax = angleMax > MathHelper.ToRadians(105f) ? MathHelper.ToRadians(105f) : angleMax; // More intuative than using a min function
angleMax = angleMax > MathHelper.ToRadians(360f) ? MathHelper.ToRadians(360f) : angleMax; // More intuative than using a min function
foreach (Projectile p in Main.ActiveProjectiles)
{
if (p.type == type && p.owner == player.whoAmI)
@@ -250,7 +250,7 @@ DankStaff: {
DazzlingStabberStaff: {
DisplayName: Dazzling Stabber Staff
Tooltip: Summons a holy blade to fight for you
Tooltip: Summons three holy blades made of profaned materials to fight for you
}
DeathstareRod: {
+224 -63
View File
@@ -1,8 +1,12 @@
using CalamityMod.Buffs.DamageOverTime;
using System;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.Summon;
using CalamityMod.Dusts;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
@@ -14,12 +18,17 @@ namespace CalamityMod.Projectiles.Summon
public Player Owner => Main.player[Projectile.owner];
public ref float AttackDelay => ref Projectile.ai[0];
public ref float RestOffsetAngle => ref Projectile.ai[1];
public ref float KnifeType => ref Projectile.ai[2]; // 1 - Crystal, 2 - Stone, 3 - Fire
public Color color1 = Color.White;
public int attackCooldown = 0;
public int attacksDone = 0;
public NPC potentialTarget;
public float moveSmoothing = 50;
public float damageMult = 1;
public Vector2 storedPos;
public override void SetStaticDefaults()
{
Main.projFrames[Projectile.type] = 4;
ProjectileID.Sets.TrailingMode[Projectile.type] = 2;
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 25;
ProjectileID.Sets.MinionSacrificable[Projectile.type] = true;
ProjectileID.Sets.MinionSacrificable[Projectile.type] = false; // To prevent blade type desync
ProjectileID.Sets.MinionTargettingFeature[Projectile.type] = true;
}
@@ -30,12 +39,11 @@ namespace CalamityMod.Projectiles.Summon
Projectile.netImportant = true;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.minionSlots = 1f;
Projectile.minionSlots = 0.333f;
Projectile.timeLeft = 90000;
Projectile.penetrate = -1;
Projectile.tileCollide = false;
Projectile.minion = true;
Projectile.light = 1f;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 10;
Projectile.DamageType = DamageClass.Summon;
@@ -43,19 +51,125 @@ namespace CalamityMod.Projectiles.Summon
public override void AI()
{
switch (KnifeType)
{
case 1: // Crystal
color1 = Color.Orchid;
Projectile.extraUpdates = 1;
damageMult = 0.5f;
Projectile.ArmorPenetration = 40;
break;
case 2: // Rock
color1 = Color.OrangeRed;
Projectile.extraUpdates = 2;
damageMult = 3;
break;
default: // Flame
color1 = Color.Orange;
damageMult = 1;
Projectile.ArmorPenetration = 20;
break;
}
Lighting.AddLight(Projectile.Center, Color.White.ToVector3());
ApplyPlayerBuffs();
UpdateFrames();
NPC potentialTarget = Projectile.Center.MinionHoming(1100f, Owner);
potentialTarget = Projectile.Center.MinionHoming(1100f, Owner);
if (potentialTarget != null && attackCooldown == 0 && AttackDelay <= 0)
{
storedPos = potentialTarget.Center;
}
if (potentialTarget != null)
SliceTarget(potentialTarget);
else
ReturnToRestingPosition();
}
{
if (KnifeType == 1 && attacksDone > 0 && Utils.Distance(Projectile.Center, storedPos) < 150 && attackCooldown == 0)
{
Particle spark = new GlowSparkParticle(Projectile.Center, -Projectile.velocity * 0.1f, false, 20, 0.03f, color1 * 0.55f, new Vector2(0.8f, 2.3f), true, false, 0.45f);
GeneralParticleHandler.SpawnParticle(spark);
}
if (KnifeType == 2 && attackCooldown == 0)
{
if (Main.rand.NextBool(4))
{
Particle spark = new CustomSpark(Projectile.Center + Main.rand.NextVector2Circular(10, 10), -Projectile.velocity * Main.rand.NextFloat(0.1f, 0.8f), "CalamityMod/Projectiles/Typeless/ArtifactOfResilienceShard6", false, Main.rand.Next(25, 35 + 1), Main.rand.NextFloat(0.55f, 1.2f), Color.White, Vector2.One, false, false, Main.rand.NextFloat(-5, 5), false, false);
GeneralParticleHandler.SpawnParticle(spark);
}
else
{
bool memesHatesLists = Main.rand.NextBool(5);
Dust dust = Dust.NewDustPerfect(Projectile.Center, memesHatesLists ? 278 : ModContent.DustType<LightDust>(), -Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(0.4f) * Main.rand.NextFloat(1f, 4f));
dust.noGravity = !memesHatesLists;
dust.scale = Main.rand.NextFloat(0.55f, 1.1f);
dust.color = color1;
}
}
if (KnifeType == 3)
{
for (int i = 0; i < 2; i++)
{
Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType<LightDust>(), Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(0.4f) * Main.rand.NextFloat(2f, 8f));
dust.noGravity = true;
dust.scale = Main.rand.NextFloat(0.65f, 1f);
dust.color = Color.Goldenrod;
dust.noLightEmittence = true;
}
Particle spark2 = new CustomSpark(Projectile.Center, Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(0.5f) * Main.rand.NextFloat(1f, 5f), "CalamityMod/Particles/ProvidenceMarkParticle", false, 14, Main.rand.NextFloat(0.9f, 1.2f), Color.Gold, new Vector2(1.3f, 0.5f), true, false, 0, false, false, 0);
GeneralParticleHandler.SpawnParticle(spark2);
for (int i = 0; i < 2; i++)
{
Particle trail = new GlowSparkParticle(Projectile.Center + i * Projectile.velocity * 0.4f, -Projectile.velocity * 0.05f, false, 9, 0.05f, Color.Orange * 0.5f, new Vector2(1, 0.3f), true, false, 0.85f);
GeneralParticleHandler.SpawnParticle(trail);
}
}
if (attackCooldown == 0)
SliceTarget(potentialTarget);
else
{
manageAttackCooldown();
}
}
else
{
manageAttackCooldown();
ReturnToRestingPosition();
}
}
public void manageAttackCooldown()
{
if (attackCooldown > 0)
{
attackCooldown--;
if (KnifeType == 1)
ReturnToRestingPosition();
else if (KnifeType == 2)
Projectile.velocity *= 0.96f;
if (attackCooldown == 0)
{
attacksDone = 0;
if (KnifeType == 1)
{
Particle orb2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Orchid, "CalamityMod/Particles/BloomRing", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0, 0.7f, 10);
GeneralParticleHandler.SpawnParticle(orb2);
Particle orb3 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Orchid, "CalamityMod/Particles/SmallBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0, 0.35f, 15, true);
GeneralParticleHandler.SpawnParticle(orb3);
for (int i = 0; i < 6; i++)
{
Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType<LightDust>(), Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(4f, 8f));
dust.noGravity = true;
dust.scale = Main.rand.NextFloat(0.65f, 1.15f);
dust.color = Color.Orchid;
dust.noLightEmittence = true;
}
}
}
}
}
public void ApplyPlayerBuffs()
{
Owner.AddBuff(ModContent.BuffType<DazzlingStabberBuff>(), 3600);
@@ -67,22 +181,24 @@ namespace CalamityMod.Projectiles.Summon
Projectile.timeLeft = 2;
}
}
public void UpdateFrames()
{
Projectile.frameCounter++;
if (Projectile.frameCounter % 6 == 0)
Projectile.frame = (Projectile.frame + 1) % Main.projFrames[Projectile.type];
}
public void SliceTarget(NPC target)
{
moveSmoothing = 50;
// Don't do anything if the attack delay is still passing.
if (AttackDelay > -60f)
{
AttackDelay--;
if (AttackDelay > 0f)
{
if (KnifeType == 1)
{
if (!Projectile.WithinRange(storedPos, 150f))
Projectile.velocity = Projectile.velocity.RotatedBy(0.1f);
else
Projectile.velocity *= 1.004f;
}
return;
}
}
// Reset the velocity to fly upward if there is very little motion to ensure
@@ -91,23 +207,34 @@ namespace CalamityMod.Projectiles.Summon
Projectile.velocity = Vector2.UnitY * -12f;
// If close to the target, slow down dramatically.
if (Projectile.velocity.Length() > 5f && Projectile.WithinRange(target.Center, 90f))
if (Projectile.velocity.Length() > 5f && Projectile.WithinRange(storedPos, 50f))
Projectile.velocity *= 0.93f;
// Otherwise, if not close, speed up dramatically.
else if (Projectile.velocity.Length() < 40f)
else if (Projectile.velocity.Length() < (KnifeType == 2 ? 15 : 40f))
Projectile.velocity *= 1.03f;
float angularTurnSpeed = 0.35f;
float angleToTargetCoords = Projectile.AngleTo(target.Center);
float angularTurnSpeed = 0.25f;
float angleToTargetCoords = Projectile.AngleTo(storedPos);
if (!Projectile.WithinRange(target.Center, 200f))
Projectile.velocity = Projectile.velocity.ToRotation().AngleTowards(angleToTargetCoords, angularTurnSpeed).ToRotationVector2() * Projectile.velocity.Length();
// If not super close to the target but the target is very much in the line of sight of the summon, charge.
if (!Projectile.WithinRange(target.Center, 75f) && Vector2.Dot(Projectile.SafeDirectionTo(target.Center), Projectile.velocity.SafeNormalize(Vector2.Zero)) > 0.85f)
if (KnifeType == 3)
{
Projectile.velocity = Projectile.SafeDirectionTo(target.Center) * 36f;
if (!Projectile.WithinRange(storedPos, 100f))
Projectile.velocity = Projectile.velocity.ToRotation().AngleTowards(angleToTargetCoords, angularTurnSpeed).ToRotationVector2() * Projectile.velocity.Length();
}
if (KnifeType == 2)
{
Projectile.velocity = Projectile.SafeDirectionTo(storedPos) * 15f;
}
if (KnifeType == 1)
{
if (!Projectile.WithinRange(storedPos, 400f))
Projectile.velocity = Projectile.SafeDirectionTo(storedPos) * 20f;
}
// If not super close to the target but the target is very much in the line of sight of the summon, charge.
if (!Projectile.WithinRange(storedPos, 75f) && Vector2.Dot(Projectile.SafeDirectionTo(storedPos), Projectile.velocity.SafeNormalize(Vector2.Zero)) > 0.99f && KnifeType == 3)
{
Projectile.velocity = Projectile.SafeDirectionTo(storedPos) * 36f;
AttackDelay = 15f;
Projectile.netUpdate = true;
@@ -118,46 +245,80 @@ namespace CalamityMod.Projectiles.Summon
public void ReturnToRestingPosition()
{
Projectile.rotation = Projectile.rotation.AngleTowards(RestOffsetAngle, 0.25f);
if (moveSmoothing > 2)
moveSmoothing--;
Projectile.rotation = Projectile.rotation.AngleTowards(RestOffsetAngle + Main.GlobalTimeWrappedHourly, 0.25f);
float sine = Math.Abs((float)Math.Sin((Main.GlobalTimeWrappedHourly + RestOffsetAngle * 1.8f) * 8f / MathHelper.Pi));
// Rapidly approach the resting position.
Vector2 destination = Owner.Center + Vector2.UnitY.RotatedBy(RestOffsetAngle) * -120f;
Projectile.velocity = (destination - Projectile.Center) / 10f;
Vector2 destination = Owner.Center + Vector2.UnitY.RotatedBy(RestOffsetAngle + Main.GlobalTimeWrappedHourly) * -220f * (MathHelper.Lerp(sine, 0.8f, 0.8f));
Projectile.velocity = (destination - Projectile.Center) / (potentialTarget == null ? moveSmoothing : 18);
}
public override void PostDraw(Color lightColor)
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
for (int i = 1; i < Projectile.oldPos.Length; i++)
CalamityUtils.DistanceClamp(ref Projectile.oldPos[i - 1], ref Projectile.oldPos[i], 6f);
Texture2D trailSegmentTexture = ModContent.Request<Texture2D>("CalamityMod/Projectiles/StarProj").Value;
for (int i = 2; i < Projectile.oldPos.Length; i++)
if (KnifeType == 1)
{
float completionRatio = i / (float)Projectile.oldPos.Length;
float rotation = (Projectile.oldPos[i - 1] - Projectile.oldPos[i]).ToRotation() + MathHelper.PiOver2;
float scale = MathHelper.Lerp(0.7f, 0.1f, completionRatio) * Projectile.scale;
Color color = Color.Lerp(Color.LightPink, Color.Goldenrod, completionRatio * 3f % 1f) * 1.5f;
// Become dimmer the slower the projectile is moving.
color *= Utils.GetLerpValue(1f, 8f, Projectile.velocity.Length(), true);
// As well as how close the projectile is to pointing away from its rotation.
color *= Utils.GetLerpValue(0.65f, 0.45f, Projectile.velocity.AngleBetween(-(Projectile.rotation + MathHelper.PiOver2).ToRotationVector2()) / MathHelper.Pi, true);
Main.EntitySpriteDraw(trailSegmentTexture,
Projectile.oldPos[i] + Projectile.Size * 0.5f + new Vector2(0f, 8f).RotatedBy(Projectile.rotation) - Main.screenPosition,
null,
color,
rotation,
trailSegmentTexture.Size() * 0.5f,
scale,
SpriteEffects.None,
0);
AttackDelay = 15;
attacksDone++;
SoundEngine.PlaySound(SoundID.DD2_WitherBeastCrystalImpact with { Volume = 0.7f, Pitch = attacksDone * 0.05f }, Projectile.Center);
if (attacksDone >= 6)
{
for (int i = 0; i < 9; i++)
{
Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType<LightDust>(), Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(0.5f) * Main.rand.NextFloat(10f, 20f));
dust.noGravity = true;
dust.scale = Main.rand.NextFloat(1.25f, 1.75f);
dust.color = Color.Orchid;
dust.noLightEmittence = true;
}
for (int i = 0; i < 4; i++)
{
Particle spark = new CustomSpark(Projectile.Center, (Projectile.velocity.SafeNormalize(Vector2.UnitX)).RotatedByRandom(0.6f) * Main.rand.NextFloat(15f, 20f), "CalamityMod/Particles/ProvidenceMarkParticle", false, 25, Main.rand.NextFloat(1.35f, 1.6f), Color.Orchid, new Vector2(1.3f, 0.5f), true, false, 0, false, false, Main.rand.NextFloat(0.25f, 0.35f));
GeneralParticleHandler.SpawnParticle(spark);
}
attackCooldown = Main.rand.Next(80, 95 + 1);
}
}
if (KnifeType == 2)
{
SoundStyle slam = new("CalamityMod/Sounds/NPCHit/RavagerRockPillarHit", 2);
SoundEngine.PlaySound(slam with { Volume = 0.4f, Pitch = Main.rand.NextFloat(-0.25f, -0.15f), MaxInstances = -1 }, Projectile.Center);
for (int i = 0; i < 7; i++)
{
Particle spark = new CustomSpark(Projectile.Center, Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(1f, 5f), "CalamityMod/Projectiles/Typeless/ArtifactOfResilienceShard6", false, Main.rand.Next(15, 25 + 1), Main.rand.NextFloat(0.75f, 1.2f), Color.White, new Vector2(1.3f, 0.5f), false, false, Main.rand.NextFloat(-5, 5), false, false);
GeneralParticleHandler.SpawnParticle(spark);
}
Projectile.velocity = (-Projectile.velocity.SafeNormalize(Vector2.UnitX) * 15).RotatedByRandom(0.7f);
attackCooldown = Main.rand.Next(45, 60 + 1);
}
if (KnifeType == 3)
{
if (attackCooldown == 0)
attackCooldown = 5;
target.AddBuff(ModContent.BuffType<HolyFlames>(), 180);
}
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType<HolyFlames>(), 180);
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
{
modifiers.SourceDamage *= damageMult;
}
public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType<HolyFlames>(), 180);
public override bool? CanDamage() => attackCooldown == 0 ? null : false;
public override bool PreDraw(ref Color lightColor)
{
Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value;
if (KnifeType == 1)
tex = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Summon/DazzlingStabber").Value;
if (KnifeType == 2)
tex = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Summon/DazzlingStabber2").Value;
if (KnifeType == 3)
tex = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Summon/DazzlingStabber3").Value;
Projectile.DrawProjectileWithBackglow(color1 with { A = 0 }, lightColor, 3.5f, tex);
return false;
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB