diff --git a/Items/CalamityGlobalItemTweaks.cs b/Items/CalamityGlobalItemTweaks.cs index 69b8920325..16c69db0be 100644 --- a/Items/CalamityGlobalItemTweaks.cs +++ b/Items/CalamityGlobalItemTweaks.cs @@ -121,7 +121,7 @@ namespace CalamityMod.Items { ItemID.Gradient, Do(AutoReuse, DamageExact(39)) }, { ItemID.GreenPhaseblade, Do(AutoReuse, UseTurn, DamageExact(32)) }, { ItemID.GreenPhasesaber, Do(DamageExact(60)) }, - { ItemID.GrenadeLauncher, Do(DamageExact(90)) }, + { ItemID.GrenadeLauncher, Do(DamageExact(112)) }, { ItemID.Gungnir, Do(AutoReuse, TrueMelee, UseRatio(0.8f), DamageExact(92), ShootSpeedRatio(1.25f)) }, { ItemID.HallowedRepeater, Do(PointBlank, UseExact(12)) }, { ItemID.Handgun, Do(PointBlank, UseExact(22), DamageExact(36)) }, @@ -206,7 +206,8 @@ namespace CalamityMod.Items { ItemID.RedPhaseblade, Do(AutoReuse, UseTurn, DamageExact(32)) }, { ItemID.RedPhasesaber, Do(DamageExact(60)) }, { ItemID.RedRyder, Do(PointBlank, DamageExact(24)) }, - { ItemID.RedsYoyo, Do(AutoReuse, DamageExact(48)) }, // Red's throw and valkyrie's yoyo are the same weapon + { ItemID.RedsYoyo, Do(AutoReuse, DamageExact(48)) }, // Red's Throw and Valkyrie Yoyo have the same stats + { ItemID.RocketLauncher, Do(DamageExact(70)) }, { ItemID.Sandgun, Do(PointBlank, DamageExact(22), UseExact(20)) }, { ItemID.SapphireStaff, Do(DamageExact(25)) }, { ItemID.SDMG, Do(PointBlank, DamageExact(80)) }, @@ -263,7 +264,7 @@ namespace CalamityMod.Items { ItemID.UnholyArrow, Do(DamageExact(11)) }, { ItemID.UnholyTrident, Do(ManaRatio(0.78f), DamageRatio(0.91f)) }, // Uses ratios due to remix seed { ItemID.VampireKnives, Do(DamageExact(38)) }, - { ItemID.ValkyrieYoyo, Do(AutoReuse, DamageExact(48)) }, // Red's Throw and Valkyrie Yoyo are the same weapon basically + { ItemID.ValkyrieYoyo, Do(AutoReuse, DamageExact(48)) }, // Red's Throw and Valkyrie Yoyo have the same stats { ItemID.VenomStaff, Do(DamageExact(55)) }, { ItemID.WaspGun, Do(UseExact(11), DamageExact(58)) }, { ItemID.WaterBolt, Do(DamageExact(23)) }, diff --git a/Items/Weapons/Ranged/TheHive.cs b/Items/Weapons/Ranged/TheHive.cs index 081c1b9961..3a753245b7 100644 --- a/Items/Weapons/Ranged/TheHive.cs +++ b/Items/Weapons/Ranged/TheHive.cs @@ -1,52 +1,63 @@ using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Weapons.Ranged { public class TheHive : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public static int OriginalUseTime = 34; + public override void SetDefaults() { - Item.width = 62; - Item.height = 30; - Item.damage = 60; + Item.damage = 323; Item.DamageType = DamageClass.Ranged; - Item.useTime = 34; - Item.useAnimation = 34; - Item.useStyle = ItemUseStyleID.Shoot; - Item.noMelee = true; + Item.useTime = Item.useAnimation = OriginalUseTime; + Item.shoot = ProjectileType(); + Item.shootSpeed = 13f; Item.knockBack = 3.5f; + + Item.width = 66; + Item.height = 30; + Item.noMelee = true; + Item.autoReuse = true; + Item.channel = true; + Item.noUseGraphic = true; + Item.useAmmo = AmmoID.Rocket; Item.value = CalamityGlobalItem.Rarity8BuyPrice; Item.rare = ItemRarityID.Yellow; - Item.UseSound = SoundID.Item61; - Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 13f; - Item.useAmmo = AmmoID.Rocket; + Item.useStyle = ItemUseStyleID.Shoot; + Item.UseSound = new SoundStyle("CalamityMod/Sounds/Item/DudFire") with { Volume = .4f, Pitch = -.9f, PitchVariance = 0.1f }; } - public override Vector2? HoldoutOffset() => new Vector2(-10, 0); + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] == 0; - // Figure out which rocket is used - public int RocketType; - public override void OnConsumeAmmo(Item ammo, Player player) => RocketType = ammo.type; + // Spawning the holdout won't consume ammo. + public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] != 0; + + // Makes the rotation of the mouse around the player sync in multiplayer. + public override void HoldItem(Player player) => player.Calamity().mouseRotationListener = true; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - int rocket = Utils.SelectRandom(Main.rand, new int[] - { - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType() - }); - Projectile.NewProjectile(source, position, velocity, rocket, damage, knockback, player.whoAmI, RocketType); + Item.channel = true; + + Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, ProjectileType(), 0, 0f, player.whoAmI); + + // We set the rotation to the direction to the mouse so the first frame doesn't appear bugged out. + holdout.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero); + return false; } + + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) => Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, Request(Texture + "_Glow").Value); } } diff --git a/Items/Weapons/Ranged/TheHive_Glow.png b/Items/Weapons/Ranged/TheHive_Glow.png new file mode 100644 index 0000000000..a1b2898a18 Binary files /dev/null and b/Items/Weapons/Ranged/TheHive_Glow.png differ diff --git a/Items/Weapons/Rogue/Lionfish.cs b/Items/Weapons/Rogue/Lionfish.cs index 80a966dd0f..7ef415c25b 100644 --- a/Items/Weapons/Rogue/Lionfish.cs +++ b/Items/Weapons/Rogue/Lionfish.cs @@ -1,4 +1,6 @@ -using CalamityMod.Projectiles.Rogue; +using CalamityMod.Projectiles.Melee; +using System; +using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -16,9 +18,8 @@ namespace CalamityMod.Items.Weapons.Rogue Item.damage = 45; Item.noMelee = true; Item.noUseGraphic = true; - Item.useAnimation = 22; + Item.useTime = Item.useAnimation = 26; Item.useStyle = ItemUseStyleID.Swing; - Item.useTime = 22; Item.knockBack = 2.5f; Item.UseSound = SoundID.Item1; Item.autoReuse = true; @@ -36,6 +37,16 @@ namespace CalamityMod.Items.Weapons.Rogue int stealth = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); if (stealth.WithinBounds(Main.maxProjectiles)) Main.projectile[stealth].Calamity().stealthStrike = true; + + for (int s = 0; s < 5; s++) + { + Vector2 spikeVel = velocity; + spikeVel *= Main.rand.NextFloat(0.85f, 1.25f); + spikeVel = spikeVel.RotatedBy((Main.rand.NextDouble() - 0.5) * Math.PI * 0.25, default); + int spike = Projectile.NewProjectile(source, position, spikeVel, ModContent.ProjectileType(), (int)(damage * 0.5), (int)(knockback * 0.5f), player.whoAmI, -10f, 1f); + if (spike.WithinBounds(Main.maxProjectiles)) + Main.projectile[spike].DamageType = RogueDamageClass.Instance; + } return false; } return true; diff --git a/Localization/en-US/Mods.CalamityMod.Items.Lore.hjson b/Localization/en-US/Mods.CalamityMod.Items.Lore.hjson index b08c49fe33..2d9a09244e 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Lore.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Lore.hjson @@ -371,9 +371,9 @@ LoreHiveMind: { Lore: ''' Some semblance of a God's mind may survive death, much like the twitches of a crushed insect. - What little remains attempts to convene and coalesce in worship. A desperate attempt that it's power may yet be restored. How pitiful. + What little remains attempts to convene and coalesce in worship. A desperate attempt that its power may yet be restored. How pitiful. Fortunately for us, the futility of this effort is unmatched. The biomass obeys; even though nothing is accomplished. - Far from all divine power flows from faith. A god is forged of its own strength, followers then may choose to worship them. + Divine power is known to be rooted in faith. Gods are forged of their own strength, and the mindless spread of corruption is its own foul reverence. ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson index 033846402b..6755615873 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson @@ -1250,8 +1250,9 @@ TheHive: { DisplayName: The Hive Tooltip: ''' - Launches a variety of rockets that explode into friendly bees - Rockets will destroy tiles with tile-destroying ammo + Launches a wide spread of 4 missiles that explode on contact with enemies and tiles + Charging the launcher decreases the spread and increases the velocity of the missile barrage + Fully charging the launcher will cause it to fire a nuke to decimate a massive area on impact ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson index 5163c929cd..db32cfeb93 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson @@ -100,6 +100,7 @@ HeavenlyGaleProj.DisplayName: Heavenly Gale HighExplosivePeanutShell.DisplayName: High Explosive Peanut Shell HiveBomb.DisplayName: Hive Bomb HiveMissile.DisplayName: Hive Missile +HiveNuke.DisplayName: Hive Nuke HolyFireBulletProj.DisplayName: Holy Fire Bullet HydraHead.DisplayName: Hydra Head HydraHeadLaunch.DisplayName: Hydra Head diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson index 36f1b3817c..af9c3b5969 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson @@ -133,3 +133,4 @@ YanmeisKnifeSlash.DisplayName: Yanmei's Knife YellowLabSeeker.DisplayName: Seeking Mechanism AscendantAura.DisplayName: Ascendant Aura CosmicDashExplosion.DisplayName: Cosmic Dash Explosion +BasicPlagueBee.DisplayName: Basic Plague Bee diff --git a/Particles/CustomPulse.cs b/Particles/CustomPulse.cs new file mode 100644 index 0000000000..a3072597f7 --- /dev/null +++ b/Particles/CustomPulse.cs @@ -0,0 +1,59 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; +using static CalamityMod.CalamityUtils; + +namespace CalamityMod.Particles +{ + public class CustomPulse : Particle + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public bool UseAltVisual = true; + public override bool UseAdditiveBlend => UseAltVisual; + public override bool SetLifetime => true; + public override bool UseCustomDraw => true; + + private string NewTexture; + private float OriginalScale; + private float FinalScale; + private float opacity; + private Vector2 Squish; + private Color BaseColor; + + public CustomPulse(Vector2 position, Vector2 velocity, Color color, string texture, Vector2 squish, float rotation, float originalScale, float finalScale, int lifeTime, bool UseAdditiveBlend = true) + { + Position = position; + Velocity = velocity; + BaseColor = color; + NewTexture = texture; + OriginalScale = originalScale; + FinalScale = finalScale; + Scale = originalScale; + Lifetime = lifeTime; + Squish = squish; + Rotation = rotation; + UseAltVisual = UseAdditiveBlend; + } + + public override void Update() + { + float pulseProgress = PiecewiseAnimation(LifetimeCompletion, new CurveSegment[] { new CurveSegment(EasingType.PolyOut, 0f, 0f, 1f, 4) }); + Scale = MathHelper.Lerp(OriginalScale, FinalScale, pulseProgress); + + opacity = (float)Math.Sin(MathHelper.PiOver2 + LifetimeCompletion * MathHelper.PiOver2); + + Color = BaseColor * opacity; + Lighting.AddLight(Position, Color.R / 255f, Color.G / 255f, Color.B / 255f); + Velocity *= 0.95f; + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + Texture2D tex = ModContent.Request(NewTexture).Value; + spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color * opacity, Rotation, tex.Size() / 2f, Scale * Squish, SpriteEffects.None, 0); + } + + } +} diff --git a/Particles/DustyCircleHardEdge.png b/Particles/DustyCircleHardEdge.png new file mode 100644 index 0000000000..77d79d4071 Binary files /dev/null and b/Particles/DustyCircleHardEdge.png differ diff --git a/Particles/FlameExplosion.png b/Particles/FlameExplosion.png new file mode 100644 index 0000000000..d678655a63 Binary files /dev/null and b/Particles/FlameExplosion.png differ diff --git a/Particles/SmallBloomRing.png b/Particles/SmallBloomRing.png new file mode 100644 index 0000000000..f51029ba21 Binary files /dev/null and b/Particles/SmallBloomRing.png differ diff --git a/Projectiles/Melee/UrchinSpikeFugu.cs b/Projectiles/Melee/UrchinSpikeFugu.cs index fc7fd7dc9b..d76ba18e0e 100644 --- a/Projectiles/Melee/UrchinSpikeFugu.cs +++ b/Projectiles/Melee/UrchinSpikeFugu.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X) + 1.57f; if (Projectile.ai[0] == 0f) { - float maxRange = 100f; + float maxRange = Projectile.ai[1] == 1f ? 256f : 100f; // Increased homing range for Lionfish int npcIndex = -1; for (int i = 0; i < Main.maxNPCs; i++) { diff --git a/Projectiles/Ranged/HiveBomb.cs b/Projectiles/Ranged/HiveBomb.cs deleted file mode 100644 index 3c4e051eb2..0000000000 --- a/Projectiles/Ranged/HiveBomb.cs +++ /dev/null @@ -1,191 +0,0 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Ranged -{ - public class HiveBomb : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - private ref float RocketType => ref Projectile.ai[0]; - - public override void SetDefaults() - { - Projectile.width = 14; - Projectile.height = 14; - Projectile.friendly = true; - Projectile.penetrate = 1; - Projectile.timeLeft = 95; - Projectile.DamageType = DamageClass.Ranged; - } - - public override void AI() - { - if (Math.Abs(Projectile.velocity.X) >= 8f || Math.Abs(Projectile.velocity.Y) >= 8f) - { - for (int i = 0; i < 2; i++) - { - float halfX = 0f; - float halfY = 0f; - if (i == 1) - { - halfX = Projectile.velocity.X * 0.5f; - halfY = Projectile.velocity.Y * 0.5f; - } - int dust = Dust.NewDust(new Vector2(Projectile.position.X + 3f + halfX, Projectile.position.Y + 3f + halfY) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, DustID.Torch, 0f, 0f, 100, default, 1f); - Main.dust[dust].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[dust].velocity *= 0.2f; - Main.dust[dust].noGravity = true; - dust = Dust.NewDust(new Vector2(Projectile.position.X + 3f + halfX, Projectile.position.Y + 3f + halfY) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, DustID.Smoke, 0f, 0f, 100, default, 0.5f); - Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[dust].velocity *= 0.05f; - } - } - if (Math.Abs(Projectile.velocity.X) < 15f && Math.Abs(Projectile.velocity.Y) < 15f) - { - Projectile.velocity *= 1.1f; - } - else if (Main.rand.NextBool()) - { - int dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Smoke, 0f, 0f, 100, default, 1f); - Main.dust[dust2].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[dust2].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[dust2].noGravity = true; - Main.dust[dust2].position = Projectile.Center + new Vector2(0f, (float)(-(float)Projectile.height / 2)).RotatedBy((double)Projectile.rotation, default) * 1.1f; - Main.rand.Next(2); - dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Torch, 0f, 0f, 100, default, 1f); - Main.dust[dust2].scale = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[dust2].noGravity = true; - Main.dust[dust2].position = Projectile.Center + new Vector2(0f, (float)(-(float)Projectile.height / 2 - 6)).RotatedBy((double)Projectile.rotation, default) * 1.1f; - } - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.ToRadians(90); - - if (RocketType == ItemID.DryRocket || RocketType == ItemID.WetRocket || RocketType == ItemID.LavaRocket || RocketType == ItemID.HoneyRocket) - { - if (Projectile.wet) - Projectile.timeLeft = 1; - } - } - - public override bool PreDraw(ref Color lightColor) - { - Texture2D tex = ModContent.Request(Texture).Value; - Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); - return false; - } - - public override void OnKill(int timeLeft) - { - var info = new CalamityUtils.RocketBehaviorInfo((int)RocketType) - { - smallRadius = 4, - mediumRadius = 7, - largeRadius = 10 - }; - int blastRadius = Projectile.RocketBehavior(info); - Projectile.ExpandHitboxBy(64); - Projectile.Damage(); - - if (Projectile.owner == Main.myPlayer) - { - for (int j = 0; j < 6; j++) - { - if (j % 2 != 1 || Main.rand.NextBool(3)) - { - Vector2 projPos = Projectile.position; - Vector2 projVel = Projectile.oldVelocity; - projVel.Normalize(); - projVel *= 8f; - float beeVelX = (float)Main.rand.Next(-35, 36) * 0.01f; - float beeVelY = (float)Main.rand.Next(-35, 36) * 0.01f; - projPos -= projVel * (float)j; - beeVelX += Projectile.oldVelocity.X / 6f; - beeVelY += Projectile.oldVelocity.Y / 6f; - int bee = Projectile.NewProjectile(Projectile.GetSource_FromThis(), projPos.X, projPos.Y, beeVelX, beeVelY, Main.player[Projectile.owner].beeType(), Main.player[Projectile.owner].beeDamage(Projectile.damage / 3), Main.player[Projectile.owner].beeKB(0f), Main.myPlayer); - if (bee.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[bee].penetrate = 2; - Main.projectile[bee].DamageType = DamageClass.Ranged; - } - } - } - } - - if (Main.dedServ) - return; - - SoundEngine.PlaySound(SoundID.Item14, Projectile.position); - for (int i = 0; i < 20; i++) - { - int dusty = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.GemEmerald, 0f, 0f, 100, default, 2f); - Main.dust[dusty].velocity *= 3f; - if (Main.rand.NextBool()) - { - Main.dust[dusty].scale = 0.5f; - Main.dust[dusty].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int j = 0; j < 30; j++) - { - int dusty2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.GemEmerald, 0f, 0f, 100, default, 3f); - Main.dust[dusty2].noGravity = true; - Main.dust[dusty2].velocity *= 5f; - dusty2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.GemEmerald, 0f, 0f, 100, default, 2f); - Main.dust[dusty2].velocity *= 2f; - } - - if (Main.netMode != NetmodeID.Server) - { - Vector2 goreSource = Projectile.Center; - int goreAmt = 3; - Vector2 source = new Vector2(goreSource.X - 24f, goreSource.Y - 24f); - for (int goreIndex = 0; goreIndex < goreAmt; goreIndex++) - { - float velocityMult = 0.33f; - if (goreIndex < (goreAmt / 3)) - { - velocityMult = 0.66f; - } - if (goreIndex >= (2 * goreAmt / 3)) - { - velocityMult = 1f; - } - Mod mod = ModContent.GetInstance(); - int type = Main.rand.Next(61, 64); - int smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - Gore gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X += 1f; - gore.velocity.Y += 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X -= 1f; - gore.velocity.Y += 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X += 1f; - gore.velocity.Y -= 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X -= 1f; - gore.velocity.Y -= 1f; - } - } - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 180); - } - } -} diff --git a/Projectiles/Ranged/HiveMissile.cs b/Projectiles/Ranged/HiveMissile.cs index 32f7c0661c..f85d0e7d92 100644 --- a/Projectiles/Ranged/HiveMissile.cs +++ b/Projectiles/Ranged/HiveMissile.cs @@ -1,74 +1,96 @@ using System; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Rogue; +using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; +using static CalamityMod.Projectiles.Ranged.TheHiveHoldout; namespace CalamityMod.Projectiles.Ranged { public class HiveMissile : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - private ref float RocketType => ref Projectile.ai[0]; + public ref float RocketID => ref Projectile.ai[0]; + public ref float ProjectileSpeed => ref Projectile.ai[1]; + public ref float Time => ref Projectile.ai[2]; + public bool HasHit = false; public override void SetDefaults() { - Projectile.width = 14; - Projectile.height = 14; - Projectile.scale = 0.75f; + Projectile.width = 25; + Projectile.height = 25; Projectile.friendly = true; Projectile.penetrate = 1; - Projectile.timeLeft = 95; + Projectile.timeLeft = 100; Projectile.DamageType = DamageClass.Ranged; + Projectile.extraUpdates = 2; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; } public override void AI() { - if (Math.Abs(Projectile.velocity.X) >= 8f || Math.Abs(Projectile.velocity.Y) >= 8f) + // Rotates towards its velocity. + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + + if (Projectile.wet && RocketID == ItemID.DryRocket && RocketID == ItemID.WetRocket && RocketID == ItemID.LavaRocket && RocketID == ItemID.HoneyRocket) { - for (int i = 0; i < 2; i++) + HasHit = true; + Projectile.Kill(); + } + + Time++; + + if (Projectile.timeLeft <= 50) + { + Projectile.velocity *= 0.965f; + if (Time % 5 == 0) { - float halfX = 0f; - float halfY = 0f; - if (i == 1) - { - halfX = Projectile.velocity.X * 0.5f; - halfY = Projectile.velocity.Y * 0.5f; - } - int dust = Dust.NewDust(new Vector2(Projectile.position.X + 3f + halfX, Projectile.position.Y + 3f + halfY) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, DustID.Torch, 0f, 0f, 100, default, 1f); - Main.dust[dust].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[dust].velocity *= 0.2f; - Main.dust[dust].noGravity = true; - dust = Dust.NewDust(new Vector2(Projectile.position.X + 3f + halfX, Projectile.position.Y + 3f + halfY) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, DustID.Smoke, 0f, 0f, 100, default, 0.5f); - Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[dust].velocity *= 0.05f; + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(10, 10) - Projectile.velocity * 3.5f, Main.rand.NextBool(3) ? DustEffectsID : 303, Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.4f, 0.9f), 0, default, Main.rand.NextFloat(0.5f, 0.9f)); + dust.noGravity = false; + if (dust.type != DustEffectsID) + dust.color = Main.rand.NextBool(3) ? EffectsColor : StaticEffectsColor; } } - if (Math.Abs(Projectile.velocity.X) < 15f && Math.Abs(Projectile.velocity.Y) < 15f) - { - Projectile.velocity *= 1.5f; - } - else if (Main.rand.NextBool()) - { - int dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Smoke, 0f, 0f, 100, default, 1f); - Main.dust[dust2].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[dust2].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[dust2].noGravity = true; - Main.dust[dust2].position = Projectile.Center + new Vector2(0f, (float)(-(float)Projectile.height / 2)).RotatedBy((double)Projectile.rotation, default) * 1.1f; - Main.rand.Next(2); - dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Torch, 0f, 0f, 100, default, 1f); - Main.dust[dust2].scale = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[dust2].noGravity = true; - Main.dust[dust2].position = Projectile.Center + new Vector2(0f, (float)(-(float)Projectile.height / 2 - 6)).RotatedBy((double)Projectile.rotation, default) * 1.1f; - } - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.ToRadians(90); - if (RocketType == ItemID.DryRocket || RocketType == ItemID.WetRocket || RocketType == ItemID.LavaRocket || RocketType == ItemID.HoneyRocket) + if (Main.dedServ) + return; + + // The projectile will fade away as its time alive is ending. + Projectile.alpha = (int)Utils.Remap(Projectile.timeLeft, 40f, 0f, 0f, 255f); + + if (Time % 3 == 0) { - if (Projectile.wet) - Projectile.timeLeft = 1; + Dust trailDust = Dust.NewDustDirect(Projectile.Center, Projectile.width, Projectile.height, Main.rand.NextBool() ? 303 : DustEffectsID, Scale: Main.rand.NextFloat(0.3f, 0.6f)); + trailDust.noGravity = true; + trailDust.noLight = true; + trailDust.noLightEmittence = true; + trailDust.velocity = -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.8f); + if (trailDust.type != DustEffectsID) + trailDust.color = Main.rand.NextBool(3) ? EffectsColor : StaticEffectsColor; } + if (Time > 5f) + { + float sizeBonus = Projectile.timeLeft < 30 ? Time * 0.003f : 0; + Color smokeColor = Color.Lerp(Color.Black, Color.Lime, 0.25f); + Particle smoke = new HeavySmokeParticle(Projectile.Center - Projectile.velocity * 2, -Projectile.velocity.RotatedByRandom(sizeBonus) * Main.rand.NextFloat(0.2f, 0.6f), smokeColor * 0.65f, 6, Main.rand.NextFloat(0.3f, 0.45f) + sizeBonus, 0.23f - (sizeBonus * 0.3f), Main.rand.NextFloat(-0.2f, 0.2f), false); + GeneralParticleHandler.SpawnParticle(smoke); + + if (Main.rand.NextBool()) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(10, 10) - Projectile.velocity * 2.5f, 303, -Projectile.velocity.RotatedByRandom(0.05f) * Main.rand.NextFloat(0.05f, 0.4f), 0, default, Main.rand.NextFloat(0.8f, 1.4f)); + dust.noGravity = false; + dust.color = Color.Black; + dust.alpha = Main.rand.Next(90, 220 + 1); + } + } + + Lighting.AddLight(Projectile.Center, StaticEffectsColor.ToVector3() * 0.7f); } public override bool PreDraw(ref Color lightColor) @@ -77,108 +99,73 @@ namespace CalamityMod.Projectiles.Ranged Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); return false; } - + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + HasHit = true; + target.AddBuff(ModContent.BuffType(), 90); + } + public override bool OnTileCollide(Vector2 oldVelocity) + { + HasHit = true; + return true; + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (Projectile.numHits > 1) + Projectile.damage = (int)(Projectile.damage * 0.8f); + if (Projectile.damage < 1) + Projectile.damage = 1; + } public override void OnKill(int timeLeft) { - var info = new CalamityUtils.RocketBehaviorInfo((int)RocketType) + if (HasHit == true) { - smallRadius = 5, - mediumRadius = 8, - largeRadius = 11 - }; - int blastRadius = Projectile.RocketBehavior(info); - Projectile.ExpandHitboxBy(80); - Projectile.Damage(); - - if (Projectile.owner == Main.myPlayer) - { - for (int j = 0; j < 3; j++) + var info = new CalamityUtils.RocketBehaviorInfo((int)RocketID) { - if (j % 2 != 1 || Main.rand.NextBool(3)) - { - Vector2 projPos = Projectile.position; - Vector2 projVel = Projectile.oldVelocity; - projVel.Normalize(); - projVel *= 8f; - float beeVelX = (float)Main.rand.Next(-35, 36) * 0.01f; - float beeVelY = (float)Main.rand.Next(-35, 36) * 0.01f; - projPos -= projVel * (float)j; - beeVelX += Projectile.oldVelocity.X / 6f; - beeVelY += Projectile.oldVelocity.Y / 6f; - int bee = Projectile.NewProjectile(Projectile.GetSource_FromThis(), projPos.X, projPos.Y, beeVelX, beeVelY, Main.player[Projectile.owner].beeType(), Main.player[Projectile.owner].beeDamage(Projectile.damage / 2), Main.player[Projectile.owner].beeKB(0f), Main.myPlayer); - if (bee.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[bee].penetrate = 2; - Main.projectile[bee].DamageType = DamageClass.Ranged; - } - } + // Since we use our own spawning method for the cluster rockets, we don't need them to shoot anything, + // we'll do it ourselves. + clusterProjectileID = ProjectileID.None, + destructiveClusterProjectileID = ProjectileID.None, + }; + + bool isClusterRocket = (RocketID == ItemID.ClusterRocketI || RocketID == ItemID.ClusterRocketII); + SoundStyle fire = new("CalamityMod/Sounds/Custom/PlagueSounds/PlagueBoom", 4); + SoundEngine.PlaySound(fire with { Volume = 0.5f, Pitch = -0.3f }, Projectile.Center); + + int blastRadius = (int)(Projectile.RocketBehavior(info) * 0.7f); + Projectile.ExpandHitboxBy((float)blastRadius); + Projectile.damage = (int)(Projectile.damage * 0.5f); + Projectile.penetrate = -1; + Projectile.Damage(); + + Particle blastRing = new CustomPulse( + Projectile.Center, + Vector2.Zero, + StaticEffectsColor * 0.8f, + "CalamityMod/Particles/FlameExplosion", + Vector2.One, + Main.rand.NextFloat(-10, 10), + Projectile.width / 22815f, + Projectile.width / 2275f, + 10); + GeneralParticleHandler.SpawnParticle(blastRing); + + for (int k = 0; k < 15; k++) + { + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, 303, new Vector2(8, 8).RotatedByRandom(100) * Main.rand.NextFloat(0.05f, 0.8f)); + dust2.scale = Main.rand.NextFloat(0.75f, 0.95f); + dust2.noGravity = true; + dust2.color = Main.rand.NextBool(3) ? EffectsColor : StaticEffectsColor; } - } - if (Main.dedServ) - return; - - SoundEngine.PlaySound(SoundID.Item14, Projectile.position); - for (int i = 0; i < 20; i++) - { - int dusty = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.GemRuby, 0f, 0f, 100, default, 2f); - Main.dust[dusty].velocity *= 3f; - if (Main.rand.NextBool()) + for (int k = 0; k < (isClusterRocket ? 3f : 2f); k++) { - Main.dust[dusty].scale = 0.5f; - Main.dust[dusty].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int j = 0; j < 30; j++) - { - int dusty2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.GemRuby, 0f, 0f, 100, default, 3f); - Main.dust[dusty2].noGravity = true; - Main.dust[dusty2].velocity *= 5f; - dusty2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.GemRuby, 0f, 0f, 100, default, 2f); - Main.dust[dusty2].velocity *= 2f; - } - - if (Main.netMode != NetmodeID.Server) - { - Vector2 goreSource = Projectile.Center; - int goreAmt = 3; - Vector2 source = new Vector2(goreSource.X - 24f, goreSource.Y - 24f); - for (int goreIndex = 0; goreIndex < goreAmt; goreIndex++) - { - float velocityMult = 0.33f; - if (goreIndex < (goreAmt / 3)) + int BEES = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, new Vector2(4, 10).RotatedByRandom(4) * Main.rand.NextFloat(0.2f, 0.8f), ModContent.ProjectileType(), (int)(Projectile.damage * (isClusterRocket ? 0.2f : 0.4f)), 0f, Projectile.owner, 0f, 0f, isClusterRocket ? 2f : 1f); + if (BEES.WithinBounds(Main.maxProjectiles)) { - velocityMult = 0.66f; + Main.projectile[BEES].penetrate = 1; + Main.projectile[BEES].DamageType = DamageClass.Ranged; } - if (goreIndex >= (2 * goreAmt / 3)) - { - velocityMult = 1f; - } - Mod mod = ModContent.GetInstance(); - int type = Main.rand.Next(61, 64); - int smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - Gore gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X += 1f; - gore.velocity.Y += 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X -= 1f; - gore.velocity.Y += 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X += 1f; - gore.velocity.Y -= 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X -= 1f; - gore.velocity.Y -= 1f; } } } diff --git a/Projectiles/Ranged/HiveNuke.cs b/Projectiles/Ranged/HiveNuke.cs new file mode 100644 index 0000000000..0c50836ddb --- /dev/null +++ b/Projectiles/Ranged/HiveNuke.cs @@ -0,0 +1,259 @@ +using System; +using System.Net.Sockets; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Rogue; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using static CalamityMod.Projectiles.Ranged.TheHiveHoldout; +namespace CalamityMod.Projectiles.Ranged +{ + public class HiveNuke : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public ref float RocketID => ref Projectile.ai[0]; + public ref float ProjectileSpeed => ref Projectile.ai[1]; + public bool HasHit = false; + public float Time = 0; + public bool BonusEffectMode; + public bool SetLifetime = false; + private Player Owner => Main.player[Projectile.owner]; + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 20; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + } + public override void SetDefaults() + { + Projectile.width = 25; + Projectile.height = 25; + Projectile.friendly = true; + Projectile.penetrate = 1; + Projectile.timeLeft = 1500; + Projectile.DamageType = DamageClass.Ranged; + Projectile.extraUpdates = 15; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + + public override void AI() + { + BonusEffectMode = Projectile.ai[2] == 2; + if (BonusEffectMode) + { + if (RocketID == ItemID.RocketII || RocketID == ItemID.RocketIV || RocketID == ItemID.MiniNukeII) + { + if (!SetLifetime) + { + Projectile.timeLeft = 60; + Projectile.extraUpdates = 0; + Projectile.damage = 0; + Projectile.alpha = 255; + SetLifetime = true; + } + + var info = new CalamityUtils.RocketBehaviorInfo((int)RocketID); + int blastRadius = (int)(Projectile.RocketBehavior(info) * 5f); + if (Time % 5 == 0) + { + Projectile.ExplodeTiles((int)(blastRadius * Utils.Remap(Time, 60f, 1f, 1f, 0f, true)), info.respectStandardBlastImmunity, info.tilesToCheck, info.wallsToCheck); + } + } + else + { + Point center = Projectile.Center.ToTileCoordinates(); + if (RocketID == ItemID.DryRocket) + { + DelegateMethods.f_1 = 10.5f * Utils.Remap(Time, 60f, 1f, 1f, 0f, true); + if (Time == 0) + { + Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadDry); + } + } + if (RocketID == ItemID.WetRocket) + { + DelegateMethods.f_1 = 10.5f * Utils.Remap(Time, 60f, 1f, 1f, 0f, true); + if (Time == 0) + { + Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadWater); + } + } + if (RocketID == ItemID.LavaRocket) + { + DelegateMethods.f_1 = 10.5f * Utils.Remap(Time, 60f, 1f, 1f, 0f, true); + if (Time == 0) + { + Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadLava); + } + } + if (RocketID == ItemID.HoneyRocket) + { + DelegateMethods.f_1 = 10.5f * Utils.Remap(Time, 60f, 1f, 1f, 0f, true); + if (Time == 0) + { + Utils.PlotTileArea(center.X, center.Y, DelegateMethods.SpreadHoney); + } + } + } + Time++; + } + else + { + // Rotates towards its velocity. + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + + if (Projectile.wet && RocketID == ItemID.DryRocket && RocketID == ItemID.WetRocket && RocketID == ItemID.LavaRocket && RocketID == ItemID.HoneyRocket) + Projectile.Kill(); + + Time++; + + if (Projectile.timeLeft <= 30) + Projectile.velocity *= 0.95f; + + if (Main.dedServ) + return; + + // The projectile will fade away as its time alive is ending. + Projectile.alpha = (int)Utils.Remap(Projectile.timeLeft, 10f, 0f, 0f, 255f); + + if (Time % 3 == 0) + { + Dust trailDust = Dust.NewDustDirect(Projectile.Center, Projectile.width, Projectile.height, Main.rand.NextBool() ? 303 : DustEffectsID, Scale: Main.rand.NextFloat(0.3f, 0.6f)); + trailDust.noGravity = true; + trailDust.noLight = true; + trailDust.noLightEmittence = true; + trailDust.velocity = -Projectile.velocity.RotatedByRandom(0.5) * Main.rand.NextFloat(0.2f, 0.8f); + if (trailDust.type != DustEffectsID) + trailDust.color = Main.rand.NextBool(3) ? EffectsColor : StaticEffectsColor; + } + if (Time > 5f) + { + Color smokeColor = Color.Lerp(Color.Black, Color.Lime, 0.25f); + Particle smoke = new HeavySmokeParticle(Projectile.Center - Projectile.velocity * 2, -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.6f), smokeColor * 0.65f, 9, Main.rand.NextFloat(0.45f, 0.6f), 0.23f, Main.rand.NextFloat(-0.2f, 0.2f), false); + GeneralParticleHandler.SpawnParticle(smoke); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(10, 10) - Projectile.velocity * 2.5f, 303, -Projectile.velocity.RotatedByRandom(0.05f) * Main.rand.NextFloat(0.2f, 0.9f), 0, default, Main.rand.NextFloat(0.9f, 1.6f)); + dust.noGravity = false; + dust.color = Color.Black; + dust.alpha = Main.rand.Next(90, 220 + 1); + } + + Lighting.AddLight(Projectile.Center, StaticEffectsColor.ToVector3() * 0.7f); + } + + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Projectile.width * 0.4f, targetHitbox); + + public override bool PreDraw(ref Color lightColor) + { + if (BonusEffectMode) { return false; } + Texture2D texture = ModContent.Request("CalamityMod/Projectiles/StarProj").Value; + if (Time > 6) + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], EffectsColor * 0.4f, 1, texture); + Texture2D tex = ModContent.Request(Texture).Value; + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); + return false; + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + HasHit = true; + target.AddBuff(ModContent.BuffType(), 60); + } + public override bool OnTileCollide(Vector2 oldVelocity) + { + HasHit = true; + return true; + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (Projectile.numHits > 1) + Projectile.damage = (int)(Projectile.damage * 0.90f); + if (Projectile.damage < 1) + Projectile.damage = 1; + } + public override void OnKill(int timeLeft) + { + bool isClusterRocket = (RocketID == ItemID.ClusterRocketI || RocketID == ItemID.ClusterRocketII); + if (HasHit == true && !BonusEffectMode) + { + if (Main.zenithWorld) + { + SoundStyle bees = new("CalamityMod/Sounds/Custom/BEES/bees", 11); + SoundEngine.PlaySound(bees with { Volume = 1.5f }, Projectile.Center); + SoundStyle fire = new("CalamityMod/Sounds/Item/TheHiveNuke"); + SoundEngine.PlaySound(fire with { Volume = 0.35f }, Projectile.Center); + } + else + { + SoundStyle fire = new("CalamityMod/Sounds/Item/TheHiveNuke"); + SoundEngine.PlaySound(fire with { Volume = 0.9f }, Projectile.Center); + } + + Owner.Calamity().GeneralScreenShakePower = 9.5f; + + var info = new CalamityUtils.RocketBehaviorInfo((int)RocketID); + int blastRadius = (int)(Projectile.RocketBehavior(info) * 5f); + Projectile.ExpandHitboxBy((float)blastRadius); + if (RocketID == ItemID.RocketII || RocketID == ItemID.RocketIV || RocketID == ItemID.MiniNukeII || RocketID == ItemID.DryRocket || RocketID == ItemID.WetRocket || RocketID == ItemID.LavaRocket || RocketID == ItemID.HoneyRocket) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Projectile.owner, RocketID, 0f, 2f); + Projectile.damage = (int)(Projectile.damage * 0.7f); + Projectile.penetrate = -1; + Projectile.Damage(); + + for (int k = 0; k < 3; k++) + { + Particle blastRing = new CustomPulse(Projectile.Center, Vector2.Zero, StaticEffectsColor * 0.8f, "CalamityMod/Particles/FlameExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), Projectile.width / 22815f, Projectile.width / (2275f + 520 * k), 20 + 4 * k); + GeneralParticleHandler.SpawnParticle(blastRing); + } + + for (int k = 0; k < 30; k++) + { + GlowOrbParticle orb = new GlowOrbParticle(Projectile.Center, new Vector2(30, 30).RotatedByRandom(100) * Main.rand.NextFloat(0.05f, 0.8f), false, 60, Main.rand.NextFloat(0.8f, 1.4f), StaticEffectsColor, true, true); + GeneralParticleHandler.SpawnParticle(orb); + } + + for (int k = 0; k < 45; k++) + { + if (Main.rand.NextBool(5)) + { + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? DustEffectsID : 303, new Vector2(30, 30).RotatedByRandom(100) * Main.rand.NextFloat(0.05f, 0.8f)); + dust2.scale = Main.rand.NextFloat(0.85f, 1.25f); + dust2.noGravity = true; + if (dust2.type != DustEffectsID) + dust2.color = Main.rand.NextBool(3) ? EffectsColor : StaticEffectsColor; + } + else + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, 303, new Vector2(35, 35).RotatedByRandom(100) * Main.rand.NextFloat(0.05f, 0.8f), 0, default, Main.rand.NextFloat(0.9f, 1.7f)); + dust.noGravity = false; + dust.color = Color.Black; + dust.alpha = Main.rand.Next(90, 220 + 1); + } + } + for (int k = 0; k < (int)((Main.zenithWorld ? 100 : 20) * (isClusterRocket ? 1.5f : 1)); k++) + { + int BEES = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, new Vector2(10, 10).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 0.8f), ModContent.ProjectileType(), (int)(Projectile.damage * (isClusterRocket ? 0.1f : 0.15f)), 0f, Projectile.owner, 0f, 0f, isClusterRocket ? 2f : 1f); + if (BEES.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[BEES].penetrate = 1; + Main.projectile[BEES].DamageType = DamageClass.Ranged; + } + } + } + else if (!BonusEffectMode) + { + for (int i = 0; i <= 15; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(10, 10) - Projectile.velocity * 3.5f, Main.rand.NextBool(3) ? DustEffectsID : 303, Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.4f, 0.9f), 0, default, Main.rand.NextFloat(0.5f, 0.9f)); + dust.noGravity = false; + if (dust.type != DustEffectsID) + dust.color = Main.rand.NextBool(3) ? EffectsColor : StaticEffectsColor; + } + } + } + } +} diff --git a/Projectiles/Ranged/HiveBomb.png b/Projectiles/Ranged/HiveNuke.png similarity index 100% rename from Projectiles/Ranged/HiveBomb.png rename to Projectiles/Ranged/HiveNuke.png diff --git a/Projectiles/Ranged/TheHiveHoldout.cs b/Projectiles/Ranged/TheHiveHoldout.cs new file mode 100644 index 0000000000..9a3de185a6 --- /dev/null +++ b/Projectiles/Ranged/TheHiveHoldout.cs @@ -0,0 +1,341 @@ +using System; +using System.Runtime.InteropServices; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Mono.Cecil; +using ReLogic.Utilities; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Projectiles.Ranged +{ + public class TheHiveHoldout : ModProjectile, ILocalizedModType + { + public override LocalizedText DisplayName => CalamityUtils.GetItemName(); + + public override string Texture => "CalamityMod/Items/Weapons/Ranged/TheHive"; + + // The type of dust used in the effects and the color of the particles that it'll use depending on the type of rocket used. + // It'll carry over to the projectiles that it shoots. + public static int DustEffectsID { get; set; } + public static Color EffectsColor { get; set; } + public static Color StaticEffectsColor = Color.Lime; + private ref float ShootingTimer => ref Projectile.ai[0]; + private bool FireNuke; + private float PostFireCooldown = 0; + private bool HasLetGo = false; + private SlotId HiveHum; + + private ref float OffsetLength => ref Projectile.localAI[0]; + + private Player Owner; + + private const float MaxOffsetLength = 15f; + private const float MaxCharge = 90f; + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 66; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.netImportant = true; + } + + public override void AI() + { + FireNuke = ShootingTimer > MaxCharge; + Item heldItem = Owner.ActiveItem(); + + if (ShootingTimer == 0) + { + SoundStyle charge = new("CalamityMod/Sounds/Item/LowHum"); + HiveHum = SoundEngine.PlaySound(charge with { Volume = 1.6f, IsLooped = true }, Projectile.Center); + } + // If there's no player, or the player is the server, or the owner's stunned, there'll be no holdout. + if (Owner.CantUseHoldout() && !HasLetGo || heldItem.type != ItemType()) + { + if (SoundEngine.TryGetActiveSound(HiveHum, out var hum) && hum.IsPlaying) + { + hum?.Stop(); + } + ShootRocket(heldItem); + NetUpdate(); + HasLetGo = true; + } + if (HasLetGo) + { + PostFiringCooldown(); + } + + // The center of the player, taking into account if they have a mount or not. + Vector2 ownerPosition = Owner.MountedCenter; + + // The vector between the player and the mouse. + Vector2 ownerToMouse = Owner.Calamity().mouseWorld - ownerPosition; + + // Deals with the holdout's rotation and direction, the owner's arms, etc. + ManageHoldout(ownerPosition, ownerToMouse); + + // When we change the distance of the gun from the arms for the recoil, + // recover to the original position smoothly. + if (OffsetLength != MaxOffsetLength) + OffsetLength = MathHelper.Lerp(OffsetLength, MaxOffsetLength, 0.1f); + + if (!HasLetGo) + { + ShootingTimer++; + if (SoundEngine.TryGetActiveSound(HiveHum, out var hum) && hum.IsPlaying) + { + hum.Position = Projectile.Center; + hum.Pitch = MathHelper.Lerp(0f, 0.8f, Utils.GetLerpValue(0f, MaxCharge, ShootingTimer, true)); + } + } + + // Inside here go all the things that dedicated servers shouldn't spend resources on. + // Like visuals and sounds. + if (Main.dedServ) + return; + + Vector2 tipPosition = Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.Zero) * 33f; + Vector2 shootDirection = Projectile.velocity.SafeNormalize(Vector2.Zero) * 20; + if (ShootingTimer >= MaxCharge && !HasLetGo) + { + for (int k = 0; k < 2; k++) + { + GlowOrbParticle spark = new GlowOrbParticle(tipPosition + Projectile.velocity * 1.5f, Vector2.Zero, false, 2, Main.rand.NextFloat(0.5f, 1.1f), Color.Red); + GeneralParticleHandler.SpawnParticle(spark); + } + for (int e = 0; e < 2; e++) + { + Dust dust2 = Dust.NewDustPerfect(tipPosition + Projectile.velocity * 1.5f, 90, shootDirection * Main.rand.NextFloat(0.01f, 0.8f)); + dust2.scale = Main.rand.NextFloat(0.45f, 0.75f); + dust2.noGravity = true; + } + } + + if (ShootingTimer == MaxCharge && !HasLetGo) + { + SoundStyle fullCharge = new("CalamityMod/Sounds/Custom/PlagueSounds/PBGAttackSwitchShort"); + SoundEngine.PlaySound(fullCharge with { Volume = 0.9f}, Projectile.Center); + for (int k = 0; k < 15; k++) + { + Dust dust2 = Dust.NewDustPerfect(tipPosition, 90, new Vector2(4, 4).RotatedByRandom(100) * Main.rand.NextFloat(0.05f, 0.8f)); + dust2.scale = Main.rand.NextFloat(0.85f, 1.15f); + dust2.noGravity = true; + } + } + } + + private void ManageHoldout(Vector2 mountedCenter, Vector2 ownerToMouse) + { + Vector2 rotationVector = Projectile.rotation.ToRotationVector2(); + float velocityRotation = Projectile.velocity.ToRotation(); + float proximityLookingUpwards = Vector2.Dot(ownerToMouse.SafeNormalize(Vector2.Zero), -Vector2.UnitY); + int direction = MathF.Sign(ownerToMouse.X); + + Vector2 armPosition = Owner.RotatedRelativePoint(mountedCenter, true); + Vector2 lengthOffset = rotationVector * OffsetLength; + Vector2 armOffset = new Vector2(Utils.Remap(proximityLookingUpwards, -1f, 1f, 0f, -12f) * direction, -10f + Utils.Remap(MathF.Abs(proximityLookingUpwards), 0f, 1f, 0f, proximityLookingUpwards > 0f ? 15f : 0f)); + Projectile.Center = armPosition + lengthOffset + armOffset; + Projectile.velocity = velocityRotation.AngleTowards(ownerToMouse.ToRotation(), 0.2f).ToRotationVector2(); + Projectile.rotation = velocityRotation; + Projectile.timeLeft = 2; + + Owner.heldProj = Projectile.whoAmI; + Owner.itemTime = Owner.itemAnimation = 2; + Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); + + Projectile.spriteDirection = Projectile.direction = direction; + Owner.ChangeDir(direction); + + float armRotation = Projectile.rotation - MathHelper.PiOver2; // -Pi/2 because the arms rotation starts with arms pointing down. + Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Quarter, armRotation); + Owner.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, armRotation + MathHelper.ToRadians(15f) * direction); + + // Rumble (only while channeling) + float rumble = Utils.GetLerpValue(0f, MaxCharge, ShootingTimer, true) * ShootingTimer >= MaxCharge ? 2 : 0.8f; + if (!Owner.CantUseHoldout()) + Projectile.Center += Main.rand.NextVector2Circular(rumble, rumble); + } + + private void ShootRocket(Item item) + { + // We use the velocity of this projectile as its direction vector. + Vector2 shootDirection = Projectile.velocity.SafeNormalize(Vector2.Zero); + float VelocityMultiplier = MathHelper.Lerp(0.5f, 1.5f, Utils.GetLerpValue(0f, MaxCharge, ShootingTimer, true)); + + // The position of the tip of the gun. + Vector2 tipPosition = Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.Zero) * 33f; + + // Every time we shoot we use ammo. + // With this method we also use the item's stats, like the shoot speed, or the type of ammo it was used. + Owner.PickAmmo(item, out _, out float projSpeed, out int damage, out float knockback, out int rocketType); + + // Decides the color of the effects depending on the type of rocket used. + switch (rocketType) + { + case ItemID.WetRocket: + DustEffectsID = 45; + EffectsColor = Color.RoyalBlue; + break; + case ItemID.LavaRocket: + DustEffectsID = DustID.Torch; + EffectsColor = Color.Red; + break; + case ItemID.HoneyRocket: + DustEffectsID = DustID.Honey; + EffectsColor = Color.Yellow; + break; + default: + DustEffectsID = 131; + EffectsColor = Color.LawnGreen; + break; + } + + // Spawns the projectile. + if (FireNuke) + { + SoundStyle fire = new("CalamityMod/Sounds/Custom/PlagueSounds/PBGBarrageLaunch"); + SoundEngine.PlaySound(fire with { Volume = 0.5f, Pitch = 0.1f }, Projectile.Center); + + Projectile.NewProjectileDirect( + Projectile.GetSource_FromThis(), + tipPosition, + shootDirection * projSpeed * 0.3f, + ProjectileType(), + damage, + knockback, + Projectile.owner, + rocketType); + PostFireCooldown = 75; + } + else + { + SoundStyle fire = new("CalamityMod/Sounds/Custom/PlagueSounds/PBGBarrageLaunch"); + SoundEngine.PlaySound(fire with { Volume = 0.4f, Pitch = 0.7f }, Projectile.Center); + + int numProj = 4; + float rotation = MathHelper.ToRadians(MathHelper.Clamp(35 - VelocityMultiplier * 26, 2, 25)); + for (int i = 0; i < numProj; i++) + { + Vector2 perturbedSpeed = (shootDirection).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); + Projectile.NewProjectileDirect( + Projectile.GetSource_FromThis(), + tipPosition, + perturbedSpeed * projSpeed * VelocityMultiplier, + ProjectileType(), + damage / 4, + knockback, + Projectile.owner, + rocketType); + } + PostFireCooldown = 30; + } + + NetUpdate(); + + // Inside here go all the things that dedicated servers shouldn't spend resources on. + // Like visuals and sounds. + if (Main.dedServ) + return; + + if (FireNuke) + { + for (int k = 0; k < 10; k++) + { + float pulseScale = Main.rand.NextFloat(0.35f, 0.55f); + DirectionalPulseRing pulse = new DirectionalPulseRing(tipPosition, (shootDirection * 25).RotatedByRandom(0.5f) * Main.rand.NextFloat(0.5f, 1.2f), (Main.rand.NextBool(3) ? EffectsColor : StaticEffectsColor) * 0.8f, new Vector2(1, 1), pulseScale - 0.25f, pulseScale, 0f, 20); + GeneralParticleHandler.SpawnParticle(pulse); + } + for (int i = 0; i <= 15; i++) + { + Dust dust = Dust.NewDustPerfect(tipPosition, Main.rand.NextBool(3) ? DustEffectsID : 303, (shootDirection * 20).RotatedByRandom(0.3f) * Main.rand.NextFloat(0.5f, 1.2f), 0, default, Main.rand.NextFloat(0.5f, 0.9f)); + dust.noGravity = false; + if (dust.type != DustEffectsID) + dust.color = Main.rand.NextBool(3) ? EffectsColor : StaticEffectsColor; + } + } + else + { + for (int k = 0; k < 6; k++) + { + float pulseScale = Main.rand.NextFloat(0.2f, 0.4f); + DirectionalPulseRing pulse = new DirectionalPulseRing(tipPosition, (shootDirection * 20).RotatedByRandom(0.25f) * Main.rand.NextFloat(0.5f, 1.2f), (Main.rand.NextBool(3) ? EffectsColor : StaticEffectsColor) * 0.8f, new Vector2(1, 1), pulseScale - 0.25f, pulseScale, 0f, 20); + GeneralParticleHandler.SpawnParticle(pulse); + } + } + + // By decreasing the offset length of the gun from the arms, we give an effect of recoil. + OffsetLength -= FireNuke ? 16f : 6f; + } + private void PostFiringCooldown() + { + Vector2 tipPosition = Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.Zero) * 33f; + + if (PostFireCooldown > 0) + { + PostFireCooldown--; + Vector2 smokeVel = new Vector2(0, -8) * Main.rand.NextFloat(0.1f, 1.1f); + Particle smoke = new HeavySmokeParticle(tipPosition, smokeVel, StaticEffectsColor, Main.rand.Next(40, 60 + 1), Main.rand.NextFloat(0.3f, 0.6f), 0.5f, Main.rand.NextFloat(-0.2f, 0.2f), Main.rand.NextBool(), required: true); + GeneralParticleHandler.SpawnParticle(smoke); + + Dust dust = Dust.NewDustPerfect(tipPosition, 303, smokeVel.RotatedByRandom(0.1f), 80, default, Main.rand.NextFloat(0.4f, 1.3f)); + dust.noGravity = false; + dust.color = StaticEffectsColor; + } + else + { + if (SoundEngine.TryGetActiveSound(HiveHum, out var hum) && hum.IsPlaying) + { + hum?.Stop(); + } + Projectile.Kill(); + NetUpdate(); + } + } + + private void NetUpdate() + { + Projectile.netUpdate = true; + if (Projectile.netSpam >= 10) + Projectile.netSpam = 9; + } + + public override void OnSpawn(IEntitySource source) + { + Owner = Main.player[Projectile.owner]; + OffsetLength = MaxOffsetLength; + } + + // Because we use the velocity as a direction, we don't need it to change its position. + public override bool ShouldUpdatePosition() => false; + + public override bool? CanDamage() => false; + + public override bool PreDraw(ref Color lightColor) + { + if (ShootingTimer <= 0) + return false; + + Texture2D texture = Request(Texture).Value; + Texture2D glowTexture = Request(Texture + "_Glow").Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Color drawColor = Projectile.GetAlpha(lightColor); + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = texture.Size() * 0.5f; + SpriteEffects flipSprite = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Main.EntitySpriteDraw(texture, drawPosition, null, drawColor, drawRotation, rotationPoint, Projectile.scale, flipSprite); + Main.EntitySpriteDraw(glowTexture, drawPosition, null, Color.White, drawRotation, rotationPoint, Projectile.scale, flipSprite); + + return false; + } + } +} diff --git a/Projectiles/Rogue/LionfishProj.cs b/Projectiles/Rogue/LionfishProj.cs index 7e83aabb55..ba42808e90 100644 --- a/Projectiles/Rogue/LionfishProj.cs +++ b/Projectiles/Rogue/LionfishProj.cs @@ -50,12 +50,12 @@ namespace CalamityMod.Projectiles.Rogue } if (Projectile.Calamity().stealthStrike) { - if (Projectile.timeLeft % 8 == 0 && Projectile.owner == Main.myPlayer) + if (Projectile.timeLeft % 7 == 0 && Projectile.owner == Main.myPlayer) { 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, 0f); + 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); if (spike.WithinBounds(Main.maxProjectiles)) Main.projectile[spike].DamageType = RogueDamageClass.Instance; } @@ -65,7 +65,7 @@ namespace CalamityMod.Projectiles.Rogue Projectile.StickyProjAI(15); } - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => Projectile.ModifyHitNPCSticky(6); + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => Projectile.ModifyHitNPCSticky(3); public override bool? CanDamage() => Projectile.ai[0] == 1f ? false : base.CanDamage(); public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) diff --git a/Projectiles/Typeless/BasicPlagueBee.cs b/Projectiles/Typeless/BasicPlagueBee.cs new file mode 100644 index 0000000000..c0d4d88fed --- /dev/null +++ b/Projectiles/Typeless/BasicPlagueBee.cs @@ -0,0 +1,211 @@ +using System; +using CalamityMod.Buffs.DamageOverTime; +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; + +namespace CalamityMod.Projectiles.Typeless +{ + public class BasicPlagueBee : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + public override string Texture => "CalamityMod/Projectiles/Rogue/PlaguenadeBee"; + + public int time = 0; + public float projRotValue; + public NPC npc; + public int tileCollisions = 0; + public override void SetStaticDefaults() + { + Main.projFrames[Projectile.type] = 4; + } + + public override void SetDefaults() + { + Projectile.width = 10; + Projectile.height = 10; + Projectile.friendly = true; + Projectile.penetrate = 2; + Projectile.timeLeft = 300; + Projectile.ignoreWater = true; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 5; + } + + public override void AI() + { + Color trailColor = Color.Lime; + if (time == 0) + trailColor = Main.rand.NextBool() ? Color.LawnGreen : Color.Lime; + time++; + + // If you would like the bees to home in sooner or later than normal, change Projectile.ai[0]! You can set it to anything above 30 to make them home in and damage immediately. + // If you set Projectile.ai[0] to a negative number, it will take longer before they begin homing. + + // You can set Projectile.ai[1] when spawning these bees to determine how long they inflict the plague debuff, default is 90 frames. + if (Projectile.ai[1] <= 0) + Projectile.ai[1] = 90; + + // You can set Projectile.ai[2] to change how detailed the bee's particle trail is. Higher is less detailed, default is 2. + // If you are spawning a lot of bees, consider raising the value to 3 or 4. + if (Projectile.ai[2] <= 0) + Projectile.ai[2] = 2; + + Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt(); + Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); + Projectile.rotation += Projectile.spriteDirection * MathHelper.ToRadians(45f); + + Projectile.frameCounter++; + if (Projectile.frameCounter >= 3) + { + Projectile.frame++; + Projectile.frameCounter = 0; + } + if (Projectile.frame >= Main.projFrames[Projectile.type]) + { + Projectile.frame = 0; + } + + // If a bee bounces around a fuckload (probably got stuck in a tile) stop it from doing visuals and kill it, that bee is doomed anyways. + if (tileCollisions < 7) + { + if (time % Projectile.ai[2] == 0) + { + PointParticle orb = new PointParticle(Projectile.Center, -Projectile.velocity * 0.05f, false, 7, 0.35f, trailColor * 0.45f); + GeneralParticleHandler.SpawnParticle(orb); + + if (Main.rand.NextBool()) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, 303, -Projectile.velocity.RotatedByRandom(0.2f) * Main.rand.NextFloat(0.2f, 0.6f), 0, default, Main.rand.NextFloat(0.35f, 0.55f)); + dust.noGravity = true; + dust.color = Color.Black; + dust.alpha = Main.rand.Next(90, 220 + 1); + } + } + } + else + Projectile.Kill(); + + Vector2 center = Projectile.Center; + float maxDistance = 800f; + bool homeIn = false; + Projectile.ai[0] += 1f; + if (Projectile.ai[0] > 30f) + { + for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) + { + if (time % 10 == 0 && npc == null) + npc = Projectile.Center.ClosestNPCAt(1000, false); + if (npc == null || !npc.CanBeChasedBy(Projectile, false)) + return; + if (npc.CanBeChasedBy(Projectile, false)) + { + float extraDistance = (npc.width / 2) + (npc.height / 2); + + bool canHit = true; + if (extraDistance < maxDistance) + canHit = Collision.CanHit(Projectile.Center, 1, 1, npc.Center, 1, 1); + + if (Vector2.Distance(npc.Center, Projectile.Center) < (maxDistance + extraDistance) && canHit) + { + center = npc.Center; + homeIn = true; + break; + } + } + } + } + if (!homeIn) + { + center.X = Projectile.Center.X + Projectile.velocity.X * 100f; + center.Y = Projectile.Center.Y + Projectile.velocity.Y * 100f; + } + float speed = 10f; + float velocityTweak = 0.30f; + Vector2 projPos = Projectile.Center; + Vector2 velocity = center - projPos; + float targetDist = velocity.Length(); + targetDist = speed / targetDist; + velocity.X *= targetDist; + velocity.Y *= targetDist; + if (Projectile.velocity.X < velocity.X) + { + Projectile.velocity.X += velocityTweak; + if (Projectile.velocity.X < 0f && velocity.X > 0f) + { + Projectile.velocity.X += velocityTweak * 2f; + } + } + else if (Projectile.velocity.X > velocity.X) + { + Projectile.velocity.X -= velocityTweak; + if (Projectile.velocity.X > 0f && velocity.X < 0f) + { + Projectile.velocity.X -= velocityTweak * 2f; + } + } + if (Projectile.velocity.Y < velocity.Y) + { + Projectile.velocity.Y += velocityTweak; + if (Projectile.velocity.Y < 0f && velocity.Y > 0f) + { + Projectile.velocity.Y += velocityTweak * 2f; + } + } + else if (Projectile.velocity.Y > velocity.Y) + { + Projectile.velocity.Y -= velocityTweak; + if (Projectile.velocity.Y > 0f && velocity.Y < 0f) + { + Projectile.velocity.Y -= velocityTweak * 2f; + } + } + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + if (Projectile.velocity.X != oldVelocity.X) + { + Projectile.velocity.X = -oldVelocity.X; + } + if (Projectile.velocity.Y != oldVelocity.Y) + { + Projectile.velocity.Y = -oldVelocity.Y; + } + tileCollisions++; + return false; + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = ModContent.Request(Texture).Value; + int frameHeight = texture.Height / Main.projFrames[Projectile.type]; + int drawStart = frameHeight * Projectile.frame; + SpriteEffects spriteEffects = SpriteEffects.None; + if (Projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, frameHeight)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture.Width / 2f, (float)frameHeight / 2f), Projectile.scale, spriteEffects, 0); + return false; + } + + public override void OnKill(int timeLeft) + { + for (int i = 0; i <= 5; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, 89, Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(0.7f, 0.85f)); + dust.noGravity = true; + } + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), (int)(Projectile.ai[1])); + + public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), (int)(Projectile.ai[1])); + + public override bool? CanDamage() => Projectile.ai[0] <= 30f ? false : null; + } +} diff --git a/Sounds/Custom/BEES/Names.txt b/Sounds/Custom/BEES/Names.txt new file mode 100644 index 0000000000..440c8bb183 --- /dev/null +++ b/Sounds/Custom/BEES/Names.txt @@ -0,0 +1,12 @@ +Names: +1 - Aqua +2 - CIT +3 - Lilac +4 - Metarex +5 - moonburn +6 - Ozzatron +7 - Rebecca +8 - Shayy +9 - StipulatedVenus +10 - Xyk +11 - Shade \ No newline at end of file diff --git a/Sounds/Custom/BEES/bees1.ogg b/Sounds/Custom/BEES/bees1.ogg new file mode 100644 index 0000000000..274f40e28e Binary files /dev/null and b/Sounds/Custom/BEES/bees1.ogg differ diff --git a/Sounds/Custom/BEES/bees10.ogg b/Sounds/Custom/BEES/bees10.ogg new file mode 100644 index 0000000000..0889776deb Binary files /dev/null and b/Sounds/Custom/BEES/bees10.ogg differ diff --git a/Sounds/Custom/BEES/bees11.ogg b/Sounds/Custom/BEES/bees11.ogg new file mode 100644 index 0000000000..e81ebe6c9b Binary files /dev/null and b/Sounds/Custom/BEES/bees11.ogg differ diff --git a/Sounds/Custom/BEES/bees2.ogg b/Sounds/Custom/BEES/bees2.ogg new file mode 100644 index 0000000000..ce687af023 Binary files /dev/null and b/Sounds/Custom/BEES/bees2.ogg differ diff --git a/Sounds/Custom/BEES/bees3.ogg b/Sounds/Custom/BEES/bees3.ogg new file mode 100644 index 0000000000..ab9ebec9bc Binary files /dev/null and b/Sounds/Custom/BEES/bees3.ogg differ diff --git a/Sounds/Custom/BEES/bees4.ogg b/Sounds/Custom/BEES/bees4.ogg new file mode 100644 index 0000000000..739b488905 Binary files /dev/null and b/Sounds/Custom/BEES/bees4.ogg differ diff --git a/Sounds/Custom/BEES/bees5.ogg b/Sounds/Custom/BEES/bees5.ogg new file mode 100644 index 0000000000..89c30e1b0e Binary files /dev/null and b/Sounds/Custom/BEES/bees5.ogg differ diff --git a/Sounds/Custom/BEES/bees6.ogg b/Sounds/Custom/BEES/bees6.ogg new file mode 100644 index 0000000000..4927be0c9d Binary files /dev/null and b/Sounds/Custom/BEES/bees6.ogg differ diff --git a/Sounds/Custom/BEES/bees7.ogg b/Sounds/Custom/BEES/bees7.ogg new file mode 100644 index 0000000000..54d3edf5a2 Binary files /dev/null and b/Sounds/Custom/BEES/bees7.ogg differ diff --git a/Sounds/Custom/BEES/bees8.ogg b/Sounds/Custom/BEES/bees8.ogg new file mode 100644 index 0000000000..677b47fc65 Binary files /dev/null and b/Sounds/Custom/BEES/bees8.ogg differ diff --git a/Sounds/Custom/BEES/bees9.ogg b/Sounds/Custom/BEES/bees9.ogg new file mode 100644 index 0000000000..094a103a5b Binary files /dev/null and b/Sounds/Custom/BEES/bees9.ogg differ diff --git a/Sounds/Custom/PlagueSounds/PBGAttackSwitchShort.ogg b/Sounds/Custom/PlagueSounds/PBGAttackSwitchShort.ogg new file mode 100644 index 0000000000..1e957a38c3 Binary files /dev/null and b/Sounds/Custom/PlagueSounds/PBGAttackSwitchShort.ogg differ diff --git a/Sounds/Item/LowHum.ogg b/Sounds/Item/LowHum.ogg new file mode 100644 index 0000000000..4dc6b63415 Binary files /dev/null and b/Sounds/Item/LowHum.ogg differ diff --git a/Sounds/Item/TheHiveNuke.ogg b/Sounds/Item/TheHiveNuke.ogg new file mode 100644 index 0000000000..ffd8ffea1e Binary files /dev/null and b/Sounds/Item/TheHiveNuke.ogg differ diff --git a/Utilities/ProjectileUtils.cs b/Utilities/ProjectileUtils.cs index c2119dbe3a..0a34629ef5 100644 --- a/Utilities/ProjectileUtils.cs +++ b/Utilities/ProjectileUtils.cs @@ -440,7 +440,8 @@ namespace CalamityMod // Explosion radii for various rocket ammos. Defaults to the sizes used in vanilla launchers. public int smallRadius = 3; // Rocket I and II public int mediumRadius = 6; // Rocket III and IV - public int largeRadius = 9; // Mini Nuke and Cluster Rockets + public int bigRadius = 7; // Cluster Rockets + public int largeRadius = 9; // Mini Nukes public bool respectStandardBlastImmunity = true; public List tilesToCheck = null; @@ -523,12 +524,12 @@ namespace CalamityMod break; case ItemID.ClusterRocketI: - explosionRadius = info.largeRadius; + explosionRadius = info.bigRadius; SpawnClusterFragments(false); break; case ItemID.ClusterRocketII: - explosionRadius = info.largeRadius; + explosionRadius = info.bigRadius; SpawnClusterFragments(true); break;