• 🏆 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!

Create a Unit Group on a random point

Status
Not open for further replies.
Level 4
Joined
Jun 3, 2012
Messages
92
Hello! I am making a 2D map and just missing the triggers, in one of them i do not know how to do:


I need that units groups are created next to the hero of the player(No in a fixed range, but in a random distance from hero and not so far away). When the player Advance on stage, this unit group change (stronger units will be created). When the enemy units are created, they will advance directly to the player.

I thought in use a region and use a random point to create the units, but this could create enemies far away from where the player is

So... How i do to create groups of units on a random point within a certain range of the player?

And sorry my bad english.
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
set loc = (whatever location)
set loc = loc with polar offset of (random real between minRange and maxRange) at (random real between 1 and 360) degrees.
units - create # units at loc
call removelocation(loc)
 
Level 12
Joined
Sep 11, 2011
Messages
1,176
set loc = (whatever location)
set loc = loc with polar offset of (random real between minRange and maxRange) at (random real between 1 and 360) degrees.
units - create # units at loc
call removelocation(loc)

you're leaking the first loc, should be loc and loc2 (an overwritten point will produce leaks).

  • Set loc = (Position of (YourHero))
  • Set loc2 = loc offset of (random real between minRange and maxRange) at (random angle) degrees
  • Unit - Create YourUnit at loc2
  • Custom script: call RemoveLocation (udg_loc)
  • Custom script: call RemoveLocation (udg_loc2)
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
you're leaking the first loc, should be loc and loc2

  • Set loc = (Position of (YourHero))
  • Set loc2 = loc offset of (random real between minRange and maxRange) at (random angle) degrees
  • Unit - Create YourUnit at loc2
  • Custom script: call RemoveLocation (udg_loc)
  • Custom script: call RemoveLocation (udg_loc2)

oh yeah forgot about that
 
Level 4
Joined
Jun 3, 2012
Messages
92
Oh will try!!! Ty for now! *-* !

*edit*

testwxn.jpg



Well, this form? nothing happens D:!
 
Last edited:
Level 33
Joined
Mar 27, 2008
Messages
8,035
Try this;
  • Melee Initialization
    • Events
      • Unit - A unit enters Estrada 1 <gen>
    • Conditions
      • (Triggering unit) Equal to Blood Mage 0011 <gen>
    • Actions
      • Set TempLoc = (Position of (Triggering unit))
      • Set TempLoc2 = (TempLoc offset by (Random real number between 0.00 and 800.00) towards (Random angle) degrees)
      • Unit - Create 5 Footman for Player 1 (Red) at TempLoc2 facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_TempLoc)
      • Custom script: call RemoveLocation(udg_TempLoc2)
      • Trigger - Turn off (This trigger)
Make sure to turn off the trigger so that it won't spawn again the waves if you accidentally steps on the region again.
 
Status
Not open for further replies.
Top