diff --git a/Items/CalamityCustomThrowingDamage/UtensilPoker.cs b/Items/CalamityCustomThrowingDamage/UtensilPoker.cs new file mode 100644 index 0000000000..2529bf74a0 --- /dev/null +++ b/Items/CalamityCustomThrowingDamage/UtensilPoker.cs @@ -0,0 +1,73 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.CalamityCustomThrowingDamage +{ + public class UtensilPoker : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Utensil Poker"); + Tooltip.SetDefault("Fires random utensils in bursts of three\n" + + "Grants Well Fed on enemy hits\n" + + "Stealth strikes launch an additional butcher knife"); + } + + public override void SetDefaults() + { + item.width = 44; + item.height = 66; + item.damage = 750; + item.GetGlobalItem(mod).rogue = true; + item.knockBack = 8f; + item.noMelee = true; + item.noUseGraphic = true; + item.useStyle = 1; + item.useTime = 15; + item.reuseDelay = 15; + item.useAnimation = 45; + item.UseSound = SoundID.Item1; + item.autoReuse = true; + item.value = Item.buyPrice(1, 20, 0, 0); + item.rare = 10; + item.GetGlobalItem(mod).postMoonLordRarity = 12; + item.shoot = mod.ProjectileType("Fork"); + item.shootSpeed = 16f; + } + + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + if (player.GetCalamityPlayer().StealthStrikeAvailable()) + { + Projectile.NewProjectile(position.X, position.Y, (int) ((double)speedX * 1.2), (int) ((double)speedY * 1.2), mod.ProjectileType("ButcherKnife"), (int) ((double)damage * 3), knockBack, Main.myPlayer); + if (Main.rand.NextBool(3)) + { + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, mod.ProjectileType("Fork"), (int) ((double)damage * 1.1), knockBack * 2f, Main.myPlayer); + } + else if (Main.rand.NextBool(2)) + { + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, mod.ProjectileType("Knife"), (int)((double)damage * 1.2), knockBack, Main.myPlayer); + } + else + { + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, mod.ProjectileType("CarvingFork"), damage, knockBack, Main.myPlayer); + } + } + else if (Main.rand.NextBool(3)) + { + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, mod.ProjectileType("Fork"), (int) ((double)damage * 1.1), knockBack * 2f, Main.myPlayer); + } + else if (Main.rand.NextBool(2)) + { + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, mod.ProjectileType("Knife"), (int)((double)damage * 1.2), knockBack, Main.myPlayer); + } + else + { + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, mod.ProjectileType("CarvingFork"), damage, knockBack, Main.myPlayer); + } + return false; + } + } +} diff --git a/Items/CalamityCustomThrowingDamage/UtensilPoker.png b/Items/CalamityCustomThrowingDamage/UtensilPoker.png new file mode 100644 index 0000000000..7cf79a1e66 Binary files /dev/null and b/Items/CalamityCustomThrowingDamage/UtensilPoker.png differ diff --git a/Projectiles/Rogue/ButcherKnife.cs b/Projectiles/Rogue/ButcherKnife.cs new file mode 100644 index 0000000000..3c342544aa --- /dev/null +++ b/Projectiles/Rogue/ButcherKnife.cs @@ -0,0 +1,137 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Rogue +{ + public class ButcherKnife : ModProjectile + { + private static float RotationIncrement = 0.22f; + private static float ReboundTime = 26f; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Butcher Knife"); + } + + public override void SetDefaults() + { + projectile.width = 14; + projectile.height = 14; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.timeLeft = 300; + projectile.GetGlobalProjectile(mod).rogue = true; + projectile.extraUpdates = 1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 60; + projectile.tileCollide = true; + } + + public override void AI() + { + if (Main.rand.Next(2) == 0) + { + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 5, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); + } + drawOffsetX = -11; + drawOriginOffsetY = -10; + drawOriginOffsetX = 0; + + // ai[0] stores whether the knife 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 = 16f; + float acceleration = 3.2f; + Player owner = Main.player[projectile.owner]; + + // Delete the knife 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 knife as it flies. + projectile.rotation += RotationIncrement; + return; + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + projectile.ai[0] += 0.1f; + if (projectile.velocity.X != oldVelocity.X) + { + projectile.velocity.X = -oldVelocity.X; + } + if (projectile.velocity.Y != oldVelocity.Y) + { + projectile.velocity.Y = -oldVelocity.Y; + } + return false; + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + Player player = Main.player[projectile.owner]; + player.AddBuff(BuffID.WellFed, 180); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1); + return false; + } + } +} diff --git a/Projectiles/Rogue/ButcherKnife.png b/Projectiles/Rogue/ButcherKnife.png new file mode 100644 index 0000000000..e6fe85c293 Binary files /dev/null and b/Projectiles/Rogue/ButcherKnife.png differ diff --git a/Projectiles/Rogue/CarvingFork.cs b/Projectiles/Rogue/CarvingFork.cs new file mode 100644 index 0000000000..bcee776a39 --- /dev/null +++ b/Projectiles/Rogue/CarvingFork.cs @@ -0,0 +1,52 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Rogue +{ + public class CarvingFork : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Carving Fork"); + } + + public override void SetDefaults() + { + projectile.width = 10; + projectile.height = 10; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.aiStyle = 113; + projectile.timeLeft = 600; + aiType = 598; + projectile.GetGlobalProjectile(mod).rogue = true; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 30; + } + + public override void AI() + { + if (Main.rand.Next(5) == 0) + { + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 5, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); + } + projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); + projectile.rotation = projectile.velocity.ToRotation(); + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + Player player = Main.player[projectile.owner]; + player.AddBuff(BuffID.WellFed, 180); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1); + return false; + } + } +} diff --git a/Projectiles/Rogue/CarvingFork.png b/Projectiles/Rogue/CarvingFork.png new file mode 100644 index 0000000000..dec658e285 Binary files /dev/null and b/Projectiles/Rogue/CarvingFork.png differ diff --git a/Projectiles/Rogue/Fork.cs b/Projectiles/Rogue/Fork.cs new file mode 100644 index 0000000000..ef32a08144 --- /dev/null +++ b/Projectiles/Rogue/Fork.cs @@ -0,0 +1,52 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Rogue +{ + public class Fork : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Fork"); + } + + public override void SetDefaults() + { + projectile.width = 14; + projectile.height = 14; + projectile.friendly = true; + projectile.penetrate = 1; + projectile.aiStyle = 113; + projectile.timeLeft = 600; + aiType = 598; + projectile.GetGlobalProjectile(mod).rogue = true; + } + + public override void AI() + { + if (Main.rand.Next(5) == 0) + { + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 5, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); + } + projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); + projectile.rotation = projectile.velocity.ToRotation(); + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + Player player = Main.player[projectile.owner]; + target.AddBuff(BuffID.Bleeding, 300); + target.AddBuff(mod.BuffType("BurningBlood"), 300); + player.AddBuff(BuffID.WellFed, 180); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1); + return false; + } + } +} diff --git a/Projectiles/Rogue/Fork.png b/Projectiles/Rogue/Fork.png new file mode 100644 index 0000000000..636e9c45c7 Binary files /dev/null and b/Projectiles/Rogue/Fork.png differ diff --git a/Projectiles/Rogue/Knife.cs b/Projectiles/Rogue/Knife.cs new file mode 100644 index 0000000000..bbd0338782 --- /dev/null +++ b/Projectiles/Rogue/Knife.cs @@ -0,0 +1,50 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Rogue +{ + public class Knife : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Knife"); + } + + public override void SetDefaults() + { + projectile.width = 12; + projectile.height = 12; + projectile.friendly = true; + projectile.penetrate = 1; + projectile.aiStyle = 113; + projectile.timeLeft = 600; + aiType = 598; + projectile.GetGlobalProjectile(mod).rogue = true; + } + + public override void AI() + { + if (Main.rand.Next(5) == 0) + { + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 5, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); + } + projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); + projectile.rotation = projectile.velocity.ToRotation(); + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + Player player = Main.player[projectile.owner]; + player.AddBuff(BuffID.WellFed, 180); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1); + return false; + } + } +} diff --git a/Projectiles/Rogue/Knife.png b/Projectiles/Rogue/Knife.png new file mode 100644 index 0000000000..3d8ef0cf3d Binary files /dev/null and b/Projectiles/Rogue/Knife.png differ