Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- This simple include allows you to detect how much health/armour is lost in
- OnPlayerTakeDamage and OnPlayerGiveDamage, instead of overall 'damage'
- (health and armour combined).
- */
- // These are the new callbacks
- forward OnPlayerTakeDamageEx(playerid, issuerid, Float:healthloss, Float:armourloss, weaponid);
- forward OnPlayerGiveDamageEx(playerid, damagedid, Float:healthloss, Float:armourloss, weaponid);
- // ----------------------------------------------------------------------------
- public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid) // Original callback
- {
- new Float:armourloss, Float:healthloss, Float:pArmour;
- GetPlayerArmour(playerid, pArmour);
- if(pArmour != 0) // They had armour, so they MUST have lost some.
- {
- if(amount > pArmour) // They took more damage than what armour they had, so they must have lost ALL of their armour and some health too.
- {
- armourloss = pArmour; // We know they lost all of their armour
- healthloss = amount-pArmour; // What ever is left, was health loss
- }
- else // Just lost armour
- {
- armourloss = amount;
- }
- }
- else healthloss = amount; // They had no armour - hence they only lost health
- // Call the new function
- CallLocalFunction("OnPlayerTakeDamageEx", "iiffi", playerid, issuerid, healthloss, armourloss, weaponid);
- // HOOKERS
- #if defined OPGTD_OnPlayerTakeDamage
- return OPGTD_OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid);
- #else
- return 1;
- #endif
- }
- #if defined OPGTD_OnPlayerTakeDamage
- forward OPGTD_OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid);
- #endif
- #if defined _ALS_OnPlayerTakeDamage
- #undef OnPlayerTakeDamage
- #else
- #define _ALS_OnPlayerTakeDamage
- #endif
- #define OnPlayerTakeDamage OPGTD_OnPlayerTakeDamage
- // ----------------------------------------------------------------------------
- public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid) // Original callback
- {
- new Float:armourloss, Float:healthloss, Float:pArmour;
- GetPlayerArmour(damagedid, pArmour);
- if(pArmour != 0) // They had armour, so they MUST have lost some.
- {
- if(amount > pArmour) // They took more damage than what armour they had, so they must have lost ALL of their armour and some health too.
- {
- armourloss = pArmour; // We know they lost all of their armour
- healthloss = amount-pArmour; // What ever is left, was health loss
- }
- else // Just lost armour
- {
- armourloss = amount;
- }
- }
- else healthloss = amount; // They had no armour - hence they only lost health
- // Call the new function
- CallLocalFunction("OnPlayerGiveDamageEx", "iiffi", playerid, damagedid, healthloss, armourloss, weaponid);
- // HOOKERS
- #if defined OPGTD_OnPlayerGiveDamage
- return OPGTD_OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid);
- #else
- return 1;
- #endif
- }
- #if defined OPGTD_OnPlayerGiveDamage
- forward OPGTD_OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid);
- #endif
- #if defined _ALS_OnPlayerGiveDamage
- #undef OnPlayerGiveDamage
- #else
- #define _ALS_OnPlayerGiveDamage
- #endif
- #define OnPlayerGiveDamage OPGTD_OnPlayerGiveDamage
Advertisement
Add Comment
Please, Sign In to add comment