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

Selection System Wont Select?

Status
Not open for further replies.
Level 17
Joined
Jun 17, 2010
Messages
2,275
Im making an auto selection system that selects units within a range and making you able to quick cast spells on the units without selecting them. It tells me Selected Unit: and thats it. Its supposed to tell me the unit type...
  • Selectable Units
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to (Number of players in (All players controlled by a User player)), do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in (Units within 1000.00 of (Position of SelectedUnit[(Integer A)])) and do (Actions)
            • Loop - Actions
              • Set SelectableUnits[(Integer A)] = (Last created unit group)
  • Picked Unit
    • Events
      • Player - Player 1 (Red) Selects a unit
      • Player - Player 2 (Blue) Selects a unit
    • Conditions
      • (Owner of (Triggering unit)) Equal to (Triggering player)
    • Actions
      • Set SelectedUnit[(Player number of (Triggering player))] = (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 1 (Red)
        • Then - Actions
          • Set SelectedEnemy[1] = (Random unit from SelectableUnits[1])
          • Game - Display to (All players) the text: Press ESC to swap b...
          • Game - Display to Player Group - Player 1 (Red) the text: (Selected Enemy: + (String((Unit-type of SelectedEnemy[1]))))
        • Else - Actions
  • Unit Selection Swap
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
      • Player - Player 2 (Blue) skips a cinematic sequence
    • Conditions
    • Actions
      • Set SelectedEnemy[(Player number of (Triggering player))] = (Random unit from SelectableUnits[(Player number of (Triggering player))])
      • Game - Display to (All players matching ((Triggering player) Equal to Player 1 (Red))) the text: (Selected Enemy: + (String((Unit-type of SelectedEnemy[(Player number of (Triggering player))]))))
      • Game - Display to (All players matching ((Triggering player) Equal to Player 2 (Blue))) the text: (Selected Enemy: + (String((Unit-type of SelectedEnemy[(Player number of (Triggering player))]))))
Edit: I noticed a leak in my first trigger, could that be the problem?
 
  • For each (Integer A) from 1 to (Number of players in (All players controlled by a User player)), do (Actions)
Leaks. Use this one instead:
  • For each (Integer A) from 1 to 12, do (Actions)
    • Loop - Actions
      • If (All conditions are true) then do (Actions) else do (Actions)
        • If - Conditions
          • ((Player(IntegerA)) controller) Equal to User
        • Then - Actions
          • //Actions here
        • Else - Actions
(Position of (Selected[(IntegerA)]) leaks. Use a Point variable.

Use this line:
  • Custom script: set bj_wantDestroyGroup = true
before this line:
  • Unit Group - Pick every unit in (Units within 1000.00 of (Position of SelectedUnit[(Integer A)])) and do (Actions)
Visit:
http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/

Instead of
  • Set SelectedEnemy[1] = (Random unit from SelectableUnits[1])
Use
  • Set SelectedEnemy[Player number of (Triggering player)] = (Random unit from SelectableUnits[Player Number of (Triggering player)])
and remove the player comparison from the conditions.

  • (All players matching ((Triggering player) Equal to Player 1 (Red)))
First of, just go through Conversion - Convert player group to player, to get Player 1 (Red).
Secondly, when you use "All players matching", your player should be then detected as "Matching player", not "Triggering player".
 
Level 9
Joined
May 27, 2006
Messages
498
  • Selectable Units
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to (Number of players in (All players controlled by a User player)), do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in (Units within 1000.00 of (Position of SelectedUnit[(Integer A)])) and do (Actions)
            • Loop - Actions
              • Set SelectableUnits[(Integer A)] = (Last created unit group)
You need to add units to your group... Unit Group - Add (Picked unit) to SelectableUnits[(Integer A)]

Edit: I noticed a leak in my first trigger, could that be the problem?
You've actually got way more leaks in this trigger... Like, 2*33*number of players. Per second.
 
Level 17
Joined
Jun 17, 2010
Messages
2,275
I plugged it all in, still no luck. Its either this line,
  • Game - Display to (All players matching ((Matching player) Equal to Player 1 (Red))) the text: (Selected Enemy: + (String((Unit-type of SelectedEnemy[(Player number of (Triggering player))]))))
or this,
  • Set SelectedEnemy[(Player number of (Triggering player))] = (Random unit from SelectableUnits[(Player number of (Triggering player))])
 
Level 9
Joined
May 27, 2006
Messages
498
Are you sure you added this:
  • Unit Group - Add (Picked unit) to SelectableUnits[(Integer A)]
Instead of this?
  • Set SelectableUnits[(Integer A)] = (Last created unit group)
In case yes and it still doesn't work, post your updated triggers.
 
Level 17
Joined
Jun 17, 2010
Messages
2,275
Okay i may have wrote the unit group - add wrong... haha fixing and will post if it works or not.

Okay, now the new problem of repeated random unit. when i click esc to swap units, it just says the same unit. Its supposed to shuffle between all the units.

Edit: i added the map so u guys could see.
 

Attachments

  • Picking System.w3x
    18.4 KB · Views: 31
Level 9
Joined
May 27, 2006
Messages
498
You'll need a simple jass function in order to prevent units from being selected, like, twice in a row, on a completely random basis
JASS:
function SelectNextUnit takes group g returns unit
    local unit u = FirstOfGroup(g)
    call GroupRemoveUnit(g, u)
    call GroupAddUnit(g, u)
    return u
endfunction
I've modified the map you provided and made everything work. You should be getting repeated results each time you press esc (like peon - peasant - wisp - acolyte - peon - peasant - ...and so on)
 

Attachments

  • Picking System.w3x
    21 KB · Views: 36
Level 17
Joined
Jun 17, 2010
Messages
2,275
I gata say man, You are a heck of a triggerer lol. You and pharaoh. Hm im 1 step closer to master GUI. Thanks for the help i appreciate it.
I realize now i may have to make a index system storing the spells for a certain hero so he can switch through his spells so he can cast whichever he pleases.
 
Status
Not open for further replies.
Top