StarCraft® II

(solved)[Trigger] Patroll reinforcements fail

Posts: 40
Hello,

I am making a 2 vs 2 map with hostile attack waves in it. (these can be turned off) However I use these Air patrol units to counter curtain attacks from player on the hostile(neutral) base. The problem lies in the "trigger" down below.

[Works] The units do not spawn if nothing is destroyed
[Works] The trigger counts the amount of living members in the group.
[Works] The trigger spawns the appropriate number of units.
[Works] The trigger stops spawning when the off switch building is destroyed.
[Does not seem to work] The trigger updates those members that are spawned to be part of that group.
[Does not seem to work] The units spawned follow the patrol route.

In short if you kill 2 members of the patroll. It keeps on spawning 2 members even if there are 6 hells angels again.

Spawn
Events
Timer - Every 30.0 seconds of Game Time
Local Variables
Conditions
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Number of Living units in Hells Angels) <= 5
(Fortress - 2 [108.50, 103.50] is alive) == True
Then
Unit - Create {6-(Number of Living units in Hells Angels)} Merc - Hel's Angel - (Merc Viking, Fighter Mode) for player 15 at Airpatrol 1-01 using default facing (No Options)
Unit Group - Add (Last created unit) to Hells Angels
Else


Any advise?
Edited by Redisia on 12/8/2012 12:58 PM PST
Reply Quote
Posts: 372
My advice would be to learn how to debug effectively.

Even for people who are very experienced it is rare that they will create something correct on the first go. Any large section of code you write will invariably have bugs in it that need to be tracked down and removed.

Try placing debugging statements inside your code to track what happens. In the trigger editor create a new action and search for "debug" and you should find it.

I'm not trying to be a smart alec by not giving you the answer. It's just that if you are handed the answer then the next time you write code it will also have bugs in it (happens to everyone, a lot of the time) and you are going to be stuck again. Then you are no better off than you were before.

May as well learn how to debug an easy piece of code than have to learn later on a hard piece.

EDIT:
I would recomend placing a debugging statement...

  • At the start of the function so you know when it runs
  • after both the "then" and "else" so you can follow which path the program takes
  • and a debugging statement before and after you modify the "Hells Angels" variable so you can know what it was like before and after the modification. (use "convert integer to text" to be able to print out integers like the size of the group)
Edited by turtles on 12/4/2012 6:52 PM PST
Reply Quote
Posts: 40
After messing with the debugging tool (wich really did not help so much) and a test map i fixxed it with a variable unit group.

Still have the problem that i cannot get all units in "Unit Group - Add (Last created unit) to Airpatrol 1"

SPAWN
Events
Timer - Every 30.0 seconds of Game Time
Local Variables
Conditions
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Number of Living units in Airpatrol 1) <= 3
Then
Unit - Create 1 Viking (Fighter Mode) for player 1 at fly 1 using default facing (No Options)
Unit Group - Add (Last created unit) to Airpatrol 1
General - If (Conditions) then do (Actions) else do (Actions)
If
(Number of Living units in Airpatrol 1) <= 3
Then
Unit - Create 1 Viking (Fighter Mode) for player 1 at fly 1 using default facing (No Options)
Unit Group - Add (Last created unit) to Airpatrol 1
General - If (Conditions) then do (Actions) else do (Actions)
If
(Number of Living units in Airpatrol 1) <= 3
Then
Unit - Create 1 Viking (Fighter Mode) for player 1 at fly 1 using default facing (No Options)
Unit Group - Add (Last created unit) to Airpatrol 1
Else
Else
Else
Unit - Order all units in Airpatrol 1 to ( Patrol targeting fly 1) (Replace Existing Orders)
Unit - Order all units in Airpatrol 1 to ( Patrol targeting fly 2) (After Existing Orders)
Unit - Order all units in Airpatrol 1 to ( Patrol targeting fly 3) (After Existing Orders)
Reply Quote

Please report any Code of Conduct violations, including:

Threats of violence. We take these seriously and will alert the proper authorities.

Posts containing personal information about other players. This includes physical addresses, e-mail addresses, phone numbers, and inappropriate photos and/or videos.

Harassing or discriminatory language. This will not be tolerated.

Forums Code of Conduct

Report Post # written by

Reason
Explain (256 characters max)
Submit Cancel

Reported!

[Close]