mirror of
https://github.com/YouHaveTrouble/YHTMod.git
synced 2026-05-11 21:56:54 +00:00
test implementation of ambition upgrade system
This commit is contained in:
@@ -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<YhtPlayer>(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<YhtPlayer>();
|
||||
|
||||
if (modPlayer.SummonerAmbition)
|
||||
{
|
||||
player.buffTime[buffIndex] = 18000;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.DelBuff(buffIndex);
|
||||
buffIndex--;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
@@ -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<YhtPlayer>();
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<YhtPlayer>();
|
||||
modPlayer.SummonerAmbition = true;
|
||||
modPlayer.HasAmbition = true;
|
||||
}
|
||||
|
||||
public override void ModifyTooltips(List<TooltipLine> tooltips)
|
||||
{
|
||||
var player = Main.LocalPlayer.GetModPlayer<YhtPlayer>();
|
||||
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<YhtPlayer>();
|
||||
return player.KilledBosses.Contains("king_slime") && !player.SummonerAmbitionCrafts.Contains("king_slime");
|
||||
})
|
||||
)
|
||||
.AddOnCraftCallback((recipe, item, consumed, destination) =>
|
||||
{
|
||||
Main.LocalPlayer.GetModPlayer<YhtPlayer>().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<YhtPlayer>();
|
||||
return player.KilledBosses.Contains("eye_of_cthulhu") && !player.SummonerAmbitionCrafts.Contains("eye_of_cthulhu");
|
||||
})
|
||||
)
|
||||
.AddOnCraftCallback((recipe, item, consumed, destination) =>
|
||||
{
|
||||
Main.LocalPlayer.GetModPlayer<YhtPlayer>().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<YhtPlayer>();
|
||||
return player.KilledBosses.Contains("skeletron") && !player.SummonerAmbitionCrafts.Contains("skeletron");
|
||||
})
|
||||
)
|
||||
.AddOnCraftCallback((recipe, item, consumed, destination) =>
|
||||
{
|
||||
Main.LocalPlayer.GetModPlayer<YhtPlayer>().SummonerAmbitionCrafts.Add("skeletron");
|
||||
})
|
||||
.Register();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
@@ -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: {
|
||||
|
||||
@@ -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<string> KilledBosses = [];
|
||||
|
||||
public HashSet<string> SummonerAmbitionCrafts = [];
|
||||
|
||||
public override void PreUpdate()
|
||||
{
|
||||
KatanaTeleportCooldown = Math.Max(KatanaTeleportCooldown - 1, 0);
|
||||
}
|
||||
|
||||
public override void PostUpdateMiscEffects()
|
||||
{
|
||||
if (SummonerAmbition)
|
||||
{
|
||||
Player.AddBuff(ModContent.BuffType<SummonerAmbitionBuff>(), 1);
|
||||
Player.maxMinions += GetSummonersAmbitionMinionBonus();
|
||||
}
|
||||
}
|
||||
|
||||
public override void ResetEffects()
|
||||
{
|
||||
ArcaneMissile = 0;
|
||||
HasAmbition = false;
|
||||
SummonerAmbition = false;
|
||||
|
||||
base.ResetEffects();
|
||||
}
|
||||
|
||||
public override void SaveData(TagCompound tag)
|
||||
{
|
||||
tag["killedBosses"] = new List<string>(KilledBosses);
|
||||
tag["summonerAmbitions"] = new List<string>(SummonerAmbitionCrafts);
|
||||
}
|
||||
|
||||
public override void LoadData(TagCompound tag)
|
||||
{
|
||||
if (tag.ContainsKey("killedBosses"))
|
||||
{
|
||||
var list = tag.GetList<string>("killedBosses");
|
||||
KilledBosses = new HashSet<string>(list);
|
||||
}
|
||||
if (tag.ContainsKey("summonerAmbitions"))
|
||||
{
|
||||
var list = tag.GetList<string>("summonerAmbitions");
|
||||
SummonerAmbitionCrafts = new HashSet<string>(list);
|
||||
}
|
||||
}
|
||||
|
||||
public int GetSummonersAmbitionMinionBonus()
|
||||
{
|
||||
return SummonerAmbitionCrafts.Count / 3 + 1;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user