• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Random regions -with the variable being reduced

Status
Not open for further replies.
Level 8
Joined
Aug 8, 2008
Messages
340
Okay I'm a little new to the whole variable thing, so I need your guys help. I am to make two triggers:

1. A trigger which moves every hero unit in a region into one of 8 diffrent regions, but without placing more heroes in the same region.

2. A trigger which creates an item in one of 4 random regions when a hero dies, but without createing one in a region which already contains the same item.
 

yip

yip

Level 3
Joined
Jan 15, 2014
Messages
69
You should probably try to make the triggers yourself then post them here if they don't work...

Remember to look out for leaks (Center of Region, for example, leaks).

Also, you could use a Region array variable to store all your regions, and use the function 'Move unit instantly to 'YourRegionVariable[Random integer between 1 and *something*]' to randomize the regions which the unit(s) is(are) moved to. Same deal for creating items.

As for the conditions, you can check if there is already a hero/item in the region, and if there is, halt and rerun the trigger... that'll will give you a new random integer (And thus a new region). Just remember to stop the loop if all regions are occupied or the game will crash.

Those are just some pointers though :<
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
1. Create a Region Array and add the regions from 1 to 8. When moving the heroes to the regions, just Pick Every Unit matching (Matching unit) is a Hero = true and move them to region [IntegerVariable], then set IntegerVariable = IntegerVariable+1. Something like this

  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set RegionVar[0] = A
      • Set RegionVar[1] = B
      • Set RegionVar[2] = C
      • Set RegionVar[3] = D
      • ...
  • Melee Initialization
    • Events
      • Your Event...
    • Conditions
    • Actions
      • Set UnitGroupVar = (Units in (Playable map area) matching (((Matching unit) is A Hero) Equal to True))
      • Set IntegerVar = 0
      • Unit Group - Pick every unit in UnitGroupVar and do (Actions)
        • Loop - Actions
          • Set PointVar = (Center of RegionVar[IntegerVar])
          • Unit - Move (Picked unit) instantly to PointVar
          • Custom script: call RemoveLocation(udg_PointVar)
          • Set IntegerVar = (IntegerVar + 1)
      • Custom script: call DestroyGroup(udg_UnitGroupVar)
2. You can follow a similar logic than applied for #1, but with items instead

EDIT: Some fixes and changes made. Thanks to vypur85
 
Last edited:
Status
Not open for further replies.
Top