• 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.

Unit Group.

Status
Not open for further replies.
Level 6
Joined
Mar 2, 2013
Messages
127
So I need 3 random units from a group, and save them into var. The problem is the way I do it over writes the previous ones. Here Is my temp until I find a better way of doing it.

  • Unit Group - Pick every unit in (Random 1 units from Ka_Group[2]) and do (Actions)
    • Loop - Actions
      • Set Ka_Unit[12] = (Picked unit)
      • Set Ka_Point[9] = (Position of Ka_Unit[12])
  • Unit Group - Pick every unit in (Random 1 units from Ka_Group[2]) and do (Actions)
    • Loop - Actions
      • Set Ka_Unit[13] = (Picked unit)
      • Set Ka_Point[10] = (Position of Ka_Unit[13])
  • Unit Group - Pick every unit in (Random 1 units from Ka_Group[2]) and do (Actions)
    • Loop - Actions
      • Set Ka_Unit[14] = (Picked unit)
      • Set Ka_Point[11] = (Position of Ka_Unit[14])
 
Level 6
Joined
Mar 2, 2013
Messages
127
So something like this?

  • Set Ka_Int[10] = 11
  • Set Ka_Int[11] = 8
  • Unit Group - Pick every unit in (Random 3 units from Ka_Group[2]) and do (Actions)
    • Loop - Actions
      • Set Ka_Unit[(Ka_Int[10] + 1)] = (Picked unit)
      • Set Ka_Point[(Ka_Int[11] + 1)] = (Position of Ka_Unit[12])
EDIT: Ya it doesn't seem to record it correctly. Only one of the units are working .
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,255
Not particularly, I do not have the time to teach basic programming. However here is an example I hacked from your code that may or may not work since the code itself, with static indices, is not very logical.
  • Set Ka_Int[10] = 11
  • Set Ka_Int[11] = 8
  • Set LOOPINT = 1
  • Unit Group - Pick every unit in (Random 3 units from Ka_Group[2]) and do (Actions)
    • Loop - Actions
      • Set Ka_Unit[(Ka_Int[10] + LOOPINT)] = (Picked unit)
      • Set Ka_Point[(Ka_Int[11] + LOOPINT)] = (Position of (Picked unit))
      • Set LOOPINT = (LOOPINT + 1)
Note the code has had the "Position of" unit changed for correctness as the other one was illogical.
 
Status
Not open for further replies.
Top