diff --git a/CalamityLists.cs b/CalamityLists.cs index 4f96e19785..cb60d04e4f 100644 --- a/CalamityLists.cs +++ b/CalamityLists.cs @@ -2038,8 +2038,6 @@ namespace CalamityMod ProjectileType(), ProjectileType(), ProjectileType(), - ProjectileType(), - ProjectileType(), ProjectileType(), ProjectileType(), ProjectileType(), diff --git a/Items/Weapons/Melee/BallOFugu.cs b/Items/Weapons/Melee/BallOFugu.cs index 144104fa28..c0d446fcdf 100644 --- a/Items/Weapons/Melee/BallOFugu.cs +++ b/Items/Weapons/Melee/BallOFugu.cs @@ -1,5 +1,6 @@ using CalamityMod.Projectiles.Melee.MaceFlails; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -8,12 +9,15 @@ namespace CalamityMod.Items.Weapons.Melee public class BallOFugu : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Melee"; + + public static readonly SoundStyle BlowSound = new("CalamityMod/Sounds/Item/FuguBlow") { PitchVariance = 0.1f }; + public override void SetStaticDefaults() => ItemID.Sets.ToolTipDamageMultiplier[Type] = 2f; public override void SetDefaults() { Item.width = 30; Item.height = 10; - Item.damage = 40; + Item.damage = 28; Item.DamageType = DamageClass.MeleeNoSpeed; Item.useTime = 20; Item.useAnimation = 20; diff --git a/Items/Weapons/Melee/DragonPow.cs b/Items/Weapons/Melee/DragonPow.cs index 0631ea083b..a5a7a08866 100644 --- a/Items/Weapons/Melee/DragonPow.cs +++ b/Items/Weapons/Melee/DragonPow.cs @@ -53,7 +53,6 @@ namespace CalamityMod.Items.Weapons.Melee AddIngredient(ItemID.Flairon). AddIngredient(). AddIngredient(). - AddIngredient(). AddIngredient(4). AddIngredient(5). AddTile(). diff --git a/Items/Weapons/Melee/UrchinFlail.cs b/Items/Weapons/Melee/UrchinFlail.cs deleted file mode 100644 index 5be6cbaa01..0000000000 --- a/Items/Weapons/Melee/UrchinFlail.cs +++ /dev/null @@ -1,32 +0,0 @@ -using CalamityMod.Projectiles.Melee; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Melee -{ - public class UrchinFlail : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.Melee"; - public override void SetDefaults() - { - Item.width = 44; - Item.height = 36; - Item.damage = 20; - Item.DamageType = DamageClass.MeleeNoSpeed; - Item.useTime = 25; - Item.useAnimation = 25; - Item.useStyle = ItemUseStyleID.Shoot; - Item.noMelee = true; - Item.noUseGraphic = true; - Item.knockBack = 6f; - Item.value = CalamityGlobalItem.RarityGreenBuyPrice; - Item.rare = ItemRarityID.Green; - Item.UseSound = SoundID.Item1; - Item.autoReuse = true; - Item.channel = true; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 16f; - } - } -} diff --git a/Items/Weapons/Melee/UrchinFlail.png b/Items/Weapons/Melee/UrchinFlail.png deleted file mode 100644 index 3079ad4adb..0000000000 Binary files a/Items/Weapons/Melee/UrchinFlail.png and /dev/null differ diff --git a/Items/Weapons/Melee/UrchinMace.cs b/Items/Weapons/Melee/UrchinMace.cs index abea666477..9947723237 100644 --- a/Items/Weapons/Melee/UrchinMace.cs +++ b/Items/Weapons/Melee/UrchinMace.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - [LegacyName("RedtideSword")] + [LegacyName("RedtideSword", "UrchinFlail")] public class UrchinMace : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Melee"; diff --git a/Items/Weapons/Melee/YateveoBloom.cs b/Items/Weapons/Melee/YateveoBloom.cs index 5984d94db1..4254bd8158 100644 --- a/Items/Weapons/Melee/YateveoBloom.cs +++ b/Items/Weapons/Melee/YateveoBloom.cs @@ -17,13 +17,14 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetStaticDefaults() { ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; + // Flail already does half damage. No tooltip mutliplier required. } public override void SetDefaults() { Item.width = 42; Item.height = 62; - Item.damage = 30; // Spear is 20 damage, Flail is 30 damage + Item.damage = 30; Item.knockBack = 5f; Item.useAnimation = Item.useTime = 22; @@ -75,7 +76,7 @@ namespace CalamityMod.Items.Weapons.Melee { float speedMult = SpearSpeed / ShootSpeed; if (player.altFunctionUse == 2) - Projectile.NewProjectile(source, position, velocity * speedMult, ModContent.ProjectileType(), (int)(damage * 0.666666f), knockback, player.whoAmI); + Projectile.NewProjectile(source, position, velocity * speedMult, ModContent.ProjectileType(), damage, knockback, player.whoAmI); else 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 d4edd80eb7..febeb20165 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson @@ -288,8 +288,6 @@ TruePurityProjection.DisplayName: Purity Projection TumbleweedRolling.DisplayName: Rolling Tumbleweed TyphonsGreedBubble.DisplayName: Typhon's Greed UltimusCleaverDust.DisplayName: Ultimus Flame -UrchinBall.DisplayName: Urchin Ball -UrchinBallSpike.DisplayName: Urchin Ball Spike UrchinMaceProjectile.DisplayName: Urchin Mace UrchinSpikeFugu.DisplayName: Urchin Spike VirulentBeeWave.DisplayName: Virulent Bee Wave diff --git a/NPCs/TownNPCs/SEAHOE.cs b/NPCs/TownNPCs/SEAHOE.cs index b455f13eb2..e8acfc2086 100644 --- a/NPCs/TownNPCs/SEAHOE.cs +++ b/NPCs/TownNPCs/SEAHOE.cs @@ -206,7 +206,6 @@ namespace CalamityMod.NPCs.TownNPCs .Add(ModContent.ItemType()) .Add(ModContent.ItemType()) .Add(ModContent.ItemType()) - .Add(ModContent.ItemType()) .Add(ModContent.ItemType()) .Add(ModContent.ItemType()) .Add(ModContent.ItemType()) diff --git a/Projectiles/BaseProjectiles/BaseMaceFlailProjectile.cs b/Projectiles/BaseProjectiles/BaseMaceFlailProjectile.cs index ee11da6960..b3386edb79 100644 --- a/Projectiles/BaseProjectiles/BaseMaceFlailProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseMaceFlailProjectile.cs @@ -15,8 +15,32 @@ namespace CalamityMod.Projectiles.BaseProjectiles public abstract class BaseMaceFlailProjectile : ModProjectile { public abstract int AssociatedItemID { get; } - public override LocalizedText DisplayName => CalamityUtils.GetItemName(AssociatedItemID); + // The following can also be used in each individual projectile class, without the need to re-define: + #region Utilities + public enum FlailState + { + Spinning = 0, + LaunchingForward = 1, + Retracting = 2, + ForcedRetracting = 4, + Ricochet = 5, + Dropping = 6 + } + + 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]; + // ai[2] and localAI[1] are completely open for additional gimmicks. + + public Player Owner => Main.player[Projectile.owner]; + #endregion + + // Core properties of the mace's function. #region Properties /// /// Local immunity frames granted while dropped or retracted
@@ -103,15 +127,15 @@ namespace CalamityMod.Projectiles.BaseProjectiles /// /// Max speed when retracted, affected by attack speed.
- /// Defaults to 14f. + /// Defaults to 15f. ///
- public virtual float MaxRetractSpeed { get; set; } = 14f; + public virtual float MaxRetractSpeed { get; set; } = 15f; /// /// Acceleration when retracted, affected by attack speed.
- /// Defaults to 2f. + /// Defaults to 2.5f. ///
- public virtual float RetractAcceleration { get; set; } = 2f; + public virtual float RetractAcceleration { get; set; } = 2.5f; #endregion // Most of these should be kept default for consistency with vanilla maces. @@ -149,6 +173,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles public virtual float DropKnockback => 0.5f; #endregion + // Methods for most individual behaviour steps which can be useful to override. #region Overridable Methods /// /// Scales every value that should be affected by melee speed.
@@ -162,6 +187,25 @@ namespace CalamityMod.Projectiles.BaseProjectiles acceleration *= meleeSpeedMultiplier; } + /// + /// Calculates the damage and knockback multiplier based on the current behaviour.
+ /// Can be overridden to include any extra stat adjustments. + ///
+ public virtual void UpdateDamageKB(out float damageMult, out float kbMult) + { + damageMult = 1f; + kbMult = 1f; + if (CurrentFlailState == FlailState.Spinning) + { + damageMult = SpinDamage; + kbMult = SpinKnockback; + } + else if (CurrentFlailState == FlailState.LaunchingForward || CurrentFlailState == FlailState.Retracting) + damageMult = LaunchDamage; + else if (CurrentFlailState == FlailState.Dropping) + kbMult = DropKnockback; + } + public virtual void SpinAI(float launchSpeed) { Projectile.ownerHitCheck = true; @@ -318,26 +362,8 @@ namespace CalamityMod.Projectiles.BaseProjectiles } #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]; + #region Hook Overrides + public override LocalizedText DisplayName => CalamityUtils.GetItemName(AssociatedItemID); public override void SetStaticDefaults() { @@ -504,15 +530,9 @@ namespace CalamityMod.Projectiles.BaseProjectiles 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; + UpdateDamageKB(out float damageMult, out float kbMult); + modifiers.SourceDamage *= damageMult; + modifiers.Knockback *= kbMult; modifiers.HitDirectionOverride = (Owner.Center.X < target.Center.X).ToDirectionInt(); } @@ -539,5 +559,6 @@ namespace CalamityMod.Projectiles.BaseProjectiles } return true; } + #endregion } } diff --git a/Projectiles/Melee/MaceFlails/BallOFuguProj.cs b/Projectiles/Melee/MaceFlails/BallOFuguProj.cs index 14242591fc..32e490f6d3 100644 --- a/Projectiles/Melee/MaceFlails/BallOFuguProj.cs +++ b/Projectiles/Melee/MaceFlails/BallOFuguProj.cs @@ -14,8 +14,13 @@ namespace CalamityMod.Projectiles.Melee.MaceFlails public class BallOFuguProj : BaseMaceFlailProjectile { public override int AssociatedItemID => ModContent.ItemType(); - public override int LaunchLifespan => 25; + public override float SpinHitboxRadius => 66f; + public override float SpinVisualRadius => 36f; + public override float LaunchSpeed => 20f; + public override int LaunchLifespan => 20; public override float MaxDropRange => 640f; + public override float MaxRetractSpeed => 24f; + public override float RetractAcceleration => 3.6f; public static float MaxSpikeTime = 180f; public static float SpikeRate = 10f; @@ -39,7 +44,7 @@ namespace CalamityMod.Projectiles.Melee.MaceFlails if (Projectile.owner == Main.myPlayer && SpikeTimer > MaxSpikeTime && SpikeTimer % SpikeRate == 0f) { Vector2 velocity = Projectile.DirectionFrom(Owner.MountedCenter).SafeNormalize(Vector2.Zero).RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(4.5f, 6.5f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * SpikeDamage), Projectile.knockBack * SpikeKnockback, Projectile.owner, -10f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * SpikeDamage), Projectile.knockBack * SpikeKnockback, Projectile.owner); } base.SpinAI(launchSpeed); } @@ -49,9 +54,13 @@ namespace CalamityMod.Projectiles.Melee.MaceFlails int SpikeCount = (int)(MathHelper.Clamp(SpikeTimer, 0f, MaxSpikeTime) / SpikeRate); for (int i = 0; i < SpikeCount; i++) { - Vector2 velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(3.5f, 5f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * SpikeDamage), Projectile.knockBack * SpikeKnockback, Projectile.owner, -10f); + Vector2 velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(6f, 7.2f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * SpikeDamage), Projectile.knockBack * SpikeKnockback, Projectile.owner); } + + if (SpikeCount > 0) + SoundEngine.PlaySound(BallOFugu.BlowSound, Projectile.Center); + SpikeTimer = 0f; Projectile.netUpdate = true; }; diff --git a/Projectiles/Melee/MaceFlails/RemsRevengeProj.cs b/Projectiles/Melee/MaceFlails/RemsRevengeProj.cs index 8afd0f1b40..224fd4eb9d 100644 --- a/Projectiles/Melee/MaceFlails/RemsRevengeProj.cs +++ b/Projectiles/Melee/MaceFlails/RemsRevengeProj.cs @@ -12,12 +12,15 @@ namespace CalamityMod.Projectiles.Melee.MaceFlails public class RemsRevengeProj : BaseMaceFlailProjectile { public override int AssociatedItemID => ModContent.ItemType(); - public override float SpinHitboxRadius => 80f; - public override float SpinVisualRadius => 48f; - public override float LaunchSpeed => 24f; - public override int LaunchLifespan => 30; + public override int SpinIFrames => 12; + public override float SpinSpeed => 16f; + public override float SpinHitboxRadius => 96f; + public override float SpinVisualRadius => 64f; + public override int AfterimageLength => 8; + public override float LaunchSpeed => 30f; + public override int LaunchLifespan => 24; public override float MaxDropRange => 960f; - public override float MaxRetractSpeed => 27f; + public override float MaxRetractSpeed => 36f; public override float RetractAcceleration => 4.5f; public ref float LaunchedHitCounter => ref Projectile.ai[2]; @@ -32,12 +35,14 @@ namespace CalamityMod.Projectiles.Melee.MaceFlails { target.AddBuff(ModContent.BuffType(), 240); - if (CurrentFlailState != FlailState.Spinning) + if (CurrentFlailState != FlailState.Spinning && CurrentFlailState != FlailState.Dropping) LaunchedHitCounter++; - if (LaunchedHitCounter < 6f) - Projectile.NewProjectile(Projectile.GetSource_FromThis(), target.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); - if (LaunchedHitCounter > 3f) + // While spinning, the projectile center won't always be where the target is, so it needs to be moved + UpdateDamageKB(out float damageMult, out float kbMult); + if (LaunchedHitCounter <= 5f) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), CurrentFlailState == FlailState.Spinning ? target.Center : Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * damageMult), Projectile.knockBack * kbMult, Projectile.owner); + if (LaunchedHitCounter >= 4f) { CurrentFlailState = FlailState.ForcedRetracting; StateTimer = 0f; diff --git a/Projectiles/Melee/MaceFlails/TumbleweedFlail.cs b/Projectiles/Melee/MaceFlails/TumbleweedFlail.cs index 8cc9d14831..e6317b1c15 100644 --- a/Projectiles/Melee/MaceFlails/TumbleweedFlail.cs +++ b/Projectiles/Melee/MaceFlails/TumbleweedFlail.cs @@ -19,14 +19,14 @@ namespace CalamityMod.Projectiles.Melee.MaceFlails { public override int AssociatedItemID => ModContent.ItemType(); public override int SpinIFrames => 10; - public override float SpinHitboxRadius => 70f + 160f * AuraScale; + public override float SpinHitboxRadius => MathF.Max(64f, 224f * AuraScale); public override float SpinVerticalFactor => 1f; // The aura is fully circular, rather than elliptical public override float SpinVisualRadius => 45f; - public override float LaunchSpeed => 20f; + public override float LaunchSpeed => 24f; public override int LaunchLifespan => 20; public override float MaxDropRange => 640f; - public override float MaxRetractSpeed => 24f; - public override float RetractAcceleration => 3.6f; + public override float MaxRetractSpeed => 28f; + public override float RetractAcceleration => 4f; public static float MaxAuraTime = 60f; @@ -40,6 +40,13 @@ namespace CalamityMod.Projectiles.Melee.MaceFlails public override void ExtraBehavior() { + if (CurrentFlailState != FlailState.Spinning || Main.rand.NextBool()) + { + Dust sand = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.Sand, Alpha: 100, Scale: Main.rand.NextFloat(0.6f, 1.2f)); + sand.noGravity = CurrentFlailState == FlailState.Dropping; + sand.velocity = CurrentFlailState == FlailState.Spinning ? Main.rand.NextVector2Unit() * 1.5f : Projectile.velocity * 0.25f; + } + if (CurrentFlailState == FlailState.Spinning) { Projectile.ownerHitCheck = false; // Dust aura can hit through walls @@ -83,7 +90,7 @@ namespace CalamityMod.Projectiles.Melee.MaceFlails public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - if (CurrentFlailState != FlailState.LaunchingForward && CurrentFlailState != FlailState.Dropping && CurrentFlailState != FlailState.Ricochet) + if (CurrentFlailState == FlailState.Spinning) return; SoundEngine.PlaySound(SoundID.NPCDeath15, Projectile.Center); diff --git a/Projectiles/Melee/TumbleweedRolling.cs b/Projectiles/Melee/TumbleweedRolling.cs index a988583342..e73c217f69 100644 --- a/Projectiles/Melee/TumbleweedRolling.cs +++ b/Projectiles/Melee/TumbleweedRolling.cs @@ -10,8 +10,8 @@ namespace CalamityMod.Projectiles.Melee public new string LocalizationCategory => "Projectiles.Melee"; public override string Texture => "CalamityMod/Projectiles/Melee/MaceFlails/TumbleweedFlail"; - public static int Lifetime = 180; - public static int Rolltime = 45; // How long it remains gravity-defiant if it doesn't hit tiles + public static int Lifetime = 120; + public static int Rolltime = 30; // How long it remains gravity-defiant if it doesn't hit tiles public ref float RollState => ref Projectile.ai[0]; // 1f: falling @@ -19,11 +19,11 @@ namespace CalamityMod.Projectiles.Melee { Projectile.width = Projectile.height = 42; Projectile.friendly = true; - Projectile.penetrate = 8; + Projectile.penetrate = 6; Projectile.timeLeft = Lifetime; Projectile.DamageType = DamageClass.MeleeNoSpeed; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 20; + Projectile.localNPCHitCooldown = 15; } public override void AI() diff --git a/Projectiles/Melee/UrchinBall.cs b/Projectiles/Melee/UrchinBall.cs deleted file mode 100644 index 439efbe746..0000000000 --- a/Projectiles/Melee/UrchinBall.cs +++ /dev/null @@ -1,150 +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 UrchinBall : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Melee"; - public bool spike = false; - - public override void SetDefaults() - { - Projectile.width = 34; - Projectile.height = 34; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.penetrate = -1; - Projectile.DamageType = DamageClass.MeleeNoSpeed; - Projectile.alpha = 255; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 3; - } - - public override void AI() - { - Player player = Main.player[Projectile.owner]; - Vector2 projDirection = player.Center - Projectile.Center; - Projectile.rotation = projDirection.ToRotation() - MathHelper.PiOver2; - if (player.dead) - { - Projectile.Kill(); - return; - } - player.itemAnimation = 10; - player.itemTime = 10; - if (projDirection.X < 0f) - { - player.ChangeDir(1); - Projectile.direction = 1; - } - else - { - player.ChangeDir(-1); - Projectile.direction = -1; - } - player.itemRotation = (projDirection * -1f * (float)Projectile.direction).ToRotation(); - Projectile.spriteDirection = (projDirection.X > 0f) ? -1 : 1; - if (Projectile.ai[0] == 0f && projDirection.Length() > 400f) - { - Projectile.ai[0] = 1f; - } - if (Projectile.ai[0] == 1f || Projectile.ai[0] == 2f) - { - if (spike) - { - spike = false; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, Projectile.velocity.X, Projectile.velocity.Y, ModContent.ProjectileType(), (int)((double)Projectile.damage * 0.5), 0f, Main.myPlayer, 0f, 0f); - } - Projectile.usesLocalNPCImmunity = false; - float projDistance = projDirection.Length(); - if (projDistance > 1500f) - { - Projectile.Kill(); - return; - } - if (projDistance > 600f) - { - Projectile.ai[0] = 2f; - } - Projectile.tileCollide = false; - float returnLength = 20f; - if (Projectile.ai[0] == 2f) - { - returnLength = 40f; - } - Projectile.velocity = Vector2.Normalize(projDirection) * returnLength; - if (projDirection.Length() < returnLength) - { - Projectile.Kill(); - return; - } - } - Projectile.ai[1] += 1f; - if (Projectile.ai[1] > 5f) - { - Projectile.alpha = 0; - } - } - - public override bool OnTileCollide(Vector2 oldVelocity) - { - Collision.HitTiles(Projectile.position, Projectile.velocity, Projectile.width, Projectile.height); - Projectile.ai[0] = 1f; - Projectile.netUpdate = true; - 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/UrchinFlailChain").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) - { - spike = true; - Projectile.ai[0] = 1f; - Projectile.netUpdate = true; - target.AddBuff(BuffID.Poisoned, 180); - } - } -} diff --git a/Projectiles/Melee/UrchinBall.png b/Projectiles/Melee/UrchinBall.png deleted file mode 100644 index 58eb311c75..0000000000 Binary files a/Projectiles/Melee/UrchinBall.png and /dev/null differ diff --git a/Projectiles/Melee/UrchinBallSpike.cs b/Projectiles/Melee/UrchinBallSpike.cs deleted file mode 100644 index 43487f17d5..0000000000 --- a/Projectiles/Melee/UrchinBallSpike.cs +++ /dev/null @@ -1,70 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Melee -{ - public class UrchinBallSpike : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Melee"; - public override void SetDefaults() - { - Projectile.width = 6; - Projectile.height = 6; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.DamageType = DamageClass.MeleeNoSpeed; - Projectile.penetrate = -1; - AIType = ProjectileID.BoneJavelin; - } - - public override void AI() - { - if (Projectile.ai[0] == 0f) - { - Projectile.velocity.X = Projectile.velocity.X * 0.99f; - Projectile.velocity.Y = Projectile.velocity.Y + 0.15f; - Projectile.rotation += 0.4f * (float)Projectile.direction; - Projectile.spriteDirection = Projectile.direction; - } - //Sticky Behaviour - Projectile.StickyProjAI(6); - } - - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => Projectile.ModifyHitNPCSticky(6); - public override bool? CanDamage() => Projectile.ai[0] == 1f ? false : base.CanDamage(); - - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) - { - if (targetHitbox.Width > 8 && targetHitbox.Height > 8) - { - targetHitbox.Inflate(-targetHitbox.Width / 8, -targetHitbox.Height / 8); - } - return null; - } - - public override void OnKill(int timeLeft) - { - SoundEngine.PlaySound(SoundID.Item10, Projectile.position); - Projectile.position.X = Projectile.position.X + (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y + (float)(Projectile.height / 2); - Projectile.width = 13; - Projectile.height = 20; - Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int i = 0; i < 20; i++) - { - int urchin = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Demonite, 0f, 0f, 0, new Color(0, 255, 255), 1f); - Main.dust[urchin].noGravity = true; - Main.dust[urchin].velocity *= 2f; - } - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(BuffID.Poisoned, 120); - } - } -} diff --git a/Projectiles/Melee/UrchinBallSpike.png b/Projectiles/Melee/UrchinBallSpike.png deleted file mode 100644 index 9828a05673..0000000000 Binary files a/Projectiles/Melee/UrchinBallSpike.png and /dev/null differ diff --git a/Projectiles/Melee/UrchinFlailChain.png b/Projectiles/Melee/UrchinFlailChain.png deleted file mode 100644 index 34510cfce7..0000000000 Binary files a/Projectiles/Melee/UrchinFlailChain.png and /dev/null differ diff --git a/Projectiles/Melee/UrchinSpikeFugu.cs b/Projectiles/Melee/UrchinSpikeFugu.cs index 23b56ceb7d..667a5789f9 100644 --- a/Projectiles/Melee/UrchinSpikeFugu.cs +++ b/Projectiles/Melee/UrchinSpikeFugu.cs @@ -1,6 +1,9 @@ -using System; +using CalamityMod.Graphics.Primitives; +using System; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +12,15 @@ namespace CalamityMod.Projectiles.Melee public class UrchinSpikeFugu : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; + + public ref float Time => ref Projectile.ai[0]; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 8; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + } + public override void SetDefaults() { Projectile.width = Projectile.height = 6; @@ -23,50 +35,30 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - // Lionfish: ai[1] is 1 (unused) - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - if (Projectile.ai[0] == 0f) - { - float maxRange = 256f; - int npcIndex = -1; - foreach (NPC npc in Main.ActiveNPCs) - { - if (npc.CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) - { - float targetDist = (npc.Center - Projectile.Center).Length(); - if (targetDist < maxRange) - { - npcIndex = npc.whoAmI; - maxRange = targetDist; - } - } - } - Projectile.ai[0] = (float)(npcIndex + 1); - if (Projectile.ai[0] == 0f) - { - Projectile.ai[0] = -15f; - } - if (Projectile.ai[0] > 0f) - { - Projectile.velocity = (Projectile.velocity * 20f + Projectile.SafeDirectionTo(Main.npc[(int)Projectile.ai[0] - 1].Center) * 4f) / 21f; - Projectile.netUpdate = true; - } - } - else if (Projectile.ai[0] > 0f) - Projectile.velocity = (Projectile.velocity * 40f + Projectile.SafeDirectionTo(Main.npc[(int)Projectile.ai[0] - 1].Center) * 12f) / 41f; - else - { - Projectile.ai[0]++; - Projectile.alpha -= 25; - if (Projectile.alpha < 0) - Projectile.alpha = 0; + Time++; + Projectile.rotation = Projectile.velocity.ToRotation(); + Projectile.alpha = (int)Utils.Remap(Time, 0f, 12f, 255f, 0f); - Projectile.velocity.Y += 0.015f; + NPC potentialTarget = Projectile.Center.ClosestNPCAt(256f); + if (potentialTarget != null && Time >= 12f) + { + Vector2 idealVelocity = Projectile.SafeDirectionTo(potentialTarget.Center) * 12f; + Projectile.velocity = (Projectile.velocity * 20f + idealVelocity) / 21f; + Projectile.velocity = Projectile.velocity.MoveTowards(idealVelocity, 2f); } } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.Poisoned, 120); - public override bool? CanDamage() => Projectile.ai[0] < 0f ? false : base.CanDamage(); + public override bool? CanDamage() => Time < 12f ? false : base.CanDamage(); + + internal float WidthFunction(float completionRatio) => (1f - completionRatio) * Projectile.scale * 4f; + internal Color ColorFunction(float completionRatio) => new Color(91, 62, 153) * Projectile.Opacity; + public override bool PreDraw(ref Color lightColor) + { + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/FabstaffStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 8); + return true; + } } } diff --git a/Projectiles/Melee/UrchinSpikeFugu.png b/Projectiles/Melee/UrchinSpikeFugu.png index 0d8e8c9ebf..477129b581 100644 Binary files a/Projectiles/Melee/UrchinSpikeFugu.png and b/Projectiles/Melee/UrchinSpikeFugu.png differ diff --git a/Projectiles/Rogue/LionfishProj.cs b/Projectiles/Rogue/LionfishProj.cs index d83ea2dff3..33fe5a4944 100644 --- a/Projectiles/Rogue/LionfishProj.cs +++ b/Projectiles/Rogue/LionfishProj.cs @@ -55,7 +55,7 @@ namespace CalamityMod.Projectiles.Rogue Vector2 velocity = Projectile.DirectionFrom(Main.player[Projectile.owner].Center); velocity *= Main.rand.NextFloat(4.5f, 6.5f); velocity = velocity.RotatedBy((Main.rand.NextDouble() - 0.5) * Math.PI * 0.5, default); - int spike = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5), Projectile.knockBack * 0.5f, Projectile.owner, -10f, 1f); + int spike = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5), Projectile.knockBack * 0.5f, Projectile.owner); if (spike.WithinBounds(Main.maxProjectiles)) Main.projectile[spike].DamageType = RogueDamageClass.Instance; } diff --git a/Sounds/Item/FuguBlow.ogg b/Sounds/Item/FuguBlow.ogg new file mode 100644 index 0000000000..0742c84e48 Binary files /dev/null and b/Sounds/Item/FuguBlow.ogg differ