/* from .\cstrike\sound\materials.txt */
// 'M' metal
// 'V' ventillation
// 'D' dirt
// 'S' slosh liquid
// 'T' tile
// 'G' grate (Concrete is the default)
// 'W' wood
// 'P' computer
// 'Y' glass
//- 'N' snow
//- 'X' grass
// Note: "minus" ("-") mean that the given texture type is absent in the above/below list
// from HLSDK
#define CTEXTURESMAX 512 // max number of textures loaded
#define CBTEXTURENAMEMAX 13 // only load first n chars of name
#define CHAR_TEX_CONCRETE 'C' // -
#define CHAR_TEX_METAL 'M'
#define CHAR_TEX_DIRT 'D'
#define CHAR_TEX_VENT 'V'
#define CHAR_TEX_GRATE 'G'
#define CHAR_TEX_TILE 'T'
#define CHAR_TEX_SLOSH 'S'
#define CHAR_TEX_WOOD 'W'
#define CHAR_TEX_COMPUTER 'P'
#define CHAR_TEX_GLASS 'Y'
#define CHAR_TEX_FLESH 'F' // -
#include <amxmodx>
#include <fakemeta_util>
public plugin_precache() {
register_forward(FM_TraceTexture, "TraceTexture", 1)
register_forward(FM_PM_FindTextureType, "PM_FindTextureType", 1) // never called on the practice
register_clcmd("texinfo", "cmd_texinfo")
}
// const char *) (edict_t *pTextureEntity, const float *v1, const float *v2 )
public TraceTexture(TextureEntity, Float:v1[3], Float:v2[3]) {
new TextureName[128]
get_orig_retval(TextureName, 127)
new id = 1, Float:start[3], Float:view_ofs[3]
pev(id, pev_origin, start)
pev(id, pev_view_ofs, view_ofs)
xs_vec_add(start, view_ofs, start)
new Float:dest[3]
pev(id, pev_v_angle, dest)
engfunc(EngFunc_MakeVectors, dest)
global_get(glb_v_forward, dest)
xs_vec_mul_scalar(dest, 9999.0, dest)
xs_vec_add(start, dest, dest)
new Float:end[3], tr = 0
engfunc(EngFunc_TraceLine, start, dest, 0, id, tr)
get_tr2(tr, TR_vecEndPos, end)
new TextureType[2]
TextureType[0] = dllfunc(DLLFunc_PM_FindTextureType, TextureName)
server_print("TextureEnt[%d] TextureName[%s] TextureType[%s]", TextureEntity, TextureName, TextureType)
new Float:angle1[3], Float:angle2[3]
xs_vec_sub(end, start, angle1)
xs_vec_sub(v2, v1, angle2)
engfunc(EngFunc_VecToAngles, angle1, angle1)
engfunc(EngFunc_VecToAngles, angle2, angle2)
// Result: AngleM[0.8][1.3][0.0] AngleT[1.1][1.1][0.0]
server_print("AngleM[%.1f][%.1f][%.1f]", angle1[0], angle1[1], angle1[2])
server_print("AngleT[%.1f][%.1f][%.1f]", angle2[0], angle2[1], angle2[2])
server_print("StartPlr[%.1f][%.1f][%.1f] EndPlr[%.1f][%.1f][%.1f]", start[0], start[1], start[2], end[0], end[1], end[2])
server_print("StartTex[%.1f][%.1f][%.1f] EndTex[%.1f][%.1f][%.1f]^n", v1[0], v1[1], v1[2], v2[0], v2[1], v2[2])
}
// char ) (char *name);
public PM_FindTextureType(TextureName[]) {
new TextureType[2]
TextureType[0] = get_orig_retval()
server_print("[!!!] TextureName[%s] TextureType[%s]^n", TextureName, TextureType)
}
public cmd_texinfo(id) {
if (!(pev(id, pev_flags) & FL_ONGROUND))
return PLUGIN_HANDLED
static Float:start[3]
pev(id, pev_origin, start)
static Float:dest[3]
dest[0] = start[0]
dest[1] = start[1]
dest[2] = -8191.0
new tr
engfunc(EngFunc_TraceLine, start, dest, 0, id, tr)
static texent
texent = get_tr2(tr, TR_pHit)
if (texent == -1)
texent = 0
else if (is_user_alive(texent))
return PLUGIN_HANDLED
static texname[16]
engfunc(EngFunc_TraceTexture, texent, start, dest, texname, 15)
static textype[2]
textype[0] = dllfunc(DLLFunc_PM_FindTextureType, texname)
server_print("TexEnt[%d] TexName[%s] TexType[%s]", texent, texname, textype)
return PLUGIN_HANDLED
}