2014-08-04 10:10:06 +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
|
|
|
|
|
|
|
|
//
|
|
|
|
// Fakemeta Module
|
|
|
|
//
|
|
|
|
|
2004-09-14 06:16:52 +00:00
|
|
|
#include "fakemeta_amxx.h"
|
|
|
|
|
2004-09-15 18:40:18 +00:00
|
|
|
TraceResult *gfm_tr;
|
2005-03-25 09:30:45 +00:00
|
|
|
KeyValueData *g_fm_keyValueData;
|
2004-09-14 06:16:52 +00:00
|
|
|
|
|
|
|
static cell AMX_NATIVE_CALL set_tr(AMX *amx, cell *params)
|
|
|
|
{
|
2004-09-15 18:40:18 +00:00
|
|
|
int type = params[1];
|
2004-09-14 06:16:52 +00:00
|
|
|
|
2004-09-15 18:40:18 +00:00
|
|
|
if (*params / sizeof(cell) < 2)
|
2006-05-10 11:19:24 +00:00
|
|
|
{
|
|
|
|
MF_LogError(amx, AMX_ERR_NATIVE, "No data passed");
|
|
|
|
return 0;
|
|
|
|
}
|
2015-10-06 21:53:01 +00:00
|
|
|
|
2004-09-15 18:40:18 +00:00
|
|
|
cell *ptr = MF_GetAmxAddr(amx, params[2]);
|
2004-09-14 06:16:52 +00:00
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case TR_AllSolid:
|
|
|
|
{
|
2004-09-15 18:40:18 +00:00
|
|
|
gfm_tr->fAllSolid = *ptr;
|
2004-09-14 06:16:52 +00:00
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TR_StartSolid:
|
|
|
|
{
|
2005-03-25 09:30:45 +00:00
|
|
|
gfm_tr->fStartSolid = *ptr;
|
|
|
|
return 1;
|
2004-09-14 06:16:52 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-01-17 14:52:09 +00:00
|
|
|
case TR_InOpen:
|
|
|
|
{
|
|
|
|
gfm_tr->fInOpen = *ptr;
|
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
}
|
2004-09-14 06:16:52 +00:00
|
|
|
case TR_InWater:
|
|
|
|
{
|
2004-09-15 18:40:18 +00:00
|
|
|
gfm_tr->fInWater = *ptr;
|
2004-09-14 06:16:52 +00:00
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TR_flFraction:
|
|
|
|
{
|
2004-09-15 18:40:18 +00:00
|
|
|
gfm_tr->flFraction = amx_ctof(*ptr);
|
2004-09-14 06:16:52 +00:00
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TR_vecEndPos:
|
|
|
|
{
|
2004-09-15 18:40:18 +00:00
|
|
|
gfm_tr->vecEndPos.x = amx_ctof(ptr[0]);
|
|
|
|
gfm_tr->vecEndPos.y = amx_ctof(ptr[1]);
|
|
|
|
gfm_tr->vecEndPos.z = amx_ctof(ptr[2]);
|
2004-09-14 06:16:52 +00:00
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TR_flPlaneDist:
|
|
|
|
{
|
2004-09-15 18:40:18 +00:00
|
|
|
gfm_tr->flPlaneDist = amx_ctof(*ptr);
|
2004-09-14 06:16:52 +00:00
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TR_vecPlaneNormal:
|
|
|
|
{
|
2004-09-15 18:40:18 +00:00
|
|
|
gfm_tr->vecPlaneNormal.x = amx_ctof(ptr[0]);
|
|
|
|
gfm_tr->vecPlaneNormal.y = amx_ctof(ptr[1]);
|
|
|
|
gfm_tr->vecPlaneNormal.z = amx_ctof(ptr[2]);
|
2004-09-14 06:16:52 +00:00
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TR_pHit:
|
|
|
|
{
|
2018-09-28 14:39:03 +00:00
|
|
|
const auto pEdict = TypeConversion.id_to_edict(*ptr);
|
|
|
|
if (pEdict == nullptr)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
gfm_tr->pHit = pEdict;
|
2004-09-14 06:16:52 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
case TR_iHitgroup:
|
|
|
|
{
|
2004-09-15 18:40:18 +00:00
|
|
|
gfm_tr->iHitgroup = *ptr;
|
2004-09-14 06:16:52 +00:00
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
2006-05-10 11:19:24 +00:00
|
|
|
MF_LogError(amx, AMX_ERR_NATIVE, "Unknown TraceResult member %d", params[2]);
|
2004-09-14 06:16:52 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static cell AMX_NATIVE_CALL get_tr(AMX *amx, cell *params)
|
|
|
|
{
|
2004-09-15 18:40:18 +00:00
|
|
|
int type = params[1];
|
2004-09-14 06:16:52 +00:00
|
|
|
cell *ptr = 0;
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case TR_AllSolid:
|
|
|
|
{
|
2004-09-15 18:40:18 +00:00
|
|
|
return gfm_tr->fAllSolid;
|
2004-09-14 06:16:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TR_StartSolid:
|
|
|
|
{
|
2004-09-15 18:40:18 +00:00
|
|
|
return gfm_tr->fStartSolid;
|
2004-09-14 06:16:52 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-01-17 14:52:09 +00:00
|
|
|
case TR_InOpen:
|
|
|
|
{
|
|
|
|
return gfm_tr->fInOpen;
|
|
|
|
break;
|
|
|
|
}
|
2004-09-14 06:16:52 +00:00
|
|
|
case TR_InWater:
|
|
|
|
{
|
2004-09-15 18:40:18 +00:00
|
|
|
return gfm_tr->fInWater;
|
2004-09-14 06:16:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TR_flFraction:
|
|
|
|
{
|
2004-09-15 18:40:18 +00:00
|
|
|
ptr = MF_GetAmxAddr(amx, params[2]);
|
|
|
|
*ptr = amx_ftoc(gfm_tr->flFraction);
|
2004-09-14 06:16:52 +00:00
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TR_vecEndPos:
|
|
|
|
{
|
2004-09-15 18:40:18 +00:00
|
|
|
ptr = MF_GetAmxAddr(amx, params[2]);
|
|
|
|
ptr[0] = amx_ftoc(gfm_tr->vecEndPos.x);
|
|
|
|
ptr[1] = amx_ftoc(gfm_tr->vecEndPos.y);
|
|
|
|
ptr[2] = amx_ftoc(gfm_tr->vecEndPos.z);
|
2004-09-14 06:16:52 +00:00
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TR_flPlaneDist:
|
|
|
|
{
|
2004-09-15 18:40:18 +00:00
|
|
|
ptr = MF_GetAmxAddr(amx, params[2]);
|
|
|
|
*ptr = amx_ftoc(gfm_tr->flPlaneDist);
|
2004-09-14 06:16:52 +00:00
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TR_vecPlaneNormal:
|
|
|
|
{
|
2004-09-15 18:40:18 +00:00
|
|
|
ptr = MF_GetAmxAddr(amx, params[2]);
|
|
|
|
ptr[0] = amx_ftoc(gfm_tr->vecPlaneNormal.x);
|
|
|
|
ptr[1] = amx_ftoc(gfm_tr->vecPlaneNormal.y);
|
|
|
|
ptr[2] = amx_ftoc(gfm_tr->vecPlaneNormal.z);
|
2004-09-14 06:16:52 +00:00
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TR_pHit:
|
|
|
|
{
|
2018-08-26 15:18:39 +00:00
|
|
|
if (FNullEnt(gfm_tr->pHit))
|
2004-09-15 18:55:30 +00:00
|
|
|
return -1;
|
2004-09-15 18:40:18 +00:00
|
|
|
return ENTINDEX(gfm_tr->pHit);
|
2004-09-14 06:16:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TR_iHitgroup:
|
|
|
|
{
|
2004-09-15 18:40:18 +00:00
|
|
|
return gfm_tr->iHitgroup;
|
2004-09-14 06:16:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
2006-05-10 11:19:24 +00:00
|
|
|
MF_LogError(amx, AMX_ERR_NATIVE, "Unknown TraceResult member %d", params[2]);
|
2004-09-14 06:16:52 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-20 18:08:51 +00:00
|
|
|
AMX_NATIVE_INFO tr_Natives[] =
|
2005-03-25 09:30:45 +00:00
|
|
|
{
|
2004-09-14 06:16:52 +00:00
|
|
|
{"get_tr", get_tr},
|
|
|
|
{"set_tr", set_tr},
|
|
|
|
{NULL, NULL},
|
2005-08-25 09:09:35 +00:00
|
|
|
};
|
|
|
|
|
2006-03-20 18:08:51 +00:00
|
|
|
|
|
|
|
|