From 9cb093d8df9ee1cc9b8e6c743168b5e0f048388b Mon Sep 17 00:00:00 2001 From: YouHaveTrouble Date: Sun, 4 Jan 2026 00:36:55 +0100 Subject: [PATCH] pre-hardmode summoner's ambition --- Buffs/SummonerAmbitionBuff.cs | 6 +- Changes/BossKillListener.cs | 21 +++++- Changes/SummonerOnHitEffects.cs | 56 ++++++++++++++ Items/SummonersAmbition.cs | 109 ++++++++++++--------------- Localization/en-US_Mods.YHTMod.hjson | 29 +++---- YhtPlayer.cs | 60 ++++++++++----- 6 files changed, 176 insertions(+), 105 deletions(-) create mode 100644 Changes/SummonerOnHitEffects.cs diff --git a/Buffs/SummonerAmbitionBuff.cs b/Buffs/SummonerAmbitionBuff.cs index 4dea666..db74a1e 100644 --- a/Buffs/SummonerAmbitionBuff.cs +++ b/Buffs/SummonerAmbitionBuff.cs @@ -16,14 +16,14 @@ public class SummonerAmbitionBuff : ModBuff { var modPlayer = Main.LocalPlayer.TryGetModPlayer(out var mp) ? mp : null; if (modPlayer == null) return; - - tip = Language.GetTextValue("Mods.YHTMod.Buffs.SummonerAmbitionBuff.Description", modPlayer.SummonerAmbitionCrafts.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(); - + if (modPlayer.SummonerAmbition) { player.buffTime[buffIndex] = 18000; diff --git a/Changes/BossKillListener.cs b/Changes/BossKillListener.cs index 48ce9d2..b3c6147 100644 --- a/Changes/BossKillListener.cs +++ b/Changes/BossKillListener.cs @@ -20,11 +20,27 @@ public class BossKillListener : GlobalNPC HandleBossKill(npc, "eye_of_cthulhu"); break; case NPCID.EaterofWorldsHead: + case NPCID.EaterofWorldsBody: + case NPCID.EaterofWorldsTail: + var foundEaterSegments = 0; + foreach (var activeNpC in Main.ActiveNPCs) + { + if (activeNpC.friendly || activeNpC.townNPC) continue; + if (activeNpC.type is not NPCID.EaterofWorldsBody + and not NPCID.EaterofWorldsHead + and not NPCID.EaterofWorldsTail + ) continue; + if (++foundEaterSegments > 1) break; + } + HandleBossKill(npc, "eater_of_worlds"); break; case NPCID.BrainofCthulhu: HandleBossKill(npc, "brain_of_cthulhu"); break; + case NPCID.Deerclops: + HandleBossKill(npc, "deerclops"); + break; case NPCID.QueenBee: HandleBossKill(npc, "queen_bee"); break; @@ -45,10 +61,11 @@ public class BossKillListener : GlobalNPC { var modPlayer = player.GetModPlayer(); if (!npc.playerInteraction[player.whoAmI]) continue; - if (modPlayer.KilledBosses.Add(bossKey)) + + if (modPlayer.SummonerAmbition && modPlayer.SummonerAmbitions.Add(bossKey)) { ChatHelper.SendChatMessageToClient( - NetworkText.FromLiteral("Your Ambition's potential grows stronger!"), + NetworkText.FromLiteral("Your Summoner Ambition's potential grows stronger!"), Color.MediumPurple, player.whoAmI ); diff --git a/Changes/SummonerOnHitEffects.cs b/Changes/SummonerOnHitEffects.cs new file mode 100644 index 0000000..a204090 --- /dev/null +++ b/Changes/SummonerOnHitEffects.cs @@ -0,0 +1,56 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +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) + { + 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)); + direction.Normalize(); + direction *= Main.rand.NextFloat(4f, 8f); + Projectile.NewProjectile( + player.GetSource_OnHit(target), + target.Center, + direction, + ProjectileID.InsanityShadowFriendly, + projectile.damage / 2, + 0f, + projectile.owner + ); + } + + if ( + modPlayer.SummonerAmbitions.Contains("queen_bee") + && Main.rand.NextBool(4) + ) + { + target.AddBuff(BuffID.Poisoned, 5 * 60); + } + } + } + + 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/SummonersAmbition.cs b/Items/SummonersAmbition.cs index e0c01ee..5296c4a 100644 --- a/Items/SummonersAmbition.cs +++ b/Items/SummonersAmbition.cs @@ -31,19 +31,62 @@ public class SummonersAmbition : ModItem { var modPlayer = player.GetModPlayer(); modPlayer.SummonerAmbition = true; - modPlayer.HasAmbition = true; } public override void ModifyTooltips(List tooltips) { var player = Main.LocalPlayer.GetModPlayer(); - tooltips.Add(new TooltipLine(Mod, "SummonerAmbition", Language.GetTextValue("Mods.YHTMod.Items.SummonersAmbition.Tooltip", player.GetSummonersAmbitionMinionBonus()))); + tooltips.Add(new TooltipLine(Mod, "SummonerAmbition", + Language.GetTextValue("Mods.YHTMod.Items.SummonersAmbition.Tooltip", + player.GetSummonersAmbitionMinionBonus()))); - if (player.KilledBosses.Contains("king_slime")) + if (player.SummonerAmbitions.Contains("king_slime")) { - tooltips.Add(new TooltipLine(Mod, "SummonerAmbitionKingSlime", Language.GetTextValue("Mods.YHTMod.Items.SummonersAmbition.KingSlime"))); + tooltips.Add(new TooltipLine(Mod, "SummonerAmbitionKingSlime", + Language.GetTextValue("Mods.YHTMod.Items.SummonersAmbition.KingSlime"))); } + 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")) + { + tooltips.Add(new TooltipLine(Mod, "SummonerAmbitionDeerclops", + Language.GetTextValue("Mods.YHTMod.Items.SummonersAmbition.Deerclops"))); + } + + 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")) + { + tooltips.Add(new TooltipLine(Mod, "SummonerAmbitionBrainOfCthulhu", + Language.GetTextValue("Mods.YHTMod.Items.SummonersAmbition.BrainOfCthulhu"))); + } + + if (player.SummonerAmbitions.Contains("queen_bee")) + { + tooltips.Add(new TooltipLine(Mod, "SummonerAmbitionQueenBee", + Language.GetTextValue("Mods.YHTMod.Items.SummonersAmbition.QueenBee"))); + } + + 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")) + { + tooltips.Add(new TooltipLine(Mod, "SummonerAmbitionWallOfFlesh", + Language.GetTextValue("Mods.YHTMod.Items.SummonersAmbition.WallOfFlesh"))); + } } public override void AddRecipes() @@ -55,61 +98,5 @@ public class SummonersAmbition : ModItem .AddTile(TileID.WorkBenches) .Register(); - #region Upgrades - - CreateRecipe() - .AddIngredient(this) - .AddTile(TileID.DemonAltar) - .AddIngredient(ItemID.Gel, 250) - .AddCondition(new Condition( - Language.GetText("Mods.YHTMod.Recipes.Ambitions.KingSlimeDead"), - () => - { - var player = Main.LocalPlayer.GetModPlayer(); - return player.KilledBosses.Contains("king_slime") && !player.SummonerAmbitionCrafts.Contains("king_slime"); - }) - ) - .AddOnCraftCallback((recipe, item, consumed, destination) => - { - Main.LocalPlayer.GetModPlayer().SummonerAmbitionCrafts.Add("king_slime"); - }) - .Register(); - - CreateRecipe() - .AddIngredient(this) - .AddTile(TileID.DemonAltar) - .AddIngredient(ItemID.Lens, 100) - .AddCondition(new Condition(Language.GetText( - "Mods.YHTMod.Recipes.Ambitions.EyeOfCthulhuDead"), - () => - { - var player = Main.LocalPlayer.GetModPlayer(); - return player.KilledBosses.Contains("eye_of_cthulhu") && !player.SummonerAmbitionCrafts.Contains("eye_of_cthulhu"); - }) - ) - .AddOnCraftCallback((recipe, item, consumed, destination) => - { - Main.LocalPlayer.GetModPlayer().SummonerAmbitionCrafts.Add("eye_of_cthulhu"); - }) - .Register(); - - CreateRecipe() - .AddIngredient(this) - .AddTile(TileID.DemonAltar) - .AddIngredient(ItemID.Bone, 250) - .AddCondition(new Condition(Language.GetText( - "Mods.YHTMod.Recipes.Ambitions.SkeletronDead"), - () => { - var player = Main.LocalPlayer.GetModPlayer(); - return player.KilledBosses.Contains("skeletron") && !player.SummonerAmbitionCrafts.Contains("skeletron"); - }) - ) - .AddOnCraftCallback((recipe, item, consumed, destination) => - { - Main.LocalPlayer.GetModPlayer().SummonerAmbitionCrafts.Add("skeletron"); - }) - .Register(); - - #endregion } -} +} \ No newline at end of file diff --git a/Localization/en-US_Mods.YHTMod.hjson b/Localization/en-US_Mods.YHTMod.hjson index 7dd0258..8dd4196 100644 --- a/Localization/en-US_Mods.YHTMod.hjson +++ b/Localization/en-US_Mods.YHTMod.hjson @@ -1,16 +1,6 @@ Recipes: { AnyWatch: Any Watch Tier2Bars: Tier 2 Hardmode Bars - - Ambitions: { - KingSlimeDead: King Slime Defeated - EyeOfCthulhuDead: Eye of Cthulhu Defeated - EaterOfWorldsDead: Eater of Worlds Defeated - BrainOfCthulhuDead: Brain of Cthulhu Defeated - QueenBeeDead: Queen Bee Defeated - SkeletronDead: Skeletron Defeated - WallOfFleshDead: Wall of Flesh Defeated - } } Buffs: { @@ -24,7 +14,7 @@ Buffs: { Description: ''' Your power grows with your ambition. - + Essences absorbed: {0} ''' } @@ -80,18 +70,17 @@ Items: { Tooltip: ''' Grants Summoner's Ambition. - Buff can be empowered by slaying powerful enemies and absorbing their essences. "For those who seek to lead." {$CommonItemTooltip.IncreasesMaxMinionsBy@0} ''' - KingSlime: "[i:560] +5 summon tag damage." - EyeOfCthulhu: "[i:43] Increases minion speed." - EaterOfWorlds: "[i:70] Minions penetrate 5 armor." - BrainOfCthulhu: "[i:1331] 5% increased minion damage." - QueenBee: "[i:1133] Minion hits can inflict poison." - Deerclops: "[i:5120] Minion hits can spawn shadow hands." - Skeletron: "[i:4801] Increases minion knockback." - WallOfFlesh: "[i:267] Increases max number of minions by 1." + KingSlime: "[i:560] 20% increased whip size" + EyeOfCthulhu: "[i:43] Increases whip damage by 10%" + EaterOfWorlds: "[i:70] Summon damage penetrates 5 armor" + BrainOfCthulhu: "[i:1331] 5% increased minion damage" + QueenBee: "[i:1133] Minion hits can inflict poison" + Deerclops: "[i:5120] Minion hits can spawn shadow hands" + Skeletron: "[i:4801] Increases minion knockback" + WallOfFlesh: "[i:267] Increases max number of minions by 1" } } diff --git a/YhtPlayer.cs b/YhtPlayer.cs index 094ba6b..3fe20a9 100644 --- a/YhtPlayer.cs +++ b/YhtPlayer.cs @@ -10,59 +10,81 @@ public class YhtPlayer : ModPlayer { public int ArcaneMissile = 0; public int KatanaTeleportCooldown = 0; + public int SummonerAmbitionDeerclopsCooldown = 0; + - public bool HasAmbition = false; public bool SummonerAmbition = false; - - public HashSet KilledBosses = []; - - public HashSet SummonerAmbitionCrafts = []; + + /** + * Set of boss and event ids for unlocking perks from Summoner's Ambition accessory + */ + public HashSet SummonerAmbitions = []; public override void PreUpdate() { KatanaTeleportCooldown = Math.Max(KatanaTeleportCooldown - 1, 0); + SummonerAmbitionDeerclopsCooldown = Math.Max(SummonerAmbitionDeerclopsCooldown - 1, 0); } - public override void PostUpdateMiscEffects() + public override void PostUpdateEquips() { if (SummonerAmbition) { Player.AddBuff(ModContent.BuffType(), 1); Player.maxMinions += GetSummonersAmbitionMinionBonus(); + + if (SummonerAmbitions.Contains("king_slime")) + { + Player.whipRangeMultiplier += 0.2f; + } + + if (SummonerAmbitions.Contains("eater_of_worlds")) + { + Player.GetArmorPenetration(DamageClass.Summon) += 5; + } + + if (SummonerAmbitions.Contains("brain_of_cthulhu")) + { + Player.GetDamage(DamageClass.Summon) += 0.05f; + } + + if (SummonerAmbitions.Contains("skeletron")) + { + Player.GetKnockback(DamageClass.Summon) += 0.1f; + } } } public override void ResetEffects() { ArcaneMissile = 0; - HasAmbition = false; SummonerAmbition = false; base.ResetEffects(); } - + public override void SaveData(TagCompound tag) { - tag["killedBosses"] = new List(KilledBosses); - tag["summonerAmbitions"] = new List(SummonerAmbitionCrafts); + tag["summonerAmbitions"] = new List(SummonerAmbitions); } - + public override void LoadData(TagCompound tag) { - if (tag.ContainsKey("killedBosses")) - { - var list = tag.GetList("killedBosses"); - KilledBosses = new HashSet(list); - } if (tag.ContainsKey("summonerAmbitions")) { var list = tag.GetList("summonerAmbitions"); - SummonerAmbitionCrafts = new HashSet(list); + SummonerAmbitions = new HashSet(list); } } - + public int GetSummonersAmbitionMinionBonus() { - return SummonerAmbitionCrafts.Count / 3 + 1; + var amount = 1; + if (SummonerAmbitions.Contains("wall_of_flesh")) + { + amount += 1; + } + + return amount; } }