View Single Post
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 04-27-2019 , 09:48   Re: Teleporting Player Check "Non-Stuck"
Reply With Quote #7

Quote:
Originally Posted by TheDS1337 View Post
Launch your trace from the said origin in the x/y/z direction, and check when it hits some other entity (including worldspawn), if the distance between the hit entity and the origin is less or equal 32 units in X/Y then you can't spawn there, same for Z axis, if it's greater then you can safely spawn there.

PS: I might support you with some code tomorrow. have a good night for now.

EDIT: Here it is,

...

I did only a few tests with this, you should try more and see if it works for "your" own special cases. also, as you can see you can't go on looping forever.. especially doing this kind of dirty work, this function is kinda heavy so I limited the number of trials, but in my most cases I got no more than 5 trials each so it's a good sign, and bare in mind, you can't go on using this everytime the player spawns, if it somehow worked for you, you should really be considering saving the corrected origins into some files once you generate them and then use them next time the map loads.
TheDS1337, that is some NICE looking code and work my friend. Thank you! I currently have a much more basic routine with traces setup to check -/+ X,Y,Z distances of the coordinates in relation to the player bounds and they are adjusted accordingly if needed. That method works great on flat world brushes but goes bad otherwise. I really appreciate your help and time with this, thank you again -- I will give this a go over the next few days and see what I can do with it.
__________________
{__ PIRATES COVE __} ● HIGH-KILL Community | Stats ●
Half-Life 2: Deathmatch
66.151.244.149:27016 => CONNECT
scorpius2k1 is offline