Trigger: If condition Unit in region doesn't work

eXirrah

New Member
Reaction score
51
This is a part of my trigger so I don't post all of it but I think this would be enought:
Trigger:
  • Actions
    • Set tmp_bool2 = True
    • Unit - Pause (Triggering unit)
    • Unit - Unpause (Triggering unit)
    • Set tmp_point[0] = (Target point of issued order)
    • Set tmp_regi[0] = (Region centered at tmp_point[0] with size (200.00, 200.00))
    • Unit Group - Pick every unit in tmp_ugrp[1] and do (Actions)
      • Loop - Actions
        • Game - Display to (All players) the text: (Name of (Picked unit)) <- works-displays all the units in the unit group as it should be
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (tmp_regi[0] contains (Picked unit)) Equal to True
          • Then - Actions
            • Game - Display to (All players) the text: ((Name of (Picked unit)) + <-) <- doesn't work and I click really close to the unit even on top of it
              • Set tmp_unit[8] = (Picked unit)
          • Else - Actions

So I tried to pick every unit in regi[0] and check if the unit is there but no luck. So I created this trigger that doesn't work too. I'll post a creenshot of the unit data cause I can't do anything with this type of units except putting them in unit group as Last Created Unit. They are simply undetectable.

EDIT: Wow. Seems like the problem is in Pause/Unpause triggering unit which causes this trigger to loop infinitely. How does this happen? Is tehre any way to fix it?
The point is that I need when issued order targeting a point the unit to disobey that order and stand still. Then I check for this unit I was talking about if it is close to the point of issued order and I order the unit to move to there. If there is no that kinda unit close to the point of issued order I want the unit to stand still and not move. How can I do that. I tried various ways and non of them worked properly.
 

Genyuumaru

New Member
Reaction score
15
This may be only a guess, but the Target Point of Issued order may disappear after you pause/unpause triggering unit.

Hope I helped.

Now my edit in reply to your edit:
Set the tmp_point[0] before you pause/unpause triggering unit.
After pausing the unit, order it to stop and unpause it after that.
Don't use an event "Is issued an order with no target" and it won't go into an infinite loop.

Edit 2: Ok I got what you ment, I'll think a bit about it...

Edit 3:
Found a way, here's how you do it:

1. Add Triggering Unit to a unit group, for example named "used" and continue on the trigger.
2. Then before that action, perform a check if Triggering Unit is in "used" group. If it IS then remove it from "used" and skip remaining actions. If it's not then go to #1.
 

eXirrah

New Member
Reaction score
51
Yes I didn't thought about that. This was the problem with finding the unit. + rep

But there is something else I posted in my edit. Why when I pause/unpause the unit the trigger start infinite loop?

EDIT: Oops. I'll post the whole trigger ... sorry bout that
Trigger:
  • Move Fig
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • tmp_bool2 Equal to False
    • Actions
      • Set tmp_bool2 = True
      • Set tmp_point[0] = (Target point of issued order)
      • Unit - Pause (Triggering unit)
      • Unit - Unpause (Triggering unit)
      • Set tmp_regi[0] = (Region centered at tmp_point[0] with size (200.00, 200.00))
      • Unit Group - Pick every unit in tmp_ugrp[1] and do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: (Name of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (tmp_regi[0] contains (Picked unit)) Equal to True
            • Then - Actions
              • Game - Display to (All players) the text: ((Name of (Picked unit)) + <-)
              • Set tmp_unit[8] = (Picked unit)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Point-value of tmp_unit[8]) Equal to 11
        • Then - Actions
          • Unit Group - Pick every unit in tmp_ugrp[1] and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Picked unit) Not equal to tmp_unit[8]
                • Then - Actions
                  • Unit - Add a 0.00 second Generic expiration timer to (Picked unit)
                  • Unit - Remove (Picked unit) from the game
                • Else - Actions
          • Unit Group - Remove all units from tmp_ugrp[1]
          • Custom script: call DestroyGroup (udg_tmp_ugrp[1])
          • Set tmp_ugrp[1] = (Units owned by Player 1 (Red))
          • Custom script: call RemoveLocation (udg_tmp_point[0])
          • Custom script: call RemoveRect(udg_tmp_regi[0])
          • For each (Integer B) from 0 to 7, do (Actions)
            • Loop - Actions
              • Animation - Change tmp_unit[(Integer B)]'s vertex coloring to (100.00%, 100.00%, 100.00%) with 0.00% transparency
          • Set Turn = (Substring(Turn, 1, 1))
          • Set tmp_point[0] = (Position of tmp_unit[8])
          • Unit - Move M_Dummy instantly to tmp_point[0]
          • Trigger - Run Return to Owner <gen> (ignoring conditions)
          • Unit - Order (Triggering unit) to Move To tmp_point[0]
          • Custom script: call RemoveLocation (udg_tmp_point[0])
          • Wait 0.00 seconds
          • Skip remaining actions
        • Else - Actions
      • Custom script: call RemoveLocation (udg_tmp_point[0])
      • Custom script: call RemoveRect(udg_tmp_regi[0])
      • Set tmp_bool2 = False

Ok so I use only event Unit - A unit Is issued an order targeting a point and there is no events added by other triggers. I got none trigger with events Unit - A unit Is issued an order with no target. But it doesn't matter cause pause/unpause cause this particular trigger to loop. I got the game messages all the time.

The loop is not infinite though. The trigger only loops when the unit is not issued something else(I think) cause when I click near a unit from tmp_ugrp[1] then the trigger proceed with the actions in the big IF and stops looping.
 

Curo

Why am I still playing this game...?
Reaction score
109
If you want a unit to stand still, order it to stop or even hold position.

What are the events and conditions, btw? Are you still having problems?
 

eXirrah

New Member
Reaction score
51
If you want a unit to stand still, order it to stop or even hold position.

What are the events and conditions, btw? Are you still having problems?

This was my original idea but this doesn't work for me. If I order the unit to stop it won't I need to add wait action. If I add wait even with 0.00 sec wait then clicking very fast will cause the unit to move.

EDIT: To Genyuumaru well yeah but another problem occurs. If you double press right button very fast the units order is not halted and it is moving free. I mean if you manage to beat the time of repeating this trigger has then the unit is still in that group and it skips all the action, which are to prevent it to move freely.
 

SomaZ

New Member
Reaction score
3
OKAY ENOUGH :D

I've started a new account, because the old one is:
1. Not mine, but a friend's.
2. Has bad reputation for breaking some rules???
3. Has broken reputation where I can't get rep from people :p

Previosly known as Genyuumaru I am now SomaZ (aka SomaZ *meister).

^^

Well okay, didn't this help you?

1. Add Triggering Unit to a unit group, for example named "used" and continue on the trigger.
2. Then before that action, perform a check if Triggering Unit is in "used" group. If it IS then remove it from "used" and skip remaining actions. If it's not then go to #1.

Edit: And I can't believe this doesn't stop the unit:
After pausing the unit, order it to stop and unpause it after that.
 

eXirrah

New Member
Reaction score
51
What are the events and conditions, btw? Are you still having problems?

Well I do have problem with pause/unpause unit and not the if condition, which is dependent on each other. But I think I don't have the means to change the topic subject to Trigger: problem with pause/unpause unit.

EDIT: Well it's not that it doesn't help. It's that this solution allows the unit to move freely if you click fast enought. You want me to do something like that
Trigger:
  • actions
    • If triggering unit is in Used then Skip remaining action
    • Unit - pause/unpause triggering unit
    • Unit Group - add triggering unit to Used
    • ... rest of trigger

but if I click once the unit to go somewhere it checks if the unit is in the group and it is not so the trigger doesn't skip the actions and stops the unit. But what If I press again very very fast < 0.05 seconds then the trigger runs checks if the unit is in the group and skips all actions. Cause this trigger probably loops with speed of 0.05 which is the minimal for warcraft 3
 

SomaZ

New Member
Reaction score
3
Okay I have a couple of questions myself.

What is this for?
Code:
Unit - Add a 0.00 second Generic expiration timer to (Picked unit)
Unit - Remove (Picked unit) from the game

Only 1 of them should be used I believe.

Also, Point Value is something new to me. What's that?

And try actualy ordering the unit to stop.
 

eXirrah

New Member
Reaction score
51
Well in that group there are units with Glowing Runes model which I use as markers to show ppl where they can move the triggering unit. After the unit is ordered to move to one of these markers I remove the other markers cause I don't need them anymore and when the unit arrives at destination marker I remove it as well.

EDIT if you ask why I set generic expiration times and remove them .... Well I'm not quite sure that Unit - remove is leakless so I put a generic timer as well.
 

SomaZ

New Member
Reaction score
3
Try:

If Unit is in "Used" then
-Remove Unit from "Used"
-Pause Unit
-Order Unit to Stop
-Unpause Unit
else
-Add Unit to "Used"
-rest of the trigger

I don't realy get the idea how they can still move, I'll thinking about it.
As for now try this trigger and check if it works.

Edit: Yeah I found that removing units still leaks something too :D Don't know which one of them (Remove or Expiration) leaks though... Most likely they both leak.
 

eXirrah

New Member
Reaction score
51
Well works exactly as I described above
Trigger:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • ((Triggering unit) is in tmp_ugrp[2]) Equal to False
    • Then - Actions
      • Unit - Pause (Triggering unit)
      • Unit - Order (Triggering unit) to Stop
      • Unit - Unpause (Triggering unit)
      • Unit Group - Add (Triggering unit) to tmp_ugrp[2]
    • Else - Actions
      • Unit Group - Remove (Triggering unit) from tmp_ugrp[2]

If you press once the trigger stops to loop cause of this condition and the unit stands still. But when I press 2 times very very fast the unit moves freely.
The trigger loops probably with speed of 0.05 seconds which is enought for a player to press 2 times the right button. So here how this proceeds:
I press once the trigger runs checks if the unit is in tmp_ugrp[2] and it is not so it pauses it orders to stop and unpauses it. after that it adds the unit to tmp_ugrp[2]
I don't press twice: the trigger loops checks if the unit is in the group and it is so the trigger removes it and don't pause the unit
I press twice <0.05 sec: the trigger runs checks if the unit is in the group and it is so the trigger don't pause it and the unit completes the order successfuly and moves to the destination point. This is the case I want to prevent from happening.

I'll post the map as well so you can try it.

EDIT: I will remove the map from the attachments cause I will probably need the space for other things
 

Curo

Why am I still playing this game...?
Reaction score
109
Oh the chess map, I remember! I think you should just make the units buildings to that they can't move, and give them custom spells that move them (trigger-based of course). Have you ever played Soul Chess? That's how it's done in there.

Anyways, if you want to stick with this method, I think you are looking too deep into it again. Just make the trigger fire when the unit is ordered to move/smart/attack, and pause/stop/unpause the unit. I don't see how that can't work.

Btw, units don't leak unless you don't remove them from the map (in any way). Just use an expiration timer and you are fine.
 

eXirrah

New Member
Reaction score
51
Well I almost done it, but I just need to stop the looping of this trigger. Which is some WE bug I think....

EDIT: I set a condition witch checks all the order types and only if patrol,smart,attack or move is ordered then to run the trigger. No luck it doesn't check any conditions and stuff... just loops it... As you can see I set a bool = true at the beggining of the trigger and set it to false at the end and the trigger only works if this var is equal to false. Pause/Unpause is in the middle so this trigger should not be triggered at this time by any order I issue. It is a problem of Pause/Unpause unit.
 

Curo

Why am I still playing this game...?
Reaction score
109
Well I almost done it, but I just need to stop the looping of this trigger. Which is some WE bug I think....

EDIT: I set a condition witch checks all the order types and only if patrol,smart,attack or move is ordered then to run the trigger. No luck it doesn't check any conditions and stuff... just loops it... As you can see I set a bool = true at the beggining of the trigger and set it to false at the end and the trigger only works if this var is equal to false. Pause/Unpause is in the middle so this trigger should not be triggered at this time by any order I issue. It is a problem of Pause/Unpause unit.

I don't really understand what you mean when you say it is looping. If it has a proper event, it should only trigger on that event. What you should do is turn the trigger off at the beginning of the trigger, then turn it back on at the end. Try that first without all your booleans and unit groups, etc.
 

eXirrah

New Member
Reaction score
51
See there in my trigger there is a Game - Message to all players. Well the message is appearing non-stop... which means the trigger is looping.

DL the map and run it. You will see...

EDIT: The version of the map that I uploaded the trigger that causing the problems are Move Fig and Attack Fig. At Move Fig just remove the if and put pause/unpause triggering unit as it was before I edit it. And the trigger will start to loop when you order the unit to go somewhere except for marked areas.... My question is why and how can this be fixed.
Trigger:
  • Melee Initialization
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
    • Actions
      • Trigger - Turn off (This trigger)
      • Unit - Pause (Triggering unit)
      • Unit - Unpause (Triggering unit)
      • Game - Display to (All players) the text: asd
      • Trigger - Turn on (This trigger)

Turning trigger off and on doesnt help....

I uploaded a map with just this trigger for anyone that wants to try this and don't wanna check all my triggers for errors and stuff, cause there are none that can cause this effect except pause/unpause unit.
 

SomaZ

New Member
Reaction score
3
I'm back ! :)

Well if it's looping (WE bug) probably then you have no other choice except for creating some kind of wait or using some kind of timer.

Like:
Code:
If Unit is in "Used" then
-Remove Unit from "Used"
-Turn Off (This Trigger)
-Pause Unit
-Order Unit to Stop
-Unpause Unit
-Countdown timer - Start MyTimer as a oneshoot timer that will expire in 0.1 seconds
else
-Add Unit to "Used"
-rest of the trigger

Code:
Event
-MyTimer Expires
Actions
-Trigger - Turn on (above trigger) <gen>

Hope this helps :)

Edit: Oh, and removing units DOES leak. Looks like it's more of a graphical leak rather than a memory leak.
This is very simple to check.

Create a trigger that runs every 1 second and creates 1 invisible dummy unit at some point (lets assume that the point leak is removed in this trigger), waits 0.5 and removes it from the game with the Unit - Remove Unit action. Or you can just use an expiration timer.

You will see that after some time your fps will go down. But you won't see ANYTHING on the screen as the unit is invisible (and it's removed anyway). On my PC (kind of an old PC, but not too old) the fps loss from a single dummy unit is 0.05-0.1 fps.

I think there's nothing that can be done about this. WC3 garbage collector must suck.
 

eXirrah

New Member
Reaction score
51
Hmm... Seems like it fixed itself :). The trigger doesn't loop anymore I just deleted and added Order unit to stop between pause/unpause unit. I remember having this kinda problem before where I was wondering why a trigger is not working after that I recreated the trigger the same way and it was working.
This usually happens when you remove some variable and the editor disables the function using the variable. But when you set a new variable in that function somethimes the function stays disabled but displays as enabled and you have to delete it and put it there again.
I guess that was the problem in my case. It took me 3 hours to manage with this.....

Thanks everyone for helping me + rep
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Edit: Oh, and removing units DOES leak. Looks like it's more of a graphical leak rather than a memory leak.
This is very simple to check.

Create a trigger that runs every 1 second and creates 1 invisible dummy unit at some point (lets assume that the point leak is removed in this trigger), waits 0.5 and removes it from the game with the Unit - Remove Unit action. Or you can just use an expiration timer.

You will see that after some time your fps will go down. But you won't see ANYTHING on the screen as the unit is invisible (and it's removed anyway). On my PC (kind of an old PC, but not too old) the fps loss from a single dummy unit is 0.05-0.1 fps.

I think there's nothing that can be done about this. WC3 garbage collector must suck.

That's simply not true. I'm not sure you understand the definition of leaks. All objects are stored in the memory, and left there until they are needed. It is considered a leak when it is not possible for the object to be needed for the rest of the game. Removing a unit removes the unit from the memory, does require some computer power, which is why you get a small drop in FPS.

@ Original Post:

Units with the Locust ability cannot be detected by Pick every Unit in <Region> and many other types of ways. However, you CAN get units with locust, if you do Pick every Unit of Type. Then, you could check to see if the units were inside the rect, by checking if the point (the picked unit's position) is inside the region.
 

eXirrah

New Member
Reaction score
51
Hmm... I used another way to find these units. When they are created I put them in unit group and then I check if the unit is in that unit group. Btw how do you check the war3 FPS is there some function or with some software?

EDIT: Thanks for the tips Darthfett + rep. If you are still here can you tell me why when I set the time of dawn and dusk to other values like 08 and 21 in gameplay constants the day and the night still change at 18 and 6 o'clock game time?

EDIT2: I ran this trigger and didn't get any progressive fps drop. FPS dropped only when the units are removed and created so I guess Unit - Remove unit doesn't leaks.
Trigger:
  • Melee Initialization
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Set point = (Center of (Playable map area))
      • Unit - Create 35 Footman for Player 1 (Red) at point facing Default building facing degrees
      • Set units = (Units owned by Player 1 (Red))
      • Custom script: call RemoveLocation(udg_point)
      • Wait 0.05 seconds
      • Unit Group - Pick every unit in units and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game
      • Custom script: call DestroyGroup(udg_units)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top