SM-TFCustomAttributeStarterPack icon indicating copy to clipboard operation
SM-TFCustomAttributeStarterPack copied to clipboard

projectile upgrades buildings attribute doesn't work on rescue ranger

Open higps opened this issue 2 years ago • 2 comments

Initial troubleshooting checklist

  • [x ] The attribute is loaded, or this bug report is about a plugin load failure. (Check sm plugins list on the server.)
  • [x ] The attribute is the most recent revision.

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):

  • Operating System: [Linux Ubuntu 18.04)
  • SourceMod version: [SourceMod 1.11.0.6927]

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

higps avatar May 05 '23 15:05 higps

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 avatar May 05 '23 16:05 nosoop

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).

nosoop avatar May 08 '23 17:05 nosoop