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

[Trigger] Infinite loop that acts strange O_o ??

Status
Not open for further replies.
Level 8
Joined
Sep 24, 2007
Messages
300
First of all, I don't even know if it's infinite loop bug, but I dunno what else could be.

Trigger 1
  • selection system
    • Events
      • Player - Player 1 (Red) Selects a unit
      • Player - Player 2 (Blue) Selects a unit
      • Player - Player 3 (Teal) Selects a unit
      • Player - Player 4 (Purple) Selects a unit
      • Player - Player 5 (Yellow) Selects a unit
      • Player - Player 7 (Green) Selects a unit
      • Player - Player 8 (Pink) Selects a unit
      • Player - Player 9 (Gray) Selects a unit
      • Player - Player 10 (Light Blue) Selects a unit
      • Player - Player 11 (Dark Green) Selects a unit
    • Conditions
      • SelectionCheck[(Player number of (Triggering player))] Equal to (==) True
        • Multiple ConditionsOr - Any (Conditions) are true
          • Conditions
            • (Unit-type of (Triggering unit)) Equal to (==) Footman
            • (Unit-type of (Triggering unit)) Equal to (==) Rohan knight
            • (Unit-type of (Triggering unit)) Equal to (==) Archer
            • (Unit-type of (Triggering unit)) Equal to (==) Grunt
            • (Unit-type of (Triggering unit)) Equal to (==) Raider
            • (Unit-type of (Triggering unit)) Equal to (==) Heavy Catapult
            • (Unit-type of (Triggering unit)) Equal to (==) Catapult
            • (Unit-type of (Triggering unit)) Equal to (==) Beast Rider
            • (Unit-type of (Triggering unit)) Equal to (==) Gryphon Rider
    • Actions
      • Set SelectionCheck[(Player number of (Triggering player))] = False
      • Selection - Select UnitGroup[(Custom value of (Triggering unit))] for (Triggering player)
      • Countdown Timer - Start SelectionTimer[(Player number of (Triggering player))] as a One-shot timer that will expire in 0.30 seconds
Trigger 2 (1 trigger per player, posted for player 1)
  • timer cd 1
    • Events
      • Time - SelectionTimer[1] expires
    • Conditions
    • Actions
      • Set SelectionCheck[1] = True

Now what's wrong?
In SINGLE PLAYER everything works fine.
In MULTIPLAYER all players that select those units, EXCEPT the host get DISCONNECTED.

Now that's what I don't understand. Wtf? If it would be infinite loop it would shut down w3 and report error, but it discs. Also, the host is intact like playing in single player that works w/o a problem.

ANy ideas?
 
Level 11
Joined
Apr 6, 2008
Messages
760
  • Actions
    • Trigger - Turn off (This trigger)
    • Set SelectionCheck[(Player number of (Triggering player))] = False
    • Selection - Select UnitGroup[(Custom value of (Triggering unit))] for (Triggering player)
    • Countdown Timer - Start SelectionTimer[(Player number of (Triggering player))] as a One-shot timer that will expire in 0.30 seconds
    • Trigger - Turn on (This trigger)
this should fix it, since when the trigger select the units it will cause infinite loop :p
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
  • Actions
    • Trigger - Turn off (This trigger)
    • Set SelectionCheck[(Player number of (Triggering player))] = False
    • Selection - Select UnitGroup[(Custom value of (Triggering unit))] for (Triggering player)
    • Countdown Timer - Start SelectionTimer[(Player number of (Triggering player))] as a One-shot timer that will expire in 0.30 seconds
    • Trigger - Turn on (This trigger)
this should fix it, since when the trigger select the units it will cause infinite loop :p

He got an if which prevents that (I think).
The syntax is kinda strange.
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
  • Actions
    • Trigger - Turn off (This trigger)
    • Set SelectionCheck[(Player number of (Triggering player))] = False
    • Selection - Select UnitGroup[(Custom value of (Triggering unit))] for (Triggering player)
    • Countdown Timer - Start SelectionTimer[(Player number of (Triggering player))] as a One-shot timer that will expire in 0.30 seconds
    • Trigger - Turn on (This trigger)
this should fix it, since when the trigger select the units it will cause infinite loop :p

It won't. I made that trigger for him I believe (modified from his version), and your solution was the first thing I tried. However the selection takes place after the trigger gets turned on I think, since it still crashes. That's why I added a timer and use booleans...
 
It won't. I made that trigger for him I believe (modified from his version), and your solution was the first thing I tried. However the selection takes place after the trigger gets turned on I think, since it still crashes. That's why I added a timer and use booleans...
It will, since the trigger that is runned is diabled for the next actions, so it won't be runned again.

I used that solution a lot of times already.
 
Level 8
Joined
Sep 24, 2007
Messages
300
The boolean is changed asap when first unit is selected. But the action still selects whole unit group (12 units). I don't really know if group selection counts as 1 or 12 (one by one). If it's one by one, it will trigger 12 times but it will stop at the boolean condition. It should basically run again 12 times (or once) but won't do anything because of false condition. But it doesn't seem to be the most efficent way to do it.

I will try increasing timer time, because I suspect server lag to cause the bug.


edit: umswe with jnp shouldn't really be a problem...it only changes the action's text a bit nothing else. I turned it off and it turned normal w/o any problems. Although I haven't tested map online since then.

edit: increasing the time to 0.5 sec actually helped a bit-they got disced after 1 min. Dunno if it has anything in common..

edit 2: Who gives a damn about infinite loop anyway? If it would really be one, it would crush w3 asap, but it doesn't! It only discs non host players! -.-'

edit 3: if nobody has any idea, I will do the: turn off this trigger-wait 0.1 sec-turn on this trigger trick. But that sucks a bit because I need to make 10 of them for each player 1. :/
 
Last edited:
Level 12
Joined
Aug 22, 2008
Messages
911
Simple:
Phase 1 - Trigger is initiated by the selection of the player
Phase 2 - Trigger selects a unit group for the player
Phase 3 - Trigger is initiated again by the previous selection action
And so on...
You could try to add a condition that will stop phase 3, like what you tried.
About array you do know that the counting begins from 0 and not from 1, so you need 1 more cell than the number of players if the 0 cell isn't used.
That could be the solution I guess, otherwise it really is a mystery.
 
Well, there are a few problems...
Anachron is only half right and can't read:
Code:
 selection system
Events
Player - Player 1 (Red) Selects a unit
Conditions
[color=red]SelectionCheck[(Player number of (Triggering player))] Equal to (==) True[/color]
    Multiple ConditionsOr - Any (Conditions) are true
    Conditions
      (Unit-type of (Triggering unit)) Equal to (==) Footman
Actions
[color=red]Set SelectionCheck[(Player number of (Triggering player))] = False[/color]
Selection - Select UnitGroup[(Custom value of (Triggering unit))] for (Triggering player)
Code for colour and shortend for better visibility.
BUT Selection events in multiplayer are VERY slow, I bet that the timer could set the boolean back before the new event aplies. However, this won't fix your problem, but clear some things.
 
Level 8
Joined
Sep 24, 2007
Messages
300
Yeah, that's what I will do.

I don't want any war here :p, I just:
1. Had no idea why the hell it isn't working. I mean, trigger is teoretically totally ok, but something unintended must happen online. And that was the mistery to me.
2. I wanted to keep it in 1 trigger, because creating 1 trigger per player is the thing I mostly dislike. Not so much because it's time taking, but because it looks bad and inefficient.


That's all, thanks for all help (although we couldn't make a conclusion). :)

/solved
 
Level 8
Joined
Sep 24, 2007
Messages
300
COnfusion has just increased

I can't believe...

New triggers:
  • player 1 selection
    • Events
      • Player - Player 1 (Red) Selects a unit
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Triggering unit)) Equal to Footman
          • (Unit-type of (Triggering unit)) Equal to Rohan knight
          • (Unit-type of (Triggering unit)) Equal to Archer
          • (Unit-type of (Triggering unit)) Equal to Heavy Catapult
          • (Unit-type of (Triggering unit)) Equal to Catapult
          • (Unit-type of (Triggering unit)) Equal to Gryphon Rider
    • Actions
      • Trigger - Turn off (This trigger)
      • Selection - Clear selection for Player 1 (Red)
      • Selection - Select UnitGroup[(Custom value of (Triggering unit))] for Player 1 (Red)
      • Wait 0.02 seconds
      • Trigger - Turn on (This trigger)

I finally got the point of this bug. When HOST select one of the groups, other players get disc. I tried this several times-the other player picked hero and didn't select any of his units. Then I selected mine and-bye bye.

I made such trigger for all players, there is defenetly no infinite loop now.


The problem lies in:
  • Selection - Select UnitGroup[(Custom value of (Triggering unit))] for Player 1 (Red)
That's the bugger! I tried to replace with: Pick every unit in UnitGroup[custom value of triggering unit] and then ->Add picked unit to selection of player 1.
But it didn't work. It only changed selection to 1 random unit in group.


Anyone has a clue what the heck is going on? I am totally confused now..
I would also gladly attach the map so you guys can try to host it if you find this helpfull.


[screaming] Help [/screaming]
 
  • selection
    • Events
      • Player - Player 1 (Red) Selects a unit
      • Player - Player 2 (Blue) Selects a unit
      • Player - Player 3 (Teal) Selects a unit
      • Player - Player 4 (Purple) Selects a unit
      • Player - Player 5 (Yellow) Selects a unit
      • Player - Player 6 (Orange) Selects a unit
      • Player - Player 7 (Green) Selects a unit
      • Player - Player 8 (Pink) Selects a unit
      • Player - Player 9 (Gray) Selects a unit
      • Player - Player 10 (...) Selects a unit
      • Player - Player 11 (...) Selects a unit
      • Player - Player 12 (...) Selects a unit
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Triggering unit)) Equal to Footman
          • (Unit-type of (Triggering unit)) Equal to Rohan knight
          • (Unit-type of (Triggering unit)) Equal to Archer
          • (Unit-type of (Triggering unit)) Equal to Heavy Catapult
          • (Unit-type of (Triggering unit)) Equal to Catapult
          • (Unit-type of (Triggering unit)) Equal to Gryphon Rider
    • Actions
      • Trigger - Turn off (This trigger)
      • Selection - Clear selection for (TriggeringPlayer)
      • Selection - Select UnitGroup[(Custom value of (Triggering unit))] for (TriggeringPlayer)
      • Trigger - Turn on (This trigger)
Does this work?

What is the Custom value of the triggering unit? Print it.
Is the UnitGroup filled?
 
Level 8
Joined
Sep 24, 2007
Messages
300
1. No it doesn't. W3 freezes because of infinite... no wait action. But it's the same trigger, why would it make any difference? Anyway, I guess with wait action it would work like mine did so far.

2. before getting freezed, it printed 8. Which is correct.
3.
  • For each (Integer A) from 1 to 12, do (Actions)
    • Loop - Actions
      • Unit - Create 1 Rohan knight for MeelePlayer[1] at Temploc facing 180.00 degrees
      • Unit - Set the custom value of (Last created unit) to 8
      • Unit Group - Add (Last created unit) to UnitGroup[8]
All units are created on the hero pick event, getting their appropriate custom values and stored in the groups. As you see, unit's custom values and the groups array match.
 
When you disable trigger Wc3 does not need a wait.

  • For each (Integer A) from 1 to 12, do (Actions)
    • Loop - Actions
      • Unit - Create 1 Rohan knight for MeelePlayer[1] at Temploc facing 180.00 degrees
      • Unit - Set the custom value of (Last created unit) to 8
      • Unit Group - Add (Last created unit) to UnitGroup[8]
Shouldn't that be
  • For each (Integer A) from 1 to 12, do (Actions)
    • Loop - Actions
      • Unit - Create 1 Rohan knight for MeelePlayer[ForLoopIndexA()] at Temploc facing 180.00 degrees
      • Unit - Set the custom value of (Last created unit) to ForLoopIndexA()
      • Unit Group - Add (Last created unit) to UnitGroup[ForLoopIndexA()]
 
Level 8
Joined
Sep 24, 2007
Messages
300
No. I need all 12 units to have the same custom value, be in the same group and be owned by the same player.

Basically, it creates you 12 footmans, and when you select 1, it get's it's custom value and select the whole group[custom value] since it's the same for units and the group array.
 
Level 8
Joined
Sep 24, 2007
Messages
300
I already checked the spell section and found only 1, and that one includes group leader which I don't need. If you could link me to one similar to mine...that would be ok.

But really, I want to smash my head for this because I can't see the damn bug...and it's so logical and easy. -.-'
 
Level 8
Joined
Sep 24, 2007
Messages
300
I did a debug and found out something incredible. Action:

Selection - Select [Unit Group] for Player

Causes player to disconnect! I simplified the trigger to 1 event and 1 action only:

  • Events
    • Time - Elapsed game time is 10.00 seconds
  • Conditions
  • Actions
    • Selection - Select Unitgroup for Player 7
Unitgroup was set as 12 sorceress picked in region. Player 7 was random non-host player on bnet.

  • Events
    • Time - Elapsed game time is 5.00 seconds
  • Conditions
  • Actions
    • Unit - Create 12 Sorceress for Player 7 (Green) at (Center of Region 071 <gen>) facing Default building facing degrees
    • Set Unitgroup= (Units in Region 071 <gen>)
After 10 seconds of gametime, player 7 disconnected!

This way-around seems to work (still needs some testing to be 100% sure)

  • Events
    • Time - Elapsed game time is 10.00 seconds
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Unitgroup and do (Actions)
        • Loop - Actions
          • Selection - Add (Picked unit) to selection for Player 7 (Green)

Could someone else make some tests about this problem?
 
Status
Not open for further replies.
Top