diff --git a/Items/Weapons/Magic/SanguineFlare.cs b/Items/Weapons/Magic/SanguineFlare.cs index bc7827c338..28bd1045a8 100644 --- a/Items/Weapons/Magic/SanguineFlare.cs +++ b/Items/Weapons/Magic/SanguineFlare.cs @@ -21,12 +21,13 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 56; Item.height = 60; - Item.damage = 143; + Item.damage = 300; Item.DamageType = DamageClass.Magic; Item.mana = 22; Item.useTime = 25; Item.useAnimation = 25; Item.useStyle = ItemUseStyleID.Shoot; + Item.channel = true; Item.noMelee = true; Item.knockBack = 8f; Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; @@ -39,11 +40,7 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - for (int i = 0; i < 7; i++) - { - Vector2 spreadVelocity = velocity.RotatedByRandom(MathHelper.ToRadians(5f)) * Main.rand.NextFloat(0.8f, 1.2f); - Projectile.NewProjectile(source, position, spreadVelocity, type, damage, knockback, Main.myPlayer); - } + velocity *= 0; return true; // Fires one directly with no randomness, totaling 8 projectiles } diff --git a/Items/Weapons/Melee/TheMutilator.cs b/Items/Weapons/Melee/TheMutilator.cs index 0c217455a0..6fc633fc4a 100644 --- a/Items/Weapons/Melee/TheMutilator.cs +++ b/Items/Weapons/Melee/TheMutilator.cs @@ -1,8 +1,11 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.Melee; using CalamityMod.Rarities; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -10,68 +13,73 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class TheMutilator : ModItem, ILocalizedModType + public class TheMutilator : BaseSwordHoldoutItem, ILocalizedModType { + public static int MaximumCharge = 10; + public int Charge = 0; + + public int DecayTimer = 0; public new string LocalizationCategory => "Items.Weapons.Melee"; + public override int ProjectileType => ModContent.ProjectileType(); public override void SetDefaults() { Item.width = 90; Item.height = 90; Item.damage = 483; Item.DamageType = DamageClass.Melee; - Item.useAnimation = 18; + Item.useAnimation = 30; Item.useStyle = ItemUseStyleID.Swing; - Item.useTime = 18; - Item.useTurn = true; + Item.useTime = 30; Item.knockBack = 8f; Item.UseSound = SoundID.Item1; - Item.autoReuse = true; Item.shootSpeed = 10f; Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; Item.rare = ModContent.RarityType(); + base.SetDefaults(); } - public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 240); - if (target.life <= (target.lifeMax * 0.2f)) + public override void ModifyWeaponDamage(Player player, ref StatModifier damage) + { + damage *= 1 + Charge / 7f; + } + public override void UpdateInventory(Player player) + { + if (DecayTimer > 0) DecayTimer--; + else { - if (!CalamityPlayer.areThereAnyDamnBosses || Main.rand.NextBool()) + if (Charge > 0) { - int heartDrop = CalamityPlayer.areThereAnyDamnBosses ? 1 : Main.rand.Next(1, 3); - for (int i = 0; i < heartDrop; i++) - { - Item.NewItem(player.GetSource_OnHit(target), (int)target.position.X, (int)target.position.Y, target.width, target.height, 58, 1, false, 0, false, false); - } - } - SoundEngine.PlaySound(SoundID.Item14, target.Center); - target.position.X += target.width / 2; - target.position.Y += target.height / 2; - target.position.X -= target.width / 2; - target.position.Y -= target.height / 2; - for (int i = 0; i < 30; i++) - { - int bloodDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, DustID.Blood, 0f, 0f, 100, default, 2f); - Main.dust[bloodDust].velocity *= 3f; - if (Main.rand.NextBool()) - { - Main.dust[bloodDust].scale = 0.5f; - Main.dust[bloodDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int j = 0; j < 50; j++) - { - int bloodDust2 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, DustID.Blood, 0f, 0f, 100, default, 3f); - Main.dust[bloodDust2].noGravity = true; - Main.dust[bloodDust2].velocity *= 5f; - bloodDust2 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, DustID.Blood, 0f, 0f, 100, default, 2f); - Main.dust[bloodDust2].velocity *= 2f; + Charge--; + DecayTimer = 60; } } } + public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + float fill = Charge / (float)MaximumCharge; + if (fill <= 0) + return; + + float barScale = 3f; + + var barBG = ModContent.Request("CalamityMod/UI/MiscTextures/GenericBarBack").Value; + var barFG = ModContent.Request("CalamityMod/UI/MiscTextures/GenericBarFront").Value; + + Vector2 barOrigin = barBG.Size() * 0.5f; + float yOffset = 44f; + Vector2 drawPos = position + Vector2.UnitY * scale * (frame.Height - yOffset); + Rectangle frameCrop = new Rectangle(0, 0, (int)((fill) * barFG.Width), barFG.Height); + Color colorBG = Color.Crimson; + Color colorFG = Color.Lerp(Color.OrangeRed, Color.DarkOrange, fill); + + spriteBatch.Draw(barBG, drawPos, null, colorBG, 0f, barOrigin, scale * barScale, 0f, 0f); + spriteBatch.Draw(barFG, drawPos, frameCrop, colorFG, 0f, barOrigin, scale * barScale, 0f, 0f); + } + + public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Weapons/Ranged/ArterialAssault.cs b/Items/Weapons/Ranged/ArterialAssault.cs index 9a37c667b7..1a6651b629 100644 --- a/Items/Weapons/Ranged/ArterialAssault.cs +++ b/Items/Weapons/Ranged/ArterialAssault.cs @@ -1,6 +1,8 @@ using System; +using CalamityMod.Items.Ammo; using CalamityMod.Items.Materials; using CalamityMod.Projectiles; +using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; @@ -17,10 +19,10 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 44; Item.height = 100; - Item.damage = 110; + Item.damage = 200; Item.DamageType = DamageClass.Ranged; - Item.useTime = 3; - Item.useAnimation = 15; + Item.useTime = 6; + Item.useAnimation = 40; Item.reuseDelay = 10; Item.useLimitPerAnimation = 5; Item.useStyle = ItemUseStyleID.Shoot; @@ -37,49 +39,16 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float arrowSpeed = Item.shootSpeed; - Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); - float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; - float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; - if (player.gravDir == -1f) - { - mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; - } - float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); - if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) - { - mouseXDist = (float)player.direction; - mouseYDist = 0f; - mouseDistance = arrowSpeed; - } - else - { - mouseDistance = arrowSpeed / mouseDistance; - } - realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (-(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f; - realPlayerPos.Y -= 100f; - mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; - mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; - if (mouseYDist < 0f) - { - mouseYDist *= -1f; - } - if (mouseYDist < 20f) - { - mouseYDist = 20f; - } - mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); - mouseDistance = arrowSpeed / mouseDistance; - mouseXDist *= mouseDistance; - mouseYDist *= mouseDistance; - Vector2 arrowVel = new Vector2(mouseXDist, mouseYDist); - - Projectile shotArrow = Projectile.NewProjectileDirect(source, realPlayerPos, arrowVel, type, damage, knockback, player.whoAmI); + position += velocity.SafeNormalize(Vector2.Zero).RotatedByRandom(1.8f) * 64; + velocity = position.DirectionTo(Main.MouseWorld) * velocity.Length()*2; + type = ModContent.ProjectileType(); + Projectile shotArrow = Projectile.NewProjectileDirect(source, position, velocity, type, damage, knockback, player.whoAmI); shotArrow.noDropItem = true; shotArrow.tileCollide = false; - shotArrow.Calamity().conditionalHomingRange = 300f; + (shotArrow.ModProjectile as BloodfireArrowProj).DisableEffects = true; + shotArrow.Calamity().conditionalHomingRange = 175f; + shotArrow.Calamity().BloodstoneOrbValue = 1; return false; } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson index b6a8a7aef9..66a90cae37 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson @@ -749,7 +749,12 @@ SandstreamScepter: { SanguineFlare: { DisplayName: Sanguine Flare - Tooltip: Fires a blast of sanguine flares that drain enemy life + Tooltip: + ''' + Charges up a sanguine flare that gains power over time + When striking an enemy, this flare causes a bloodsplosion and splits into blood orbs + Picking up these blood orbs reduces the duration of Potion Sickness + ''' } SeethingDischarge: { diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson index fbba76be1c..51182e117f 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson @@ -1359,8 +1359,9 @@ TheMutilator: { DisplayName: The Mutilator Tooltip: ''' - Striking an enemy below 20% life will trigger a bloodsplosion - Bloodsplosions cause hearts to drop that can be picked up to heal you + Striking enemies empowers The Mutilator, increasing its damage + At full charge, striking enemies causes a blood orb explosion + Picking up these blood orbs reduces the duration of Potion Sickness ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson index d4036cd346..5040e2be9c 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson @@ -113,8 +113,9 @@ ArterialAssault: { DisplayName: Arterial Assault Tooltip: ''' - Fires a chain of 5 arrows from the sky - All arrows will rapidly home in on nearby enemies + Fires a group of 5 homing blood arrows + These blood arrows burst into blood orbs upon striking an enemy + Picking up these blood orbs reduces the duration of Potion Sickness ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson index 2d5549e4c7..0f45c1dca0 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson @@ -85,8 +85,9 @@ BloodsoakedCrasher: { ''' Throws a bloody axe that is affected by gravity and can bounce twice The axe speeds up over time, but will slow down upon hitting an enemy - Heals on enemy hits - Stealth strikes spawn homing blood on enemy hits + Spews blood orbs upon enemy hits + Picking up these blood orbs reduces the duration of Potion Sickness + Stealth strikes spawn homing blood bolts on hit ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson index dff9c92674..b9d505cc19 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson @@ -292,7 +292,8 @@ DragonbloodDisgorger: { Tooltip: ''' Summons a skeletal dragon and her two children - Baby spits passively heal the player + Baby spits burst into blood orbs upon hitting an enemy + Picking up these blood orbs reduces the duration of Potion Sickness Requires 6 minion slots to be summoned There can only be one family at a time ''' diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Healing.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Healing.hjson index 6f207a3da2..211c3eb65d 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Healing.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Healing.hjson @@ -19,3 +19,4 @@ RoyalHeal.DisplayName: Heal ShinobiHealOrb.DisplayName: Blue Healing Orb SilvaOrb.DisplayName: Silva Orb TransfusionTrail.DisplayName: Heal +BloodstoneHealOrb.DisplayName: Bloodstone Heal Orb diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson index 72ae489a01..c1cd99f172 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson @@ -306,3 +306,4 @@ WulfrumScrew.DisplayName: Wulfrum Screw WulfrumScrewdriverProj.DisplayName: Wulfrum Screwdriver YinYoDark.DisplayName: Dark Shard YinYoLight.DisplayName: Light Shard +MutilatorSwordProj.DisplayName: Mutilator Sword Proj diff --git a/Projectiles/BaseProjectiles/BaseCustomMeleeSwingProjectile.cs b/Projectiles/BaseProjectiles/BaseCustomMeleeSwingProjectile.cs new file mode 100644 index 0000000000..7a4991b567 --- /dev/null +++ b/Projectiles/BaseProjectiles/BaseCustomMeleeSwingProjectile.cs @@ -0,0 +1,476 @@ +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Graphics.Primitives; +using CalamityMod.NPCs; +using CalamityMod.Systems.Collections; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.DataStructures; +using Terraria.GameContent.Prefixes; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.BaseProjectiles +{ + + public class BaseSwordHoldoutPlayer : ModPlayer + { + /// + /// Used to detect what swing a weapon is doing. + /// + public int swingNum = 0; + + } + /// + /// Manages all the required settings for custom sword holdouts done using BaseSwordHoldoutProjectile + /// + public abstract class BaseSwordHoldoutItem : ModItem + { + public virtual int ProjectileType { get; set; } + public virtual bool SizeModifiers { get; set; } = true; + + public virtual bool RClickAutoswing { get; set; } = false; + + public override void SetStaticDefaults() + { + if (RClickAutoswing) ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; + } + + public override bool MeleePrefix() + { + return SizeModifiers; + } + public override void SetDefaults() + { + Item.noMelee = true; + Item.noUseGraphic = true; + Item.shoot = ProjectileType; + Item.autoReuse = true; + Item.useTurn = false; + Item.useStyle = ItemUseStyleID.Shoot; + if (SizeModifiers) PrefixLegacy.ItemSets.SwordsHammersAxesPicks[Item.type] = true; + } + public override bool CanUseItem(Player player) + { + if (player.itemTime > 0) + { + return false; + } + for (int i = 0; i < 1000; i++) + { + var proj = Main.projectile[i]; + if (proj.type == ProjectileType && proj.owner == player.whoAmI && proj.active) + { + return false; + } + + } + return base.CanUseItem(player); + } + } + + [PierceResistException] + //Doze 24apr2025 - Not a child of BaseCustomUseStyleProjectile because this doesn't use any of it's functionality. Comes from my melee rework mod. + public abstract class BaseSwordHoldoutProjectile : ModProjectile + { + #region Overrideable Fields + /// + /// The width, in degrees, of the sword swing. + /// Defaults to 180 + /// + public virtual int swingWidth { get; set; } = 180; + /// + /// How many frames the sword swing should take. + /// Defaults to 20 + /// + public virtual int swingTime { get; set; } = 20; + /// + /// If the swing should alternate directions each use. + /// Defaults to true + /// + public virtual bool AlternateSwings { get; set; } = true; + /// + /// How far the held sword should be offset from the player + /// Defaults to 0 + /// + public virtual int OffsetDistance { get; set; } = 0; + /// + /// What item this projectile uses as a base. + /// + public virtual Item BaseItem { get; set; } + /// + /// Whether or not this projectile uses a base item at all. + /// Defaults to true. + /// + public virtual bool UsesBaseItem { get; set; } = true; + + /// + /// Length of after-image trail left by the projectile. + /// Defaults to 0 + /// + public virtual int AfterImageLength { get; set; } = 0; + + /// + /// Whether or not this should get melee speed bonuses + /// Defaults to TRUE + /// + public virtual bool useMeleeSpeed { get; set; } = true; + + /// + /// Whether or not this should get melee size bonuses (Titan Glove) + /// Defaults to TRUE + /// + public virtual bool useMeleeSize { get; set; } = true; + /// + /// Array of three colors used for the built-in trail drawing code. + /// Defaults to White, Black, Green. + /// + public virtual Color[] trailColors { get; set; } = [Color.White, Color.Black, Color.Green]; + + /// + /// Whether or not to draw a trail when swung. + /// + public virtual bool drawSwordTrail { get; set; } = false; + /// + /// How far the trail should be offset from the center of the projectile. Use to draw trail at sword tip + /// Defaults to 25 + /// + public virtual float trailOffset { get; set; } = 25; + /// + /// Length of the trail in frames + /// Defaults to 25 + /// + public virtual int trailLength { get; set; } = 25; + + /// + /// How long before the weapon should begin it's actual swing once used + /// + public virtual int StartupTime { get; set; } = 0; + /// + /// How long the weapon should "cool down" after swinging before ending the item use + /// + public virtual int CooldownTime { get; set; } = 0; + /// + /// Speed at which the projectile should rotate to match the mouse angle during StartupTime. + /// Set to 0 to disable. + /// Defaults to 0.5f + /// + public virtual float RotateInStartup { get; set; } = 0.5f; + + #endregion + + #region Fields + + /// + /// Angle of the swing. By default, gets set to mouse angle. Can be set in Spawn(IEntitySource) for fixed angles. + /// + public Vector2 angle { get; set; } = Vector2.Zero; + /// + /// Internal timer for the projectile's entire lifespan + /// + public int timer { get; set; } = 0; + + /// + /// Internal timer for the projectile's swing animation + /// + internal int swingTimer = 0; + + public static Asset TrailTexture; + + public float baseScale; + /// + /// Old weapon scales used to track for trail drawing + /// + public List oldScale = new List(); + List oldProjectileRot = new List { }; + List oldProjectilePos = new List { }; + + internal int ExistsTime = 20; + #endregion + + #region Overridable Methods + /// + /// Happens after movement but before timer increases. Use as to not cancel the default AI behavior. + /// + public virtual void AdditionalAI() { } + /// + /// happens after OnSpawn. Use as not to cancel the default OnSpawn behavior. + /// + /// + public virtual void Spawn(IEntitySource source) { } + /// + /// happens after SetDefaults. Use as not to cancel default SetDefaults behavior. + /// + public virtual void Defaults() { } + /// + /// Returns the offset from the centerpoint in radians. Automatically will be inverted if AlternateSwings is enabled. + /// + /// + public virtual float SwingFunction() + { + return MathHelper.ToRadians(MathHelper.SmoothStep(-swingWidth / 2, swingWidth / 2, swingTimer / (float)swingTime)); + } + /// + /// The function for the width of the trail + /// + /// + /// + public virtual float trailWidth(float completion) + { + return MathHelper.Lerp(30, 0, completion); + } + + /// + /// The function for the color of the trail + /// + /// + /// + public virtual Color trailColor(float completion) + { + return Color.Black; + } + #endregion + + #region Overrides + public override void SetStaticDefaults() + { + ProjectileDestroyExceptionsList.List.Add(Projectile.type); + } + /// + /// DO NOT OVERRIDE IN MOST SITUATIONS + /// use Defaults() instead. + /// That will set defaults after everything is set in the base projectile. + /// + public override void SetDefaults() + { + Projectile.timeLeft = swingTime * 2; + if (UsesBaseItem) + { + Projectile.width = BaseItem.width; + Projectile.height = BaseItem.height; + } + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.localNPCHitCooldown = -1; + Projectile.usesLocalNPCImmunity = true; + Projectile.extraUpdates = 0; + Projectile.aiStyle = -2; + Projectile.DamageType = ModLoader.GetMod("CalamityMod").Find("TrueMeleeDamageClass"); + Projectile.tileCollide = false; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 100; + Defaults(); + + + } + /// + /// DO NOT OVERRIDE IN MOST SITUATIONS + /// use Spawn(IEntitySource) instead + /// That will run spawn code in the proper timing. + /// + public override void OnSpawn(IEntitySource source) + { + var player = Main.player[Projectile.owner]; + angle = (player.Center - Main.MouseWorld).SafeNormalize(Vector2.One); + Projectile.velocity = Vector2.Zero; + if (angle.X < 0) + { + player.direction = 1; + Projectile.spriteDirection = 1 * (int)player.gravDir; + } + else + { + player.direction = -1; + Projectile.spriteDirection = -1 * (int)player.gravDir; + } + swingTime = Main.player[Projectile.owner].HeldItem.useTime; + Spawn(source); + if (useMeleeSpeed) + { + var speed = Main.player[Projectile.owner].GetAttackSpeed(); + if (speed > 3f) + speed = 3f; + + if (speed != 0f) + speed = 1f / speed; + + swingTime = (int)(swingTime * speed); + if (swingTime < 1) + { + swingTime = 1; + } + StartupTime = (int)(StartupTime * speed); + CooldownTime = (int)(CooldownTime * speed); + } + if (useMeleeSize) + { + if (player.meleeScaleGlove) Projectile.scale *= 1.1f; + Projectile.scale *= player.HeldItem.scale; + } + baseScale = Projectile.scale; + ExistsTime = swingTime + StartupTime + CooldownTime; + Projectile.timeLeft = ExistsTime * 2; + } + + /// + /// DO NOT OVERRIDE IN MOST SITUATIONS + /// use AdditionalAI() instead + /// That will run AI code at the right time. + /// + public override void AI() + { + var player = Main.player[Projectile.owner]; + var modplayer = player.GetModPlayer(); + float adust = MathHelper.ToRadians(45 + 180); + if (timer < StartupTime || timer > StartupTime + swingTime) + { + angle = Vector2.Lerp(angle, (player.Center - Main.MouseWorld).SafeNormalize(Vector2.One), RotateInStartup); + if (angle.X < 0) + { + player.direction = 1; + Projectile.spriteDirection = 1 * (int)player.gravDir; + } + else + { + player.direction = -1; + Projectile.spriteDirection = -1 * (int)player.gravDir; + } + } + if (Projectile.spriteDirection == -1) + { + adust = MathHelper.ToRadians(-45); + } + var armCenter = player.Center - new Vector2(5 * player.direction, 2); + if (AfterImageLength > 0) + { + oldProjectileRot.Add(Projectile.rotation); + oldProjectilePos.Add(Projectile.Center); + if (oldProjectileRot.Count > AfterImageLength) + { + oldProjectileRot.RemoveAt(0); + oldProjectilePos.RemoveAt(0); + } + } + var angle2 = (AlternateSwings && (modplayer.swingNum % 2 == 1 ? false : true) ? SwingFunction() : -SwingFunction()); + Projectile.Center = armCenter - (angle * OffsetDistance * (1 + (Projectile.scale - 1) * 0.75f)).RotatedBy(Projectile.spriteDirection * angle2); + Projectile.rotation = angle.RotatedBy(Projectile.spriteDirection * angle2).ToRotation() + adust; + AdditionalAI(); + oldScale.Insert(0, Projectile.scale); + + player.itemTime = ExistsTime + 1 - timer; + if (timer > ExistsTime) + { + Projectile.Kill(); + player.itemTime = 0; + } + timer++; + if (timer >= StartupTime && timer < StartupTime + swingTime) + { + swingTimer++; + } + var armDir = armCenter - Projectile.Center; + armDir.Y *= player.gravDir; + player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, armDir.ToRotation() + MathHelper.ToRadians(90)); + } + public override bool PreDraw(ref Color lightColor) + { + + var player = Main.player[Projectile.owner]; + var modplayer = player.GetModPlayer(); + if (AfterImageLength > 0) + { + Texture2D texture = ModContent.Request(Texture).Value; + for (int i = 0; i < oldProjectileRot.Count; i++) + { + var col = Projectile.Opacity * (i / (float)AfterImageLength) * 0.1f; + if (Projectile.spriteDirection == 1) + { + Main.EntitySpriteDraw(texture, oldProjectilePos[i] - Main.screenPosition, null, Color.White * col, oldProjectileRot[i], texture.Size() / 2, 1, SpriteEffects.None, 0); + } + else + { + Main.EntitySpriteDraw(texture, oldProjectilePos[i] - Main.screenPosition, null, Color.White * col, oldProjectileRot[i], texture.Size() / 2, 1, SpriteEffects.FlipHorizontally, 0); + } + } + } + if (drawSwordTrail && timer >= StartupTime && timer <= StartupTime + swingTime) + { + Main.spriteBatch.EnterShaderRegion(); + if (TrailTexture == null) + { + TrailTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/VoronoiShapes", (AssetRequestMode)2); + } + Vector2 trailOffset = (Projectile.rotation - MathHelper.PiOver4).ToRotationVector2() + Projectile.Size * 0.5f; + GameShaders.Misc["CalamityMod:ExobladeSlash"].SetShaderTexture(TrailTexture); + + GameShaders.Misc["CalamityMod:ExobladeSlash"].UseColor(trailColors[0]); + + GameShaders.Misc["CalamityMod:ExobladeSlash"].UseSecondaryColor(trailColors[1]); + + GameShaders.Misc["CalamityMod:ExobladeSlash"].Shader.Parameters["fireColor"].SetValue(trailColors[2].ToVector3()); + + GameShaders.Misc["CalamityMod:ExobladeSlash"].Shader.Parameters["flipped"].SetValue((AlternateSwings && modplayer.swingNum % 2 == 1) ^ Projectile.spriteDirection == -1 ? false : true); + GameShaders.Misc["CalamityMod:ExobladeSlash"].Apply(); + + var positionsToUse = Projectile.oldPos.Take(trailLength).ToArray(); + for (var i = 0; i < positionsToUse.Length; i++) + { + if (i >= timer) continue; + positionsToUse[i] += (Projectile.oldRot[i] - MathHelper.PiOver4 * (Projectile.spriteDirection == -1 ? 3 : 1)).ToRotationVector2() * this.trailOffset * oldScale[i]; + } + PrimitiveRenderer.RenderTrail(positionsToUse, new(trailWidth, trailColor, (_) => trailOffset, shader: GameShaders.Misc["CalamityMod:ExobladeSlash"]), 25); + Main.spriteBatch.ExitShaderRegion(); + + Main.player[Projectile.owner].heldProj = Projectile.whoAmI; + } + Main.player[Projectile.owner].heldProj = Projectile.whoAmI; + return true; + } + public override void ModifyDamageHitbox(ref Rectangle hitbox) + { + var center = hitbox.Center.ToVector2(); + hitbox.Height = (int)(Projectile.height * Projectile.scale); + hitbox.Width = (int)(Projectile.width * Projectile.scale); + hitbox.Location = (center - new Vector2(hitbox.Width / 2, hitbox.Height / 2)).ToPoint(); + + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + modifiers.HitDirectionOverride = ((Main.player[Projectile.owner].DirectionTo(target.Center)).X >= 0 ? 1 : -1); + } + #endregion + + #region Helper Methods + /// + /// Spawns projectiles from the sword swing, automatically spacing them out on the if an amount is set. + /// + /// + /// Velocity of the projectile. Automatically converted into a Vector2 in the direction of swing. + /// The modifier from the source projectile's damage for this projectile + /// The amount of projectiles for the sword to shoot. If set, it will space out those projectiles evenly. If unset, will force a shot. + /// + /// + public void shootCheck(int type = 0, float velocity = 1, float damagemod = 1, int amount = 0, int negate = 0, int ai0 = 0) + { + if (negate == 0) + { + negate = Projectile.spriteDirection; + } + if (amount == 0) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, (Projectile.rotation + negate * MathHelper.ToRadians(45 - negate * 90)).ToRotationVector2() * velocity, type, (int)(Projectile.damage * damagemod), Projectile.knockBack, Projectile.owner, ai0); + return; + } + amount += 1; + if (timer % (swingTime / amount) == 0 && timer > 0 && timer < swingTime - swingTime / amount / 2) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, (Projectile.rotation + negate * MathHelper.ToRadians(45 - negate * 90)).ToRotationVector2() * velocity, type, (int)(Projectile.damage * damagemod), Projectile.knockBack, Projectile.owner, ai0); + } + } + #endregion + } + +} diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 4d91d08a39..cf00086d09 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -19,6 +19,7 @@ using CalamityMod.NPCs.NormalNPCs; using CalamityMod.NPCs.PlagueEnemies; using CalamityMod.Particles; using CalamityMod.Projectiles.Boss; +using CalamityMod.Projectiles.Healing; using CalamityMod.Projectiles.Melee; using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Rogue; @@ -282,6 +283,8 @@ namespace CalamityMod.Projectiles /// public float UpdatePriority = 0f; + public int BloodstoneOrbValue = 0; + #region On Spawn public override void OnSpawn(Projectile projectile, IEntitySource source) @@ -4222,6 +4225,11 @@ namespace CalamityMod.Projectiles #region On Hit NPC public override void OnHitNPC(Projectile projectile, NPC target, NPC.HitInfo hit, int damageDone) { + for (var i = 0; i < BloodstoneOrbValue; i++) + { + Projectile.NewProjectile(projectile.GetSource_OnHit(target), projectile.Center, projectile.velocity.SafeNormalize(Vector2.Zero) * Math.Min(((projectile.velocity.Length() * projectile.MaxUpdates) / 4f), 4f) * Main.rand.NextFloat(0.75f, 1.25f), ModContent.ProjectileType(), 1, 0f, Main.player[projectile.owner].whoAmI); + + } // Hyperius Overflow if (projectile.type != ProjectileType() && projectile.type != ProjectileType() && projectile.type != ProjectileType() && projectile.type != ProjectileType() && target.Calamity().hyperiusMarked) { diff --git a/Projectiles/Healing/BloodstoneHealOrb.cs b/Projectiles/Healing/BloodstoneHealOrb.cs new file mode 100644 index 0000000000..f87cc69824 --- /dev/null +++ b/Projectiles/Healing/BloodstoneHealOrb.cs @@ -0,0 +1,155 @@ +using System; +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.Healing +{ + public class BloodstoneHealOrb : ModProjectile, ILocalizedModType //Modified copy from SanguineHealOrb + { + public new string LocalizationCategory => "Projectiles.Healing"; + + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public int target = -1; + public ref int heal => ref Projectile.damage; + + public int spawnCooldown = 60; //how many frames must pass before it can be picked up + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailingMode[Type] = 0; + ProjectileID.Sets.TrailCacheLength[Type] = 20; + } + + public override void SetDefaults() + { + Projectile.width = 8; + Projectile.height = 8; + Projectile.ignoreWater = true; + Projectile.alpha = 255; + Projectile.penetrate = 1; + Projectile.tileCollide = false; + Projectile.extraUpdates = 3; + Projectile.timeLeft = 60 * 5 * Projectile.MaxUpdates; + spawnCooldown *= Projectile.MaxUpdates; + } + + public override void AI() + { + if ((true)) + { + float particleSize = 0.9f + 0.15f * (float)Math.Cos(Main.GlobalTimeWrappedHourly % 60f * MathHelper.TwoPi); + if (Projectile.timeLeft <= 60) //Shrinks to nothing when projectile is nearing death + { + particleSize *= Projectile.timeLeft / 60f; + } + particleSize *= 8f; + Particle beam3 = new CustomSpark(Projectile.Center + Projectile.Size / 2f, -Projectile.velocity * 0.1f, "CalamityMod/Particles/PearlParticleGlow", false, 10, 0.05f * particleSize, Color.DarkRed, new Vector2(0.5f, 1), false, false, 0, false, false, 0f); + GeneralParticleHandler.SpawnParticle(beam3); + + if (Main.rand.NextBool(8)) + { + Particle beam4 = new CustomSpark(Projectile.Center + Projectile.Size / 2f, Projectile.velocity * 0.1f, "CalamityMod/Particles/WaterFoam", false, 5, 0.01f * particleSize, Color.Red, new Vector2(1f, 1), true, false, Main.rand.NextFloat(-10, 10), false, false, 0f); + GeneralParticleHandler.SpawnParticle(beam4); + } + + } + Projectile.scale = MathHelper.Lerp(1, 1, 0.65f); + float maxDistance = 200f; + if (spawnCooldown > 0) + { + PassiveBehavior(); + spawnCooldown--; + return; + } + if (target < 0) + { + PassiveBehavior(); + if (Projectile.FinalExtraUpdate()) for (int playerIndex = 0; playerIndex < Main.maxPlayers; playerIndex++) + { + Player player = Main.player[playerIndex]; + if (player.lifeMagnet) + maxDistance *= 1.5f; //Heartreach gives 50% more range + float targetDist = Vector2.Distance(player.Center, Projectile.Center); + if (targetDist < maxDistance) + { + maxDistance = targetDist; + target = playerIndex; + } + } + } + else HealHome(); + } + + public void PassiveBehavior() + { + Projectile.velocity *= 0.99f; + } + + public void HealHome() + { + Player player = Main.player[target]; + Vector2 playerVector = player.Center - Projectile.Center; + float playerDist = playerVector.Length(); + if (playerDist < 50f && Projectile.position.X < player.position.X + player.width && Projectile.position.X + Projectile.width > player.position.X && Projectile.position.Y < player.position.Y + player.height && Projectile.position.Y + Projectile.height > player.position.Y) + { + AdjustedHeal(player, heal); + Projectile.Kill(); + } + + Projectile.velocity = (Projectile.velocity * 5 + (playerVector.SafeNormalize(Vector2.Zero) * 5)) / 6f; //Move towards player. Range is determined in the AI(); + } + + public void AdjustedHeal(Player player, int heal) + { + var cplayer = player.Calamity(); + if (player.potionDelay > 0) + { + player.potionDelay -= 20; + if (player.potionDelay < 0) + player.potionDelay = 0; + if (player.HasBuff(BuffID.PotionSickness)) + { + for (var i = 0; i < player.buffType.Length; i++) + { + if (player.buffType[i] == BuffID.PotionSickness) + { + player.buffTime[i] = player.potionDelay; + } + } + } + } + else + { + player.lifeRegenTime += 60; //if Potion Sickness is full, each orb speeds up natural regen by 1 second + } + } + + public override bool PreDraw(ref Color lightColor) + { + for (int i = 0; i < Projectile.oldPos.Length; i++) + { + float particleSize = 0.9f + 0.15f * (float)Math.Cos(Main.GlobalTimeWrappedHourly % 60f * MathHelper.TwoPi); + particleSize *= MathHelper.Lerp(0.15f, 1f, 1f - i / (float)Projectile.oldPos.Length); + if (Projectile.timeLeft <= 60) //Shrinks to nothing when projectile is nearing death + { + particleSize *= Projectile.timeLeft / 60f; + } + Particle beam3 = new CustomSpark(Projectile.oldPos[i] + Projectile.Size / 2f, -Projectile.velocity * 0.1f, "CalamityMod/Particles/PearlParticleGlow", false, 10, 0.05f * particleSize, Color.DarkRed, new Vector2(0.5f, 1), false, false, 0, false, false, 0f); + GeneralParticleHandler.SpawnParticle(beam3); + + if (Main.rand.NextBool(8)) + { + Particle beam4 = new CustomSpark(Projectile.oldPos[i] + Projectile.Size / 2f, Projectile.velocity * 0.1f, "CalamityMod/Particles/WaterFoam", false, 5, 0.01f * particleSize, Color.Red, new Vector2(1f, 1), true, false, Main.rand.NextFloat(-10, 10), false, false, 0f); + GeneralParticleHandler.SpawnParticle(beam4); + } + } + return false; + } + } +} diff --git a/Projectiles/Magic/SanguineFlareProj.cs b/Projectiles/Magic/SanguineFlareProj.cs index 4926c62ddd..898ff2d51d 100644 --- a/Projectiles/Magic/SanguineFlareProj.cs +++ b/Projectiles/Magic/SanguineFlareProj.cs @@ -2,7 +2,11 @@ using CalamityMod.Balancing; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Healing; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -13,10 +17,8 @@ namespace CalamityMod.Projectiles.Magic public class SanguineFlareProj : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; - private int x; - private double speed = 10; - private float startSpeedY = 0f; - + public bool beingChanneled = true; + public float dmgMult = 1; public override void SetStaticDefaults() { ProjectileID.Sets.TrailCacheLength[Type] = 4; @@ -25,43 +27,64 @@ namespace CalamityMod.Projectiles.Magic public override void SetDefaults() { - Projectile.width = 10; - Projectile.height = 10; + Projectile.width = 30; + Projectile.height = 30; Projectile.friendly = true; Projectile.penetrate = 1; Projectile.tileCollide = false; Projectile.timeLeft = 600; Projectile.alpha = 255; Projectile.DamageType = DamageClass.Magic; + Projectile.extraUpdates = 19; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; } public override void AI() { - Lighting.AddLight(Projectile.Center, 1f, 0f, 0f); - if (Projectile.localAI[0] == 0f) + var player = Main.player[Projectile.owner]; + if (beingChanneled && player.channel) { - Projectile.velocity.X = Projectile.velocity.X + (Main.player[Projectile.owner].velocity.X * 0.5f); - startSpeedY = Projectile.velocity.Y + (Main.player[Projectile.owner].velocity.Y * 0.5f); - Projectile.velocity.Y = startSpeedY; - } - Projectile.localAI[0] += 1f; - if (Projectile.localAI[0] >= 180f) - { - x++; - speed += 0.1; - Projectile.velocity.Y = startSpeedY + (float)(speed * Math.Sin(x / 4)); - } - Projectile.rotation += Projectile.velocity.Y * 0.02f; - Projectile.alpha -= 5; - if (Projectile.alpha < 30) - { - Projectile.alpha = 30; - } - } + Projectile.velocity = Vector2.Zero; + Projectile.timeLeft = 300 * Projectile.MaxUpdates; + if (Projectile.FinalExtraUpdate()) + { + player.itemTime = 15; + player.SetItemAnimation(15); + var dir = player.Center.DirectionTo(player.ClampedMouseWorld()) * 64; + player.direction = dir.X >= 0 ? 1 : -1; + Projectile.direction = player.direction; + player.itemRotation = (dir * player.direction).ToRotation(); + Projectile.Center = player.Center + player.Center.DirectionTo(player.ClampedMouseWorld()) * 64; + dmgMult *= 1.009f; + if (dmgMult >= 5f) + { + dmgMult = 5f; + player.channel = false; + } - public override Color? GetAlpha(Color lightColor) - { - return new Color(200, 60, 60, Projectile.alpha); + } + + } else + { + if (beingChanneled) + { + Projectile.damage = (int)(Projectile.damage * dmgMult); + Projectile.velocity = player.MountedCenter.DirectionTo(player.ClampedMouseWorld())*4; + Projectile.extraUpdates = 19; + beingChanneled = false; + } + + float particleSize = (dmgMult * 5 + 5)/2f; + Particle beam3 = new CustomSpark(Projectile.Center, -Projectile.velocity * 0.1f, "CalamityMod/Particles/PearlParticleGlow", false, 10, 0.05f * particleSize, Color.DarkRed, new Vector2(0.5f, 1), false, false, 0, false, false, 0f); + GeneralParticleHandler.SpawnParticle(beam3); + + if (Main.rand.NextBool(8)) + { + Particle beam4 = new CustomSpark(Projectile.Center, Projectile.velocity * 0.1f, "CalamityMod/Particles/WaterFoam", false, 5, 0.01f * particleSize, Color.Red, new Vector2(1f, 1), true, false, Main.rand.NextFloat(-10, 10), false, false, 0f); + GeneralParticleHandler.SpawnParticle(beam4); + } + } } public override void OnKill(int timeLeft) @@ -95,23 +118,74 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 60); - - int heal = (int)Math.Round(hit.Damage * 0.025); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (Main.LocalPlayer.lifeSteal <= 0f || heal <= 0 || target.lifeMax <= 5) + //target.AddBuff(ModContent.BuffType(), 360); + if (beingChanneled || Projectile.penetrate == -1) return; - - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], heal, ProjectileID.VampireHeal, BalancingConstants.LifeStealRange); + var player = Main.player[Projectile.owner]; + float orbCount = MathHelper.Lerp(0, 20, (dmgMult-1) / 4f); + for (var i = 0; i < orbCount; i++) + { + Projectile.NewProjectile(Projectile.GetSource_OnHit(target), Projectile.Center, Projectile.velocity.RotatedByRandom(1) * Main.rand.NextFloat(0.75f, 1.25f), ModContent.ProjectileType(), 1, 0f, player.whoAmI); + } + if (dmgMult > 1) + { + Projectile.position = Projectile.Center; + Projectile.Size *= dmgMult * 1.5f; + Projectile.Center = Projectile.position; + Projectile.penetrate = -1; + Projectile.extraUpdates = 0; + Projectile.timeLeft = 20; + Projectile.velocity *= 0; + Particle bloodsplosion = new CustomPulse(Projectile.Center, Vector2.Zero, Color.DarkRed*0.5f, "CalamityMod/Particles/DetailedExplosion", Vector2.One, Main.rand.NextFloat(-15f, 15f), 0.16f*dmgMult/5f, 0.87f * dmgMult / 5f, (int)(Viscera.BoomLifetime * 0.38f), false); + GeneralParticleHandler.SpawnParticle(bloodsplosion); + Particle bloodsplosion2 = new CustomPulse(Projectile.Center, Vector2.Zero, new Color(255, 32, 32)*0.5f, "CalamityMod/Particles/DustyCircleHardEdge", Vector2.One, Main.rand.NextFloat(-15f, 15f), 0.03f * dmgMult / 5f, 0.155f * dmgMult / 5f, Viscera.BoomLifetime); + GeneralParticleHandler.SpawnParticle(bloodsplosion2); + } } public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 60); public override bool PreDraw(ref Color lightColor) { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); + if (beingChanneled) + { + + Texture2D lightTexture = ModContent.Request("CalamityMod/ExtraTextures/SmallGreyscaleCircle").Value; + for (int i = 0; i < 1; i++) + { + //Photoviscerator drawcode, edited slightly + float colorInterpolation = (float)Math.Cos(Projectile.timeLeft / 32f + dmgMult / 20f + i / (float)Projectile.oldPos.Length * MathHelper.Pi) * 0.5f + 0.5f; + Color color = Color.Lerp(Color.Red, Color.DarkRed, colorInterpolation) * 0.8f; + color.A = 0; + Vector2 drawPosition = Projectile.oldPos[i]+Projectile.Size /2f + lightTexture.Size() * 0.5f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY) + new Vector2(-32.5f, -32.5f); //Last vector is to offset the circle so that it is displayed where the hitbox actually is, instead of a bit down and to the right. + Color outerColor = color; + Color innerColor = color * 0.5f; + float intensity = 0.9f + 0.15f * (float)Math.Cos(dmgMult * MathHelper.TwoPi); + intensity *= MathHelper.Lerp(0.15f, 1f, 1f - i / (float)Projectile.oldPos.Length); + if (Projectile.timeLeft <= 60) //Shrinks to nothing when projectile is nearing death + { + intensity *= Projectile.timeLeft / 60f; + } + // Become smaller the futher along the old positions we are. + Vector2 outerScale = new Vector2(1f) * Projectile.scale * intensity; + Vector2 innerScale = new Vector2(1f) * Projectile.scale * intensity * 0.7f; + outerColor *= intensity; + innerColor *= intensity; + Main.EntitySpriteDraw(lightTexture, drawPosition, null, outerColor, 0f, lightTexture.Size() * 0.5f, outerScale * dmgMult * 0.25f, SpriteEffects.None, 0); + Main.EntitySpriteDraw(lightTexture, drawPosition, null, innerColor, 0f, lightTexture.Size() * 0.5f, innerScale * dmgMult * 0.25f, SpriteEffects.None, 0); + } + } + + + /*if (Main.rand.NextBool(6) && Projectile.ai[1] == 0f) + { + Color smokeColor = Main.rand.NextBool() ? Color.Red : Color.Firebrick; + Vector2 smokePosition = Projectile.Center + Main.rand.NextVector2Circular(5 + Time * 0.3f, 5 + Time * 0.3f); + float smokeScale = Main.rand.NextFloat(0.5f, 1.6f); + float smokeOpacity = 170 + -Time * 0.6f; + Particle smoke = new MediumMistParticle(smokePosition, Vector2.Zero, smokeColor, Color.Black, smokeScale, smokeOpacity, Main.rand.NextFloat(0.2f, -0.2f)); + GeneralParticleHandler.SpawnParticle(smoke); + }*/ return false; } } diff --git a/Projectiles/Melee/TheMutilatorHoldoutProjectile.cs b/Projectiles/Melee/TheMutilatorHoldoutProjectile.cs new file mode 100644 index 0000000000..3117c4212a --- /dev/null +++ b/Projectiles/Melee/TheMutilatorHoldoutProjectile.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CalamityMod.Items.Weapons.Melee; +using Microsoft.Xna.Framework; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria; +using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.Healing; +using Terraria.Audio; +using Terraria.IO; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Particles; + +namespace CalamityMod.Projectiles.Melee +{ + public class MutilatorSwordProj : BaseSwordHoldoutProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Melee"; + public override int swingWidth => 180; + public override string Texture => ModContent.GetModItem(BaseItem.type).Texture; + public override Item BaseItem => ModContent.GetModItem(ModContent.ItemType()).Item; + public override int AfterImageLength => 5; + public override int OffsetDistance => 60; + public override bool drawSwordTrail => true; + public override Color[] trailColors => [Color.Red, Color.DarkRed, Color.Gold]; + + public override float trailOffset => 30; + + public override float trailWidth(float completion) + { + return base.trailWidth(completion); + } + + public override int trailLength => 5; + + public override int StartupTime { get; set; } + public override int CooldownTime { get; set; } + + public bool hasGivenBlood = false; + + public override void Spawn(IEntitySource source) + { + var player = Main.player[Projectile.owner]; + var modplayer = player.GetModPlayer(); + StartupTime = 15; + CooldownTime = 5; + swingTime -= StartupTime + CooldownTime; + modplayer.swingNum = 0; + } + + public override void AdditionalAI() + { + Projectile.scale = baseScale * Math.Min(MathHelper.SmoothStep(1, 2, swingTimer / (float)swingTime), MathHelper.SmoothStep(2, 1, swingTimer / (float)swingTime)); + } + + public override float SwingFunction() + { + return MathHelper.ToRadians(MathHelper.SmoothStep(-swingWidth / 4 * 3, swingWidth / 4, swingTimer / (float)swingTime)); + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 60); + var player = Main.player[Projectile.owner]; + var item = player.HeldItem; + if (item.type != ModContent.ItemType()) + { + Projectile.Kill(); + return; + } + var modItem = item.ModItem as TheMutilator; + if (!hasGivenBlood) + { + modItem.Charge++; + hasGivenBlood = true; + if (modItem.Charge > TheMutilator.MaximumCharge) + { + modItem.Charge = 0; + int healAmount = 1; + int orbAmount = 30; + if (orbAmount > 0) + { + float spreadAmount = MathHelper.ToRadians(360); + for (var i = 0; i < orbAmount; i++) + { + Projectile.NewProjectile(Projectile.GetSource_OnHit(target), target.Center, -angle.RotatedByRandom(spreadAmount) * 3.5f * Main.rand.NextFloat(0.75f, 1.25f), ModContent.ProjectileType(), healAmount, 0f, player.whoAmI); + + } + Particle bloodsplosion2 = new CustomPulse(target.Center, Vector2.Zero, new Color(255, 32, 32) * 0.75f, "CalamityMod/Particles/DustyCircleHardEdge", Vector2.One, Main.rand.NextFloat(-15f, 15f), 0.03f, 0.155f, 40); + GeneralParticleHandler.SpawnParticle(bloodsplosion2); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/BloodPactCrit") { Volume = 0.5f }, player.Center); + } + } + modItem.DecayTimer = 180; + } + } + } +} diff --git a/Projectiles/Ranged/BloodfireArrowProj.cs b/Projectiles/Ranged/BloodfireArrowProj.cs index 5c271827d0..4ccc6336d3 100644 --- a/Projectiles/Ranged/BloodfireArrowProj.cs +++ b/Projectiles/Ranged/BloodfireArrowProj.cs @@ -18,6 +18,9 @@ namespace CalamityMod.Projectiles.Ranged { public new string LocalizationCategory => "Projectiles.Ranged"; + //Used by Arterial Assault + public bool DisableEffects = false; + public override string Texture => "CalamityMod/Items/Ammo/BloodfireArrow"; public override void SetStaticDefaults() @@ -47,14 +50,22 @@ namespace CalamityMod.Projectiles.Ranged if (Projectile.localAI[0] == 0) { - Projectile.damage = (int)(Projectile.damage * 1.3f); // damage boost - player.statLife -= 1; - if (player.statLife <= 0) + if (DisableEffects) { - PlayerDeathReason pdr = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.BloodFireArrow" + Main.rand.Next(1, 2 + 1)).ToNetworkText(player.name)); - player.KillMe(pdr, 1000.0, 0, false); + + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * 9; + } else + { + Projectile.damage = (int)(Projectile.damage * 1.3f); // damage boost + player.statLife -= 1; + if (player.statLife <= 0) + { + PlayerDeathReason pdr = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.BloodFireArrow" + Main.rand.Next(1, 2 + 1)).ToNetworkText(player.name)); + player.KillMe(pdr, 1000.0, 0, false); + } + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * 9; } - Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * 9; + } Player Owner = Main.player[Projectile.owner]; @@ -101,6 +112,8 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { + if (DisableEffects) + return; Player player = Main.player[Projectile.owner]; player.lifeRegenTime += 2; diff --git a/Projectiles/Rogue/BloodsoakedCrashax.cs b/Projectiles/Rogue/BloodsoakedCrashax.cs index 4884fc3f27..b894edd6e7 100644 --- a/Projectiles/Rogue/BloodsoakedCrashax.cs +++ b/Projectiles/Rogue/BloodsoakedCrashax.cs @@ -6,6 +6,10 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Healing; +using System.Reflection.Metadata; +using Terraria.Audio; namespace CalamityMod.Projectiles.Rogue { public class BloodsoakedCrashax : ModProjectile, ILocalizedModType @@ -109,7 +113,7 @@ namespace CalamityMod.Projectiles.Rogue int projID = ModContent.ProjectileType(); int bloodDamage = Projectile.damage; float bloodKB = 1f; - int stealth = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, projID, bloodDamage, bloodKB, Projectile.owner, 1f, 0.85f + Main.rand.NextFloat() * 1.15f); + int stealth = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.UnitX.RotatedByRandom(MathHelper.TwoPi)*4f, projID, bloodDamage, bloodKB, Projectile.owner, 1f, 0.85f + Main.rand.NextFloat() * 1.15f); if (stealth.WithinBounds(Main.maxProjectiles)) { Main.projectile[stealth].DamageType = RogueDamageClass.Instance; @@ -117,14 +121,16 @@ namespace CalamityMod.Projectiles.Rogue } } - int heal = (int)Math.Round(damage * 0.01); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; + float orbAmount = Projectile.Calamity().stealthStrike ? 3 : Projectile.penetrate % 2; + if (orbAmount > 0) + { + float spreadAmount = MathHelper.ToRadians(360); + for (var i = 0; i < orbAmount; i++) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.One.RotatedByRandom(spreadAmount) * 2f * Main.rand.NextFloat(0.75f, 1.25f), ModContent.ProjectileType(), 1, 0f, Projectile.owner); - if (Main.LocalPlayer.lifeSteal <= 0f || heal <= 0) - return; - - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], heal, ProjectileID.VampireHeal, BalancingConstants.LifeStealRange); + } + } } public override bool PreDraw(ref Color lightColor) //afterimages diff --git a/Projectiles/Summon/BloodSpit.cs b/Projectiles/Summon/BloodSpit.cs index 1a0908f86e..057b6387c2 100644 --- a/Projectiles/Summon/BloodSpit.cs +++ b/Projectiles/Summon/BloodSpit.cs @@ -28,6 +28,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 6; Projectile.DamageType = DamageClass.Summon; + Projectile.Calamity().BloodstoneOrbValue = 1; //Bloodstone Orb lifesteal. May want to go back to regular lifesteal. } public override void AI() @@ -49,8 +50,8 @@ namespace CalamityMod.Projectiles.Summon blood.velocity = Main.rand.NextVector2Circular(1f, 2f); blood.noGravity = true; } - - int heal = (int)Math.Round(hit.Damage * 0.01); + //regular lifesteal code. Not sure if we wanna go back to it so I left it here. + /*int heal = (int)Math.Round(hit.Damage * 0.01); if (heal > BalancingConstants.LifeStealCap) heal = BalancingConstants.LifeStealCap; @@ -58,6 +59,7 @@ namespace CalamityMod.Projectiles.Summon return; CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], heal, ProjectileID.VampireHeal, BalancingConstants.LifeStealRange); + */ } } }