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

Solved Max Z Stock


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-13-2018 , 10:38   Max Z Stock
Reply With Quote #1

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;

__________________

Last edited by edon1337; 07-28-2018 at 06:04.
edon1337 is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 07-13-2018 , 12:16   Re: Max Z Stock
Reply With Quote #2

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.
__________________

[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 07-13-2018 , 14:50   Re: Max Z Stock
Reply With Quote #3

You can try to convert this util to amxx and work with sky instead.

Spoiler
__________________









Last edited by CrazY.; 07-13-2018 at 14:52.
CrazY. is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-13-2018 , 15:32   Re: Max Z Stock
Reply With Quote #4

Quote:
Originally Posted by CrazY. View Post
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
__________________

Last edited by edon1337; 07-13-2018 at 15:33.
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-13-2018 , 15:45   Re: Max Z Stock
Reply With Quote #5

new Float:sth[3]
__________________
HamletEagle is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-13-2018 , 16:53   Re: Max Z Stock
Reply With Quote #6

Quote:
Originally Posted by HamletEagle View Post
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?
__________________
edon1337 is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 07-13-2018 , 17:03   Re: Max Z Stock
Reply With Quote #7

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]...)
__________________

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


Probably Left AM

Last edited by Ghosted; 07-13-2018 at 17:04.
Ghosted is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-13-2018 , 17:52   Re: Max Z Stock
Reply With Quote #8

Quote:
Originally Posted by Ghosted View Post
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];
    }

__________________

Last edited by edon1337; 07-13-2018 at 17:57.
edon1337 is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-13-2018 , 18:14   Re: Max Z Stock
Reply With Quote #9

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];
    }

__________________

Last edited by edon1337; 07-13-2018 at 18:14.
edon1337 is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 07-13-2018 , 18:52   Re: Max Z Stock
Reply With Quote #10

You can actually just assign an array to another one that's greater or equal in size.
__________________
klippy 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 05:34.


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