Raised This Month: $12 Target: $400
 3% 

[INC/STOCK] Calculate Player TakeDamage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Fr33m@n
Veteran Member
Join Date: May 2008
Location: France Marne
Old 05-03-2017 , 10:45   [INC/STOCK] Calculate Player TakeDamage
Reply With Quote #1

Calculate Player TakeDamage
- last updated : 03 may 2017

Ever wanted to know what is the final Player TakeDamage on CS before the damage is actually applied ?
This stock mimic the player.cpp TakeDamage way of calculation of damage Before the damage is actually applied.

PHP Code:
Calculate_Player_TakeDamage(VictimInflictorAttackerFloat:flDamagebitsDamageType, &Float:flCalcDamage 0.0, &Float:flCalcArmorHit 0.0
This is useful if you want to do something depending of the real damage before it's actually applied.
If flCalcDamage is >= player health, the player will die, if flCalcArmorHit >= player float armorvalue, the player will lost all his armor.

This stock respects the player.cpp calls, in order to keep the calls as close as possible of the game way.

If the damage is blocked (IE friendlyfire) Calculate_Player_TakeDamage will return false and calc values will be zero, otherwise the function will return true and the real calc values.

This stock support mp_freeforall cvar from CSDM and ReGameDll bugfixed.


│ Credits
The credits goes to the RegameDLL_CS team.
player.cpp


I provided the plugin i used to develop this stock.
Note: This stock only work with amxmodx 1.8.3, if you want it compatible with amxmodx 1.8.2, feel free to convert it, i won't do it.
Attached Files
File Type: inc player_takedamage.inc (5.9 KB, 227 views)
File Type: sma Get Plugin or Get Source (test.sma - 727 views - 1.2 KB)

Last edited by Fr33m@n; 05-10-2017 at 08:39.
Fr33m@n is offline
Fr33m@n
Veteran Member
Join Date: May 2008
Location: France Marne
Old 05-03-2017 , 12:01   Re: [INC] Calculate Player TakeDamage
Reply With Quote #2

Reserved.
Fr33m@n is offline
Fr33m@n
Veteran Member
Join Date: May 2008
Location: France Marne
Old 05-03-2017 , 12:19   Re: [INC/STOCK] Calculate Player TakeDamage
Reply With Quote #3

I didn't developed this at first for sharing purpose, but you know... i though It may interest some people out there.
Fr33m@n is offline
heliumdream
Senior Member
Join Date: Aug 2006
Old 05-14-2017 , 05:50   Re: [INC/STOCK] Calculate Player TakeDamage
Reply With Quote #4

Oooo. That is handy!
I've encountered problems with this in the past:
https://forums.alliedmods.net/showthread.php?p=2364521

And should also be able to shield/stop otherwise lethal damage!
https://forums.alliedmods.net/showth...t=30272&page=2
__________________
heliumdream is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:27.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode