Raised This Month: $12 Target: $400
 3% 

ROG - A better random origin generator[NO HIDDEN ZONES UPDATE]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-28-2018 , 07:30   ROG - A better random origin generator[NO HIDDEN ZONES UPDATE]
Reply With Quote #1

ROG is an include file which allows you to generate random valid origins around the map. It could be used to create random player spawns or in Battle Royale mods(PUBG/Fortnite) to spawn the floor loot/drop crates/llamas, etc.

I know there are already 2 other includes that to the same thing(one made by joropito and one made by GHW_Chronic), but seeing how people complain that this 2 includes produce sometimes invalid points I decided to give it a try and see if I can make something that produces more consistent results in a shorter time.

Below are comparison results between superspawns and rog on some default and custom maps:

Spoiler


On average rog produces 3x more origins than superspawns.
On average rog generates origins 7.8x faster than superspawns.
Keep in mind that the number of origins depends on the minimum distance between points(in above tests 250 was used for both includes).

Functions:
1.ROGInitialize(Float:MinDistance, const CheckFunction[] = "") initializes the random origin generator and fills the arrays. MinDistance is the minimum distance between points. CheckFunction allows you to set custom conditions for origins.
2.ROGGetOrigin(Float:Origin[3]) retrieves a random origin. Note that once all origins are used it will start over, meaning it will never run out of points.
3.ROGShuffleOrigins() randomizes the origin array.
4.ROGDumpOriginData() shows all generated origins and their count.

Because rog is fast you can generate origins during runtime without freezing the server, meaning that at any point you can call again ROGInitialize() without any troubles.
If you don't want to call again ROGInitialize() but you also don't want to always spawn your entities in the same place you can use ROGShuffleOrigins which will randomize the origins.

Example code(which can also be used to manually check the generated origins):
PHP Code:
#include <amxmodx> 
#include <rog> 
#include <fakemeta> 

public plugin_init() 

    
ROGInitialize(250.0)
    
ROGDumpOriginData() 

    
register_clcmd("say /next""ClientCommand_NextOrigin"
    
register_clcmd("say /generate""ClientCommand_GenerateOrigins")
    
register_clcmd("say /shuffle""ClientCommand_ShuffleOrigins"


public 
ClientCommand_NextOrigin(id
{  
    
//get the next origin and spawn the player there
    
new Float:Origin[3
    
ROGGetOrigin(Origin
    
engfunc(EngFunc_SetOriginidOrigin
}  

public 
ClientCommand_GenerateOrigins(id
{  
    
//generate a new set of origins during runtime
    
ROGInitialize(250.0
}  

public 
ClientCommand_ShuffleOrigins(id
{  
    
//shuffle the existing set of origins
    
ROGShuffleOrigins()

Custom conditions:
Now you can add custom conditions for filtering origins, without editing the include file.
Example code:
PHP Code:
#include <amxmodx> 
#include <rog> 
#include <fakemeta> 

public plugin_init() 

    
ROGInitialize(250.0"CheckOrigin")
    
ROGDumpOriginData() 

    
register_clcmd("say /next""ClientCommand_NextOrigin"


public 
CheckOrigin(Float:origin[3])
{
    if(
origin[0] < -2000.0)
    {
        return 
0
    
}
    return 
1
}

public 
ClientCommand_NextOrigin(id
{  
    new 
Float:Origin[3
    
ROGGetOrigin(Origin
    
engfunc(EngFunc_SetOriginidOrigin

It will skip all origins that have origin[0] < -2000.0.
To skip an origin you have to return 0.
If you do not wish to use this feature simply leave the second param empty.

Credits:
edon for testing and ideas

Previous version downloads: 350
Attached Files
File Type: inc rog.inc (8.0 KB, 1012 views)
__________________

Last edited by HamletEagle; 02-16-2019 at 11:41.
HamletEagle is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-28-2018 , 12:53   Re: ROG - A better random origin generator
Reply With Quote #2

Awesome job
Also, I think you should mention that this value
PHP Code:
for(new 1<= 10000i++) 
can be reduced if you're not looking to find 500+ valid origins. It will reduce run-time of the plugin
__________________

Last edited by edon1337; 07-28-2018 at 17:01.
edon1337 is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 07-29-2018 , 09:03   Re: ROG - A better random origin generator
Reply With Quote #3

Tested a little, and got these feedbacks:

A check for de_mon map:

PHP Code:
if((fOrigin[2] <= -1000.0) || (fOrigin[2] >= 350.0)) 
Because it generates points under the map, if you guys didn't know, the de_mon map has another simple map under the original one. So with the <= -1000.0 it doesn't spawn entities there.
About the >= 350.0, it's generating points in the montains, which is bad, because players can drop there and camp forever.

The differences of the randomspawns that I found:

1. It has more checks for invalid points than the randomspawns
2. It generates the points more faster than the randomspawns
3. It generates more points than the randomspawns.

But, both generates goods and BADS points.

There are others maps with some blocked areas, like de_hotpoint and what I mentioned about the de_mon, it'll generate points there too. I don't know if there's a way to check that, but, that's a considerable issue.
That's my feedback for now...

de_mon simple map picture: http://prntscr.com/kce3zq
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-29-2018 , 09:07   Re: ROG - A better random origin generator
Reply With Quote #4

Quote:
Originally Posted by EFFx View Post
Tested a little, and got these feedbacks:

A check for de_mon map:

PHP Code:
if((fOrigin[2] <= -1000.0) || (fOrigin[2] >= 350.0)) 
Because it generates points under the map, if you guys didn't know, the de_mon map has another simple map under the original one. So with the <= -1000.0 it doesn't spawn entities there.
About the >= 350.0, it's generating points in the montains, which is bad, because players can drop there and camp forever.
We're already aware of the outside areas and the hill sides. I made a stock that can be used in maps where the outside area is underground (such as de_mon). As for the 'mountains' I still don't have a solution.

PHP Code:
public Float:GetValidPoint( )  
{  
    new 
Float:fPoint];  
    
fPoint] = GetLowestPoint( );  

    
fPoint] += 10.0;  
    while( ( 
engfuncEngFunc_PointContentsfPoint ) == CONTENTS_SOLID ) || ( engfuncEngFunc_PointContentsfPoint ) == CONTENTS_WATER ) )  
    {  
        
fPoint] += 1.0;  
    }  
          
    new 
pcCurrent engfuncEngFunc_PointContents fPoint );  
          
    if( 
pcCurrent == CONTENTS_EMPTY )  
    return 
fPoint];  
          
    return 
0.0;  
}  

public 
Float:GetLowestPoint( )  
{  
    new 
pcCurrent;  
    new 
Float:fStartingOffset];  
      
    while( ( 
engfuncEngFunc_PointContentsfStartingOffset ) == CONTENTS_SOLID ) || ( engfuncEngFunc_PointContentsfStartingOffset ) == CONTENTS_WATER ) || ( engfuncEngFunc_PointContentsfStartingOffset ) == CONTENTS_EMPTY ) )  
    {  
        
fStartingOffset] -= 5.0;   
    }  
      
    
pcCurrent engfuncEngFunc_PointContents fStartingOffset );   

    if( 
pcCurrent == CONTENTS_SKY )  
    return 
fStartingOffset];  
      
    return 
0.0;  

Usage
PHP Code:
new Float:fLowestPoint GetValidPoint( ); 
FYI, -350.0 is a non stuck-free origin in de_mon. ~ -420.0 is the minimum.
__________________

Last edited by edon1337; 07-29-2018 at 09:09.
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-29-2018 , 09:16   Re: ROG - A better random origin generator
Reply With Quote #5

About this "bad spots", from the point of view of the checks the points are fully valid, meaning a player can fit there without being stuck.
I tried to find a way to filter outside map areas or areas where the player can't get out but I failed.

So yeah, I don't know how we could filter out this points, because again, they are valid spots. Maybe we could run some kind of pathfinding algorithm and if it fails we could assume it's a bad spot and ignore this origin.
The downside is the execution time will be increased tremendously and such algorithms are not easy to implement.
__________________
HamletEagle is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-29-2018 , 09:21   Re: ROG - A better random origin generator
Reply With Quote #6

Quote:
Originally Posted by HamletEagle View Post
About this "bad spots", from the point of view of the checks the points are fully valid, meaning a player can fit there without being stuck.
I tried to find a way to filter outside map areas or areas where the player can't get out but I failed.

So yeah, I don't know how we could filter out this points, because again, they are valid spots. Maybe we could run some kind of pathfinding algorithm and if it fails we could assume it's a bad spot and ignore this origin.
The downside is the execution time will be increased tremendously and such algorithms are not easy to implement.
Is there any method on making an entity slide down if the place is steepy?
__________________

Last edited by edon1337; 07-29-2018 at 09:24.
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-29-2018 , 09:28   Re: ROG - A better random origin generator
Reply With Quote #7

Yes, with some knowledge about traceline and vectors you can do that.
__________________
HamletEagle is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-29-2018 , 09:31   Re: ROG - A better random origin generator
Reply With Quote #8

Quote:
Originally Posted by HamletEagle View Post
Yes, with some knowledge about traceline and vectors you can do that.
Then you got your answer how to do it without using pathfinding, these hills are all steepy. Though there's nothing in the forum about this..
__________________

Last edited by edon1337; 07-29-2018 at 09:31.
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-29-2018 , 09:34   Re: ROG - A better random origin generator
Reply With Quote #9

This would be a fix for a specific map. If we start creating custom code for every possible map we are not accomplishing anything.
If you guys need more checks for your mods you are free to modify the include in any way.
__________________
HamletEagle is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-29-2018 , 09:37   Re: ROG - A better random origin generator
Reply With Quote #10

Quote:
Originally Posted by HamletEagle View Post
This would be a fix for a specific map. If we start creating custom code for every possible map we are not accomplishing anything.
If you guys need more checks for your mods you are free to modify the include in any way.
I've never seen any hills in any other map, I think de_mon is the only one
__________________
edon1337 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 04:37.


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