• 🏆 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!

Multiple bugs in this trigger

Status
Not open for further replies.
Level 3
Joined
Jan 11, 2018
Messages
23
  • RaceSelect
    • Events
      • Unit - A unit Finishes an upgrade
    • Conditions
    • Actions
      • Set PlayerNumber = (Player number of (Owner of (Triggering unit)))
      • For each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Triggering unit)) Equal to RaceType[(Integer A)]
            • Then - Actions
              • Unit - Create 1 BattlefieldHQType[(Integer A)] for (Player(PlayerNumber)) at (Center of PlayerStartBattlefield[PlayerNumber]) facing Default building facing degrees
              • Unit Group - Pick every unit in (Units in PlayerStart[PlayerNumber] matching ((Unit-type of (Matching unit)) Equal to Building Foundation)) and do (Actions)
                • Loop - Actions
                  • Unit - Replace (Picked unit) with a FoundationType[(Integer A)] using The new unit's max life and mana
            • Else - Actions
The trigger is supposed to pick the default foundations around the newly chosen race's headquarters and make them into ones compatible with the race they picked, but for some reason it does not change them. Also there should be a structure spawning in the middle of a miniature 'area', which is directly northwest of the foundations, but for some reason the structure that is supposed to spawn in there spawns in the middle of the map. What gives?
 
Level 9
Joined
Apr 23, 2011
Messages
527
That's good.

I would clean up the leaks, though. Like so:
  • RaceSelect
    • Events
      • Unit - A unit Finishes an upgrade
    • Conditions
    • Actions
      • Set PlayerNumber = (Player number of (Owner of (Triggering unit)))
      • For each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Triggering unit)) Equal to RaceType[(Integer A)]
            • Then - Actions
              • Set PlayerStartCenter[PlayerNumber] = (Center of PlayerStartBattlefield[PlayerNumber])
              • Unit - Create 1 BattlefieldHQType[(Integer A)] for (Player(PlayerNumber)) at PlayerStartCenter facing Default building facing degrees
              • Set PlayerStartGroup[PlayerNumber] = (Units in PlayerStart[PlayerNumber] matching ((Unit-type of (Matching unit)) Equal to Building Foundation))
              • Unit Group - Pick every unit in PlayerStartGroup[PlayerNumber] and do (Actions)
                • Loop - Actions
                  • Unit - Replace (Picked unit) with a FoundationType[(Integer A)] using The new unit's max life and mana
              • Custom script: call RemoveLocation(udg_PlayerStartCenter[udg_PlayerNumber])
              • Custom script: call DestroyGroup(udg_PlayerStartGroup[udg_PlayerNumber])
            • Else - Actions
You could also set the variables in a init trigger, if it isn't used for anything else. You don't need to clean up the leaks if so.
 
Status
Not open for further replies.
Top