mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 06:15:37 +03:00
added traceresult stuff
This commit is contained in:
parent
3d9bf8bc93
commit
f171842cf8
@ -123,6 +123,12 @@
|
||||
<File
|
||||
RelativePath=".\fakemeta_amxx.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fm_tr.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fm_tr.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\pdata.cpp">
|
||||
</File>
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "dllfunc.h"
|
||||
#include "pev.h"
|
||||
#include "forward.h"
|
||||
#include "fm_tr.h"
|
||||
|
||||
extern edict_t *g_player_edicts[33];
|
||||
|
||||
@ -25,6 +26,7 @@ extern AMX_NATIVE_INFO dllfunc_natives[];
|
||||
extern AMX_NATIVE_INFO pev_natives[];
|
||||
extern AMX_NATIVE_INFO forward_natives[];
|
||||
extern AMX_NATIVE_INFO pdata_natives[];
|
||||
extern AMX_NATIVE_INFO tr_Natives[];
|
||||
extern TraceResult g_tr;
|
||||
|
||||
/* Wouldnt modifying the table AFTER it's memcpy'd be ... pointless?
|
||||
|
177
dlls/fakemeta/fm_tr.cpp
Executable file
177
dlls/fakemeta/fm_tr.cpp
Executable file
@ -0,0 +1,177 @@
|
||||
#include "fakemeta_amxx.h"
|
||||
|
||||
/*enum
|
||||
{
|
||||
TR_AllSolid,
|
||||
TR_StartSolid,
|
||||
TR_InOpen,
|
||||
TR_InWater,
|
||||
TR_flFraction,
|
||||
TR_vecEndPos,
|
||||
TR_flPlaneDist,
|
||||
TR_vecPlaneNormal,
|
||||
TR_pHit,
|
||||
TR_iHitgroup,
|
||||
};*/
|
||||
|
||||
static cell AMX_NATIVE_CALL set_tr(AMX *amx, cell *params)
|
||||
{
|
||||
cell *cPtr = ¶ms[1];
|
||||
int type = params[2];
|
||||
TraceResult *tr = (TraceResult*)((void *)cPtr);
|
||||
|
||||
if (*params / sizeof(cell) < 3)
|
||||
return 0; //TODO: Error
|
||||
|
||||
cell *ptr = MF_GetAmxAddr(amx, params[3]);
|
||||
edict_t *e = 0;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case TR_AllSolid:
|
||||
{
|
||||
tr->fAllSolid = *ptr;
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
case TR_StartSolid:
|
||||
{
|
||||
return tr->fStartSolid;
|
||||
break;
|
||||
}
|
||||
case TR_InWater:
|
||||
{
|
||||
tr->fInWater = *ptr;
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
case TR_flFraction:
|
||||
{
|
||||
tr->flFraction = amx_ctof(*ptr);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
case TR_vecEndPos:
|
||||
{
|
||||
tr->vecEndPos.x = amx_ctof(ptr[0]);
|
||||
tr->vecEndPos.y = amx_ctof(ptr[1]);
|
||||
tr->vecEndPos.z = amx_ctof(ptr[2]);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
case TR_flPlaneDist:
|
||||
{
|
||||
tr->flPlaneDist = amx_ctof(*ptr);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
case TR_vecPlaneNormal:
|
||||
{
|
||||
tr->vecPlaneNormal.x = amx_ctof(ptr[0]);
|
||||
tr->vecPlaneNormal.y = amx_ctof(ptr[1]);
|
||||
tr->vecPlaneNormal.z = amx_ctof(ptr[2]);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
case TR_pHit:
|
||||
{
|
||||
e = INDEXENT(*ptr);
|
||||
if (!e || FNullEnt(e))
|
||||
return 0; //TODO: return error
|
||||
tr->pHit = e;
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
case TR_iHitgroup:
|
||||
{
|
||||
tr->iHitgroup = *ptr;
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
//TODO: error
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_tr(AMX *amx, cell *params)
|
||||
{
|
||||
cell *cPtr = ¶ms[1];
|
||||
int type = params[2];
|
||||
TraceResult *tr = (TraceResult*)((void *)cPtr);
|
||||
cell *ptr = 0;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case TR_AllSolid:
|
||||
{
|
||||
return tr->fAllSolid;
|
||||
break;
|
||||
}
|
||||
case TR_StartSolid:
|
||||
{
|
||||
return tr->fStartSolid;
|
||||
break;
|
||||
}
|
||||
case TR_InWater:
|
||||
{
|
||||
return tr->fInWater;
|
||||
break;
|
||||
}
|
||||
case TR_flFraction:
|
||||
{
|
||||
ptr = MF_GetAmxAddr(amx, params[3]);
|
||||
*ptr = amx_ftoc(tr->flFraction);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
case TR_vecEndPos:
|
||||
{
|
||||
ptr = MF_GetAmxAddr(amx, params[3]);
|
||||
ptr[0] = amx_ftoc(tr->vecEndPos.x);
|
||||
ptr[1] = amx_ftoc(tr->vecEndPos.y);
|
||||
ptr[2] = amx_ftoc(tr->vecEndPos.z);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
case TR_flPlaneDist:
|
||||
{
|
||||
ptr = MF_GetAmxAddr(amx, params[3]);
|
||||
*ptr = amx_ftoc(tr->flPlaneDist);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
case TR_vecPlaneNormal:
|
||||
{
|
||||
ptr = MF_GetAmxAddr(amx, params[3]);
|
||||
ptr[0] = amx_ftoc(tr->vecPlaneNormal.x);
|
||||
ptr[1] = amx_ftoc(tr->vecPlaneNormal.y);
|
||||
ptr[2] = amx_ftoc(tr->vecPlaneNormal.z);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
case TR_pHit:
|
||||
{
|
||||
return ENTINDEX(tr->pHit);
|
||||
break;
|
||||
}
|
||||
case TR_iHitgroup:
|
||||
{
|
||||
return tr->iHitgroup;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
//TODO: error
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AMX_NATIVE_INFO tr_Natives[] = {
|
||||
{"get_tr", get_tr},
|
||||
{"set_tr", set_tr},
|
||||
{NULL, NULL},
|
||||
};
|
18
dlls/fakemeta/fm_tr.h
Executable file
18
dlls/fakemeta/fm_tr.h
Executable file
@ -0,0 +1,18 @@
|
||||
#ifndef _INCLUDE_TR_H
|
||||
#define _INCLUDE_TR_H
|
||||
|
||||
enum
|
||||
{
|
||||
TR_AllSolid,
|
||||
TR_StartSolid,
|
||||
TR_InOpen,
|
||||
TR_InWater,
|
||||
TR_flFraction,
|
||||
TR_vecEndPos,
|
||||
TR_flPlaneDist,
|
||||
TR_vecPlaneNormal,
|
||||
TR_pHit,
|
||||
TR_iHitgroup,
|
||||
};
|
||||
|
||||
#endif //_INCLUDE_TR_H
|
@ -90,6 +90,26 @@ void SetModel_post(edict_t *e, const char *m)
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void TraceLine(const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr)
|
||||
{
|
||||
cell vec1[3] = {amx_ftoc(v1[0]), amx_ftoc(v1[1]), amx_ftoc(v1[2])};
|
||||
cell vec2[3] = {amx_ftoc(v2[0]), amx_ftoc(v2[1]), amx_ftoc(v2[2])};
|
||||
cell retvec1 = MF_PrepareCellArray(vec1, 3);
|
||||
cell retvec2 = MF_PrepareCellArray(vec2, 3);
|
||||
FM_ENG_HANDLE(FM_TraceLine, (Engine[FM_TraceLine].at(i), vec1, vec2, fNoMonsters, ENTINDEX(pentToSkip), (cell)ptr));
|
||||
RETURN_META(mswi(lastFmRes));
|
||||
}
|
||||
|
||||
void TraceLine_post(const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr)
|
||||
{
|
||||
cell vec1[3] = {amx_ftoc(v1[0]), amx_ftoc(v1[1]), amx_ftoc(v1[2])};
|
||||
cell vec2[3] = {amx_ftoc(v2[0]), amx_ftoc(v2[1]), amx_ftoc(v2[2])};
|
||||
cell retvec1 = MF_PrepareCellArray(vec1, 3);
|
||||
cell retvec2 = MF_PrepareCellArray(vec2, 3);
|
||||
FM_ENG_HANDLE(FM_TraceLine, (Engine[FM_TraceLine].at(i), vec1, vec2, fNoMonsters, ENTINDEX(pentToSkip), (cell)ptr));
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
// pfnModelIndex
|
||||
SIMPLE_INT_HOOK_CONSTSTRING(ModelIndex);
|
||||
|
||||
@ -569,8 +589,8 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params)
|
||||
ENGHOOK(EmitAmbientSound);
|
||||
break;
|
||||
case FM_TraceLine:
|
||||
fId = MF_RegisterSPForwardByName(amx, funcname, FP_ARRAY, FP_ARRAY, FP_CELL, FP_CELL, FP_DONE);
|
||||
// ENGHOOK(TraceLine);
|
||||
fId = MF_RegisterSPForwardByName(amx, funcname, FP_ARRAY, FP_ARRAY, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
|
||||
ENGHOOK(TraceLine);
|
||||
break;
|
||||
case FM_TraceToss:
|
||||
fId = MF_RegisterSPForwardByName(amx, funcname, FP_CELL, FP_CELL, FP_DONE);
|
||||
|
@ -2681,7 +2681,7 @@ void ValidateMacros_DontCallThis_Smiley()
|
||||
MF_AmxExecv(0, 0, 0, 0, 0);
|
||||
MF_AmxFindPublic(0, 0, 0);
|
||||
MF_AmxAllot(0, 0, 0, 0);
|
||||
MF_LoadAmxScript(0, 0, 0, 0);
|
||||
MF_LoadAmxScript(0, 0, 0, 0, 0);
|
||||
MF_UnloadAmxScript(0, 0);
|
||||
MF_RegisterSPForward(0, 0, 0, 0, 0, 0);
|
||||
MF_RegisterSPForwardByName(0, 0, 0, 0, 0, 0);
|
||||
|
@ -35,4 +35,10 @@ native register_forward(_forwardType,_function[],_post=0);
|
||||
native forward_return(type,{Float,Sql,Result,_}:...);
|
||||
|
||||
native engfunc(type,{Float,Sql,Result,_}:...);
|
||||
native dllfunc(type,{Float,Sql,Result,_}:...);
|
||||
native dllfunc(type,{Float,Sql,Result,_}:...);
|
||||
|
||||
//only use this with functions that pass a Trace
|
||||
// get: zero extra params - return int, one extra param = byref float or vector
|
||||
// set: use anything
|
||||
native get_tr(Trace:tr, TraceResult:tr_member, {Float,_}:...);
|
||||
native set_tr(Trace:tr, TraceResult:tr_member, {Float,_}:...);
|
@ -437,3 +437,17 @@ enum {
|
||||
FM_CreateInstancedBaseline, // done
|
||||
FM_AllowLagCompensation, // done
|
||||
};
|
||||
|
||||
enum TraceResult
|
||||
{
|
||||
TR_AllSolid,
|
||||
TR_StartSolid,
|
||||
TR_InOpen,
|
||||
TR_InWater,
|
||||
TR_flFraction,
|
||||
TR_vecEndPos,
|
||||
TR_flPlaneDist,
|
||||
TR_vecPlaneNormal,
|
||||
TR_pHit,
|
||||
TR_iHitgroup,
|
||||
};
|
Loading…
Reference in New Issue
Block a user