• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Trigger Issue

Status
Not open for further replies.
  • Create unit
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in Capital <gen>) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in (Units in Capital <gen>)) Greater than or equal to 1
              • ((Picked unit) is A structure) Equal to True
              • (Unit-type of (Triggering unit)) Equal to Footman
            • Then - Actions
              • Set Temp_Point = (Position of (Triggering unit))
              • Unit - Create 1 Knight for (Owner of (Triggering unit)) at Temp_Point facing Default building facing degrees
              • Unit - Remove (Triggering unit) from the game
              • Custom script: call RemoveLocation (udg_Temp_Point)
            • Else - Actions
              • Do nothing
This trigger is only supposed to make the units into another unit after creation, if there is a building inside a region. But the thing is, even if there is not a building in the region, it still does. It also created two knights rather than one.

Can someone explain to me the issue?

And possibly help me fix it.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Hey there, midsie :D

First of all: the first condition is useless.
If you loop through a unit group, you always expect that there actually are any units.
If the unit group is empty, it simply won't do anything (thus the condition to check whether there are units is rendered useless).

Second: it creates multiple units because it loops through all units in the region, if multiple units comply with these conditions, multiple units will be created.

Third point: Remove the "Do nothing"

I assume there must be some kind of structure in the region (any structure would do), otherwise the units won't be created.


My suggestions: Move "Unit type of (triggering unit)" the the condition-part of the trigger itself.
Then, when doing the ForGroup(), check if (Picked unit) is a structure and as actions do "Game - Display name of (Picked Unit)" to easily see which units the silly trigger thinks are structures (and thus are in fact actually structures).
Remove the damned Unit Group leak! :D
 
Level 8
Joined
Aug 21, 2009
Messages
333
try this:

  • Create unit
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • (Number of units in (Units in Capital <gen> match (((Matching unit is A structure) Equal to True))) Greater than 0
      • (Unit-type of (Triggering unit)) Equal to Footman
    • Actions
      • Set Temp_Point = (Position of (Triggering unit))
      • Unit - Create 1 Knight for (Owner of (Triggering unit)) at Temp_Point facing Default building facing degrees
      • Unit - Remove (Triggering unit) from the game
      • Custom script: call RemoveLocation (udg_Temp_Point)
 
Level 8
Joined
Aug 21, 2009
Messages
333
Well, that stopped the creation of two units, but they still convert even if there is not a building in the region.

Well, then you must have some sort of building in there that you are forgetting.
The only way that your original trigger would have created two knights is if there were two buildings in that region; which makes me think that there is a building in there that you are forgetting about besides the one you are intending to use. Keep in mind, even in a building has been destroyed, it will still be around until it reaches the end of its decay animation.
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
Don't forget that the unit group condition still leaks.

->

  • Untitled Trigger 054 Copy
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Footman
          • (Number of units in (Units in Region 003 <gen> matching (((Matching unit) is A Hero) Equal to True))) Greater than 0
        • Then - Actions
          • Unit - Replace (Triggering unit) with a Knight using The old unit's relative life and mana
        • Else - Actions
 
Level 8
Joined
Aug 21, 2009
Messages
333
Don't forget that the unit group condition still leaks.

->

  • Untitled Trigger 054 Copy
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Footman
          • (Number of units in (Units in Region 003 <gen> matching (((Matching unit) is A Hero) Equal to True))) Greater than 0
        • Then - Actions
          • Unit - Replace (Triggering unit) with a Knight using The old unit's relative life and mana
        • Else - Actions

right you are.
 
Status
Not open for further replies.
Top