• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

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,223
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