Raised This Month: $32 Target: $400
 8% 

Solved [ H3LP ] Distance to ground


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 09-13-2018 , 11:12   [ H3LP ] Distance to ground
Reply With Quote #1

Hello, is there something wrong with this function that returns distance between entity and ground. If the entity "is not on ground", it returns normal value. Now if the entity is on or under of the ground, it returns 9999.0. Any ideas?

Code:
Float:DistanceToGround(this) {     static Float:flFraction, Float:vecStart[3], Float:vecEnd[3];     entity_get_vector(this, EV_VEC_origin, vecStart);     xs_vec_set(vecEnd, vecStart[0], vecStart[1], vecStart[2] - 9999.0);     //engfunc(EngFunc_TraceLine, vecStart, vecEnd, IGNORE_MONSTERS, this, 0);     engfunc(EngFunc_TraceHull, vecStart, vecEnd, IGNORE_MONSTERS, HULL_HEAD, this, 0);     //global_get(glb_trace_fraction, flFraction);     get_tr2(0, TR_flFraction, flFraction);         return flFraction * 9999.0; }
__________________









Last edited by CrazY.; 09-13-2018 at 14:48.
CrazY. is offline
Garey
Member
Join Date: Feb 2008
Location: Russian Federation
Old 09-13-2018 , 12:13   Re: [ H3LP ] Distance to ground
Reply With Quote #2

Why not using fm_distance_to_floor from fakemeta_util ?
__________________
Sorry for my bad english
Garey is offline
Send a message via ICQ to Garey
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 09-13-2018 , 12:34   Re: [ H3LP ] Distance to ground
Reply With Quote #3

Same issue, but now returning 7848.52.
__________________








CrazY. is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 09-13-2018 , 12:56   Re: [ H3LP ] Distance to ground
Reply With Quote #4

dont return/stamp if its equal to that number, cuz you only need distance above the ground ?
JocAnis is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 09-13-2018 , 13:05   Re: [ H3LP ] Distance to ground
Reply With Quote #5

Well, for my purpose looks working fine, but maybe it won't work at another situations. I will keep the post opened, case anyone have other suggestion.

Code:
Float:DistanceToGround(this) {     static Float:flFraction, Float:vecStart[3], Float:vecEnd[3];     entity_get_vector(this, EV_VEC_origin, vecStart);     xs_vec_set(vecEnd, vecStart[0], vecStart[1], vecStart[2] - 9999.0);     //engfunc(EngFunc_TraceLine, vecStart, vecEnd, IGNORE_MONSTERS, this, 0);     engfunc(EngFunc_TraceHull, vecStart, vecEnd, IGNORE_MONSTERS, HULL_HEAD, this, 0);     //global_get(glb_trace_fraction, flFraction);     get_tr2(0, TR_flFraction, flFraction);         if (flFraction == 1.0)         return 0.0;     //flFraction *= 9999.0;     return flFraction * 9999.0; }
__________________









Last edited by CrazY.; 09-13-2018 at 13:06.
CrazY. is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 09-13-2018 , 14:03   Re: [ H3LP ] Distance to ground
Reply With Quote #6

Just check if the player is on ground and return 0.
__________________
klippy is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 09-13-2018 , 14:18   Re: [ H3LP ] Distance to ground
Reply With Quote #7

The purpose is not check if player is on the ground. Basically, the entity is set in player's aim origin, but must keep on ground, that means, x/y based on player's view angle origin and z based on ground. So what I did was subtract distance from vecOrigin[2]. Anyway, the code still is not working properly.
__________________









Last edited by CrazY.; 09-13-2018 at 14:20.
CrazY. is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 09-13-2018 , 14:22   Re: [ H3LP ] Distance to ground
Reply With Quote #8

Why not use TraceLine & get vecEndPos?
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM
Ghosted is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 09-13-2018 , 14:24   Re: [ H3LP ] Distance to ground
Reply With Quote #9

Because if player aim at the sky or wall, the entity don't keep on ground, on the contrary, it floats. Or you mean traceline in DistanceToGround function?
__________________









Last edited by CrazY.; 09-13-2018 at 14:26.
CrazY. is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 09-13-2018 , 14:28   Re: [ H3LP ] Distance to ground
Reply With Quote #10

Quote:
Originally Posted by CrazY. View Post
Because if player aim at the sky or wall, the entity don't keep on ground, on the contrary, it floats. Or you mean traceline in DistanceToGround function?
Why we need player aim, just get origin and subtract from 3rd dimension maximum value to get endorigin for traceline?
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM
Ghosted 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 00:27.


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