AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Max Z Stock (https://forums.alliedmods.net/showthread.php?t=309087)

edon1337 07-13-2018 10:38

Max Z Stock
 
Hi,

I have this stock that finds the highest point on the map by adding velocity until we reach CONTENTS_SKY, but sometimes it randomly spawns me on the ground. Are there any better stocks or any improvements to be done to this stock? I believe it spawns me to the ground because neither of the loops happen and return 0.0 is the return value, but why?

PHP Code:

Float:GetMaxHeightid 

    new 
Float:fOrigin], Float:fDist
    
pevidpev_originfOrigin ); 
    
    
fDist fOrigin]; 
    
    while( 
engfuncEngFunc_PointContentsfOrigin ) == CONTENTS_EMPTY 
    
fOrigin] += 5.0
    
    if( 
engfuncEngFunc_PointContentsfOrigin ) == CONTENTS_SKY 
    return ( 
fOrigin] - fDist ); 
    
    return 
0.0;



Ghosted 07-13-2018 12:16

Re: Max Z Stock
 
As code says, if you go upwards before reach other than CONTENTS_EMPTY, you will then check if that place is CONTENTS_SKY & if not it will return zero. I think you need to add some content checks.

CrazY. 07-13-2018 14:50

Re: Max Z Stock
 
You can try to convert this util to amxx and work with sky instead.

Spoiler

edon1337 07-13-2018 15:32

Re: Max Z Stock
 
Quote:

Originally Posted by CrazY. (Post 2603369)
You can try to convert this util to amxx and work with sky instead.

Spoiler

Is vector an array in Pawn? How do we even convert this to Pawn..
PHP Code:

    Vector midUp;
    
float diff;

    
midUp position


HamletEagle 07-13-2018 15:45

Re: Max Z Stock
 
new Float:sth[3]

edon1337 07-13-2018 16:53

Re: Max Z Stock
 
Quote:

Originally Posted by HamletEagle (Post 2603377)
new Float:sth[3]

yea but we don't simply do this in Pawn

PHP Code:

new Float:sth[3]
new 
Float:sth2[3]

sth sth2 

Should I just loop and pass values like
PHP Code:

sth] = sth2

with a loop?

Ghosted 07-13-2018 17:03

Re: Max Z Stock
 
Not loop just use 0,1,2 or use xs. You can't assign Vector to Vector cause theres no = operator, but they are same (VecA = VecB & VecA[0] = VecB[0]...)

edon1337 07-13-2018 17:52

Re: Max Z Stock
 
Quote:

Originally Posted by Ghosted (Post 2603385)
Not loop just use 0,1,2 or use xs. You can't assign Vector to Vector cause theres no = operator, but they are same (VecA = VecB & VecA[0] = VecB[0]...)

Do you even read what I write or you just post unknowingly? I basically just stated that I'm aware you can't assign values as in C++ here in Pawn and that we need to go through both of the arrays dimensions at the same time and assign values.

PHP Code:

public MyFunction( )
{
    new 
aArray], bArray];
    
MixArraysaArraybArray );
}

MixArraysaArray[ ], bArray[ ] )
{
    for( new 
i3i++ )
    {
        
aArray] = bArray];
    }



edon1337 07-13-2018 18:14

Re: Max Z Stock
 
I pretty much converted the first stock, all left is to test it, Crazy where did you find these stocks?
PHP Code:

Float:UTIL_SkyLevel( const iOrigin], Float:iMinZFloat:iMaxZ )
{
    new 
iMidUp], iMidUpZ];
    
Float:fDiff;

    
MixArraysiMidUpiOrigin );
    
MixArraysiMidUpZiMinZ );

    if( 
engfuncEngFunc_PointContentsiMidUp ) != CONTENTS_SKY )
    return 
iMinZ;

    
iMidUpZ iMaxZ;
    
    if( 
engfuncEngFunc_PointContentsiMidUp ) == CONTENTS_SKY )
    return 
iMaxZ;

    
fDiff iMaxZ iMinZ;
    
    while( 
fDiff )
    {
        
iMidUpZ iMiNZ fDiff 2;
        
        if( 
engfuncEngFunc_PointContentsiMidUp ) == CONTENTS_SKY )
            
iMinZ iMidUpZ;
            
        else
            
iMaxZ iMidUpZ;

        
fDiff iMaxZ iMinZ;
    }
    return 
iMidUpZ;
}

MixArraysaArray[ ], bArray[ ] )
{
    for( new 
i3i++ )
    {
        
aArray] = bArray];
    }



klippy 07-13-2018 18:52

Re: Max Z Stock
 
You can actually just assign an array to another one that's greater or equal in size.


All times are GMT -4. The time now is 17:27.

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