• 🏆 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] Shorter Trigger

Status
Not open for further replies.
Level 14
Joined
Oct 16, 2011
Messages
296
Hey guys. Can someone make a shorter version of this trigger? I'm losing my mind.
  • Demon Build
    • Events
      • Unit - A unit Finishes construction
    • Conditions
    • Actions
      • Set Point[0] = (Position of (Triggering unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Unit-type of (Triggering unit)) Equal to Chaos Hall
              • (Unit-type of (Triggering unit)) Equal to Barracks
              • (Unit-type of (Triggering unit)) Equal to Obsidian Mill
              • (Unit-type of (Triggering unit)) Equal to Inferno Tower
              • (Unit-type of (Triggering unit)) Equal to Pig Farm
              • (Unit-type of (Triggering unit)) Equal to Altar of Dimensions
              • (Unit-type of (Triggering unit)) Equal to Temple of Tyranny
              • (Unit-type of (Triggering unit)) Equal to Beast Den
              • (Unit-type of (Triggering unit)) Equal to Demon Gate
              • (Unit-type of (Triggering unit)) Equal to Shrine of Artifacts
        • Then - Actions
          • For each (Integer Point_Max) from 1 to 12, do (Actions)
            • Loop - Actions
              • Set Point[1] = (Point[0] offset by 128.00 towards (30.00 x (Real(Point_Max))) degrees)
              • Set Point[2] = (Point[0] offset by 256.00 towards (30.00 x (Real(Point_Max))) degrees)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain type at Point[1]) Equal to Barrens - Grassy Dirt
                • Then - Actions
                  • Environment - Change terrain type at Point[1] to Outland - Light Dirt using variation -1 in an area of size 1 and shape Circle
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Terrain type at Point[1]) Equal to Barrens - Dark Desert
                    • 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
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain type at Point[2]) Equal to Barrens - Grassy Dirt
                • Then - Actions
                  • Environment - Change terrain type at Point[2] to Outland - Light Dirt using variation -1 in an area of size 1 and shape Circle
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Terrain type at Point[2]) Equal to Barrens - Dark Desert
                    • Then - Actions
                      • Environment - Change terrain type at Point[2] 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])
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Unit-type of (Triggering unit)) Equal to Chaos Hall
              • (Unit-type of (Triggering unit)) Equal to Barracks
              • (Unit-type of (Triggering unit)) Equal to Obsidian Mill
              • (Unit-type of (Triggering unit)) Equal to Altar of Dimensions
              • (Unit-type of (Triggering unit)) Equal to Temple of Tyranny
              • (Unit-type of (Triggering unit)) Equal to Beast Den
              • (Unit-type of (Triggering unit)) Equal to Demon Gate
              • (Unit-type of (Triggering unit)) Equal to Shrine of Artifacts
        • Then - Actions
          • For each (Integer Point_Max) from 1 to 24, do (Actions)
            • Loop - Actions
              • Set Point[1] = (Point[0] offset by 384.00 towards (15.00 x (Real(Point_Max))) degrees)
              • Set Point[2] = (Point[0] offset by 512.00 towards (15.00 x (Real(Point_Max))) degrees)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain type at Point[1]) Equal to Barrens - Grassy Dirt
                • Then - Actions
                  • Environment - Change terrain type at Point[1] to Outland - Light Dirt using variation -1 in an area of size 1 and shape Circle
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Terrain type at Point[1]) Equal to Barrens - Dark Desert
                    • 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
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain type at Point[2]) Equal to Barrens - Grassy Dirt
                • Then - Actions
                  • Environment - Change terrain type at Point[2] to Outland - Light Dirt using variation -1 in an area of size 1 and shape Circle
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Terrain type at Point[2]) Equal to Barrens - Dark Desert
                    • Then - Actions
                      • Environment - Change terrain type at Point[2] 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])
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Chaos Hall
        • Then - Actions
          • For each (Integer Point_Max) from 1 to 36, do (Actions)
            • Loop - Actions
              • Set Point[1] = (Point[0] offset by 640.00 towards (10.00 x (Real(Point_Max))) degrees)
              • Set Point[2] = (Point[0] offset by 768.00 towards (10.00 x (Real(Point_Max))) degrees)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain type at Point[1]) Equal to Barrens - Grassy Dirt
                • Then - Actions
                  • Environment - Change terrain type at Point[1] to Outland - Light Dirt using variation -1 in an area of size 1 and shape Circle
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Terrain type at Point[1]) Equal to Barrens - Dark Desert
                    • 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
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain type at Point[2]) Equal to Barrens - Grassy Dirt
                • Then - Actions
                  • Environment - Change terrain type at Point[2] to Outland - Light Dirt using variation -1 in an area of size 1 and shape Circle
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Terrain type at Point[2]) Equal to Barrens - Dark Desert
                    • Then - Actions
                      • Environment - Change terrain type at Point[2] 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])
        • Else - Actions
      • Custom script: call RemoveLocation(udg_Point[0])
Thankyou :grin:
 
Level 25
Joined
Sep 26, 2009
Messages
2,381
Ok, let's take a look at this.

First of all, the idea here:
From what I understand, you're trying to change the terrain tiles around your newly built buildings. You want to achieve something like what undead race has with blight - when building is finished, it creates a blight circle around the area. You want to achieve something similar by changing two specific tiles around your building - a "Barrens - Grassy Dirt" and "Barrens - Dark Desert" to "Outland - Light Dirt" and "Outland - Rough Dirt".
Just like with undead blight, you want the bigger/more important buildings to create larger circle of outland dirt than smaller structures.

This is what I understand from the trigger and hence what I'm going to try to optimize, so I hope I got it right.


#1 - Triggering unit, conditions
Because there will be multiple conditions involving the triggering unit, it will be less efficient using the function call (Triggering unit) than saving the (Triggering unit) into variable (thus making just one function call) and then referring to the variable.
For yet better optimization, I'm going to also save the unit-type of (Triggering unit) into its own variable (variable of type "unit-type).

I'm also going to change conditions. I will first save the (Triggering unit) into the variable, then I'm going to check if the newly built structure IS NOT EQUAL to any of your special structures. If it really is not equal to any of those structures, I'm going to end the trigger immediately.

That is going to look like this:
  • Actions
    • Set structure = (Triggering unit)
    • Set structure_type = (Unit-type of structure)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • structure_type Not equal to Altar of Kings
        • structure_type Not equal to Barracks
        • structure_type Not equal to Blacksmith
        • structure_type Not equal to Farm
        • structure_type Not equal to Scout Tower
        • structure_type Not equal to Town Hall
      • Then - Actions
        • Set structure = No unit
        • Skip remaining actions
      • Else - Actions

#2 - Changing tile at given point
Now I will change the part of trigger which determines if tile should be changed at a given point. Instead of having two pairs of ITEs - one for point[1] and other for point[2], I will remove the second pair of ITE, so your trigger now operates only with point[1]. For each angle we will use point[1] twice - once like it was before and the second time instead of point[2]. The reason for what I did is because leaving here the second pair of ITE which does exactly the same as the first one but operates with point[2] instead just creates redundancy in code.

This is how it should look like:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Terrain type at point[1]) Equal to Barrens - Grassy Dirt
    • Then - Actions
      • Environment - Change terrain type at point[1] to Outland - Light Dirt using variation -1 in an area of size 1 and shape Circle
    • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Terrain type at point[1]) Equal to Barrens - Dark Desert
        • 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

#3 - The logic behind determining circle size
Now I'm going to change the logic of the trigger. Right now, the trigger executes in this order:
1) "Is it one of my special structures?"
Yes: create small circle No: nothing
2) "Is it one of my bigger special structures?"
Yes: create medium ring No: nothing
3) "Is it my special town hall?"
Yes: create large ring No: nothing

The trigger always executes all 3 steps! I'm going to change this logic into:
1) "Is it my special town hall?"
Yes: Set radius = 3 No: Ask 2)
2) "Is it my large building?"
Yes: Set radius = 2 No: Set radius = 1
The reason for this is because the trigger won't even get to this point (asking if the structure is town hall/big/small building) if it ain't one of your special buildings (this is taken care of in step #1). So logically if the structure is one of your special structures, but it ain't a town hall nor a big structure, then it obviously has to be a small structure.
Notice how I'm not doing anything yet, but setting radius size to 1, 2 or 3 depending on how big the circle is supposed to be.


#4 - Changing tiles around structure
So now that we have the radius size set, all we need is to efficiently set loops which will take care of everything. This is why we need the radius variable - to determine the number of iterations in the main (=outermost) loop. This will require two loops (one inside another) so you're going to need two integer variables that will be used by these loops (you already have one such variable - the Point_Max variable).

We will also need one extra loop which will create points for point[1] two times, instead of creating two points manually and saving them in point[1] and point[2]. The reason is that the ITE I modified in step #2 operates only with point[1].

So now the idea here is that via loops we will get the location of each point we want, we set that point in array point[] under index 1 (thus into point[1]) and then check via the ITE if tile there is one of the desired tiles or not.


#5 - Final trigger
Here is what I managed to make out of it:
  • Structure built
    • Events
      • Unit - A unit Finishes construction
    • Conditions
    • Actions
      • Set structure = (Triggering unit)
      • Set structure_type = (Unit-type of structure)
      • -------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --------
      • -------- If the condition below DOES NOT pass, the structure built is one of our special structures --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • structure_type Not equal to Altar of Kings
          • structure_type Not equal to Barracks
          • structure_type Not equal to Blacksmith
          • structure_type Not equal to Farm
          • structure_type Not equal to Scout Tower
          • structure_type Not equal to Town Hall
        • Then - Actions
          • Set structure = No unit
          • Skip remaining actions
        • Else - Actions
      • -------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --------
      • -------- Determine size of the circle by setting value into variable "radius" --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • structure_type Equal to Town Hall
        • Then - Actions
          • Set radius = 3
        • Else - Actions
          • -------- NOTICE HERE --------
          • -------- I'm checking if structure is small structure, because the list of small structures is shorter than list of big structures --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • structure_type Equal to Farm
                  • structure_type Equal to Scout Tower
            • Then - Actions
              • Set radius = 1
            • Else - Actions
              • Set radius = 2
      • -------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --------
      • -------- Get location of structure, use loops for changing tiles --------
      • Set point[0] = (Position of structure)
      • -------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --------
      • -------- This main loop is the cause for creating small/medium/large circles --------
      • For each (Integer Loop_1) from 1 to radius, do (Actions)
        • Loop - Actions
          • Set angle = (360.00 / (Real((12 x Loop_1))))
          • -------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --------
          • -------- Runs 12/24/36 times depending on current iteration of outer loop (of Loop_1) --------
          • For each (Integer Loop_2) from 1 to (12 x Loop_1), do (Actions)
            • Loop - Actions
              • -------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --------
              • -------- This loop is here instead of manually setting point[1] and point[2] --------
              • For each (Integer Loop_3) from 1 to 2, do (Actions)
                • Loop - Actions
                  • -------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --------
                  • -------- Sets range to 128 and 256; 384 and 512; 640 and 768 --------
                  • Set range = ((Real((1 + ((Loop_1 - 1) x 2)))) x 128.00)
                  • Set range = (range + (Real(((Loop_3 - 1) x 128))))
                  • Set point[1] = (point[0] offset by range towards (angle x (Real(Loop_2))) degrees)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Terrain type at point[1]) Equal to Lordaeron Summer - Grass
                    • Then - Actions
                      • Environment - Change terrain type at point[1] to Outland - Light Dirt using variation -1 in an area of size 1 and shape Circle
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Terrain type at point[1]) Equal to Lordaeron Summer - Dark Grass
                        • 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])
      • Set structure = No unit
  • Structure built
    • Events
      • Unit - A unit Finishes construction
    • Conditions
    • Actions
      • Set structure = (Triggering unit)
      • Set structure_type = (Unit-type of structure)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • structure_type Not equal to Altar of Kings
          • structure_type Not equal to Barracks
          • structure_type Not equal to Blacksmith
          • structure_type Not equal to Farm
          • structure_type Not equal to Scout Tower
          • structure_type Not equal to Town Hall
        • Then - Actions
          • Set structure = No unit
          • Skip remaining actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • structure_type Equal to Town Hall
        • Then - Actions
          • Set radius = 3
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • structure_type Equal to Farm
                  • structure_type Equal to Scout Tower
            • Then - Actions
              • Set radius = 1
            • Else - Actions
              • Set radius = 2
      • Set point[0] = (Position of structure)
      • For each (Integer Loop_1) from 1 to radius, do (Actions)
        • Loop - Actions
          • Set angle = (360.00 / (Real((12 x Loop_1))))
          • For each (Integer Loop_2) from 1 to (12 x Loop_1), do (Actions)
            • Loop - Actions
              • For each (Integer Loop_3) from 1 to 2, do (Actions)
                • Loop - Actions
                  • Set range = ((Real((1 + ((Loop_1 - 1) x 2)))) x 128.00)
                  • Set range = (range + (Real(((Loop_3 - 1) x 128))))
                  • Set point[1] = (point[0] offset by range towards (angle x (Real(Loop_2))) degrees)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Terrain type at point[1]) Equal to Lordaeron Summer - Grass
                    • Then - Actions
                      • Environment - Change terrain type at point[1] to Outland - Light Dirt using variation -1 in an area of size 1 and shape Circle
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Terrain type at point[1]) Equal to Lordaeron Summer - Dark Grass
                        • 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])
      • Set structure = No unit

A few words
1) The code would be imo simpler and more efficient if written in jass, because you could use functions there.

2) Your approach is not completely thought-out. The problem here is that WCIII tiles operate on grid with the smallest square being 128x128, while you try to change tiles in a circle by using angles and range. The result of this is that some tiles, which should be changed, are left intact, while some tiles are changed multiple times.

The solution here could be using Pythagoras where sides a and b are multiples of 128 + X/Y coordinate of center of circle; and side c is actual range from the center where you should check tile type.
 
Level 14
Joined
Oct 16, 2011
Messages
296
  • Structure built
    • Events
      • Unit - A unit Finishes construction
    • Conditions
    • Actions
      • Set structure = (Triggering unit)
      • Set structure_type = (Unit-type of structure)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • structure_type Not equal to Altar of Kings
          • structure_type Not equal to Barracks
          • structure_type Not equal to Blacksmith
          • structure_type Not equal to Farm
          • structure_type Not equal to Scout Tower
          • structure_type Not equal to Town Hall
        • Then - Actions
          • Set structure = No unit
          • Skip remaining actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • structure_type Equal to Town Hall
        • Then - Actions
          • Set radius = 3
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • structure_type Equal to Farm
                  • structure_type Equal to Scout Tower
            • Then - Actions
              • Set radius = 1
            • Else - Actions
              • Set radius = 2
      • Set point[0] = (Position of structure)
      • For each (Integer Loop_1) from 1 to radius, do (Actions)
        • Loop - Actions
          • Set angle = (360.00 / (Real((12 x Loop_1))))
          • For each (Integer Loop_2) from 1 to (12 x Loop_1), do (Actions)
            • Loop - Actions
              • For each (Integer Loop_3) from 1 to 2, do (Actions)
                • Loop - Actions
                  • Set range = ((Real((1 + ((Loop_1 - 1) x 2)))) x 128.00)
                  • Set range = (range + (Real(((Loop_3 - 1) x 128))))
                  • Set point[1] = (point[0] offset by range towards (angle x (Real(Loop_2))) degrees)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Terrain type at point[1]) Equal to Lordaeron Summer - Grass
                    • Then - Actions
                      • Environment - Change terrain type at point[1] to Outland - Light Dirt using variation -1 in an area of size 1 and shape Circle
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Terrain type at point[1]) Equal to Lordaeron Summer - Dark Grass
                        • 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])
      • Set structure = No unit
Looks very nice. Thankyou bro :grin:
Your approach is not completely thought-out. The problem here is that WCIII tiles operate on grid with the smallest square being 128x128, while you try to change tiles in a circle by using angles and range. The result of this is that some tiles, which should be changed, are left intact, while some tiles are changed multiple times.

The solution here could be using Pythagoras where sides a and b are multiples of 128 + X/Y coordinate of center of circle; and side c is actual range from the center where you should check tile type.
What do you mean? Sorry, but I'm not that good at math :ogre_rage:
 
Level 25
Joined
Sep 26, 2009
Messages
2,381
Take a look at this picture:
attachment.php

The black circle is the area you want to affect (where you want to change tiles).
Tiles operate on grid - that is the red grid. The center of each tile is where the lines of the grid intersect.
Because you determined points via angles (multiples of some number - in your case it was 30/15/10), it will happen that sometimes two points affect one tile (because both are in the area of the tile), while in some other cases the distance will be enough that it won't affect tile.
The solution I wrote about was using Pythagoras to determine the length of side c, because you know length of sides a and b (as shown on the picture).

Thinking about it now, there is also far easier solution. Because you always have X and Y coordinates of the center, all you would need is to offset that point by multiples of 128 to X and Y to get to all the intersections inside circle. That way you get all points inside the circle.


----
Also, I got another idea.
When I posted the trigger, I wrote about first checking if the newly built structure is NOT EQUAL to any of your special structures.
There is a way around this which shortens the trigger by a good amount.
Create a passive item ability (for example item attack damage bonus) and make that ability do nothing. Name that ability as you want. The reason why it should be item ability is because most item abilities do not show any icon in game.
Give this ability to all your special buildings. Now instead of checking the unit-type of the newly built structure, you check if level of ability > 0

So instead of this:
  • Structure built
    • Events
      • Unit - A unit Finishes construction
    • Conditions
    • Actions
      • Set structure = (Triggering unit)
      • Set structure_type = (Unit-type of structure)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • structure_type Not equal to Altar of Kings
          • structure_type Not equal to Barracks
          • structure_type Not equal to Blacksmith
          • structure_type Not equal to Farm
          • structure_type Not equal to Scout Tower
          • structure_type Not equal to Town Hall
        • Then - Actions
          • Set structure = No unit
          • Skip remaining actions
        • Else - Actions
      • ...
You would have this:
  • Structure built
    • Events
      • Unit - A unit Finishes construction
    • Conditions
      • Level of Your_ability for (Triggering unit) Greater than 0
    • Actions
      • Set structure = (Triggering unit)
      • Set structure_type = (Unit-type of structure)
      • *no ITE here anymore*
      • ...
 

Attachments

  • graph.png
    graph.png
    22 KB · Views: 152
Level 14
Joined
Oct 16, 2011
Messages
296
Take a look at this picture:
attachment.php

The black circle is the area you want to affect (where you want to change tiles).
Tiles operate on grid - that is the red grid. The center of each tile is where the lines of the grid intersect.
Because you determined points via angles (multiples of some number - in your case it was 30/15/10), it will happen that sometimes two points affect one tile (because both are in the area of the tile), while in some other cases the distance will be enough that it won't affect tile.
The solution I wrote about was using Pythagoras to determine the length of side c, because you know length of sides a and b (as shown on the picture).

Thinking about it now, there is also far easier solution. Because you always have X and Y coordinates of the center, all you would need is to offset that point by multiples of 128 to X and Y to get to all the intersections inside circle. That way you get all points inside the circle.
Pythagorean theorem! Sounds cool. Too bad I don't know how to use it in this trigger :ogre_rage:
Also, I got another idea.
When I posted the trigger, I wrote about first checking if the newly built structure is NOT EQUAL to any of your special structures.
There is a way around this which shortens the trigger by a good amount.
Create a passive item ability (for example item attack damage bonus) and make that ability do nothing. Name that ability as you want. The reason why it should be item ability is because most item abilities do not show any icon in game.
Give this ability to all your special buildings. Now instead of checking the unit-type of the newly built structure, you check if level of ability > 0

So instead of this:
  • Structure built
    • Events
      • Unit - A unit Finishes construction
    • Conditions
    • Actions
      • Set structure = (Triggering unit)
      • Set structure_type = (Unit-type of structure)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • structure_type Not equal to Altar of Kings
          • structure_type Not equal to Barracks
          • structure_type Not equal to Blacksmith
          • structure_type Not equal to Farm
          • structure_type Not equal to Scout Tower
          • structure_type Not equal to Town Hall
        • Then - Actions
          • Set structure = No unit
          • Skip remaining actions
        • Else - Actions
      • ...
You would have this:
  • Structure built
    • Events
      • Unit - A unit Finishes construction
    • Conditions
      • Level of Your_ability for (Triggering unit) Greater than 0
    • Actions
      • Set structure = (Triggering unit)
      • Set structure_type = (Unit-type of structure)
      • *no ITE here anymore*
      • ...
Oooooh Oooooh! I never thought of this in my whole life! Thankyou bro! Can I hug you? No? Why not? :ogre_love:

EDIT: I'm going to practice more in that "Pythagoras" thing. I'm too bad at math sorry.
 
Status
Not open for further replies.
Top