Re: EngFunc_TraceTexture result is only NoTexture
hy guys, i find it out by reading many posts on this forum an many other sites.
the distance between the two points that you have to give to the function (startOrigin,endOrigin)
PHP Code:
engfunc(EngFunc_TraceTexture, 0, startOrigin , endOrigin, texture_name, charsmax(texture_name))
has to be longer than 2000.0 .
in a post from Arkshine i found a calculation function that helps me a lot to calculate the new endpoint.
PHP Code:
enum _:Angle_t { Float:Pitch, Float:Yaw, Float:Roll };
enum _:Coord_t { Float:x, Float:y, Float:z };
#define VectorMA(%0,%1,%2,%3) ( %3[ x ] = %0[ x ] + %1 * %2[ x ], %3[ y ] = %0[ y ] + %1 * %2[ y ], %3[ z ] = %0[ z ] + %1 * %2[ z ] )
const Float:LENGTH = 8000.0;
new Float:endOrigin[ Coord_t ];
new Float:startOrigin[ Coord_t ];
new Float:dirForward[ Coord_t ];
new Float:viewAngles[ Angle_t ];
pev( iAttacker, pev_origin, startOrigin );
pev( iAttacker, pev_v_angle, viewAngles );
engfunc( EngFunc_MakeVectors, viewAngles );
global_get( glb_v_forward, dirForward );
VectorMA( startOrigin, LENGTH, dirForward, endOrigin );
here the full code of my plugin that seems to work^^
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <engine>
#include <xs>
new const Version[] = "1.0";
enum _:Angle_t { Float:Pitch, Float:Yaw, Float:Roll };
enum _:Coord_t { Float:x, Float:y, Float:z };
#define VectorMA(%0,%1,%2,%3) ( %3[ x ] = %0[ x ] + %1 * %2[ x ], %3[ y ] = %0[ y ] + %1 * %2[ y ], %3[ z ] = %0[ z ] + %1 * %2[ z ] )
#define MAX_PLAYERS 32
#define IsPlayer(%1) ( 1 <= %1 <= MAX_PLAYERS )
public plugin_init()
{
register_plugin( "Anti_Wallbang" , Version , "AimniX" );
RegisterHam( Ham_TraceAttack , "player" , "Player_TraceAttack" );
}
public Player_TraceAttack( iEnt , iAttacker , Float:flDamage , Float:fDir[ 3 ] , ptr , iDamageType )
{
if( IsPlayer( iAttacker ) )
{
if ( iDamageType & DMG_BULLET )
{
new Float:fEnd[3]
new Float:normal[3]
new hit
get_tr2( ptr , TR_vecEndPos , fEnd , TR_vecPlaneNormal, normal, TR_pHit,hit);
if(bool:!ExecuteHam( Ham_FVecVisible , iAttacker , fEnd )!= false)
{
const Float:LENGTH = 8000.0;
new Float:endOrigin[ Coord_t ];
new Float:startOrigin[ Coord_t ];
new Float:dirForward[ Coord_t ];
new Float:viewAngles[ Angle_t ];
pev( iAttacker, pev_origin, startOrigin );
pev( iAttacker, pev_v_angle, viewAngles );
engfunc( EngFunc_MakeVectors, viewAngles );
global_get( glb_v_forward, dirForward );
VectorMA( startOrigin, LENGTH, dirForward, endOrigin );
new texture_name[32],texture_type[1]
engfunc(EngFunc_TraceTexture, 0, startOrigin , endOrigin, texture_name, charsmax(texture_name))
texture_type[0] = dllfunc(DLLFunc_PM_FindTextureType, texture_name)
client_print( 0, print_chat, "This is the Texture: %s",texture_type)
new wood[] = "W";
if(texture_type[0] == wood[0])
{
return HAM_IGNORED;
}
return HAM_SUPERCEDE
}
}
else
{
return HAM_IGNORED
}
}
return HAM_IGNORED
}
|