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

[Solved] Random Problems (Please help :))

Status
Not open for further replies.
Level 4
Joined
May 2, 2013
Messages
107
Hi there,


I got the following triggers (see images/screenshots @ attachment).


What we did is if player makes a research, a globar var (integer) will go +1, which is placed in the other triggers which are creating units by whiles..

If all works, but sometimes it doesnt.. Lately we published it public and for some reason 2 players just coudnt spawn when they made a research.. Units just didnt appeared.. This might be logical when something is wrong in the triggers.. I checked the triggers over and over and I can't see any mistakes..

Later on, I tested again on the same and its just works!! After testing it few times, I made a conclusion its random.. Sometimes it works and sometimes it doesnt.. Its weird and I cant just firgure what the problem that is causing this..

Thats why I'm asking here on The Hive workshop..

Is it possible that many whiles could give bug or something.. Cuz I used like 6 whiles per unit and the total amount of units in sc2 are like 30-40 or something..

Just can't stand that some time its working fine and some time it doesnt do shit!!!! How the helllll..

Please someone could think of something?

Thanks in advance
 

Attachments

  • HIVEWORKSHOP SCREENY PART 1.png
    HIVEWORKSHOP SCREENY PART 1.png
    72.6 KB · Views: 171
  • HIVESHOP SCREENY PART 2.png
    HIVESHOP SCREENY PART 2.png
    83.4 KB · Views: 145
Level 5
Joined
Dec 3, 2004
Messages
44
I don't see a cause for your bug, but I do see that the triggers are way more complicated than they need to be, which makes bughunting more difficult. If you replaced most of these nested "if then else" actions with "Switch", the code would be a lot clearer and the bug, hopefully, more apparent.

If you don't know how switch works, it is used similar to If then else, but you set a value and then make several branches of code, one of which is chosen depending on the value you set.

For example, instead of:

If "Race" = Protoss
Then Actions
Else - If "Race" = Zerg
Then Actions
Else - If "Race" = Terran
Then Actions...

You'd have:

Switch depending on "race"
Case If Protoss
Actions
Case If Zerg
Actions
Case if Zerg
Actions

The benefit is even greater when the value has more cases, such as the 6 players earlier in the trigger.

The second screenshot, I'm pretty sure that the While loop keeps looping until the conditions are no longer met, so the trigger won't go any further until the first player either stops playing, or stops being protoss. That would mean that if the first player is protoss, the other while loops won't ever be triggered until he leaves the game. (which might be your bug).

I think it would be better instead of using the while loops to make the whole trigger loop and this time utilize if then else. Also, using "For each integer" could save up some space by allowing you to cycle the same actions for each player. Something like this:

Events
Map initialization

Variables
Team <---- not sure what this does but I assume you are using it
Integer X (integer)

Actions
For each integer Integer X from 1 to 6 with increment 1 do (actions)
If (status of Player set by Lobby [Integer X] = playing
Then: Switch depending on (Race of Player set by Lobby [Integer X])
Case Protoss:
Create Zealot [(Player set by Lobby [Integer X])] Zealot for (Player set by Lobby [Integer X]) etc ...
Case Zerg
etc ...
Wait X seconds
Run (current trigger)

This would consolidate the three triggers from the second screenshot into a single, shorter one.

Now that I think of it, it seems you want the delay between spawns to differ for different players. If that is so, skip the "For each action" part and make six triggers:

If (status of Player set by Lobby [1] = playing
Then: Switch depending on (Race of Player set by Lobby [Integer X])
Case Protoss:
Create Zealot [(Player set by Lobby [Integer X])] Zealot for (Player set by Lobby [Integer X]) etc ...
Case Zerg
etc ...
Wait (Spawn tijd [1] seconds
Run (current trigger)


Let me know if anything is unclear. I'm a tad drunk right now, so I might have messed up or overlooked something, but I think this should solve your problems.
 
Level 4
Joined
May 2, 2013
Messages
107
Yes.. Its very clear.. I see i really learn step by step.. Didnt knew about the Switch action.. But I fixed it on an other way.. I just get rid of the whiles and it works.. You are probely right.. But even though you were tad drunk.. ;) hahah.. :p Anyway, It is a very usefull answer and I'm happy you responded..

Many thanks!!
 
Status
Not open for further replies.
Top