static cell AMX_NATIVE_CALL set_pdata_ehandle(AMX *amx, cell *params) { int index = params[1]; CHECK_ENTITY(index); int offset = params[2]; CHECK_OFFSET(offset); int entity = params[3]; CHECK_ENTITY(entity); #if defined(__linux__) offset += params[4]; #elif defined(__APPLE__) // Use Linux offset in older plugins if (params[0] / sizeof(cell) == 4) offset += params[4]; else offset += params[5]; #endif edict_t *pEntity = TypeConversion.id_to_edict(entity); set_pdata<edict_t*>(TypeConversion.id_to_edict(index), offset, pEntity); if (pEntity) { set_pdata<int>(TypeConversion.id_to_edict(index), offset + 4, pEntity->serialnumber); } return 1; }
static cell AMX_NATIVE_CALL is_visible(AMX *amx, cell *params) { int src = params[1]; int dest = params[2]; CHECK_ENTITY(src); CHECK_ENTITY(dest); edict_t *pEntity = INDEXENT2(src); edict_t *pTarget = INDEXENT2(dest); 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; TraceResult tr; TRACE_LINE(vLooker, vTarget, FALSE, pEntity, &tr); if (tr.fInOpen && tr.fInWater) return 0; else if (tr.flFraction == 1.0) return 1; return 0; }
cell Call_Void_Vector_Entvar_Entvar_Float_Int_Int(AMX *amx, cell *params) { SETUP(6); Vector v3; float *fl3=(float *)MF_GetAmxAddr(amx, params[3]); v3.x=fl3[0]; v3.y=fl3[1]; v3.z=fl3[2]; int id4=*MF_GetAmxAddr(amx, params[4]); int id5=*MF_GetAmxAddr(amx, params[5]); float f6=amx_ctof2(*MF_GetAmxAddr(amx, params[6])); int i7=*MF_GetAmxAddr(amx, params[7]); int i8=*MF_GetAmxAddr(amx, params[8]); CHECK_ENTITY(id4); CHECK_ENTITY(id5); entvars_t *ev4=&(INDEXENT_NEW(id4)->v); entvars_t *ev5=&(INDEXENT_NEW(id5)->v); #if defined(_WIN32) reinterpret_cast<void (__fastcall *)(void *, int, Vector, entvars_t *, entvars_t *, float, int, int)>(__func)(pv, 0, v3, ev4, ev5, f6, i7, i8); #elif defined(__linux__) || defined(__APPLE__) reinterpret_cast<void (*)(void *, Vector, entvars_t *, entvars_t *, float, int, int)>(__func)(pv, v3, ev4, ev5, f6, i7, i8); #endif return 1; }
static cell AMX_NATIVE_CALL entity_range(AMX *amx, cell *params) { int idxa = params[1]; int idxb = params[2]; CHECK_ENTITY(idxa); CHECK_ENTITY(idxb); edict_t *pEntA = INDEXENT2(idxa); edict_t *pEntB = INDEXENT2(idxb); REAL fRet = (pEntA->v.origin - pEntB->v.origin).Length(); return amx_ftoc(fRet); }
static cell AMX_NATIVE_CALL fake_touch(AMX *amx, cell *params) { int iPtr = params[1]; int iPtd = params[2]; CHECK_ENTITY(iPtr); CHECK_ENTITY(iPtd); edict_t *pToucher = INDEXENT2(iPtr); edict_t *pTouched = INDEXENT2(iPtd); MDLL_Touch(pToucher, pTouched); return 1; }
static cell AMX_NATIVE_CALL force_use(AMX *amx, cell *params) { int iPtr = params[1]; int iPtd = params[2]; CHECK_ENTITY(iPtr); CHECK_ENTITY(iPtd); edict_t *pUser = INDEXENT2(iPtr); edict_t *pUsed = INDEXENT2(iPtd); MDLL_Use(pUsed, pUser); return 1; }
// GetModelCollisionBox( index, Float:mins[3], Float:maxs[3] ); static cell AMX_NATIVE_CALL GetModelCollisionBox(AMX *amx, cell *params) { int entityIndex = params[1]; CHECK_ENTITY(entityIndex); edict_t *pEdict = INDEXENT2(entityIndex); if (!FNullEnt(pEdict)) { studiohdr_t *pStudiohdr = static_cast<studiohdr_t*>(GET_MODEL_PTR(pEdict)); if (!pStudiohdr) { MF_LogError(amx, AMX_ERR_NATIVE, "Could not find the model pointer for the entity."); return 0; } cell *cmins = MF_GetAmxAddr(amx, params[2]); cell *cmaxs = MF_GetAmxAddr(amx, params[3]); cmins[0] = amx_ftoc(pStudiohdr->bbmin.x); cmins[1] = amx_ftoc(pStudiohdr->bbmin.y); cmins[2] = amx_ftoc(pStudiohdr->bbmin.z); cmaxs[0] = amx_ftoc(pStudiohdr->bbmax.x); cmaxs[1] = amx_ftoc(pStudiohdr->bbmax.y); cmaxs[2] = amx_ftoc(pStudiohdr->bbmax.z); return 1; } return 0; };
cell Call_Int_Vector_Cbase(AMX *amx, cell *params) { SETUP(2); Vector v3; float *fl3=(float *)MF_GetAmxAddr(amx, params[3]); v3.x=fl3[0]; v3.y=fl3[1]; v3.z=fl3[2]; int id4=*MF_GetAmxAddr(amx, params[4]); CHECK_ENTITY(id4); void *p4=IndexToPrivate(id4); #if defined(_WIN32) int ret=reinterpret_cast<int (__fastcall *)(void *, int, Vector, void*)>(__func)(pv, 0, v3, p4); #elif defined(__linux__) || defined(__APPLE__) int ret=reinterpret_cast<int (*)(void *, Vector, void*)>(__func)(pv, v3, p4); #endif fl3[0]=v3.x; fl3[1]=v3.y; fl3[2]=v3.z; return ret; }
static cell AMX_NATIVE_CALL set_pdata_vector(AMX *amx, cell *params) { int index = params[1]; CHECK_ENTITY(index); int offset = params[2]; CHECK_OFFSET(offset); #if defined(__linux__) offset += params[4]; #elif defined(__APPLE__) // Use Linux offset in older plugins if (params[0] / sizeof(cell) == 4) offset += params[4]; else offset += params[5]; #endif cell *pcvec = MF_GetAmxAddr(amx, params[3]); Vector vec(amx_ctof(pcvec[0]), amx_ctof(pcvec[1]), amx_ctof(pcvec[2])); set_pdata<Vector>(TypeConversion.id_to_edict(index), offset, vec); return 1; }
cell Call_Int_Cbase_pVector(AMX *amx, cell *params) { SETUP(2); int id3=*MF_GetAmxAddr(amx, params[3]); CHECK_ENTITY(id3); void *pv1=(INDEXENT_NEW(id3)->pvPrivateData); Vector v4; float *fl4=(float *)MF_GetAmxAddr(amx, params[4]); v4.x=fl4[0]; v4.y=fl4[1]; v4.z=fl4[2]; #if defined(_WIN32) int ret = reinterpret_cast<int (__fastcall *)(void*, int, void *, Vector *)>(__func)(pv, 0, pv1, &v4); #elif defined(__linux__) || defined(__APPLE__) int ret = reinterpret_cast<int (*)(void *, void *, Vector *)>(__func)(pv, pv1, &v4); #endif fl4[0]=v4.x; fl4[1]=v4.y; fl4[2]=v4.z; return ret; }
cell Call_Vector_Float_Cbase_Int(AMX *amx, cell *params) { SETUP(4); float f3=amx_ctof2(*MF_GetAmxAddr(amx, params[3])); int id4=*MF_GetAmxAddr(amx, params[4]); int i5=*MF_GetAmxAddr(amx, params[5]); CHECK_ENTITY(id4); void *p4=IndexToPrivate(id4); #if defined(_WIN32) Vector ret; reinterpret_cast<void(__fastcall *)(void *, int, Vector*, float, void *, int)>(__func)(pv, 0, &ret, f3, p4, i5); #elif defined(__linux__) || defined(__APPLE__) Vector ret = reinterpret_cast<Vector(*)(void *, float, void *, int)>(__func)(pv, f3, p4, i5); #endif float *out = (float *)MF_GetAmxAddr(amx, params[6]); out[0] = ret.x; out[1] = ret.y; out[2] = ret.z; return 1; }
cell Call_Void_Entvar_Float_Vector_Trace_Int(AMX *amx, cell *params) { SETUP(5); int id3=*MF_GetAmxAddr(amx, params[3]); float f4=amx_ctof2(*MF_GetAmxAddr(amx, params[4])); Vector v5; TraceResult *tr6=reinterpret_cast<TraceResult *>(*MF_GetAmxAddr(amx, params[6])); int i7=*MF_GetAmxAddr(amx, params[7]); float *fl5=(float *)MF_GetAmxAddr(amx, params[5]); v5.x=fl5[0]; v5.y=fl5[1]; v5.z=fl5[2]; if (tr6==NULL) { MF_LogError(amx, AMX_ERR_NATIVE, "Null traceresult provided."); return 0; } CHECK_ENTITY(id3); entvars_t *ev3=&(INDEXENT_NEW(id3)->v); #if defined(_WIN32) reinterpret_cast<void (__fastcall *)(void *, int, entvars_t *, float, Vector, TraceResult *, int)>(__func)(pv, 0, ev3, f4, v5, tr6, i7); #elif defined(__linux__) || defined(__APPLE__) reinterpret_cast<void (*)(void *, entvars_t *, float, Vector, TraceResult *, int)>(__func)(pv, ev3, f4, v5, tr6, i7); #endif return 1; }
// SetModelCollisionBox( index ); static cell AMX_NATIVE_CALL SetModelCollisionBox(AMX *amx, cell *params) { int entityIndex = params[1]; CHECK_ENTITY(entityIndex); edict_t *pentModel = INDEXENT2(entityIndex); if (!FNullEnt(pentModel)) { studiohdr_t *pStudiohdr = static_cast<studiohdr_t*>(GET_MODEL_PTR(pentModel)); if (!pStudiohdr) { MF_LogError(amx, AMX_ERR_NATIVE, "Could not find the model pointer for the entity."); return 0; } SET_SIZE(pentModel, pStudiohdr->bbmin, pStudiohdr->bbmax); return 1; } return 0; };
cell Call_Void_Cbase_pVector_Float(AMX *amx, cell *params) { SETUP(3); int id3=*MF_GetAmxAddr(amx, params[3]); CHECK_ENTITY(id3); void *i3=IndexToPrivate(id3); Vector v4; float *fl4=(float *)MF_GetAmxAddr(amx, params[4]); v4.x=fl4[0]; v4.y=fl4[1]; v4.z=fl4[2]; float f5=amx_ctof2(*MF_GetAmxAddr(amx, params[5])); #if defined(_WIN32) reinterpret_cast<void (__fastcall *)(void*, int, void *, Vector *, float)>(__func)(pv, 0, i3, &v4, f5); #elif defined(__linux__) || defined(__APPLE__) reinterpret_cast<void (*)(void *, void *, Vector *, float)>(__func)(pv, i3, &v4, f5); #endif fl4[0]=v4.x; fl4[1]=v4.y; fl4[2]=v4.z; return 1; }
static cell AMX_NATIVE_CALL get_keyvalue(AMX *amx, cell *params) { int idx = params[1]; CHECK_ENTITY(idx); edict_t *pEntity = INDEXENT2(idx); int iLength=0; char *char1 = MF_GetAmxString(amx, params[2], 1, &iLength); return MF_SetAmxString(amx, params[3], INFO_KEY_VALUE(INFO_KEY_BUFFER(pEntity),char1), params[4]); }
//from jghg, who says it doesn't work // it works, it's just a picky engine call -sawce static cell AMX_NATIVE_CALL drop_to_floor(AMX *amx, cell *params) { int iEnt = params[1]; CHECK_ENTITY(iEnt); edict_t *e = INDEXENT2(iEnt); return DROP_TO_FLOOR(e); }
// GetModelBoundingBox( index, Float:mins[3], Float:maxs[3], sequence = Model_DefaultSize ); static cell AMX_NATIVE_CALL GetModelBoundingBox(AMX *amx, cell *params) { int entityIndex = params[1]; CHECK_ENTITY(entityIndex); edict_t *pentModel = INDEXENT2(entityIndex); if (!FNullEnt(pentModel)) { studiohdr_t *pStudiohdr = static_cast<studiohdr_t*>(GET_MODEL_PTR(pentModel)); if (!pStudiohdr) { MF_LogError(amx, AMX_ERR_NATIVE, "Could not find the model pointer for the entity."); return 0; } cell *bbmins = MF_GetAmxAddr(amx, params[2]); cell *bbmaxs = MF_GetAmxAddr(amx, params[3]); int sequence = params[4]; if (sequence <= Model_DefaultSize) { bbmins[0] = amx_ftoc(pStudiohdr->min.x); bbmins[1] = amx_ftoc(pStudiohdr->min.y); bbmins[2] = amx_ftoc(pStudiohdr->min.z); bbmaxs[0] = amx_ftoc(pStudiohdr->max.x); bbmaxs[1] = amx_ftoc(pStudiohdr->max.y); bbmaxs[2] = amx_ftoc(pStudiohdr->max.z); } else { if (sequence <= Model_CurrentSequence || sequence >= pStudiohdr->numseq) sequence = pentModel->v.sequence; mstudioseqdesc_t *pSeqdesc; pSeqdesc = (mstudioseqdesc_t*)((byte*)pStudiohdr + pStudiohdr->seqindex); bbmins[0] = amx_ftoc(pSeqdesc[sequence].bbmin.x); bbmins[1] = amx_ftoc(pSeqdesc[sequence].bbmin.y); bbmins[2] = amx_ftoc(pSeqdesc[sequence].bbmin.z); bbmaxs[0] = amx_ftoc(pSeqdesc[sequence].bbmax.x); bbmaxs[1] = amx_ftoc(pSeqdesc[sequence].bbmax.y); bbmaxs[2] = amx_ftoc(pSeqdesc[sequence].bbmax.z); } return 1; } return 0; };
// 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]; CHECK_ENTITY(iIndex); SET_VIEW(INDEXENT2(iIndex), INDEXENT2(iTargetIndex)); return 1; }
static cell AMX_NATIVE_CALL call_think(AMX *amx, cell *params) { int iEnt = params[1]; CHECK_ENTITY(iEnt); edict_t *pEnt = INDEXENT2(iEnt); MDLL_Think(pEnt); return 1; }
cell Call_Int_Entvar_Entvar_Float_Int(AMX *amx, cell *params) { SETUP(4); int id3=*MF_GetAmxAddr(amx, params[3]); int id4=*MF_GetAmxAddr(amx, params[4]); float f5=amx_ctof2(*MF_GetAmxAddr(amx, params[5])); int i6=*MF_GetAmxAddr(amx, params[6]); CHECK_ENTITY(id3); CHECK_ENTITY(id4); entvars_t *ev3=&(INDEXENT_NEW(id3)->v); entvars_t *ev4=&(INDEXENT_NEW(id4)->v); #if defined(_WIN32) return reinterpret_cast<int (__fastcall *)(void *, int, entvars_t *, entvars_t *, float, int)>(__func)(pv, 0, ev3, ev4, f5, i6); #elif defined(__linux__) || defined(__APPLE__) return reinterpret_cast<int (*)(void *, entvars_t *, entvars_t *, float, int)>(__func)(pv, ev3, ev4, f5, i6); #endif }
cell Call_Void_Entvar_Entvar_Int(AMX *amx, cell *params) { SETUP(3); int id3=*MF_GetAmxAddr(amx, params[3]); int id4=*MF_GetAmxAddr(amx, params[4]); int i5=*MF_GetAmxAddr(amx, params[5]); CHECK_ENTITY(id3); CHECK_ENTITY(id4); entvars_t *ev3=&(INDEXENT_NEW(id3)->v); entvars_t *ev4=&(INDEXENT_NEW(id4)->v); #if defined(_WIN32) reinterpret_cast<void (__fastcall *)(void*, int, entvars_t *, entvars_t *, int)>(__func)(pv, 0, ev3, ev4, i5); #elif defined(__linux__) || defined(__APPLE__) reinterpret_cast<void (*)(void *, entvars_t *, entvars_t *, int)>(__func)(pv, ev3, ev4, i5); #endif return 1; }
static cell AMX_NATIVE_CALL get_info_keybuffer(AMX *amx, cell *params) { int iEnt = params[1]; CHECK_ENTITY(iEnt); edict_t *e = INDEXENT2(iEnt); char *info = GETINFOKEYBUFFER(e); return MF_SetAmxString(amx, params[2], info, params[3]); }
static cell AMX_NATIVE_CALL DispatchSpawn(AMX *amx, cell *params) { int iEnt = params[1]; CHECK_ENTITY(iEnt); edict_t *pEnt = INDEXENT2(iEnt); MDLL_Spawn(pEnt); return 1; }
static cell AMX_NATIVE_CALL spawn(AMX *amx, cell *params) // spawn(id) = 1 param { // Spawns an entity, this can be a user/player -> spawns at spawnpoints, or created entities seems to need this as a final "kick" into the game? :-) // params[1] = entity to spawn CHECK_ENTITY(params[1]); edict_t *pEnt = GETEDICT(params[1]); MDLL_Spawn(pEnt); return 1; }
cell Call_Int_Entvar_Entvar_Float_Float_Int(AMX *amx, cell *params) { SETUP(5); int id3=*MF_GetAmxAddr(amx, params[3]); int id4=*MF_GetAmxAddr(amx, params[4]); float f5=amx_ctof(*MF_GetAmxAddr(amx, params[5])); float f6=amx_ctof(*MF_GetAmxAddr(amx, params[6])); int i7=*MF_GetAmxAddr(amx, params[7]); CHECK_ENTITY(id3); CHECK_ENTITY(id4); entvars_t *ev3 = TypeConversion.id_to_entvars(id3); entvars_t *ev4 = TypeConversion.id_to_entvars(id4); #if defined(_WIN32) return reinterpret_cast<int (__fastcall *)(void *, int, entvars_t *, entvars_t *, float, float, int)>(__func)(pv, 0, ev3, ev4, f5, f6, i7); #elif defined(__linux__) || defined(__APPLE__) return reinterpret_cast<int (*)(void *, entvars_t *, entvars_t *, float, float, int)>(__func)(pv, ev3, ev4, f5, f6, i7); #endif }
cell Call_Int_pVector_pVector_Float_Cbase_pVector(AMX *amx, cell *params) { SETUP(5); Vector v3; Vector v4; float *fl3=(float *)MF_GetAmxAddr(amx, params[3]); float *fl4=(float *)MF_GetAmxAddr(amx, params[4]); v3.x=fl3[0]; v3.y=fl3[1]; v3.z=fl3[2]; v4.x=fl4[0]; v4.y=fl4[1]; v4.z=fl4[2]; float f5=amx_ctof2(*MF_GetAmxAddr(amx, params[5])); int id6=*MF_GetAmxAddr(amx, params[6]); CHECK_ENTITY(id6); void *p6=IndexToPrivate(id6); Vector v7; float *fl7=(float *)MF_GetAmxAddr(amx, params[7]); v7.x=fl7[0]; v7.y=fl7[1]; v7.z=fl7[2]; #if defined(_WIN32) int ret=reinterpret_cast<int (__fastcall *)(void *, int, Vector*, Vector*, float, void*, Vector*)>(__func)(pv, 0, &v3, &v4, f5, p6, &v7); #elif defined(__linux__) || defined(__APPLE__) int ret=reinterpret_cast<int (*)(void *, Vector*, Vector*, float, void*, Vector*)>(__func)(pv, &v3, &v4, f5, p6, &v7); #endif fl3[0]=v3.x; fl3[1]=v3.y; fl3[2]=v3.z; fl4[0]=v4.x; fl4[1]=v4.y; fl4[2]=v4.z; fl7[0]=v7.x; fl7[1]=v7.y; fl7[2]=v7.z; return ret; }
cell Call_Bool_Cbase(AMX *amx, cell *params) { SETUP(1); int id3=*MF_GetAmxAddr(amx, params[3]); CHECK_ENTITY(id3); void *pv1 = TypeConversion.id_to_cbase(id3); #if defined(_WIN32) return reinterpret_cast<bool (__fastcall *)(void*, int, void*)>(__func)(pv, 0, pv1); #elif defined(__linux__) || defined(__APPLE__) return reinterpret_cast<bool (*)(void *, void*)>(__func)(pv, pv1); #endif }
cell Call_Void_Cbase_Cbase_Int_Float(AMX *amx, cell *params) { SETUP(4); int id3=*MF_GetAmxAddr(amx, params[3]); int id4=*MF_GetAmxAddr(amx, params[4]); int i5=*MF_GetAmxAddr(amx, params[5]); float f6=amx_ctof2(*MF_GetAmxAddr(amx, params[6])); CHECK_ENTITY(id3); CHECK_ENTITY(id4); void *p3=IndexToPrivate(id3); void *p4=IndexToPrivate(id4); #if defined(_WIN32) reinterpret_cast<void (__fastcall *)(void *, int, void *, void *, int, float)>(__func)(pv, 0, p3, p4, i5, f6); #elif defined(__linux__) || defined(__APPLE__) reinterpret_cast<void (*)(void *, void *, void *, int, float)>(__func)(pv, p3, p4, i5, f6); #endif return 1; }
cell Call_Bool_Cbase(AMX *amx, cell *params) { SETUP(1); int id3=*MF_GetAmxAddr(amx, params[3]); CHECK_ENTITY(id3); void *pv1=(INDEXENT_NEW(id3)->pvPrivateData); #if defined(_WIN32) return reinterpret_cast<bool (__fastcall *)(void*, int, void*)>(__func)(pv, 0, pv1); #elif defined(__linux__) || defined(__APPLE__) return reinterpret_cast<bool (*)(void *, void*)>(__func)(pv, pv1); #endif }
cell Call_Int_Entvar(AMX *amx, cell *params) { SETUP(1); int id3=*MF_GetAmxAddr(amx, params[3]); CHECK_ENTITY(id3); entvars_t *ev3=&(INDEXENT_NEW(id3)->v); #if defined(_WIN32) return reinterpret_cast<int (__fastcall *)(void *, int, entvars_t *)>(__func)(pv, 0, ev3); #elif defined(__linux__) || defined(__APPLE__) return reinterpret_cast<int (*)(void *, entvars_t *)>(__func)(pv, ev3); #endif }