samp-weapon-config icon indicating copy to clipboard operation
samp-weapon-config copied to clipboard

Custom Damage Types

Open codectile opened this issue 10 years ago • 9 comments

It will be very nice if there is a function/way to add custom damage types overcoming the complexities.

codectile avatar Feb 24 '15 14:02 codectile

Umm, like custom weapon ids?

Crayder avatar Feb 24 '15 23:02 Crayder

Yes.

codectile avatar Feb 25 '15 03:02 codectile

That's why we're here. That's why I suggested you add weapon id's for the water splash and vehicle rolling/bike crashing.

Crayder avatar Feb 25 '15 12:02 Crayder

Adding custom ids is very complicated.

codectile avatar Feb 25 '15 16:02 codectile

That's why slice made it simple. Just change examine how he does his. Define a new one, change to yours in the OnPlayerDeath hook, use it in ProcessDamage when needed, and InflictDamage.

Crayder avatar Feb 25 '15 20:02 Crayder

Actually, there are some compile-time issues. Many arrays are declared with max value WEAPON_UNKNOWN and some runtime checks limit the value.

I think the best thing would be to just add WEAPON_CUSTOM_1-9 or more. People could just do something like this:

#define WEAPON_TAZER      WEAPON_CUSTOM_1
#define WEAPON_ADMIN_SLAP WEAPON_CUSTOM_2

oscar-broman avatar Feb 25 '15 20:02 oscar-broman

@Crayder Sorry for being off topic a bit, have you tested the file which I sent you ?

codectile avatar Feb 26 '15 02:02 codectile

@codectile Actually no, haven't had the spare time for anything lately, maybe tomorrow when I get home from work. I'll get back to ya when I do though.

@oscar-broman Thanks for the headsup on that, I was just about to add a few more too.

Crayder avatar Feb 26 '15 02:02 Crayder

The downside of WEAPON_CUSTOM_* is if you use modular includes that provide custom damage types - it would be hard to decide which ID it should get.

The best solution is a convention like this:

#define WEAPON_TAZER WEAPON_CUSTOM_x
#include <tazer>

// tazer.inc
#if !defined WEAPON_TAZER
    #error Define WEAPON_TAZER before including tazer.inc
#endif

Why? Because the IDs will remain the same (as decided in one place) instead of dynamically allocated depending on which order you include files. The IDs should remain the same, since they could be stored in databases or other persistent storages.

oscar-broman avatar Mar 08 '15 18:03 oscar-broman