Raised This Month: $ Target: $400
 0% 

EngFunc_TraceTexture


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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 15:07.


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