3 * ===============================================================
4 * SourceMod SDK Tools Extension
5 * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
6 * ===============================================================
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 #include "extension.h"
26 CallHelper s_Teleport;
27 CallHelper s_GetVelocity;
33 return s_Teleport.supported;
38 if (g_pGameConf->GetOffset("Teleport", &offset))
41 info[0].flags = info[1].flags = info[2].flags = PASSFLAG_BYVAL;
42 info[0].size = info[1].size = info[2].size = sizeof(void *);
43 info[0].type = info[1].type = info[2].type = PassType_Basic;
45 s_Teleport.call = g_pBinTools->CreateVCall(offset, 0, 0, NULL, info, 3);
49 s_Teleport.supported = true;
53 s_Teleport.setup = true;
55 return s_Teleport.supported;
58 void Teleport(CBaseEntity *pEntity, Vector *origin, QAngle *ang, Vector *velocity)
60 unsigned char params[sizeof(void *) * 4];
61 unsigned char *vptr = params;
62 *(CBaseEntity **)vptr = pEntity;
63 vptr += sizeof(CBaseEntity *);
64 *(Vector **)vptr = origin;
65 vptr += sizeof(Vector *);
66 *(QAngle **)vptr = ang;
67 vptr += sizeof(QAngle *);
68 *(Vector **)vptr = velocity;
70 s_Teleport.call->Execute(params, NULL);
73 bool IsTeleportSupported()
75 return SetupTeleport();
78 bool SetupGetVelocity()
80 if (s_GetVelocity.setup)
82 return s_GetVelocity.supported;
86 if (g_pGameConf->GetOffset("GetVelocity", &offset))
89 info[0].flags = info[1].flags = PASSFLAG_BYVAL;
90 info[0].size = info[1].size = sizeof(void *);
91 info[0].type = info[1].type = PassType_Basic;
93 s_GetVelocity.call = g_pBinTools->CreateVCall(offset, 0, 0, NULL, info, 2);
95 if (s_GetVelocity.call)
97 s_GetVelocity.supported = true;
101 s_GetVelocity.setup = true;
103 return s_GetVelocity.supported;
106 void GetVelocity(CBaseEntity *pEntity, Vector *velocity, AngularImpulse *angvelocity)
108 unsigned char params[sizeof(void *) * 3];
109 unsigned char *vptr = params;
110 *(CBaseEntity **)vptr = pEntity;
111 vptr += sizeof(CBaseEntity *);
112 *(Vector **)vptr = velocity;
113 vptr += sizeof(Vector *);
114 *(AngularImpulse **)vptr = angvelocity;
116 s_GetVelocity.call->Execute(params, NULL);
119 bool IsGetVelocitySupported()
121 return SetupGetVelocity();
124 void ShutdownHelpers()
126 s_Teleport.Shutdown();
127 s_GetVelocity.Shutdown();