AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   EngFunc_TraceTexture (https://forums.alliedmods.net/showthread.php?t=101576)

ot_207 08-25-2009 05:58

EngFunc_TraceTexture
 
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?

Arkshine 08-25-2009 06:33

Re: EngFunc_TraceTexture
 
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 );

ot_207 08-25-2009 06:35

Re: EngFunc_TraceTexture
 
Shouldn't you use xs in this situation?

xs_vec_copy(origin, end)?
And, for walls does this work?

Arkshine 08-25-2009 06:37

Re: EngFunc_TraceTexture
 
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

ot_207 08-25-2009 06:39

Re: EngFunc_TraceTexture
 
That is why it crashed. I tried doing that on a wall.
Question. is it possible to determine the material of the wall?

Arkshine 08-25-2009 07:00

Re: EngFunc_TraceTexture
 
Don't know :/ Try to walk on the wall and execute the code. :p

ot_207 08-25-2009 07:10

Re: EngFunc_TraceTexture
 
Quote:

Originally Posted by Arkshine (Post 912261)
Don't know :/ Try to walk on the wall and execute the code. :p

=)))))))))))))))))))

Arkshine 08-25-2009 07:53

Re: EngFunc_TraceTexture
 
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);         }     } [...]

ot_207 08-25-2009 08:03

Re: EngFunc_TraceTexture
 
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;


Arkshine 08-25-2009 08:44

Re: EngFunc_TraceTexture
 
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. :/


All times are GMT -4. The time now is 05:50.

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