Raised This Month: $51 Target: $400
 12% 

EngFunc_TraceTexture


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 08-25-2009 , 05:58   EngFunc_TraceTexture
Reply With Quote #1

Crashes server...
Tried it this way in the Ham_TraceAttack forward.
PHP Code:
new text_name[16], text_type[2]
engfunc(EngFunc_TraceTexture0startendtext_namecharsmax(text_name))
text_type[0] = dllfunc(DllFunc_PM_FindTextureTypetext_name
My mistake?
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-25-2009 , 06:33   Re: EngFunc_TraceTexture
Reply With Quote #2

If I remember you have to do something like :

Code:
new Float:Origin[ Coord_e ]; new Float:End   [ Coord_e ]; new TextureType[ 1 ]; new Texture[ 64 ];             pev( Player, pev_origin, Origin );             End = Origin; End[ z ] = -8191.0; engfunc( EngFunc_TraceTexture, pev( Player, pev_groundentity ), Origin, End, Texture, charsmax( Texture ) ); TextureType[ 0 ] = dllfunc  DLLFunc_PM_FindTextureType, Texture );
__________________
Arkshine is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 08-25-2009 , 06:35   Re: EngFunc_TraceTexture
Reply With Quote #3

Shouldn't you use xs in this situation?

xs_vec_copy(origin, end)?
And, for walls does this work?
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-25-2009 , 06:37   Re: EngFunc_TraceTexture
Reply With Quote #4

If the array is the same size, you can do that directly.

No you can't do that on the wall, the trace has to be straight down from you. You don't walk on the wall. :p
__________________

Last edited by Arkshine; 08-25-2009 at 06:40.
Arkshine is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 08-25-2009 , 06:39   Re: EngFunc_TraceTexture
Reply With Quote #5

That is why it crashed. I tried doing that on a wall.
Question. is it possible to determine the material of the wall?
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-25-2009 , 07:00   Re: EngFunc_TraceTexture
Reply With Quote #6

Don't know :/ Try to walk on the wall and execute the code. :p
__________________
Arkshine is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 08-25-2009 , 07:10   Re: EngFunc_TraceTexture
Reply With Quote #7

Quote:
Originally Posted by Arkshine View Post
Don't know :/ Try to walk on the wall and execute the code. :p
=)))))))))))))))))))
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-25-2009 , 07:53   Re: EngFunc_TraceTexture
Reply With Quote #8

It's weird because in the HLSDK a trace_texture is done after you fire.

Code:
[...]         if (tr.flFraction != 1.0)         {             CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);             if ( iDamage )             {                 pEntity->TraceAttack(pevAttacker, iDamage, vecDir, &tr, DMG_BULLET | ((iDamage > 16) ? DMG_ALWAYSGIB : DMG_NEVERGIB) );                                 TEXTURETYPE_PlaySound(&tr, vecSrc, vecEnd, iBulletType);                 DecalGunshot( &tr, iBulletType );             } [...]

Code:
// play a strike sound based on the texture that was hit by the attack traceline.  VecSrc/VecEnd are the // original traceline endpoints used by the attacker, iBulletType is the type of bullet that hit the texture. // returns volume of strike instrument (crowbar) to play float TEXTURETYPE_PlaySound(TraceResult *ptr,  Vector vecSrc, Vector vecEnd, int iBulletType) { // hit the world, try to play sound based on texture material type         char chTextureType;     float fvol;     float fvolbar;     char szbuffer[64];     const char *pTextureName;     float rgfl1[3];     float rgfl2[3];     char *rgsz[4];     int cnt;     float fattn = ATTN_NORM;     if ( !g_pGameRules->PlayTextureSounds() )         return 0.0;     CBaseEntity *pEntity = CBaseEntity::Instance(ptr->pHit);     chTextureType = 0;     if (pEntity && pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE)         // hit body         chTextureType = CHAR_TEX_FLESH;     else     {         // hit world         // find texture under strike, get material type         // copy trace vector into array for trace_texture         vecSrc.CopyToArray(rgfl1);         vecEnd.CopyToArray(rgfl2);         // get texture from entity or world (world is ent(0))         if (pEntity)             pTextureName = TRACE_TEXTURE( ENT(pEntity->pev), rgfl1, rgfl2 );         else             pTextureName = TRACE_TEXTURE( ENT(0), rgfl1, rgfl2 );                     if ( pTextureName )         {             // strip leading '-0' or '+0~' or '{' or '!'             if (*pTextureName == '-' || *pTextureName == '+')                 pTextureName += 2;             if (*pTextureName == '{' || *pTextureName == '!' || *pTextureName == '~' || *pTextureName == ' ')                 pTextureName++;             // '}}'             strcpy(szbuffer, pTextureName);             szbuffer[CBTEXTURENAMEMAX - 1] = 0;                             // ALERT ( at_console, "texture hit: %s\n", szbuffer);             // get texture type             chTextureType = TEXTURETYPE_Find(szbuffer);          }     } [...]
__________________
Arkshine is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 08-25-2009 , 08:03   Re: EngFunc_TraceTexture
Reply With Quote #9

Then it is a fakemeta error?

Edit:
Code:
		// pfnTraceTexture
	case EngFunc_TraceTexture:		// const char *)			(edict_t *pTextureEntity, const float *v1, const float *v2 );
		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]);
		cRet = MF_GetAmxAddr(amx,params[4]);
		Vec2[0]=amx_ctof(cRet[0]);
		Vec2[1]=amx_ctof(cRet[1]);
		Vec2[2]=amx_ctof(cRet[2]);
		temp = (char*)(*g_engfuncs.pfnTraceTexture)(INDEXENT2(index),Vec1,Vec2);
		cRet = MF_GetAmxAddr(amx,params[6]);
		MF_SetAmxString(amx, params[5], temp, cRet[0]);
		return 1;
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.

Last edited by ot_207; 08-25-2009 at 08:09.
ot_207 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-25-2009 , 08:44   Re: EngFunc_TraceTexture
Reply With Quote #10

I don't think, and I don't see anything wrong. Plus, it works fine if you do like my code above.

In CBaseEntity *pEntity = CBaseEntity::Instance(ptr->pHit);

Instance() returns pent->pvPrivateData; and as comment we can read :
Quote:
void* pvPrivateData; // Alloced and freed by engine, used by DLLs
get_tr2() will return -1 if not there is not hit. I'm not pro at all but I was wondering if the wall is not attributed with a specific index managed by the engine and ptr->pHit would not return 0 in this case. Anyway I really don't know why it crashes. :/
__________________

Last edited by Arkshine; 08-25-2009 at 08:50.
Arkshine is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:03.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode