From 62ae36d4f0c1ff535eca8e15984c5d8c7f4e3dac Mon Sep 17 00:00:00 2001 From: YouHaveTrouble Date: Fri, 30 Jan 2026 19:16:17 +0100 Subject: [PATCH] an attempt at increasing melee weapon size --- Changes/WarriorItemEffects.cs | 53 +++++++++++++++++++++++++++++++++++ YhtPlayer.cs | 33 ++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 Changes/WarriorItemEffects.cs diff --git a/Changes/WarriorItemEffects.cs b/Changes/WarriorItemEffects.cs new file mode 100644 index 0000000..5b19ee8 --- /dev/null +++ b/Changes/WarriorItemEffects.cs @@ -0,0 +1,53 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace YHTMod.Changes; + +public class WarriorItemEffects : GlobalItem { + + public override bool InstancePerEntity => true; + + public override void UseItemHitbox(Item item, Player player, ref Rectangle hitbox, ref bool noHitbox) { + YhtPlayer modPlayer = player.GetModPlayer(); + + if (!modPlayer.WarriorAmbition) { + base.UseItemHitbox(item, player, ref hitbox, ref noHitbox); + return; + } + + if (item.DamageType == DamageClass.Melee && !item.noMelee) { + float scale = modPlayer.GetWarriorsAmbitionMeleeSizeBonus(); + if (scale > 1f) { + int newW = (int)(hitbox.Width * scale); + int newH = (int)(hitbox.Height * scale); + int cx = hitbox.X + hitbox.Width / 2; + int cy = hitbox.Y + hitbox.Height / 2; + hitbox.X = cx - newW / 2; + hitbox.Y = cy - newH / 2; + hitbox.Width = newW; + hitbox.Height = newH; + } + } + + base.UseItemHitbox(item, player, ref hitbox, ref noHitbox); + } + + public override void HoldItem(Item item, Player player) { + YhtPlayer modPlayer = player.GetModPlayer(); + + if (!modPlayer.WarriorAmbition) { + base.HoldItem(item, player); + return; + } + + if (item.DamageType == DamageClass.Melee && !item.noMelee) { + float sizeBonus = modPlayer.GetWarriorsAmbitionMeleeSizeBonus(); + if (sizeBonus >= 1f) + { + item.scale *= sizeBonus; + } + } + base.HoldItem(item, player); + } +} diff --git a/YhtPlayer.cs b/YhtPlayer.cs index 0845082..cdda512 100644 --- a/YhtPlayer.cs +++ b/YhtPlayer.cs @@ -65,6 +65,12 @@ public class YhtPlayer : ModPlayer { } if (WarriorAmbition) { Player.AddBuff(ModContent.BuffType(), 1); + Player.statDefense += GetWarriorsAmbitionDefenseBonus(); + + if (ModLoader.HasMod("CalamityMod") && SummonerAmbitions.Contains("desert_scourge")) { + Player.statLifeMax2 += 10; + } + } } @@ -109,6 +115,14 @@ public class YhtPlayer : ModPlayer { public int GetWarriorsAmbitionDefenseBonus() { int amount = 2; + + if (ModLoader.HasMod("CalamityMod") && SummonerAmbitions.Contains("perforators")) { + amount += 2; + } + + if (ModLoader.HasMod("CalamityMod") && SummonerAmbitions.Contains("hive_mind")) { + amount += 2; + } if (WarriorAmbitions.Contains("wall_of_flesh")) { amount += 5; @@ -116,4 +130,23 @@ public class YhtPlayer : ModPlayer { return amount; } + + public float GetWarriorsAmbitionMeleeSizeBonus() { + float scale = 1f; + + if (WarriorAmbitions.Contains("king_slime")) { + if (ModLoader.HasMod("CalamityMod")) { + scale += 0.025f; + } + else { + scale += 0.05f; + } + } + + if (ModLoader.HasMod("CalamityMod") && WarriorAmbitions.Contains("slime_god")) { + scale += 0.025f; + } + + return scale; + } }