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

Solved Max Z Stock


Post New Thread Reply   
 
Thread Tools Display Modes
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-27-2018 , 20:41   Re: Max Z Stock
Reply With Quote #31

I'm not sure where in the map the origin is getting created, maybe it is in a tight location and then the -75 offset puts it underground? I've never used this map.
__________________
Bugsy is offline
SkumTomteN
Veteran Member
Join Date: Oct 2013
Location: Asgard
Old 07-27-2018 , 20:50   Re: Max Z Stock
Reply With Quote #32

HTML Code:
stock Float: get_origin_to_roof(Float:start[3])
{ 
	new Float:dest[3] = {-90.0, 0.0, 0.0}
	engfunc(EngFunc_MakeVectors, dest)
	global_get(glb_v_forward, dest)
	xs_vec_mul_scalar(dest, 9999.0, dest)
	xs_vec_add(start, dest, dest) 

	engfunc(EngFunc_TraceLine, start, dest, 0, 0, 0)
	new Float:origin[3]	
	get_tr2(0, TR_vecEndPos, origin)

	return origin
}
__________________
Contact: Steam
Videos: Youtube

Last edited by SkumTomteN; 07-27-2018 at 20:50.
SkumTomteN is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-28-2018 , 06:03   Re: Max Z Stock
Reply With Quote #33

Quote:
Originally Posted by Bugsy View Post
I'm not sure where in the map the origin is getting created, maybe it is in a tight location and then the -75 offset puts it underground? I've never used this map.
I did a minor tweak to your code, also something that affected your code was the maps 'easter egg', which is an underground place.

PHP Code:
public Float:GetMaxHeightid 

    new 
Float:fOrigin] = { 0.00.00.0 }, pcCurrent;
    
    
pevid pev_origin fOrigin ); 
    
    while ( ( 
engfuncEngFunc_PointContents fOrigin ) == CONTENTS_EMPTY ) || (  engfuncEngFunc_PointContents fOrigin ) == CONTENTS_SOLID ) )
    {
        
fOrigin] += 5.0
    }
    
    
pcCurrent engfuncEngFunc_PointContents fOrigin ); 

    if( 
pcCurrent == CONTENTS_SKY )
    {
        return 
fOrigin] -= 105.0;
    }
    return 
0.0

Quote:
Originally Posted by SkumTomteN View Post
HTML Code:
stock Float: get_origin_to_roof(Float:start[3])
{ 
	new Float:dest[3] = {-90.0, 0.0, 0.0}
	engfunc(EngFunc_MakeVectors, dest)
	global_get(glb_v_forward, dest)
	xs_vec_mul_scalar(dest, 9999.0, dest)
	xs_vec_add(start, dest, dest) 

	engfunc(EngFunc_TraceLine, start, dest, 0, 0, 0)
	new Float:origin[3]	
	get_tr2(0, TR_vecEndPos, origin)

	return origin
}
I already fixed the problem but could you explain how that works? I've never worked with trace lines.
__________________

Last edited by edon1337; 07-28-2018 at 06:03.
edon1337 is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 07-28-2018 , 09:40   Re: Max Z Stock
Reply With Quote #34

It traces a invisible line and set in TR_vecEndPos the first hit origin between start and end origin or the end origin if doesn't hit anything.
__________________








CrazY. is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-28-2018 , 12:57   Re: Max Z Stock
Reply With Quote #35

Quote:
Originally Posted by CrazY. View Post
It traces a invisible line and set in TR_vecEndPos the first hit origin between start and end origin or the end origin if doesn't hit anything.
So if I got it right, that trace line will return the origin of anything it hits? That wouldn't work at all, because it might hit something else than the sky.
__________________

Last edited by edon1337; 07-28-2018 at 12:59.
edon1337 is offline
Old 07-28-2018, 14:18
HamletEagle
This message has been deleted by HamletEagle. Reason: nvm
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-28-2018 , 14:19   Re: Max Z Stock
Reply With Quote #36

You could use traceline for this purpose as well, something like this:
PHP Code:
public GetMaxHeightOriginFloat:fStartOrigin] , Float:fResultOrigin] )

    new 
tlTrace Float:fDestOrigin];
    
    
fDestOrigin] = fStartOrigin];
    
fDestOrigin] = fStartOrigin];
    
fDestOrigin] = 99999.0

    
engfuncEngFunc_TraceLine fStartOrigin fDestOrigin IGNORE_MONSTERS tlTrace )
    
    
get_tr2tlTrace TR_vecEndPos fResultOrigin );
    
    
fResultOrigin] -= 150.0;

__________________
Bugsy is offline
SkumTomteN
Veteran Member
Join Date: Oct 2013
Location: Asgard
Old 07-28-2018 , 15:35   Re: Max Z Stock
Reply With Quote #37

Quote:
Originally Posted by edon1337 View Post
So if I got it right, that trace line will return the origin of anything it hits? That wouldn't work at all, because it might hit something else than the sky.
It will hit depending on what flags you use for the traceline.

you could just filter it.

Quote:
Originally Posted by Bugsy View Post
You could use traceline for this purpose as well, something like this:
PHP Code:
fResultOrigin] -= 150.0;

Would this not be inaccurate?
__________________
Contact: Steam
Videos: Youtube

Last edited by SkumTomteN; 07-28-2018 at 15:37.
SkumTomteN is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-28-2018 , 16:32   Re: Max Z Stock
Reply With Quote #38

Quote:
Originally Posted by SkumTomteN View Post
Would this not be inaccurate?
This will vary based on the entity being moved to the result origin so the value will need to be dynamic. May need to find the Z of the ceiling of the entity and use that to determine the minus offset.
__________________
Bugsy is offline
SkumTomteN
Veteran Member
Join Date: Oct 2013
Location: Asgard
Old 02-01-2019 , 18:07   Re: Max Z Stock
Reply With Quote #39

i belivieve traceline would be most accurate, i have used the stock i posted alot, it works well.
__________________
Contact: Steam
Videos: Youtube
SkumTomteN 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 17:58.


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