• 🏆 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] Building is fully constructed

Status
Not open for further replies.
Level 11
Joined
Mar 28, 2015
Messages
632
In order to create an additional source of gold (source of gold other than gold mines) I've created a trigger that gives gold to the player if the player builds a structure on top of a glowing ruin, however in order for the gold to only be given when the structure is fully build I've found it necessary to add another trigger. This other trigger replaces the structure when it is fully build with an identical version which allows the first trigger to act and give the player gold on a periodic basis.

  • Untitled Trigger 12
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in Region 001 <gen> matching ((Unit-type of (Matching unit)) Equal to Moon Well (gold))) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Region 001 <gen> contains (Picked unit)) Equal to True
            • Then - Actions
              • Player - Set (Owner of (Picked unit)) Current gold to (((Owner of (Picked unit)) Current gold) + 20)
            • Else - Actions
  • Untitled Trigger 15
    • Events
      • Unit - A unit Finishes construction
    • Conditions
      • (Unit-type of (Constructed structure)) Equal to Moon Well (Building dummy)
    • Actions
      • Unit - Replace (Constructed structure) with a Moon Well (gold) using The old unit's relative life and mana
Is there any way to simplify this into one trigger? I couldn't find a condition which checks if the building is fully constructed is there a way to check for such a thing?
 
Level 15
Joined
Mar 25, 2016
Messages
1,327
It's better to use a trigger to add the construced building to a group. In you trigger 15 you add to MoonWellGroup and and trigger 12 you pick every unit in MoonWellGroup.
You will need another trigger to remove killed units from the group.
It's also more efficient, because you don't have to pick every unit every 5 seconds.
 
Level 15
Joined
Mar 25, 2016
Messages
1,327
Yes it's better. You will have a unit group, that contains all finished buildings of that type.
You need triggers to add them to the group, when the are finished and triggers to remove them from the group, when they are killed.
With this method you won't have to create a new unit group and picke every unit all the time, so it's a lot faster.
It's not one trigger, but 3, so it's not what you wanted, but it's more efficient.
If you use JASS/vJASS you could put it in one trigger sheet.
 
Status
Not open for further replies.
Top