configure a code style that is not completely cursed

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