tModLoader

tModLoader

290 ratings
Minion ModifyWeaponDamage Patch
2
   
Award
Favorite
Favorited
Unfavorite
Mod Features: Utilities, Quality Of Life
Mod Side: Both
tModLoader Version: 1.4.4
File Size
Posted
Updated
57.184 KB
10 Aug, 2023 @ 6:27pm
8 Jan, 2024 @ 8:52am
3 Change Notes ( view )

Subscribe to download
Minion ModifyWeaponDamage Patch

Description
Minion ModifyWeaponDamage Patch

Notice: This mod is discontinued, but will remain available on the workshop (for tML v1.4.4.x) for those that have a use for it.

This is a simple mod that fixes a tML bug*, in which minions, sentries, and other projectiles which continuously update their damage don't scale with their parent weapon/player's damage modifications from mods' usage of the ModifyWeaponDamage hook.

Players:
Just download (Via. subscribing to the Steam Workshop item) and enable this mod and it'll do its thing. You probably only need this mod if you're a summoner playing with a mod(s) that has an issue similar to what is described above.

Modders:
If you utilize the ModifyWeaponDamage hook in your mod, you may want to investigate the damage of minions/sentries and make sure they work fine. If they don't, this mod may fix your problems.
This mod is open-source, so feel free to just copy the code instead of depending on this mod. There isn't a public repository (Ex: GitHub), so use tMod's extract function to access the source.

Outline of how the patch works (For Modders):
This mod affects minions, sentries, and any projectile with ContinuouslyUpdateDamageStats set to true.
It attempts to find the parent player and item, uses that info to call CombinedHooks.ModifyWeaponDamage and saves the result to a StatModifier. The mod then uses the PreAI hook to re-create vanilla code that updates projectile.damage, and builds in the saved StatModifier from CombinedHooks.ModifyWeaponDamage. To clarify, all of this is done within a GlobalProjectile class.

Compatibility/Multiplayer
Should be compatible with multiplayer and just about every other mod.
The only potential for mod incompatibility is if another mod already has its own patch for this bug, or otherwise messes with projectiles that continuously update their damage.
My mods already have this mod's effects integrated into them, so there's no need to use it with them!

Disclaimers
Be warned that this is NOT a perfect solution; akin to how minion damage used to 'snapshot' stat boosts on-summon, this workaround will 'snapshot' boosts from ModifyWeaponDamage. This means if ModifyWeaponDamage is used in a dynamic way (Which it often is), minion/sentry damage will be stuck in the state given on-spawn. This means you'll have to re-summon minions/sentries if you want them to update their benefits from ModifyWeaponDamage, and kind of opens up old pre-1.4 damage build 'exploits' but with regard to ModifyWeaponDamage instead of stat boosts.

*There is no need to report this bug on the tML GitHub; I already have done so!
It is not likely to be patched due the complexity of messing with the OriginalDamage varaible, and the complication described in the previous disclaimer. Solving the issue would take more effort than it's worth, considering workarounds like this are possible.

Originally posted by tModLoader:
Developed By BlockCrusader
28 Comments
Lord Foog The 2st 22 Jan @ 7:57am 
Good to know, thanks for the quick reply. Seriously enjoying your mods!
BlockCrusader  [author] 22 Jan @ 7:41am 
@Lord Foog The 2st, yes the effects of this mod are already integrated into all my other mods so you won't need it for those.

This one is basically discontinued, really. I just leave it available in case there are mods out there that would benefit from it (Though I don't know of any).
I oughta update the mod's description here to reflect this.
Lord Foog The 2st 22 Jan @ 7:33am 
Hey! Is this patch already included in your weapon levelling/augments mods? Just double checking whether I need to get this one as well.
Rei Da Tecnologia 15 Jul, 2024 @ 10:07am 
Well this was an interesting read!
Freak4Leeks 17 Feb, 2024 @ 10:23pm 
Thanks, Appreciated!
BlockCrusader  [author] 24 Jan, 2024 @ 5:26am 
@ValcomDrifty, this primarily affects summons/sentries, not whips.
One way tModLoader provides modders venues to modify weapon damage is through a hook called 'ModifyWeaponDamage'.
The problem is that, due to the way summons/sentries update their damage constantly (Which was done by Re-Logic in 1.4 to prevent damage build exploits used in 1.3), they are not affected by any damage changes made via. ModifyWeaponDamage.

It's very hard to say when this will impact you as a summoner because modders don't just announce 'hey this mod is using ModifyWeaponDamage' (Why would they?), but from my experience it's relatively common to see it used by mods which add ways to level up or otherwise upgrade your weapons. I made this patch because I noticed this problem when making such mods myself.
Valcom 23 Jan, 2024 @ 7:36pm 
Could you maybe elaborate what the bug even is? I basically only play Summoner so I just want to know how it affects me. Like specifically what vanilla weapons have this bug and how much it would affect me (like if the bug only triggers when I use a wrath potion or a reforge for example)
BlockCrusader  [author] 12 Nov, 2023 @ 4:46am 
@matheusverli24, I'm not really able to give a proper solution without knowing what mod has that bug, and also since it's not my mod. If enchantments are applied based on the held item, that may be intended behavior. It'd be best to ask the creator of whatever mod has the problem you've described.
Diablo B.Blake 11 Nov, 2023 @ 9:53pm 
hi, sorry for the possible spelling errors, I don't speak English so I'm using a translator, but then I noticed a bug unrelated to your mobs that I would like to know if you know how to solve, apparently the enchantments made on the summon staffs only Summons apply when holding the staff, this applies to any item, minions benefit from enchantments placed on other items as long as you have it in your hand, but only those in your hand, ignoring their own
andro951 6 Oct, 2023 @ 8:09am 
The specific hooks I use are GlobalItem.ModifyWeaponDamage() and ModPlayer.ModifyHitNPCWithProj(Projectile proj, NPC target, ref NPC.HitModifiers modifiers) { modifiers *= multiplier }
I also store a reference to the source item in GlobalProjectile.OnSpawn by getting it from the source that created the projectile so that the GlobalItem with the modifier can be accessed in the ModPlayer hook.

This solution doesn't update the actual projectile damage if that's something you need.