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

Muiltiboard question/problem

Status
Not open for further replies.
Level 15
Joined
Jul 9, 2008
Messages
1,552
ok iv got a muiltiboard and when you select a hero the heros icon shows up on the muiliboard

its simple to add the icons to the muiltiboard

but i have a feature where you can random your hero how do i set the icon to the randomed hero??
 
Level 15
Joined
Jul 9, 2008
Messages
1,552
alright thanks

EDIT so somthing like this

  • Random set up
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Random_hero[1] = Holy Knight
      • Set Hero_icon[1] = ReplaceableTextures\CommandButtons\BTNArthas.blp
  • ...ect
  • random hero
    • Events
      • Player - Player 1 (Red) types a chat message containing -random as An exact match
      • Player - Player 2 (Blue) types a chat message containing -random as An exact match
      • Player - Player 3 (Teal) types a chat message containing -random as An exact match
      • Player - Player 4 (Purple) types a chat message containing -random as An exact match
      • Player - Player 5 (Yellow) types a chat message containing -random as An exact match
      • Player - Player 6 (Orange) types a chat message containing -random as An exact match
      • Player - Player 7 (Green) types a chat message containing -random as An exact match
      • Player - Player 8 (Pink) types a chat message containing -random as An exact match
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • hero_randomed[(Player number of (Triggering player))] Equal to False
        • Then - Actions
          • Game - Display to (All players) the text: (coulors[(Player number of (Triggering player))] + |r has randomed)
          • Set hero_randomed[(Player number of (Triggering player))] = True
          • Set Temp_Group = (Units in hero selection area <gen> owned by (Triggering player))
          • Unit Group - Pick every unit in Temp_Group and do (Actions)
            • Loop - Actions
              • Unit - Remove (Picked unit) from the game
          • Set Randomnumber = (Random integer number between 1 and Number of heros)
          • Custom script: call DestroyGroup ( udg_Temp_Group)
          • Unit - Create 1 Random_hero[Randomnumber] for (Triggering player) at temp_point facing Default building facing degrees
          • Multiboard - Set the icon for Muiltiboard item in column 1, row ((Player number of (Triggering player)) + 1) to Hero_icon[Randomnumber]
        • Else - Actions
          • Game - Display to (Player group((Triggering player))) the text: You already have a hero
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Dont remove the unit group (call DestroyGroup (udg_Temp_Group) or you wont be able to use that specific unit group again.
That's the point... he never WANTS to use it again, so he destroys it.
If he didn't destroy it, then it would've caused a memory leak, memory leaks cause lag and always have to be fixed.

User Title said:
Jass<Noobs GUI=Pro[20000]
I just proved that statement wrong, as you can only fix most memory leaks (and thus reduce lag) with JASS.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
It's a unit group,but if you destroy it,it will remove it forever (until you play again that is)
Uhm wait, I think you're mistaken.


This works:
  • Actions
    • Set TempGroup = (Units owned by Player 1 (Red))
    • Unit Group - Pick every unit in TempGroup and do (Actions)
      • Loop - Actions
        • Game - Display to (All players) the text: (Name of (Picked unit))
    • Custom script: call DestroyGroup(udg_TempGroup)
    • -------- --------
    • Set TempGroup = (Units owned by Player 2 (Blue))
    • Unit Group - Pick every unit in TempGroup and do (Actions)
      • Loop - Actions
        • Game - Display to (All players) the text: (Name of (Picked unit))
    • Custom script: call DestroyGroup(udg_TempGroup)
The unit group can still be used!


millzy, please don't pay any attention :D
Destroying the group must be done! The only way it will affect the game is by reducing lag, which is a good thing.
You can use the unit group variable any time you want, even after destroying it (as it doesn't destroy the variable itself).
 
Level 11
Joined
Aug 6, 2009
Messages
697
Uhm wait, I think you're mistaken.


This works:
  • Actions
    • Set TempGroup = (Units owned by Player 1 (Red))
    • Unit Group - Pick every unit in TempGroup and do (Actions)
      • Loop - Actions
        • Game - Display to (All players) the text: (Name of (Picked unit))
    • Custom script: call DestroyGroup(udg_TempGroup)
    • -------- --------
    • Set TempGroup = (Units owned by Player 2 (Blue))
    • Unit Group - Pick every unit in TempGroup and do (Actions)
      • Loop - Actions
        • Game - Display to (All players) the text: (Name of (Picked unit))
    • Custom script: call DestroyGroup(udg_TempGroup)
The unit group can still be used!


millzy, please don't pay any attention :D
Destroying the group must be done! The only way it will affect the game is by reducing lag, which is a good thing.
You can use the unit group variable any time you want, even after destroying it (as it doesn't destroy the variable itself).
Everytime I use call RemoveGroup though,it removes it and can't be used until restartion of the game etc.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Everytime I use call RemoveGroup though,it removes it and can't be used until restartion of the game etc.
Then you've done something wrong :|

If you use JASS, you're right: those cannot be used again.
But that's because in GUI a new group is created every time you set a group variable to something.

Hence the reason it leaks: every time a new group is created, it leaks -> a new group is created every time you set it to something.



Picking all units of a certain player looks like this in JASS:

JASS:
function GetUnitsOfPlayerMatching takes player whichPlayer returns group
    local group g = CreateGroup()
    call GroupEnumUnitsOfPlayer(g, whichPlayer, null)
    return g
endfunction

As you can see, a new group is created and transferred to the global variable.


However, if you use JASS, you do something like this:

JASS:
call GroupEnumUnitsOfPlayer(udg_Group, Player(X), null)
No new group is created, thus if you destroy the group and then use the above function, it won't work.
That's because there is no group to set the units in.


I hope you got all of this.
 
Status
Not open for further replies.
Top