11
11
12
12
#include <stocksoup/memory>
13
13
14
- #define PLUGIN_VERSION " 0.12 .0"
14
+ #define PLUGIN_VERSION " 0.13 .0"
15
15
public Plugin myinfo = {
16
16
name = " TF2 Utils" ,
17
17
author = " nosoop" ,
@@ -28,6 +28,7 @@ Handle g_SDKCallPlayerTakeHealth;
28
28
Handle g_SDKCallPlayerGetShootPosition ;
29
29
Handle g_SDKCallPlayerGetEntityForLoadoutSlot ;
30
30
31
+ Handle g_SDKCallEntityGetMaxHealth ;
31
32
Handle g_SDKCallPlayerSharedGetMaxHealth ;
32
33
33
34
Handle g_SDKCallIsEntityWeapon ;
@@ -57,7 +58,8 @@ public APLRes AskPluginLoad2(Handle self, bool late, char[] error, int maxlen) {
57
58
58
59
CreateNative (" TF2Util_UpdatePlayerSpeed" , Native_UpdatePlayerSpeed );
59
60
CreateNative (" TF2Util_TakeHealth" , Native_TakeHealth );
60
- CreateNative (" TF2Util_GetPlayerMaxHealth" , Native_GetMaxHealth );
61
+ CreateNative (" TF2Util_GetEntityMaxHealth" , Native_GetMaxHealth );
62
+ CreateNative (" TF2Util_GetPlayerMaxHealthBoost" , Native_GetMaxHealthBoost );
61
63
CreateNative (" TF2Util_GetPlayerMaxAmmo" , Native_GetMaxAmmo );
62
64
63
65
CreateNative (" TF2Util_GetConditionCount" , Native_GetConditionCount );
@@ -84,6 +86,9 @@ public APLRes AskPluginLoad2(Handle self, bool late, char[] error, int maxlen) {
84
86
85
87
CreateNative (" TF2Util_IsPointInRespawnRoom" , Native_IsPointInRespawnRoom );
86
88
89
+ // deprecated name for backcompat
90
+ CreateNative (" TF2Util_GetPlayerMaxHealth" , Native_GetMaxHealthBoost );
91
+
87
92
return APLRes_Success ;
88
93
}
89
94
@@ -125,6 +130,11 @@ public void OnPluginStart() {
125
130
PrepSDKCall_AddParameter (SDKType_Bool , SDKPass_Plain );
126
131
g_SDKCallPlayerSharedGetMaxHealth = EndPrepSDKCall ();
127
132
133
+ StartPrepSDKCall (SDKCall_Entity );
134
+ PrepSDKCall_SetReturnInfo (SDKType_PlainOldData , SDKPass_Plain );
135
+ PrepSDKCall_SetFromConf (hGameConf , SDKConf_Virtual , " CBaseEntity::GetMaxHealth()" );
136
+ g_SDKCallEntityGetMaxHealth = EndPrepSDKCall ();
137
+
128
138
StartPrepSDKCall (SDKCall_Entity );
129
139
PrepSDKCall_SetFromConf (hGameConf , SDKConf_Virtual , " CBaseEntity::IsBaseCombatWeapon()" );
130
140
PrepSDKCall_SetReturnInfo (SDKType_Bool , SDKPass_Plain );
@@ -281,8 +291,18 @@ public int Native_GetMaxAmmo(Handle plugin, int nParams) {
281
291
return SDKCall (g_SDKCallPlayerGetMaxAmmo , client , ammoIndex , playerClass );
282
292
}
283
293
284
- // int(int client, bool bIgnoreAttributes, bool bIgnoreOverheal );
294
+ // int(int entity );
285
295
public int Native_GetMaxHealth (Handle plugin , int nParams ) {
296
+ int entity = GetNativeCell (1 );
297
+ if (! IsValidEntity (entity )) {
298
+ return ThrowNativeError (SP_ERROR_NATIVE , " Entity %d is invalid" , entity );
299
+ }
300
+
301
+ return SDKCall (g_SDKCallEntityGetMaxHealth , entity );
302
+ }
303
+
304
+ // int(int client, bool bIgnoreAttributes, bool bIgnoreOverheal);
305
+ public int Native_GetMaxHealthBoost (Handle plugin , int nParams ) {
286
306
int client = GetNativeCell (1 );
287
307
bool bIgnoreAttributes = !! GetNativeCell (2 );
288
308
bool bIgnoreOverheal = !! GetNativeCell (3 );
0 commit comments