diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index e49c923993..c901fb7c28 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -87,7 +87,7 @@ namespace CalamityMod.CalPlayer public const float projectileMeleeWeaponMeleeSpeedMultiplier = 0f; public bool brimlashBusterBoost = false; public int evilSmasherBoost = 0; - public int hellbornBoost = 0; + public int hellbornShots = 0; public int searedPanCounter = 0; public int searedPanTimer = 0; public int potionTimer = 0; @@ -2699,7 +2699,7 @@ namespace CalamityMod.CalPlayer AdrenalineTrail = false; ascendantTrail = false; evilSmasherBoost = 0; - hellbornBoost = 0; + hellbornShots = 0; searedPanCounter = 0; searedPanTimer = 0; potionTimer = 0; diff --git a/CalPlayer/CalamityPlayerHitHurt.cs b/CalPlayer/CalamityPlayerHitHurt.cs index 7d0162d726..5dba7943f7 100644 --- a/CalPlayer/CalamityPlayerHitHurt.cs +++ b/CalPlayer/CalamityPlayerHitHurt.cs @@ -2217,7 +2217,7 @@ namespace CalamityMod.CalPlayer if (evilSmasherBoost > 0) evilSmasherBoost -= 1; - hellbornBoost = 0; + hellbornShots = 0; if (trinketOfChi) chiBuffTimer = 0; diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 1b52325b51..e44acd9d49 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -1516,8 +1516,6 @@ namespace CalamityMod.CalPlayer hideOfDeusTimer--; if (murasamaHitCooldown > 0) murasamaHitCooldown--; - if (hellbornBoost > 0) - hellbornBoost--; if (persecutedEnchantSummonTimer < 1800) persecutedEnchantSummonTimer++; else diff --git a/Items/Weapons/Ranged/Hellborn.cs b/Items/Weapons/Ranged/Hellborn.cs index 6ec064fecf..1401b6ad48 100644 --- a/Items/Weapons/Ranged/Hellborn.cs +++ b/Items/Weapons/Ranged/Hellborn.cs @@ -1,4 +1,6 @@ -using Microsoft.Xna.Framework; +using System.Linq; +using CalamityMod.Projectiles.Ranged; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.DataStructures; @@ -10,121 +12,61 @@ namespace CalamityMod.Items.Weapons.Ranged public class Hellborn : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; - public const float ExplosionDamageMultiplier = 3f; public override void SetDefaults() { Item.width = 62; Item.height = 34; - Item.damage = 20; + Item.damage = 500; Item.DamageType = DamageClass.Ranged; - Item.useAnimation = Item.useTime = 20; + Item.useAnimation = Item.useTime = 35; Item.useStyle = ItemUseStyleID.Shoot; Item.knockBack = 2f; + Item.value = CalamityGlobalItem.RarityPinkBuyPrice; Item.rare = ItemRarityID.Pink; - Item.UseSound = SoundID.Item11; + + Item.noMelee = true; + Item.UseSound = null; + Item.noUseGraphic = true; + Item.channel = true; Item.autoReuse = true; - Item.shoot = ProjectileID.PurificationPowder; + + Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 12f; - Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; } - - public override float UseTimeMultiplier(Player player) => 1f - 0.5f * (player.Calamity().hellbornBoost * (1f / 600f)); - - public override void ModifyWeaponDamage(Player player, ref StatModifier damage) => damage *= 1f + player.Calamity().hellbornBoost * (1f / 600f); - - public override void ModifyWeaponKnockback(Player player, ref StatModifier knockback) => knockback *= 1f + (player.Calamity().hellbornBoost * (1f / 600f)); - - public override Vector2? HoldoutOffset() => new Vector2(-10, 0); - - //Custom melee hitbox - public override bool? CanHitNPC(Player player, NPC target) + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override bool AltFunctionUse(Player player) => true; + public override void HoldItem(Player player) { - Rectangle targetHitbox = target.Hitbox; + if (player.whoAmI != Main.myPlayer) + return; - float collisionPoint = 0f; - float gunLength = 66f; - float gunHeight = 15; + // Right-click channeling + player.Calamity().rightClickListener = true; - return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), player.MountedCenter, player.MountedCenter + ((player.itemRotation + (player.direction < 0 ? MathHelper.Pi : 0f)).ToRotationVector2() * gunLength), gunHeight, ref collisionPoint) ? null : false; + if (player.Calamity().mouseRight && CanUseItem(player) && !Main.mapFullscreen && !Main.blockMouse) + { + // Only one out at a time + if (Main.projectile.Any(n => n.active && n.type == Item.shoot && n.owner == player.whoAmI)) + return; + + var source = player.GetSource_ItemUse(player.ActiveItem()); + Projectile holdout = Projectile.NewProjectileDirect(source, player.Center, Vector2.Zero, Item.shoot, player.ActiveItem().damage, 0f, player.whoAmI, 0, 0, 5); + holdout.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero); + } } - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - for (int index = 0; index < 3; index++) - { - float SpeedX = velocity.X + Main.rand.Next(-15, 16) * 0.05f; - float SpeedY = velocity.Y + Main.rand.Next(-15, 16) * 0.05f; + // Only one out at a time + if (Main.projectile.Any(n => n.active && n.type == Item.shoot && n.owner == player.whoAmI)) + return false; - if (type == ProjectileID.Bullet) - { - int bullet = Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, ProjectileID.ExplosiveBullet, damage, knockback, player.whoAmI); - Main.projectile[bullet].usesLocalNPCImmunity = true; - Main.projectile[bullet].localNPCHitCooldown = 10; - } - else - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI); - } + Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, type, damage, knockback, player.whoAmI, 0, 0, 0); + + // 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 ModifyHitNPC(Player player, NPC target, ref NPC.HitModifiers modifiers) - { - player.Calamity().hellbornBoost = 600; - modifiers.SourceDamage *= ExplosionDamageMultiplier; - int touchDamage = player.CalcIntDamage(Item.damage); - player.ApplyDamageToNPC(target, touchDamage, 0f, 0, false); - float firstDustScale = 3.4f; - float secondDustScale = 1.6f; - float thirdDustScale = 4f; - Vector2 dustRotation = (target.rotation - MathHelper.PiOver2).ToRotationVector2(); - Vector2 dustVelocity = dustRotation * target.velocity.Length(); - SoundEngine.PlaySound(SoundID.Item14, target.Center); - for (int i = 0; i < 80; i++) - { - int contactDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, DustID.InfernoFork, 0f, 0f, 200, default, firstDustScale); - Dust dust = Main.dust[contactDust]; - dust.position = target.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * target.width / 2f; - dust.noGravity = true; - dust.velocity.Y -= 6f; - dust.velocity *= 3f; - dust.velocity += dustVelocity * Main.rand.NextFloat(); - contactDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, DustID.InfernoFork, 0f, 0f, 100, default, secondDustScale); - dust.position = target.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * target.width / 2f; - dust.velocity.Y -= 6f; - dust.velocity *= 2f; - dust.noGravity = true; - dust.fadeIn = 1f; - dust.color = Color.Crimson * 0.5f; - dust.velocity += dustVelocity * Main.rand.NextFloat(); - } - for (int j = 0; j < 40; j++) - { - int contactDust2 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, DustID.InfernoFork, 0f, 0f, 0, default, thirdDustScale); - Dust dust = Main.dust[contactDust2]; - dust.position = target.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(target.velocity.ToRotation()) * target.width / 3f; - dust.noGravity = true; - dust.velocity.Y -= 6f; - dust.velocity *= 0.5f; - dust.velocity += dustVelocity * (0.6f + 0.6f * Main.rand.NextFloat()); - } - } - - public override void ModifyHitPvp(Player player, Player target, ref Player.HurtModifiers modifiers) - { - modifiers.SourceDamage *= 10; - } - - public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(BuffID.OnFire3, 360); - } - - public override void OnHitPvp(Player player, Player target, Player.HurtInfo hurtInfo) - { - target.AddBuff(BuffID.OnFire3, 360); - } } } diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson index 389293cecf..648b4d173e 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson @@ -244,3 +244,5 @@ WaterSpout.DisplayName: Spout WildfireBloomFire.DisplayName: Wildfire Fire WildfireBloomFlare.DisplayName: Wildfire Flare WulfrumScrapBullet.DisplayName: High Speed Scrap +HellbornProj.DisplayName: Hellborn Proj +HellbornShell.DisplayName: Hellborn Shell diff --git a/Projectiles/Ranged/HellbornHoldout.cs b/Projectiles/Ranged/HellbornHoldout.cs new file mode 100644 index 0000000000..45d4cecae2 --- /dev/null +++ b/Projectiles/Ranged/HellbornHoldout.cs @@ -0,0 +1,237 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Utilities; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.ModLoader; +using Terraria.ID; +using CalamityMod.Buffs.StatDebuffs; +using System; + +namespace CalamityMod.Projectiles.Ranged +{ + public class HellbornHoldout : BaseGunHoldoutProjectile + { + public override int AssociatedItemID => ModContent.ItemType(); + public override float MaxOffsetLengthFromArm => 24f; + public override float OffsetXUpwards => -5f; + public override float BaseOffsetY => -5f; + public override float OffsetYDownwards => 5f; + public override float RecoilResolveSpeed => 0.5f; + + public ref float time => ref Projectile.ai[0]; + public float cooldownTimer = 0; + public ref float shootingTimer => ref Projectile.ai[1]; + public bool onCooldown => cooldownTimer > 0; + public SlotId SoundSlot; + + public bool Spinning => Projectile.ai[2] == 0; + public bool failedShot = false; + public float drawRot = 0; + public bool hasPlayedSound = false; + public bool hasPlayedReloadSound = false; + public float fade = 0; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 12; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + } + public override void SetDefaults() + { + Projectile.width = 62; + Projectile.height = 34; + Projectile.penetrate = -1; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 5; + Projectile.tileCollide = false; + Projectile.ArmorPenetration = 25; + } + public override void KillHoldoutLogic() + { + //if ( !onCooldown && (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type)) + //Projectile.Kill(); + } + + public override void HoldoutAI() + { + fade = Utils.GetLerpValue(0, 40, time, true); + if (SoundEngine.TryGetActiveSound(SoundSlot, out var sSound) && sSound.IsPlaying) + { + sSound.Volume = fade * 100 * 0.5f; + sSound.Position = Projectile.Center; + } + + if (onCooldown) + { + PostFiringCooldown(); + if (!Spinning) + return; + } + if (Spinning) + { + float armRot = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + float spinArmRot = (((Projectile.Center + new Vector2(0, -3).RotatedBy(drawRot * 0.6f)) - Owner.Center).SafeNormalize(Vector2.UnitX) * 5).ToRotation(); + Owner.SetCompositeArmBack(true, FrontArmStretch, armRot + 0.6f * Projectile.direction); + Owner.SetCompositeArmFront(true, BackArmStretch, spinArmRot + MathHelper.ToRadians(-90f)); + } + if (time > 3) + { + if (Spinning) + { + if (Owner.CantUseHoldout()) + { + Projectile.Kill(); + sSound?.Stop(); + } + else + { + OffsetLengthFromArm = MathHelper.Lerp(OffsetLengthFromArm, 9, 0.5f); + drawRot += 0.75f * Projectile.direction * MathHelper.Clamp(fade, 0.3f, 1f); + + Lighting.AddLight(Projectile.Center, Color.Lerp(Color.OrangeRed, Color.White, 0.6f).ToVector3() * fade * 0.7f); + if (!hasPlayedSound) + { + SoundStyle spin = new("CalamityMod/Sounds/Item/SpinningWoosh"); + SoundSlot = SoundEngine.PlaySound(spin with { Volume = 0.01f, Pitch = -0.1f, IsLooped = true }, Projectile.Center); + hasPlayedSound = true; + } + + Particle Smear = new CircularSmearVFX(Projectile.Center, Color.Red * Main.rand.NextFloat(0.38f, 0.55f), Main.rand.NextFloat(-8, 8), Main.rand.NextFloat(1f, 1.1f) * fade); + GeneralParticleHandler.SpawnParticle(Smear); + + Particle Smear2 = new CircularSmearVFX(Projectile.Center, Color.OrangeRed * Main.rand.NextFloat(0.58f, 0.7f), Main.rand.NextFloat(-8, 8), Main.rand.NextFloat(0.5f, 0.6f) * fade); + GeneralParticleHandler.SpawnParticle(Smear2); + + if (Main.rand.NextBool() && fade > 0.2f) + { + for (int i = 0; i < 2; i++) + { + Vector2 dustPos = Projectile.Center + (i * MathHelper.Pi + drawRot * 0.25f + MathHelper.PiOver2).ToRotationVector2() * 35f * fade; + Dust dust = Dust.NewDustPerfect(dustPos, 278, (i * MathHelper.Pi + (drawRot * Projectile.direction) * 0.25f * Math.Sign(Projectile.velocity.X)).ToRotationVector2().RotatedBy(MathHelper.ToRadians(180f) * (Projectile.direction == 1 ? 0 : 1)) * -5f * Main.rand.NextFloat(0.5f, 1f) * fade); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.42f, 0.62f); + dust.color = Color.Lerp(Color.Orange, Color.Red, Main.rand.NextFloat(0f, 1f)); + + } + } + else if (fade > 0.2f) + { + for (int i = 0; i < 2; i++) + { + Vector2 dustPos = Projectile.Center + (i * MathHelper.Pi + drawRot * 0.5f + MathHelper.PiOver2).ToRotationVector2() * 80f * fade; + Dust dust = Dust.NewDustPerfect(dustPos, 267, (i * MathHelper.Pi + (drawRot * Projectile.direction) * 0.5f * Math.Sign(Projectile.velocity.X)).ToRotationVector2().RotatedBy(MathHelper.ToRadians(180f) * (Projectile.direction == 1 ? 0 : 1)) * -7f * Main.rand.NextFloat(0.5f, 1f) * fade); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.62f, 0.82f); + dust.color = Color.Lerp(Color.Orange, Color.Red, Main.rand.NextFloat(0f, 1f)); + } + } + } + } + else if (!onCooldown) + { + if (Owner.Calamity().hellbornShots > 0) + { + Owner.Calamity().GeneralScreenShakePower = 5f; + OffsetLengthFromArm -= 35f; + cooldownTimer = Owner.itemAnimationMax * 2; + Owner.Calamity().hellbornShots--; + SoundStyle bigShot = new("CalamityMod/Sounds/Item/HellbornShoot"); + SoundEngine.PlaySound(bigShot with { PitchVariance = 0.15f, Volume = 0.9f }, Projectile.Center); + + Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 7; + + Owner.velocity += shootVelocity * -0.85f; + + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, -shootVelocity.RotatedBy(0.75f * Projectile.direction) * 1f, ModContent.ProjectileType(), 1, 0, Projectile.owner); + + for (int i = 0; i <= 13; i++) + { + Dust dust = Dust.NewDustPerfect(GunTipPosition, 303, shootVelocity.RotatedByRandom(0.5f) * Main.rand.NextFloat(0.2f, 1.5f), 80, default, Main.rand.NextFloat(0.4f, 1.3f)); + dust.noGravity = false; + dust.color = Color.White; + + Dust dust2 = Dust.NewDustPerfect(GunTipPosition, 278, shootVelocity.RotatedByRandom(0.5f) * Main.rand.NextFloat(0.1f, 1f)); + dust2.noGravity = true; + dust2.scale = Main.rand.NextFloat(0.52f, 0.72f); + dust2.color = Color.Lerp(Color.Orange, Color.Red, Main.rand.NextFloat(0f, 1f)); + } + for (int i = 0; i < 14; i++) + { + Particle smoke = new HeavySmokeParticle(GunTipPosition, shootVelocity.RotatedByRandom(0.6f) * Main.rand.NextFloat(0.2f, 1.5f), Color.White, 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); + } + } + else + { + OffsetLengthFromArm -= 8f; + failedShot = true; + SoundStyle bigShot = new("CalamityMod/Sounds/Item/DudFire"); + SoundEngine.PlaySound(bigShot with { PitchVariance = 0.15f, Volume = 0.75f }, Projectile.Center); + cooldownTimer = Owner.itemAnimationMax; + } + } + } + + time++; + } + private void PostFiringCooldown() + { + Owner.channel = true; + cooldownTimer -= (Spinning ? 1 : 2f); + + if (cooldownTimer > 1) + { + if (!Owner.Calamity().mouseRight && cooldownTimer < Owner.itemAnimationMax * 1.7f && !failedShot) + Projectile.ai[2] = 0; + if (cooldownTimer <= 18 && !hasPlayedReloadSound) + { + if (!failedShot) + { + SoundStyle fire = new("CalamityMod/Sounds/Item/HellbornReload"); + SoundEngine.PlaySound(fire with { Volume = 0.8f }, Projectile.Center); + } + hasPlayedReloadSound = true; + } + } + else if (!Spinning) + { + if (SoundEngine.TryGetActiveSound(SoundSlot, out var sSound) && sSound.IsPlaying) + sSound?.Stop(); + Projectile.Kill(); + } + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + modifiers.SourceDamage *= 0.08f; + if (Owner.Calamity().hellbornShots < 6) + { + Owner.Calamity().hellbornShots++; + } + } + public override bool PreDraw(ref Color lightColor) + { + if (time < 2) + return false; + Texture2D texture = ModContent.Request("CalamityMod/Items/Weapons/Ranged/Hellborn").Value; + Texture2D spinTexture = ModContent.Request("CalamityMod/Items/Weapons/Ranged/Hellborn").Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = texture.Size() * 0.5f; + SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Main.EntitySpriteDraw(texture, drawPosition + (Spinning ? new Vector2(0, -8).RotatedBy(drawRot * 0.6f) : Vector2.Zero), null, Projectile.GetAlpha(lightColor), drawRotation + drawRot, rotationPoint, Projectile.scale, flipSprite); + return false; + } + public override bool? CanDamage() => Spinning ? null : false; + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 90, targetHitbox); + } +} diff --git a/Projectiles/Ranged/HellbornProj.cs b/Projectiles/Ranged/HellbornProj.cs new file mode 100644 index 0000000000..1b152a1483 --- /dev/null +++ b/Projectiles/Ranged/HellbornProj.cs @@ -0,0 +1,127 @@ +using CalamityMod.Particles; +using System; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Microsoft.Xna.Framework.Graphics; +using Terraria.Audio; + +namespace CalamityMod.Projectiles.Ranged +{ + public class HellbornProj : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override void SetStaticDefaults() + { + Main.projFrames[Projectile.type] = 6; + } + + public override void SetDefaults() + { + Projectile.width = 38; + Projectile.height = 38; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.penetrate = 1; + Projectile.timeLeft = 600; + Projectile.DamageType = DamageClass.Ranged; + Projectile.extraUpdates = 2; + Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; + } + + public override void AI() + { + Player Owner = Main.player[Projectile.owner]; + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); + + //Animation + Projectile.frameCounter++; + if (Projectile.frameCounter > 4) + { + Projectile.frame++; + Projectile.frameCounter = 0; + } + if (Projectile.frame > 6) + { + Projectile.frame = 0; + } + if (Projectile.velocity.Length() < 18) + Projectile.velocity *= 1.035f; + + //Rotation + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.ToRadians(90); + + Lighting.AddLight(Projectile.Center, Color.Orange.ToVector3()); + + if (targetDist < 1400f) + { + // Spawn in a helix-style pattern + float sine = (float)Math.Sin(Projectile.timeLeft * 0.575f / MathHelper.Pi); + + Vector2 offset = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2) * sine * 16f; + if (Main.rand.NextBool(2)) + { + Particle orb = new GlowOrbParticle(Projectile.Center + offset, -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.8f), false, Main.rand.Next(20, 28 + 1), Main.rand.NextFloat(0.6f, 1.3f), Main.rand.NextBool() ? Color.Orange : Color.OrangeRed); + GeneralParticleHandler.SpawnParticle(orb); + } + if (Main.rand.NextBool(2)) + { + Particle orb2 = new GlowOrbParticle(Projectile.Center - offset, -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.8f), false, Main.rand.Next(20, 28 + 1), Main.rand.NextFloat(0.6f, 1.3f), Main.rand.NextBool() ? Color.Orange : Color.OrangeRed); + GeneralParticleHandler.SpawnParticle(orb2); + } + } + + Vector2 dustPos = Projectile.Center + Main.rand.NextVector2Circular(30, 30); + Dust dust = Dust.NewDustPerfect(dustPos, 267, -Projectile.velocity * Main.rand.NextFloat(0.1f, 0.4f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.72f, 1.12f); + dust.color = Color.Lerp(Color.Orange, Color.Red, Main.rand.NextFloat(0f, 1f)); + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + Player Owner = Main.player[Projectile.owner]; + if (target.CanBeMoved(true)) + { + // Launch + Vector2 launchVel = (Projectile.Center - target.Center).SafeNormalize(Vector2.UnitY) * -17; + target.velocity = launchVel * (target.knockBackResist == 0 ? 0.5f : 1f); + } + } + public override void OnKill(int timeLeft) + { + for (int l = 0; l < 17; l++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, 278, new Vector2(8, 8).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 0.8f)); + dust.noGravity = false; + dust.scale = Main.rand.NextFloat(0.62f, 0.82f); + dust.color = Color.Lerp(Color.Orange, Color.Red, Main.rand.NextFloat(0f, 1f)); + } + + Particle blastRing = new CustomPulse(Projectile.Center, Vector2.Zero, Color.OrangeRed * 0.7f, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 1.2f, 1.7f, 16, true); + GeneralParticleHandler.SpawnParticle(blastRing); + Particle blastRing2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.White * 0.7f, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.7f, 0.9f, 16, true); + GeneralParticleHandler.SpawnParticle(blastRing2); + + SoundStyle bigShot = new("CalamityMod/Sounds/Item/HellbornImpact"); + SoundEngine.PlaySound(bigShot with { PitchVariance = 0.15f, Volume = 0.8f }, Projectile.Center); + } + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = ModContent.Request("CalamityMod/Projectiles/Ranged/HellbornProj").Value; + + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = texture.Size() * 0.5f; + + Rectangle frame = texture.Frame(1, 6, 0, Projectile.frame); + Vector2 origin = frame.Size() * 0.5f; + + for (int i = 0; i < 2; i++) + Main.EntitySpriteDraw(texture, drawPosition, frame, Color.White with { A = 0 }, 0, origin, Projectile.scale * (i == 0 ? 1.15f : 1), SpriteEffects.None, 0); + + return false; + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 35, targetHitbox); + } +} diff --git a/Projectiles/Ranged/HellbornProj.png b/Projectiles/Ranged/HellbornProj.png new file mode 100644 index 0000000000..7bab1d813d Binary files /dev/null and b/Projectiles/Ranged/HellbornProj.png differ diff --git a/Projectiles/Ranged/HellbornShell.cs b/Projectiles/Ranged/HellbornShell.cs new file mode 100644 index 0000000000..ffde6bddc8 --- /dev/null +++ b/Projectiles/Ranged/HellbornShell.cs @@ -0,0 +1,102 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using static Humanizer.In; + +namespace CalamityMod.Projectiles.Ranged +{ + public class HellbornShell : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/Ranged/HellbornShell"; + public int Time = 0; + public bool TouchedGrass = false; + + public override void SetDefaults() + { + Projectile.width = 12; + Projectile.height = 26; + Projectile.friendly = true; + Projectile.ignoreWater = false; + Projectile.DamageType = DamageClass.Ranged; + Projectile.penetrate = -1; + Projectile.timeLeft = 300; + Projectile.tileCollide = false; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + public override void SetStaticDefaults() + { + // Unsure if it will look good with these + //ProjectileID.Sets.TrailCacheLength[Projectile.type] = 8; + //ProjectileID.Sets.TrailingMode[Projectile.type] = 0; + } + public override bool PreDraw(ref Color lightColor) + { + //CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1, ModContent.Request("CalamityMod/Projectiles/Ranged/DragonsBreathMag").Value); + return true; + } + public override void AI() + { + Projectile.scale = 0.8f; + Projectile.extraUpdates = 1; + Time++; + Player Owner = Main.player[Projectile.owner]; + if (!TouchedGrass) + { + if (Projectile.timeLeft <= 240) + Projectile.rotation += 0.04f * Projectile.direction; + else + Projectile.rotation = (new Vector2(0, -5 * Projectile.direction) + Projectile.velocity * -1.2f).ToRotation(); + + Projectile.velocity.Y += 0.087f; + Projectile.velocity.X *= 0.99f; + + if (Main.rand.NextBool(4)) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity, 303, -Projectile.velocity.RotatedByRandom(0.1f) * Main.rand.NextFloat(0.2f, 1f), 180, default, Main.rand.NextFloat(0.4f, 1.3f)); + dust.noGravity = false; + dust.color = Color.White; + } + } + else + { + Projectile.velocity = Vector2.Zero; + } + Projectile.alpha = (int)(255 * Utils.GetLerpValue(60, 0, Projectile.timeLeft, true)); + if (Collision.SolidCollision(Projectile.Center - Projectile.velocity * 1.5f, 2, 2)) + Projectile.tileCollide = true; + } + public override bool OnTileCollide(Vector2 oldVelocity) + { + Projectile.damage = 0; + TouchedGrass = true; + Projectile.velocity = Vector2.Zero; + return false; + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + /* + if (Main.zenithWorld) + { + for (int i = 0; i <= 30; i++) + { + SparkParticle spark1 = new SparkParticle(Projectile.Center, new Vector2(4, 4).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 2.8f), false, 45, 1.4f, Main.rand.NextBool(4) ? Color.Orange : Color.OrangeRed); + GeneralParticleHandler.SpawnParticle(spark1); + } + Particle explosion = new DetailedExplosion(Projectile.Center, Vector2.Zero, Color.DarkOrange, Vector2.One, Main.rand.NextFloat(-5, 5), 0f, 2.8f, 33); + GeneralParticleHandler.SpawnParticle(explosion); + Particle explosion2 = new DetailedExplosion(Projectile.Center, Vector2.Zero, Color.OrangeRed, Vector2.One, Main.rand.NextFloat(-5, 5), 0f, 3f, 33, false); + GeneralParticleHandler.SpawnParticle(explosion2); + } + target.AddBuff(ModContent.BuffType(), 20); + */ + } + } +} diff --git a/Projectiles/Ranged/HellbornShell.png b/Projectiles/Ranged/HellbornShell.png new file mode 100644 index 0000000000..03dd40086a Binary files /dev/null and b/Projectiles/Ranged/HellbornShell.png differ diff --git a/Sounds/Item/HellbornImpact.ogg b/Sounds/Item/HellbornImpact.ogg new file mode 100644 index 0000000000..630befa59a Binary files /dev/null and b/Sounds/Item/HellbornImpact.ogg differ diff --git a/Sounds/Item/HellbornReload.ogg b/Sounds/Item/HellbornReload.ogg new file mode 100644 index 0000000000..098e08b0e0 Binary files /dev/null and b/Sounds/Item/HellbornReload.ogg differ diff --git a/Sounds/Item/HellbornShoot.ogg b/Sounds/Item/HellbornShoot.ogg new file mode 100644 index 0000000000..f136ea748b Binary files /dev/null and b/Sounds/Item/HellbornShoot.ogg differ