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

Units are not added to Unit Group

Status
Not open for further replies.
Level 5
Joined
Nov 30, 2012
Messages
200
I'm making a transport system so that you are able to easily load more than 10 units as the Cargo Hold ability appears to not be able to have more than 10 (it crashes WC3).

So, I imported Bribe's Unit Indexer and made some abilities and made the triggers for them. However, for some reason, it appears that in the first trigger, the units that are selected by the ability are not added to the unit group variable (with an array) called TransportGroups. I know that it's this because of the following debug ITE, but the first ITE still runs (I know this because the units are still hidden by the following action). So when I cast "Unload Units" the units are not moved to the target location and are not unhidden.

Here are the triggers:

  • Transport Load
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Unit-type of (Casting unit)) Equal to Human Transport Ship
      • (Ability being cast) Equal to Load Units
    • Actions
      • Set temp_Point = (Target point of ability being cast)
      • Set temp_Integer = (Custom value of (Casting unit))
      • Set temp_Integer2 = 0
      • Unit Group - Pick every unit in (Units within 384.00 of temp_Point) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is A structure) Equal to False
              • (Unit-type of (Picked unit)) Not equal to Human Transport Ship
              • temp_Integer2 Less than 30
            • Then - Actions
              • Set temp_Integer2 = (temp_Integer2 + (Point-value of (Picked unit)))
              • Unit Group - Add (Picked unit) to TransportGroups[temp_Integer]
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is in TransportGroups[temp_Integer]) Equal to True
                • Then - Actions
                  • Game - Display to (All players) the text: true
                • Else - Actions
              • Unit - Hide temp_Unit
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • temp_Integer2 Greater than 0
        • Then - Actions
          • Floating Text - Change TransportFloatingText[temp_Integer]: Disable permanence
          • Floating Text - Destroy TransportFloatingText[temp_Integer]
          • Floating Text - Create floating text that reads (|cfffffcc0 + ((String(temp_Integer2)) + |r)) above (Triggering unit) with Z offset -128.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
          • Set TransportFloatingText[temp_Integer] = (Last created floating text)
          • Floating Text - Change TransportFloatingText[temp_Integer]: Enable permanence
        • Else - Actions
      • Custom script: call RemoveLocation( udg_temp_Point )
  • Transport Unload
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Unit-type of (Casting unit)) Equal to Human Transport Ship
      • (Ability being cast) Equal to Unload Units
    • Actions
      • Set temp_Integer = (Custom value of (Casting unit))
      • Set temp_Point = (Target point of ability being cast)
      • Unit Group - Pick every unit in TransportGroups[temp_Integer] and do (Actions)
        • Loop - Actions
          • Unit - Move (Picked unit) instantly to temp_Point, facing Default building facing degrees
          • Unit - Unhide (Picked unit)
      • Unit Group - Remove all units from TransportGroups[temp_Integer]
      • Floating Text - Change TransportFloatingText[temp_Integer]: Disable permanence
      • Floating Text - Destroy TransportFloatingText[temp_Integer]
      • Custom script: call RemoveLocation( udg_temp_Point )
Current clarifying info: temp_Integer2 is the maximum cargo load (based upon the point value of the unit being loaded, with infantry being 1 and heavier units being 2-3).

What could the problem be?

Thanks.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
your unit group array is probably set to 1 in the variable editor. This means that only indexes 0 and 1 are initialized. Instead change the number to the number you need.
Also never use casting unit use trigger unit.
Anything used twice or more should be stored in a variable and the variable should be used.
You also leak a unit group.
 
Level 5
Joined
Nov 30, 2012
Messages
200
Oh yeah, I meant to change them back to Triggering Unit, but I was just fiddling around to see if it was a stupid mistake I made. What unit group leaks?

Edit: also, that solved the problem. Thanks, I had no idea!
 
Status
Not open for further replies.
Top