|
sıɹɹoɥɔ ʞɔnu
|
07-29-2012
, 16:00
Re: [TUT] Modules and efficient scripting
|
#117
|
Ok, thank you for reply. Also if anybody still have minor confusion can see the natives source.
Spoiler
Engine:
Code:
int is_ent_valid(int iEnt)
{
if (iEnt < 1 || iEnt > gpGlobals->maxEntities)
return 0;
if (iEnt <= gpGlobals->maxClients)
{
if (!MF_IsPlayerIngame(iEnt))
{
return 0;
}
} else {
if (FNullEnt(INDEXENT(iEnt)))
{
return 0;
}
}
return 1;
}
static cell AMX_NATIVE_CALL is_valid_ent(AMX *amx, cell *params)
{
return is_ent_valid(params[1]);
}
Code:
static cell AMX_NATIVE_CALL entity_set_origin(AMX *amx, cell *params)
{
int iEnt = params[1];
CHECK_ENTITY_SIMPLE(iEnt);
edict_t *pEnt = INDEXENT2(iEnt);
cell *vVector = MF_GetAmxAddr(amx, params[2]);
REAL fX = amx_ctof(vVector[0]);
REAL fY = amx_ctof(vVector[1]);
REAL fZ = amx_ctof(vVector[2]);
Vector vOrigin = Vector(fX, fY, fZ);
SET_SIZE(pEnt, pEnt->v.mins, pEnt->v.maxs);
SET_ORIGIN(pEnt, vOrigin);
return 1;
}
Spoiler
Fakemeta:
Code:
// pev_valid
static cell AMX_NATIVE_CALL amx_pev_valid(AMX *amx, cell *params)
{
int idx = static_cast<int>(params[1]);
edict_t *e = INDEXENT(idx);
if (FNullEnt(e))
return 0;
if (e->pvPrivateData)
return 2;
return 1;
}
Code:
#define CHECK_ENTITY(x) if (x != 0 && (FNullEnt(INDEXENT_NEW(x)) || x < 0 || x > gpGlobals->maxEntities)) return 0;
Code:
static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
{
.... some code ....
// pfnSetOrigin
case EngFunc_SetOrigin: // void ) (edict_t *e, const float *rgflOrigin);
cRet = MF_GetAmxAddr(amx,params[2]);
index = cRet[0];
CHECK_ENTITY(index);
cRet = MF_GetAmxAddr(amx,params[3]);
Vec1[0]=amx_ctof(cRet[0]);
Vec1[1]=amx_ctof(cRet[1]);
Vec1[2]=amx_ctof(cRet[2]);
(*g_engfuncs.pfnSetOrigin)(INDEXENT2(index),Vec1);
return 1;
}
|
|
|
|