AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get ground Z from an origin (https://forums.alliedmods.net/showthread.php?t=327847)

Siveroo 10-13-2020 07:39

get ground Z from an origin
 
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
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();     } }

CrazY. 10-13-2020 08:05

Re: get ground Z from an origin
 
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.

HamletEagle 10-17-2020 04:56

Re: get ground Z from an origin
 
PHP Code:

getGroundOrigin(Float:origin[3])
{
    new 
Float:traceEnd[3]
    
traceEnd origin
    traceEnd
[2] = traceEnd[2] - 8192.0

    
new traceLineHandle create_tr2()
    
engfunc(EngFunc_TraceLineorigintraceEndIGNORE_MONSTERS0traceLineHandle)
    
get_tr2(traceLineHandleTR_vecEndPosorigin)
    
free_tr2(traceLineHandle)


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


All times are GMT -4. The time now is 13:50.

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