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

Losing control of a unit until deselected and then reselected.

Status
Not open for further replies.
Level 5
Joined
Mar 24, 2020
Messages
80
Hello,

During gameplay, players can occasionally lose control of a unit. They would have the unit selected, but it wouldn't respond to any actions like move or to cast an ability. To regain control of the unit, the player would need to select another unit and then reselect the original unit. The issue occurs rarely, but usually to at least 1 or 2 players per game.

Has anyone experienced an issue like this and found an occurrence?

It's hard for me to pinpoint a timeframe when the bug started re-occurring enough for me to realize it must be a trigger or something disrupting the gameplay. However, I think the below trigger is my best bet for where the cause is, due to the fact it manipulates a players selection. The trigger simply allows a player to scroll between their Leader unit and their Hero easily.

Does anyone see an issue with the below trigger that may cause these issues?

  • Esc Command
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
      • Player - Player 2 (Blue) skips a cinematic sequence
      • Player - Player 3 (Teal) skips a cinematic sequence
      • Player - Player 4 (Purple) skips a cinematic sequence
      • Player - Player 5 (Yellow) skips a cinematic sequence
      • Player - Player 6 (Orange) skips a cinematic sequence
      • Player - Player 7 (Green) skips a cinematic sequence
      • Player - Player 8 (Pink) skips a cinematic sequence
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Random unit from (Units currently selected by (Triggering player)))) Not equal to Leader
        • Then - Actions
          • Set VariableSet TempPoint = (Position of Leaders[(Player number of (Triggering player))])
          • Camera - Pan camera for (Triggering player) to TempPoint over 0.00 seconds
          • Selection - Select Leaders[(Player number of (Triggering player))] for (Triggering player)
          • Custom script: call RemoveLocation(udg_TempPoint)
        • Else - Actions
          • Set VariableSet TempPoint = (Position of Heroes[(Player number of (Triggering player))])
          • Camera - Pan camera for (Triggering player) to TempPoint over 0.00 seconds
          • Selection - Select Heroes[(Player number of (Triggering player))] for (Triggering player)
          • Custom script: call RemoveLocation(udg_TempPoint)

Thanks!
upload_2020-12-28_17-36-5.gif
 
Level 23
Joined
Dec 4, 2007
Messages
1,557
I would probably use temporary or global unit groups for what you are doing here, but:

I assume the problem lies in another trigger which handles unit behaviour?!
 
Level 5
Joined
Mar 24, 2020
Messages
80
I would probably use temporary or global unit groups for what you are doing here, but:

I assume the problem lies in another trigger which handles unit behaviour?!

Ah yes I need to rid that leak in the condition. Thanks for the spot.

No, there's no triggers that manipulate player owned units directly in terms of behavior. Only dummies' on the occasional ability. However, the undead forces that are computer have a lot of handled unit behavior. Such as "attack move" to certain points and casting abilities.
 
Level 23
Joined
Dec 4, 2007
Messages
1,557
Well you wrote that players sometimes lose control of their units, but your posted trigger doesn't interfere at all with unit control - so :goblin_wtf:.
 
Level 24
Joined
Jun 26, 2020
Messages
1,928
That's because in "(Unit-type of (Random unit from (Units currently selected by (Triggering player)))) Not equal to Leader" you used "Random unit" so it will be a probability, because that will only check a random unit of that group, you must check every unit of that group, for this you need use Jass Language.
  • Esc Command
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
      • Player - Player 2 (Blue) skips a cinematic sequence
      • Player - Player 3 (Teal) skips a cinematic sequence
      • Player - Player 4 (Purple) skips a cinematic sequence
      • Player - Player 5 (Yellow) skips a cinematic sequence
      • Player - Player 6 (Orange) skips a cinematic sequence
      • Player - Player 7 (Green) skips a cinematic sequence
      • Player - Player 8 (Pink) skips a cinematic sequence
    • Conditions
    • Actions
    • Custom script: local unit u
    • Set VariableSet TempGroup = (Units currently selected by (Triggering player))
    • Set VariableSet TempBool = True
    • Custom script: loop
    • Custom script: set u=FirstofGroup(udg_TempGroup)
    • Custom script: exitwhen u==null or udg_TempBool==false
    • Custom script: if GetUnitTypeId(u)=="The ID of the Leader unit" then
    • Set VariableSet TempBool = False
    • Custom script: endif
    • Custom script: call GroupRemoveUnit(udg_TempGroup,u)
    • Custom script: endloop
    • Custom script: call DestroyGroup(udg_TempGroup)
    • Custom script: set u=null
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TempBool Equal to True
        • Then - Actions
          • Set VariableSet TempPoint = (Position of Leaders[(Player number of (Triggering player))])
          • Camera - Pan camera for (Triggering player) to TempPoint over 0.00 seconds
          • Selection - Select Leaders[(Player number of (Triggering player))] for (Triggering player)
          • Custom script: call RemoveLocation(udg_TempPoint)
        • Else - Actions
          • Set VariableSet TempPoint = (Position of Heroes[(Player number of (Triggering player))])
          • Camera - Pan camera for (Triggering player) to TempPoint over 0.00 seconds
          • Selection - Select Heroes[(Player number of (Triggering player))] for (Triggering player)
          • Custom script: call RemoveLocation(udg_TempPoint)
 
Status
Not open for further replies.
Top