diff --git a/CalamityLists.cs b/CalamityLists.cs index 4cd4d3d5f5..4f96e19785 100644 --- a/CalamityLists.cs +++ b/CalamityLists.cs @@ -63,6 +63,7 @@ using CalamityMod.Projectiles.DraedonsArsenal; using CalamityMod.Projectiles.Enemy; using CalamityMod.Projectiles.Magic; using CalamityMod.Projectiles.Melee; +using CalamityMod.Projectiles.Melee.MaceFlails; using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Rogue; using CalamityMod.Projectiles.Summon; @@ -2043,7 +2044,7 @@ namespace CalamityMod ProjectileType(), ProjectileType(), ProjectileType(), - ProjectileType(), + ProjectileType(), ProjectileType(), }; diff --git a/Items/Weapons/Melee/YateveoBloom.cs b/Items/Weapons/Melee/YateveoBloom.cs index b6e7a31af2..5984d94db1 100644 --- a/Items/Weapons/Melee/YateveoBloom.cs +++ b/Items/Weapons/Melee/YateveoBloom.cs @@ -1,4 +1,4 @@ -using CalamityMod.Projectiles.Melee; +using CalamityMod.Projectiles.Melee.MaceFlails; using CalamityMod.Projectiles.Melee.Spears; using Microsoft.Xna.Framework; using Terraria; @@ -41,7 +41,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.rare = ItemRarityID.Green; Item.Calamity().donorItem = true; - Item.shoot = ModContent.ProjectileType(); + Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = ShootSpeed; } @@ -75,9 +75,9 @@ namespace CalamityMod.Items.Weapons.Melee { float speedMult = SpearSpeed / ShootSpeed; if (player.altFunctionUse == 2) - Projectile.NewProjectile(source, position.X, position.Y, velocity.X * speedMult, velocity.Y * speedMult, ModContent.ProjectileType(), (int)(damage * 0.666666f), knockback, player.whoAmI); + Projectile.NewProjectile(source, position, velocity * speedMult, ModContent.ProjectileType(), (int)(damage * 0.666666f), knockback, player.whoAmI); else - Projectile.NewProjectile(source, position.X, position.Y, velocity.X, velocity.Y, type, damage, knockback, player.whoAmI); + Projectile.NewProjectile(source, position, velocity, type, (int)(damage * 0.5f), knockback, player.whoAmI); return false; } diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson index 60c7c765e4..be765dce6e 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson @@ -307,6 +307,5 @@ WhiteOrb.DisplayName: White Orb Whiterain.DisplayName: White Rain WulfrumScrew.DisplayName: Wulfrum Screw WulfrumScrewdriverProj.DisplayName: Wulfrum Screwdriver -YateveoBloomProj.DisplayName: Yateveo Bloom YinYoDark.DisplayName: Dark Shard YinYoLight.DisplayName: Light Shard diff --git a/Projectiles/BaseProjectiles/BaseMaceFlailProjectile.cs b/Projectiles/BaseProjectiles/BaseMaceFlailProjectile.cs new file mode 100644 index 0000000000..0d745f3749 --- /dev/null +++ b/Projectiles/BaseProjectiles/BaseMaceFlailProjectile.cs @@ -0,0 +1,536 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using System; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.BaseProjectiles +{ + // Adapted from ExampleMod's ExampleAdvancedFlailProjectile (which in turn also adapted from Vanilla's AI Style 15) + public abstract class BaseMaceFlailProjectile : ModProjectile + { + public abstract int AssociatedItemID { get; } + public override LocalizedText DisplayName => CalamityUtils.GetItemName(AssociatedItemID); + + #region Properties + /// + /// Local immunity frames granted while dropped or retracted
+ /// Defaults to 10. + ///
+ public virtual int BaseIFrames => 10; + + /// + /// Local immunity frames granted during the spin.
+ /// Defaults to 20. + ///
+ public virtual int SpinIFrames => 20; + + /// + /// Local immunity frames granted while launched or ricochet.
+ /// Defaults to 10. + ///
+ public virtual int LaunchIFrames => 10; + + /// + /// The rate of which the mace visually spins around the player. Does NOT influence any other aspects.
+ /// Defaults to 10f. + ///
+ public virtual float SpinSpeed => 10f; + + /// + /// Horizontal radius for the mace's hitbox while spinning.
+ /// Defaults to 55f. (3.4375 tiles) + ///
+ public virtual float SpinHitboxRadius => 55f; + + /// + /// Max amount of afterimages, which is only drawn while the mace is launched.
+ /// Defaults to 6. + ///
+ public virtual int AfterimageLength => 6; + + /// + /// Constant speed when launched, affected by attack speed.
+ /// Defaults to 16f. + ///
+ public virtual float LaunchSpeed { get; set; } = 16f; + + /// + /// How long the mace launches before retracting. Multiply by its speed to determine its base range.
+ /// Defaults to 15. (0.25 seconds) + ///
+ public virtual int LaunchLifespan => 15; + + /// + /// Max launch range before forcibly being set to retract.
+ /// Typically not useful as it should retract naturally through lifespan before doing so by force.
+ /// Defaults to 960f. (60 tiles) + ///
+ public virtual float MaxLaunchRange => 960f; + + /// + /// Max drop range before forcibly being set to retract.
+ /// Defaults to 400f. (25 tiles) + ///
+ public virtual float MaxDropRange => 400f; + + /// + /// Effect which runs as soon as a launched mace retracts. Does nothing by default. + /// + public virtual Action EffectBeforePullback => null; + + /// + /// When hitting a tile while launched, how long the ricochet lasts before dropping. + /// Defaults to the launch's lifespan added by 5. (20 / 0.33 seconds) + /// + public virtual int RicochetLifespan => LaunchLifespan + 5; + + /// + /// Max speed when retracted, affected by attack speed.
+ /// Defaults to 14f. + ///
+ public virtual float MaxRetractSpeed { get; set; } = 14f; + + /// + /// Acceleration when retracted, affected by attack speed.
+ /// Defaults to 2f. + ///
+ public virtual float RetractAcceleration { get; set; } = 2f; + #endregion + + // Most of these should be kept default for consistency with vanilla maces. + // However, they can be overridden anyway. + #region Overridable Values + /// + /// File path for the mace's chain. These should just be the name of the projectile with "Chain" appended at the end.
+ /// Custom maces may also elect to not draw chains. Simply override this value with string.Empty. + ///
+ public virtual string ChainTexturePath => Texture + "Chain"; + + /// + /// Damage multiplier while spinning. Defaults to 1.2f. + /// + public virtual float SpinDamage => 1.2f; + + /// + /// Knockback multiplier while spinning. Defaults to 0.25f. + /// + public virtual float SpinKnockback => 0.25f; + + /// + /// The vertical multiplier which makes the spin motion elliptical. Defaults to 0.8f. + /// + public virtual float SpinVerticalFactor => 0.8f; + + /// + /// Damage multiplier while launching or non-forced retracting. Defaults to 2f. + /// + public virtual float LaunchDamage => 2f; + + /// + /// Knockback multiplier while dropping. Defaults to 0.5f. + /// + public virtual float DropKnockback => 0.5f; + #endregion + + #region Overridable Methods + /// + /// Scales every value that should be affected by melee speed.
+ /// Can be overridden to leave out certain variables. + ///
+ public virtual void ScaleWithMeleeSpeed(ref float launchSpeed, ref float maxSpeed, ref float acceleration) + { + float meleeSpeedMultiplier = Owner.GetTotalAttackSpeed(DamageClass.Melee); + launchSpeed *= meleeSpeedMultiplier; + maxSpeed *= meleeSpeedMultiplier; + acceleration *= meleeSpeedMultiplier; + } + + public virtual void SpinAI(float launchSpeed) + { + Projectile.ownerHitCheck = true; + if (Projectile.owner == Main.myPlayer) + { + Vector2 toMouse = Owner.MountedCenter.DirectionTo(Main.MouseWorld).SafeNormalize(Vector2.UnitX * Owner.direction); + Owner.ChangeDir((toMouse.X > 0f).ToDirectionInt()); + if (!Owner.channel) + { + CurrentFlailState = FlailState.LaunchingForward; + StateTimer = 0f; + Projectile.Center = Owner.MountedCenter; + Projectile.velocity = toMouse * launchSpeed + Owner.velocity; + Projectile.netUpdate = true; + Projectile.ResetLocalNPCHitImmunity(); + Projectile.localNPCHitCooldown = LaunchIFrames * Projectile.MaxUpdates; + Projectile.ownerHitCheck = false; + return; + } + } + StateTimer++; + Vector2 spinOffset = new Vector2(Owner.direction).RotatedBy(MathHelper.Pi * SpinSpeed * (StateTimer / 60f) * Owner.direction); + + spinOffset.Y *= SpinVerticalFactor; + if (spinOffset.Y * Owner.gravDir > 0f) + spinOffset.Y *= 0.5f; + + Projectile.Center = Owner.MountedCenter + spinOffset * 30f + new Vector2(0, Owner.gfxOffY); + Projectile.velocity = Vector2.Zero; + Projectile.localNPCHitCooldown = SpinIFrames * Projectile.MaxUpdates; + } + + public virtual void LaunchAI() + { + bool shouldRetract = StateTimer++ >= LaunchLifespan; + shouldRetract |= Projectile.Distance(Owner.MountedCenter) >= MaxLaunchRange; + if (Owner.controlUseItem) // If the player clicks, transition to the Dropping state + { + CurrentFlailState = FlailState.Dropping; + StateTimer = 0f; + Projectile.netUpdate = true; + Projectile.velocity *= 0.2f; + return; + } + if (shouldRetract) + { + CurrentFlailState = FlailState.Retracting; + StateTimer = 0f; + Projectile.netUpdate = true; + Projectile.velocity *= 0.3f; + EffectBeforePullback?.Invoke(Projectile); + } + Owner.ChangeDir((Owner.Center.X < Projectile.Center.X).ToDirectionInt()); + Projectile.localNPCHitCooldown = LaunchIFrames * Projectile.MaxUpdates; + } + + public virtual void RetractAI(bool forced, float maxSpeed, float acceleration) + { + if (forced) + { + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + } + + float forceMult = forced ? 2f : 1f; + Vector2 toPlayer = Projectile.DirectionTo(Owner.MountedCenter).SafeNormalize(Vector2.Zero); + Vector2 value = Owner.MountedCenter.DirectionFrom(Projectile.Center + Projectile.velocity).SafeNormalize(Vector2.Zero); + if (Projectile.Distance(Owner.MountedCenter) <= maxSpeed * forceMult || (forced && Vector2.Dot(toPlayer, value) < 0f)) + { + Projectile.Kill(); + return; + } + if (Owner.controlUseItem && !forced) // If the player clicks, transition to the Dropping state + { + CurrentFlailState = FlailState.Dropping; + StateTimer = 0f; + Projectile.netUpdate = true; + Projectile.velocity *= 0.2f; + return; + } + + Projectile.velocity *= 0.98f; + Projectile.velocity = Projectile.velocity.MoveTowards(toPlayer * maxSpeed * forceMult, acceleration * forceMult); + Owner.ChangeDir((Owner.Center.X < Projectile.Center.X).ToDirectionInt()); + } + + public virtual void RicochetAI() + { + if (StateTimer++ >= RicochetLifespan) + { + CurrentFlailState = FlailState.Dropping; + StateTimer = 0f; + Projectile.netUpdate = true; + return; + } + + Projectile.localNPCHitCooldown = LaunchIFrames * Projectile.MaxUpdates; + Projectile.velocity.Y += 0.6f; + Projectile.velocity.X *= 0.95f; + Owner.ChangeDir((Owner.Center.X < Projectile.Center.X).ToDirectionInt()); + } + + public virtual void DropAI() + { + if (!Owner.controlUseItem || Projectile.Distance(Owner.MountedCenter) > MaxDropRange) + { + CurrentFlailState = FlailState.ForcedRetracting; + StateTimer = 0f; + Projectile.netUpdate = true; + return; + } + + Projectile.localNPCHitCooldown = BaseIFrames * Projectile.MaxUpdates; + Projectile.velocity.Y += 0.8f; + Projectile.velocity.X *= 0.95f; + Owner.ChangeDir((Owner.Center.X < Projectile.Center.X).ToDirectionInt()); + } + + /// + /// Reserved for extra AI that is always ran regardless of state. Does nothing by default.
+ /// Example cases include shooting projectiles in a similar manner to Flower Pow. + ///
+ public virtual void ExtraBehavior() { } + + /// + /// Handles simple chain drawing. Can be overridden for cases such as chains with multiple frames/variants. + /// Example cases include Drippler Cripper's chain variants. + /// + public virtual void DrawChain() + { + Vector2 playerArmPosition = Main.GetPlayerArmPosition(Projectile); + + // This fixes a vanilla GetPlayerArmPosition bug causing the chain to draw incorrectly when stepping up slopes. The flail itself still draws incorrectly due to another similar bug. + // This should be removed once the vanilla bug is fixed. + playerArmPosition.Y -= Owner.gfxOffY; + + Vector2 chainPos = Projectile.Center; + Vector2 toArms = playerArmPosition.MoveTowards(chainPos, 4f) - chainPos; + float chainSegmentLength = MathF.Max(1f, Chain.Height()); + float rotation = toArms.ToRotation() + MathHelper.PiOver2; + + float chainsLeft = toArms.Length() + chainSegmentLength * 0.5f; + while (chainsLeft > 0f) + { + Color chainDrawColor = Lighting.GetColor((int)(chainPos.X / 16f), (int)(chainPos.Y / 16f)); + Main.spriteBatch.Draw(Chain.Value, chainPos - Main.screenPosition, null, chainDrawColor, rotation, Chain.Size() * 0.5f, 1f, SpriteEffects.None, 0f); + + chainPos += toArms.SafeNormalize(Vector2.Zero) * chainSegmentLength; + chainsLeft -= chainSegmentLength; + } + } + #endregion + + public enum FlailState + { + Spinning = 0, + LaunchingForward = 1, + Retracting = 2, + ForcedRetracting = 4, + Ricochet = 5, + Dropping = 6 + } + + // These properties wrap the usual ai and localAI arrays for cleaner and easier to understand code. + public FlailState CurrentFlailState + { + get => (FlailState)Projectile.ai[0]; + set => Projectile.ai[0] = (float)value; + } + public ref float StateTimer => ref Projectile.ai[1]; + public ref float CollisionCounter => ref Projectile.localAI[0]; + + public Player Owner => Main.player[Projectile.owner]; + + public static Asset Chain; + public override void Load() + { + if (!String.IsNullOrEmpty(ChainTexturePath)) + Chain = ModContent.Request(ChainTexturePath); + } + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = AfterimageLength; + ProjectileID.Sets.TrailingMode[Type] = 2; + ProjectileID.Sets.HeldProjDoesNotUsePlayerGfxOffY[Type] = true; + } + + public override void SetDefaults() + { + Projectile.netImportant = true; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.DamageType = DamageClass.Melee; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = BaseIFrames * Projectile.MaxUpdates; + } + + public override void AI() + { + if (!Owner.active || Owner.dead || Owner.noItems || Owner.CCed || Vector2.Distance(Projectile.Center, Owner.Center) > MaxLaunchRange + 160f) + { + Projectile.Kill(); + return; + } + if (Main.myPlayer == Projectile.owner && Main.mapFullscreen) + { + Projectile.Kill(); + return; + } + + float launchSpeed = LaunchSpeed; + float maxRetractSpeed = MaxRetractSpeed; + float retractAcceleration = RetractAcceleration; + ScaleWithMeleeSpeed(ref launchSpeed, ref maxRetractSpeed, ref retractAcceleration); + + switch (CurrentFlailState) + { + case FlailState.Spinning: + SpinAI(launchSpeed); + break; + case FlailState.LaunchingForward: + LaunchAI(); + break; + case FlailState.Retracting: + RetractAI(false, maxRetractSpeed, retractAcceleration); + break; + case FlailState.ForcedRetracting: + RetractAI(true, maxRetractSpeed, retractAcceleration); + break; + case FlailState.Ricochet: + RicochetAI(); + break; + case FlailState.Dropping: + DropAI(); + break; + } + + ExtraBehavior(); + + Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X > 0f).ToDirectionInt(); + + // Non-symmetric rotation (symmetric is just in this if condition here) + if (CurrentFlailState == FlailState.Ricochet || CurrentFlailState == FlailState.Dropping) + { + if (Projectile.velocity.Length() > 1f) + Projectile.rotation = Projectile.velocity.ToRotation() + Projectile.velocity.X * 0.1f; + else + Projectile.rotation += Projectile.velocity.X * 0.1f; + } + else + { + Vector2 vectorTowardsPlayer = Projectile.DirectionTo(Owner.MountedCenter).SafeNormalize(Vector2.Zero); + Projectile.rotation = vectorTowardsPlayer.ToRotation() + MathHelper.PiOver2; + } + + Projectile.timeLeft = 2; + Owner.heldProj = Projectile.whoAmI; + Owner.SetDummyItemTime(2); + Owner.itemRotation = Projectile.DirectionFrom(Owner.MountedCenter).ToRotation(); + if (Projectile.Center.X < Owner.MountedCenter.X) + Owner.itemRotation += MathHelper.Pi; + Owner.itemRotation = MathHelper.WrapAngle(Owner.itemRotation); + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + int impactIntensity = 0; + Vector2 velocity = Projectile.velocity; + float bounceFactor = 0.2f; + if (CurrentFlailState == FlailState.LaunchingForward || CurrentFlailState == FlailState.Ricochet) + bounceFactor = 0.4f; + if (CurrentFlailState == FlailState.Dropping) + bounceFactor = 0f; + + if (oldVelocity.X != Projectile.velocity.X) + { + if (Math.Abs(oldVelocity.X) > 4f) + impactIntensity = 1; + + Projectile.velocity.X = oldVelocity.X * -bounceFactor; + CollisionCounter++; + } + + if (oldVelocity.Y != Projectile.velocity.Y) + { + if (Math.Abs(oldVelocity.Y) > 4f) + impactIntensity = 1; + + Projectile.velocity.Y = oldVelocity.Y * -bounceFactor; + CollisionCounter++; + } + + if (CurrentFlailState == FlailState.LaunchingForward) + { + CurrentFlailState = FlailState.Ricochet; + Projectile.localNPCHitCooldown = BaseIFrames * Projectile.MaxUpdates; + Projectile.netUpdate = true; + Point scanAreaStart = Projectile.TopLeft.ToTileCoordinates(); + Point scanAreaEnd = Projectile.BottomRight.ToTileCoordinates(); + impactIntensity = 2; + Projectile.CreateImpactExplosion(2, Projectile.Center, ref scanAreaStart, ref scanAreaEnd, Projectile.width, out bool causedShockwaves); + Projectile.CreateImpactExplosion2_FlailTileCollision(Projectile.Center, causedShockwaves, velocity); + Projectile.position -= velocity; + } + + if (impactIntensity > 0) + { + Projectile.netUpdate = true; + for (int i = 0; i < impactIntensity; i++) + Collision.HitTiles(Projectile.position, velocity, Projectile.width, Projectile.height); + + SoundEngine.PlaySound(SoundID.Dig, Projectile.position); + } + + // Force retraction if stuck on tiles while retracting + if (CurrentFlailState != FlailState.Spinning && CurrentFlailState != FlailState.Ricochet && CurrentFlailState != FlailState.Dropping && CollisionCounter >= 10f) + { + CurrentFlailState = FlailState.ForcedRetracting; + Projectile.netUpdate = true; + } + + return false; + } + + public override bool? CanDamage() + { + if (CurrentFlailState == FlailState.Spinning && StateTimer <= 12f) + return false; + + return base.CanDamage(); + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) { + if (CurrentFlailState == FlailState.Spinning) + { + Vector2 distance = targetHitbox.ClosestPointInRect(Owner.MountedCenter) - Owner.MountedCenter; + distance.Y /= SpinVerticalFactor; + return distance.Length() <= SpinHitboxRadius; + } + // Regular collision logic happens otherwise. + return base.Colliding(projHitbox, targetHitbox); + } + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (CurrentFlailState == FlailState.Spinning) + modifiers.SourceDamage *= SpinDamage; + else if (CurrentFlailState == FlailState.LaunchingForward || CurrentFlailState == FlailState.Retracting) + modifiers.SourceDamage *= LaunchDamage; + + if (CurrentFlailState == FlailState.Spinning) + modifiers.Knockback *= SpinKnockback; + else if (CurrentFlailState == FlailState.Dropping) + modifiers.Knockback *= DropKnockback; + + modifiers.HitDirectionOverride = (Owner.Center.X < target.Center.X).ToDirectionInt(); + } + + public override bool PreDraw(ref Color lightColor) + { + if (!String.IsNullOrEmpty(ChainTexturePath)) + DrawChain(); + + // By default, maces have afterimages when launched. + // This can still be disabled via config or set individually by the projectile. + // (Does not use utils due to set trail length conditions) + if (CurrentFlailState == FlailState.LaunchingForward && CalamityConfig.Instance.Afterimages && AfterimageLength > 0) + { + Texture2D maceTex = TextureAssets.Projectile[Type].Value; + Vector2 drawOrigin = new Vector2(maceTex.Width * 0.5f, maceTex.Height * 0.5f); + SpriteEffects spriteEffects = Projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + for (int k = 0; k < Projectile.oldPos.Length && k < StateTimer; k++) + { + Vector2 drawPos = Projectile.oldPos[k] - Main.screenPosition + drawOrigin + new Vector2(0f, Projectile.gfxOffY); + Color color = Projectile.GetAlpha(lightColor) * ((float)(Projectile.oldPos.Length - k) / (float)Projectile.oldPos.Length); + Main.spriteBatch.Draw(maceTex, drawPos, null, color, Projectile.rotation, drawOrigin, Projectile.scale - k / (float)Projectile.oldPos.Length / 3, spriteEffects, 0f); + } + } + return true; + } + } +} diff --git a/Projectiles/Melee/MaceFlails/YateveoBloomMace.cs b/Projectiles/Melee/MaceFlails/YateveoBloomMace.cs new file mode 100644 index 0000000000..3b78e442ef --- /dev/null +++ b/Projectiles/Melee/MaceFlails/YateveoBloomMace.cs @@ -0,0 +1,44 @@ +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Projectiles.BaseProjectiles; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee.MaceFlails +{ + public class YateveoBloomMace : BaseMaceFlailProjectile + { + public override int AssociatedItemID => ModContent.ItemType(); + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 30; + base.SetDefaults(); + } + + public override void ExtraBehavior() + { + if (Main.rand.NextBool(3)) + { + int dustType = Main.rand.Next(5); + switch (dustType) + { + case 0: + dustType = 2; + break; + case 1: + dustType = 44; + break; + default: + dustType = 136; + break; + } + Dust spore = Dust.NewDustDirect(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, dustType, 0f, 0f); + spore.noGravity = true; + spore.scale = 1.5f; + } + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.Poisoned, 180); + } +} diff --git a/Projectiles/Melee/YateveoBloomProj.png b/Projectiles/Melee/MaceFlails/YateveoBloomMace.png similarity index 100% rename from Projectiles/Melee/YateveoBloomProj.png rename to Projectiles/Melee/MaceFlails/YateveoBloomMace.png diff --git a/Projectiles/Melee/YateveoBloomChain.png b/Projectiles/Melee/MaceFlails/YateveoBloomMaceChain.png similarity index 100% rename from Projectiles/Melee/YateveoBloomChain.png rename to Projectiles/Melee/MaceFlails/YateveoBloomMaceChain.png diff --git a/Projectiles/Melee/YateveoBloomProj.cs b/Projectiles/Melee/YateveoBloomProj.cs deleted file mode 100644 index 1e4dcf6113..0000000000 --- a/Projectiles/Melee/YateveoBloomProj.cs +++ /dev/null @@ -1,224 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Melee -{ - public class YateveoBloomProj : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Melee"; - public override void SetDefaults() - { - Projectile.width = 18; - Projectile.height = 18; - Projectile.friendly = true; - Projectile.penetrate = -1; - Projectile.DamageType = DamageClass.Melee; - Projectile.alpha = 255; - } - - public override void AI() - { - Vector2 projDirection = Main.player[Projectile.owner].MountedCenter - Projectile.Center; - Projectile.rotation = projDirection.ToRotation() - MathHelper.PiOver2; - float distance = projDirection.Length(); - - if (Main.player[Projectile.owner].dead) - { - Projectile.Kill(); - return; - } - - Main.player[Projectile.owner].itemAnimation = 10; - Main.player[Projectile.owner].itemTime = 10; - - if (projDirection.X < 0f) - { - Main.player[Projectile.owner].ChangeDir(1); - Projectile.direction = 1; - } - else - { - Main.player[Projectile.owner].ChangeDir(-1); - Projectile.direction = -1; - } - - if (Projectile.ai[0] == 0f) - { - Projectile.tileCollide = true; - if (distance > 210f) - { - Projectile.ai[0] = 1f; - Projectile.netUpdate = true; - } - else if (!Main.player[Projectile.owner].channel) - { - if (Projectile.velocity.Y < 0f) - Projectile.velocity.Y = Projectile.velocity.Y * 0.9f; - - Projectile.velocity.Y = Projectile.velocity.Y + 1f; - Projectile.velocity.X = Projectile.velocity.X * 0.9f; - } - } - else - { - float meleeSpeedDistance = 14f / Main.player[Projectile.owner].GetAttackSpeed() * 1.25f; - float meleeDamage = 0.9f / Main.player[Projectile.owner].GetAttackSpeed() * 1.25f; - - if (Projectile.ai[1] == 1f) - Projectile.tileCollide = false; - - if (!Main.player[Projectile.owner].channel || distance > 375f || !Projectile.tileCollide) - { - Projectile.ai[1] = 1f; - - if (Projectile.tileCollide) - Projectile.netUpdate = true; - - Projectile.tileCollide = false; - - if (distance < 20f) - Projectile.Kill(); - } - - if (!Projectile.tileCollide) - meleeDamage *= 2f; - - if (distance > 80f || !Projectile.tileCollide) - { - distance = meleeSpeedDistance / distance; - projDirection.X *= distance; - projDirection.Y *= distance; - - float projXDirect = projDirection.X - Projectile.velocity.X; - float projYDirect = projDirection.Y - Projectile.velocity.Y; - float projDistance = (float)Math.Sqrt((double)(projXDirect * projXDirect + projYDirect * projYDirect)); - - projDistance = meleeDamage / projDistance; - projXDirect *= projDistance; - projYDirect *= projDistance; - - Projectile.velocity.X = Projectile.velocity.X * 0.98f; - Projectile.velocity.Y = Projectile.velocity.Y * 0.98f; - Projectile.velocity.X = Projectile.velocity.X + projXDirect; - Projectile.velocity.Y = Projectile.velocity.Y + projYDirect; - } - else - { - if (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y) < 6f) - { - Projectile.velocity.X = Projectile.velocity.X * 0.96f; - Projectile.velocity.Y = Projectile.velocity.Y + 0.2f; - } - - if (Main.player[Projectile.owner].velocity.X == 0f) - Projectile.velocity.X = Projectile.velocity.X * 0.96f; - } - } - - if (Main.rand.NextBool(3)) - { - int dustType = Main.rand.Next(5); - switch (dustType) - { - case 0: - dustType = 2; - break; - case 1: - dustType = 44; - break; - case 2: - case 3: - case 4: - dustType = 136; - break; - default: - break; - } - int dust = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, dustType, 0f, 0f); - Main.dust[dust].noGravity = true; - Main.dust[dust].scale = 1.5f; - } - - if (Projectile.alpha == 255 && distance > 10f) - Projectile.alpha = 0; - } - - public override bool OnTileCollide(Vector2 oldVelocity) - { - bool hitTile = false; - if (oldVelocity.X != Projectile.velocity.X) - { - hitTile = Math.Abs(oldVelocity.X) > 4f; - - Projectile.position.X = Projectile.position.X + Projectile.velocity.X; - Projectile.velocity.X = -oldVelocity.X * 0.2f; - } - if (oldVelocity.Y != Projectile.velocity.Y) - { - hitTile = Math.Abs(oldVelocity.Y) > 4f; - - Projectile.position.Y = Projectile.position.Y + Projectile.velocity.Y; - Projectile.velocity.Y = -oldVelocity.Y * 0.2f; - } - - Projectile.ai[0] = 1f; - - if (hitTile) - { - Projectile.netUpdate = true; - Collision.HitTiles(Projectile.position, Projectile.velocity, Projectile.width, Projectile.height); - SoundEngine.PlaySound(SoundID.Dig, Projectile.position); - } - - return false; - } - - public override bool PreDraw(ref Color lightColor) - { - Vector2 mountedCenter = Main.player[Projectile.owner].MountedCenter; - Texture2D texture2D2 = ModContent.Request("CalamityMod/Projectiles/Melee/YateveoBloomChain").Value; - Vector2 projCenter = Projectile.Center; - Rectangle? sourceRectangle = null; - Vector2 origin = new Vector2((float)texture2D2.Width * 0.5f, (float)texture2D2.Height * 0.5f); - float projHeight = (float)texture2D2.Height; - Vector2 actualCenter = mountedCenter - projCenter; - float projRotation = (float)Math.Atan2((double)actualCenter.Y, (double)actualCenter.X) - MathHelper.PiOver2; - bool isActive = true; - if (float.IsNaN(projCenter.X) && float.IsNaN(projCenter.Y)) - { - isActive = false; - } - if (float.IsNaN(actualCenter.X) && float.IsNaN(actualCenter.Y)) - { - isActive = false; - } - while (isActive) - { - if (actualCenter.Length() < projHeight + 1f) - { - isActive = false; - } - else - { - Vector2 centerCopy = actualCenter; - centerCopy.Normalize(); - projCenter += centerCopy * projHeight; - actualCenter = mountedCenter - projCenter; - Color drawArea = Lighting.GetColor((int)projCenter.X / 16, (int)(projCenter.Y / 16f)); - Main.spriteBatch.Draw(texture2D2, projCenter - Main.screenPosition, sourceRectangle, drawArea, projRotation, origin, 1f, SpriteEffects.None, 0); - } - } - return true; - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(BuffID.Poisoned, 180); - } - } -}