From 98247ca38342eee8fa4138a2248ec771661bd467 Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Sun, 22 Nov 2020 15:24:11 -0500 Subject: [PATCH] removed rogue stellar contempt --- Items/Weapons/Melee/StellarContemptMelee.cs | 16 +- Items/Weapons/Rogue/StellarContemptRogue.cs | 64 ----- Items/Weapons/Rogue/StellarContemptRogue.png | Bin 1785 -> 0 bytes Projectiles/Hybrid/StellarContemptHammer.cs | 261 ------------------- Projectiles/Melee/StellarContemptHammer.cs | 254 ++++++++++++++++++ 5 files changed, 258 insertions(+), 337 deletions(-) delete mode 100644 Items/Weapons/Rogue/StellarContemptRogue.cs delete mode 100644 Items/Weapons/Rogue/StellarContemptRogue.png delete mode 100644 Projectiles/Hybrid/StellarContemptHammer.cs create mode 100644 Projectiles/Melee/StellarContemptHammer.cs diff --git a/Items/Weapons/Melee/StellarContemptMelee.cs b/Items/Weapons/Melee/StellarContemptMelee.cs index 793eb2f920..f339a04d03 100644 --- a/Items/Weapons/Melee/StellarContemptMelee.cs +++ b/Items/Weapons/Melee/StellarContemptMelee.cs @@ -1,12 +1,11 @@ -using CalamityMod.Projectiles.Hybrid; -using Microsoft.Xna.Framework; +using CalamityMod.Projectiles.Melee; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class StellarContemptMelee : ModItem + public class StellarContemptMelee : ModItem { public static int BaseDamage = 250; public static float Speed = 18f; @@ -33,21 +32,14 @@ namespace CalamityMod.Items.Weapons.Melee item.useStyle = ItemUseStyleID.SwingThrow; item.UseSound = SoundID.Item1; - item.rare = 10; + item.rare = ItemRarityID.Red; item.Calamity().customRarity = CalamityRarity.Turquoise; - item.value = Item.buyPrice(1, 20, 0, 0); + item.value = Item.buyPrice(platinum: 1, gold: 20); item.shoot = ModContent.ProjectileType(); item.shootSpeed = Speed; } - public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) - { - int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - Main.projectile[proj].Calamity().forceMelee = true; - return false; - } - public override void AddRecipes() { ModRecipe r = new ModRecipe(mod); diff --git a/Items/Weapons/Rogue/StellarContemptRogue.cs b/Items/Weapons/Rogue/StellarContemptRogue.cs deleted file mode 100644 index be5b13af4d..0000000000 --- a/Items/Weapons/Rogue/StellarContemptRogue.cs +++ /dev/null @@ -1,64 +0,0 @@ -using CalamityMod.Projectiles.Hybrid; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Rogue -{ - public class StellarContemptRogue : RogueWeapon - { - public static int BaseDamage = 250; - public static float Speed = 18f; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Stellar Contempt"); - Tooltip.SetDefault("Lunar flares rain down on enemy hits"); - } - - public override void SafeSetDefaults() - { - item.width = 66; - item.height = 64; - item.damage = BaseDamage; - item.knockBack = 9f; - item.useTime = 13; - item.useAnimation = 13; - item.autoReuse = true; - item.noMelee = true; - item.noUseGraphic = true; - - item.useStyle = ItemUseStyleID.SwingThrow; - item.UseSound = SoundID.Item1; - - item.rare = 10; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.value = Item.buyPrice(1, 20, 0, 0); - - item.Calamity().rogue = true; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = Speed; - } - - public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) - { - int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - Main.projectile[proj].Calamity().forceRogue = true; - Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); - return false; - } - - public override void AddRecipes() - { - ModRecipe r = new ModRecipe(mod); - r.SetResult(this); - r.AddIngredient(ModContent.ItemType()); - r.AddIngredient(ItemID.LunarBar, 5); - r.AddIngredient(ItemID.FragmentSolar, 10); - r.AddIngredient(ItemID.FragmentNebula, 10); - r.AddTile(TileID.LunarCraftingStation); - r.AddRecipe(); - } - } -} diff --git a/Items/Weapons/Rogue/StellarContemptRogue.png b/Items/Weapons/Rogue/StellarContemptRogue.png deleted file mode 100644 index d77b953151999a3faf5f93443b67d31e3c6cb1d8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1785 zcmVPx*vq?ljRCt{2n_X;FMHI(>ce`yVRVW3@Qd&_yjO9Zzy>++%McIV_3dK+E-WWA#Xu0wRo@Ob?(W{9V}zz@+*D7vSQT zO#l?ty=ArU-}^lPVJFK0=ywMa_M2|+2#7Gsm`7-IP*0d%Uu2P>$~)a=zc-%I-q(>Z znmiOLb^vl`O4JEESpam$daQPLOH4q7QQC=65}bK60dVWC3kip864V=d%H@6J$W;KM z=JT`bmRRi%{!#|Op6FpK+O+p|08kj3;sA8SZjI`>10syl7B!M(jNxq?0BB$J8342Q zZ3LjFJOT_M;pQ~}b`Pw#`rVOr)OxQ3C^2sw&j#S+zYPFnJ7EW)&+WJFOXV2>5k_hE z2qi(k!yV@OqdT4fply?oP`LjD;CX_Qpajgxngc+nKnQ!Vv&0%_>biXS;kfirlswvu zi28sCqqKVj$Qq(#=3)T4=Hvn}`ARR~d4cK`=Scv*c7FmOG*t+QluFcTYrZb8ZFaul zk1Ex*%>eXN3Q4z*i)V~9Lk);9$`}!;v~ofP09OXC03Hc9UzF?9zL6P?{Usit(Zau4 z{qTm2dpaz`9+`R`@W|8qhRFJz10sCN1QE%UFe8jaB#NXWVM60e0Q4X1wmQ}J{-~m) zsZx;<5Mh+DdW4@4T_yIr11@+ZRIFNVwX6UBWWxS58eHA_Ef8PFSX3vT(Ap%Ks^%eE zqw@jJL-s@u15ieh18@OZ9S1}hWt@mgN&%>+*@`AhS1bddq(t(ChPp-o!p?N7AI(El znvb+?nr&TIuQ6ELV1B67fq;lXWsHc2i&p^99qVxcz6xyyytPE} zQkhZB9Q`CDoAK_sc67+U+ycatp!JKLyZ%V{e4p%k0Ps8`Ai^kP6{@J)2Y7kI;;P>O z2%XPKc%SZPX#2wb_L`*IL=9D5z2pfWYyD!O^sgSU^Mk8a`xoAqyhNi&xo`Y{2&1$U zksrzfJa6zaI*A?)+hk@d_R5TE2C33DhhFb^bG7xk)-n8*EY;c+BxpYI+7lO~!7(## z%HQmNqO=jA-Y_s}0suwbLWX8|)wM!E zy_pmZXagh7JljtR5vyYJ053DGSyO7YR}z#wC850EPM(#7s%d!+KJ3_Vs0z(> z04`?9Zn=`63WzXDn@1=Ky2FLoImoAZ;my^qpTG1s$FCuy**kCp^gK!i~o5y^J7 zb8@7Xs3iDzsoCY96JL*+5NK0yKvh+Bb_PT>uLRf2qR}!WRW%V#d(s+wf3~T02`iv8t~37RBl)a zc)Qnn`mO2InYg}T?EWX~UKJ2wG#E8Bhu_n4*oq1|^SXKrZMV-sDhYWL#S?n&jEyIx zTLBS9ae0KEXsxc5Jw&Z0M|M94K*g)_KU!aW^r>~9k}zI8!LNV_BWG>#Qvh6w$r&gA z8RzxqZvd&IgDN0moXgS7vbspB&^7H{R((OGHNa%iVZ4%{3WzWo{C=l87wNxeyc6J8 bK!nkMtl^9V%DiJH00000NkvXXu0mjf`=Ued diff --git a/Projectiles/Hybrid/StellarContemptHammer.cs b/Projectiles/Hybrid/StellarContemptHammer.cs deleted file mode 100644 index 9186fb7da8..0000000000 --- a/Projectiles/Hybrid/StellarContemptHammer.cs +++ /dev/null @@ -1,261 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Weapons.Melee; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Hybrid -{ - public class StellarContemptHammer : ModProjectile - { - public override string Texture => "CalamityMod/Items/Weapons/Melee/StellarContemptMelee"; - - private static float RotationIncrement = 0.22f; - private static int Lifetime = 240; - private static float ReboundTime = 26f; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Stellar Contempt"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 8; - ProjectileID.Sets.TrailingMode[projectile.type] = 1; - } - - public override void SetDefaults() - { - projectile.width = 44; - projectile.height = 44; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.penetrate = -1; - projectile.extraUpdates = 3; - projectile.timeLeft = Lifetime; - } - - public override void AI() - { - drawOffsetX = -11; - drawOriginOffsetY = -10; - drawOriginOffsetX = 0; - - Lighting.AddLight(projectile.Center, 0.7f, 0.3f, 0.6f); - - // The hammer makes sound while flying. - if (projectile.soundDelay == 0) - { - projectile.soundDelay = 8; - Main.PlaySound(SoundID.Item7, (int)projectile.position.X, (int)projectile.position.Y); - } - - // ai[0] stores whether the hammer is returning. If 0, it isn't. If 1, it is. - if (projectile.ai[0] == 0f) - { - projectile.ai[1] += 1f; - if (projectile.ai[1] >= ReboundTime) - { - projectile.ai[0] = 1f; - projectile.ai[1] = 0f; - projectile.netUpdate = true; - } - } - else - { - projectile.tileCollide = false; - float returnSpeed = StellarContemptMelee.Speed; - float acceleration = 3.2f; - Player owner = Main.player[projectile.owner]; - - // Delete the hammer if it's excessively far away. - Vector2 playerCenter = owner.Center; - float xDist = playerCenter.X - projectile.Center.X; - float yDist = playerCenter.Y - projectile.Center.Y; - float dist = (float)Math.Sqrt((double)(xDist * xDist + yDist * yDist)); - if (dist > 3000f) - projectile.Kill(); - - dist = returnSpeed / dist; - xDist *= dist; - yDist *= dist; - - // Home back in on the player. - if (projectile.velocity.X < xDist) - { - projectile.velocity.X = projectile.velocity.X + acceleration; - if (projectile.velocity.X < 0f && xDist > 0f) - projectile.velocity.X += acceleration; - } - else if (projectile.velocity.X > xDist) - { - projectile.velocity.X = projectile.velocity.X - acceleration; - if (projectile.velocity.X > 0f && xDist < 0f) - projectile.velocity.X -= acceleration; - } - if (projectile.velocity.Y < yDist) - { - projectile.velocity.Y = projectile.velocity.Y + acceleration; - if (projectile.velocity.Y < 0f && yDist > 0f) - projectile.velocity.Y += acceleration; - } - else if (projectile.velocity.Y > yDist) - { - projectile.velocity.Y = projectile.velocity.Y - acceleration; - if (projectile.velocity.Y > 0f && yDist < 0f) - projectile.velocity.Y -= acceleration; - } - - // Delete the projectile if it touches its owner. - if (Main.myPlayer == projectile.owner) - if (projectile.Hitbox.Intersects(owner.Hitbox)) - projectile.Kill(); - } - - // Rotate the hammer as it flies. - projectile.rotation += RotationIncrement; - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1); - return false; - } - - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - // Some dust gets produced on impact. - int dustCount = Main.rand.Next(20, 24); - int dustRadius = 6; - Vector2 corner = new Vector2(target.Center.X - (float)dustRadius, target.Center.Y - (float)dustRadius); - for (int i = 0; i < dustCount; ++i) - { - int dustType = 229; - float scale = 0.8f + Main.rand.NextFloat(1.1f); - int idx = Dust.NewDust(corner, 2 * dustRadius, 2 * dustRadius, dustType); - Main.dust[idx].noGravity = true; - Main.dust[idx].velocity *= 3f; - Main.dust[idx].scale = scale; - } - - // Applies Nightwither on contact at night. - if (!Main.dayTime) - target.AddBuff(ModContent.BuffType(), 480); - - // Do not drop lunar flares on dummies. - if (target.type == NPCID.TargetDummy) - return; - - // Play the Lunar Flare sound centered on the user, not the target (consistent with Lunar Flare and Stellar Striker) - Player user = Main.player[projectile.owner]; - Main.PlaySound(SoundID.Item88, projectile.position); - projectile.netUpdate = true; - - int numFlares = 2; - int flareDamage = (int)(0.3f * projectile.damage); - float flareKB = 4f; - for (int i = 0; i < numFlares; ++i) - { - float flareSpeed = Main.rand.NextFloat(8f, 11f); - - // Flares never come from straight up, there is always at least an 80 pixel horizontal offset - float xDist = Main.rand.NextFloat(80f, 320f) * (Main.rand.NextBool() ? -1f : 1f); - float yDist = Main.rand.NextFloat(1200f, 1440f); - Vector2 startPoint = target.Center + new Vector2(xDist, -yDist); - - // The flare is somewhat inaccurate based on the size of the target. - float xVariance = target.width / 4f; - if (xVariance < 8f) - xVariance = 8f; - float yVariance = target.height / 4f; - if (yVariance < 8f) - yVariance = 8f; - float xOffset = Main.rand.NextFloat(-xVariance, xVariance); - float yOffset = Main.rand.NextFloat(-yVariance, yVariance); - Vector2 offsetTarget = target.Center + new Vector2(xOffset, yOffset); - - // Finalize the velocity vector and make sure it's going at the right speed. - Vector2 velocity = offsetTarget - startPoint; - velocity.Normalize(); - velocity *= flareSpeed; - - float AI1 = (float)Main.rand.Next(3); - if (projectile.owner == Main.myPlayer) - { - int proj = Projectile.NewProjectile(startPoint, velocity, ProjectileID.LunarFlare, flareDamage, flareKB, Main.myPlayer, 0f, AI1); - CalamityGlobalProjectile cgp = Main.projectile[proj].Calamity(); - if (projectile.melee) - cgp.forceMelee = true; - else - cgp.forceRogue = true; - } - } - } - - public override void OnHitPvp(Player target, int damage, bool crit) - { - // Some dust gets produced on impact. - int dustCount = Main.rand.Next(20, 24); - int dustRadius = 6; - Vector2 corner = new Vector2(target.Center.X - (float)dustRadius, target.Center.Y - (float)dustRadius); - for (int i = 0; i < dustCount; ++i) - { - int dustType = 229; - float scale = 0.8f + Main.rand.NextFloat(1.1f); - int idx = Dust.NewDust(corner, 2 * dustRadius, 2 * dustRadius, dustType); - Main.dust[idx].noGravity = true; - Main.dust[idx].velocity *= 3f; - Main.dust[idx].scale = scale; - } - - // Applies Nightwither on contact at night. - if (!Main.dayTime) - target.AddBuff(ModContent.BuffType(), 480); - - // Play the Lunar Flare sound centered on the user, not the target (consistent with Lunar Flare and Stellar Striker) - Player user = Main.player[projectile.owner]; - Main.PlaySound(SoundID.Item88, projectile.position); - projectile.netUpdate = true; - - int numFlares = 2; - int flareDamage = (int)(0.3f * projectile.damage); - float flareKB = 4f; - for (int i = 0; i < numFlares; ++i) - { - float flareSpeed = Main.rand.NextFloat(8f, 11f); - - // Flares never come from straight up, there is always at least an 80 pixel horizontal offset - float xDist = Main.rand.NextFloat(80f, 320f) * (Main.rand.NextBool() ? -1f : 1f); - float yDist = Main.rand.NextFloat(1200f, 1440f); - Vector2 startPoint = target.Center + new Vector2(xDist, -yDist); - - // The flare is somewhat inaccurate based on the size of the target. - float xVariance = target.width / 4f; - if (xVariance < 8f) - xVariance = 8f; - float yVariance = target.height / 4f; - if (yVariance < 8f) - yVariance = 8f; - float xOffset = Main.rand.NextFloat(-xVariance, xVariance); - float yOffset = Main.rand.NextFloat(-yVariance, yVariance); - Vector2 offsetTarget = target.Center + new Vector2(xOffset, yOffset); - - // Finalize the velocity vector and make sure it's going at the right speed. - Vector2 velocity = offsetTarget - startPoint; - velocity.Normalize(); - velocity *= flareSpeed; - - float AI1 = (float)Main.rand.Next(3); - if (projectile.owner == Main.myPlayer) - { - int proj = Projectile.NewProjectile(startPoint, velocity, ProjectileID.LunarFlare, flareDamage, flareKB, Main.myPlayer, 0f, AI1); - CalamityGlobalProjectile cgp = Main.projectile[proj].Calamity(); - if (projectile.melee) - cgp.forceMelee = true; - else - cgp.forceRogue = true; - } - } - } - } -} diff --git a/Projectiles/Melee/StellarContemptHammer.cs b/Projectiles/Melee/StellarContemptHammer.cs new file mode 100644 index 0000000000..32c987a62a --- /dev/null +++ b/Projectiles/Melee/StellarContemptHammer.cs @@ -0,0 +1,254 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Weapons.Melee; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee +{ + public class StellarContemptHammer : ModProjectile + { + public override string Texture => "CalamityMod/Items/Weapons/Melee/StellarContemptMelee"; + + private static float RotationIncrement = 0.22f; + private static int Lifetime = 240; + private static float ReboundTime = 26f; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Stellar Contempt"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 8; + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + } + + public override void SetDefaults() + { + projectile.width = 44; + projectile.height = 44; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.extraUpdates = 3; + projectile.timeLeft = Lifetime; + } + + public override void AI() + { + drawOffsetX = -11; + drawOriginOffsetY = -10; + drawOriginOffsetX = 0; + + Lighting.AddLight(projectile.Center, 0.7f, 0.3f, 0.6f); + + // The hammer makes sound while flying. + if (projectile.soundDelay == 0) + { + projectile.soundDelay = 8; + Main.PlaySound(SoundID.Item7, (int)projectile.position.X, (int)projectile.position.Y); + } + + // ai[0] stores whether the hammer is returning. If 0, it isn't. If 1, it is. + if (projectile.ai[0] == 0f) + { + projectile.ai[1] += 1f; + if (projectile.ai[1] >= ReboundTime) + { + projectile.ai[0] = 1f; + projectile.ai[1] = 0f; + projectile.netUpdate = true; + } + } + else + { + projectile.tileCollide = false; + float returnSpeed = StellarContemptMelee.Speed; + float acceleration = 3.2f; + Player owner = Main.player[projectile.owner]; + + // Delete the hammer if it's excessively far away. + Vector2 playerCenter = owner.Center; + float xDist = playerCenter.X - projectile.Center.X; + float yDist = playerCenter.Y - projectile.Center.Y; + float dist = (float)Math.Sqrt(xDist * xDist + yDist * yDist); + if (dist > 3000f) + projectile.Kill(); + + dist = returnSpeed / dist; + xDist *= dist; + yDist *= dist; + + // Home back in on the player. + if (projectile.velocity.X < xDist) + { + projectile.velocity.X = projectile.velocity.X + acceleration; + if (projectile.velocity.X < 0f && xDist > 0f) + projectile.velocity.X += acceleration; + } + else if (projectile.velocity.X > xDist) + { + projectile.velocity.X = projectile.velocity.X - acceleration; + if (projectile.velocity.X > 0f && xDist < 0f) + projectile.velocity.X -= acceleration; + } + if (projectile.velocity.Y < yDist) + { + projectile.velocity.Y = projectile.velocity.Y + acceleration; + if (projectile.velocity.Y < 0f && yDist > 0f) + projectile.velocity.Y += acceleration; + } + else if (projectile.velocity.Y > yDist) + { + projectile.velocity.Y = projectile.velocity.Y - acceleration; + if (projectile.velocity.Y > 0f && yDist < 0f) + projectile.velocity.Y -= acceleration; + } + + // Delete the projectile if it touches its owner. + if (Main.myPlayer == projectile.owner) + if (projectile.Hitbox.Intersects(owner.Hitbox)) + projectile.Kill(); + } + + // Rotate the hammer as it flies. + projectile.rotation += RotationIncrement; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1); + return false; + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + // Some dust gets produced on impact. + int dustCount = Main.rand.Next(20, 24); + int dustRadius = 6; + Vector2 corner = new Vector2(target.Center.X - dustRadius, target.Center.Y - dustRadius); + for (int i = 0; i < dustCount; ++i) + { + int dustType = 229; + float scale = 0.8f + Main.rand.NextFloat(1.1f); + int idx = Dust.NewDust(corner, 2 * dustRadius, 2 * dustRadius, dustType); + Main.dust[idx].noGravity = true; + Main.dust[idx].velocity *= 3f; + Main.dust[idx].scale = scale; + } + + // Applies Nightwither on contact at night. + if (!Main.dayTime) + target.AddBuff(ModContent.BuffType(), 480); + + // Do not drop lunar flares on dummies. + if (target.type == NPCID.TargetDummy) + return; + + // Play the Lunar Flare sound centered on the user, not the target (consistent with Lunar Flare and Stellar Striker) + Player user = Main.player[projectile.owner]; + Main.PlaySound(SoundID.Item88, projectile.position); + projectile.netUpdate = true; + + int numFlares = 2; + int flareDamage = (int)(0.3f * projectile.damage); + float flareKB = 4f; + for (int i = 0; i < numFlares; ++i) + { + float flareSpeed = Main.rand.NextFloat(8f, 11f); + + // Flares never come from straight up, there is always at least an 80 pixel horizontal offset + float xDist = Main.rand.NextFloat(80f, 320f) * (Main.rand.NextBool() ? -1f : 1f); + float yDist = Main.rand.NextFloat(1200f, 1440f); + Vector2 startPoint = target.Center + new Vector2(xDist, -yDist); + + // The flare is somewhat inaccurate based on the size of the target. + float xVariance = target.width / 4f; + if (xVariance < 8f) + xVariance = 8f; + float yVariance = target.height / 4f; + if (yVariance < 8f) + yVariance = 8f; + float xOffset = Main.rand.NextFloat(-xVariance, xVariance); + float yOffset = Main.rand.NextFloat(-yVariance, yVariance); + Vector2 offsetTarget = target.Center + new Vector2(xOffset, yOffset); + + // Finalize the velocity vector and make sure it's going at the right speed. + Vector2 velocity = offsetTarget - startPoint; + velocity.Normalize(); + velocity *= flareSpeed; + + float AI1 = Main.rand.Next(3); + if (projectile.owner == Main.myPlayer) + { + int proj = Projectile.NewProjectile(startPoint, velocity, ProjectileID.LunarFlare, flareDamage, flareKB, Main.myPlayer, 0f, AI1); + CalamityGlobalProjectile cgp = Main.projectile[proj].Calamity(); + cgp.forceMelee = true; + } + } + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + // Some dust gets produced on impact. + int dustCount = Main.rand.Next(20, 24); + int dustRadius = 6; + Vector2 corner = new Vector2(target.Center.X - dustRadius, target.Center.Y - dustRadius); + for (int i = 0; i < dustCount; ++i) + { + int dustType = 229; + float scale = 0.8f + Main.rand.NextFloat(1.1f); + int idx = Dust.NewDust(corner, 2 * dustRadius, 2 * dustRadius, dustType); + Main.dust[idx].noGravity = true; + Main.dust[idx].velocity *= 3f; + Main.dust[idx].scale = scale; + } + + // Applies Nightwither on contact at night. + if (!Main.dayTime) + target.AddBuff(ModContent.BuffType(), 480); + + Main.PlaySound(SoundID.Item88, projectile.position); + projectile.netUpdate = true; + + int numFlares = 2; + int flareDamage = (int)(0.3f * projectile.damage); + float flareKB = 4f; + for (int i = 0; i < numFlares; ++i) + { + float flareSpeed = Main.rand.NextFloat(8f, 11f); + + // Flares never come from straight up, there is always at least an 80 pixel horizontal offset + float xDist = Main.rand.NextFloat(80f, 320f) * (Main.rand.NextBool() ? -1f : 1f); + float yDist = Main.rand.NextFloat(1200f, 1440f); + Vector2 startPoint = target.Center + new Vector2(xDist, -yDist); + + // The flare is somewhat inaccurate based on the size of the target. + float xVariance = target.width / 4f; + if (xVariance < 8f) + xVariance = 8f; + float yVariance = target.height / 4f; + if (yVariance < 8f) + yVariance = 8f; + float xOffset = Main.rand.NextFloat(-xVariance, xVariance); + float yOffset = Main.rand.NextFloat(-yVariance, yVariance); + Vector2 offsetTarget = target.Center + new Vector2(xOffset, yOffset); + + // Finalize the velocity vector and make sure it's going at the right speed. + Vector2 velocity = offsetTarget - startPoint; + velocity.Normalize(); + velocity *= flareSpeed; + + float AI1 = Main.rand.Next(3); + if (projectile.owner == Main.myPlayer) + { + int proj = Projectile.NewProjectile(startPoint, velocity, ProjectileID.LunarFlare, flareDamage, flareKB, Main.myPlayer, 0f, AI1); + CalamityGlobalProjectile cgp = Main.projectile[proj].Calamity(); + cgp.forceMelee = true; + } + } + } + } +}