AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved [TF2] How to check is the point on wall or on floor (https://forums.alliedmods.net/showthread.php?t=303497)

oplkill 12-09-2017 15:47

[TF2] How to check is the point on wall or on floor
 
There the code which checking can place on this point a sentry, but its working only on plate serfaces.
I want to change it to place on any surface(like engineer), but except walls.

How to change this code to make it to allow to creating not only plate surfaces, but not the walls?
PHP Code:


...
new 
Float:flPos[3];
if(
GetClientLookPosition(clientflPos))
       if(
CanBuildAtPosSentry(flPos))
...


stock bool CanBuildAtPosSentry(float fPos[3]){
    
float fMins[3], fMaxs[3];

    
fMins[0] = -20.0;
    
fMins[1] = -20.0;
    
fMins[2] = 0.0;

    
fMaxs[0] = 20.0;
    
fMaxs[1] = 20.0;
    
fMaxs[2] = 66.0;

    
TR_TraceHull(fPosfPosfMinsfMaxsMASK_SOLID);
    return !
TR_DidHit();



backwards 12-09-2017 16:20

Re: [TF2] How to check is the point on wall or on floor
 
PHP Code:

stock bool CanBuildAtPosSentry(float fPos[3]){
    
float fMins[3], fMaxs[3];

    
fMins[0] = -20.0;
    
fMins[1] = -20.0;
    
fMins[2] = 0.0;

    
fMaxs[0] = 20.0;
    
fMaxs[1] = 20.0;
    
fMaxs[2] = 66.0;

    
TR_TraceHull(fPosfPosfMinsfMaxsMASK_SOLID);

    
float fPlaneNormals[3];
    
TR_GetPlaneNormal(INVALID_HANDLEfPlaneNormals)
    if(
fPlaneNormals[0] == 0.0 && fPlaneNormals[1] == 0.0 && fPlaneNormals[2] == 1.0)
        return !
TR_DidHit();

    return 
false;



oplkill 12-10-2017 07:04

Re: [TF2] How to check is the point on wall or on floor
 
Thanks, that works, but you mistaken, need to be fPlaneNormals[2] == -1.0, not 1.0

full right code, for copy pasters =)

PHP Code:

stock bool CanBuildAtPosSentry(float fPos[3]){
    
float fMins[3], fMaxs[3];

    
fMins[0] = -20.0;
    
fMins[1] = -20.0;
    
fMins[2] = 0.0;

    
fMaxs[0] = 20.0;
    
fMaxs[1] = 20.0;
    
fMaxs[2] = 66.0;

    
TR_TraceHull(fPosfPosfMinsfMaxsMASK_SOLID);

    
float fPlaneNormals[3];
    
TR_GetPlaneNormal(INVALID_HANDLEfPlaneNormals)
    if(
fPlaneNormals[0] == 0.0 && fPlaneNormals[1] == 0.0 && fPlaneNormals[2] == -1.0)
        return !
TR_DidHit();

    return 
false;



backwards 12-10-2017 07:45

Re: [TF2] How to check is the point on wall or on floor
 
Quote:

Originally Posted by oplkill (Post 2565376)
Thanks, that works, but you mistaken, need to be fPlaneNormals[2] == -1.0, not 1.0

This may depend on the map, in css the map I've tested 1.0 on z was the floor but -1.0 was the ceiling. So keep that in mind, it's easy to change for slightly slanted surfaces as well.


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

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