Removed Wind Blade rework from main branch

Hi to people who snoop around in the source I guess
This commit is contained in:
CongratsIsTrash committed 2024-05-22 15:42:52 -04:00
1 parent 47ca086011
commit 2b6eee0fdf
11 files changed
+146 -570

No files matched your search

-23
View File
@@ -1,23 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Items.BaseItems
{
public abstract class CustomUseProjItem : ModItem
{
public override void SetDefaults()
{
Item.channel = true;
}
public override bool CanShoot(Player player)
{
return player.ownedProjectileCounts[Item.shoot] < 1;
}
}
}
+19 -12
View File
@@ -1,6 +1,4 @@
using CalamityMod.Items.BaseItems;
using CalamityMod.Items.Materials;
using CalamityMod.Projectiles.BaseProjectiles;
using CalamityMod.Items.Materials;
using CalamityMod.Projectiles.Melee;
using Microsoft.Xna.Framework;
using Terraria;
@@ -10,29 +8,38 @@ using Terraria.ModLoader;
namespace CalamityMod.Items.Weapons.Melee
{
public class WindBlade : CustomUseProjItem, ILocalizedModType
public class WindBlade : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Weapons.Melee";
public override void SetDefaults()
{
Item.width = 58;
Item.height = 58;
Item.damage = 42;
Item.damage = 41;
Item.DamageType = DamageClass.Melee;
Item.useAnimation = 18;
Item.useAnimation = 20;
Item.useStyle = ItemUseStyleID.Swing;
Item.useTime = 18;
Item.useTime = 20;
Item.useTurn = true;
Item.knockBack = 5f;
Item.UseSound = SoundID.Item1;
Item.autoReuse = true;
Item.value = CalamityGlobalItem.RarityOrangeBuyPrice;
Item.rare = ItemRarityID.Orange;
Item.shoot = ModContent.ProjectileType<Cyclone>();
Item.shootSpeed = 3f;
}
Item.channel = true;
Item.shoot = ModContent.ProjectileType<WindBladeHoldout>();
Item.noUseGraphic = true;
Item.noMelee = true;
Item.useStyle = ItemUseStyleID.Shoot;
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
Projectile.NewProjectile(source, position, velocity, type, damage / 2, knockback, player.whoAmI);
return false;
}
public override void MeleeEffects(Player player, Rectangle hitbox)
{
if (Main.rand.NextBool(3))
Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, DustID.BlueTorch);
}
public override void AddRecipes()
Binary file not shown.

Before

Width:  |  Height:  |  Size: 870 B

After

Width:  |  Height:  |  Size: 930 B

@@ -1390,12 +1390,7 @@ VulcaniteLance: {
WindBlade: {
DisplayName: Wind Blade
Tooltip:
'''
Perform a three swing combo which ends by thrusting the blade forwards
Thrusting the blade launches an expanding cyclone that lingers
Cyclones pull enemies in, or pulls itself towards bosses
'''
Tooltip: Fires cyclones that suck enemies in
}
WulfrumScrewdriver: {
@@ -76,6 +76,7 @@ CosmicSpiritBomb3.DisplayName: Cosmic Bomb
CrescentMoonFlail.DisplayName: Crescent Moon
CrescentMoonProj.DisplayName: Crescent Moon
CrystylCrusherRay.DisplayName: Crystyl Crusher Ray
Cyclone.DisplayName: Cyclone
DarkBall.DisplayName: Dark Ball
DarkBeam.DisplayName: Dark Beam
DarkIceZero.DisplayName: Dark Ice
@@ -310,7 +311,6 @@ Waterfall.DisplayName: Waterfall Beam
WhiteBoltAura.DisplayName: White Aura
WhiteOrb.DisplayName: White Orb
Whiterain.DisplayName: White Rain
WindBolt.DisplayName: Wind Bolt
WulfrumScrew.DisplayName: Wulfrum Screw
WulfrumScrewdriverProj.DisplayName: Wulfrum Screwdriver
YateveoBloomProj.DisplayName: Yateveo Bloom
@@ -1,250 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CalamityMod.Items.Weapons.Melee;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using ReLogic.Content;
using Terraria;
using Terraria.DataStructures;
using Terraria.GameInput;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.BaseProjectiles
{
public abstract class BaseCustomUseStyleProjectile : ModProjectile
{
public override void SetDefaults()
{
Projectile.friendly = true;
Projectile.tileCollide = false;
Projectile.penetrate = -1;
}
public override void OnSpawn(IEntitySource source)
{
Projectile.timeLeft = Owner.HeldItem.useAnimation + 1;
}
#region Fields
/// <summary>
/// The offset in pixels of the weapon from the projectile owner's center. This works even while using AbsolutePosition.
/// </summary>
public Vector2 Offset = Vector2.Zero;
/// <summary>
/// The Player that is using the projectile.
/// </summary>
public virtual Player Owner => Main.player[Projectile.owner];
/// <summary>
/// The amount of pixels out the center of the projectile's hitbox is.
/// </summary>
public virtual float HitboxOutset => 30;
/// <summary>
/// The projectile's hitbox size in pixels.
/// </summary>
public virtual Vector2 HitboxSize => new Vector2(30, 30);
/// <summary>
/// The number of animations that this projectile has gone through. Useful for things like swing combos.
/// </summary>
public int NumberOfAnimations = 0;
public float Animation = 0;
/// <summary>
/// If true, flips the sprite with a 45-degree sword tilt in mind.
/// </summary>
public bool FlipAsSword = false;
/// <summary>
/// The offset in radians of the weapon's rotation from its current rotation.
/// </summary>
public float RotationOffset = 0f;
/// <summary>
/// The offset in radians of the rotation of the player's front arm.
/// </summary>
public float ArmRotationOffset = 0f;
/// <summary>
/// The offset in radians of the rotation of the player's back arm.
/// </summary>
public float ArmRotationOffsetBack = 0f;
/// <summary>
/// The amount of animation frames the projectile has in a vertical sheet.
/// </summary>
public virtual int FrameCount => 1;
/// <summary>
/// The individual frame currently being drawn in a vertical sheet.
/// </summary>
public int Frame = 0;
/// <summary>
/// The origin of the sprite when drawn on your character.
/// </summary>
/// <returns></returns>
public virtual Vector2 SpriteOrigin => Projectile.Size / 2;
/// <summary>
/// Helper method for getting the rotation of the sprite plus RotationOffset, without having to make your own local variable every time.
/// </summary>
/// <returns></returns>
public float FinalRotation => Projectile.rotation + RotationOffset;
/// <summary>
/// Rotation offset for the hitbox that doesn't affect the sprite.
/// Useful for if you have, for instance, a sword sprite at a 45 degree angle, and need that to reflect on the hitbox.
/// </summary>
/// <returns></returns>
public virtual float HitboxRotationOffset => 0f;
/// <summary>
/// Whether or not the projectile can hit enemies at the current frame.
/// Useful for wind-up animations where you don't want the projectile to deal damage.
/// </summary>
public bool CanHit = true;
/// <summary>
/// Overrides the projectile owner's center as the projectile's location, so long as it isn't Vector2.Zero.
/// </summary>
public Vector2 AbsolutePosition = Vector2.Zero;
/// <summary>
/// If this field is true, the projectile will draw at all times. Otherwise, it will only draw when its associated item is in use.
/// </summary>
public bool DrawUnconditionally = false;
/// <summary>
/// The number of frames that the current use animation has progressed through.
/// </summary>
public float AnimationProgress = 0;
#endregion
#region Use Style
/// <summary>
/// Determines the behavior to reset to when the item is not in use.
/// </summary>
public virtual void ResetStyle() { }
/// <summary>
/// Determines the behavior of the projectile when the item is in use.
/// </summary>
public virtual void UseStyle() { }
/// <summary>
/// Determines the behavior of the projectile when the item use animation begins for the first time in a row.
/// </summary>
public virtual void OnBeginUse() { }
/// <summary>
/// Determines the behavior of the projectile when the item use animation ends.
/// </summary>
public virtual void OnEndUse() { }
#endregion
public override void AI()
{
Owner.Calamity().mouseWorldListener = true;
if (Owner.ItemAnimationActive)
{
Animation++;
UseStyle();
Owner.heldProj = Projectile.whoAmI;
Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, Projectile.rotation + RotationOffset + ArmRotationOffset);
Owner.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, Projectile.rotation + RotationOffset + ArmRotationOffsetBack);
}
else
{
Animation = 0;
if (DrawUnconditionally)
{
Owner.heldProj = Projectile.whoAmI;
Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, Projectile.rotation + RotationOffset + ArmRotationOffset);
Owner.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, Projectile.rotation + RotationOffset + ArmRotationOffsetBack);
}
NumberOfAnimations = 0;
ResetStyle();
}
AnimationProgress = Animation % Owner.itemAnimationMax;
if (AbsolutePosition == Vector2.Zero)
{
Projectile.position = Owner.position + (Owner.Size / 2) - (Projectile.Size / 2) + Offset;
}
else
{
Projectile.position = AbsolutePosition - (Projectile.Size / 2) + Offset;
}
if (Owner.itemAnimation == 1)
{
OnEndUse();
NumberOfAnimations++;
}
if (Owner.ItemAnimationJustStarted)
{
Projectile.timeLeft = Owner.HeldItem.useAnimation + 1;
OnBeginUse();
}
}
public override bool? CanHitNPC(NPC target)
{
bool bb = (target.immune[0] <= 0) && !target.friendly && !target.dontTakeDamage;
return bb;
}
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
{
modifiers.HitDirectionOverride = Owner.direction;
base.ModifyHitNPC(target, ref modifiers);
}
public override bool? CanDamage()
{
return CanHit ? base.CanDamage() : false;
}
public override void ModifyDamageHitbox(ref Rectangle hitbox)
{
Vector2 cen = Projectile.Center + new Vector2(HitboxOutset, 0).RotatedBy(FinalRotation + HitboxRotationOffset);
hitbox = new Rectangle((int)cen.X - (int)(HitboxSize.X / 2), (int)cen.Y - (int)(HitboxSize.Y / 2), (int)HitboxSize.X, (int)HitboxSize.Y);
base.ModifyDamageHitbox(ref hitbox);
}
public override bool PreDraw(ref Color lightColor)
{
// Only draw the projectile if the projectile's owner is currently using the item this projectile is attached to.
if (Owner.itemAnimation > 0 || DrawUnconditionally)
{
Asset<Texture2D> tex = ModContent.Request<Texture2D>(Texture);
float r = FlipAsSword ? MathHelper.ToRadians(90) : 0f;
Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition + new Vector2(0, Owner.gfxOffY), tex.Frame(1, FrameCount, 0, Frame), lightColor, Projectile.rotation + RotationOffset + r, FlipAsSword ? new Vector2(tex.Width() - SpriteOrigin.X, SpriteOrigin.Y) : SpriteOrigin, Projectile.scale, FlipAsSword ? SpriteEffects.FlipHorizontally : SpriteEffects.None);
}
return false;
}
}
}
+125
View File
@@ -0,0 +1,125 @@
using CalamityMod.CalPlayer;
using Microsoft.Xna.Framework;
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.Audio;
namespace CalamityMod.Projectiles.Melee
{
public class Cyclone : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Melee";
public int dustvortex = 0;
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 6;
ProjectileID.Sets.TrailingMode[Projectile.type] = 0;
}
public override void SetDefaults()
{
Projectile.width = 56;
Projectile.height = 56;
Projectile.alpha = 255;
Projectile.friendly = true;
Projectile.DamageType = DamageClass.Melee;
Projectile.timeLeft = 300;
Projectile.extraUpdates = 2;
Projectile.penetrate = 2;
Projectile.ignoreWater = true;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = -1;
Projectile.tileCollide = false;
}
public override void AI()
{
Projectile.ai[0]++;
Projectile.ai[1]++;
//Code so it doesnt collide on tiles instantly
if (Projectile.ai[0] >= 12)
Projectile.tileCollide = true;
Projectile.rotation += 2.5f;
Projectile.alpha -= 5;
if (Projectile.alpha < 50)
{
Projectile.alpha = 50;
if (Projectile.ai[1] >= 15)
{
for (int i = 1; i <= 6; i++)
{
Vector2 dustspeed = new Vector2(3f, 3f).RotatedBy(MathHelper.ToRadians(dustvortex));
int d = Dust.NewDust(Projectile.Center, Projectile.width / 2, Projectile.height / 2, 31, dustspeed.X, dustspeed.Y, 200, new Color(232, 251, 250, 200), 1.3f);
Main.dust[d].noGravity = true;
Main.dust[d].velocity = dustspeed;
dustvortex += 60;
}
dustvortex -= 355;
Projectile.ai[1] = 0;
}
}
float num472 = Projectile.Center.X;
float num473 = Projectile.Center.Y;
float num474 = 600f;
for (int num475 = 0; num475 < Main.maxNPCs; num475++)
{
NPC npc = Main.npc[num475];
if (npc.CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, npc.Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses)
{
float npcCenterX = npc.position.X + (float)(npc.width / 2);
float npcCenterY = npc.position.Y + (float)(npc.height / 2);
float num478 = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcCenterX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcCenterY);
if (num478 < num474)
{
if (npc.position.X < num472)
{
npc.velocity.X += 0.05f;
}
else
{
npc.velocity.X -= 0.05f;
}
if (npc.position.Y < num473)
{
npc.velocity.Y += 0.05f;
}
else
{
npc.velocity.Y -= 0.05f;
}
}
}
}
}
public override Color? GetAlpha(Color lightColor)
{
return new Color(204, 255, 255, Projectile.alpha);
}
public override bool PreDraw(ref Color lightColor)
{
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1);
return false;
}
public override void OnKill(int timeLeft)
{
SoundEngine.PlaySound(SoundID.Item60 with { Volume = SoundID.Item60.Volume * 0.6f }, Projectile.Center);
for (int i = 0; i <= 360; i += 3)
{
Vector2 dustspeed = new Vector2(3f, 3f).RotatedBy(MathHelper.ToRadians(i));
int d = Dust.NewDust(Projectile.Center, Projectile.width, Projectile.height, 31, dustspeed.X, dustspeed.Y, 200, new Color(232, 251, 250, 200), 1.4f);
Main.dust[d].noGravity = true;
Main.dust[d].position = Projectile.Center;
Main.dust[d].velocity = dustspeed;
}
}
}
}
File renamed without changes.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

-132
View File
@@ -1,132 +0,0 @@
using CalamityMod.Items.Weapons.Melee;
using CalamityMod.Particles;
using CalamityMod.Projectiles.BaseProjectiles;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Melee
{
public class WindBladeHoldout : BaseCustomUseStyleProjectile, ILocalizedModType
{
public override LocalizedText DisplayName => CalamityUtils.GetItemName<WindBlade>();
public override float HitboxOutset => 60;
public override Vector2 HitboxSize => new Vector2(70, 70);
public override float HitboxRotationOffset => MathHelper.ToRadians(-45);
public override Vector2 SpriteOrigin => new(0, 80);
public override void SetDefaults()
{
base.SetDefaults();
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 10;
}
public override void OnSpawn(IEntitySource source)
{
Projectile.scale = 0f;
Projectile.ai[1] = 1;
base.OnSpawn(source);
}
public override void UseStyle()
{
Vector2 mousePos = Owner.Calamity().mouseWorld;
if (mousePos.X < Owner.Center.X) Owner.direction = -1;
else Owner.direction = 1;
DrawUnconditionally = true;
if (NumberOfAnimations % 4 < 2)
{
Projectile.rotation = Owner.AngleTo(mousePos) + MathHelper.ToRadians(45f);
if (NumberOfAnimations % 4 == 0 && AnimationProgress < 10)
Projectile.scale = MathHelper.Lerp(Projectile.scale, 1f, 0.4f);
if (AnimationProgress < (Owner.itemAnimationMax / 3))
{
CanHit = false;
if (AnimationProgress == 0)
{
Projectile.ai[1] = -Projectile.ai[1];
}
RotationOffset = MathHelper.Lerp(RotationOffset, MathHelper.ToRadians(120f * Projectile.ai[1] * Owner.direction), 0.2f);
}
else
{
CanHit = true;
if ((int)AnimationProgress == (int)(Owner.itemAnimationMax / 1.5f))
{
SoundEngine.PlaySound(SoundID.DD2_MonkStaffSwing, Owner.Center);
}
if ((int)AnimationProgress > (int)(Owner.itemAnimationMax / 1.5f))
{
GeneralParticleHandler.SpawnParticle(new HeavySmokeParticle(Owner.Center + (new Vector2(Main.rand.Next(30, 100), 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45))), new Vector2(0, 10 * -Projectile.ai[1] * Owner.direction).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)), Color.LightSkyBlue, 40, 1f, 0.4f, MathHelper.ToRadians(Main.rand.NextFloat(-10f, 10f)), true));
}
float time = (AnimationProgress) - (Owner.itemAnimationMax / 3);
float timeMax = Owner.itemAnimationMax - (Owner.itemAnimationMax / 3);
RotationOffset = MathHelper.Lerp(RotationOffset, MathHelper.ToRadians(MathHelper.Lerp(150f * Projectile.ai[1] * Owner.direction, 120f * -Projectile.ai[1] * Owner.direction, CalamityUtils.ExpInOutEasing(time / timeMax, 1))),
0.2f);
}
FlipAsSword = Owner.direction == -1 ? true : false;
}
else if (NumberOfAnimations % 4 == 3)
{
float ProjectileSpeed = 10;
int ProjectileDamage = (int)(Projectile.damage * 0.3f);
float ProjectileKnockback = (int)(Projectile.knockBack * 0.5f);
CanHit = true;
if ((int)AnimationProgress == 1)
{
SoundEngine.PlaySound(SoundID.DD2_SkyDragonsFurySwing, Owner.Center);
SoundEngine.PlaySound(SoundID.DD2_MonkStaffSwing.WithPitchOffset(-0.4f), Owner.Center);
Projectile.NewProjectile(new EntitySource_ItemUse(Owner, Owner.HeldItem), Projectile.Hitbox.Center.ToVector2(), new Vector2(ProjectileSpeed, 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)), ModContent.ProjectileType<WindBolt>(), ProjectileDamage, ProjectileKnockback, Owner.whoAmI);
}
RotationOffset = 0f;
if (AnimationProgress < Owner.itemAnimationMax / 3)
{
Projectile.scale = MathHelper.Lerp(Projectile.scale, 1.5f, 0.4f);
float rot = FinalRotation + MathHelper.ToRadians(-45);
GeneralParticleHandler.SpawnParticle(new HeavySmokeParticle(Owner.Center + new Vector2(105 * Projectile.scale, 0).RotatedBy(rot), new Vector2(5, 0).RotatedBy(rot + MathHelper.ToRadians(Main.rand.NextFloat(-20, 20))), Color.LightSkyBlue, 30, 2f, 0.3f, MathHelper.ToRadians(Main.rand.NextFloat(-10f, 10f)), true));
GeneralParticleHandler.SpawnParticle(new LineParticle(Owner.Center + new Vector2(0, 20).RotatedBy(rot) + new Vector2(45 * Projectile.scale, 0).RotatedBy(rot), new Vector2(5, 0).RotatedBy(rot), false, 30, 1f, Color.LightSkyBlue));
GeneralParticleHandler.SpawnParticle(new LineParticle(Owner.Center + new Vector2(0, -20).RotatedBy(rot) + new Vector2(45 * Projectile.scale, 0).RotatedBy(rot), new Vector2(5, 0).RotatedBy(rot), false, 30, 1f, Color.LightSkyBlue));
}
else
{
Projectile.scale = MathHelper.Lerp(Projectile.scale, 1.5f, -0.2f);
}
}
else
{
CanHit = false;
RotationOffset = MathHelper.Lerp(RotationOffset, MathHelper.ToRadians(MathHelper.Lerp(150f * -Projectile.ai[1] * Owner.direction, 120f * Projectile.ai[1] * Owner.direction, 0.1f)),
0.2f);
Projectile.rotation = Owner.AngleTo(mousePos) + MathHelper.ToRadians(45f);
Projectile.scale = MathHelper.Lerp(Projectile.scale, 0f, 0.2f);
}
ArmRotationOffset = MathHelper.ToRadians(-90f);
}
public override void ResetStyle()
{
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 870 B

-146
View File
@@ -1,146 +0,0 @@
using System;
using CalamityMod.CalPlayer;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.Audio;
using Terraria.GameContent.UI;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.Utilities.Terraria.Utilities;
using XPT.Core.Audio.MP3Sharp.Decoding.Decoders.LayerIII;
namespace CalamityMod.Projectiles.Melee
{
public class WindBolt : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Melee";
public int dustvortex = 0;
public float scFactor = 0f;
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 6;
ProjectileID.Sets.TrailingMode[Projectile.type] = 0;
}
public override void SetDefaults()
{
Projectile.width = 40;
Projectile.height = 40;
Projectile.alpha = 255;
Projectile.friendly = true;
Projectile.DamageType = DamageClass.Melee;
Projectile.timeLeft = 300;
Projectile.extraUpdates = 2;
Projectile.penetrate = -1;
Projectile.ignoreWater = true;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 8 * Projectile.MaxUpdates;
Projectile.tileCollide = false;
}
public override void AI()
{
Projectile.velocity *= 0.98f;
Projectile.ai[0]++;
Projectile.ai[1]++;
//Code so it doesnt collide on tiles instantly
if (Projectile.ai[0] >= 12)
Projectile.tileCollide = true;
Projectile.rotation += MathHelper.ToRadians(1f);
Projectile.alpha -= 5;
{
Projectile.alpha = 50;
if (Projectile.ai[1] >= 15)
{
scFactor = MathHelper.Lerp(scFactor, 1f, 0.1f);
for (int i = 1; i <= 6; i++)
{
Vector2 dustpos = new Vector2(48f, 48f).RotatedBy(MathHelper.ToRadians(dustvortex + Main.rand.Next(30)));
Vector2 dustspeed = new Vector2(-5f, -5f).RotatedBy(MathHelper.ToRadians(dustvortex + Main.rand.Next(30)));
int d = Dust.NewDust(Projectile.Center + dustpos, Projectile.width / 2, Projectile.height / 2, DustID.Smoke, dustspeed.X, dustspeed.Y, 200, new Color(232, 251, 250, 50), 1.3f);
Main.dust[d].noGravity = true;
Main.dust[d].velocity = dustspeed;
dustvortex += 60;
}
dustvortex -= 355;
Projectile.ai[1] = 0;
}
}
float projX = Projectile.Center.X;
float projY = Projectile.Center.Y;
foreach (var npc in Main.ActiveNPCs)
{
if (npc.CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, npc.Center, 1, 1))
{
if (!CalamityPlayer.areThereAnyDamnBosses) // Pulls enemies in while no boss is alive
{
float npcCenterX = npc.position.X + (float)(npc.width / 2);
float npcCenterY = npc.position.Y + (float)(npc.height / 2);
float npcDistance = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcCenterX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcCenterY);
if (npcDistance < 320f)
{
float factor = MathHelper.Lerp(1f, 0f, CalamityUtils.SineBumpEasing(npcDistance / 300, 1));
npc.velocity += npc.DirectionTo(Projectile.Center) * factor * 0.25f;
}
if (npcDistance < 40)
npc.velocity *= 0.75f;
}
else // Pulls itself toward enemies while a boss is alive so that the gimmick isn't entirely lost
{
if (Math.Abs(Projectile.velocity.X) < 1.5f && Math.Abs(Projectile.velocity.Y) < 1.5f)
CalamityUtils.HomeInOnNPC(Projectile, false, 320f, 1.5f, 20f);
}
}
}
}
public override bool PreDraw(ref Color lightColor)
{
Asset<Texture2D> tex = ModContent.Request<Texture2D>(Texture);
for (int i = 5; i >= 0; i--)
{
float c = Math.Max(i, 1);
Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition, tex.Frame(), new Color(1f / c, 1f / c, 1f / c, 1f / c), -Projectile.rotation * c, tex.Size() / 2, (float)MathHelper.Lerp(1f, i, scFactor), SpriteEffects.None);
}
return false;
}
public override void ModifyDamageHitbox(ref Rectangle hitbox)
{
// The hitbox gets bigger over time, because the vortex visually grows
int sizeIncrease = (int)(Projectile.ai[0] * 0.3f);
hitbox.Inflate(sizeIncrease, sizeIncrease);
}
// The vortex slows down on enemies hits, so that it is easier for it to linger on top of stuff
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => Projectile.velocity *= 0.5f;
public override void OnKill(int timeLeft)
{
SoundEngine.PlaySound(SoundID.Item60 with { Volume = SoundID.Item60.Volume * 0.6f }, Projectile.Center);
for (int i = 0; i <= 360; i += 3)
{
Vector2 dustspeed = new Vector2(12f, 12f).RotatedBy(MathHelper.ToRadians(i));
int d = Dust.NewDust(Projectile.Center + (dustspeed * 2), Projectile.width, Projectile.height, DustID.Smoke, dustspeed.X, dustspeed.Y, 200, new Color(232, 251, 250, 200), 1.4f);
Main.dust[d].noGravity = true;
Main.dust[d].position = Projectile.Center;
Main.dust[d].velocity = dustspeed;
}
}
}
}