From e2d7abb34da57eb74b53e1e7a9dd534560bfcac5 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Wed, 13 May 2020 13:45:07 -0400 Subject: [PATCH] added monstrous knives --- Items/Weapons/Melee/MonstrousKnives.cs | 111 ++++++++++++++++++++++++ Items/Weapons/Melee/MonstrousKnives.png | Bin 0 -> 588 bytes Projectiles/Melee/MonstrousKnife.cs | 85 ++++++++++++++++++ Projectiles/Melee/MonstrousKnife.png | Bin 0 -> 478 bytes 4 files changed, 196 insertions(+) create mode 100644 Items/Weapons/Melee/MonstrousKnives.cs create mode 100644 Items/Weapons/Melee/MonstrousKnives.png create mode 100644 Projectiles/Melee/MonstrousKnife.cs create mode 100644 Projectiles/Melee/MonstrousKnife.png diff --git a/Items/Weapons/Melee/MonstrousKnives.cs b/Items/Weapons/Melee/MonstrousKnives.cs new file mode 100644 index 0000000000..b0f22ac525 --- /dev/null +++ b/Items/Weapons/Melee/MonstrousKnives.cs @@ -0,0 +1,111 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Melee; +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Melee +{ + public class MonstrousKnives : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Monstrous Knives"); + Tooltip.SetDefault("Throws a spread of knives that can heal the user"); + } + + public override void SetDefaults() + { + item.width = 18; + item.damage = 4; + item.melee = true; + item.noMelee = true; + item.noUseGraphic = true; + item.useAnimation = 21; + item.useStyle = 1; + item.useTime = 21; + item.knockBack = 3f; + item.UseSound = SoundID.Item39; + item.autoReuse = true; + item.height = 20; + item.value = Item.buyPrice(0, 2, 0, 0); + item.rare = 2; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 15f; + item.Calamity().customRarity = CalamityRarity.Dedicated; + } + + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + float speed = item.shootSpeed; + Vector2 playerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float xDist = Main.mouseX + Main.screenPosition.X - playerPos.X; + float yDist = Main.mouseY + Main.screenPosition.Y - playerPos.Y; + if (player.gravDir == -1f) + { + yDist = Main.screenPosition.Y + Main.screenHeight - Main.mouseY - playerPos.Y; + } + Vector2 vector = new Vector2(xDist, yDist); + float speedMult = vector.Length(); + if ((float.IsNaN(xDist) && float.IsNaN(yDist)) || (xDist == 0f && yDist == 0f)) + { + xDist = player.direction; + yDist = 0f; + speedMult = speed; + } + else + { + speedMult = speed / speedMult; + } + xDist *= speedMult; + yDist *= speedMult; + int knifeAmt = 3; + if (Main.rand.NextBool(2)) + { + knifeAmt++; + } + if (Main.rand.NextBool(4)) + { + knifeAmt++; + } + if (Main.rand.NextBool(8)) + { + knifeAmt++; + } + if (Main.rand.NextBool(16)) + { + knifeAmt++; + } + for (int i = 0; i < knifeAmt; i++) + { + float xVec = xDist; + float yVec = yDist; + float spreadMult = 0.05f * i; + xVec += Main.rand.NextFloat(-25f, 25f) * spreadMult; + yVec += Main.rand.NextFloat(-25f, 25f) * spreadMult; + Vector2 directionToShoot = new Vector2(xVec, yVec); + speedMult = directionToShoot.Length(); + speedMult = speed / speedMult; + xVec *= speedMult; + yVec *= speedMult; + directionToShoot = new Vector2(xVec, yVec); + Projectile.NewProjectile(playerPos, directionToShoot, type, damage, knockBack, player.whoAmI, 0f, 0f); + } + return false; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.ThrowingKnife, 200); + recipe.AddIngredient(ItemID.LifeCrystal); + recipe.AddIngredient(ItemID.LesserHealingPotion, 5); //I considered making a recipe group for any healing potion but Merchant sells these + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/Weapons/Melee/MonstrousKnives.png b/Items/Weapons/Melee/MonstrousKnives.png new file mode 100644 index 0000000000000000000000000000000000000000..cce1236fb9f75492e91d35bb4cc885947a5eae81 GIT binary patch literal 588 zcmV-S0<-;zP)Px#AY({UO#lFTCIA3{ga82g0001h=l}q9FaQARU;qF* zm;eA5aGbhPJOBUy24YJ`L;(K){{a7>y{D4^00EjwL_t(I%e~aiYLh_}#_`{)6@p1< zz*;}3v`Em@g~bm9#VZi}=te~B!i`I};uVOu;6fMeLIkZScnJzcl(^7FL=;1{)rh5y z1{LDs?Lg)wxO?+#W|(v4@IMb{CXvy_lT|QQEP!Ua)9sBf{rHu@xym-M;Ab~eB7seE z($JCW4p1%(fsxUaq`A`S!uh?sz@_;Y;OzKlL^^8%%=i#Gk}q*%dA$o~rc$zRD=jd6 z;dGj@@I1QEt!$1+gC5mCgWbc0oQcC`^57xx=GDt6;okd{q;dZ$c>1;j9&E(7gpTUz zvb5S65OGlOcK+_;z86mHOFg{(@ExcfJDLVIrY0yi;$*VA2Yg!o-i13iu7JhY%_y;U zU@Yn+bawgrt-gixBQBMTVIR$Nn361Mc6!3g3<@taf8yHq5?K72zQk)Yry{bf0(sEQ z*(d4wNGadnEh&|Y(SJHOeK_(eDC>P7>{oLz#H&-s!EpT=W*7np#9@JLF40>|K_i+weuzZ2l#k@X{z+OO#lD@5_CmabVXQ6MmkS&X=QG7 aVRUJ4ZU8ZaSnTfr0000= 30f) + { + projectile.alpha += 10; + if (projectile.damage > 1) + projectile.damage = (int)(projectile.damage * 0.9); + projectile.knockBack = projectile.knockBack * 0.9f; + if (projectile.alpha >= 255) + projectile.Kill(); + } + if (projectile.ai[0] < 30f) + projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + MathHelper.PiOver2; + } + + public override void Kill(int timeLeft) + { + for (int dustIndex = 0; dustIndex < 3; ++dustIndex) + { + int redDust = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 182, 0f, 0f, 100, new Color(), 0.8f); + Dust dust = Main.dust[redDust]; + dust.noGravity = true; + dust.velocity *= 1.2f; + dust.velocity -= projectile.oldVelocity * 0.3f; + } + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + if (Main.myPlayer != projectile.owner) + return; + if (target.type == NPCID.TargetDummy || target.lifeMax <= 5 || Main.player[projectile.owner].moonLeech) + return; + if (Main.player[projectile.owner].lifeSteal <= 0f) + return; + + float healAmt = damage * Main.rand.NextFloat(0.075f, 0.9f); + if (healAmt < 1f) + healAmt = 1f; + if (Main.rand.NextBool(3)) + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ProjectileID.VampireHeal, 1200f, 1.5f); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + if (Main.myPlayer != projectile.owner) + return; + if (Main.player[projectile.owner].moonLeech) + return; + if (Main.player[projectile.owner].lifeSteal <= 0f) + return; + + float healAmt = damage * Main.rand.NextFloat(0.075f, 0.9f); + if (healAmt < 1f) + healAmt = 1f; + if (Main.rand.NextBool(3)) + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ProjectileID.VampireHeal, 1200f, 1.5f); + } + } +} diff --git a/Projectiles/Melee/MonstrousKnife.png b/Projectiles/Melee/MonstrousKnife.png new file mode 100644 index 0000000000000000000000000000000000000000..5873e9229d66d1ebf5b7c2b7a7dfa543670fdf98 GIT binary patch literal 478 zcmeAS@N?(olHy`uVBq!ia0vp^d_XM0!3HEx9X}Heq*&4&eH|GXHuiJ>Nn{1`8H<*SG)+{QUWo&%rgW-Qk zH^EyU-*GX#%;RbB{vVq>i|NOoA503zrkH)U|M=`*X2ZN_hJs7T@XM~DY=lt=>*`g#R zy=mJ-Gp=jfx23vyW@<0;Qjv8&8}*g7;qYQ52J`Ep%{7Ik>E?@Xoz!Cv_=j!ONfOdl@1d}R=p$m3GL*w)c9 z`{HTd*oKU}a}kerL}fo>=9aD Q9w^J;>FVdQ&MBb@0Hl7nx&QzG literal 0 HcmV?d00001