diff --git a/Buffs/SummonerAmbitionBuff.cs b/Buffs/SummonerAmbitionBuff.cs index db74a1e..5d9d460 100644 --- a/Buffs/SummonerAmbitionBuff.cs +++ b/Buffs/SummonerAmbitionBuff.cs @@ -4,32 +4,27 @@ using Terraria.ModLoader; namespace YHTMod.Buffs; -public class SummonerAmbitionBuff : ModBuff -{ - public override void SetStaticDefaults() - { +public class SummonerAmbitionBuff : ModBuff { + public override void SetStaticDefaults() { Main.buffNoSave[Type] = true; Main.buffNoTimeDisplay[Type] = true; } - public override void ModifyBuffText(ref string buffName, ref string tip, ref int rare) - { - var modPlayer = Main.LocalPlayer.TryGetModPlayer(out var mp) ? mp : null; + public override void ModifyBuffText(ref string buffName, ref string tip, ref int rare) { + YhtPlayer modPlayer = Main.LocalPlayer.TryGetModPlayer(out var mp) ? mp : null; if (modPlayer == null) return; - tip = Language.GetTextValue("Mods.YHTMod.Buffs.SummonerAmbitionBuff.Description", modPlayer.SummonerAmbitions.Count); + tip = Language.GetTextValue("Mods.YHTMod.Buffs.SummonerAmbitionBuff.Description", + modPlayer.SummonerAmbitions.Count); } - public override void Update(Player player, ref int buffIndex) - { - var modPlayer = player.GetModPlayer(); + public override void Update(Player player, ref int buffIndex) { + YhtPlayer modPlayer = player.GetModPlayer(); - if (modPlayer.SummonerAmbition) - { + if (modPlayer.SummonerAmbition) { player.buffTime[buffIndex] = 18000; } - else - { + else { player.DelBuff(buffIndex); buffIndex--; } diff --git a/Buffs/ToclafaneMinionBuff.cs b/Buffs/ToclafaneMinionBuff.cs index 053c799..e885e31 100644 --- a/Buffs/ToclafaneMinionBuff.cs +++ b/Buffs/ToclafaneMinionBuff.cs @@ -4,24 +4,19 @@ using YHTMod.Projectiles.Weapons; namespace YHTMod.Buffs; -public class ToclafaneMinionBuff : ModBuff -{ - public override void SetStaticDefaults() - { +public class ToclafaneMinionBuff : ModBuff { + public override void SetStaticDefaults() { Main.buffNoSave[Type] = true; Main.buffNoTimeDisplay[Type] = true; } - public override void Update(Player player, ref int buffIndex) - { - if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) - { + public override void Update(Player player, ref int buffIndex) { + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) { player.buffTime[buffIndex] = 18000; } - else - { + else { player.DelBuff(buffIndex); buffIndex--; } } -} \ No newline at end of file +} diff --git a/Changes/BossKillListener.cs b/Changes/BossKillListener.cs index b3c6147..5fd0275 100644 --- a/Changes/BossKillListener.cs +++ b/Changes/BossKillListener.cs @@ -7,12 +7,9 @@ using Terraria.ModLoader; namespace YHTMod.Changes; -public class BossKillListener : GlobalNPC -{ - public override void OnKill(NPC npc) - { - switch (npc.type) - { +public class BossKillListener : GlobalNPC { + public override void OnKill(NPC npc) { + switch (npc.type) { case NPCID.KingSlime: HandleBossKill(npc, "king_slime"); break; @@ -22,9 +19,8 @@ public class BossKillListener : GlobalNPC case NPCID.EaterofWorldsHead: case NPCID.EaterofWorldsBody: case NPCID.EaterofWorldsTail: - var foundEaterSegments = 0; - foreach (var activeNpC in Main.ActiveNPCs) - { + int foundEaterSegments = 0; + foreach (NPC activeNpC in Main.ActiveNPCs) { if (activeNpC.friendly || activeNpC.townNPC) continue; if (activeNpC.type is not NPCID.EaterofWorldsBody and not NPCID.EaterofWorldsHead @@ -55,15 +51,12 @@ public class BossKillListener : GlobalNPC base.OnKill(npc); } - private static void HandleBossKill(NPC npc, string bossKey) - { - foreach (var player in Main.ActivePlayers) - { - var modPlayer = player.GetModPlayer(); + private static void HandleBossKill(NPC npc, string bossKey) { + foreach (Player player in Main.ActivePlayers) { + YhtPlayer modPlayer = player.GetModPlayer(); if (!npc.playerInteraction[player.whoAmI]) continue; - if (modPlayer.SummonerAmbition && modPlayer.SummonerAmbitions.Add(bossKey)) - { + if (modPlayer.SummonerAmbition && modPlayer.SummonerAmbitions.Add(bossKey)) { ChatHelper.SendChatMessageToClient( NetworkText.FromLiteral("Your Summoner Ambition's potential grows stronger!"), Color.MediumPurple, diff --git a/Changes/NPCLoot.cs b/Changes/NPCLoot.cs index 6154d14..0560b5c 100644 --- a/Changes/NPCLoot.cs +++ b/Changes/NPCLoot.cs @@ -8,19 +8,15 @@ using YHTMod.Items.ArcaneMissile; namespace YHTMod.Changes; -public class NpcLoot : GlobalNPC -{ - public override void ModifyNPCLoot(NPC npc, NPCLoot npcLoot) - { - var id = npc.type; +public class NpcLoot : GlobalNPC { + public override void ModifyNPCLoot(NPC npc, NPCLoot npcLoot) { + int id = npc.type; - if (NPCID.Sets.CountsAsCritter[id]) - { + if (NPCID.Sets.CountsAsCritter[id]) { npcLoot.Add(ItemDropRule.Common(ModContent.ItemType(), 400)); } - switch (id) - { + switch (id) { case NPCID.Plantera: npcLoot.Add(ItemDropRule.Common(ItemID.ChlorophyteOre, 1, 60, 80)); break; @@ -29,4 +25,4 @@ public class NpcLoot : GlobalNPC break; } } -} \ No newline at end of file +} diff --git a/Changes/SummonerOnHitEffects.cs b/Changes/SummonerOnHitEffects.cs index a204090..426bf6b 100644 --- a/Changes/SummonerOnHitEffects.cs +++ b/Changes/SummonerOnHitEffects.cs @@ -5,24 +5,19 @@ using Vector2 = Microsoft.Xna.Framework.Vector2; namespace YHTMod.Changes; -public class SummonerOnHitEffects : GlobalProjectile -{ - public override void OnHitNPC(Projectile projectile, NPC target, NPC.HitInfo hit, int damageDone) - { - var player = Main.player[projectile.owner]; - var modPlayer = player.GetModPlayer(); - if (projectile.minion && Main.myPlayer == projectile.owner) - { - if (modPlayer.SummonerAmbition) - { +public class SummonerOnHitEffects : GlobalProjectile { + public override void OnHitNPC(Projectile projectile, NPC target, NPC.HitInfo hit, int damageDone) { + Player player = Main.player[projectile.owner]; + YhtPlayer modPlayer = player.GetModPlayer(); + if (projectile.minion && Main.myPlayer == projectile.owner) { + if (modPlayer.SummonerAmbition) { if ( modPlayer.SummonerAmbitions.Contains("deerclops") && modPlayer.SummonerAmbitionDeerclopsCooldown == 0 && Main.rand.NextBool(10) - ) - { + ) { modPlayer.SummonerAmbitionDeerclopsCooldown = 5 * 60; - var direction = new Vector2(Main.rand.NextFloat(-1f, 1f), Main.rand.NextFloat(-1f, 1f)); + Vector2 direction = new Vector2(Main.rand.NextFloat(-1f, 1f), Main.rand.NextFloat(-1f, 1f)); direction.Normalize(); direction *= Main.rand.NextFloat(4f, 8f); Projectile.NewProjectile( @@ -39,18 +34,16 @@ public class SummonerOnHitEffects : GlobalProjectile if ( modPlayer.SummonerAmbitions.Contains("queen_bee") && Main.rand.NextBool(4) - ) - { + ) { target.AddBuff(BuffID.Poisoned, 5 * 60); } } } - if (projectile.WhipSettings.Segments > 0) - { + if (projectile.WhipSettings.Segments > 0) { projectile.damage = (int)(projectile.damage * 1.1); } base.OnHitNPC(projectile, target, hit, damageDone); } -} \ No newline at end of file +} diff --git a/Items/ArcaneMissile/ArcaneMissile.cs b/Items/ArcaneMissile/ArcaneMissile.cs index c3e8baa..a55fc75 100644 --- a/Items/ArcaneMissile/ArcaneMissile.cs +++ b/Items/ArcaneMissile/ArcaneMissile.cs @@ -5,15 +5,12 @@ using Terraria.ModLoader; namespace YHTMod.Items.ArcaneMissile; -public class ArcaneMissile : ModItem -{ - public override void SetStaticDefaults() - { +public class ArcaneMissile : ModItem { + public override void SetStaticDefaults() { CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1; } - public override void SetDefaults() - { + public override void SetDefaults() { Item.width = 32; Item.height = 32; Item.accessory = true; @@ -24,10 +21,9 @@ public class ArcaneMissile : ModItem Item.noUseGraphic = true; } - public override void UpdateAccessory(Player player, bool hideVisual) - { + public override void UpdateAccessory(Player player, bool hideVisual) { player.GetModPlayer().ArcaneMissile = Item.damage; base.UpdateAccessory(player, hideVisual); } -} \ No newline at end of file +} diff --git a/Items/ArcaneMissile/ArcaneMissileBehavior.cs b/Items/ArcaneMissile/ArcaneMissileBehavior.cs index a468c1f..cf90a73 100644 --- a/Items/ArcaneMissile/ArcaneMissileBehavior.cs +++ b/Items/ArcaneMissile/ArcaneMissileBehavior.cs @@ -4,27 +4,22 @@ using Terraria.ModLoader; namespace YHTMod.Items.ArcaneMissile; -public class ArcaneMissileBehavior : GlobalNPC -{ - public override void OnHitByProjectile(NPC npc, Projectile projectile, NPC.HitInfo hitInfo, int damage) - { - if (!hitInfo.Crit) - { +public class ArcaneMissileBehavior : GlobalNPC { + public override void OnHitByProjectile(NPC npc, Projectile projectile, NPC.HitInfo hitInfo, int damage) { + if (!hitInfo.Crit) { base.OnHitByProjectile(npc, projectile, hitInfo, damage); return; } - if (Main.netMode == NetmodeID.Server) - { + if (Main.netMode == NetmodeID.Server) { return; } - var player = Main.LocalPlayer; + Player player = Main.LocalPlayer; - if (player.GetModPlayer().ArcaneMissile != 0 && projectile.DamageType == DamageClass.Magic) - { + if (player.GetModPlayer().ArcaneMissile != 0 && projectile.DamageType == DamageClass.Magic) { // player just crit with magic weapon while having arcane missile accessory - var proj = Projectile.NewProjectileDirect( + Projectile proj = Projectile.NewProjectileDirect( projectile.GetSource_FromThis("arcaneMissile"), Main.LocalPlayer.position, npc.position.DirectionFrom(Main.LocalPlayer.position), @@ -47,4 +42,4 @@ public class ArcaneMissileBehavior : GlobalNPC base.OnHitByProjectile(npc, projectile, hitInfo, damage); } -} \ No newline at end of file +} diff --git a/Items/CopperSwordOnAStick.cs b/Items/CopperSwordOnAStick.cs index 5c1db66..31c0ea8 100644 --- a/Items/CopperSwordOnAStick.cs +++ b/Items/CopperSwordOnAStick.cs @@ -5,15 +5,12 @@ using YHTMod.Projectiles.Weapons; namespace YHTMod.Items; -public class CopperSwordOnAStick : ModItem -{ - public override void SetStaticDefaults() - { +public class CopperSwordOnAStick : ModItem { + public override void SetStaticDefaults() { CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1; } - public override void SetDefaults() - { + public override void SetDefaults() { Item.DamageType = DamageClass.Melee; Item.damage = 3; Item.width = 80; @@ -34,12 +31,11 @@ public class CopperSwordOnAStick : ModItem Item.shoot = ModContent.ProjectileType(); } - public override void AddRecipes() - { + public override void AddRecipes() { CreateRecipe() .AddIngredient(ItemID.Wood, 5) .AddIngredient(ItemID.Rope, 5) .AddIngredient(ItemID.CopperShortsword) .Register(); } -} \ No newline at end of file +} diff --git a/Items/KatanaRedo.cs b/Items/KatanaRedo.cs index f465283..1d001bc 100644 --- a/Items/KatanaRedo.cs +++ b/Items/KatanaRedo.cs @@ -6,41 +6,36 @@ using Terraria.ModLoader; namespace YHTMod.Items; -public class KatanaRedo : GlobalItem -{ - public override void ModifyTooltips(Item item, List tooltips) - { +public class KatanaRedo : GlobalItem { + public override void ModifyTooltips(Item item, List tooltips) { if (item.type != ItemID.Katana) return; tooltips.Insert(5, new TooltipLine(YHTMod.GetInstance(), "flavor", "Nothing personel kid.")); tooltips.Insert(6, new TooltipLine(YHTMod.GetInstance(), "usage", "Right click to teleport behind them.")); } - public override bool AltFunctionUse(Item item, Player player) - { + public override bool AltFunctionUse(Item item, Player player) { return item.type == ItemID.Katana || base.AltFunctionUse(item, player); } - public override bool? UseItem(Item item, Player player) - { + public override bool? UseItem(Item item, Player player) { if (item.type != ItemID.Katana || player.altFunctionUse != 2) return null; - var yhtPlayer = player.GetModPlayer(); + YhtPlayer yhtPlayer = player.GetModPlayer(); if (yhtPlayer.KatanaTeleportCooldown > 0) return null; yhtPlayer.KatanaTeleportCooldown = 300; - for (var i = 0; i < Main.maxNPCs; i++) - { - var npc = Main.npc[i]; + for (int i = 0; i < Main.maxNPCs; i++) { + NPC npc = Main.npc[i]; if (!npc.CanBeChasedBy()) continue; - var between = Vector2.Distance(npc.Center, player.Center); - var inRange = between < 650; + float between = Vector2.Distance(npc.Center, player.Center); + bool inRange = between < 650; - var lineOfSight = Collision.CanHitLine(player.position, player.width, player.height, npc.position, + bool lineOfSight = Collision.CanHitLine(player.position, player.width, player.height, npc.position, npc.width, npc.height); if (!inRange || !lineOfSight) continue; - var tpPos = npc.position; + Vector2 tpPos = npc.position; tpPos.X += -(npc.direction * npc.width + (player.width * 2)); if (Collision.TileCollision(tpPos, Vector2.Zero, player.width, player.height) != Vector2.Zero) return true; @@ -53,4 +48,4 @@ public class KatanaRedo : GlobalItem return null; } -} \ No newline at end of file +} diff --git a/Items/MithrilPebbleOfPigSmiting.cs b/Items/MithrilPebbleOfPigSmiting.cs index acc6d79..878b9ae 100644 --- a/Items/MithrilPebbleOfPigSmiting.cs +++ b/Items/MithrilPebbleOfPigSmiting.cs @@ -5,15 +5,12 @@ using YHTMod.Projectiles.Weapons; namespace YHTMod.Items; -public class MithrilPebbleOfPigSmiting : ModItem -{ - public override void SetStaticDefaults() - { +public class MithrilPebbleOfPigSmiting : ModItem { + public override void SetStaticDefaults() { CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1; } - public override void SetDefaults() - { + public override void SetDefaults() { Item.DamageType = DamageClass.Ranged; Item.damage = 16; Item.width = 8; @@ -33,4 +30,4 @@ public class MithrilPebbleOfPigSmiting : ModItem Item.shootSpeed = 20f; Item.shoot = ModContent.ProjectileType(); } -} \ No newline at end of file +} diff --git a/Items/SummonersAmbition.cs b/Items/SummonersAmbition.cs index 6a430b4..dde7062 100644 --- a/Items/SummonersAmbition.cs +++ b/Items/SummonersAmbition.cs @@ -7,17 +7,14 @@ using Terraria.ModLoader; namespace YHTMod.Items; -public class SummonersAmbition : ModItem -{ - public override void SetStaticDefaults() - { +public class SummonersAmbition : ModItem { + public override void SetStaticDefaults() { CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1; } public override LocalizedText Tooltip => Language.GetText(""); - public override void SetDefaults() - { + public override void SetDefaults() { Item.width = 32; Item.height = 32; Item.accessory = true; @@ -27,76 +24,76 @@ public class SummonersAmbition : ModItem ItemID.Sets.ShimmerTransformToItem[Type] = 0; } - public override void UpdateAccessory(Player player, bool hideVisual) - { - var modPlayer = player.GetModPlayer(); + public override void UpdateAccessory(Player player, bool hideVisual) { + YhtPlayer modPlayer = player.GetModPlayer(); modPlayer.SummonerAmbition = true; } - public override void ModifyTooltips(List tooltips) - { - var player = Main.LocalPlayer.GetModPlayer(); + public override void ModifyTooltips(List tooltips) { + YhtPlayer player = Main.LocalPlayer.GetModPlayer(); tooltips.Add(new TooltipLine(Mod, "SummonerAmbition", Language.GetTextValue("Mods.YHTMod.Items.SummonersAmbition.Tooltip", player.GetSummonersAmbitionMinionBonus()))); - if (player.SummonerAmbitions.Contains("king_slime")) - { + if (player.SummonerAmbitions.Contains("king_slime")) { tooltips.Add(new TooltipLine(Mod, "SummonerAmbitionKingSlime", Language.GetTextValue("Mods.YHTMod.Items.SummonersAmbition.KingSlime"))); } - if (player.SummonerAmbitions.Contains("eye_of_cthulhu")) - { + if (player.SummonerAmbitions.Contains("eye_of_cthulhu")) { tooltips.Add(new TooltipLine(Mod, "SummonerAmbitionEyeOfCthulhu", Language.GetTextValue("Mods.YHTMod.Items.SummonersAmbition.EyeOfCthulhu"))); } - - if (player.SummonerAmbitions.Contains("deerclops")) - { + + if (player.SummonerAmbitions.Contains("deerclops")) { tooltips.Add(new TooltipLine(Mod, "SummonerAmbitionDeerclops", Language.GetTextValue("Mods.YHTMod.Items.SummonersAmbition.Deerclops"))); } - if (player.SummonerAmbitions.Contains("eater_of_worlds")) - { + if (player.SummonerAmbitions.Contains("eater_of_worlds")) { tooltips.Add(new TooltipLine(Mod, "SummonerAmbitionEaterOfWorlds", Language.GetTextValue("Mods.YHTMod.Items.SummonersAmbition.EaterOfWorlds"))); } - if (player.SummonerAmbitions.Contains("brain_of_cthulhu")) - { + if (player.SummonerAmbitions.Contains("brain_of_cthulhu")) { tooltips.Add(new TooltipLine(Mod, "SummonerAmbitionBrainOfCthulhu", Language.GetTextValue("Mods.YHTMod.Items.SummonersAmbition.BrainOfCthulhu"))); } - - if (player.SummonerAmbitions.Contains("queen_bee")) - { + + if (player.SummonerAmbitions.Contains("queen_bee")) { tooltips.Add(new TooltipLine(Mod, "SummonerAmbitionQueenBee", Language.GetTextValue("Mods.YHTMod.Items.SummonersAmbition.QueenBee"))); } - if (player.SummonerAmbitions.Contains("skeletron")) - { + if (player.SummonerAmbitions.Contains("skeletron")) { tooltips.Add(new TooltipLine(Mod, "SummonerAmbitionSkeletron", Language.GetTextValue("Mods.YHTMod.Items.SummonersAmbition.Skeletron"))); } - - if (player.SummonerAmbitions.Contains("wall_of_flesh")) - { + + if (player.SummonerAmbitions.Contains("wall_of_flesh")) { tooltips.Add(new TooltipLine(Mod, "SummonerAmbitionWallOfFlesh", Language.GetTextValue("Mods.YHTMod.Items.SummonersAmbition.WallOfFlesh"))); } } - public override void AddRecipes() - { + public override void AddRecipes() { CreateRecipe() .AddIngredient(ItemID.Rope, 5) .AddRecipeGroup(RecipeGroupID.Squirrels) .AddIngredient(ItemID.Acorn, 25) .AddTile(TileID.WorkBenches) .Register(); - } -} \ No newline at end of file + + public static bool IsPreHardmodeRealized(Player player) { + YhtPlayer modPlayer = player.GetModPlayer(); + return modPlayer.SummonerAmbitions.Contains("king_slime") + && modPlayer.SummonerAmbitions.Contains("eye_of_cthulhu") + && modPlayer.SummonerAmbitions.Contains("deerclops") + && modPlayer.SummonerAmbitions.Contains("eater_of_worlds") + && modPlayer.SummonerAmbitions.Contains("brain_of_cthulhu") + && modPlayer.SummonerAmbitions.Contains("queen_bee") + && modPlayer.SummonerAmbitions.Contains("skeletron") + && modPlayer.SummonerAmbitions.Contains("wall_of_flesh"); + } +} diff --git a/Items/ToclafaneStaff.cs b/Items/ToclafaneStaff.cs index 08403d6..11c38cc 100644 --- a/Items/ToclafaneStaff.cs +++ b/Items/ToclafaneStaff.cs @@ -10,18 +10,15 @@ using YHTMod.Projectiles.Weapons; namespace YHTMod.Items; -public class ToclafaneStaff : ModItem -{ - public override void SetStaticDefaults() - { +public class ToclafaneStaff : ModItem { + public override void SetStaticDefaults() { ItemID.Sets.GamepadWholeScreenUseRange[Item.type] = true; // This lets the player target anywhere on the whole screen while using a controller. ItemID.Sets.LockOnIgnoresCollision[Item.type] = true; CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1; } - public override void SetDefaults() - { + public override void SetDefaults() { Item.damage = 30; Item.knockBack = 3f; Item.mana = 10; @@ -40,16 +37,14 @@ public class ToclafaneStaff : ModItem } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, - int type, int damage, float knockback) - { + int type, int damage, float knockback) { player.AddBuff(Item.buffType, 2); position = Main.MouseWorld; return base.Shoot(player, source, position, velocity, type, damage, knockback); } - public override void AddRecipes() - { - var watchGroup = new RecipeGroup(() => Language.GetTextValue("Mods.YHTMod.Recipes.AnyWatch"), + public override void AddRecipes() { + RecipeGroup watchGroup = new RecipeGroup(() => Language.GetTextValue("Mods.YHTMod.Recipes.AnyWatch"), ItemID.GoldWatch, ItemID.SilverWatch, ItemID.TinWatch, @@ -59,30 +54,28 @@ public class ToclafaneStaff : ModItem ); RecipeGroup.RegisterGroup("YHTMod:Watches", watchGroup); - var tier2BarGroup = new RecipeGroup(() => Language.GetTextValue("Mods.YHTMod.Recipes.Tier2Bars"), + RecipeGroup tier2BarGroup = new RecipeGroup(() => Language.GetTextValue("Mods.YHTMod.Recipes.Tier2Bars"), ItemID.MythrilBar, ItemID.OrichalcumBar ); RecipeGroup.RegisterGroup("YHTMod:Tier2Bars", tier2BarGroup); - var recipe = CreateRecipe(); + Recipe recipe = CreateRecipe(); recipe.AddRecipeGroup(watchGroup); recipe.AddIngredient(ItemID.GuideVoodooDoll); recipe.AddTile(TileID.MythrilAnvil); // Calamity delays when you obtain hallowed bars, so use alternate recipe if Calamity is installed - if (ModLoader.HasMod("CalamityMod")) - { + if (ModLoader.HasMod("CalamityMod")) { recipe.AddRecipeGroup(tier2BarGroup, 35); recipe.AddIngredient(ItemID.SoulofLight, 10); recipe.AddIngredient(ItemID.SoulofNight, 10); } - else - { + else { recipe.AddIngredient(ItemID.HallowedBar, 15); } recipe.Register(); } -} \ No newline at end of file +} diff --git a/Projectiles/Weapons/CopperSwordOnAStickProjectile.cs b/Projectiles/Weapons/CopperSwordOnAStickProjectile.cs index 00c58d8..b285ac8 100644 --- a/Projectiles/Weapons/CopperSwordOnAStickProjectile.cs +++ b/Projectiles/Weapons/CopperSwordOnAStickProjectile.cs @@ -6,10 +6,8 @@ using Terraria.ModLoader; namespace YHTMod.Projectiles.Weapons; -class CopperSwordOnAStickProjectile : ModProjectile -{ - public override void SetDefaults() - { +class CopperSwordOnAStickProjectile : ModProjectile { + public override void SetDefaults() { Projectile.width = 80; Projectile.height = 80; @@ -23,8 +21,7 @@ class CopperSwordOnAStickProjectile : ModProjectile Projectile.aiStyle = ProjAIStyleID.ShortSword; } - public override void AI() - { + public override void AI() { base.AI(); float random = (float)(Random.Shared.NextDouble() / 5f); Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2 - @@ -33,4 +30,4 @@ class CopperSwordOnAStickProjectile : ModProjectile DrawOriginOffsetX = 0; DrawOffsetX = 0; } -} \ No newline at end of file +} diff --git a/Projectiles/Weapons/MithrilPebbleOfPigSmitingProjectile.cs b/Projectiles/Weapons/MithrilPebbleOfPigSmitingProjectile.cs index d3648f3..44f163e 100644 --- a/Projectiles/Weapons/MithrilPebbleOfPigSmitingProjectile.cs +++ b/Projectiles/Weapons/MithrilPebbleOfPigSmitingProjectile.cs @@ -5,10 +5,8 @@ using Terraria.ModLoader; namespace YHTMod.Projectiles.Weapons; -class MithrilPebbleOfPigSmitingProjectile : ModProjectile -{ - public override void SetDefaults() - { +class MithrilPebbleOfPigSmitingProjectile : ModProjectile { + public override void SetDefaults() { Projectile.width = 8; Projectile.height = 8; Projectile.friendly = true; @@ -22,13 +20,12 @@ class MithrilPebbleOfPigSmitingProjectile : ModProjectile Projectile.light = 0.3f; } - public override void AI() - { + public override void AI() { base.AI(); DrawOriginOffsetX = 0; DrawOffsetX = 0; - var dust = Dust.NewDust(Projectile.Center, 1, 1, DustID.Mythril, 0f, 0f, 0, default(Color), 1f); + int dust = Dust.NewDust(Projectile.Center, 1, 1, DustID.Mythril, 0f, 0f, 0, default(Color), 1f); Main.dust[dust].noGravity = true; Main.dust[dust].velocity *= 0.3f; } -} \ No newline at end of file +} diff --git a/Projectiles/Weapons/ToclafaneMinion.cs b/Projectiles/Weapons/ToclafaneMinion.cs index 69c9a9a..375a2e5 100644 --- a/Projectiles/Weapons/ToclafaneMinion.cs +++ b/Projectiles/Weapons/ToclafaneMinion.cs @@ -7,13 +7,11 @@ using YHTMod.Buffs; namespace YHTMod.Projectiles.Weapons; -public class ToclafaneMinion : ModProjectile -{ +public class ToclafaneMinion : ModProjectile { private int _shootCooldown = 0; private AttackMode _attackMode = AttackMode.Ranged; - public override void SetStaticDefaults() - { + public override void SetStaticDefaults() { // Sets the amount of frames this minion has on its spritesheet Main.projFrames[Projectile.type] = 8; // This is necessary for right-click targeting @@ -23,8 +21,7 @@ public class ToclafaneMinion : ModProjectile ProjectileID.Sets.MinionSacrificable[Projectile.type] = true; } - public sealed override void SetDefaults() - { + public sealed override void SetDefaults() { Projectile.width = 32; Projectile.height = 32; Projectile.scale = 0.65f; @@ -37,29 +34,24 @@ public class ToclafaneMinion : ModProjectile Projectile.penetrate = -1; } - public override bool? CanCutTiles() - { + public override bool? CanCutTiles() { return false; } - public override bool MinionContactDamage() - { + public override bool MinionContactDamage() { return true; } - public override void AI() - { - var player = Main.player[Projectile.owner]; + public override void AI() { + Player player = Main.player[Projectile.owner]; #region Active check - if (player.dead || !player.active) - { + if (player.dead || !player.active) { player.ClearBuff(ModContent.BuffType()); } - if (player.HasBuff(ModContent.BuffType())) - { + if (player.HasBuff(ModContent.BuffType())) { Projectile.timeLeft = 2; } @@ -67,8 +59,7 @@ public class ToclafaneMinion : ModProjectile #region General behavior - if (_shootCooldown > 0) - { + if (_shootCooldown > 0) { _shootCooldown = _shootCooldown - 1; } @@ -85,8 +76,7 @@ public class ToclafaneMinion : ModProjectile // Teleport to player if distance is too big var vectorToIdlePosition = idlePosition - Projectile.Center; var distanceToIdlePosition = vectorToIdlePosition.Length(); - if (Main.myPlayer == player.whoAmI && distanceToIdlePosition > 2000f) - { + if (Main.myPlayer == player.whoAmI && distanceToIdlePosition > 2000f) { // Whenever you deal with non-regular events that change the behavior or position drastically, make sure to only run the code on the owner of the projectile, // and then set netUpdate to true Projectile.position = idlePosition; @@ -96,8 +86,7 @@ public class ToclafaneMinion : ModProjectile // If your minion is flying, you want to do this independently of any conditions const float overlapVelocity = 0.04f; - for (var i = 0; i < Main.maxProjectiles; i++) - { + for (var i = 0; i < Main.maxProjectiles; i++) { // Fix overlap with other minions var other = Main.projectile[i]; if (i == Projectile.whoAmI || !other.active || other.owner != Projectile.owner || @@ -119,23 +108,19 @@ public class ToclafaneMinion : ModProjectile var foundTarget = false; // This code is required if your minion weapon has the targeting feature - if (player.HasMinionAttackTargetNPC) - { + if (player.HasMinionAttackTargetNPC) { var npc = Main.npc[player.MinionAttackTargetNPC]; var between = Vector2.Distance(npc.Center, Projectile.Center); // Reasonable distance away so it doesn't target across multiple screens - if (between < 2000f) - { + if (between < 2000f) { distanceFromTarget = between; targetCenter = npc.Center; foundTarget = true; } } - if (!foundTarget) - { - for (var i = 0; i < Main.maxNPCs; i++) - { + if (!foundTarget) { + for (var i = 0; i < Main.maxNPCs; i++) { var npc = Main.npc[i]; if (!npc.CanBeChasedBy()) continue; var between = Vector2.Distance(npc.Center, Projectile.Center); @@ -163,24 +148,20 @@ public class ToclafaneMinion : ModProjectile var speed = 8f; var inertia = 20f; - if (foundTarget) - { + if (foundTarget) { var direction = targetCenter - Projectile.Center; direction.Normalize(); - if (distanceFromTarget > 40f) - { + if (distanceFromTarget > 40f) { // The immediate range around the target (so it doesn't latch onto it when close) direction *= speed; Projectile.velocity = (Projectile.velocity * (inertia - 1) + direction) / inertia; } - switch (distanceFromTarget) - { + switch (distanceFromTarget) { case <= 120f: _attackMode = AttackMode.Melee; break; - case > 120f when _shootCooldown == 0: - { + case > 120f when _shootCooldown == 0: { _shootCooldown = 60; // 1 second between shots var laser = Projectile.NewProjectileDirect(player.GetSource_FromThis(), Projectile.Center, direction, ProjectileID.DeathLaser, 30, Projectile.knockBack, Projectile.owner); @@ -192,24 +173,20 @@ public class ToclafaneMinion : ModProjectile } } } - else - { + else { // Minion doesn't have a target: return to player and idle - if (distanceToIdlePosition > 600f) - { + if (distanceToIdlePosition > 600f) { // Speed up the minion if it's away from the player speed = 12f; inertia = 60f; } - else - { + else { // Slow down the minion if closer to the player speed = 4f; inertia = 80f; } - if (distanceToIdlePosition > 20f) - { + if (distanceToIdlePosition > 20f) { // The immediate range around the player (when it passively floats about) // This is a simple movement formula using the two parameters and its desired direction to create a "homing" movement @@ -217,8 +194,7 @@ public class ToclafaneMinion : ModProjectile vectorToIdlePosition *= speed; Projectile.velocity = (Projectile.velocity * (inertia - 1) + vectorToIdlePosition) / inertia; } - else if (Projectile.velocity == Vector2.Zero) - { + else if (Projectile.velocity == Vector2.Zero) { // If there is a case where it's not moving at all, give it a little "poke" Projectile.velocity.X = -0.15f; Projectile.velocity.Y = -0.05f; @@ -234,14 +210,11 @@ public class ToclafaneMinion : ModProjectile const int frameSpeed = 8; Projectile.frameCounter++; - if (Projectile.frameCounter >= frameSpeed) - { + if (Projectile.frameCounter >= frameSpeed) { Projectile.frameCounter = 0; - switch (_attackMode) - { + switch (_attackMode) { case AttackMode.Melee: - switch (Projectile.frame) - { + switch (Projectile.frame) { case 0: case 1: case 2: @@ -266,8 +239,7 @@ public class ToclafaneMinion : ModProjectile break; case AttackMode.Ranged: - switch (Projectile.frame) - { + switch (Projectile.frame) { case 0: Projectile.frame = 5; break; @@ -301,9 +273,8 @@ public class ToclafaneMinion : ModProjectile #endregion } - private enum AttackMode - { + private enum AttackMode { Melee, Ranged, } -} \ No newline at end of file +} diff --git a/YHTMod.cs b/YHTMod.cs index a01874d..b6cdbe9 100644 --- a/YHTMod.cs +++ b/YHTMod.cs @@ -1,14 +1,15 @@ using Terraria.ModLoader; -namespace YHTMod { - public class YHTMod : Mod { - private static YHTMod _mod; - public YHTMod() { - _mod = this; - } +namespace YHTMod; - public static YHTMod GetInstance() { - return _mod; - } - } -} \ No newline at end of file +public class YHTMod : Mod { + private static YHTMod _mod; + + public YHTMod() { + _mod = this; + } + + public static YHTMod GetInstance() { + return _mod; + } +} diff --git a/YHTMod.csproj b/YHTMod.csproj index 69fad5b..ce365bb 100644 --- a/YHTMod.csproj +++ b/YHTMod.csproj @@ -5,6 +5,4 @@ YHTMod latest - - \ No newline at end of file diff --git a/YhtPlayer.cs b/YhtPlayer.cs index 3fe20a9..81f99e9 100644 --- a/YhtPlayer.cs +++ b/YhtPlayer.cs @@ -6,8 +6,7 @@ using YHTMod.Buffs; namespace YHTMod; -public class YhtPlayer : ModPlayer -{ +public class YhtPlayer : ModPlayer { public int ArcaneMissile = 0; public int KatanaTeleportCooldown = 0; public int SummonerAmbitionDeerclopsCooldown = 0; @@ -20,68 +19,54 @@ public class YhtPlayer : ModPlayer */ public HashSet SummonerAmbitions = []; - public override void PreUpdate() - { + public override void PreUpdate() { KatanaTeleportCooldown = Math.Max(KatanaTeleportCooldown - 1, 0); SummonerAmbitionDeerclopsCooldown = Math.Max(SummonerAmbitionDeerclopsCooldown - 1, 0); } - public override void PostUpdateEquips() - { - if (SummonerAmbition) - { + public override void PostUpdateEquips() { + if (SummonerAmbition) { Player.AddBuff(ModContent.BuffType(), 1); Player.maxMinions += GetSummonersAmbitionMinionBonus(); - if (SummonerAmbitions.Contains("king_slime")) - { + if (SummonerAmbitions.Contains("king_slime")) { Player.whipRangeMultiplier += 0.2f; } - if (SummonerAmbitions.Contains("eater_of_worlds")) - { + if (SummonerAmbitions.Contains("eater_of_worlds")) { Player.GetArmorPenetration(DamageClass.Summon) += 5; } - if (SummonerAmbitions.Contains("brain_of_cthulhu")) - { + if (SummonerAmbitions.Contains("brain_of_cthulhu")) { Player.GetDamage(DamageClass.Summon) += 0.05f; } - if (SummonerAmbitions.Contains("skeletron")) - { + if (SummonerAmbitions.Contains("skeletron")) { Player.GetKnockback(DamageClass.Summon) += 0.1f; } } } - public override void ResetEffects() - { + public override void ResetEffects() { ArcaneMissile = 0; SummonerAmbition = false; base.ResetEffects(); } - public override void SaveData(TagCompound tag) - { + public override void SaveData(TagCompound tag) { tag["summonerAmbitions"] = new List(SummonerAmbitions); } - public override void LoadData(TagCompound tag) - { - if (tag.ContainsKey("summonerAmbitions")) - { - var list = tag.GetList("summonerAmbitions"); - SummonerAmbitions = new HashSet(list); - } + public override void LoadData(TagCompound tag) { + if (!tag.ContainsKey("summonerAmbitions")) return; + IList list = tag.GetList("summonerAmbitions"); + SummonerAmbitions = new HashSet(list); } - public int GetSummonersAmbitionMinionBonus() - { - var amount = 1; - if (SummonerAmbitions.Contains("wall_of_flesh")) - { + public int GetSummonersAmbitionMinionBonus() { + int amount = 1; + if (SummonerAmbitions.Contains("wall_of_flesh")) { amount += 1; }