|
11 | 11 |
|
12 | 12 | #include <stocksoup/memory>
|
13 | 13 |
|
14 |
| -#define PLUGIN_VERSION "0.17.0" |
| 14 | +#define PLUGIN_VERSION "0.18.0" |
15 | 15 | public Plugin myinfo = {
|
16 | 16 | name = "TF2 Utils",
|
17 | 17 | author = "nosoop",
|
@@ -40,6 +40,8 @@ Handle g_SDKCallIsEntityWearable;
|
40 | 40 | Handle g_SDKCallPlayerEquipWearable;
|
41 | 41 |
|
42 | 42 | Handle g_SDKCallPointInRespawnRoom;
|
| 43 | +Handle g_SDKCallPlayerSharedImmuneToPushback; |
| 44 | +Handle g_SDKCallPlayerSharedBurn; |
43 | 45 |
|
44 | 46 | Address offs_ConditionNames;
|
45 | 47 | Address offs_CTFPlayer_aObjects;
|
@@ -77,6 +79,9 @@ public APLRes AskPluginLoad2(Handle self, bool late, char[] error, int maxlen) {
|
77 | 79 | CreateNative("TF2Util_SetPlayerConditionProvider", Native_SetPlayerConditionProvider);
|
78 | 80 | CreateNative("TF2Util_GetPlayerBurnDuration", Native_GetPlayerBurnDuration);
|
79 | 81 | CreateNative("TF2Util_SetPlayerBurnDuration", Native_SetPlayerBurnDuration);
|
| 82 | + CreateNative("TF2Util_IgnitePlayer", Native_IgnitePlayer); |
| 83 | + CreateNative("TF2Util_IsPlayerImmuneToPushback", Native_IsPlayerImmuneToPushback); |
| 84 | + |
80 | 85 | CreateNative("TF2Util_GetPlayerRespawnTimeOverride", Native_GetPlayerRespawnTimeOverride);
|
81 | 86 | CreateNative("TF2Util_SetPlayerRespawnTimeOverride", Native_SetPlayerRespawnTimeOverride);
|
82 | 87 |
|
@@ -145,6 +150,19 @@ public void OnPluginStart() {
|
145 | 150 | PrepSDKCall_AddParameter(SDKType_Bool, SDKPass_Plain);
|
146 | 151 | g_SDKCallPlayerSharedGetMaxHealth = EndPrepSDKCall();
|
147 | 152 |
|
| 153 | + StartPrepSDKCall(SDKCall_Raw); |
| 154 | + PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "CTFPlayerShared::Burn()"); |
| 155 | + PrepSDKCall_AddParameter(SDKType_CBasePlayer, SDKPass_Pointer, VDECODE_FLAG_ALLOWNULL); |
| 156 | + PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer, VDECODE_FLAG_ALLOWNULL); |
| 157 | + PrepSDKCall_AddParameter(SDKType_Float, SDKPass_Plain); |
| 158 | + g_SDKCallPlayerSharedBurn = EndPrepSDKCall(); |
| 159 | + |
| 160 | + StartPrepSDKCall(SDKCall_Raw); |
| 161 | + PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, |
| 162 | + "CTFPlayerShared::IsImmuneToPushback()"); |
| 163 | + PrepSDKCall_SetReturnInfo(SDKType_Bool, SDKPass_Plain); |
| 164 | + g_SDKCallPlayerSharedImmuneToPushback = EndPrepSDKCall(); |
| 165 | + |
148 | 166 | StartPrepSDKCall(SDKCall_Entity);
|
149 | 167 | PrepSDKCall_SetReturnInfo(SDKType_PlainOldData, SDKPass_Plain);
|
150 | 168 | PrepSDKCall_SetFromConf(hGameConf, SDKConf_Virtual, "CBaseEntity::GetMaxHealth()");
|
@@ -364,9 +382,7 @@ int Native_GetMaxHealthBoost(Handle plugin, int nParams) {
|
364 | 382 | ThrowNativeError(SP_ERROR_NATIVE, "Client index %d is invalid", client);
|
365 | 383 | }
|
366 | 384 |
|
367 |
| - Address offs_Shared = view_as<Address>(GetEntSendPropOffs(client, "m_Shared", true)); |
368 |
| - |
369 |
| - return SDKCall(g_SDKCallPlayerSharedGetMaxHealth, GetEntityAddress(client) + offs_Shared, |
| 385 | + return SDKCall(g_SDKCallPlayerSharedGetMaxHealth, GetPlayerSharedAddress(client), |
370 | 386 | bIgnoreAttributes, bIgnoreOverheal);
|
371 | 387 | }
|
372 | 388 |
|
@@ -530,6 +546,19 @@ int Native_GetWeaponMaxClip(Handle plugin, int nParams) {
|
530 | 546 | return SDKCall(g_SDKCallWeaponGetMaxClip, entity);
|
531 | 547 | }
|
532 | 548 |
|
| 549 | +// bool(int client); |
| 550 | +int Native_IsPlayerImmuneToPushback(Handle plugin, int nParams) { |
| 551 | + int client = GetNativeCell(1); |
| 552 | + |
| 553 | + if (!(0 < client <= MaxClients)) { |
| 554 | + return ThrowNativeError(SP_ERROR_NATIVE, "Client %d index is not valid", client); |
| 555 | + } else if (!IsClientInGame(client)) { |
| 556 | + return ThrowNativeError(SP_ERROR_NATIVE, "Client %d is not in game", client); |
| 557 | + } |
| 558 | + |
| 559 | + return SDKCall(g_SDKCallPlayerSharedImmuneToPushback, GetPlayerSharedAddress(client)); |
| 560 | +} |
| 561 | + |
533 | 562 | // bool(const float[3] position, int entity, bool bRestrictToSameTeam)
|
534 | 563 | int Native_IsPointInRespawnRoom(Handle plugin, int nParams) {
|
535 | 564 | if (IsNativeParamNullVector(1)) {
|
@@ -677,6 +706,37 @@ any Native_SetPlayerBurnDuration(Handle plugin, int numParams) {
|
677 | 706 | SetEntDataFloat(client, pOffsSharedBurnDuration, duration);
|
678 | 707 | }
|
679 | 708 |
|
| 709 | +// void(int client, int attacker, float duration, int weapon = INVALID_ENT_REFERENCE); |
| 710 | +any Native_IgnitePlayer(Handle plugin, int numParams) { |
| 711 | + int client = GetNativeCell(1); |
| 712 | + int attacker = GetNativeCell(2); |
| 713 | + float duration = GetNativeCell(3); |
| 714 | + int weapon = GetNativeCell(4); |
| 715 | + |
| 716 | + if (!(0 < client <= MaxClients)) { |
| 717 | + return ThrowNativeError(SP_ERROR_NATIVE, "Client %d index is not valid", client); |
| 718 | + } else if (!IsClientInGame(client)) { |
| 719 | + return ThrowNativeError(SP_ERROR_NATIVE, "Client %d is not in game", client); |
| 720 | + } |
| 721 | + |
| 722 | + if (attacker != INVALID_ENT_REFERENCE) { |
| 723 | + if (!(0 < attacker <= MaxClients)) { |
| 724 | + return ThrowNativeError(SP_ERROR_NATIVE, "Client %d index is not valid", attacker); |
| 725 | + } else if (!IsClientInGame(attacker)) { |
| 726 | + return ThrowNativeError(SP_ERROR_NATIVE, "Client %d is not in game", attacker); |
| 727 | + } |
| 728 | + } |
| 729 | + |
| 730 | + if (weapon != INVALID_ENT_REFERENCE) { |
| 731 | + if (!IsValidEntity(weapon) || !IsEntityWeapon(weapon)) { |
| 732 | + return ThrowNativeError(SP_ERROR_NATIVE, "Entity %d is not a valid weapon", weapon); |
| 733 | + } |
| 734 | + } |
| 735 | + |
| 736 | + SDKCall(g_SDKCallPlayerSharedBurn, GetPlayerSharedAddress(client), attacker, weapon, |
| 737 | + duration); |
| 738 | +} |
| 739 | + |
680 | 740 | // float(int client);
|
681 | 741 | any Native_GetPlayerRespawnTimeOverride(Handle plugin, int numParams) {
|
682 | 742 | int client = GetNativeCell(1);
|
@@ -730,6 +790,10 @@ static Address GetConditionData(int client, TFCond cond) {
|
730 | 790 | return pCondMemory + view_as<Address>(view_as<int>(cond) * sizeof_TFCondInfo);
|
731 | 791 | }
|
732 | 792 |
|
| 793 | +static Address GetPlayerSharedAddress(int client) { |
| 794 | + return GetEntityAddress(client) + FindSendPropInfo("CTFPlayer", "m_Shared"); |
| 795 | +} |
| 796 | + |
733 | 797 | static bool IsConditionValid(TFCond cond) {
|
734 | 798 | return 0 <= view_as<any>(cond) < g_nConditions;
|
735 | 799 | }
|
|
0 commit comments