Raised This Month: $51 Target: $400
 12% 

Find out if there is a free space


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kowalsky
Senior Member
Join Date: Mar 2015
Location: Poland
Old 03-18-2016 , 04:00   Find out if there is a free space
Reply With Quote #1

Hey.

I want to find out if there is a "free space" for entity to spawn it at player's origin. so I need to ignore the particular player who is spawning an entity and find out if the entity collides with anything around it. How do I do it?
Kowalsky is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 03-18-2016 , 09:58   Re: Find out if there is a free space
Reply With Quote #2

If I understood correctly, use traceline/tracehull + IGNORE_MONSTERS flag.
__________________

Last edited by HamletEagle; 03-18-2016 at 09:59.
HamletEagle is offline
Kowalsky
Senior Member
Join Date: Mar 2015
Location: Poland
Old 03-18-2016 , 10:02   Re: Find out if there is a free space
Reply With Quote #3

I understand how the traceline works, but could you please explain what is tracehull and how it works?

Last edited by Kowalsky; 03-18-2016 at 10:02.
Kowalsky is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 03-18-2016 , 13:15   Re: Find out if there is a free space
Reply With Quote #4

TraceHull is same as TraceLine, but only difference (as the name suggests) is that it traces a hull (a volume) instead of a line. It just has one additional parameter that says what hull type to use. Search around, there are numerous examples.
klippy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-18-2016 , 19:00   Re: Find out if there is a free space
Reply With Quote #5

https://forums.alliedmods.net/showpo...11&postcount=7

Untested, I took the linked code and made minor tweaks.
PHP Code:
new Float:fOrigin]; //Need to set origin in question here 
    
if ( Is_Hull_VacantfOrigin id ) )
{
    
//ok to use origin
}

stock bool:Is_Hull_Vacant( const Float:Origin] , id )
{
    new 
tr Hull = ( pevid pev_flags) & FL_DUCKING ) ? HULL_HEAD HULL_HUMAN;
    
engfuncEngFunc_TraceHull Origin Origin Hull id tr );
    return 
bool:( !get_tr2tr TR_StartSolid ) || !get_tr2tr TR_AllSolid ) );

__________________

Last edited by Bugsy; 03-18-2016 at 22:24.
Bugsy 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 16:25.


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