Raised This Month: $ Target: $400
 0% 

Solved [TF2] How to check is the point on wall or on floor


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
oplkill
Member
Join Date: Aug 2015
Old 12-09-2017 , 15:47   [TF2] How to check is the point on wall or on floor
Reply With Quote #1

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();


Last edited by oplkill; 12-10-2017 at 07:04.
oplkill is offline
backwards
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 12-09-2017 , 16:20   Re: [TF2] How to check is the point on wall or on floor
Reply With Quote #2

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;

__________________
I highly recommend joining the SourceMod Discord Server for real time support.
backwards is offline
oplkill
Member
Join Date: Aug 2015
Old 12-10-2017 , 07:04   Re: [TF2] How to check is the point on wall or on floor
Reply With Quote #3

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;

oplkill is offline
backwards
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 12-10-2017 , 07:45   Re: [TF2] How to check is the point on wall or on floor
Reply With Quote #4

Quote:
Originally Posted by oplkill View Post
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.
__________________
I highly recommend joining the SourceMod Discord Server for real time support.
backwards is offline
Reply


Thread Tools
Display Modes

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 13:50.


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