alliedmodders / sourcemod

SourceMod - Source Engine Scripting and Administration
http://www.sourcemod.net/
987 stars 422 forks source link

Add new native for TraceAttack #675

Open ghost opened 7 years ago

ghost commented 7 years ago

Hi,

I would like to know if new 'TakeDamage' & 'TraceAttack' natives could be added to permit plugin developers to create easily new dangerous objects (Claymore, Sentry...) without the need of an extension.

Gamedata offsets are already present, so it shouldn't be hard to maintain these new natives.

1 - TakeDamage

I already know about SDKHooks_TakeDamage, but this native doesn't fire the hooks created in other plugins.

I know it's intended, but it can be a pain if you have a plugin A to inflict damage and a plugin B to reduce the damage received.

When all the plugins for a mode are created by the same developer, solutions can be found (Common API, ...). But if I would like for example to share in the AM forum a new plugin which uses SDKHooks_TakeDamage, then users will have issues if they have on their server another plugin which reduces / cancels damage (A shop item, a zombie class, ...).

The new native would have the same arguments than SDKHooks_TakeDamage, the only difference would be that it doesn't bypass the hooks.

2 - TraceAttack

To look like TakeDamage, 2 natives could be created (With / Without bypass). The prototype could be:

SDKHooks_TraceAttack(int entity, int inflictor, int attacker, float damage, int damageType, int weapon, const float damageForce[3], const float damagePosition[3], const float damageDirection[3], Handle trace);

Argument 'Handle trace' -> Can be built using TR_TraceRayEx for example.

Remark: calling this TraceAttack native alone will be useless. ClearMultiDamage() & ApplyMultiDamage() are necessary to make it work. Plugin developers will be able to call these two functions easily using SDKCall (They don't have any arguments - The only difficulty is to find their signature).


If needed (Because you don't have a lot of free time / whatever reason), I can work on a solution and request a pull. But I would like to avoid to work if it's already a NO .

Thank you for reading 😺.

asherkin commented 7 years ago

What is the purpose / utility of the TraceAttack native? Can you point to a plugin that does this in gamedata / with an extension?

ghost commented 7 years ago

SDKHooks_TakeDamage doesn't seem to spawn blood nor modify the player velocity when taking damage (Test - CS:GO).

The purpose of SDKHooks_TraceAttack would be to simplify all this management (-> It would be helpful if I want for example to create a plugin working for several games [CSS, CS:GO, ...], without taking care of the blood particle_effects / decals which can be different depending of the game).


I don't have an example for Source currently, I'm mainly thinking about plugins that were developed under Amxmodx (CS 1.6).

KyleSanderson commented 3 years ago

Closing per #1598

psychonic commented 3 years ago

Re-opening. #1598 does not address a TraceAttack native.

eyal282 commented 1 year ago

TraceAttack lets you simulate headshots with hitgroup set to 1. TakeDamage cannot do it.