nosoop / SM-TFCustomAttributeStarterPack

A collection of plugins to be used with the TF2 Custom Attribute framework.
MIT License
20 stars 10 forks source link

projectile upgrades buildings attribute doesn't work on rescue ranger #81

Open higps opened 1 year ago

higps commented 1 year ago

Initial troubleshooting checklist

Describe the bug When setting the attribute: TF2CustAttr_SetString(Weapon1, "projectile upgrades buildings", "50"); Shooting my own buildings does nothing to upgrade them when I have metal.

To Reproduce Add the attribute to any projectile weapon and shoot unupgraded buildings with the projectile.

Expected behavior The building to be upgraded.

Server environment (please complete the following information):

Additional context I tested this with Pomson as well as on friendly buildings No errors are thrown.

nosoop commented 1 year ago

As the code itself specifies, it currently only works with syringes due to some known crashes with rockets (arrows, including the Rescue Ranger's repair claw, use rockets as their base). It would be fine on the Pomson once the checks are patched out, however.

Definitely should be fixed; just a pain to track down. Might have to swap it out to a detour.

The crash occurs at DHookGetParam and leads to a null dereference; if you'd like to investigate, you can start experimenting there.

nosoop commented 1 year ago

On further inspection, rockets don't inherit from the TF base projectile class, so it's just hooking the wrong function (it's hooking ::GetDamageType on Linux and ::Explode on Windows).

Should be able to hook ::RocketTouch on them instead, though now the question is about how to properly differentiate between projectiles in a future-proof manner (while it's unlikely that new projectiles will be added, I'd prefer to not have to hardcode this behavior to a known set).