2008-03-30 09:00:22 +02:00
|
|
|
/**
|
|
|
|
* vim: set ts=4 :
|
|
|
|
* =============================================================================
|
2008-04-05 00:37:14 +02:00
|
|
|
* SourceMod Team Fortress 2 Extension
|
2008-03-30 09:00:22 +02:00
|
|
|
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
|
|
|
* =============================================================================
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it under
|
|
|
|
* the terms of the GNU General Public License, version 3.0, as published by the
|
|
|
|
* Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* As a special exception, AlliedModders LLC gives you permission to link the
|
|
|
|
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
|
|
|
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
|
|
|
* by the Valve Corporation. You must obey the GNU General Public License in
|
|
|
|
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
|
|
|
* this exception to all derivative works. AlliedModders LLC defines further
|
|
|
|
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
|
|
|
* or <http://www.sourcemod.net/license.php>.
|
|
|
|
*
|
|
|
|
* Version: $Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "extension.h"
|
2008-04-05 00:37:14 +02:00
|
|
|
#include "util.h"
|
|
|
|
#include "time.h"
|
2008-03-30 09:00:22 +02:00
|
|
|
#include "RegNatives.h"
|
|
|
|
|
2014-06-24 01:24:27 +02:00
|
|
|
#include <ISDKTools.h>
|
2019-04-12 21:10:37 +02:00
|
|
|
#include <sm_argbuffer.h>
|
2014-06-24 01:24:27 +02:00
|
|
|
|
2011-05-24 16:17:48 +02:00
|
|
|
// native TF2_MakeBleed(client, attacker, Float:duration)
|
2010-07-26 17:06:08 +02:00
|
|
|
cell_t TF2_MakeBleed(IPluginContext *pContext, const cell_t *params)
|
|
|
|
{
|
|
|
|
static ICallWrapper *pWrapper = NULL;
|
|
|
|
|
2015-03-13 21:19:57 +01:00
|
|
|
// CTFPlayerShared::MakeBleed(CTFPlayer*, CTFWeaponBase*, float, int=4, bool=false)
|
2010-07-26 17:06:08 +02:00
|
|
|
if(!pWrapper)
|
|
|
|
{
|
|
|
|
REGISTER_NATIVE_ADDR("MakeBleed",
|
2017-10-22 14:37:51 +02:00
|
|
|
PassInfo pass[6]; \
|
2010-07-26 17:06:08 +02:00
|
|
|
pass[0].flags = PASSFLAG_BYVAL; \
|
|
|
|
pass[0].size = sizeof(CBaseEntity *); \
|
|
|
|
pass[0].type = PassType_Basic; \
|
|
|
|
pass[1].flags = PASSFLAG_BYVAL; \
|
|
|
|
pass[1].size = sizeof(CBaseEntity *); \
|
|
|
|
pass[1].type = PassType_Basic; \
|
|
|
|
pass[2].flags = PASSFLAG_BYVAL; \
|
|
|
|
pass[2].size = sizeof(float); \
|
2019-05-15 13:22:34 +02:00
|
|
|
pass[2].type = PassType_Float; \
|
2012-08-16 00:29:00 +02:00
|
|
|
pass[3].flags = PASSFLAG_BYVAL; \
|
|
|
|
pass[3].size = sizeof(int); \
|
|
|
|
pass[3].type = PassType_Basic; \
|
2015-03-12 22:54:47 +01:00
|
|
|
pass[4].flags = PASSFLAG_BYVAL; \
|
|
|
|
pass[4].size = sizeof(bool); \
|
|
|
|
pass[4].type = PassType_Basic; \
|
2017-10-22 14:37:51 +02:00
|
|
|
pass[5].flags = PASSFLAG_BYVAL; \
|
|
|
|
pass[5].size = sizeof(int); \
|
|
|
|
pass[5].type = PassType_Basic; \
|
|
|
|
pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 6))
|
2010-07-26 17:06:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CBaseEntity *pEntity;
|
|
|
|
if (!(pEntity = UTIL_GetCBaseEntity(params[1], true)))
|
|
|
|
{
|
|
|
|
return pContext->ThrowNativeError("Client index %d is not valid", params[1]);
|
|
|
|
}
|
|
|
|
|
2011-05-24 16:17:48 +02:00
|
|
|
CBaseEntity *pAttacker;
|
|
|
|
if (!(pAttacker = UTIL_GetCBaseEntity(params[2], true)))
|
2010-07-26 17:06:08 +02:00
|
|
|
{
|
|
|
|
return pContext->ThrowNativeError("Client index %d is not valid", params[2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void *obj = (void *)((uint8_t *)pEntity + playerSharedOffset->actual_offset);
|
2019-04-12 21:10:37 +02:00
|
|
|
ArgBuffer<void*, CBaseEntity*, CBaseEntity*,
|
|
|
|
float,
|
|
|
|
int, // Damage amount
|
|
|
|
bool, // Permanent
|
|
|
|
int> // Custom Damage type (bleeding)
|
|
|
|
vstk(obj, pAttacker, NULL, sp_ctof(params[3]), 4, false, 32);
|
|
|
|
|
|
|
|
pWrapper->Execute(vstk, nullptr);
|
2010-07-26 17:06:08 +02:00
|
|
|
return 1;
|
|
|
|
}
|
2008-03-30 09:00:22 +02:00
|
|
|
|
2019-07-05 23:37:25 +02:00
|
|
|
// native TF2_Burn(client, target, duration)
|
2008-03-30 09:00:22 +02:00
|
|
|
cell_t TF2_Burn(IPluginContext *pContext, const cell_t *params)
|
|
|
|
{
|
|
|
|
static ICallWrapper *pWrapper = NULL;
|
|
|
|
|
2015-03-13 21:19:57 +01:00
|
|
|
// CTFPlayerShared::Burn(CTFPlayer*, CTFWeaponBase*, float=-1.0)
|
2008-03-30 09:00:22 +02:00
|
|
|
if (!pWrapper)
|
|
|
|
{
|
|
|
|
REGISTER_NATIVE_ADDR("Burn",
|
2013-10-29 23:59:12 +01:00
|
|
|
PassInfo pass[3]; \
|
2008-03-30 09:00:22 +02:00
|
|
|
pass[0].flags = PASSFLAG_BYVAL; \
|
|
|
|
pass[0].size = sizeof(CBaseEntity *); \
|
|
|
|
pass[0].type = PassType_Basic; \
|
2008-05-31 00:38:04 +02:00
|
|
|
pass[1].flags = PASSFLAG_BYVAL; \
|
|
|
|
pass[1].size = sizeof(CBaseEntity *); \
|
|
|
|
pass[1].type = PassType_Basic; \
|
2013-10-29 23:59:12 +01:00
|
|
|
pass[2].flags = PASSFLAG_BYVAL; \
|
|
|
|
pass[2].size = sizeof(float); \
|
2019-05-15 13:22:34 +02:00
|
|
|
pass[2].type = PassType_Float; \
|
2013-10-29 23:59:12 +01:00
|
|
|
pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 3))
|
2008-03-30 09:00:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CBaseEntity *pEntity;
|
2008-04-05 00:37:14 +02:00
|
|
|
if (!(pEntity = UTIL_GetCBaseEntity(params[1], true)))
|
2008-03-30 09:00:22 +02:00
|
|
|
{
|
|
|
|
return pContext->ThrowNativeError("Client index %d is not valid", params[1]);
|
|
|
|
}
|
|
|
|
|
2008-04-05 00:37:14 +02:00
|
|
|
CBaseEntity *pTarget;
|
|
|
|
if (!(pTarget = UTIL_GetCBaseEntity(params[2], true)))
|
|
|
|
{
|
|
|
|
return pContext->ThrowNativeError("Client index %d is not valid", params[2]);
|
|
|
|
}
|
|
|
|
|
2019-07-05 23:37:25 +02:00
|
|
|
float fDuration = 10.0;
|
|
|
|
// Compatibility fix for the newly-added duration
|
|
|
|
if (params[0] >= 3)
|
|
|
|
{
|
|
|
|
fDuration = sp_ctof(params[3]);
|
|
|
|
}
|
|
|
|
|
2008-04-05 00:37:14 +02:00
|
|
|
void *obj = (void *)((uint8_t *)pEntity + playerSharedOffset->actual_offset);
|
2019-04-12 21:10:37 +02:00
|
|
|
ArgBuffer<void*, CBaseEntity*, CBaseEntity*,
|
|
|
|
float> //duration
|
2019-07-05 23:37:25 +02:00
|
|
|
vstk(obj, pTarget, nullptr, fDuration);
|
2008-03-30 09:00:22 +02:00
|
|
|
|
2019-04-12 21:10:37 +02:00
|
|
|
pWrapper->Execute(vstk, nullptr);
|
2008-03-30 09:00:22 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-04-05 00:37:14 +02:00
|
|
|
// native TF2_Invuln(client, bool:enabled)
|
2008-03-30 09:00:22 +02:00
|
|
|
cell_t TF2_Invuln(IPluginContext *pContext, const cell_t *params)
|
|
|
|
{
|
2008-05-09 01:43:02 +02:00
|
|
|
return pContext->ThrowNativeError("TF2_SetPlayerInvuln is no longer available");
|
2008-04-05 00:37:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cell_t TF2_Disguise(IPluginContext *pContext, const cell_t *params)
|
|
|
|
{
|
|
|
|
static ICallWrapper *pWrapper = NULL;
|
|
|
|
|
2015-03-13 21:52:20 +01:00
|
|
|
//CTFPlayerShared::Disguise(int, int, CTFPlayer *, bool=true)
|
2008-04-05 00:37:14 +02:00
|
|
|
if (!pWrapper)
|
|
|
|
{
|
|
|
|
REGISTER_NATIVE_ADDR("Disguise",
|
2011-04-15 18:11:32 +02:00
|
|
|
PassInfo pass[4]; \
|
2008-04-05 00:37:14 +02:00
|
|
|
pass[0].flags = PASSFLAG_BYVAL; \
|
|
|
|
pass[0].size = sizeof(int); \
|
|
|
|
pass[0].type = PassType_Basic; \
|
|
|
|
pass[1].flags = PASSFLAG_BYVAL; \
|
|
|
|
pass[1].size = sizeof(int); \
|
|
|
|
pass[1].type = PassType_Basic; \
|
2010-10-01 16:46:21 +02:00
|
|
|
pass[2].flags = PASSFLAG_BYVAL; \
|
|
|
|
pass[2].size = sizeof(CBaseEntity *); \
|
|
|
|
pass[2].type = PassType_Basic; \
|
2011-04-15 18:11:32 +02:00
|
|
|
pass[3].flags = PASSFLAG_BYVAL; \
|
|
|
|
pass[3].size = sizeof(bool); \
|
|
|
|
pass[3].type = PassType_Basic; \
|
|
|
|
pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 4))
|
2008-04-05 00:37:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CBaseEntity *pEntity;
|
|
|
|
if (!(pEntity = UTIL_GetCBaseEntity(params[1], true)))
|
|
|
|
{
|
|
|
|
return pContext->ThrowNativeError("Client index %d is not valid", params[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void *obj = (void *)((uint8_t *)pEntity + playerSharedOffset->actual_offset);
|
2010-10-01 16:46:21 +02:00
|
|
|
|
|
|
|
CBaseEntity *pTarget = NULL;
|
|
|
|
// Compatibility fix for the newly-added target parameter
|
|
|
|
if (params[0] >= 4 && params[4] > 0 && !(pTarget = UTIL_GetCBaseEntity(params[4], true)))
|
|
|
|
{
|
2012-06-13 11:07:02 +02:00
|
|
|
return pContext->ThrowNativeError("Target client index %d is not valid", params[4]);
|
2010-10-01 16:46:21 +02:00
|
|
|
}
|
2008-04-05 00:37:14 +02:00
|
|
|
|
2019-04-12 21:10:37 +02:00
|
|
|
ArgBuffer<void*, int, int, CBaseEntity*, bool> vstk(obj, params[2], params[3], pTarget, true);
|
2008-04-05 00:37:14 +02:00
|
|
|
|
2019-04-12 21:10:37 +02:00
|
|
|
pWrapper->Execute(vstk, nullptr);
|
2008-04-05 00:37:14 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
cell_t TF2_RemoveDisguise(IPluginContext *pContext, const cell_t *params)
|
|
|
|
{
|
|
|
|
static ICallWrapper *pWrapper = NULL;
|
|
|
|
|
|
|
|
//CTFPlayerShared::RemoveDisguise()
|
|
|
|
if (!pWrapper)
|
|
|
|
{
|
|
|
|
REGISTER_NATIVE_ADDR("RemoveDisguise",
|
|
|
|
pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, NULL, 0))
|
|
|
|
}
|
|
|
|
|
|
|
|
CBaseEntity *pEntity;
|
|
|
|
if (!(pEntity = UTIL_GetCBaseEntity(params[1], true)))
|
|
|
|
{
|
|
|
|
return pContext->ThrowNativeError("Client index %d is not valid", params[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void *obj = (void *)((uint8_t *)pEntity + playerSharedOffset->actual_offset);
|
2019-04-12 21:10:37 +02:00
|
|
|
ArgBuffer<void*> vstk(obj);
|
2008-04-05 00:37:14 +02:00
|
|
|
|
2019-04-12 21:10:37 +02:00
|
|
|
pWrapper->Execute(vstk, nullptr);
|
2008-04-05 00:37:14 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-03-18 16:35:05 +01:00
|
|
|
cell_t TF2_AddCondition(IPluginContext *pContext, const cell_t *params)
|
|
|
|
{
|
|
|
|
static ICallWrapper *pWrapper = NULL;
|
|
|
|
|
2013-03-16 23:05:22 +01:00
|
|
|
// CTFPlayerShared::AddCond(int, float, CBaseEntity *)
|
2010-03-18 16:35:05 +01:00
|
|
|
if (!pWrapper)
|
|
|
|
{
|
|
|
|
REGISTER_NATIVE_ADDR("AddCondition",
|
2012-12-19 13:55:03 +01:00
|
|
|
PassInfo pass[3]; \
|
2010-03-18 16:35:05 +01:00
|
|
|
pass[0].flags = PASSFLAG_BYVAL; \
|
|
|
|
pass[0].size = sizeof(int); \
|
|
|
|
pass[0].type = PassType_Basic; \
|
|
|
|
pass[1].flags = PASSFLAG_BYVAL; \
|
|
|
|
pass[1].size = sizeof(float); \
|
2019-05-15 13:22:34 +02:00
|
|
|
pass[1].type = PassType_Float; \
|
2012-12-19 13:55:03 +01:00
|
|
|
pass[2].flags = PASSFLAG_BYVAL; \
|
|
|
|
pass[2].size = sizeof(CBaseEntity *); \
|
|
|
|
pass[2].type = PassType_Basic; \
|
|
|
|
pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 3))
|
2010-03-18 16:35:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
CBaseEntity *pEntity;
|
|
|
|
if (!(pEntity = UTIL_GetCBaseEntity(params[1], true)))
|
|
|
|
{
|
|
|
|
return pContext->ThrowNativeError("Client index %d is not valid", params[1]);
|
|
|
|
}
|
|
|
|
|
2013-03-16 23:05:22 +01:00
|
|
|
CBaseEntity *pInflictor = NULL;
|
|
|
|
// Compatibility fix for the new inflictor parameter; TF2 seems to only use player entities in it
|
|
|
|
if (params[0] >= 4 && params[4] > 0 && !(pInflictor = UTIL_GetCBaseEntity(params[4], true)))
|
|
|
|
{
|
|
|
|
return pContext->ThrowNativeError("Inflictor index %d is not valid", params[4]);
|
|
|
|
}
|
|
|
|
|
2010-03-18 16:35:05 +01:00
|
|
|
void *obj = (void *)((uint8_t *)pEntity + playerSharedOffset->actual_offset);
|
2019-05-15 01:22:43 +02:00
|
|
|
ArgBuffer<void*, int, float, CBaseEntity*> vstk(obj, params[2], sp_ctof(params[3]), pInflictor);
|
2010-03-18 16:35:05 +01:00
|
|
|
|
2019-04-12 21:10:37 +02:00
|
|
|
pWrapper->Execute(vstk, nullptr);
|
2010-03-18 16:35:05 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
cell_t TF2_RemoveCondition(IPluginContext *pContext, const cell_t *params)
|
|
|
|
{
|
|
|
|
static ICallWrapper *pWrapper = NULL;
|
|
|
|
|
2010-10-01 16:46:21 +02:00
|
|
|
// CTFPlayerShared::RemoveCond(int, bool)
|
2010-03-18 16:35:05 +01:00
|
|
|
if (!pWrapper)
|
|
|
|
{
|
|
|
|
REGISTER_NATIVE_ADDR("RemoveCondition",
|
2010-10-01 15:07:51 +02:00
|
|
|
PassInfo pass[2]; \
|
2010-03-18 16:35:05 +01:00
|
|
|
pass[0].flags = PASSFLAG_BYVAL; \
|
|
|
|
pass[0].size = sizeof(int); \
|
|
|
|
pass[0].type = PassType_Basic; \
|
2010-10-01 15:07:51 +02:00
|
|
|
pass[1].flags = PASSFLAG_BYVAL; \
|
|
|
|
pass[1].size = sizeof(bool); \
|
|
|
|
pass[1].type = PassType_Basic; \
|
|
|
|
pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 2))
|
2010-03-18 16:35:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
CBaseEntity *pEntity;
|
|
|
|
if (!(pEntity = UTIL_GetCBaseEntity(params[1], true)))
|
|
|
|
{
|
|
|
|
return pContext->ThrowNativeError("Client index %d is not valid", params[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void *obj = (void *)((uint8_t *)pEntity + playerSharedOffset->actual_offset);
|
2019-04-12 21:10:37 +02:00
|
|
|
ArgBuffer<void*, int, bool> vstk(obj, params[2], true);
|
2010-03-18 16:35:05 +01:00
|
|
|
|
2019-04-12 21:10:37 +02:00
|
|
|
pWrapper->Execute(vstk, nullptr);
|
2010-03-18 16:35:05 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-03-31 14:51:25 +02:00
|
|
|
cell_t TF2_StunPlayer(IPluginContext *pContext, const cell_t *params)
|
|
|
|
{
|
|
|
|
static ICallWrapper *pWrapper = NULL;
|
|
|
|
|
|
|
|
// CTFPlayerShared::StunPlayer(float, float, int, CTFPlayer *)
|
|
|
|
if (!pWrapper)
|
|
|
|
{
|
|
|
|
REGISTER_NATIVE_ADDR("StunPlayer",
|
|
|
|
PassInfo pass[4]; \
|
|
|
|
pass[0].flags = PASSFLAG_BYVAL; \
|
|
|
|
pass[0].size = sizeof(float); \
|
2019-05-15 13:22:34 +02:00
|
|
|
pass[0].type = PassType_Float; \
|
2010-03-31 14:51:25 +02:00
|
|
|
pass[1].flags = PASSFLAG_BYVAL; \
|
|
|
|
pass[1].size = sizeof(float); \
|
2019-05-15 13:22:34 +02:00
|
|
|
pass[1].type = PassType_Float; \
|
2010-03-31 14:51:25 +02:00
|
|
|
pass[2].flags = PASSFLAG_BYVAL; \
|
|
|
|
pass[2].size = sizeof(int); \
|
|
|
|
pass[2].type = PassType_Basic; \
|
|
|
|
pass[3].flags = PASSFLAG_BYVAL; \
|
|
|
|
pass[3].size = sizeof(CBaseEntity *); \
|
|
|
|
pass[3].type = PassType_Basic; \
|
|
|
|
pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 4))
|
|
|
|
}
|
|
|
|
|
|
|
|
CBaseEntity *pEntity;
|
|
|
|
if (!(pEntity = UTIL_GetCBaseEntity(params[1], true)))
|
|
|
|
{
|
|
|
|
return pContext->ThrowNativeError("Client index %d is not valid", params[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool bByPlayer = (params[5] != 0);
|
|
|
|
CBaseEntity *pAttacker = NULL;
|
|
|
|
if (bByPlayer && !(pAttacker = UTIL_GetCBaseEntity(params[5], true)))
|
|
|
|
{
|
|
|
|
return pContext->ThrowNativeError("Attacker index %d is not valid", params[5]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void *obj = (void *)((uint8_t *)pEntity + playerSharedOffset->actual_offset);
|
2019-04-12 21:10:37 +02:00
|
|
|
ArgBuffer<void*, float, float, int, CBaseEntity*> vstk(obj, sp_ctof(params[2]), sp_ctof(params[3]), params[4], pAttacker);
|
2010-03-31 14:51:25 +02:00
|
|
|
|
2019-04-12 21:10:37 +02:00
|
|
|
pWrapper->Execute(vstk, nullptr);
|
2010-03-31 14:51:25 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-03-18 16:35:05 +01:00
|
|
|
cell_t TF2_SetPowerplayEnabled(IPluginContext *pContext, const cell_t *params)
|
|
|
|
{
|
|
|
|
static ICallWrapper *pWrapper = NULL;
|
|
|
|
|
|
|
|
// CTFPlayer::SetPowerPlayEnabled(bool)
|
|
|
|
if (!pWrapper)
|
|
|
|
{
|
|
|
|
REGISTER_NATIVE_ADDR("SetPowerplayEnabled",
|
|
|
|
PassInfo pass[1]; \
|
|
|
|
pass[0].flags = PASSFLAG_BYVAL; \
|
|
|
|
pass[0].size = sizeof(bool); \
|
|
|
|
pass[0].type = PassType_Basic; \
|
|
|
|
pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 1))
|
|
|
|
}
|
|
|
|
|
|
|
|
CBaseEntity *pEntity;
|
|
|
|
if (!(pEntity = UTIL_GetCBaseEntity(params[1], true)))
|
|
|
|
{
|
|
|
|
return pContext->ThrowNativeError("Client index %d is not valid", params[1]);
|
|
|
|
}
|
|
|
|
|
2019-04-12 21:10:37 +02:00
|
|
|
ArgBuffer<void*, bool> vstk(pEntity, params[2] != 0);
|
2010-03-18 16:35:05 +01:00
|
|
|
|
2019-04-12 21:10:37 +02:00
|
|
|
pWrapper->Execute(vstk, nullptr);
|
2010-03-18 16:35:05 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-04-05 00:37:14 +02:00
|
|
|
cell_t TF2_Respawn(IPluginContext *pContext, const cell_t *params)
|
|
|
|
{
|
|
|
|
static ICallWrapper *pWrapper = NULL;
|
|
|
|
|
|
|
|
//CTFPlayer::ForceRespawn()
|
|
|
|
|
|
|
|
if (!pWrapper)
|
|
|
|
{
|
|
|
|
int offset;
|
|
|
|
|
|
|
|
if (!g_pGameConf->GetOffset("ForceRespawn", &offset))
|
|
|
|
{
|
|
|
|
return pContext->ThrowNativeError("Failed to locate function");
|
|
|
|
}
|
|
|
|
|
|
|
|
pWrapper = g_pBinTools->CreateVCall(offset,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
0);
|
|
|
|
|
|
|
|
g_RegNatives.Register(pWrapper);
|
|
|
|
}
|
|
|
|
|
|
|
|
CBaseEntity *pEntity;
|
|
|
|
if (!(pEntity = UTIL_GetCBaseEntity(params[1], true)))
|
|
|
|
{
|
|
|
|
return pContext->ThrowNativeError("Client index %d is not valid", params[1]);
|
|
|
|
}
|
|
|
|
|
2019-04-12 21:10:37 +02:00
|
|
|
ArgBuffer<void*> vstk(pEntity);
|
2008-03-30 09:00:22 +02:00
|
|
|
|
2019-04-12 21:10:37 +02:00
|
|
|
pWrapper->Execute(vstk, nullptr);
|
2008-03-30 09:00:22 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-03-18 16:35:05 +01:00
|
|
|
cell_t TF2_Regenerate(IPluginContext *pContext, const cell_t *params)
|
|
|
|
{
|
|
|
|
static ICallWrapper *pWrapper = NULL;
|
|
|
|
|
2012-08-16 00:29:00 +02:00
|
|
|
//CTFPlayer::Regenerate( bool=true )
|
2010-03-18 16:35:05 +01:00
|
|
|
|
|
|
|
if (!pWrapper)
|
|
|
|
{
|
|
|
|
REGISTER_NATIVE_ADDR("Regenerate",
|
2012-08-16 00:29:00 +02:00
|
|
|
PassInfo pass[1]; \
|
|
|
|
pass[0].flags = PASSFLAG_BYVAL; \
|
|
|
|
pass[0].size = sizeof(bool); \
|
|
|
|
pass[0].type = PassType_Basic; \
|
|
|
|
pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 1))
|
2010-03-18 16:35:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
CBaseEntity *pEntity;
|
|
|
|
if (!(pEntity = UTIL_GetCBaseEntity(params[1], true)))
|
|
|
|
{
|
|
|
|
return pContext->ThrowNativeError("Client index %d is not valid", params[1]);
|
|
|
|
}
|
2012-08-16 00:29:00 +02:00
|
|
|
|
2019-04-12 21:10:37 +02:00
|
|
|
ArgBuffer<void*, bool> vstk(pEntity, true);
|
|
|
|
|
|
|
|
pWrapper->Execute(vstk, nullptr);
|
2010-03-18 16:35:05 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-04-05 00:37:14 +02:00
|
|
|
cell_t TF2_GetResourceEntity(IPluginContext *pContext, const cell_t *params)
|
|
|
|
{
|
|
|
|
return g_resourceEntity;
|
|
|
|
}
|
|
|
|
|
|
|
|
cell_t TF2_GetClass(IPluginContext *pContext, const cell_t *params)
|
|
|
|
{
|
|
|
|
char *str;
|
|
|
|
pContext->LocalToString(params[1], &str);
|
|
|
|
|
|
|
|
return (cell_t)ClassnameToType(str);
|
|
|
|
}
|
2008-03-30 09:00:22 +02:00
|
|
|
|
2010-11-08 01:05:32 +01:00
|
|
|
// native TF2_IsPlayerInDuel(client)
|
|
|
|
cell_t TF2_IsPlayerInDuel(IPluginContext *pContext, const cell_t *params)
|
|
|
|
{
|
|
|
|
static ICallWrapper *pWrapper = NULL;
|
|
|
|
|
|
|
|
// DuelMiniGame_IsPlayerInDuel(CTFPlayer *)
|
|
|
|
if (!pWrapper)
|
|
|
|
{
|
|
|
|
REGISTER_NATIVE_ADDR("IsPlayerInDuel",
|
|
|
|
PassInfo pass[1]; \
|
|
|
|
pass[0].flags = PASSFLAG_BYVAL; \
|
|
|
|
pass[0].size = sizeof(CBaseEntity *); \
|
|
|
|
pass[0].type = PassType_Basic; \
|
|
|
|
PassInfo ret; \
|
|
|
|
ret.flags = PASSFLAG_BYVAL; \
|
|
|
|
ret.size = sizeof(bool); \
|
|
|
|
ret.type = PassType_Basic; \
|
|
|
|
pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &ret, pass, 1))
|
|
|
|
}
|
|
|
|
|
|
|
|
CBaseEntity *pPlayer;
|
|
|
|
if (!(pPlayer = UTIL_GetCBaseEntity(params[1], true)))
|
|
|
|
{
|
|
|
|
return pContext->ThrowNativeError("Client index %d is not valid", params[1]);
|
|
|
|
}
|
|
|
|
|
2019-04-12 21:10:37 +02:00
|
|
|
ArgBuffer<CBaseEntity*> vstk(pPlayer);
|
|
|
|
|
2010-11-08 01:05:32 +01:00
|
|
|
bool retValue;
|
|
|
|
pWrapper->Execute(vstk, &retValue);
|
|
|
|
|
|
|
|
return (retValue) ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
2014-04-08 05:17:11 +02:00
|
|
|
// native bool:TF2_IsHolidayActive(TFHoliday:holiday);
|
|
|
|
cell_t TF2_IsHolidayActive(IPluginContext *pContext, const cell_t *params)
|
|
|
|
{
|
2014-06-24 01:24:27 +02:00
|
|
|
void *pGameRules;
|
|
|
|
if (!g_pSDKTools || !(pGameRules = g_pSDKTools->GetGameRules()))
|
|
|
|
{
|
|
|
|
return pContext->ThrowNativeError("Failed to find GameRules");
|
|
|
|
}
|
|
|
|
|
2014-04-08 05:17:11 +02:00
|
|
|
static ICallWrapper *pWrapper = NULL;
|
|
|
|
|
2014-06-23 22:23:49 +02:00
|
|
|
// CTFGameRules::IsHolidayActive(int)
|
2014-04-08 05:17:11 +02:00
|
|
|
if (!pWrapper)
|
|
|
|
{
|
2014-06-23 22:23:49 +02:00
|
|
|
int offset;
|
|
|
|
if (!g_pGameConf->GetOffset("IsHolidayActive", &offset))
|
|
|
|
{
|
|
|
|
return pContext->ThrowNativeError("Failed to locate function");
|
|
|
|
}
|
|
|
|
|
|
|
|
PassInfo pass[1];
|
|
|
|
pass[0].flags = PASSFLAG_BYVAL;
|
|
|
|
pass[0].size = sizeof(int);
|
|
|
|
pass[0].type = PassType_Basic;
|
|
|
|
PassInfo ret;
|
|
|
|
ret.flags = PASSFLAG_BYVAL;
|
|
|
|
ret.size = sizeof(bool);
|
|
|
|
ret.type = PassType_Basic;
|
|
|
|
|
|
|
|
pWrapper = g_pBinTools->CreateVCall(offset, 0, 0, &ret, pass, 1);
|
|
|
|
|
|
|
|
g_RegNatives.Register(pWrapper);
|
2014-04-08 05:17:11 +02:00
|
|
|
}
|
|
|
|
|
2019-04-12 21:10:37 +02:00
|
|
|
ArgBuffer<void*, int> vstk(pGameRules, params[1]);
|
2014-04-08 05:17:11 +02:00
|
|
|
|
2019-04-12 21:10:37 +02:00
|
|
|
bool retValue;
|
2014-04-08 05:17:11 +02:00
|
|
|
pWrapper->Execute(vstk, &retValue);
|
|
|
|
|
|
|
|
return (retValue) ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
2014-07-30 03:31:27 +02:00
|
|
|
cell_t TF2_RemoveWearable(IPluginContext *pContext, const cell_t *params)
|
|
|
|
{
|
|
|
|
static ICallWrapper *pWrapper = NULL;
|
|
|
|
|
|
|
|
//CBasePlayer::RemoveWearable(CEconWearable *)
|
|
|
|
|
|
|
|
if (!pWrapper)
|
|
|
|
{
|
|
|
|
int offset;
|
|
|
|
|
|
|
|
if (!g_pGameConf->GetOffset("RemoveWearable", &offset))
|
|
|
|
{
|
|
|
|
return pContext->ThrowNativeError("Failed to locate function");
|
|
|
|
}
|
|
|
|
|
|
|
|
PassInfo pass[1];
|
|
|
|
pass[0].flags = PASSFLAG_BYVAL;
|
|
|
|
pass[0].size = sizeof(CBaseEntity *);
|
|
|
|
pass[0].type = PassType_Basic;
|
|
|
|
|
|
|
|
pWrapper = g_pBinTools->CreateVCall(offset, 0, 0, NULL, pass, 1);
|
|
|
|
|
|
|
|
g_RegNatives.Register(pWrapper);
|
|
|
|
}
|
|
|
|
|
|
|
|
CBaseEntity *pEntity;
|
|
|
|
if (!(pEntity = UTIL_GetCBaseEntity(params[1], true)))
|
|
|
|
{
|
|
|
|
return pContext->ThrowNativeError("Client index %d is not valid", params[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
CBaseEntity *pWearable;
|
|
|
|
if (!(pWearable = UTIL_GetCBaseEntity(params[2], false)))
|
|
|
|
{
|
|
|
|
return pContext->ThrowNativeError("Wearable index %d is not valid", params[2]);
|
|
|
|
}
|
|
|
|
|
2019-04-12 21:10:37 +02:00
|
|
|
ArgBuffer<void*, CBaseEntity*> vstk(pEntity, pWearable);
|
2014-07-30 03:31:27 +02:00
|
|
|
|
2019-04-12 21:10:37 +02:00
|
|
|
pWrapper->Execute(vstk, nullptr);
|
2014-07-30 03:31:27 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-03-30 09:00:22 +02:00
|
|
|
sp_nativeinfo_t g_TFNatives[] =
|
|
|
|
{
|
2008-04-05 00:37:14 +02:00
|
|
|
{"TF2_IgnitePlayer", TF2_Burn},
|
|
|
|
{"TF2_SetPlayerInvuln", TF2_Invuln},
|
|
|
|
{"TF2_RespawnPlayer", TF2_Respawn},
|
|
|
|
{"TF2_DisguisePlayer", TF2_Disguise},
|
|
|
|
{"TF2_RemovePlayerDisguise", TF2_RemoveDisguise},
|
|
|
|
{"TF2_GetResourceEntity", TF2_GetResourceEntity},
|
|
|
|
{"TF2_GetClass", TF2_GetClass},
|
2010-03-18 16:35:05 +01:00
|
|
|
{"TF2_RegeneratePlayer", TF2_Regenerate},
|
|
|
|
{"TF2_AddCondition", TF2_AddCondition},
|
|
|
|
{"TF2_RemoveCondition", TF2_RemoveCondition},
|
2010-03-31 14:51:25 +02:00
|
|
|
{"TF2_SetPlayerPowerPlay", TF2_SetPowerplayEnabled},
|
|
|
|
{"TF2_StunPlayer", TF2_StunPlayer},
|
2010-07-26 17:06:08 +02:00
|
|
|
{"TF2_MakeBleed", TF2_MakeBleed},
|
2010-11-08 01:05:32 +01:00
|
|
|
{"TF2_IsPlayerInDuel", TF2_IsPlayerInDuel},
|
2014-04-08 05:17:11 +02:00
|
|
|
{"TF2_IsHolidayActive", TF2_IsHolidayActive},
|
2014-07-30 03:31:27 +02:00
|
|
|
{"TF2_RemoveWearable", TF2_RemoveWearable},
|
2008-03-30 09:00:22 +02:00
|
|
|
{NULL, NULL}
|
|
|
|
};
|