• 🏆 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] I can't find what's wrong

Status
Not open for further replies.
Level 4
Joined
Sep 23, 2010
Messages
88
I spent about 4 hours trying to figure out what's wrong. The units spawn, gets added to a group and are ordered to move depending on where the "Core" building is, then the other trigger detects if unit enters the region and sends the unit to attack the "Core". What's wrong is that first few units doesn't go after they enter the region, but the rest goes.
  • Spawn
    • Events
      • Time - sTimer[1] expires
    • Conditions
    • Actions
      • Set sTime[1] = (sTime[1] - 1.00)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • sTime[1] Equal to 46.00
        • Then - Actions
          • Set sTime[2] = 60.00
          • Countdown Timer - Start sTimer[2] as a One-shot timer that will expire in sTime[2] seconds
        • Else - Actions
      • Countdown Timer - Start sTimer[1] as a One-shot timer that will expire in sTime[1] seconds
      • For each (Integer A) from 1 to 8, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Corner[1] contains Core[(Integer A)]) Equal to True
            • Then - Actions
              • Unit - Create 1 Injured Zombie for Player 12 (Brown) at (Center of Start <gen>) facing Default building facing degrees
              • AI - Ignore (Last created unit)'s guard position
              • Unit - Order (Last created unit) to Attack-Move To (Center of Checkpoint[(Random integer number between 1 and 2)])
              • Unit Group - Add (Last created unit) to Zombies[(Integer A)]
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Corner[2] contains Core[(Integer A)]) Equal to True
            • Then - Actions
              • Unit - Create 1 Injured Zombie for Player 12 (Brown) at (Center of Start <gen>) facing Default building facing degrees
              • AI - Ignore (Last created unit)'s guard position
              • Unit - Order (Last created unit) to Attack-Move To (Center of Checkpoint[(Random integer number between 3 and 4)])
              • Unit Group - Add (Last created unit) to Zombies[(Integer A)]
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Corner[3] contains Core[(Integer A)]) Equal to True
            • Then - Actions
              • Unit - Create 1 Injured Zombie for Player 12 (Brown) at (Center of Start <gen>) facing Default building facing degrees
              • AI - Ignore (Last created unit)'s guard position
              • Unit - Order (Last created unit) to Attack-Move To (Center of Checkpoint[(Random integer number between 5 and 6)])
              • Unit Group - Add (Last created unit) to Zombies[(Integer A)]
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Corner[4] contains Core[(Integer A)]) Equal to True
            • Then - Actions
              • Unit - Create 1 Injured Zombie for Player 12 (Brown) at (Center of Start <gen>) facing Default building facing degrees
              • AI - Ignore (Last created unit)'s guard position
              • Unit - Order (Last created unit) to Attack-Move To (Center of Checkpoint[(Random integer number between 7 and 8)])
              • Unit Group - Add (Last created unit) to Zombies[(Integer A)]
            • Else - Actions
  • AttackCore
    • Events
      • Unit - A unit enters Cp11 <gen>
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 8, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Entering unit) is in Zombies[(Integer A)]) Equal to True
            • Then - Actions
              • Unit - Order (Entering unit) to Attack Core[(Integer A)]
            • Else - Actions
there are 8 triggers of this one with different regions.
 
Level 17
Joined
Feb 11, 2011
Messages
1,860
If you have lots of leaks the game will begin to lag. It is important to remove them depending on what it is. For example, a location (point) leak is like this:

  • Unit - Create 1 Footman for Player 1 (Red) at (Center of Spawn1 <gen>) facing Default building facing degrees
To fix this leak, you would do this:

  • Set Temp_Point = (Center of Spawn1 <gen>)
  • Unit - Create 1 Footman for Player 1 (Red) at Temp_Point facing Default building facing degrees
  • Custom script: call RemoveLocation(udg_Temp_Point)
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
There were no hints about leaks or performance drops mentioned by TC. Cant you solve the actual question first before adding to confusion?

edit: Have just seen that your Zombies is a unit group instead of a rect array, so you can skip from here but now that I have already written it, I let it remain as some piece of information. Thought of the "<unit> is in" as in a rect. The GUI lines are quite irritating as they do not always contain a unique or informative identifier which function was used.

The Cp11 rect is an element of the Zombies array? You use it as the triggering event and should be aware that events mark the change of something. In this case, the unit was outside of Cp11 before and is inside afterwards. When the trigger is firing, this fact is just about to change, so you should be careful what the current state is at that moment. It can either be that the unit still counts as outside or as inside. While it is determined normally, you should check the case for this event.

Now, I can reveal you that when you register a "Unit enters Rect"-event, there is no such event in actuality. In jass, you can see, that a region object is created that only inherits the cells of your rect. This region object is then linked to an event. So your trigger starts when a unit enters this region. Therefore, it does not have directly to do with your rect anymore which turns it unlikely that you can pick it up like an event response.

Possible solution: Unite all that enter event triggers and enlarge the checking areas slightly like this for example:

  • Events
    • Map initialization
  • Conditions
  • Actions
    • Set Zombies[0] = Rect 000 <gen>
    • Set Zombies[1] = Rect 001 <gen>
    • Set Zombies[2] = Rect 002 <gen>
    • For each (Integer A) from 0 to 2, do (Actions)
      • Loop - Actions
        • Set ZombiesEnlarged[(Integer A)] = (Region(((Min X of Zombies[(Integer A)]) - 32.00), ((Min Y of Zombies[(Integer A)]) - 32.00), ((Max X of Zombies[(Integer A)]) + 32.00), ((Max Y of Zombies[(Integer A)]) + 32.00)))
        • Trigger - Add to Enter <gen> the event (Unit - A unit enters Zombies[(Integer A)])
  • Enter
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 0 to 2, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • 'IF'-Conditions
              • (ZombiesEnlarged[(Integer A)] contains (Triggering unit)) Equal To True
            • 'THEN'-Actions
              • Game - Display to (All players) the text: (You are in the rect with the index + (String((Integer A))))
            • 'ELSE'-Actions
 
Unit groups array in GUI are always going to point to null groups.
To fix this, on map initialization, you should create those groups like this:

  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 8, do (Actions)
        • Loop - Actions
          • Custom script: set udg_Zombies[bj_forLoopAIndex] = CreateGroup()
 
Level 4
Joined
Sep 23, 2010
Messages
88
One more question, why do units ordered "attack-move to" are going back after they went to the point they were ordered to?
 
Level 17
Joined
Feb 11, 2011
Messages
1,860
Sorry for not answering!

Try this:

  • Custom script: set bj_wantDestroyGroup = true
  • Unit Group - Pick every unit in (Units owned by Player 12 (Brown)) and do (Actions)
    • Loop - Actions
      • AI - Ignore (Picked unit)'s guard position
If new units for player 12 are created after initialization, you will need to include this line when they are created:

  • AI - Ignore (Last created unit)'s guard position
 
Level 4
Joined
Sep 23, 2010
Messages
88
Ok I'll test the game now.


They're ignoring units (not structures).
lol I think I found myself what's the problem.
 
Status
Not open for further replies.
Top