diff --git a/Buffs/SummonerAmbitionBuff.cs b/Buffs/SummonerAmbitionBuff.cs new file mode 100644 index 0000000..4dea666 --- /dev/null +++ b/Buffs/SummonerAmbitionBuff.cs @@ -0,0 +1,37 @@ +using Terraria; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace YHTMod.Buffs; + +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; + if (modPlayer == null) return; + + tip = Language.GetTextValue("Mods.YHTMod.Buffs.SummonerAmbitionBuff.Description", modPlayer.SummonerAmbitionCrafts.Count); + } + + public override void Update(Player player, ref int buffIndex) + { + var modPlayer = player.GetModPlayer(); + + if (modPlayer.SummonerAmbition) + { + player.buffTime[buffIndex] = 18000; + } + else + { + player.DelBuff(buffIndex); + buffIndex--; + } + } +} diff --git a/Buffs/SummonerAmbitionBuff.png b/Buffs/SummonerAmbitionBuff.png new file mode 100644 index 0000000..3677bec Binary files /dev/null and b/Buffs/SummonerAmbitionBuff.png differ diff --git a/Changes/BossKillListener.cs b/Changes/BossKillListener.cs new file mode 100644 index 0000000..48ce9d2 --- /dev/null +++ b/Changes/BossKillListener.cs @@ -0,0 +1,58 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Chat; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace YHTMod.Changes; + +public class BossKillListener : GlobalNPC +{ + public override void OnKill(NPC npc) + { + switch (npc.type) + { + case NPCID.KingSlime: + HandleBossKill(npc, "king_slime"); + break; + case NPCID.EyeofCthulhu: + HandleBossKill(npc, "eye_of_cthulhu"); + break; + case NPCID.EaterofWorldsHead: + HandleBossKill(npc, "eater_of_worlds"); + break; + case NPCID.BrainofCthulhu: + HandleBossKill(npc, "brain_of_cthulhu"); + break; + case NPCID.QueenBee: + HandleBossKill(npc, "queen_bee"); + break; + case NPCID.SkeletronHead: + HandleBossKill(npc, "skeletron"); + break; + case NPCID.WallofFlesh: + HandleBossKill(npc, "wall_of_flesh"); + break; + } + + base.OnKill(npc); + } + + private static void HandleBossKill(NPC npc, string bossKey) + { + foreach (var player in Main.ActivePlayers) + { + var modPlayer = player.GetModPlayer(); + if (!npc.playerInteraction[player.whoAmI]) continue; + if (modPlayer.KilledBosses.Add(bossKey)) + { + ChatHelper.SendChatMessageToClient( + NetworkText.FromLiteral("Your Ambition's potential grows stronger!"), + Color.MediumPurple, + player.whoAmI + ); + } + } + } +} diff --git a/Items/SummonersAmbition.cs b/Items/SummonersAmbition.cs new file mode 100644 index 0000000..e0c01ee --- /dev/null +++ b/Items/SummonersAmbition.cs @@ -0,0 +1,115 @@ +using System.Collections.Generic; +using Terraria; +using Terraria.GameContent.Creative; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace YHTMod.Items; + +public class SummonersAmbition : ModItem +{ + public override void SetStaticDefaults() + { + CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1; + } + + public override LocalizedText Tooltip => Language.GetText(""); + + public override void SetDefaults() + { + Item.width = 32; + Item.height = 32; + Item.accessory = true; + Item.rare = ItemRarityID.White; + Item.noMelee = true; + Item.noUseGraphic = true; + ItemID.Sets.ShimmerTransformToItem[Type] = 0; + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + 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()))); + + if (player.KilledBosses.Contains("king_slime")) + { + tooltips.Add(new TooltipLine(Mod, "SummonerAmbitionKingSlime", Language.GetTextValue("Mods.YHTMod.Items.SummonersAmbition.KingSlime"))); + } + + } + + public override void AddRecipes() + { + CreateRecipe() + .AddIngredient(ItemID.Rope, 5) + .AddIngredient(ItemID.Squirrel) + .AddIngredient(ItemID.Acorn, 25) + .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 + } +} diff --git a/Items/SummonersAmbition.png b/Items/SummonersAmbition.png new file mode 100644 index 0000000..8e27abd Binary files /dev/null and b/Items/SummonersAmbition.png differ diff --git a/Localization/en-US_Mods.YHTMod.hjson b/Localization/en-US_Mods.YHTMod.hjson index a06aa72..7dd0258 100644 --- a/Localization/en-US_Mods.YHTMod.hjson +++ b/Localization/en-US_Mods.YHTMod.hjson @@ -1,6 +1,16 @@ 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: { @@ -8,6 +18,16 @@ Buffs: { DisplayName: Summon Toclafane Description: It came from a parallel world to fight for its Master. } + + SummonerAmbitionBuff: { + DisplayName: Summoner's Ambition + Description: + ''' + Your power grows with your ambition. + + Essences absorbed: {0} + ''' + } } Items: { @@ -54,6 +74,25 @@ Items: { DisplayName: Toclafane Staff Tooltip: Summons a toclafane to remove population for you } + + SummonersAmbition: { + DisplayName: Summoner's Ambition + 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." + } } Projectiles: { diff --git a/YhtPlayer.cs b/YhtPlayer.cs index 79ec25c..094ba6b 100644 --- a/YhtPlayer.cs +++ b/YhtPlayer.cs @@ -1,5 +1,8 @@ using System; +using System.Collections.Generic; using Terraria.ModLoader; +using Terraria.ModLoader.IO; +using YHTMod.Buffs; namespace YHTMod; @@ -8,15 +11,58 @@ public class YhtPlayer : ModPlayer public int ArcaneMissile = 0; public int KatanaTeleportCooldown = 0; + public bool HasAmbition = false; + public bool SummonerAmbition = false; + + public HashSet KilledBosses = []; + + public HashSet SummonerAmbitionCrafts = []; + public override void PreUpdate() { KatanaTeleportCooldown = Math.Max(KatanaTeleportCooldown - 1, 0); } + public override void PostUpdateMiscEffects() + { + if (SummonerAmbition) + { + Player.AddBuff(ModContent.BuffType(), 1); + Player.maxMinions += GetSummonersAmbitionMinionBonus(); + } + } + public override void ResetEffects() { ArcaneMissile = 0; + HasAmbition = false; + SummonerAmbition = false; base.ResetEffects(); } -} \ No newline at end of file + + public override void SaveData(TagCompound tag) + { + tag["killedBosses"] = new List(KilledBosses); + tag["summonerAmbitions"] = new List(SummonerAmbitionCrafts); + } + + 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); + } + } + + public int GetSummonersAmbitionMinionBonus() + { + return SummonerAmbitionCrafts.Count / 3 + 1; + } +}