From f221bf059d13616a0ef21cfd711f8d96467ae75d Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Fri, 10 Jul 2020 17:59:37 -0400 Subject: [PATCH] refactored Halley's Inferno and Spark Spreader --- Items/Weapons/Ranged/HalleysInferno.cs | 90 ++++++++++---------- Items/Weapons/Ranged/SparkSpreader.cs | 87 +++++++++----------- Items/Weapons/Rogue/EclipsesFall.cs | 74 ++++++++--------- Items/Weapons/Summon/BensUmbrella.cs | 104 ++++++++++++------------ Projectiles/Ranged/HalleysComet.cs | 34 ++++---- Projectiles/Ranged/SparkSpreaderFire.cs | 76 ++++++++--------- Projectiles/Summon/AstralProbeRound.cs | 2 +- 7 files changed, 223 insertions(+), 244 deletions(-) diff --git a/Items/Weapons/Ranged/HalleysInferno.cs b/Items/Weapons/Ranged/HalleysInferno.cs index f313f0ea94..d30aae8053 100644 --- a/Items/Weapons/Ranged/HalleysInferno.cs +++ b/Items/Weapons/Ranged/HalleysInferno.cs @@ -8,53 +8,53 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class HalleysInferno : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Halley's Inferno"); - Tooltip.SetDefault("Halley came sooner than expected\n" + - "Fires a flaming comet\n" + - "50% chance to not consume gel\n" + - "Right click to zoom out"); - } + public class HalleysInferno : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Halley's Inferno"); + Tooltip.SetDefault("Halley came sooner than expected\n" + + "Fires a flaming comet\n" + + "50% chance to not consume gel\n" + + "Right click to zoom out"); + } - public override void SetDefaults() - { - item.damage = 1666; - item.crit += 20; - item.ranged = true; - item.width = 84; - item.height = 34; - item.useTime = 30; - item.useAnimation = 30; - item.useStyle = ItemUseStyleID.HoldingOut; - item.noMelee = true; - item.knockBack = 5f; - item.UseSound = SoundID.Item34; - item.value = Item.buyPrice(1, 40, 0, 0); - item.rare = 10; - item.Calamity().customRarity = CalamityRarity.PureGreen; - item.autoReuse = true; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 14.6f; - item.useAmmo = 23; - } + public override void SetDefaults() + { + item.damage = 1666; + item.crit += 20; + item.knockBack = 5f; + item.ranged = true; + item.useTime = item.useAnimation = 30; + item.autoReuse = true; + item.useAmmo = AmmoID.Gel; + item.shootSpeed = 14.6f; + item.shoot = ModContent.ProjectileType(); - public override Vector2? HoldoutOffset() => new Vector2(-15, 0); + item.width = 84; + item.height = 34; + item.useStyle = ItemUseStyleID.HoldingOut; + item.noMelee = true; + item.UseSound = SoundID.Item34; + item.value = Item.buyPrice(1, 40, 0, 0); + item.rare = 10; + item.Calamity().customRarity = CalamityRarity.PureGreen; + } - public override bool ConsumeAmmo(Player player) => Main.rand.Next(100) >= 50; + public override Vector2? HoldoutOffset() => new Vector2(-15, 0); - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 6); - recipe.AddIngredient(ModContent.ItemType(), 4); - recipe.AddIngredient(ModContent.ItemType(), 12); - recipe.AddIngredient(ItemID.SniperScope); - recipe.AddTile(TileID.LunarCraftingStation); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override bool ConsumeAmmo(Player player) => Main.rand.Next(100) >= 50; + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType(), 6); + recipe.AddIngredient(ModContent.ItemType(), 4); + recipe.AddIngredient(ModContent.ItemType(), 12); + recipe.AddIngredient(ItemID.SniperScope); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Ranged/SparkSpreader.cs b/Items/Weapons/Ranged/SparkSpreader.cs index 5b9e319afc..449eae6502 100644 --- a/Items/Weapons/Ranged/SparkSpreader.cs +++ b/Items/Weapons/Ranged/SparkSpreader.cs @@ -6,55 +6,48 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class SparkSpreader : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Spark Spreader"); - Tooltip.SetDefault("20% chance to not consume gel"); - } + public class SparkSpreader : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Spark Spreader"); + Tooltip.SetDefault("20% chance to not consume gel"); + } - public override void SetDefaults() - { - item.damage = 7; - item.ranged = true; - item.width = 52; - item.height = 20; - item.useTime = 10; - item.useAnimation = 30; - item.useStyle = ItemUseStyleID.HoldingOut; - item.noMelee = true; - item.knockBack = 1f; - item.UseSound = SoundID.Item34; - item.value = Item.buyPrice(0, 1, 0, 0); - item.rare = 1; - item.autoReuse = true; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 5f; - item.useAmmo = 23; - } + public override void SetDefaults() + { + item.damage = 7; + item.knockBack = 1f; + item.ranged = true; + item.autoReuse = true; + item.useTime = 10; + item.useAnimation = 30; + item.useAmmo = AmmoID.Gel; + item.shootSpeed = 5f; + item.shoot = ModContent.ProjectileType(); - public override Vector2? HoldoutOffset() - { - return new Vector2(-4, 0); - } + item.width = 52; + item.height = 20; + item.useStyle = ItemUseStyleID.HoldingOut; + item.noMelee = true; + item.UseSound = SoundID.Item34; + item.value = Item.buyPrice(0, 1, 0, 0); + item.rare = 1; + } - public override bool ConsumeAmmo(Player player) - { - if (Main.rand.Next(0, 100) < 20) - return false; - return true; - } + public override Vector2? HoldoutOffset() => new Vector2(-4, 0); - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.FlareGun, 1); - recipe.AddIngredient(ItemID.Ruby, 1); - recipe.AddIngredient(ItemID.Gel, 12); - recipe.AddTile(TileID.Anvils); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override bool ConsumeAmmo(Player player) => Main.rand.Next(100) >= 20; + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.FlareGun); + recipe.AddIngredient(ItemID.Ruby); + recipe.AddIngredient(ItemID.Gel, 12); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Rogue/EclipsesFall.cs b/Items/Weapons/Rogue/EclipsesFall.cs index 38c1d153a7..8afad26224 100644 --- a/Items/Weapons/Rogue/EclipsesFall.cs +++ b/Items/Weapons/Rogue/EclipsesFall.cs @@ -8,35 +8,35 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class EclipsesFall : RogueWeapon - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Eclipse's Fall"); - Tooltip.SetDefault("When the sun goes dark, you will know judgment\n" + - "Summons spears from the sky on hit\n" + - "Stealth strikes impale enemies and summon a constant barrage of spears over time"); - } + public class EclipsesFall : RogueWeapon + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Eclipse's Fall"); + Tooltip.SetDefault("When the sun goes dark, you will know judgment\n" + + "Summons spears from the sky on hit\n" + + "Stealth strikes impale enemies and summon a constant barrage of spears over time"); + } - public override void SafeSetDefaults() - { - item.damage = 1060; - item.knockBack = 3.5f; - item.useAnimation = item.useTime = 21; - item.autoReuse = true; - item.Calamity().rogue = true; - item.shootSpeed = 15f; - item.shoot = ModContent.ProjectileType(); + public override void SafeSetDefaults() + { + item.damage = 1060; + item.knockBack = 3.5f; + item.useAnimation = item.useTime = 21; + item.autoReuse = true; + item.Calamity().rogue = true; + item.shootSpeed = 15f; + item.shoot = ModContent.ProjectileType(); - item.useStyle = ItemUseStyleID.SwingThrow; - item.width = item.height = 72; - item.noMelee = true; - item.noUseGraphic = true; - item.UseSound = SoundID.Item1; - item.value = Item.buyPrice(2, 50, 0, 0); - item.rare = 10; - item.Calamity().customRarity = CalamityRarity.Violet; - } + item.useStyle = ItemUseStyleID.SwingThrow; + item.width = item.height = 72; + item.noMelee = true; + item.noUseGraphic = true; + item.UseSound = SoundID.Item1; + item.value = Item.buyPrice(2, 50, 0, 0); + item.rare = 10; + item.Calamity().customRarity = CalamityRarity.Violet; + } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { @@ -49,15 +49,15 @@ namespace CalamityMod.Items.Weapons.Rogue return false; } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType(), 15); - recipe.AddIngredient(ModContent.ItemType(), 6); + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType(), 15); + recipe.AddIngredient(ModContent.ItemType(), 6); recipe.AddTile(ModContent.TileType()); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Summon/BensUmbrella.cs b/Items/Weapons/Summon/BensUmbrella.cs index deb68215dc..dee041c074 100644 --- a/Items/Weapons/Summon/BensUmbrella.cs +++ b/Items/Weapons/Summon/BensUmbrella.cs @@ -9,65 +9,65 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Summon { public class BensUmbrella : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Temporal Umbrella"); - Tooltip.SetDefault("Surprisingly sturdy, I reckon this could defeat the Mafia in a single blow\n" + + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Temporal Umbrella"); + Tooltip.SetDefault("Surprisingly sturdy, I reckon this could defeat the Mafia in a single blow\n" + "Summons a magic hat to hover above your head\n" + - "The hat will release a variety of objects to assault your foes\n" + - "Requires 5 minion slots to use\n" + - "There can only be one"); - } + "The hat will release a variety of objects to assault your foes\n" + + "Requires 5 minion slots to use\n" + + "There can only be one"); + } - public override void SetDefaults() - { - item.damage = 963; - item.knockBack = 1f; - item.mana = 99; - item.useTime = item.useAnimation = 10; - item.summon = true; - item.shootSpeed = 0f; - item.shoot = ModContent.ProjectileType(); + public override void SetDefaults() + { + item.damage = 963; + item.knockBack = 1f; + item.mana = 99; + item.useTime = item.useAnimation = 10; + item.summon = true; + item.shootSpeed = 0f; + item.shoot = ModContent.ProjectileType(); - item.useStyle = ItemUseStyleID.SwingThrow; - item.width = 74; - item.height = 72; - item.noMelee = true; - item.UseSound = SoundID.Item68; - item.value = Item.buyPrice(5, 0, 0, 0); - item.rare = 10; - item.Calamity().customRarity = CalamityRarity.ItemSpecific; - } + item.useStyle = ItemUseStyleID.SwingThrow; + item.width = 74; + item.height = 72; + item.noMelee = true; + item.UseSound = SoundID.Item68; + item.value = Item.buyPrice(5, 0, 0, 0); + item.rare = 10; + item.Calamity().customRarity = CalamityRarity.ItemSpecific; + } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0 && player.maxMinions >= 5; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0 && player.maxMinions >= 5; - public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) - { - for (int x = 0; x < Main.maxProjectiles; x++) - { - Projectile projectile = Main.projectile[x]; - if (projectile.active && projectile.owner == player.whoAmI && projectile.type == type) - { - projectile.Kill(); + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + for (int x = 0; x < Main.maxProjectiles; x++) + { + Projectile projectile = Main.projectile[x]; + if (projectile.active && projectile.owner == player.whoAmI && projectile.type == type) + { + projectile.Kill(); break; - } - } - Projectile.NewProjectile(player.Center, Vector2.Zero, type, damage, knockBack, player.whoAmI); - return false; - } + } + } + Projectile.NewProjectile(player.Center, Vector2.Zero, type, damage, knockBack, player.whoAmI); + return false; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ItemID.Umbrella); - recipe.AddIngredient(ItemID.TopHat); + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ItemID.Umbrella); + recipe.AddIngredient(ItemID.TopHat); recipe.AddIngredient(ModContent.ItemType(), 4); recipe.AddTile(ModContent.TileType()); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Projectiles/Ranged/HalleysComet.cs b/Projectiles/Ranged/HalleysComet.cs index fa16faba6b..4f36c704cf 100644 --- a/Projectiles/Ranged/HalleysComet.cs +++ b/Projectiles/Ranged/HalleysComet.cs @@ -13,8 +13,7 @@ namespace CalamityMod.Projectiles.Ranged public override void SetDefaults() { - projectile.width = 12; - projectile.height = 12; + projectile.width = projectile.height = 12; projectile.friendly = true; projectile.ignoreWater = true; projectile.ranged = true; @@ -29,32 +28,30 @@ namespace CalamityMod.Projectiles.Ranged { projectile.scale *= 1.01f; } + Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.35f / 255f, (255 - projectile.alpha) * 0f / 255f, (255 - projectile.alpha) * 0.45f / 255f); - if (projectile.timeLeft > 600) + + if (projectile.ai[0]++ > 5f) { - projectile.timeLeft = 600; - } - if (projectile.ai[0] > 5f) - { - float num296 = 1f; + float dustScaleSize = 1f; if (projectile.ai[0] == 6f) { - num296 = 0.25f; + dustScaleSize = 0.25f; } else if (projectile.ai[0] == 7f) { - num296 = 0.5f; + dustScaleSize = 0.5f; } else if (projectile.ai[0] == 8f) { - num296 = 0.75f; + dustScaleSize = 0.75f; } projectile.ai[0] += 1f; - int num297 = 176; - for (int num298 = 0; num298 < 3; num298++) + int dustType = 176; + for (int i = 0; i < 3; i++) { - int num299 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, num297, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 1, default, 1f); - Dust dust = Main.dust[num299]; + int fire = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 1, default, 1f); + Dust dust = Main.dust[fire]; if (Main.rand.NextBool(3)) { dust.noGravity = true; @@ -68,7 +65,7 @@ namespace CalamityMod.Projectiles.Ranged } dust.velocity.X *= 1.2f; dust.velocity.Y *= 1.2f; - dust.scale *= num296; + dust.scale *= dustScaleSize; dust.velocity += projectile.velocity; if (!dust.noGravity) { @@ -76,10 +73,7 @@ namespace CalamityMod.Projectiles.Ranged } } } - else - { - projectile.ai[0] += 1f; - } + projectile.rotation += 0.3f * (float)projectile.direction; } diff --git a/Projectiles/Ranged/SparkSpreaderFire.cs b/Projectiles/Ranged/SparkSpreaderFire.cs index 4fede1d4eb..9ee590766e 100644 --- a/Projectiles/Ranged/SparkSpreaderFire.cs +++ b/Projectiles/Ranged/SparkSpreaderFire.cs @@ -14,8 +14,7 @@ namespace CalamityMod.Projectiles.Ranged public override void SetDefaults() { - projectile.width = 12; - projectile.height = 12; + projectile.width = projectile.height = 12; projectile.friendly = true; projectile.ranged = true; projectile.penetrate = 3; @@ -28,65 +27,58 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.05f / 255f, (255 - projectile.alpha) * 0.45f / 255f, (255 - projectile.alpha) * 0.05f / 255f); - if (projectile.timeLeft > 60) - { - projectile.timeLeft = 60; - } + if (projectile.wet && !projectile.lavaWet) { projectile.Kill(); } - if (Main.rand.Next(3) == 0) + + if (Main.rand.NextBool(3)) { - Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 35, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 80, default, 0.75f); - Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 55, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 50, default, 0.75f); + Dust.NewDust(projectile.position, projectile.width, projectile.height, 35, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 80, default, 0.75f); + Dust.NewDust(projectile.position, projectile.width, projectile.height, 55, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 50, default, 0.75f); } - if (projectile.ai[0] > 7f) + + if (projectile.ai[0]++ > 7f) { - float num296 = 1f; + float dustScaleSize = 1f; if (projectile.ai[0] == 8f) { - num296 = 0.25f; + dustScaleSize = 0.25f; } else if (projectile.ai[0] == 9f) { - num296 = 0.5f; + dustScaleSize = 0.5f; } else if (projectile.ai[0] == 10f) { - num296 = 0.75f; + dustScaleSize = 0.75f; } projectile.ai[0] += 1f; - int num297 = 6; - if (Main.rand.Next(1) == 0) - { - for (int num298 = 0; num298 < 2; num298++) - { - int num299 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, num297, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 10, default, 0.75f); - Dust dust = Main.dust[num299]; - if (Main.rand.Next(3) == 0) - { - dust.noGravity = true; - dust.scale *= 1.75f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.noGravity = true; - dust.scale *= 0.5f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= num296; - dust.velocity += projectile.velocity; - } + int dustType = DustID.Fire; + for (int i = 0; i < 2; i++) + { + int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 10, default, 0.75f); + Dust dust = Main.dust[fire]; + if (Main.rand.Next(3) == 0) + { + dust.noGravity = true; + dust.scale *= 1.75f; + dust.velocity.X *= 2f; + dust.velocity.Y *= 2f; + } + else + { + dust.noGravity = true; + dust.scale *= 0.5f; + } + dust.velocity.X *= 1.2f; + dust.velocity.Y *= 1.2f; + dust.scale *= dustScaleSize; + dust.velocity += projectile.velocity; } } - else - { - projectile.ai[0] += 1f; - } + projectile.rotation += 0.3f * (float)projectile.direction; } diff --git a/Projectiles/Summon/AstralProbeRound.cs b/Projectiles/Summon/AstralProbeRound.cs index 8ec459fb29..09f08b9890 100644 --- a/Projectiles/Summon/AstralProbeRound.cs +++ b/Projectiles/Summon/AstralProbeRound.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Projectiles.Summon { ModContent.DustType(), ModContent.DustType() - }; + }); int astral = Dust.NewDust(projectile.position, 1, 1, randomDust, 0f, 0f, 0, default, 0.5f); Main.dust[astral].alpha = projectile.alpha; Main.dust[astral].velocity *= 0f;