Raised This Month: $ Target: $400
 0% 

trace_line to the ground


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 08-14-2009 , 22:48   trace_line to the ground
Reply With Quote #1

Hi, I've read a lot of posts that suggest tracing a line to the ground, but I've not seen one that shows the actual code for doing so.

Would I be allowed to just set the endpoint to 5000 below the starting point, or is there some optimal value I should set it to?

Also, I'm finding random spots above the ground. How do I know when my spot I've found is below the entire map?

What I have is fully functional, I just don't know if my methods are terrible or not.
__________________

Last edited by Bad_Bud; 08-14-2009 at 23:27.
Bad_Bud is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-15-2009 , 03:34   Re: trace_line to the ground
Reply With Quote #2

Please show some code, and tell why you do that.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 08-15-2009 , 03:57   Re: trace_line to the ground
Reply With Quote #3

Not much to show. I have defined two points that create a large box in a map. Within this box, I wish to spawn things 50 units above the ground. Here's how I'm getting my points (this works):

PHP Code:
FindPointAboveGround(Float:Origin[3])
{
    static 
Float:Start[3]
    static 
Float:End[3]
    
    do
    {
        
Start[0]=random_float(X1,X2)
        
Start[1]=random_float(Y1,Y2)
        
Start[2]=random_float(Z1,Z2)
        
        
End[0]=Start[0]
        
End[1]=Start[1]
        
End[2]=(Start[2]-5000.0)
        
        
trace_line(0,Start,End,Origin)
    }while(
Origin[2]<-5000.0)
    
    
Origin[2]+=50.0

But I don't know if this is necessarily a "good way" to do it, by assigning an arbitrarily huge number to trace down to, or if there's another way to make it just trace until it hits the ground.

The Origin[2]<-5000.0 condition is what I check against to see if my random start point was created inside of a wall, in which case it traces through the map to the huge number below, and I do it again.
__________________
Bad_Bud is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-15-2009 , 04:02   Re: trace_line to the ground
Reply With Quote #4

I think you need just one trace. Start shoud be the same as End, and End[2] you remove 5000. Get the TR_flFraction of the trace, if <1.0, you have touched something, otherwise nothing.
__________________
Arkshine is offline
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 08-15-2009 , 04:25   Re: trace_line to the ground
Reply With Quote #5

Heh, sorry, it's my first time working with trace_line. I couldn't find any good posts on it when searching for trace_line, but I found some good tutorials while looking for TR_flFraction. I should be okay now. ;)

Thanks.
__________________
Bad_Bud 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 15:10.


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