From 2e276c274886bcc8de5d42bfbd210a39a1cde970 Mon Sep 17 00:00:00 2001 From: Shucks Date: Mon, 16 Dec 2019 22:20:11 -0600 Subject: [PATCH] Added metal monstrosity, added a function for sticky projectiles and fixed the rarity of burning strife --- Items/Weapons/Rogue/BurningStrife.cs | 2 +- Items/Weapons/Rogue/MetalMonstrosity.cs | 59 +++++++++++ Items/Weapons/Rogue/MetalMonstrosity.png | Bin 0 -> 727 bytes Projectiles/Rogue/MetalChunk.cs | 65 ++++++++++++ Projectiles/Rogue/MetalChunk.png | Bin 0 -> 727 bytes Projectiles/Rogue/MetalShard.cs | 90 ++++++++++++++++ Projectiles/Rogue/MetalShard.png | Bin 0 -> 281 bytes Projectiles/Rogue/MetalShard2.png | Bin 0 -> 319 bytes Projectiles/Rogue/MetalShard3.png | Bin 0 -> 269 bytes Utilities/CalamityUtils.cs | 124 +++++++++++++++++++++++ 10 files changed, 339 insertions(+), 1 deletion(-) create mode 100644 Items/Weapons/Rogue/MetalMonstrosity.cs create mode 100644 Items/Weapons/Rogue/MetalMonstrosity.png create mode 100644 Projectiles/Rogue/MetalChunk.cs create mode 100644 Projectiles/Rogue/MetalChunk.png create mode 100644 Projectiles/Rogue/MetalShard.cs create mode 100644 Projectiles/Rogue/MetalShard.png create mode 100644 Projectiles/Rogue/MetalShard2.png create mode 100644 Projectiles/Rogue/MetalShard3.png diff --git a/Items/Weapons/Rogue/BurningStrife.cs b/Items/Weapons/Rogue/BurningStrife.cs index e4f5fc7907..35635ed188 100644 --- a/Items/Weapons/Rogue/BurningStrife.cs +++ b/Items/Weapons/Rogue/BurningStrife.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.UseSound = SoundID.Item1; item.useStyle = ItemUseStyleID.SwingThrow; item.value = Item.buyPrice(0, 36, 0, 0); - item.rare = 4; + item.rare = 5; item.autoReuse = true; item.noUseGraphic = true; item.noMelee = true; diff --git a/Items/Weapons/Rogue/MetalMonstrosity.cs b/Items/Weapons/Rogue/MetalMonstrosity.cs new file mode 100644 index 0000000000..c0928f66d5 --- /dev/null +++ b/Items/Weapons/Rogue/MetalMonstrosity.cs @@ -0,0 +1,59 @@ +using CalamityMod.Projectiles.Rogue; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Rogue +{ + public class MetalMonstrosity : RogueWeapon + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Metal Monstrosity"); + Tooltip.SetDefault("Hurls a heavy metal ball that shatters on impact \n" + + "Stealth Strikes makes the ball release spikes as it travels \n" + + "'This has to hurt'"); + } + + public override void SafeSetDefaults() + { + item.width = 32; + item.height = 32; + item.useStyle = ItemUseStyleID.SwingThrow; + item.autoReuse = true; + item.noUseGraphic = true; + item.noMelee = true; + item.UseSound = SoundID.Item1; + item.rare = 3; + item.value = Item.buyPrice(0, 4, 0, 0); + + item.damage = 40; + item.useAnimation = 40; + item.useTime = 40; + item.knockBack = 7f; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 7f; + + item.Calamity().rogue = true; + } + + 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), ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); + if (player.Calamity().StealthStrikeAvailable()) + Main.projectile[proj].Calamity().stealthStrike = true; + return false; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.SpikyBall, 500); + recipe.AddIngredient(ItemID.Spike, 80); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/Weapons/Rogue/MetalMonstrosity.png b/Items/Weapons/Rogue/MetalMonstrosity.png new file mode 100644 index 0000000000000000000000000000000000000000..a9984302ef420c1ccf6d53342d00de9a4b95faab GIT binary patch literal 727 zcmV;|0x127P)8e_rBzwuSwMD-gimPJ%@A8 z_nhy%-?^?_sszL|JW_Q48_O#IY}QukrgEtQK;`;P0KRf zFP;N1`FK14IA1Ee_&^(hA|D>90e$ziZ`xM z=m%h9dBuzTf0Z5rEA#IGsNNa%28e`|$((cmjmAy@aQVs&Z@lKQQqI_1N)Lh0pFV~J z7;Q^p@y!ANyY)?v$hWN;08Jd2Q92#0g~g0zYt@<=QKo)spsDgcPYg z9rA%@vjM>OTG*dBfnzyfy;qDv{JwQ?c^JlMDhf-j*fuV{a&|RMQp3t%+yQZxVIC10TJDRtP@H$ zCz2=dE2;&5yWiU{9qa9uL^jjwMcPS;6L8~^6V4p`?z+<3rBax+Kequm 16f) + projectile.velocity.Y = 16f; + //Rotation + projectile.rotation += 0.14f * projectile.direction; + if (projectile.Calamity().stealthStrike) + { + projectile.ai[0]++; + if(projectile.ai[0] >= 10f) + { + Vector2 speed = new Vector2(Main.rand.NextFloat(-6f, 6f), Main.rand.NextFloat(-6f, 6f)); + Projectile.NewProjectile(projectile.Center, speed, ModContent.ProjectileType(), (int)(projectile.damage * 0.3f), 0f, projectile.owner, 0f, 0f); + projectile.ai[0] = 0f; + } + } + } + + public override void Kill(int timeLeft) + { + Main.PlaySound(SoundID.NPCHit42, projectile.Center); + for (int i = 0; i < 3; i++) + { + Vector2 S1 = new Vector2(-projectile.velocity.X, -projectile.velocity.Y).RotatedBy(MathHelper.ToRadians(Main.rand.Next(-45, 46))); + int proj = Projectile.NewProjectile(projectile.Center, S1, ProjectileID.SpikyBall, (int)(projectile.damage * 0.3), 0f, projectile.owner, 0f, 0f); + Main.projectile[proj].timeLeft = 600; + Main.projectile[proj].usesLocalNPCImmunity = true; + Main.projectile[proj].localNPCHitCooldown = 20; + S1 = new Vector2(-projectile.velocity.X * 0.7f, -projectile.velocity.Y*0.7f).RotatedBy(MathHelper.ToRadians(Main.rand.Next(-45, 46))); + Projectile.NewProjectile(projectile.Center, S1, ModContent.ProjectileType(), (int)(projectile.damage * 0.3), 0f, projectile.owner, 0f, 0f); + } + //Dust + for (int i = 0; i < 20; i++) + { + Dust.NewDust(projectile.Center, 1, 1, DustID.Lead, 0f, 0f, 0, default, 1.1f); + } + } + } +} diff --git a/Projectiles/Rogue/MetalChunk.png b/Projectiles/Rogue/MetalChunk.png new file mode 100644 index 0000000000000000000000000000000000000000..a9984302ef420c1ccf6d53342d00de9a4b95faab GIT binary patch literal 727 zcmV;|0x127P)8e_rBzwuSwMD-gimPJ%@A8 z_nhy%-?^?_sszL|JW_Q48_O#IY}QukrgEtQK;`;P0KRf zFP;N1`FK14IA1Ee_&^(hA|D>90e$ziZ`xM z=m%h9dBuzTf0Z5rEA#IGsNNa%28e`|$((cmjmAy@aQVs&Z@lKQQqI_1N)Lh0pFV~J z7;Q^p@y!ANyY)?v$hWN;08Jd2Q92#0g~g0zYt@<=QKo)spsDgcPYg z9rA%@vjM>OTG*dBfnzyfy;qDv{JwQ?c^JlMDhf-j*fuV{a&|RMQp3t%+yQZxVIC10TJDRtP@H$ zCz2=dE2;&5yWiU{9qa9uL^jjwMcPS;6L8~^6V4p`?z+<3rBax+Kequm 16f) + projectile.velocity.Y = 16f; + //Sticky Behaviour + CalamityUtils.StickyProjAI(projectile); + } + + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + CalamityUtils.ModifyHitNPCSticky(projectile, 8 , true); + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (targetHitbox.Width > 8 && targetHitbox.Height > 8) + { + targetHitbox.Inflate(-targetHitbox.Width / 8, -targetHitbox.Height / 8); + } + return null; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture; + if (projectile.localAI[1] == 0f) + projectile.localAI[1] = Main.rand.Next(1, 4); + switch (projectile.localAI[1]) + { + + case 2f: texture = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/MetalShard2"); + break; + case 3f: texture = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/MetalShard3"); + break; + default: texture = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/MetalShard"); + break; + } + Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Rectangle?(new Rectangle(0, 0, texture.Width, texture.Height)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture.Width / 2f, texture.Height / 2f), projectile.scale, SpriteEffects.None, 0f); + return false; + } + + public override void Kill(int timeLeft) + { + for (int i = 0; i < 6; i++) + { + Dust.NewDust(projectile.Center, projectile.width, projectile.height, DustID.Lead, 0f, 0f, 0, default, 1f); + } + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + Main.PlaySound(SoundID.Dig, projectile.Center); + return true; + } + } +} diff --git a/Projectiles/Rogue/MetalShard.png b/Projectiles/Rogue/MetalShard.png new file mode 100644 index 0000000000000000000000000000000000000000..fd91eb1b32bb50906523d971645f5d630a7dfc14 GIT binary patch literal 281 zcmeAS@N?(olHy`uVBq!ia0vp^Ahr+(8<0%e?(Yqx*pj^6T^Rm@;DWu&Cj&(`c)B=- zXq;bqX)hn6qe$Ds@*^g}3t}g((Qw(iFmQ)z>pj*NqVHV26{R*#6c9;by}f8gTGz!J zNv$dM`(CL$e{wQh=Ainz$BYk3s~KYW%(*{QurY{uNC#f%Oyo zbi7v9dENKalUl6nu=LF_v415~1AE%C&USh}ziha?Vt*UM6=`3FvfHW*UQ=E6^>zQ$ zDO>PWJN@{J=p`Xc2PEbO{!wRrs5bWp+xctOS2H(N7=gT2;u--&o^DqDMVYC2C5a`O Y`FRY6EfH_t17#UJUHx3vIVCg!0D!x06aWAK literal 0 HcmV?d00001 diff --git a/Projectiles/Rogue/MetalShard2.png b/Projectiles/Rogue/MetalShard2.png new file mode 100644 index 0000000000000000000000000000000000000000..6ab3926f2d650336ad805005938857a3c66260cd GIT binary patch literal 319 zcmeAS@N?(olHy`uVBq!ia0vp^0zk~i!3HGN^yhQ|DYhhUcNd2LAh=-f^2tDvYo0ES zAsXk`UNZDzP82x$@&5AN9AbtMJC$-YHKL-UxZ@5oM=U$TsKd%#++dQ)>X@^YBa>xz zL_|lNgUJFFmq_XGI|(XBzps*fcJ{+_L&fvk&aQY=zIoD9#%F1F=PgV5^yz#;oub1e zwFHYA=IY<<4<7A_bx~$Gds+BGmR$4n>&uz!?A#NQi=Uro{>X7IO17Zl$_j}*{d}#z zj}OR7`fe$e%M(~DKIOhKx8UA-mV z=YQPY&m1l>H`v{cli~dJ!&i%!1~De&zWiFw;c{#v(}GoNe#fvaxNge8($d&1_ptvMggr|e>QP_&P!V7GYO-u1m1XAf{s@nYPt z?aP^zDI7m)UwUsiDE(%h#;XZc^+iDU3YEA<0FkGgm48uYYF + /// Call this function in the ai of your projectile so it can stick to enemies, also requires ModifyHitNPCSticky to be called in ModifyHitNPC + /// + /// The projectile you're adding sticky behaviour to + public static void StickyProjAI (Projectile projectile) + { + if (projectile.ai[0] == 1f) + { + projectile.tileCollide = false; + int num988 = 15; + bool flag54 = false; + bool flag55 = false; + projectile.localAI[0]++; + if (projectile.localAI[0] % 30f == 0f) + { + flag55 = true; + } + int num989 = (int)projectile.ai[1]; + if (projectile.localAI[0] >= (float)(60 * num988)) + { + flag54 = true; + } + else if (num989 < 0 || num989 >= 200) + { + flag54 = true; + } + else if (Main.npc[num989].active && !Main.npc[num989].dontTakeDamage) + { + projectile.Center = Main.npc[num989].Center - projectile.velocity * 2f; + projectile.gfxOffY = Main.npc[num989].gfxOffY; + if (flag55) + { + Main.npc[num989].HitEffect(0, 1.0); + } + } + else + { + flag54 = true; + } + if (flag54) + { + projectile.Kill(); + } + } + } + + /// + /// Call this function in ModifyHitNPC to make your projectiles stick to enemies, needs StickyProjAI to be called in the AI of the projectile + /// + /// The projectile you're giving sticky behaviour to + /// How many projectiles of this type can stick to one enemy + /// Decides if you want the projectile to deal damage while its sticked to enemies or not + public static void ModifyHitNPCSticky(Projectile projectile, int maxStick, bool constantDamage) + { + Rectangle myRect = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height); + if (projectile.owner == Main.myPlayer) + { + for (int i = 0; i < 200; i++) + { + if (Main.npc[i].active && !Main.npc[i].dontTakeDamage && + ((projectile.friendly && (!Main.npc[i].friendly || projectile.type == 318 || (Main.npc[i].type == 22 && projectile.owner < 255 && Main.player[projectile.owner].killGuide) || (Main.npc[i].type == 54 && projectile.owner < 255 && Main.player[projectile.owner].killClothier))) || + (projectile.hostile && Main.npc[i].friendly && !Main.npc[i].dontTakeDamageFromHostiles)) && (projectile.owner < 0 || Main.npc[i].immune[projectile.owner] == 0 || projectile.maxPenetrate == 1)) + { + if (Main.npc[i].noTileCollide || !projectile.ownerHitCheck || projectile.CanHit(Main.npc[i])) + { + bool flag3; + if (Main.npc[i].type == 414) + { + Rectangle rect = Main.npc[i].getRect(); + int num5 = 8; + rect.X -= num5; + rect.Y -= num5; + rect.Width += num5 * 2; + rect.Height += num5 * 2; + flag3 = projectile.Colliding(myRect, rect); + } + else + { + flag3 = projectile.Colliding(myRect, Main.npc[i].getRect()); + } + if (flag3) + { + if (Main.npc[i].reflectingProjectiles && projectile.CanReflect()) + { + Main.npc[i].ReflectProjectile(projectile.whoAmI); + return; + } + projectile.ai[0] = 1f; + projectile.ai[1] = (float)i; + projectile.velocity = (Main.npc[i].Center - projectile.Center) * 0.75f; + projectile.netUpdate = true; + if (!constantDamage) + projectile.damage = 0; + Point[] array2 = new Point[maxStick]; + int num29 = 0; + for (int l = 0; l < 1000; l++) + { + if (l != projectile.whoAmI && Main.projectile[l].active && Main.projectile[l].owner == Main.myPlayer && Main.projectile[l].type == projectile.type && Main.projectile[l].ai[0] == 1f && Main.projectile[l].ai[1] == (float)i) + { + array2[num29++] = new Point(l, Main.projectile[l].timeLeft); + if (num29 >= array2.Length) + { + break; + } + } + } + if (num29 >= array2.Length) + { + int num30 = 0; + for (int m = 1; m < array2.Length; m++) + { + if (array2[m].Y < array2[num30].Y) + { + num30 = m; + } + } + Main.projectile[array2[num30].X].Kill(); + } + } + } + } + } + } + } #endregion #region Tile Utilities