From 7f877765ebfc5f59f3cb4983ea3a3bb991d59635 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Mon, 13 Jan 2020 23:27:18 -0500 Subject: [PATCH] added seeking scorcher --- Items/Weapons/Melee/DivineHatchet.cs | 50 +++++ Items/Weapons/Melee/DivineHatchet.png | Bin 0 -> 1500 bytes Projectiles/Melee/DivineHatchetBoomerang.cs | 220 +++++++++++++++++++ Projectiles/Melee/DivineHatchetBoomerang.png | Bin 0 -> 1500 bytes 4 files changed, 270 insertions(+) create mode 100644 Items/Weapons/Melee/DivineHatchet.cs create mode 100644 Items/Weapons/Melee/DivineHatchet.png create mode 100644 Projectiles/Melee/DivineHatchetBoomerang.cs create mode 100644 Projectiles/Melee/DivineHatchetBoomerang.png diff --git a/Items/Weapons/Melee/DivineHatchet.cs b/Items/Weapons/Melee/DivineHatchet.cs new file mode 100644 index 0000000000..4a7046c6f1 --- /dev/null +++ b/Items/Weapons/Melee/DivineHatchet.cs @@ -0,0 +1,50 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Melee; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Melee +{ + public class DivineHatchet : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Seeking Scorcher"); + Tooltip.SetDefault("May your enemies burn in hell for the sins they have committed\n" + + "Throws a holy boomerang that seeks out up to three enemies before returning to the player"); + } + + public override void SetDefaults() + { + item.width = 60; + item.damage = 500; + item.noMelee = true; + item.noUseGraphic = true; + item.autoReuse = true; + item.useAnimation = 15; + item.useStyle = 1; + item.useTime = 15; + item.knockBack = 8.5f; + item.UseSound = SoundID.Item1; + item.melee = true; + item.height = 62; + item.value = Item.buyPrice(1, 40, 0, 0); + item.rare = 8; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 14f; + item.Calamity().postMoonLordRarity = 13; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.PossessedHatchet); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ModContent.ItemType(), 9); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/Weapons/Melee/DivineHatchet.png b/Items/Weapons/Melee/DivineHatchet.png new file mode 100644 index 0000000000000000000000000000000000000000..991e07cd78e6244de2628d827a3ecff8580cf3ef GIT binary patch literal 1500 zcmV<21ta>2P)^+5S84%#d${?U`f0oHT~ePbEvdbY17-YQKh(PWDF8}V z@3aAyKQh|_II!m@)xb9;&P-4y4b?*6p^)V!%Y*;=~=fXdgD zH#clO3&2O~%k>+>|HSOCc!DqC@3r-XwPTO)jcP=O1;Ermh6PZ)`z;%wYV{_-Au6Or zf1mvefPMAz)rroZRX;_Fc%FZT*1qG?Mfs|&+Vf!by}3a4~chh>pTD z%4Y)3`W#P{%a;J~!?8bX<5JA1{r=OH0Bqb*V*>;-)eQ3pr%GF2+yKC1i#q{_=$5@- zsn3XKFP!=YfMs*<2B5C?UDbhKMd8mkR{`+M8`WC>{`7PJdIkrz^QAf209ZbCfAN5t zX|5xD!`VyJI+zgv;LcJNRZstU%m!z~Uw?V0)_j;`L}yxB0k~s&2>`3s+^by|!r}ft z3t&oQj@sd{4e&zMqX3-zy#;{n^+y25%O2seY6M|3iULlQon59!ib9{?@EpbfBg@dB;?Ik!&-;N$B309ZbsNBFvA5?*ra zw1n*+czB+6ECd^lE7H%es{r7WZ4ChYSbGeBx^pUHD#^{U09vnf$0RE;pz=ZGebdXX zBb@SeSjb3}{$kfb06u(Y9S}{{lz6)(_%8s>qmY$$Gb>88&x6NL03PA%SAjp<0;oH8 zUh}e$5Dy9I(a6e7cyi4$0G6RLFp0k6O(A!vdNBZxKiin_IbBCMDRm-nqIH2^5e)Y9 z#`KzyZmr)Ov!BDiUeb&Mdq%^B`0H;zR6^*(B zYPXb?mZr_7=I-9e%uqyyoDdeWNB3UVu8YiET4qo@vLe?J9Ms>-=%&Mix-0uz(%?nrn9bMf3gd+84ldQ;fgs<7dQM;iCS+j;E z6%K!Tx<=L<@p$ibg={>cg^_)CAX7bhQ%5Lf|MBEH!dASIHb-n$t{;HVz}19gCuOPn z@8$k*%zi|p)w4xHw0~egem`NqqseuIGcZP2YE!1NGBW`v^{G$snyiDO(a6S7!j+=E zr+2LVC6wz3Tg4N6nkP*!_D4J;>t#IeN+#7mGz27%NV4TR!cpt+2+}ckLGiqMvy&Bh zge9{vy=vyRlKGh4z1ihn!X`l>Et2=GHQ)cDogXjW6}gYF>?aQ%KVgGYSrFo8?MTQ= zjw_kac#-=Eo0S4n@& previousNPCs = new List() { -1 }; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Scorching Seeker"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 8; + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + } + + public override void SetDefaults() + { + projectile.width = 60; + projectile.height = 60; + projectile.friendly = true; + projectile.tileCollide = false; + projectile.penetrate = 3; + projectile.timeLeft = Lifetime; + projectile.melee = true; + projectile.extraUpdates = 1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + } + + public override void AI() + { + //holy dust + if (Main.rand.NextBool(8)) + { + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 244, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); + } + + // Boomerang rotation + projectile.rotation += 0.4f * (float)projectile.direction; + + // Boomerang sound + if (projectile.soundDelay == 0) + { + projectile.soundDelay = 8; + Main.PlaySound(SoundID.Item7, projectile.position); + } + + // Returns after some number of frames in the air + if (projectile.timeLeft < Lifetime - ReboundTime) + projectile.ai[0] = 1f; + + if (projectile.ai[0] != 0f) + { + float returnSpeed = 26f; + float acceleration = 1.4f; + + Player owner = Main.player[projectile.owner]; + + // Delete the projectile 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(); + + //home in on nearby NPCs if not returning to player + if (projectile.penetrate != -1) + { + if (!hasHitEnemy) + { + float range = 999f; + for (int a = 0; a < Main.npc.Length; a++) + { + if (Main.npc[a].CanBeChasedBy(projectile, false)) + { + float var2 = Main.npc[a].position.X + (Main.npc[a].width / 2); + float var3 = Main.npc[a].position.Y + (Main.npc[a].height / 2); + float distance2npc = Math.Abs(projectile.position.X + (projectile.width / 2) - var2) + Math.Abs(projectile.position.Y + (projectile.height / 2) - var3); + if (distance2npc < range) + { + Vector2 newVelocity = Main.npc[a].Center - projectile.Center; + newVelocity.Normalize(); + newVelocity *= 15f; + projectile.velocity = newVelocity; + } + } + } + } + else + { + if (targetNPC >= 0) + { + Vector2 newVelocity = Main.npc[targetNPC].Center - projectile.Center; + newVelocity.Normalize(); + newVelocity *= 15f; + projectile.velocity = newVelocity; + } + } + } + } + } + + 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) + { + //inflict Holy Flames for 6 seconds + target.AddBuff(ModContent.BuffType(), 360); + + if (projectile.penetrate != -1) + { + //find a nearby NPC to track + float minDist = 999f; + int index = 0; + for (int i = 0; i < Main.npc.Length; i++) + { + bool hasHitNPC = false; + for (int j = 0; j < previousNPCs.Count; j++) + { + if (previousNPCs[j] == i) + { + hasHitNPC = true; + } + } + + NPC npc = Main.npc[i]; + if (npc == target) + { + previousNPCs.Add(i); + } + if (!npc.friendly && !npc.townNPC && npc.active && !npc.dontTakeDamage && npc.chaseable && npc != target && !hasHitNPC && npc.type != NPCID.TargetDummy) + { + float dist = (projectile.Center - npc.Center).Length(); + if (dist < minDist) + { + minDist = dist; + index = i; + } + } + } + + Vector2 velocityNew; + if (minDist < 999f) + { + hasHitEnemy = true; + targetNPC = index; + velocityNew = Main.npc[index].Center - projectile.Center; + velocityNew.Normalize(); + velocityNew *= 15f; + projectile.velocity = velocityNew; + } + else + { + projectile.penetrate = -1; + projectile.ai[0] = 1f; + targetNPC = -1; + } + } + + // After its last hit, starts returning instead of vanishing. Can pierce infinitely on the way back. + if (projectile.penetrate == 1) + { + projectile.penetrate = -1; + projectile.ai[0] = 1f; + targetNPC = -1; + } + } + } +} diff --git a/Projectiles/Melee/DivineHatchetBoomerang.png b/Projectiles/Melee/DivineHatchetBoomerang.png new file mode 100644 index 0000000000000000000000000000000000000000..991e07cd78e6244de2628d827a3ecff8580cf3ef GIT binary patch literal 1500 zcmV<21ta>2P)^+5S84%#d${?U`f0oHT~ePbEvdbY17-YQKh(PWDF8}V z@3aAyKQh|_II!m@)xb9;&P-4y4b?*6p^)V!%Y*;=~=fXdgD zH#clO3&2O~%k>+>|HSOCc!DqC@3r-XwPTO)jcP=O1;Ermh6PZ)`z;%wYV{_-Au6Or zf1mvefPMAz)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