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

Unit Wont Store

Status
Not open for further replies.
Level 6
Joined
Sep 11, 2006
Messages
172
So I've taken a long vacation from working on maps and now I've started a new project that has run into an odd problem.

In one of my scripts I am unable to store a unit in a group after it is created. I have confirmed in game that the created unit is present, but it is not being stored and I have tested this with other triggers and an integer message that counts the number of units in the group I'm looking at.

Here it is. Look near the bottom.

  • Rooms
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Integer((Distance between (Position of (Ordered unit)) and (Position of (Target destructible of issued order))))) Less than or equal to 500
      • And - All (Conditions) are true
        • Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Destructible-type of (Target destructible of issued order)) Equal to Gate (Vertical)
              • (Destructible-type of (Target destructible of issued order)) Equal to Gate (Horizontal)
              • (Destructible-type of (Target destructible of issued order)) Equal to Large Gate (Horizontal)
              • (Destructible-type of (Target destructible of issued order)) Equal to Large Gate (Vertical)
    • Actions
      • Unit - Order (Ordered unit) to Stop
      • Unit - Order (Ordered unit) to Move To (Position of (Target destructible of issued order))
      • Floating Text - Create floating text that reads +1 Turn above (Ordered unit) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
      • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
      • Floating Text - Change (Last created floating text): Disable permanence
      • Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
      • Floating Text - Change the fading age of (Last created floating text) to 4.00 seconds
      • Destructible - Open (Target destructible of issued order)
      • Set Turn = (Turn + 1)
      • -------- Region 000 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Target destructible of issued order) Equal to Gate (Vertical) 0048 <gen>
        • Then - Actions
          • Unit - Create 1 Spawner for Player 12 (Brown) at ((Center of Region 000 <gen>) offset by (200.00, 0.00)) facing Default building facing degrees
          • Unit Group - Add (Last created unit) to SpawnersUnite
          • Unit - Set Rally-Point for (Last created unit) to (Center of Region 001 <gen>)
        • Else - Actions
      • -------- Run Waves --------
      • Trigger - Run Turn Wave <gen> (checking conditions)
The Spawner unit is created, but it does not get added to the group. I have no other triggers that would immediately remove it from the group.

I must be forgetting something.

Edit:I do realize their are leaks. I will address them later. Just trying to pin down this basic script first.
 
Level 25
Joined
Sep 26, 2009
Messages
2,373
Check number of units in the unit group - are there any? It may be that the unit group is destroyed in some other script, in which case the action "Unit Group - Add (Last created unit) to SpawnersUnite" would do nothing at all (since you would be adding unit to "null" if the group is destroyed).
 
Level 6
Joined
Sep 11, 2006
Messages
172
Yeah, I thought the same and went to check if I had made another script that was stealing the unit out of the group. Didn't see anything that would fire immediately after this action and cause this.

Ill check again and get back to you.


Edit: Found it. Not what I was expecting. The unit was not being removed from the group. The group was being destroyed by another trigger, where I was trying to prevent unit group leaks.

Just in case anyone wants to know, if you call Custom script: call DestroyGroup(udg_TempGroup), to clean up the action for pick every unit in unit group, that function also destroys the original unit group you set your TempGroup to. I honestly did not know this. I thought it only destroyed the "picked units" group in the TempGroup. Here's the problem trigger.

  • Turn Wave
    • Events
    • Conditions
    • Actions
      • -------- Difficulty 0 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Difficulty Equal to 0
        • Then - Actions
          • Set TempGroup = SpawnersUnite
          • Unit Group - Pick every unit in TempGroup and do (Actions)
            • Loop - Actions
              • -------- Switch --------
              • Set Switch = (Random integer number between 0 and 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Switch Equal to 1
                • Then - Actions
                  • -------- Ping --------
                  • Set TempPoint = (Position of (Picked unit))
                  • Cinematic - Ping minimap for (All players) at TempPoint for 1.00 seconds, using a Simple ping of color (100.00%, 100.00%, 100.00%)
                  • Custom script: call RemoveLocation(udg_TempPoint)
                  • -------- Spawns --------
                  • For each (Integer A) from 1 to (Random integer number between 1 and 3), do (Actions)
                    • Loop - Actions
                      • Unit - Order (Picked unit) to train/upgrade to a |cffbfcddbCorrupt Droid|r
                • Else - Actions
          • Custom script: call DestroyGroup(udg_TempGroup)
        • Else - Actions
The trigger was destroying SpawnersUnite as well as TempGroup.

Thanks for the input.
 
Status
Not open for further replies.
Top