2014-08-04 10:05:55 +00:00
|
|
|
// vim: set ts=4 sw=4 tw=99 noet:
|
|
|
|
//
|
|
|
|
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
|
|
|
|
// Copyright (C) The AMX Mod X Development Team.
|
|
|
|
//
|
|
|
|
// This software is licensed under the GNU General Public License, version 3 or higher.
|
|
|
|
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
|
|
|
|
// https://alliedmods.net/amxmodx-license
|
|
|
|
|
|
|
|
//
|
|
|
|
// Engine Module
|
|
|
|
//
|
|
|
|
|
2004-05-26 05:15:40 +00:00
|
|
|
#include "engine.h"
|
|
|
|
|
|
|
|
struct usercmd_s *g_cmd;
|
|
|
|
struct PlayerInfo plinfo[33];
|
|
|
|
struct GlobalInfo glinfo;
|
|
|
|
|
2004-08-11 12:17:39 +00:00
|
|
|
int g_CameraCount;
|
|
|
|
|
2004-06-25 22:51:18 +00:00
|
|
|
TraceResult g_tr;
|
|
|
|
|
2014-08-08 10:44:37 +00:00
|
|
|
char g_buffer[1024];
|
2004-09-16 11:02:51 +00:00
|
|
|
|
2004-05-26 05:15:40 +00:00
|
|
|
void UTIL_SetSize(edict_t *pev, const Vector &vecMin, const Vector &vecMax)
|
|
|
|
{
|
|
|
|
SET_SIZE(ENT(pev), vecMin, vecMax);
|
|
|
|
}
|
|
|
|
|
|
|
|
edict_t *UTIL_FindEntityInSphere(edict_t *pStart, const Vector &vecCenter, float flRadius) {
|
|
|
|
if (!pStart) pStart = NULL;
|
|
|
|
|
|
|
|
pStart = FIND_ENTITY_IN_SPHERE(pStart, vecCenter, flRadius);
|
|
|
|
|
|
|
|
if (!FNullEnt(pStart)) return pStart;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-06-25 22:51:18 +00:00
|
|
|
static cell AMX_NATIVE_CALL register_think(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
|
|
|
|
EntClass *p = new EntClass;
|
|
|
|
const char *clsname = MF_GetAmxString(amx, params[1], 0, &len);
|
2014-08-09 18:30:31 +00:00
|
|
|
p->Class = clsname;
|
2004-06-25 22:51:18 +00:00
|
|
|
|
2004-08-12 03:31:51 +00:00
|
|
|
p->Forward = MF_RegisterSPForwardByName(amx, MF_GetAmxString(amx, params[2], 0, &len), FP_CELL, FP_DONE);
|
2004-06-25 22:51:18 +00:00
|
|
|
|
2014-08-09 18:30:31 +00:00
|
|
|
Thinks.append(p);
|
2004-06-25 22:51:18 +00:00
|
|
|
|
2004-09-08 21:13:04 +00:00
|
|
|
if (!g_pFunctionTable->pfnThink)
|
|
|
|
g_pFunctionTable->pfnThink=Think;
|
|
|
|
|
2004-06-25 22:51:18 +00:00
|
|
|
return p->Forward;
|
|
|
|
}
|
|
|
|
|
2015-05-10 21:40:22 +00:00
|
|
|
static cell AMX_NATIVE_CALL unregister_think(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
int fwd = params[1];
|
|
|
|
for (size_t i = 0; i < Thinks.length(); ++i)
|
|
|
|
{
|
|
|
|
EntClass *p = Thinks.at(i);
|
|
|
|
if (p->Forward == fwd)
|
|
|
|
{
|
|
|
|
Thinks.remove(i);
|
|
|
|
delete p;
|
|
|
|
|
|
|
|
if (!Thinks.length())
|
|
|
|
g_pFunctionTable->pfnThink = NULL;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-06-25 22:51:18 +00:00
|
|
|
static cell AMX_NATIVE_CALL register_impulse(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
|
|
|
|
Impulse *p = new Impulse;
|
|
|
|
p->Check = params[1];
|
|
|
|
|
2004-09-05 19:53:40 +00:00
|
|
|
p->Forward = MF_RegisterSPForwardByName(amx, MF_GetAmxString(amx, params[2], 0, &len), FP_CELL, FP_CELL, FP_DONE);
|
2004-06-25 22:51:18 +00:00
|
|
|
|
2014-08-09 18:30:31 +00:00
|
|
|
Impulses.append(p);
|
2004-06-25 22:51:18 +00:00
|
|
|
|
2004-09-08 21:13:04 +00:00
|
|
|
if (!g_pFunctionTable->pfnCmdStart)
|
|
|
|
g_pFunctionTable->pfnCmdStart=CmdStart;
|
|
|
|
|
2004-06-25 22:51:18 +00:00
|
|
|
return p->Forward;
|
|
|
|
}
|
|
|
|
|
2015-05-10 21:40:22 +00:00
|
|
|
static cell AMX_NATIVE_CALL unregister_impulse(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
int fwd = params[1];
|
|
|
|
for (size_t i = 0; i < Impulses.length(); ++i)
|
|
|
|
{
|
|
|
|
Impulse *p = Impulses.at(i);
|
|
|
|
if (p->Forward == fwd)
|
|
|
|
{
|
|
|
|
Impulses.remove(i);
|
|
|
|
delete p;
|
|
|
|
|
|
|
|
if (!Impulses.length())
|
|
|
|
g_pFunctionTable->pfnCmdStart = NULL;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-06-25 22:51:18 +00:00
|
|
|
static cell AMX_NATIVE_CALL register_touch(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
|
|
|
|
char *Toucher = MF_GetAmxString(amx, params[1], 0, &len);
|
|
|
|
char *Touched = MF_GetAmxString(amx, params[2], 1, &len);
|
|
|
|
|
|
|
|
Touch *p = new Touch;
|
|
|
|
|
|
|
|
if (!strlen(Toucher) || strcmp(Toucher, "*")==0) {
|
2014-12-06 11:22:29 +00:00
|
|
|
p->Toucher = "";
|
2004-06-25 22:51:18 +00:00
|
|
|
} else {
|
2014-08-09 18:30:31 +00:00
|
|
|
p->Toucher = Toucher;
|
2004-06-25 22:51:18 +00:00
|
|
|
}
|
|
|
|
if (!strlen(Touched) || strcmp(Touched, "*")==0) {
|
2014-12-06 11:22:29 +00:00
|
|
|
p->Touched = "";
|
2004-06-25 22:51:18 +00:00
|
|
|
} else {
|
2014-08-09 18:30:31 +00:00
|
|
|
p->Touched = Touched;
|
2004-06-25 22:51:18 +00:00
|
|
|
}
|
|
|
|
|
2004-08-12 03:31:51 +00:00
|
|
|
p->Forward = MF_RegisterSPForwardByName(amx, MF_GetAmxString(amx, params[3], 2, &len), FP_CELL, FP_CELL, FP_DONE);
|
2004-06-25 22:51:18 +00:00
|
|
|
|
2014-08-09 18:30:31 +00:00
|
|
|
Touches.append(p);
|
2004-06-25 22:51:18 +00:00
|
|
|
|
2004-09-08 21:13:04 +00:00
|
|
|
if (!g_pFunctionTable->pfnTouch)
|
|
|
|
g_pFunctionTable->pfnTouch=pfnTouch;
|
2004-08-11 12:17:39 +00:00
|
|
|
|
2004-06-25 22:51:18 +00:00
|
|
|
return p->Forward;
|
|
|
|
}
|
|
|
|
|
2015-05-10 21:40:22 +00:00
|
|
|
static cell AMX_NATIVE_CALL unregister_touch(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
int fwd = params[1];
|
|
|
|
for (size_t i = 0; i < Touches.length(); ++i)
|
|
|
|
{
|
|
|
|
Touch *p = Touches.at(i);
|
|
|
|
if (p->Forward == fwd)
|
|
|
|
{
|
|
|
|
Touches.remove(i);
|
|
|
|
delete p;
|
|
|
|
|
|
|
|
if (!Touches.length())
|
|
|
|
g_pFunctionTable->pfnTouch = NULL;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-05-26 05:15:40 +00:00
|
|
|
static cell AMX_NATIVE_CALL halflife_time(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
REAL fVal = gpGlobals->time;
|
|
|
|
|
|
|
|
return amx_ftoc(fVal);
|
|
|
|
}
|
|
|
|
|
2014-06-05 20:20:06 +00:00
|
|
|
// RadiusDamage. Damages players within a certain radius. ToDo: add the
|
|
|
|
// damage messaging so players know where the damage is coming from
|
|
|
|
// (the red arrow-like things on the screen).
|
|
|
|
static cell AMX_NATIVE_CALL RadiusDamage(AMX *amx, cell *params)
|
2006-09-01 03:29:27 +00:00
|
|
|
{
|
2004-05-26 05:15:40 +00:00
|
|
|
cell *cAddr = MF_GetAmxAddr(amx,params[1]);
|
|
|
|
|
|
|
|
REAL fCurrentX = amx_ctof(cAddr[0]);
|
|
|
|
REAL fCurrentY = amx_ctof(cAddr[1]);
|
|
|
|
REAL fCurrentZ = amx_ctof(cAddr[2]);
|
|
|
|
int iDamageMultiplier = params[2];
|
|
|
|
int iRadiusMultiplier = params[3];
|
|
|
|
|
|
|
|
Vector vOrigin = Vector(fCurrentX, fCurrentY, fCurrentZ);
|
|
|
|
|
|
|
|
edict_t *pSearchEnt = NULL;
|
2007-04-25 18:13:16 +00:00
|
|
|
while ((pSearchEnt = UTIL_FindEntityInSphere(pSearchEnt, vOrigin, 5 * iRadiusMultiplier)) != NULL)
|
|
|
|
{
|
|
|
|
if (FStrEq(STRING(pSearchEnt->v.classname), "player"))
|
|
|
|
{
|
|
|
|
if (pSearchEnt->v.takedamage != DAMAGE_NO)
|
|
|
|
{
|
|
|
|
pSearchEnt->v.health -= 10 + RANDOM_FLOAT(0, 1 * iDamageMultiplier);
|
|
|
|
if (pSearchEnt->v.health < 1)
|
|
|
|
{
|
2004-05-26 05:15:40 +00:00
|
|
|
MDLL_ClientKill(pSearchEnt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pSearchEnt = NULL;
|
|
|
|
|
2007-04-25 18:13:16 +00:00
|
|
|
while ((pSearchEnt = UTIL_FindEntityInSphere(pSearchEnt, vOrigin, 4 * iRadiusMultiplier)) != NULL)
|
|
|
|
{
|
|
|
|
if (FStrEq(STRING(pSearchEnt->v.classname), "player"))
|
|
|
|
{
|
|
|
|
if (pSearchEnt->v.takedamage != DAMAGE_NO)
|
|
|
|
{
|
|
|
|
pSearchEnt->v.health -= 25 + RANDOM_FLOAT(0, 2 * iDamageMultiplier);
|
|
|
|
if (pSearchEnt->v.health < 1)
|
|
|
|
{
|
2004-05-26 05:15:40 +00:00
|
|
|
MDLL_ClientKill(pSearchEnt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pSearchEnt = NULL;
|
|
|
|
|
2007-04-25 18:13:16 +00:00
|
|
|
while ((pSearchEnt = UTIL_FindEntityInSphere(pSearchEnt, vOrigin, 3 * iRadiusMultiplier)) != NULL)
|
|
|
|
{
|
|
|
|
if (FStrEq(STRING(pSearchEnt->v.classname), "player"))
|
|
|
|
{
|
|
|
|
if (pSearchEnt->v.takedamage != DAMAGE_NO)
|
|
|
|
{
|
|
|
|
pSearchEnt->v.health -= 50 + RANDOM_FLOAT(0, 3 * iDamageMultiplier);
|
|
|
|
if (pSearchEnt->v.health < 1)
|
|
|
|
{
|
2004-05-26 05:15:40 +00:00
|
|
|
MDLL_ClientKill(pSearchEnt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pSearchEnt = NULL;
|
|
|
|
|
2007-04-25 18:13:16 +00:00
|
|
|
while ((pSearchEnt = UTIL_FindEntityInSphere(pSearchEnt, vOrigin, 2 * iRadiusMultiplier)) != NULL)
|
|
|
|
{
|
|
|
|
if (FStrEq(STRING(pSearchEnt->v.classname), "player"))
|
|
|
|
{
|
|
|
|
if (pSearchEnt->v.takedamage != DAMAGE_NO)
|
|
|
|
{
|
|
|
|
MDLL_ClientKill(pSearchEnt);
|
|
|
|
}
|
2004-05-26 05:15:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static cell AMX_NATIVE_CALL PointContents(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
cell *cAddr = MF_GetAmxAddr(amx, params[1]);
|
|
|
|
|
|
|
|
REAL fX = amx_ctof(cAddr[0]);
|
|
|
|
REAL fY = amx_ctof(cAddr[1]);
|
|
|
|
REAL fZ = amx_ctof(cAddr[2]);
|
|
|
|
|
|
|
|
Vector vPoint = Vector(fX, fY, fZ);
|
|
|
|
|
|
|
|
return POINT_CONTENTS(vPoint);
|
|
|
|
}
|
|
|
|
|
|
|
|
static cell AMX_NATIVE_CALL trace_normal(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
int iEnt = params[1];
|
2015-07-13 12:43:39 +00:00
|
|
|
if (iEnt > 0) {
|
|
|
|
CHECK_ENTITY(iEnt);
|
|
|
|
}
|
2004-05-26 05:15:40 +00:00
|
|
|
|
|
|
|
cell *cStart = MF_GetAmxAddr(amx, params[2]);
|
|
|
|
cell *cEnd = MF_GetAmxAddr(amx, params[3]);
|
|
|
|
REAL fStartX = amx_ctof(cStart[0]);
|
|
|
|
REAL fStartY = amx_ctof(cStart[1]);
|
|
|
|
REAL fStartZ = amx_ctof(cStart[2]);
|
|
|
|
REAL fEndX = amx_ctof(cEnd[0]);
|
|
|
|
REAL fEndY = amx_ctof(cEnd[1]);
|
|
|
|
REAL fEndZ = amx_ctof(cEnd[2]);
|
|
|
|
|
|
|
|
cell *vRet = MF_GetAmxAddr(amx, params[4]);
|
|
|
|
|
|
|
|
Vector vStart = Vector(fStartX, fStartY, fStartZ);
|
|
|
|
Vector vEnd = Vector(fEndX, fEndY, fEndZ);
|
|
|
|
|
2015-10-06 22:10:48 +00:00
|
|
|
TRACE_LINE(vStart, vEnd, dont_ignore_monsters, iEnt > 0 ? TypeConversion.id_to_edict(iEnt) : NULL, &g_tr);
|
2004-05-26 05:15:40 +00:00
|
|
|
|
2015-05-10 22:08:47 +00:00
|
|
|
vRet[0] = amx_ftoc(g_tr.vecPlaneNormal.x);
|
|
|
|
vRet[1] = amx_ftoc(g_tr.vecPlaneNormal.y);
|
|
|
|
vRet[2] = amx_ftoc(g_tr.vecPlaneNormal.z);
|
2004-05-26 05:15:40 +00:00
|
|
|
|
2015-05-10 22:08:47 +00:00
|
|
|
if (g_tr.flFraction >= 1.0)
|
2004-05-26 05:15:40 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static cell AMX_NATIVE_CALL trace_line(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
int iEnt = params[1];
|
2015-07-13 12:43:39 +00:00
|
|
|
if (iEnt > 0) {
|
2015-05-10 23:09:45 +00:00
|
|
|
CHECK_ENTITY(iEnt);
|
2015-06-11 14:08:46 +00:00
|
|
|
}
|
2004-05-26 05:15:40 +00:00
|
|
|
|
|
|
|
cell *cStart = MF_GetAmxAddr(amx, params[2]);
|
|
|
|
cell *cEnd = MF_GetAmxAddr(amx, params[3]);
|
|
|
|
REAL fStartX = amx_ctof(cStart[0]);
|
|
|
|
REAL fStartY = amx_ctof(cStart[1]);
|
|
|
|
REAL fStartZ = amx_ctof(cStart[2]);
|
|
|
|
REAL fEndX = amx_ctof(cEnd[0]);
|
|
|
|
REAL fEndY = amx_ctof(cEnd[1]);
|
|
|
|
REAL fEndZ = amx_ctof(cEnd[2]);
|
|
|
|
|
|
|
|
cell *vRet = MF_GetAmxAddr(amx, params[4]);
|
|
|
|
|
|
|
|
Vector vStart = Vector(fStartX, fStartY, fStartZ);
|
|
|
|
Vector vEnd = Vector(fEndX, fEndY, fEndZ);
|
2015-05-10 22:08:47 +00:00
|
|
|
|
2015-07-13 12:43:39 +00:00
|
|
|
if (iEnt > 0)
|
2015-10-06 22:10:48 +00:00
|
|
|
TRACE_LINE(vStart, vEnd, dont_ignore_monsters, TypeConversion.id_to_edict(iEnt), &g_tr);
|
2015-07-13 12:43:39 +00:00
|
|
|
else
|
|
|
|
TRACE_LINE(vStart, vEnd, ignore_monsters, NULL, &g_tr);
|
2004-05-26 05:15:40 +00:00
|
|
|
|
2015-05-10 22:08:47 +00:00
|
|
|
edict_t *pHit = g_tr.pHit;
|
2004-05-26 05:15:40 +00:00
|
|
|
|
2015-05-10 22:08:47 +00:00
|
|
|
vRet[0] = amx_ftoc(g_tr.vecEndPos.x);
|
|
|
|
vRet[1] = amx_ftoc(g_tr.vecEndPos.y);
|
|
|
|
vRet[2] = amx_ftoc(g_tr.vecEndPos.z);
|
2004-05-26 05:15:40 +00:00
|
|
|
|
|
|
|
if (FNullEnt(pHit))
|
|
|
|
return 0;
|
|
|
|
|
2016-02-03 16:34:51 +00:00
|
|
|
return TypeConversion.edict_to_id(pHit);
|
2004-05-26 05:15:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static cell AMX_NATIVE_CALL set_speak(AMX *amx, cell *params) {
|
|
|
|
int iIndex = params[1];
|
|
|
|
int iNewSpeakFlags = params[2];
|
|
|
|
|
2004-10-03 20:00:23 +00:00
|
|
|
if (iIndex > gpGlobals->maxClients || !MF_IsPlayerIngame(iIndex)) {
|
|
|
|
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", iIndex);
|
2004-05-26 05:15:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
plinfo[iIndex].iSpeakFlags = iNewSpeakFlags;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static cell AMX_NATIVE_CALL get_speak(AMX *amx, cell *params) {
|
|
|
|
int iIndex = params[1];
|
|
|
|
|
2004-10-03 20:00:23 +00:00
|
|
|
if (iIndex > gpGlobals->maxClients || !MF_IsPlayerIngame(iIndex)) {
|
|
|
|
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", iIndex);
|
2004-05-26 05:15:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return plinfo[iIndex].iSpeakFlags;
|
|
|
|
}
|
|
|
|
|
|
|
|
static cell AMX_NATIVE_CALL get_decal_index(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
char *szDecal = MF_GetAmxString(amx, params[1], 0, &len);
|
|
|
|
return DECAL_INDEX(szDecal);
|
|
|
|
}
|
|
|
|
|
|
|
|
static cell AMX_NATIVE_CALL get_info_keybuffer(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
int iEnt = params[1];
|
2015-06-11 14:08:46 +00:00
|
|
|
if (iEnt != -1) {
|
2015-05-10 22:19:26 +00:00
|
|
|
CHECK_ENTITY(iEnt);
|
2015-06-11 14:08:46 +00:00
|
|
|
}
|
2004-05-26 05:15:40 +00:00
|
|
|
|
2015-10-06 22:10:48 +00:00
|
|
|
char *info = GETINFOKEYBUFFER((iEnt == -1) ? NULL : TypeConversion.id_to_edict(iEnt));
|
2004-05-26 05:15:40 +00:00
|
|
|
|
2015-05-10 22:35:14 +00:00
|
|
|
return MF_SetAmxStringUTF8Char(amx, params[2], info, strlen(info), params[3]);
|
2004-05-26 05:15:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//from jghg, who says it doesn't work
|
2004-08-12 03:31:51 +00:00
|
|
|
// it works, it's just a picky engine call -sawce
|
2004-05-26 05:15:40 +00:00
|
|
|
static cell AMX_NATIVE_CALL drop_to_floor(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
int iEnt = params[1];
|
|
|
|
|
2004-10-03 20:00:23 +00:00
|
|
|
CHECK_ENTITY(iEnt);
|
2004-05-26 05:15:40 +00:00
|
|
|
|
2015-10-06 22:10:48 +00:00
|
|
|
edict_t *e = TypeConversion.id_to_edict(iEnt);
|
2004-05-26 05:15:40 +00:00
|
|
|
|
|
|
|
return DROP_TO_FLOOR(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Attachview, this allows you to attach a player's view to an entity.
|
|
|
|
// use AttachView(player, player) to reset view.
|
|
|
|
//(vexd)
|
|
|
|
static cell AMX_NATIVE_CALL attach_view(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
int iIndex = params[1];
|
|
|
|
int iTargetIndex = params[2];
|
|
|
|
|
2004-10-03 20:00:23 +00:00
|
|
|
CHECK_ENTITY(iIndex);
|
2015-05-10 23:09:45 +00:00
|
|
|
CHECK_ENTITY(iTargetIndex);
|
2004-05-26 05:15:40 +00:00
|
|
|
|
2015-10-06 22:10:48 +00:00
|
|
|
SET_VIEW(TypeConversion.id_to_edict(iIndex), TypeConversion.id_to_edict(iTargetIndex));
|
2004-05-26 05:15:40 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetView, this sets the view of a player. This is done by
|
|
|
|
// Creating a camera entity, which follows the player.
|
|
|
|
//(vexd)
|
|
|
|
static cell AMX_NATIVE_CALL set_view(AMX *amx, cell *params) {
|
|
|
|
int iIndex = params[1];
|
|
|
|
int iCameraType = params[2];
|
|
|
|
|
2004-10-03 20:00:23 +00:00
|
|
|
if (iIndex > gpGlobals->maxClients || !MF_IsPlayerIngame(iIndex)) {
|
|
|
|
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", iIndex);
|
2004-05-26 05:15:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-10-06 22:10:48 +00:00
|
|
|
edict_t *pPlayer = TypeConversion.id_to_edict(iIndex);
|
2004-05-26 05:15:40 +00:00
|
|
|
edict_t *pNewCamera;
|
|
|
|
|
|
|
|
switch(iCameraType)
|
|
|
|
{
|
|
|
|
case CAMERA_NONE:
|
|
|
|
SET_VIEW(pPlayer, pPlayer);
|
2016-02-03 16:34:51 +00:00
|
|
|
if(plinfo[iIndex].pViewEnt) {
|
|
|
|
REMOVE_ENTITY(plinfo[iIndex].pViewEnt);
|
2004-05-26 05:15:40 +00:00
|
|
|
}
|
2016-02-03 16:34:51 +00:00
|
|
|
if (plinfo[iIndex].iViewType != CAMERA_NONE) // Verify that they were originally in a modified view
|
2004-08-11 12:17:39 +00:00
|
|
|
{
|
|
|
|
g_CameraCount--;
|
|
|
|
if (g_CameraCount < 0)
|
|
|
|
g_CameraCount=0;
|
2004-08-12 03:31:51 +00:00
|
|
|
if (g_CameraCount==0) // Reset the AddToFullPack pointer if there's no more cameras in use...
|
|
|
|
g_pFunctionTable->pfnAddToFullPack=NULL;
|
2004-08-11 12:17:39 +00:00
|
|
|
}
|
|
|
|
|
2016-02-03 16:34:51 +00:00
|
|
|
plinfo[iIndex].iViewType = CAMERA_NONE;
|
|
|
|
plinfo[iIndex].pViewEnt = NULL;
|
2004-05-26 05:15:40 +00:00
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
case CAMERA_3RDPERSON:
|
2016-02-03 16:34:51 +00:00
|
|
|
if(plinfo[iIndex].iViewType != CAMERA_NONE) {
|
|
|
|
plinfo[iIndex].iViewType = CAMERA_3RDPERSON;
|
2004-05-26 05:15:40 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2004-08-11 12:17:39 +00:00
|
|
|
g_CameraCount++;
|
2013-06-15 20:02:24 +00:00
|
|
|
g_pFunctionTable_Post->pfnAddToFullPack=AddToFullPack_Post;
|
2004-08-12 03:31:51 +00:00
|
|
|
g_pFunctionTable_Post->pfnPlayerPostThink=PlayerPostThink_Post;
|
2004-05-26 05:15:40 +00:00
|
|
|
|
2016-02-03 16:34:51 +00:00
|
|
|
plinfo[iIndex].iViewType = CAMERA_3RDPERSON;
|
2004-05-26 05:15:40 +00:00
|
|
|
pNewCamera = CREATE_NAMED_ENTITY(MAKE_STRING("info_target"));
|
|
|
|
pNewCamera->v.classname = MAKE_STRING("VexdCam");
|
|
|
|
|
|
|
|
SET_MODEL(pNewCamera, "models/rpgrocket.mdl");
|
|
|
|
SET_SIZE(pNewCamera, Vector(0, 0, 0), Vector(0, 0, 0));
|
|
|
|
|
|
|
|
pNewCamera->v.movetype = MOVETYPE_NOCLIP;
|
|
|
|
pNewCamera->v.solid = SOLID_NOT;
|
|
|
|
pNewCamera->v.takedamage = DAMAGE_NO;
|
|
|
|
pNewCamera->v.gravity = 0;
|
|
|
|
pNewCamera->v.owner = pPlayer;
|
|
|
|
pNewCamera->v.rendermode = kRenderTransColor;
|
|
|
|
pNewCamera->v.renderamt = 0;
|
|
|
|
pNewCamera->v.renderfx = kRenderFxNone;
|
|
|
|
|
|
|
|
SET_VIEW(pPlayer, pNewCamera);
|
|
|
|
|
2016-02-03 16:34:51 +00:00
|
|
|
plinfo[iIndex].pViewEnt = pNewCamera;
|
2004-05-26 05:15:40 +00:00
|
|
|
break;
|
|
|
|
case CAMERA_UPLEFT:
|
2016-02-03 16:34:51 +00:00
|
|
|
if(plinfo[iIndex].iViewType != CAMERA_NONE) {
|
|
|
|
plinfo[iIndex].iViewType = CAMERA_UPLEFT;
|
2004-05-26 05:15:40 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2004-08-11 12:17:39 +00:00
|
|
|
g_CameraCount++;
|
2013-06-15 20:02:24 +00:00
|
|
|
g_pFunctionTable_Post->pfnAddToFullPack=AddToFullPack_Post;
|
2004-08-12 03:31:51 +00:00
|
|
|
g_pFunctionTable_Post->pfnPlayerPostThink=PlayerPostThink_Post;
|
2004-05-26 05:15:40 +00:00
|
|
|
|
2016-02-03 16:34:51 +00:00
|
|
|
plinfo[iIndex].iViewType = CAMERA_UPLEFT;
|
2004-05-26 05:15:40 +00:00
|
|
|
pNewCamera = CREATE_NAMED_ENTITY(MAKE_STRING("info_target"));
|
|
|
|
pNewCamera->v.classname = MAKE_STRING("VexdCam");
|
|
|
|
|
|
|
|
SET_MODEL(pNewCamera, "models/rpgrocket.mdl");
|
|
|
|
SET_SIZE(pNewCamera, Vector(0, 0, 0), Vector(0, 0, 0));
|
|
|
|
|
|
|
|
pNewCamera->v.movetype = MOVETYPE_NOCLIP;
|
|
|
|
pNewCamera->v.solid = SOLID_NOT;
|
|
|
|
pNewCamera->v.takedamage = DAMAGE_NO;
|
|
|
|
pNewCamera->v.gravity = 0;
|
|
|
|
pNewCamera->v.owner = pPlayer;
|
|
|
|
pNewCamera->v.rendermode = kRenderTransColor;
|
|
|
|
pNewCamera->v.renderamt = 0;
|
|
|
|
pNewCamera->v.renderfx = kRenderFxNone;
|
|
|
|
|
|
|
|
SET_VIEW(pPlayer, pNewCamera);
|
|
|
|
|
2016-02-03 16:34:51 +00:00
|
|
|
plinfo[iIndex].pViewEnt = pNewCamera;
|
2004-05-26 05:15:40 +00:00
|
|
|
break;
|
|
|
|
case CAMERA_TOPDOWN:
|
2016-02-03 16:34:51 +00:00
|
|
|
if(plinfo[iIndex].iViewType != CAMERA_NONE) {
|
|
|
|
plinfo[iIndex].iViewType = CAMERA_TOPDOWN;
|
2004-05-26 05:15:40 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2004-08-11 12:17:39 +00:00
|
|
|
g_CameraCount++;
|
2013-06-15 20:02:24 +00:00
|
|
|
g_pFunctionTable_Post->pfnAddToFullPack=AddToFullPack_Post;
|
2004-08-12 03:31:51 +00:00
|
|
|
g_pFunctionTable_Post->pfnPlayerPostThink=PlayerPostThink_Post;
|
2004-05-26 05:15:40 +00:00
|
|
|
|
2016-02-03 16:34:51 +00:00
|
|
|
plinfo[iIndex].iViewType = CAMERA_TOPDOWN;
|
2004-05-26 05:15:40 +00:00
|
|
|
pNewCamera = CREATE_NAMED_ENTITY(MAKE_STRING("info_target"));
|
|
|
|
pNewCamera->v.classname = MAKE_STRING("VexdCam");
|
|
|
|
|
|
|
|
SET_MODEL(pNewCamera, "models/rpgrocket.mdl");
|
|
|
|
SET_SIZE(pNewCamera, Vector(0, 0, 0), Vector(0, 0, 0));
|
|
|
|
|
|
|
|
pNewCamera->v.movetype = MOVETYPE_NOCLIP;
|
|
|
|
pNewCamera->v.solid = SOLID_NOT;
|
|
|
|
pNewCamera->v.takedamage = DAMAGE_NO;
|
|
|
|
pNewCamera->v.gravity = 0;
|
|
|
|
pNewCamera->v.owner = pPlayer;
|
|
|
|
pNewCamera->v.rendermode = kRenderTransColor;
|
|
|
|
pNewCamera->v.renderamt = 0;
|
|
|
|
pNewCamera->v.renderfx = kRenderFxNone;
|
|
|
|
|
|
|
|
SET_VIEW(pPlayer, pNewCamera);
|
|
|
|
|
2016-02-03 16:34:51 +00:00
|
|
|
plinfo[iIndex].pViewEnt = pNewCamera;
|
2004-05-26 05:15:40 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetLights, this sets the lights for the map.
|
|
|
|
//(vexd)
|
|
|
|
static cell AMX_NATIVE_CALL set_lights(AMX *amx, cell *params) {
|
|
|
|
int iLength;
|
|
|
|
char *szLights = MF_GetAmxString(amx, params[1], 0, &iLength);
|
|
|
|
|
|
|
|
if (FStrEq(szLights, "#OFF")) {
|
2005-11-26 20:38:58 +00:00
|
|
|
glinfo.bCheckLights = false;
|
2004-05-26 05:15:40 +00:00
|
|
|
memset(glinfo.szLastLights, 0x0, 128);
|
2015-05-10 21:21:12 +00:00
|
|
|
LIGHT_STYLE(0, glinfo.szRealLights);
|
2004-05-26 05:15:40 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2005-11-26 20:59:47 +00:00
|
|
|
|
2004-05-26 05:15:40 +00:00
|
|
|
glinfo.bCheckLights = true;
|
|
|
|
|
2015-05-10 21:21:12 +00:00
|
|
|
//Reset LastLights and store custom lighting
|
2017-12-07 17:45:16 +00:00
|
|
|
ke::SafeStrcpy(glinfo.szLastLights, sizeof(glinfo.szLastLights), szLights);
|
2004-05-26 05:15:40 +00:00
|
|
|
|
2015-06-11 14:08:46 +00:00
|
|
|
LightStyleDetour->DisableDetour();
|
2017-10-08 19:57:12 +00:00
|
|
|
LIGHT_STYLE(0, glinfo.szLastLights);
|
2015-06-11 14:08:46 +00:00
|
|
|
LightStyleDetour->EnableDetour();
|
2004-05-26 05:15:40 +00:00
|
|
|
|
|
|
|
// These make it so that players/weaponmodels look like whatever the lighting is
|
|
|
|
// at. otherwise it would color players under the skybox to these values.
|
|
|
|
SERVER_COMMAND("sv_skycolor_r 0\n");
|
|
|
|
SERVER_COMMAND("sv_skycolor_g 0\n");
|
|
|
|
SERVER_COMMAND("sv_skycolor_b 0\n");
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//(mahnsawce)
|
|
|
|
static cell AMX_NATIVE_CALL trace_hull(AMX *amx,cell *params)
|
|
|
|
{
|
2015-05-10 23:09:45 +00:00
|
|
|
int iEnt = params[3];
|
2015-06-11 14:08:46 +00:00
|
|
|
if (iEnt > 0) {
|
2015-05-10 23:09:45 +00:00
|
|
|
CHECK_ENTITY(iEnt);
|
2015-06-11 14:08:46 +00:00
|
|
|
}
|
2015-05-10 23:09:45 +00:00
|
|
|
|
2004-05-26 05:15:40 +00:00
|
|
|
int iResult=0;
|
2015-05-10 22:05:25 +00:00
|
|
|
Vector vStart;
|
|
|
|
Vector vEnd;
|
2004-05-26 05:15:40 +00:00
|
|
|
cell *vCell;
|
|
|
|
|
|
|
|
vCell = MF_GetAmxAddr(amx, params[1]);
|
|
|
|
|
2015-05-10 22:05:25 +00:00
|
|
|
vStart.x = amx_ctof(vCell[0]);
|
|
|
|
vStart.y = amx_ctof(vCell[1]);
|
|
|
|
vStart.z = amx_ctof(vCell[2]);
|
2004-05-26 05:15:40 +00:00
|
|
|
|
2015-05-10 22:05:25 +00:00
|
|
|
if (params[0] / sizeof(cell) >= 5 && (vCell = MF_GetAmxVectorNull(amx, params[5])))
|
|
|
|
{
|
|
|
|
|
|
|
|
vEnd.x = amx_ctof(vCell[0]);
|
|
|
|
vEnd.y = amx_ctof(vCell[1]);
|
|
|
|
vEnd.z = amx_ctof(vCell[2]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
vEnd = vStart;
|
|
|
|
|
2015-05-10 23:09:45 +00:00
|
|
|
|
2015-10-06 22:10:48 +00:00
|
|
|
TRACE_HULL(vStart, vEnd, params[4], params[2], iEnt > 0 ? TypeConversion.id_to_edict(iEnt) : NULL, &g_tr);
|
2004-05-26 05:15:40 +00:00
|
|
|
|
2015-05-10 22:08:47 +00:00
|
|
|
if (g_tr.fStartSolid) {
|
2004-05-26 05:15:40 +00:00
|
|
|
iResult += 1;
|
|
|
|
}
|
2015-05-10 22:08:47 +00:00
|
|
|
if (g_tr.fAllSolid) {
|
2004-05-26 05:15:40 +00:00
|
|
|
iResult += 2;
|
|
|
|
}
|
2015-05-10 22:08:47 +00:00
|
|
|
if (!g_tr.fInOpen) {
|
2004-05-26 05:15:40 +00:00
|
|
|
iResult += 4;
|
|
|
|
}
|
|
|
|
return iResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
//(mahnsawce)
|
|
|
|
static cell AMX_NATIVE_CALL playback_event(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
/* Params:
|
|
|
|
* native playback_event(flags,invoker,eventindex,Float:delay,Float:origin[3],Float:angles[3],Float:fparam1,Float:fparam2,iparam1,iparam2,bparam1,bparam2)
|
|
|
|
* 1 2 3 4 5 6 7 8 9 10 11 12
|
|
|
|
*/
|
|
|
|
int flags;
|
|
|
|
edict_t *pInvoker;
|
|
|
|
unsigned short eventindex;
|
|
|
|
REAL delay;
|
|
|
|
vec3_t origin;
|
|
|
|
vec3_t angles;
|
|
|
|
REAL fparam1;
|
|
|
|
REAL fparam2;
|
|
|
|
int iparam1;
|
|
|
|
int iparam2;
|
|
|
|
int bparam1;
|
|
|
|
int bparam2;
|
|
|
|
flags = params[1];
|
2015-07-13 12:43:39 +00:00
|
|
|
if (params[2] > 0) {
|
|
|
|
CHECK_ENTITY(params[2]);
|
|
|
|
}
|
2015-10-06 22:10:48 +00:00
|
|
|
pInvoker=TypeConversion.id_to_edict(params[2]);
|
2004-05-26 05:15:40 +00:00
|
|
|
eventindex=params[3];
|
|
|
|
delay=amx_ctof(params[4]);
|
|
|
|
cell *cOrigin=MF_GetAmxAddr(amx, params[5]);
|
|
|
|
cell *cAngles=MF_GetAmxAddr(amx, params[6]);
|
|
|
|
origin.x=amx_ctof(cOrigin[0]);
|
|
|
|
origin.y=amx_ctof(cOrigin[1]);
|
|
|
|
origin.z=amx_ctof(cOrigin[2]);
|
|
|
|
angles.x=amx_ctof(cAngles[0]);
|
|
|
|
angles.y=amx_ctof(cAngles[1]);
|
|
|
|
angles.z=amx_ctof(cAngles[2]);
|
|
|
|
fparam1=amx_ctof(params[7]);
|
|
|
|
fparam2=amx_ctof(params[8]);
|
|
|
|
iparam1=params[9];
|
|
|
|
iparam2=params[10];
|
|
|
|
bparam1=params[11];
|
|
|
|
bparam2=params[12];
|
|
|
|
PLAYBACK_EVENT_FULL(flags, pInvoker,eventindex, delay, origin, angles, fparam1, fparam2, iparam1, iparam2, bparam1, bparam2);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//(mahnsawce)
|
|
|
|
static cell AMX_NATIVE_CALL get_usercmd(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
if (!incmd)
|
|
|
|
return 0;
|
|
|
|
int type = params[1];
|
|
|
|
if (type > usercmd_int_start && type < usercmd_int_end)
|
|
|
|
{
|
|
|
|
// Requesting an integer value...
|
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case usercmd_lerp_msec:
|
2015-10-06 22:10:48 +00:00
|
|
|
return g_cmd->lerp_msec;
|
2004-05-26 05:15:40 +00:00
|
|
|
case usercmd_msec:
|
|
|
|
return g_cmd->msec;
|
|
|
|
case usercmd_lightlevel:
|
|
|
|
return g_cmd->lightlevel;
|
|
|
|
case usercmd_buttons:
|
|
|
|
return g_cmd->buttons;
|
|
|
|
case usercmd_weaponselect:
|
|
|
|
return g_cmd->weaponselect;
|
|
|
|
case usercmd_impact_index:
|
|
|
|
return g_cmd->impact_index;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (type > usercmd_float_start && type < usercmd_float_end)
|
|
|
|
{
|
|
|
|
// Requesting a single float value
|
|
|
|
// The second parameter needs to be the float variable.
|
|
|
|
|
|
|
|
cell *cRet = MF_GetAmxAddr(amx, params[2]);
|
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case usercmd_forwardmove:
|
2004-06-25 22:51:18 +00:00
|
|
|
*cRet = amx_ftoc(g_cmd->forwardmove);
|
2004-05-26 05:15:40 +00:00
|
|
|
return 1;
|
|
|
|
case usercmd_sidemove:
|
2004-06-25 22:51:18 +00:00
|
|
|
*cRet = amx_ftoc(g_cmd->sidemove);
|
2004-05-26 05:15:40 +00:00
|
|
|
return 1;
|
|
|
|
case usercmd_upmove:
|
2004-06-25 22:51:18 +00:00
|
|
|
*cRet = amx_ftoc(g_cmd->upmove);
|
2004-05-26 05:15:40 +00:00
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (type > usercmd_vec_start && type < usercmd_vec_end)
|
|
|
|
{
|
|
|
|
// Requesting a Vector value.
|
|
|
|
cell *cRet = MF_GetAmxAddr(amx,params[2]);
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case usercmd_viewangles:
|
2004-06-25 22:51:18 +00:00
|
|
|
cRet[0] = amx_ftoc(g_cmd->viewangles.x);
|
|
|
|
cRet[1] = amx_ftoc(g_cmd->viewangles.y);
|
|
|
|
cRet[2] = amx_ftoc(g_cmd->viewangles.z);
|
2004-05-26 05:15:40 +00:00
|
|
|
return 1;
|
|
|
|
case usercmd_impact_position:
|
2004-06-25 22:51:18 +00:00
|
|
|
cRet[0] = amx_ftoc(g_cmd->impact_position.x);
|
|
|
|
cRet[1] = amx_ftoc(g_cmd->impact_position.y);
|
|
|
|
cRet[2] = amx_ftoc(g_cmd->impact_position.z);
|
2004-05-26 05:15:40 +00:00
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static cell AMX_NATIVE_CALL set_usercmd(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
if (!incmd)
|
|
|
|
return 0;
|
|
|
|
int type = params[1];
|
|
|
|
if (type > usercmd_int_start && type < usercmd_int_end)
|
|
|
|
{
|
|
|
|
// Setting an integer value...
|
|
|
|
cell *blah = MF_GetAmxAddr(amx,params[2]);
|
|
|
|
int iValue = blah[0];
|
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case usercmd_lerp_msec:
|
2015-10-06 22:10:48 +00:00
|
|
|
g_cmd->lerp_msec = iValue;
|
2004-05-26 05:15:40 +00:00
|
|
|
return 1;
|
|
|
|
case usercmd_msec:
|
|
|
|
g_cmd->msec = iValue;
|
|
|
|
return 1;
|
|
|
|
case usercmd_lightlevel:
|
|
|
|
g_cmd->lightlevel = iValue;
|
|
|
|
return 1;
|
|
|
|
case usercmd_buttons:
|
|
|
|
g_cmd->buttons = iValue;
|
|
|
|
return 1;
|
|
|
|
case usercmd_weaponselect:
|
|
|
|
g_cmd->weaponselect = iValue;
|
|
|
|
return 1;
|
|
|
|
case usercmd_impact_index:
|
|
|
|
g_cmd->impact_index = iValue;
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (type > usercmd_float_start && type < usercmd_float_end)
|
|
|
|
{
|
|
|
|
// Requesting a single float value
|
|
|
|
// The second parameter needs to be the float variable.
|
|
|
|
|
|
|
|
cell *blah = MF_GetAmxAddr(amx,params[2]);
|
|
|
|
REAL fValue = amx_ctof(blah[0]);
|
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case usercmd_forwardmove:
|
|
|
|
g_cmd->forwardmove = fValue;
|
|
|
|
return 1;
|
|
|
|
case usercmd_sidemove:
|
|
|
|
g_cmd->sidemove = fValue;
|
|
|
|
return 1;
|
|
|
|
case usercmd_upmove:
|
|
|
|
g_cmd->upmove = fValue;
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (type > usercmd_vec_start && type < usercmd_vec_end)
|
|
|
|
{
|
|
|
|
// Requesting a Vector value.
|
|
|
|
Vector vValue;
|
|
|
|
cell *blah = MF_GetAmxAddr(amx,params[2]);
|
|
|
|
vValue.x = amx_ctof(blah[0]);
|
|
|
|
vValue.y = amx_ctof(blah[1]);
|
|
|
|
vValue.z = amx_ctof(blah[2]);
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case usercmd_viewangles:
|
|
|
|
g_cmd->viewangles = vValue;
|
|
|
|
return 1;
|
|
|
|
case usercmd_impact_position:
|
|
|
|
g_cmd->impact_position = vValue;
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-07-15 20:28:22 +00:00
|
|
|
static cell AMX_NATIVE_CALL is_visible(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
int src = params[1];
|
2005-08-01 19:01:25 +00:00
|
|
|
int dest = params[2];
|
2005-07-15 20:28:22 +00:00
|
|
|
CHECK_ENTITY(src);
|
2005-08-01 19:01:25 +00:00
|
|
|
CHECK_ENTITY(dest);
|
2005-07-15 20:28:22 +00:00
|
|
|
|
2015-10-06 22:10:48 +00:00
|
|
|
edict_t *pEntity = TypeConversion.id_to_edict(src);
|
|
|
|
edict_t *pTarget = TypeConversion.id_to_edict(dest);
|
2005-07-15 20:28:22 +00:00
|
|
|
|
2006-04-28 19:19:24 +00:00
|
|
|
if (pTarget->v.flags & FL_NOTARGET)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
Vector vLooker = pEntity->v.origin + pEntity->v.view_ofs;
|
|
|
|
Vector vTarget = pTarget->v.origin + pTarget->v.view_ofs;
|
2005-07-15 20:28:22 +00:00
|
|
|
|
2015-10-06 22:10:48 +00:00
|
|
|
TraceResult tr;
|
2005-07-15 20:28:22 +00:00
|
|
|
|
2017-01-17 14:52:49 +00:00
|
|
|
auto oldSolid = pTarget->v.solid;
|
|
|
|
pTarget->v.solid = SOLID_NOT;
|
2005-08-01 19:01:25 +00:00
|
|
|
TRACE_LINE(vLooker, vTarget, FALSE, pEntity, &tr);
|
2017-01-17 14:52:49 +00:00
|
|
|
pTarget->v.solid = oldSolid;
|
2005-07-15 20:28:22 +00:00
|
|
|
|
2006-04-28 19:19:24 +00:00
|
|
|
if (tr.fInOpen && tr.fInWater)
|
2005-07-15 20:28:22 +00:00
|
|
|
return 0;
|
2006-04-28 19:19:24 +00:00
|
|
|
else if (tr.flFraction == 1.0)
|
2005-07-15 20:28:22 +00:00
|
|
|
return 1;
|
2015-10-06 22:10:48 +00:00
|
|
|
|
2006-04-28 19:19:24 +00:00
|
|
|
return 0;
|
2005-07-15 20:28:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//taken from dlls\combat.cpp
|
|
|
|
static cell AMX_NATIVE_CALL in_view_cone(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
int src = params[1];
|
2015-10-06 22:10:48 +00:00
|
|
|
|
2005-07-15 20:28:22 +00:00
|
|
|
CHECK_ENTITY(src);
|
|
|
|
|
2015-10-06 22:10:48 +00:00
|
|
|
edict_t *pEdictSrc = TypeConversion.id_to_edict(src);
|
2006-10-01 06:08:39 +00:00
|
|
|
|
|
|
|
Vector vecLOS, vecForward;
|
2005-07-15 20:28:22 +00:00
|
|
|
float flDot;
|
|
|
|
|
|
|
|
cell *addr = MF_GetAmxAddr(amx, params[2]);
|
2006-10-01 06:08:39 +00:00
|
|
|
Vector origin(amx_ctof(addr[0]), amx_ctof(addr[1]), amx_ctof(addr[2]));
|
2005-07-15 20:28:22 +00:00
|
|
|
|
2006-10-01 06:08:39 +00:00
|
|
|
bool use2D = (params[0] / sizeof(cell)) == 2 || params[3] == 0;
|
2005-07-15 20:28:22 +00:00
|
|
|
|
2006-10-01 06:08:39 +00:00
|
|
|
if (use2D)
|
|
|
|
{
|
|
|
|
MAKE_VECTORS(pEdictSrc->v.angles);
|
|
|
|
vecForward = gpGlobals->v_forward;
|
2005-07-15 20:28:22 +00:00
|
|
|
|
2006-10-01 06:08:39 +00:00
|
|
|
vecLOS = origin - pEdictSrc->v.origin;
|
|
|
|
|
|
|
|
vecForward.z = 0;
|
|
|
|
vecLOS.z = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MAKE_VECTORS(pEdictSrc->v.v_angle);
|
|
|
|
vecForward = gpGlobals->v_forward;
|
|
|
|
|
|
|
|
vecLOS = origin - (pEdictSrc->v.origin + pEdictSrc->v.view_ofs);
|
|
|
|
}
|
2005-07-15 20:28:22 +00:00
|
|
|
|
2006-09-22 15:11:51 +00:00
|
|
|
vecLOS = vecLOS.Normalize();
|
2005-07-15 20:28:22 +00:00
|
|
|
|
2006-10-01 06:08:39 +00:00
|
|
|
flDot = DotProduct(vecLOS, vecForward);
|
2005-07-15 20:28:22 +00:00
|
|
|
|
2007-03-11 05:19:54 +00:00
|
|
|
/* Dividing fov by two and then converting it to radians - don't ask about this ever again, please :\ */
|
2006-04-28 19:19:24 +00:00
|
|
|
if (flDot >= cos(pEdictSrc->v.fov * (M_PI / 360)))
|
2005-07-15 20:28:22 +00:00
|
|
|
return 1;
|
2006-04-28 19:19:24 +00:00
|
|
|
else
|
2005-07-15 20:28:22 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-06-25 22:51:18 +00:00
|
|
|
static cell AMX_NATIVE_CALL traceresult(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
int type = params[1];
|
|
|
|
cell *cRet;
|
|
|
|
/*
|
|
|
|
TR_AllSolid, // (int) if true, plane is not valid
|
|
|
|
TR_StartSolid, // (int) if true, the initial point was in a solid area
|
|
|
|
TR_InOpen, // (int)
|
|
|
|
TR_InWater, // (int)
|
|
|
|
TR_Fraction, // (float) time completed, 1.0 = didn't hit anything
|
|
|
|
TR_EndPos, // (vector) final position
|
|
|
|
TR_PlaneDist, // (float)
|
|
|
|
TR_PlaneNormal, // (vector) surface normal at impact
|
|
|
|
TR_Hit, // (entity) entity the surface is on
|
|
|
|
TR_Hitgroup // (int) 0 == generic, non zero is specific body part
|
|
|
|
*/
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case TR_AllSolid:
|
|
|
|
return g_tr.fAllSolid;
|
|
|
|
case TR_StartSolid:
|
|
|
|
return g_tr.fStartSolid;
|
|
|
|
case TR_InOpen:
|
|
|
|
return g_tr.fInOpen;
|
|
|
|
case TR_InWater:
|
|
|
|
return g_tr.fInWater;
|
|
|
|
case TR_Hitgroup:
|
|
|
|
return g_tr.iHitgroup;
|
|
|
|
case TR_Hit:
|
|
|
|
if (!FNullEnt(g_tr.pHit))
|
2016-02-03 16:34:51 +00:00
|
|
|
return TypeConversion.edict_to_id(g_tr.pHit);
|
2004-06-25 22:51:18 +00:00
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
case TR_Fraction:
|
|
|
|
cRet = MF_GetAmxAddr(amx,params[2]);
|
|
|
|
cRet[0] = amx_ftoc(g_tr.flFraction);
|
|
|
|
return 1;
|
|
|
|
case TR_EndPos:
|
|
|
|
cRet = MF_GetAmxAddr(amx,params[2]);
|
|
|
|
cRet[0] = amx_ftoc(g_tr.vecEndPos[0]);
|
|
|
|
cRet[1] = amx_ftoc(g_tr.vecEndPos[1]);
|
|
|
|
cRet[2] = amx_ftoc(g_tr.vecEndPos[2]);
|
|
|
|
return 1;
|
|
|
|
case TR_PlaneDist:
|
|
|
|
cRet = MF_GetAmxAddr(amx,params[2]);
|
|
|
|
cRet[0] = amx_ftoc(g_tr.flPlaneDist);
|
|
|
|
return 1;
|
|
|
|
case TR_PlaneNormal:
|
|
|
|
cRet = MF_GetAmxAddr(amx,params[2]);
|
|
|
|
cRet[0] = amx_ftoc(g_tr.vecPlaneNormal[0]);
|
|
|
|
cRet[1] = amx_ftoc(g_tr.vecPlaneNormal[1]);
|
|
|
|
cRet[2] = amx_ftoc(g_tr.vecPlaneNormal[2]);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-09-16 11:02:51 +00:00
|
|
|
// (jghg)
|
|
|
|
static cell AMX_NATIVE_CALL get_string(AMX *amx, cell *params) // (string, returnstring[], length)
|
|
|
|
{
|
2015-10-05 17:06:38 +00:00
|
|
|
ke::SafeSprintf(g_buffer, sizeof(g_buffer), "%s", STRING(params[1]));
|
2004-09-16 11:02:51 +00:00
|
|
|
return MF_SetAmxString(amx, params[2], g_buffer, params[3]);
|
|
|
|
}
|
|
|
|
|
2005-07-29 20:15:08 +00:00
|
|
|
//contributed by twistedeuphoria
|
|
|
|
static cell AMX_NATIVE_CALL trace_forward(AMX *amx, cell *params)
|
2005-07-30 01:51:12 +00:00
|
|
|
//native trace_forward(Float:start[3], Float:angles[3], give, ignoreEnt, &Float:hitX, &Float:hitY, &Float:shortestDistance, &Float:shortestDistLow, &Float:shortestDistHigh)
|
2005-07-29 20:15:08 +00:00
|
|
|
{
|
|
|
|
cell *cStart = MF_GetAmxAddr(amx, params[1]);
|
2005-07-30 01:51:12 +00:00
|
|
|
cell *cAngles = MF_GetAmxAddr(amx, params[2]);
|
2005-07-29 20:15:08 +00:00
|
|
|
REAL fGive = amx_ctof(params[3]);
|
|
|
|
int iIgnoreEnt = params[4];
|
2015-07-13 12:43:39 +00:00
|
|
|
if (iIgnoreEnt > 0) {
|
2015-05-10 23:09:45 +00:00
|
|
|
CHECK_ENTITY(iIgnoreEnt);
|
2015-06-11 14:08:46 +00:00
|
|
|
}
|
2015-05-10 23:09:45 +00:00
|
|
|
|
2005-07-29 20:15:08 +00:00
|
|
|
cell *hitX = MF_GetAmxAddr(amx, params[5]);
|
|
|
|
cell *hitY = MF_GetAmxAddr(amx, params[6]);
|
|
|
|
cell *shortestDistance = MF_GetAmxAddr(amx, params[7]);
|
|
|
|
cell *shortestDistLow = MF_GetAmxAddr(amx, params[8]);
|
|
|
|
cell *shortestDistHigh = MF_GetAmxAddr(amx, params[9]);
|
2005-07-30 01:51:12 +00:00
|
|
|
|
2005-07-29 20:15:08 +00:00
|
|
|
if(fGive < 0.0)
|
2015-10-06 22:10:48 +00:00
|
|
|
fGive = 20.0;
|
2005-07-29 20:15:08 +00:00
|
|
|
|
|
|
|
REAL fStartX = amx_ctof(cStart[0]);
|
|
|
|
REAL fStartY = amx_ctof(cStart[1]);
|
|
|
|
REAL fStartZ = amx_ctof(cStart[2]);
|
2005-07-30 01:51:12 +00:00
|
|
|
|
|
|
|
REAL fAnglesX = amx_ctof(cAngles[0]);
|
|
|
|
REAL fAnglesY = amx_ctof(cAngles[1]);
|
|
|
|
REAL fAnglesZ = amx_ctof(cAngles[2]);
|
|
|
|
Vector playerAngleVector = Vector(fAnglesX,fAnglesY,fAnglesZ);
|
|
|
|
MAKE_VECTORS(playerAngleVector);
|
|
|
|
|
|
|
|
Vector forwardVector = gpGlobals->v_forward;
|
|
|
|
REAL fEndX = forwardVector[0] * 4000;
|
|
|
|
REAL fEndY = forwardVector[1] * 4000;
|
|
|
|
|
2005-07-29 20:15:08 +00:00
|
|
|
REAL fClosestDist = 999999.9;
|
|
|
|
REAL fClosestLow = 0.0;
|
|
|
|
REAL fClosestHigh = 0.0;
|
|
|
|
REAL fClosestX = 0.0;
|
|
|
|
REAL fClosestY = 0.0;
|
|
|
|
TraceResult tr;
|
|
|
|
REAL fRetX;
|
|
|
|
REAL fRetY;
|
|
|
|
REAL fRetZ;
|
|
|
|
|
|
|
|
for(int inum=-36;inum<=36;inum++)
|
|
|
|
{
|
2015-10-06 22:10:48 +00:00
|
|
|
REAL fUseZ = fStartZ + (REAL)inum;
|
|
|
|
Vector vStart = Vector(fStartX, fStartY, fUseZ);
|
|
|
|
Vector vEnd = Vector(fEndX, fEndY, fUseZ);
|
|
|
|
if(iIgnoreEnt > 0)
|
|
|
|
TRACE_LINE(vStart, vEnd, dont_ignore_monsters, TypeConversion.id_to_edict(iIgnoreEnt), &tr);
|
2015-07-13 12:43:39 +00:00
|
|
|
else
|
|
|
|
TRACE_LINE(vStart, vEnd, ignore_monsters, NULL, &tr);
|
2015-10-06 22:10:48 +00:00
|
|
|
fRetX = tr.vecEndPos.x;
|
|
|
|
fRetY = tr.vecEndPos.y;
|
|
|
|
fRetZ = tr.vecEndPos.z;
|
|
|
|
Vector vHit = Vector(fRetX, fRetY, fRetZ);
|
|
|
|
|
|
|
|
REAL fLength = (vStart - vHit).Length();
|
|
|
|
if(fabs(fLength - fClosestDist) < fGive)
|
|
|
|
fClosestHigh = fUseZ - fStartZ;
|
|
|
|
else if(fLength < fClosestDist)
|
|
|
|
{
|
|
|
|
fClosestDist = fLength;
|
|
|
|
fClosestLow = fUseZ - fStartZ;
|
|
|
|
fClosestHigh = fUseZ - fStartZ;
|
|
|
|
fClosestX = fRetX;
|
|
|
|
fClosestY = fRetY;
|
|
|
|
}
|
2005-07-29 20:15:08 +00:00
|
|
|
}
|
|
|
|
fClosestLow += 36.0;
|
|
|
|
fClosestHigh += 36.0;
|
|
|
|
|
|
|
|
*hitX = amx_ftoc(fClosestX);
|
|
|
|
*hitY = amx_ftoc(fClosestY);
|
|
|
|
*shortestDistance = amx_ftoc(fClosestDist);
|
|
|
|
*shortestDistLow = amx_ftoc(fClosestLow);
|
|
|
|
*shortestDistHigh = amx_ftoc(fClosestHigh);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2006-09-01 03:29:27 +00:00
|
|
|
AMX_NATIVE_INFO engine_NewNatives[] =
|
|
|
|
{
|
|
|
|
{"trace_line", trace_line},
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2004-05-26 05:15:40 +00:00
|
|
|
AMX_NATIVE_INFO engine_Natives[] = {
|
|
|
|
{"halflife_time", halflife_time},
|
|
|
|
|
|
|
|
//These are mostly from original VexD
|
2004-08-11 12:17:39 +00:00
|
|
|
|
|
|
|
{"radius_damage", RadiusDamage},
|
|
|
|
{"point_contents", PointContents},
|
2004-05-26 05:15:40 +00:00
|
|
|
{"trace_normal", trace_normal},
|
|
|
|
{"trace_hull", trace_hull},
|
2004-06-25 22:51:18 +00:00
|
|
|
{"traceresult", traceresult},
|
2004-05-26 05:15:40 +00:00
|
|
|
|
|
|
|
{"set_speak", set_speak},
|
|
|
|
{"get_speak", get_speak},
|
|
|
|
|
|
|
|
{"playback_event", playback_event},
|
|
|
|
|
|
|
|
{"set_view", set_view},
|
|
|
|
{"attach_view", attach_view},
|
|
|
|
|
|
|
|
{"get_decal_index", get_decal_index},
|
|
|
|
{"get_info_keybuffer", get_info_keybuffer},
|
|
|
|
{"set_lights", set_lights},
|
|
|
|
{"drop_to_floor", drop_to_floor},
|
|
|
|
|
|
|
|
{"get_usercmd", get_usercmd},
|
|
|
|
{"set_usercmd", set_usercmd},
|
|
|
|
|
2004-06-25 22:51:18 +00:00
|
|
|
{"register_impulse", register_impulse},
|
|
|
|
{"register_think", register_think},
|
|
|
|
{"register_touch", register_touch},
|
2015-05-10 21:40:22 +00:00
|
|
|
{"unregister_impulse", unregister_impulse},
|
|
|
|
{"unregister_think", unregister_think},
|
|
|
|
{"unregister_touch", unregister_touch},
|
2004-06-25 22:51:18 +00:00
|
|
|
|
2005-08-01 05:15:57 +00:00
|
|
|
{"eng_get_string", get_string},
|
2005-08-30 23:22:27 +00:00
|
|
|
{"is_in_viewcone", in_view_cone},
|
2005-07-15 20:28:22 +00:00
|
|
|
{"is_visible", is_visible},
|
2005-07-29 20:15:08 +00:00
|
|
|
{"trace_forward", trace_forward},
|
2004-09-16 11:02:51 +00:00
|
|
|
|
2006-09-01 03:29:27 +00:00
|
|
|
{NULL, NULL}
|
2004-05-26 05:15:40 +00:00
|
|
|
///////////////////
|
2004-05-26 06:19:50 +00:00
|
|
|
};
|