Raised This Month: $ Target: $400
 0% 

Find proper origin to spawn.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Jacob
Senior Member
Join Date: Oct 2010
Old 12-31-2010 , 23:35   Find proper origin to spawn.
Reply With Quote #1

PHP Code:
new ent create_entity("info_target")
entity_set_origin(entorigin)
... 
my question is that if spawn 5 or more ents when round start,how to make sure the distance between two ents is more than 500,if distance<500,then make a loop to find another origin to spawn till find a proper one.
thanks in advance.
Jacob is offline
Elusive138
Senior Member
Join Date: Dec 2010
Old 01-01-2011 , 03:00   Re: Find proper origin to spawn.
Reply With Quote #2

You can use if (get_distance_f(origin1, origin2) < 500.0) and get a new origin, or some variation.
Elusive138 is offline
Jacob
Senior Member
Join Date: Oct 2010
Old 01-01-2011 , 03:11   Re: Find proper origin to spawn.
Reply With Quote #3

Quote:
Originally Posted by Elusive138 View Post
You can use if (get_distance_f(origin1, origin2) < 500.0) and get a new origin, or some variation.
please show the full example.
Jacob is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-01-2011 , 03:50   Re: Find proper origin to spawn.
Reply With Quote #4

Show your full code in getting the first original origin.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Jacob
Senior Member
Join Date: Oct 2010
Old 01-01-2011 , 04:23   Re: Find proper origin to spawn.
Reply With Quote #5

Quote:
Originally Posted by Exolent[jNr] View Post
Show your full code in getting the first original origin.
i tested the RuneMod plugin today, found that sometimes two or three runes spawned at a same location,so i thought this part of code is not that good.

PHP Code:
new EntNum SpawnRune(RuneIndex,g_SpawnOrigin[SpawnPoint]) // We spawn the rune
    
new LocStatus CheckDistance(EntNum,SpawnPoint)     // We check the the Spawn location the rune was spawned at, and 
    
    
if(LocStatus == 2)   // This means the newly spawned rune was to close to 1 of the other runes. We now try 5 random other locations to see if their free
    
{
     new 
CPS=0   // Just incase, we will only check 5 diffrent spawn locations
     
while( LocStatus == && CPS 5)
     {
      
CPS++
      
SpawnPoint random_num(1,g_NumberOfSpawnPoints)
      
LocStatus CheckDistance(EntNum,SpawnPoint)
     }
     
set_origin(EntNum,g_SpawnOrigin[SpawnPoint])
    } 
PHP Code:
stock CheckDistance(EntNum,IndexInSpawnArray)  // This stuck is used to check the distance between where a rune is spawned, and the other runes ingame. To make sure their not spawned to close together
{
 new 
Origin[3]
 for(new 
i=0;i<=MAX_RUNESINGAME;i++) if(g_RuneEntNum[i][0] && g_RuneEntNum[i][0] != EntNum)
 {
  
get_origin(g_RuneEntNum[i][0],Origin)
  if(
get_distance(Origin,g_SpawnOrigin[IndexInSpawnArray]) < MIN_DISTANCE_BETWEEN_RUNES)
  {
   return 
2
  
}
 }
 return 
1

Jacob is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-01-2011 , 04:36   Re: Find proper origin to spawn.
Reply With Quote #6

Change MIN_DISTANCE_BETWEEN_RUNES to 500.

Also, if there are runes at all 5 origins that are checked first, the plugin will not continue to check for an empty one.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Jacob
Senior Member
Join Date: Oct 2010
Old 01-02-2011 , 01:37   Re: Find proper origin to spawn.
Reply With Quote #7

Quote:
Originally Posted by Exolent[jNr] View Post
Change MIN_DISTANCE_BETWEEN_RUNES to 500.

Also, if there are runes at all 5 origins that are checked first, the plugin will not continue to check for an empty one.
thanks!
Jacob is offline
Reply



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 01:50.


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