AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Creating a room dynamically off the map (https://forums.alliedmods.net/showthread.php?t=40887)

Geesu 07-05-2006 13:31

Creating a room dynamically off the map
 
Basically I'd like to create a room that I could teleport players to...

But I want to be able to create the room for any given map (so make sure the room isn't planted somewhere where the map is in use)

Is this possible?

Thanks,
Josh

Hawk552 07-05-2006 14:24

Re: Creating a room dynamically off the map
 
Pick some random location, then scan upward and check PointContents each time. Once you hit a good spot, scan around it and if there's anything around it pick a new point.

Once you find enough space, make a bunch of func_walls or something to make a small room.

Geesu 07-05-2006 14:28

Re: Creating a room dynamically off the map
 
Think there is a code example anywhere?

Hawk552 07-05-2006 15:17

Re: Creating a room dynamically off the map
 
Quote:

Originally Posted by Geesu
Think there is a code example anywhere?

Here's a pseudo implementation of it minus the room (I dunno how big you want it)

Code:
// dist between center and shortest point of each wall #define ROOM_RADIUS 100.0 // the real thing is 4096.0, but we don't really want to go off the map #define MAP_MAX 3800.0 fnFindLocation(Float:vVec[3]) {     static Float:vOrigin[3],iContents         vOrigin[0] = random_float(-MAP_MAX,MAP_MAX)     vOrigin[1] = random_float(-MAP_MAX,MAP_MAX)         vOrigin[2] = -MAP_MAX         do     {         if(vOrigin[2] > MAP_MAX)             return fnFindLocation(vVec)                     vOrigin[2] += 10.0         iContents = PointContents(vOrigin)     }     while(iContents != CONTENTS_EMPTY)         vOrigin[2] += 200.0     if(PointContents(vOrigin) != CONTENTS_EMPTY)         return fnFindLocation(vVec)     vOrigin[2] -= 160.0         for(new iCount = 0;iCount < 2;iCount++)     {         vOrigin[iCount] += ROOM_RADIUS         if(PointContents(vOrigin) != CONTENTS_EMPTY)             return fnFindLocation(vVec)         vOrigin[iCount] -= ROOM_RADIUS                 vOrigin[iCount] -= ROOM_RADIUS         if(PointContents(vOrigin) != CONTENTS_EMPTY)             return fnFindLocation(vVec)         vOrigin[iCount] += ROOM_RADIUS     }             vVec = vOrigin         return PLUGIN_CONTINUE }

Geesu 07-05-2006 15:18

Re: Creating a room dynamically off the map
 
Awesome thanks, this will get me started :P Is there a downside to going off the map ??

Hawk552 07-05-2006 15:41

Re: Creating a room dynamically off the map
 
Quote:

Originally Posted by Geesu
Awesome thanks, this will get me started :P Is there a downside to going off the map ??

No, I guess it should really be

Code:
// dist between center and shortest point of each wall #define ROOM_RADIUS 100.0 // limits of the map #define MAP_MAX 4096.0 - ROOM_RADIUS

VEN 07-06-2006 15:52

Re: Creating a room dynamically off the map
 
I'd simply trace a few lines instead of looping.

Geesu 07-06-2006 15:52

Re: Creating a room dynamically off the map
 
Quote:

Originally Posted by VEN
I'd simply trace a few lines instead of looping.

Interesting... not a bad idea...

Hawk552 07-06-2006 17:43

Re: Creating a room dynamically off the map
 
Quote:

Originally Posted by VEN
I'd simply trace a few lines instead of looping.

I don't think that would work well, I haven't had good results with trace_line when using it off the map.

If it does though that's a good idea.


All times are GMT -4. The time now is 08:02.

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