[SPC] Custom Damage (Now on GitHub!) -
Scaleta - 24.02.2014
Short Pieces of Code - Custom Damage (UPDATED 25/2/2014)
NOTE
If you are using the 0.3z version of this include, please update it to the one currently in the repository.
About
So, I saw a lot of people made "custom damage scripts", but none of these was ever actual custom damage. It simply added onto the current damage and caused problems when the normal damage already killed the player. I first devised the method on the same idea, but it was bugged so I scrapped it. Then, I realized two key pieces missing to the method. 1. Set their team and you can manage the damage yourself. 2. The bug which fatally destroyed my last system.
I am currently using this system, but I still like to contribute to the community as it would be pointless to just keep it to myself.
Notes
The 0.3z version is untested and might not work with all weapons.
The normal version _will_ conflict if you use SetPlayerTeam within your script.
It is suggested that you modify the damages to your liking, as they are not all great amounts.
Current Releases
Documentation
The normal version of this include blocks normal SA-MP damage by setting the player's team and then handling the damage when it normally would have been taken.
With this you could factor in damage modifiers with bodypart hits
Example
pawn Код:
// If statement for just one, but you can use a switch for all.
// Do not forget to define the parts, as they are not already in the samp include.
#define BODY_PART_TORSO 3
if(bodypart == BODY_PART_TORSO) damage *= 2.0; // this would be outrageous to increment by, it's an example.
The 0.3z version uses the OnPlayerWeaponShot, handles the damage and then blocks the shot (this part was untested, compared to the normal). I only made this version to allow compatibility with servers that use multiple teams.
This is meant to be short and sweet, as it is apart of the
Short Pieces of Code library.
Re: [SPC] Custom Damage -
Lordzy - 24.02.2014
9.0 value as MELEE_DAMAGE seems to be much, but yeah the coders could edit it if they're using. You seem to use the _ALS_ hooking method at the last of the include but the callbacks aren't hooked yet in calling out that callback used somewhere else. This usage might not bypass the code or compile well if being re-used. Other than that, the include seems interesting.
Re: [SPC] Custom Damage -
Scaleta - 24.02.2014
Quote:
Originally Posted by Lordz™
9.0 value as MELEE_DAMAGE seems to be much, but yeah the coders could edit it if they're using. You seem to use the _ALS_ hooking method at the last of the include but the callbacks aren't hooked yet in calling out that callback used somewhere else. This usage might not bypass the code or compile well if being re-used. Other than that, the include seems interesting.
|
The damage values were off the top of my head and are meant to be edited. As for the hooking, would you suggest another method of doing so, as it works fine.
Re: [SPC] Custom Damage -
Lordzy - 24.02.2014
Quote:
Originally Posted by Scaleta
The damage values were off the top of my head and are meant to be edited. As for the hooking, would you suggest another method of doing so, as it works fine.
|
According to the one I use these days:
pawn Код:
public OnPlayerConnect(playerid)
{
//codes.
#if defined LIBNAME_OnPlayerConnect
return LIBNAME_OnPlayerConnect(playerid); //This is being done to get this include compatible with the scripts using it. So in case if those scripts too use the same callback, it would call it.
#else
return 1;
#endif
}
#if defined _ALS_OnPlayerConnect
#undef OnPlayerConnect
#else
#define _ALS_OnPlayerConnect
#endif
#define OnPlayerConnect LIBNAME_OnPlayerConnect
#if defined LIBNAME_OnPlayerConnect
forward LIBNAME_OnPlayerConnect(playerid);
#endif
^
This hook method being used is some what called "Hook method 7" and you can get the tutorial of it explained well from the below link. I'm also adding the old hooking method's tutorial which would probably fix your confusion about hooking process.
https://sampforum.blast.hk/showthread.php?tid=441293 - Hook method 7
https://sampforum.blast.hk/showthread.php?tid=392061 - Normal hooking.
Re: [SPC] Custom Damage -
Scaleta - 25.02.2014
EDIT:
The topic was updated and the hooking will no longer conflict with your script.
Thanks to Lordz for his assistance on this understanding.
Re: [SPC] Custom Damage -
John_Cooper - 10.03.2014
Thanks. Will for sure use this.