Raised This Month: $147 Target: $400

get ground Z from an origin

Post New Thread Reply   
Thread Tools Display Modes
Author Message
Junior Member
Join Date: Apr 2020
Old 10-13-2020 , 08:39   get ground Z from an origin
Reply With Quote #1

I don't know how to phrase the title correctly, so im going to explain my problem here.

Basically i just wanna make a function that spreads flame in random coordinate in the spesific radius. I managed to do that, but the problem is that, if the flame spreads on air, the "fire" sprites are also floating on air, to fix this, i think im going to modify the sprite's origin so that it will show the sprites on the ground. (The x and y axis is fine, just need to modify the z axis)

So, my question is that how do i get from a normal origin to the new origin that is actually placed on the ground.

I think it's like "EngFunc_DropToFloor" but for an origin instead of an entity

This is the actual code
stock random_fire(iOrigin[3], max_radius, count) {         for(new i = 0; i < count; i++){                 new Float:rand_coord[2]         new Float:theta         new Float:r         new Float:rand[2]                 new randomSize = random_num(7,12)                 rand[0] = random_float(0.0, 1.0);         rand[1] = random_float(0.0, 1.0);         r = max_radius * rand[0]         theta = rand[1] * 7         rand_coord[0] = r*floatcos(theta, radian)         rand_coord[1] = r*floatsin(theta, radian)                 message_begin(MSG_BROADCAST, SVC_TEMPENTITY);         write_byte(TE_SPRITE);         write_coord(iOrigin[0] + floatround(rand_coord[0]));         write_coord(iOrigin[1] + floatround(rand_coord[1]));         write_coord(iOrigin[2]);         write_short(firespr);         write_byte(randomSize);         write_byte(255);         message_end();     } }
Siveroo is offline
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 10-13-2020 , 09:05   Re: get ground Z from an origin
Reply With Quote #2

What you will need is EngFunc_TraceLine. Subtracting 9999 from the start position z axis you'll get the end position. Trace a line using those positions and get the result of TR_vecEndPos.
Accepting private $$$ plugins requests.

@Steam: crazy770
@Discord: CrazY.#5317

Website | Channel

CrazY. is offline
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-17-2020 , 05:56   Re: get ground Z from an origin
Reply With Quote #3

PHP Code:
traceEnd origin
[2] = traceEnd[2] - 8192.0

new traceLineHandle create_tr2()

The function will change "origin" to hold the ground origin. If you still need the previous value, create a backup before calling getGroundOrigin.

Last edited by HamletEagle; 10-17-2020 at 05:58.
HamletEagle is offline

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 22:46.

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