Raised This Month: $ Target: $400
 0% 

[HELP] Wall thickness problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wiwi249
Member
Join Date: Oct 2013
Old 07-30-2014 , 05:31   [HELP] Wall thickness problem
Reply With Quote #1

Hello.
I've recently found a code for calculating the wall thickness by player aim. Here's it, by Arkshine:

Code:
Float:getWallThickness( const player ) {
     /* TRACELINE #1 : Player's eyes to wall. */ 
    server_print( "START TRACELINE #1" );
    new Float:source[3], Float:direction[3], Float:end[3], Float:endOrig[3];
    new Float:fraction;   
       // Get eyes position
    pev( player, pev_origin, source );
    pev( player, pev_view_ofs, direction );
    xs_vec_add( source, direction, source );  

        // Get eyes direction
    pev( player, pev_v_angle, direction ); 

    engfunc( EngFunc_MakeVectors, direction ); 
    global_get( glb_v_forward, direction ); 

         // Get the end direction from eyes
    xs_vec_mul_scalar( direction, 9999.0, end ); 
    xs_vec_add( source, end, end ); 
    engfunc( EngFunc_TraceLine, source, end, IGNORE_MONSTERS, player, 0 );  

        // Get the fraction of the trace 
    get_tr2( 0, TR_flFraction, fraction );  
        // No hit
    if( fraction == 1.0 ) 
    {
         return 0.0; 
    }  

    /* TRACELINE #2 : Inside wall to behind wall to check if there is free space*/

    server_print( "START TRACELINE #2" );

          // Get the end position the trace hits.
    get_tr2( 0, TR_vecEndPos, end );
    //get_tr2( 0, TR_vecPlaneNormal, direction );

          drawBeam( source, end, 200, 50, 50 );

          // Save this position so we can calculate the thickness later.
     endOrig = end;

      // Get new start position by moving inside the wall a bit.
     xs_vec_mul_scalar( direction, 2.0, direction );
     xs_vec_add( end, direction, source );
          // Get the end position from inside the wall to far behind.
     xs_vec_mul_scalar( direction, 9999.0, direction );
     xs_vec_add( source, direction, end );
     engfunc( EngFunc_TraceLine, source, end, IGNORE_MONSTERS | IGNORE_GLASS, player, 0 );

          // Get the fraction of the trace
     get_tr2( 0, TR_flFraction, fraction );
      // No hit or no free space
     if( fraction == 1.0 || get_tr2( 0, TR_AllSolid ) )
     {
         return 0.0;
     } 

         /* TRACELINE #3 : From behind the wall to back inside the wall to know the */
     server_print( "START TRACELINE #3" );
          // The end position of the next trace is the start position of the previous trace.
         // Get the end position the trace hits which is the start position of next trace.
     end = source;
     get_tr2( 0, TR_vecEndPos, source );
     drawBeam( source, end, 50, 200, 50 );
     engfunc( EngFunc_TraceLine, source, end, IGNORE_MONSTERS | IGNORE_GLASS, player, 0 );

          // Get the end position just behind the wall.
     get_tr2( 0, TR_vecEndPos, end );
     drawBeam( source, end, 50, 50, 200 );
          // Get the thickness of the wall.
     return vector_distance( end, endOrig );
}
Unfortunately I don't fully understand this code to edit it for my needs. In my mod, some weapons fire bullet entities and I need to calculate if they can go through wall, so I need to get the wall thickness by entity velocity. Could anyone change it for me here?

Last edited by wiwi249; 07-30-2014 at 05:38.
wiwi249 is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 07-30-2014 , 11:12   Re: [HELP] Wall thickness problem
Reply With Quote #2

What do you exactly mean by "entity velocity"? Please explain better what are you willing to do with that code.
klippy is offline
wiwi249
Member
Join Date: Oct 2013
Old 08-02-2014 , 10:22   Re: [HELP] Wall thickness problem
Reply With Quote #3

The bullet entity i mentioned, it has its velocity (because bullet is flying). Velocity is a vector, so I just want to get the wall thickness in the direction the bullet is flying. The code i pasted is getting the wall thickness by player aim. I want to get the same but not by the player aim, but by entity velocity vector (flying direction).
wiwi249 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 20:45.


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