Raised This Month: $120 Target: $400
 30% 

Random locations generator


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 07-15-2010 , 15:09   Random locations generator
Reply With Quote #1

I will share with all this utility to generate random locations to be used as spawnpoints or whatever you want.

With this you can get random spawns with a minimum distance between each one.

I know there's other alternatives but didn't help me
Hawk Tutorial: http://forums.alliedmods.net/showthread.php?p=519409
Chronic's plugin: http://forums.alliedmods.net/showthread.php?p=669666
I'm using some checks to be sure the location will be suitable to spawn a player or and entity without problems:
  • Minimum distance between points on first pass
  • Check for empty point contents
  • Check for hull (HULL_LARGE)
  • Avoiding locations near sky (250.0 units)
  • Avoiding water and other surfaces on floor
  • Visibility between consecutive points (to get "in map" points)

I tested this on some standard and custom maps without problems.

Sometimes you can get a location over a box but you can check that outside this utility. Also I worked to avoid ceiling locations.

I will be glad with feedback about useless locations (outside map, non stuck-free locations, etc).

Ideas and improvements are welcome too.

Here's an example on how to use the included file

PHP Code:
#include <amxmodx>
#include <superspawns>

public plugin_init()
{
    
// First we have to initialize the arrays and parameters
    // The value 3500.0 is the minimum distance between points
    // Nearest points will be found, but GetOrigin will erase points
    // with less than 3500.0 distance with other used points and return
    
SsInit(3500.0)

    
// Let start scanning the map
        
SsScan()

    
// This call is to dump on server logs the origins found
        
SsDump()

    
// This command will call GetOrigin() to get a new location, then spawn a model (is't just an example)
        
register_concmd("spawnent""spawnent")
}

public 
spawnent(id)
{
        new 
Float:origin[3]

    
// SsGetOrigin() will return true if useful location was found
    // will return false if there's no more usefull locations

        
if(SsGetOrigin(origin))
        {
                new 
ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"))
                if(
pev_valid(ent))
                {
                        
engfunc(EngFunc_SetModelent"models/player/sas/sas.mdl")
                        
engfunc(EngFunc_SetOriginentorigin)
                }
        }
        else
        {
                
server_print("No more locations")
        }

        return 
PLUGIN_HANDLED

Attached Files
File Type: inc superspawns.inc (4.6 KB, 1253 views)
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.

Last edited by joropito; 07-15-2010 at 17:09.
joropito is offline
Send a message via MSN to joropito
xPaw
AMX Mod X Moderator
Join Date: Jul 2008
Old 07-15-2010 , 15:31   Re: Random locations generator
Reply With Quote #2

Well done, will be using this for sure
__________________
xPaw is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 07-15-2010 , 15:35   Re: Random locations generator
Reply With Quote #3

Good job joro.
I would have posted this tutorial if I would have worked on runemodx. When I was at the start of the project I wanted to improve what Chronic made, but no problem.
I now have what you did, good job again!
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 07-15-2010 , 15:45   Re: Random locations generator
Reply With Quote #4

joropito, you're the man.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
Quote:
Originally Posted by bash.org
<axle345> I mean seriosuly guys holocaust jokes aren't funny
<axle345> Anne Frankly, I won't stand for it.
wrecked_ is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 07-15-2010 , 17:06   Re: Random locations generator
Reply With Quote #5

awesome work.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 07-16-2010 , 01:02   Re: Random locations generator
Reply With Quote #6

Cool!!!!! i will use this. Nice job.
__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...
Alucard^ is offline
Send a message via Skype™ to Alucard^
infek
Senior Member
Join Date: May 2009
Location: Behind you
Old 07-21-2010 , 21:59   Re: Random locations generator
Reply With Quote #7

I've been looking for this, damn thanks
__________________
"Domo Arigato, Mr. Roboto!"
PM me if you want to know a secret
infek is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 07-21-2010 , 23:07   Re: Random locations generator
Reply With Quote #8

Currently I have a better than the one in firts post.

I will update as soon as possible.
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
5c0r-|3i0
Veteran Member
Join Date: Nov 2008
Location: Việt Nam
Old 07-31-2010 , 11:28   Re: Random locations generator
Reply With Quote #9

Cool....Thanks
5c0r-|3i0 is offline
Gadzislaw007
Senior Member
Join Date: Nov 2009
Old 07-31-2010 , 11:38   Re: Random locations generator
Reply With Quote #10

Oh, this is great. Will use... somewhen... for sure ;]
Gadzislaw007 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 09:26.


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