• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

random spawn location

Status
Not open for further replies.
Level 5
Joined
Aug 24, 2010
Messages
133
id like to make it so when a player picks a hero it spawns at a random set location where there isnt another unit already otherwise if all the areas are filled then spawn anywhere where there are no units in 2000

thanks for help
 
Level 3
Joined
Jul 13, 2010
Messages
46
you can do :
  • Actions
  • Variable - set spawnpoint - random point in "region"
  • Unit Group - pick enery unit in units within 2000 of spawnpoint matching boolean - owner of matching is an enemy of "owner of spawning unit"equal to true and do multiple actions
  • Loop - Actions
  • Unit - Move picked unit instantly to posision of picked unit offset by 2000 towards random integer between 0 and 360
it doesn't actually picks the region but makes way.hope it helps.
 
Level 18
Joined
Mar 7, 2005
Messages
824
Player picks a Hero
ll
v

Create new Hero for Player in Region[x] (while x is a random value between all available regions. e.g. you're using 5 regions, x will be a random number between 1 and 5)
l
l->
If Number of Units in Region of last created Hero is greater than 1 move hero to Region[x] (while choosing a new x value)
l
'->
If not, Do nothing :)

You could turn on some timer, for 1 second or 2, and then just create it in a region of your choice, because if the hero was not created after the timer expires, there were units in every region, and no hero would be created, it will be an endless loop. So you have to stop the loop manually with a timer, like timer expires: end player picks a hero and create the hero manually. Or using the 2000 Range limit of yours.

*edit*
bloody_Mage was faster with a good solution, damn! :)
 
Level 5
Joined
Aug 24, 2010
Messages
133
if i were to move the unit it would reveal the fog wouldnt it even if the unit is there for half a trigger
cause im using complete black fog

what i been trying is
  • Set ran_num = (Random integer number between 1 and 5)
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (start area 1 <gen> contains No unit) Equal to True
      • ran_num Equal to 1
    • Then - Actions
      • Unit - Create 1 hero_p1[(Player number of (Triggering player))] for (Triggering player) at (Random point in region[ran_num]) facing (Center of (Playable map area))
    • Else - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (start area 2 <gen> contains No unit) Equal to True
      • ran_num Equal to 2
    • Then - Actions
      • Unit - Create 1 hero_p1[(Player number of (Triggering player))] for (Triggering player) at (Random point in region[ran_num]) facing (Center of (Playable map area))
    • Else - Actions
  • -------- etc --------
but it always goes to the end not making any hero even though all the regions are free

is it possible to do looping with gui
say
  • Set temp_integer = 1
  • For each (Integer A) from 1 to temp_integer, do (Actions)
    • Loop - Actions
      • If - Conditions
  • -------- condition -------
    • Then - Actions
  • -------- action --------
    • Else - Actions
  • Set temp_integer = (temp_integer + 1)
 
Last edited:
Status
Not open for further replies.
Top