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

[Trigger] [GUI] Computer or not?

Status
Not open for further replies.
Level 12
Joined
Feb 11, 2008
Messages
809
Okay so i have a -ar (all random) trigger which will randomly give you 1 of 26 heros but when you type it in it will make heros for computers as well as actual players what trigger could i use to make it just allow players and not computers to get the random heros?
 
Level 8
Joined
Aug 3, 2008
Messages
391
Give it a condition.

  • Player Group - Pick every player in (All players) and do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • ((Picked player) controller) Equal to User
              • ((Picked player) slot status) Equal to Is playing
        • Then - Actions
        • Else - Actions
 
Level 12
Joined
Feb 11, 2008
Messages
809
Sadly i tried that and it still doesnt work heres the code:
  • allrandom
    • Events
      • Player - Player 1 (Red) types a chat message containing -ar as An exact match
      • Player - Player 1 (Red) types a chat message containing -all random as An exact match
    • Conditions
      • ((Units in UNITSCANTRANDOM <gen> owned by Player 1 (Red)) is empty) Equal to True
      • ((Units in UNITSCANTRANDOM <gen> owned by Player 2 (Blue)) is empty) Equal to True
      • ((Units in UNITSCANTRANDOM <gen> owned by Player 3 (Teal)) is empty) Equal to True
      • ((Units in UNITSCANTRANDOM <gen> owned by Player 4 (Purple)) is empty) Equal to True
      • ((Units in UNITSCANTRANDOM <gen> owned by Player 5 (Yellow)) is empty) Equal to True
      • ((Units in UNITSCANTRANDOM <gen> owned by Player 6 (Orange)) is empty) Equal to True
      • ((Units in UNITSCANTRANDOM <gen> owned by Player 7 (Green)) is empty) Equal to True
      • ((Units in UNITSCANTRANDOM <gen> owned by Player 8 (Pink)) is empty) Equal to True
      • ((Units in UNITSCANTRANDOM <gen> owned by Player 9 (Gray)) is empty) Equal to True
      • ((Units in UNITSCANTRANDOM <gen> owned by Player 10 (Light Blue)) is empty) Equal to True
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • ((Picked player) controller) Equal to User
                  • ((Picked player) slot status) Equal to Is playing
            • Then - Actions
              • Unit Group - Pick every unit in (Units in Region 045 <gen>) and do (Unit - Kill (Picked unit))
              • Set hero[1] = (First unit of group (Units owned by Player 1 (Red)))
              • Set hero[2] = (First unit of group (Units owned by Player 2 (Blue)))
              • Set hero[3] = (First unit of group (Units owned by Player 3 (Teal)))
              • Set hero[4] = (First unit of group (Units owned by Player 4 (Purple)))
              • Set hero[5] = (First unit of group (Units owned by Player 5 (Yellow)))
              • Set hero[6] = (First unit of group (Units owned by Player 6 (Orange)))
              • Set hero[7] = (First unit of group (Units owned by Player 7 (Green)))
              • Set hero[8] = (First unit of group (Units owned by Player 8 (Pink)))
              • Set hero[9] = (First unit of group (Units owned by Player 9 (Gray)))
              • Set hero[10] = (First unit of group (Units owned by Player 10 (Light Blue)))
              • Player - Set Player 1 (Red) Current gold to ((Player 1 (Red) Current gold) + 20)
              • Player - Set Player 2 (Blue) Current gold to ((Player 2 (Blue) Current gold) + 20)
              • Player - Set Player 3 (Teal) Current gold to ((Player 3 (Teal) Current gold) + 20)
              • Player - Set Player 4 (Purple) Current gold to ((Player 4 (Purple) Current gold) + 20)
              • Player - Set Player 5 (Yellow) Current gold to ((Player 5 (Yellow) Current gold) + 20)
              • Player - Set Player 6 (Orange) Current gold to ((Player 6 (Orange) Current gold) + 20)
              • Player - Set Player 7 (Green) Current gold to ((Player 7 (Green) Current gold) + 20)
              • Player - Set Player 8 (Pink) Current gold to ((Player 8 (Pink) Current gold) + 20)
              • Player - Set Player 9 (Gray) Current gold to ((Player 9 (Gray) Current gold) + 20)
              • Player - Set Player 10 (Light Blue) Current gold to ((Player 10 (Light Blue) Current gold) + 20)
              • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 1 (Red) at (Center of ENd1 <gen>) facing Default building facing (270.0) degrees
              • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 2 (Blue) at (Center of ENd1 <gen>) facing Default building facing (270.0) degrees
              • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 3 (Teal) at (Center of ENd1 <gen>) facing Default building facing (270.0) degrees
              • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 4 (Purple) at (Center of ENd1 <gen>) facing Default building facing (270.0) degrees
              • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 5 (Yellow) at (Center of ENd1 <gen>) facing Default building facing (270.0) degrees
              • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 6 (Orange) at (Center of ENd2 <gen>) facing Default building facing (270.0) degrees
              • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 7 (Green) at (Center of ENd2 <gen>) facing Default building facing (270.0) degrees
              • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 8 (Pink) at (Center of ENd2 <gen>) facing Default building facing (270.0) degrees
              • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 9 (Gray) at (Center of ENd2 <gen>) facing Default building facing (270.0) degrees
              • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 10 (Light Blue) at (Center of ENd2 <gen>) facing Default building facing (270.0) degrees
              • Camera - Pan camera for Player 1 (Red) to (Center of ENd1 <gen>) over 2.00 seconds
              • Camera - Pan camera for Player 2 (Blue) to (Center of ENd1 <gen>) over 2.00 seconds
              • Camera - Pan camera for Player 3 (Teal) to (Center of ENd1 <gen>) over 2.00 seconds
              • Camera - Pan camera for Player 4 (Purple) to (Center of ENd1 <gen>) over 2.00 seconds
              • Camera - Pan camera for Player 5 (Yellow) to (Center of ENd1 <gen>) over 2.00 seconds
              • Camera - Pan camera for Player 6 (Orange) to (Center of ENd2 <gen>) over 2.00 seconds
              • Camera - Pan camera for Player 7 (Green) to (Center of ENd2 <gen>) over 2.00 seconds
              • Camera - Pan camera for Player 8 (Pink) to (Center of ENd2 <gen>) over 2.00 seconds
              • Camera - Pan camera for Player 9 (Gray) to (Center of ENd2 <gen>) over 2.00 seconds
              • Camera - Pan camera for Player 10 (Light Blue) to (Center of ENd2 <gen>) over 2.00 seconds
              • Trigger - Turn off (This trigger)
            • Else - Actions
              • Do nothing
 
Level 8
Joined
Aug 3, 2008
Messages
391
Change your actions to:

  • Actions
    • Player Group - Pick every player in (All players) and do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • And - All (Conditions) are true
              • Conditions
                • ((Picked player) controller) Equal to User
                • ((Picked player) slot status) Equal to Is playing
          • Then - Actions
            • Set hero[(Player number of (Picked player))] = (First unit of unit group (Units owned by (Picked Player)))
            • Player - Set (Picked player) Current gold to (((Picked player) Current gold) + 20)
            • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for (Picked player) at (Center of (Playable map area)) facing Default building facing degrees
            • Camera - Pan camera for (Picked player) to (Center of (Playable map area)) over 2.00 seconds
          • Else - Actions
Just put another condition, for the region stuff.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
I don't think this leaks at all.

Then you aren't looking really good.


  • Player Group - Pick every player in (All players) and do (Actions)
  • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for (Picked player) at (Center of (Playable map area)) facing Default building facing degrees
This is one of your actions.



  • Player Group - Pick every player in (All players) and do (Actions)
  • Unit Group - Pick every unit in (Units in Region 045 <gen>) and do (Unit - Kill (Picked unit))
  • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 1 (Red) at (Center of ENd1 <gen>) facing Default building facing (270.0) degrees
  • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 2 (Blue) at (Center of ENd1 <gen>) facing Default building facing (270.0) degrees
  • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 3 (Teal) at (Center of ENd1 <gen>) facing Default building facing (270.0) degrees
  • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 4 (Purple) at (Center of ENd1 <gen>) facing Default building facing (270.0) degrees
  • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 5 (Yellow) at (Center of ENd1 <gen>) facing Default building facing (270.0) degrees
  • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 6 (Orange) at (Center of ENd2 <gen>) facing Default building facing (270.0) degrees
  • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 7 (Green) at (Center of ENd2 <gen>) facing Default building facing (270.0) degrees
  • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 8 (Pink) at (Center of ENd2 <gen>) facing Default building facing (270.0) degrees
  • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 9 (Gray) at (Center of ENd2 <gen>) facing Default building facing (270.0) degrees
  • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 10 (Light Blue) at (Center of ENd2 <gen>) facing Default building facing (270.0) degrees
I've already said I'm not sure about the "all players"-player group, but the rest leaks.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Please tell me what leaks. It looks fine.

All right, here is the fixed version:


  • Trigger
    • set TempForce = All Players
    • Player Group - Pick every player in TempForce and do (Actions)
      • set TempLoc = Center of Area
      • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for (Picked player) at TempLoc facing Default building facing degrees
      • call RemoveLocation(udg_TempLoc)
    • call DestroyForce(udg_TempForce)
[hidden="CHA_Owner's fixed Trigger:]
  • Trigger
    • set TempForce = All Players
    • Player Group - Pick every player in TempForce and do (Actions)
    • set TempGroup = Pick every unit in (Units in Region 045 <gen>)
    • set TempLoc = (Center of ENd1 <gen>)
    • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 1 (Red) at TempLoc facing Default building facing (270.0) degrees
    • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 2 (Blue) at TempLoc facing Default building facing (270.0) degrees
    • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 3 (Teal) at TempLoc facing Default building facing (270.0) degrees
    • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 4 (Purple) at TempLoc facing Default building facing (270.0) degrees
    • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 5 (Yellow) at TempLoc facing Default building facing (270.0) degrees
    • call RemoveLocation(udg_TempLoc)
    • set TempLoc = (Center of ENd2 <gen>)
    • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 6 (Orange) at TempLoc facing Default building facing (270.0) degrees
    • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 7 (Green) at TempLoc facing Default building facing (270.0) degrees
    • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 8 (Pink) at TempLoc facing Default building facing (270.0) degrees
    • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 9 (Gray) at TempLoc facing Default building facing (270.0) degrees
    • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 10 (Light Blue) at TempLoc facing Default building facing (270.0) degrees
    • call RemoveLocation(udg_TempLoc)
    • call DestroyForce(udg_TempForce)
    • call DestroyGroup(udg_TempGroup)
[/hidden]

Note: I've only used the actions that leaked, the other actions aren't in these triggers.
 
Level 12
Joined
Feb 11, 2008
Messages
809
All right, here is the fixed version:


  • Trigger
    • set TempForce = All Players
    • Player Group - Pick every player in TempForce and do (Actions)
      • set TempLoc = Center of Area
      • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for (Picked player) at TempLoc facing Default building facing degrees
      • call RemoveLocation(udg_TempLoc)
    • call DestroyForce(udg_TempForce)
[hidden="CHA_Owner's fixed Trigger:]
  • Trigger
    • set TempForce = All Players
    • Player Group - Pick every player in TempForce and do (Actions)
    • set TempGroup = Pick every unit in (Units in Region 045 <gen>)
    • set TempLoc = (Center of ENd1 <gen>)
    • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 1 (Red) at TempLoc facing Default building facing (270.0) degrees
    • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 2 (Blue) at TempLoc facing Default building facing (270.0) degrees
    • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 3 (Teal) at TempLoc facing Default building facing (270.0) degrees
    • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 4 (Purple) at TempLoc facing Default building facing (270.0) degrees
    • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 5 (Yellow) at TempLoc facing Default building facing (270.0) degrees
    • call RemoveLocation(udg_TempLoc)
    • set TempLoc = (Center of ENd2 <gen>)
    • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 6 (Orange) at TempLoc facing Default building facing (270.0) degrees
    • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 7 (Green) at TempLoc facing Default building facing (270.0) degrees
    • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 8 (Pink) at TempLoc facing Default building facing (270.0) degrees
    • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 9 (Gray) at TempLoc facing Default building facing (270.0) degrees
    • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for Player 10 (Light Blue) at TempLoc facing Default building facing (270.0) degrees
    • call RemoveLocation(udg_TempLoc)
    • call DestroyForce(udg_TempForce)
    • call DestroyGroup(udg_TempGroup)
[/hidden]

Note: I've only used the actions that leaked, the other actions aren't in these triggers.

what are they tempforce and temploc variables? (as in like unit group or what?)
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
what are they tempforce and temploc variables? (as in like unit group or what?)

TempForce is a Player Group variable
TempLoc is a Point variable
TempGroup is a Unit Group variable

Things that leak

GhostWolf said:
Yeah, destroying all the players sure is useful - you can't put any reference to them through out all the game. :icon_sarcasm:
-.-
I already thought so, though... I added it to be sure.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Try something like this:


  • Random
  • Events
    • Player - Player 1 (Red) types a chat message containing -ar as An exact match
    • Player - Player 1 (Red) types a chat message containing -all random as An exact match
  • Conditions
    • ((Units in UNITSCANTRANDOM <gen> owned by Player 1 (Red)) is empty) Equal to True
    • ((Units in UNITSCANTRANDOM <gen> owned by Player 2 (Blue)) is empty) Equal to True
    • ((Units in UNITSCANTRANDOM <gen> owned by Player 3 (Teal)) is empty) Equal to True
    • ((Units in UNITSCANTRANDOM <gen> owned by Player 4 (Purple)) is empty) Equal to True
    • ((Units in UNITSCANTRANDOM <gen> owned by Player 5 (Yellow)) is empty) Equal to True
    • ((Units in UNITSCANTRANDOM <gen> owned by Player 6 (Orange)) is empty) Equal to True
    • ((Units in UNITSCANTRANDOM <gen> owned by Player 7 (Green)) is empty) Equal to True
    • ((Units in UNITSCANTRANDOM <gen> owned by Player 8 (Pink)) is empty) Equal to True
    • ((Units in UNITSCANTRANDOM <gen> owned by Player 9 (Gray)) is empty) Equal to True
    • ((Units in UNITSCANTRANDOM <gen> owned by Player 10 (Light Blue)) is empty) Equal to True
  • Actions
    • For each (Integer A) from 1 to 10, do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • ((Player((Integer A))) controller) Equal to User
            • ((Player((Integer A))) slot status) Equal to Is playing
          • Then - Actions
            • Set TempUnitGroup = (Units in Region 045 <gen>)
            • Unit Group - Pick every unit in TempUnitGroup and do (Unit - Remove (Picked unit) from the game)
            • Custom script: call DestroyGroup(udg_TempUnitGroup)
            • Player - Set (Player((Integer A))) Current gold to (((Player((Integer A))) Current gold) + 20)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Integer A) Less than or equal to 5
              • Then - Actions
                • Set TempLoc = (Center of ENd1)
                • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for (Player((Integer A))) at TempLoc facing Default building facing (270.0) degrees
                • Set Hero[(Integer A)] = (Last created unit)
                • Camera - Pan camera for (Player((Integer A))) to TempLoc over 2.00 seconds
                • Custom script: call RemoveLocation(udg_TempLoc)
              • Else - Actions
                • Set TempLoc = (Center of ENd2)
                • Unit - Create 1 Random_Hero[(Random integer number between 1 and 26)] for (Player((Integer A))) at TempLoc facing Default building facing (270.0) degrees
                • Set Hero[(Integer A)] = (Last created unit)
                • Camera - Pan camera for (Player((Integer A))) to TempLoc over 2.00 seconds
                • Custom script: call RemoveLocation(udg_TempLoc)
          • Else - Actions
    • Trigger - Turn off (This trigger)



This is what it does:

When Red types -ar / -all random, everyone's hero chooser will be removed, player 1-5 will get a random hero at ENd1 and player 6-10 will get a random here at ENd2.
It is completely (?) leakless and it should work.


This is how it works:

I have made a loop that goes from integer 1 to 10.
Then, it checks if the player of the current integer is a user and is playing.
If that is true, then it removes the hero chooser of that player and gives extra gold.
I have checked if the integer was lower or equal than 5, or not, to see where the hero should be positioned.

This is a brief explanation, I hope you've understood this, otherwise I can explain it a little bit further.


If something deos not work properly, please check all variables, if there is no mistake there, tell me exactly what's the problem.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
No, it actually crashes the game :p

I think Hive should have a mandatory DL of LeakCheck

If you are talking about my trigger, it is leakless.
I always remove leaks of any trigger I give on the hive.

I did it without Leak Check, but especially because of this comment I've tested it with Leak Check and it didn't give any error.
You must be talking about something else...
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Talking about the original Trigger, alot of the triggers I see in here and on maps are leaky.

It gets rather annoying.

Well, Memory leaks are actually something "new" in mapping.
It isn't new, but only recently are almost all mappers interested in removing them, a year ago nobody really bothered about it.

But you're right... only the more experienced users remove the leaks...
 
Level 15
Joined
Mar 31, 2009
Messages
1,397
There was this map a couple years ago on here, some sort of maul template, Triggering was so fricken leaky, and the nub probably didn't even check Things That Leak.

After some clean-up did make a maul out of it...... Idk, music system idea was kinda cool
 
Status
Not open for further replies.
Top