• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Point Terrain Fix

Status
Not open for further replies.
Level 14
Joined
Oct 16, 2011
Messages
296
Does this kind of trigger leaks?
  • Terrain
    • Events
      • Unit - A unit Finishes construction
    • Conditions
    • Actions
      • Set Point[0] = (Position of (Triggering unit))
      • For each (Integer Point_Max) from 1 to 8, do (Actions)
        • Loop - Actions
          • Set Point[Point_Max] = (Point[0] offset by 128.00 towards (45.00 x (Real(Point_Max))) degrees)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Terrain type at Point[Point_Max]) Equal to Barrens - Grassy Dirt
            • Then - Actions
              • Environment - Change terrain type at Point[Point_Max] to Outland - Rough Dirt using variation -1 in an area of size 1 and shape Circle
            • Else - Actions
          • Custom script: call RemoveLocation(udg_Point[1])
          • Custom script: call RemoveLocation(udg_Point[2])
          • Custom script: call RemoveLocation(udg_Point[3])
          • Custom script: call RemoveLocation(udg_Point[4])
          • Custom script: call RemoveLocation(udg_Point[5])
          • Custom script: call RemoveLocation(udg_Point[6])
          • Custom script: call RemoveLocation(udg_Point[7])
          • Custom script: call RemoveLocation(udg_Point[8])
      • Custom script: call RemoveLocation(udg_Point[0])
I want to use the trigger above 'cos I hate long triggers like this below:
  • Terrain
    • Events
      • Unit - A unit Finishes construction
    • Conditions
    • Actions
      • Set Point[0] = (Position of (Triggering unit))
      • Set Point[1] = (Point[0] offset by 128.00 towards 0.00 degrees)
      • Set Point[2] = (Point[0] offset by 128.00 towards 90.00 degrees)
      • Set Point[3] = (Point[0] offset by 128.00 towards 180.00 degrees)
      • Set Point[4] = (Point[0] offset by 128.00 towards 270.00 degrees)
      • Set Point[5] = (Point[0] offset by 128.00 towards 45.00 degrees)
      • Set Point[6] = (Point[0] offset by 128.00 towards 135.00 degrees)
      • Set Point[7] = (Point[0] offset by 128.00 towards 225.00 degrees)
      • Set Point[8] = (Point[0] offset by 128.00 towards 315.00 degrees)
      • For each (Integer Point_Max) from 0 to 8, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Terrain type at Point[Point_Max]) Equal to Barrens - Grassy Dirt
            • Then - Actions
              • Environment - Change terrain type at Point[Point_Max] to Outland - Rough Dirt using variation -1 in an area of size 1 and shape Circle
            • Else - Actions
      • Custom script: call RemoveLocation(udg_Point[0])
      • Custom script: call RemoveLocation(udg_Point[1])
      • Custom script: call RemoveLocation(udg_Point[2])
      • Custom script: call RemoveLocation(udg_Point[3])
      • Custom script: call RemoveLocation(udg_Point[4])
      • Custom script: call RemoveLocation(udg_Point[5])
      • Custom script: call RemoveLocation(udg_Point[6])
      • Custom script: call RemoveLocation(udg_Point[7])
      • Custom script: call RemoveLocation(udg_Point[8])
I'm going to need a shorter version of this trigger 'cos the points that I will use will reach up to Point[32] but that's too long.
If someone knows how to execute this properly, please show me how :grin:



`
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
He does not. It serves no purpose there.

With the way the trigger is constructed, it would iterate inside the loop like this:
Code:
Iteration #1:
    Set point[1] = somewhere
    If point[1] terrain = Barrens, do some action
    Call Remove point[1]
    Call Remove point[2]
    Call Remove point[3]
    Call Remove point[4]
    Call Remove point[5]
    Call Remove point[6]
    Call Remove point[7]
    Call Remove point[8]

Iteration #2:
    Set point[2] = somewhere
    If point[2] terrain = Barrens, do some action
    Call Remove point[1]
    Call Remove point[2]
    Call Remove point[3]
    Call Remove point[4]
    Call Remove point[5]
    Call Remove point[6]
    Call Remove point[7]
    Call Remove point[8]

Iteration #3
    same as #1 and #2 but does stuff with point[3] instead

Moral of the story: In each iteration you only use one "layer" and you immediately destroy the stuff saved in it (iteration 1 uses layer 1 - that is the point[1]; iteration 2 only uses layer 2, etc.). The use of temporal variables is best here.

So the actual code should look like this instead:
  • Terrain
    • Events
      • Unit - A unit Finishes construction
    • Conditions
    • Actions
      • Set Point[0] = (Position of (Triggering unit))
      • For each (Integer Point_Max) from 1 to 8, do (Actions)
        • Loop - Actions
          • Set Point[1] = (Point[0] offset by 128.00 towards (45.00 x (Real(Point_Max))) degrees)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Terrain type at Point[1]) Equal to Barrens - Grassy Dirt
            • Then - Actions
              • Environment - Change terrain type at Point[1] to Outland - Rough Dirt using variation -1 in an area of size 1 and shape Circle
            • Else - Actions
          • Custom script: call RemoveLocation(udg_Point[1])
      • Custom script: call RemoveLocation(udg_Point[0])
I'm assuming the OR condition is needed there because there will be multiple conditions. If that is not the case, the OR block can be removed as well.
 
Level 14
Joined
Oct 16, 2011
Messages
296
He does not. It serves no purpose there.

With the way the trigger is constructed, it would iterate inside the loop like this:
Code:
Iteration #1:
    Set point[1] = somewhere
    If point[1] terrain = Barrens, do some action
    Call Remove point[1]
    Call Remove point[2]
    Call Remove point[3]
    Call Remove point[4]
    Call Remove point[5]
    Call Remove point[6]
    Call Remove point[7]
    Call Remove point[8]

Iteration #2:
    Set point[2] = somewhere
    If point[2] terrain = Barrens, do some action
    Call Remove point[1]
    Call Remove point[2]
    Call Remove point[3]
    Call Remove point[4]
    Call Remove point[5]
    Call Remove point[6]
    Call Remove point[7]
    Call Remove point[8]

Iteration #3
    same as #1 and #2 but does stuff with point[3] instead

Moral of the story: In each iteration you only use one "layer" and you immediately destroy the stuff saved in it (iteration 1 uses layer 1 - that is the point[1]; iteration 2 only uses layer 2, etc.). The use of temporal variables is best here.

So the actual code should look like this instead:
  • Terrain
    • Events
      • Unit - A unit Finishes construction
    • Conditions
    • Actions
      • Set Point[0] = (Position of (Triggering unit))
      • For each (Integer Point_Max) from 1 to 8, do (Actions)
        • Loop - Actions
          • Set Point[1] = (Point[0] offset by 128.00 towards (45.00 x (Real(Point_Max))) degrees)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Terrain type at Point[1]) Equal to Barrens - Grassy Dirt
            • Then - Actions
              • Environment - Change terrain type at Point[1] to Outland - Rough Dirt using variation -1 in an area of size 1 and shape Circle
            • Else - Actions
          • Custom script: call RemoveLocation(udg_Point[1])
      • Custom script: call RemoveLocation(udg_Point[0])
I'm assuming the OR condition is needed there because there will be multiple conditions. If that is not the case, the OR block can be removed as well.

This should do. Thanks bro :grin:
 
Status
Not open for further replies.
Top