Ok, I have got 2 near exactly the same triggers. One for firing cannons on the right side and one for firing them on the left side. However the one for firing cannons on the left side is not working. It is ignoring any conditions that use a variable in it.
Here is the working trigger
What is happening is that the trigger is ignoring the condition Closest[playernum2] Less then 750.00 (see extract below) and proceeding onto the Then Actions. I am completely lost in why this is happening. However, it only happens for variables not preset numbers. Any help would be appreciated
Here is the working trigger
-
Firing Rightside Cannons
-
Events
- Unit - A unit Begins casting an ability
-
Conditions
- (Ability being cast) Equal to Fire Right Cannons
-
Actions
- Custom script: local integer udg_playernum
- Set playernum = ((Player number of (Triggering player)) - 1)
- Set Closest[playernum] = 751.00
- Set PlayersShip[playernum] = (Position of (Triggering unit))
- Set FaceAngle[playernum] = (Facing of (Triggering unit))
-
Unit Group - Pick every unit in (Units within 750.00 of PlayersShip[playernum]) and do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Picked unit) Not equal to (Triggering unit)
-
Then - Actions
- Set AngleBetweenShips[playernum] = (Angle from PlayersShip[playernum] to (Position of (Picked unit)))
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
And - All (Conditions) are true
-
Conditions
- AngleBetweenShips[playernum] Less than or equal to (FaceAngle[playernum] - 45.00)
- AngleBetweenShips[playernum] Greater than or equal to ((FaceAngle[playernum] - 180.00) + 45.00)
-
Conditions
-
And - All (Conditions) are true
-
Then - Actions
- Set TargetLoc[playernum] = (Distance between (Position of (Triggering unit)) and (Position of (Picked unit)))
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- TargetLoc[playernum] Less than Closest[playernum]
-
Then - Actions
- Set Closest[playernum] = TargetLoc[playernum]
- Set FireingTarg[playernum] = (Position of (Picked unit))
- Else - Actions
-
If - Conditions
- Else - Actions
-
If - Conditions
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Closest[playernum] Less than 751.00
-
Then - Actions
-
For each (Integer CannonNumber[playernum]) from 0 to 3, do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- CannonFire[playernum] Equal to True
-
Then - Actions
- Set CannonFire[playernum] = False
- Set Position[playernum] = (FireingTarg[playernum] offset by (Random real number between 0.00 and 150.00) towards (Random angle) degrees)
- Unit - Create 1 DummyCannon for Neutral Passive at PlayersShip[playernum] facing Default building facing degrees
- Set Cannon[playernum] = (Last created unit)
- Unit - Create 1 DummyTarget for Neutral Passive at Position[playernum] facing Default building facing degrees
- Set Target[playernum] = (Last created unit)
- Unit - Order Cannon[playernum] to Attack Target[playernum]
- Wait 0.70 seconds
- Unit - Order Target[playernum] to Human Mountain King - Thunder Clap
- Wait 0.50 seconds
- Unit - Remove Cannon[playernum] from the game
- Unit - Remove Target[playernum] from the game
- Set CannonFire[playernum] = True
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
-
For each (Integer CannonNumber[playernum]) from 0 to 3, do (Actions)
-
Else - Actions
- Game - Display to Player Group - Player 1 (Red) the text: No ship within rang...
-
If - Conditions
-
Events
-
Firing Leftside Cannons Copy
-
Events
- Unit - A unit Begins casting an ability
-
Conditions
- (Ability being cast) Equal to Fire Left Cannons
-
Actions
- Custom script: local integer udg_playernum2
- Set playernum2 = (Player number of (Triggering player))
- Set Closest[playernum2] = 751.00
- Set PlayersShip[playernum2] = (Position of (Triggering unit))
- Set FaceAngle[playernum2] = (Facing of (Triggering unit))
-
Unit Group - Pick every unit in (Units within 750.00 of PlayersShip[playernum2]) and do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Picked unit) Not equal to (Triggering unit)
-
Then - Actions
- Game - Display to (All players) the text: (Name of (Picked unit))
- Set Integer = (Integer + 1)
- Game - Display to (All players) the text: (String(Integer))
- Game - Display to (All players) the text: (Picked Unit is + (Name of (Picked unit)))
- Set AngleBetweenShips[playernum2] = (Angle from PlayersShip[playernum2] to (Position of (Picked unit)))
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
And - All (Conditions) are true
-
Conditions
- AngleBetweenShips[playernum2] Greater than or equal to (FaceAngle[playernum2] + 45.00)
- AngleBetweenShips[playernum2] Greater than or equal to ((FaceAngle[playernum2] - 180.00) - 45.00)
-
Conditions
-
And - All (Conditions) are true
-
Then - Actions
- Set TargetLoc[playernum2] = (Distance between (Position of (Triggering unit)) and (Position of (Picked unit)))
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- TargetLoc[playernum2] Less than Closest[playernum2]
-
Then - Actions
- Set Closest[playernum2] = TargetLoc[playernum2]
- Set FireingTarg[playernum2] = (Position of (Picked unit))
- Else - Actions
-
If - Conditions
- Else - Actions
-
If - Conditions
-
Else - Actions
- Game - Display to (All players) the text: No unit Picked
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
- Game - Display to (All players) the text: (String(Closest[playernum2]))
- Set Closest[playernum2] = 751.00
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Closest[playernum2] Less than 750.00
-
Then - Actions
- Game - Display to (All players) the text: (String(Closest[playernum2]))
-
For each (Integer CannonNumber[playernum2]) from 0 to 3, do (Actions)
-
Loop - Actions
- Game - Display to Player Group - Player 1 (Red) the text: ship within range o...
- Set Position[playernum2] = (FireingTarg[playernum2] offset by (Random real number between 0.00 and 150.00) towards (Random angle) degrees)
- Unit - Create 1 DummyCannon for Neutral Passive at PlayersShip[playernum2] facing Default building facing degrees
- Set Cannon[playernum2] = (Last created unit)
- Unit - Create 1 DummyTarget for Neutral Passive at Position[playernum2] facing Default building facing degrees
- Set Target[playernum2] = (Last created unit)
- Unit - Order Cannon[playernum2] to Attack Target[playernum2]
- Wait 0.70 seconds
- Unit - Order Target[playernum2] to Human Mountain King - Thunder Clap
- Wait 0.50 seconds
- Unit - Remove Cannon[playernum2] from the game
- Unit - Remove Target[playernum2] from the game
-
Loop - Actions
-
Else - Actions
- Game - Display to Player Group - Player 1 (Red) the text: No ship within rang...
-
If - Conditions
-
Events
What is happening is that the trigger is ignoring the condition Closest[playernum2] Less then 750.00 (see extract below) and proceeding onto the Then Actions. I am completely lost in why this is happening. However, it only happens for variables not preset numbers. Any help would be appreciated
- Set Closest[playernum2] = 751.00
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Closest[playernum2] Less than 750.00
-
Then - Actions
- Game - Display to (All players) the text: (String(Closest[playernum2]))
-
For each (Integer CannonNumber[playernum2]) from 0 to 3, do (Actions)
-
Loop - Actions
- Game - Display to Player Group - Player 1 (Red) the text: ship within range o...
- Set Position[playernum2] = (FireingTarg[playernum2] offset by (Random real number between 0.00 and 150.00) towards (Random angle) degrees)
- Unit - Create 1 DummyCannon for Neutral Passive at PlayersShip[playernum2] facing Default building facing degrees
- Set Cannon[playernum2] = (Last created unit)
- Unit - Create 1 DummyTarget for Neutral Passive at Position[playernum2] facing Default building facing degrees
- Set Target[playernum2] = (Last created unit)
- Unit - Order Cannon[playernum2] to Attack Target[playernum2]
- Wait 0.70 seconds
- Unit - Order Target[playernum2] to Human Mountain King - Thunder Clap
- Wait 0.50 seconds
- Unit - Remove Cannon[playernum2] from the game
- Unit - Remove Target[playernum2] from the game
-
Loop - Actions
-
Else - Actions
- Game - Display to Player Group - Player 1 (Red) the text: No ship within rang...
-
If - Conditions