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

Locust, moving & enter regions, unit groups

Status
Not open for further replies.

deepstrasz

Map Reviewer
Level 69
Joined
Jun 4, 2009
Messages
18,847
What am I doing wrong? Please help. I'm going nuts.
The ArcaneBlast unit is flying and has the Locust ability. There's a region moving with (periodic event).
The problem is, that when ArcaneBlast gets near enemy units, it very rarely triggers the last part of the triggers (where an enemy enters said region and something happens).
Tried a unit comes within range of unit but the locust unit isn't detected.

  • Faceless 3n4 Spell Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Conditions
            • (Ability being cast) Equal to Arcane Blast (Channel)
        • Then - Actions
          • Game - Display to (All players) the text: ARCANE CAST
          • Unit - Create 1 Arcane Blast for Player 4 (Purple) at (Position of (Casting unit)) facing (Facing of (Casting unit)) degrees
          • Set ArcaneBlast01 = (Last created unit)
          • Unit - Add a 4.00 second Generic expiration timer to ArcaneBlast01
          • Unit - Order ArcaneBlast01 to Move To (Target point of ability being cast)
          • Set ArcaneBlast01PositionReg = (Region centered at (Position of ArcaneBlast01) with size (1000.00, 1000.00))
          • Trigger - Add to Faceless 3n4 Spell Slow Copy <gen> the event (Unit - A unit enters ArcaneBlast01PositionReg)
          • Trigger - Turn on Faceless 3n4 Spell Slow Copy <gen>
          • Trigger - Turn on Faceless 3n4 Spell Region Move <gen>
          • Game - Display to (All players) the text: (ARCANE REG 01 + (String((Distance between (Position of ArcaneBlast01) and (Center of ArcaneBlast01PositionReg)))))
        • Else - Actions
          • Do nothing
  • Faceless 3n4 Spell Region Move
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Region - Center ArcaneBlast01PositionReg on (Position of ArcaneBlast01)
      • Game - Display to (All players) the text: (ARCANE REG 02 + (String((Distance between (Position of ArcaneBlast01) and (Center of ArcaneBlast01PositionReg)))))
      • Game - Display to (All players) the text: (String((Center X of ArcaneBlast01PositionReg)))
  • Faceless 3n4 Spell Slow Copy
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Entering unit)) Equal to Player 1 (Red)
        • Then - Actions
          • Game - Display to (All players) the text: ENTERED
          • Unit - Kill ArcaneBlast01
          • Unit Group - Pick every unit in (Units within 200.00 of (Position of ArcaneBlast01) matching (((Matching unit) belongs to an enemy of Player 4 (Purple)) Equal to True)) and do (Actions)
            • Loop - Actions
              • Game - Display to (All players) the text: Arcane HITS
              • Unit - Create 1 Arcane Blast Slow Caster for Player 4 (Purple) at (Position of (Picked unit)) facing (Facing of (Picked unit)) degrees
              • Set ArcaneBlastSlow01 = (Last created unit)
              • Unit - Add a 4.00 second Generic expiration timer to ArcaneBlastSlow01
              • Unit - Order ArcaneBlastSlow01 to Human Sorceress - Slow (Picked unit)
          • Trigger - Turn off Faceless 3n4 Spell Slow Copy <gen>
          • Trigger - Turn off Faceless 3n4 Spell Region Move <gen>
        • Else - Actions
          • Do nothing
So, the ENTERED game text is rarely displayed too.
 
When I copied your triggers I found out that when you use this "(Unit - A unit enters ArcaneBlast01PositionReg)" It makes a (let's say)copy of that region and uses it. That's why when the locust came near the units the Slow couldn't trigger. I moved enemy unit near the point where the locust was created and it the slow trigger triggered.

You said when you used Unit comes within and it didn't work but for some reason, it worked for me.
Here are the sloppy triggers
  • Cast Copy
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Blizzard
        • Then - Actions
          • Unit - Create 1 Locust for Player 1 (Red) at (Position of (Casting unit)) facing Default building facing degrees
          • Unit - Add a 99.00 second Generic expiration timer to (Last created unit)
          • Unit - Order (Last created unit) to Move To (Target point of ability being cast)
          • Set u = (Last created unit)
          • Trigger - Add to Slow <gen> the event (Unit - A unit comes within 1024.00 of u)
          • Trigger - Turn on Slow <gen>
        • Else - Actions
  • Slow
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Entering unit)) Equal to Player 2 (Blue)
        • Then - Actions
          • Game - Display to (All players) the text: (Name of (Entering unit))
          • Game - Display to (All players) the text: Done!
        • Else - Actions
 

Attachments

  • Works.-..w3x
    18.6 KB · Views: 38

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
The event "enters a region" 'copies' the region as Avatars Lord said, so moving the region will have no effect on the event.

Locust units are a bit special. They are not affected by "units in range", and will probably be ignored by "a unit comes within range of ..." as well.
You can always use a periodic trigger to compare the distance of the unit to its target.
 

deepstrasz

Map Reviewer
Level 69
Joined
Jun 4, 2009
Messages
18,847
When I copied your triggers I found out that when you use this "(Unit - A unit enters ArcaneBlast01PositionReg)" It makes a (let's say)copy of that region and uses it.
Why does it make a sort of copy if I trigger the region to be moved? You're saying the region isn't being moved at least properly? The tracing game text shows that the region is being moved from the initial point and the distance between it and the moving locust unit is 0.

Tried with the within range again and it works... but also doesn't. This is bizarre. I think the problem now is the unit group being made around the locust unit as the text when it comes near a unit always appears.
Weird, it works every time if I set the range around the locust unit to 300 instead of 200. But that's too much because the locust unit looking like an FX will cause slow by visually not touching the enemy.

You can always use a periodic trigger to compare the distance of the unit to its target.
Am I to spam pick every unit around the locust unit once in 0.10 seconds?


EDIT: It's pretty much working now with the a unit comes within range of unit event. I just had to make the unit bigger, set the range lower than 200 and then could also reduce the area around the locust unit lower than 200.

Thanks guys!
 
Last edited:

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
Technical explanation why the region event does not work:
A region is called rect in jass. There is another type in jass called region, which does not exist in GUI. The jass region is not rectangular, but can be seen as the combined area of multiple rects/GUI-regions.
When you use the event "enters region" a new Jass-region is created. Initially, this region is empty. Then the GUI-region or JASS-rect, you use in your event is added to the Jass-region.
Once the GUI-region is added to the JASS-region, changing the GUI-region will not affect the JASS-region anymore.
The JASS-region is used internally for the event.
You can even destroy the GUI region after it was added to the "enters region" event. If you only use your region for the enters region event, you could remove it at map initialization to save some memory.

Most missile systems periodically (usually around every 0.03 seconds) create unit groups to check for nearby units. If done properly this is no problem at all.
If not too many units are nearby and missile number is kept at a normal value, you won't have any lag problems.

"Comes within range of" should also work and may be faster. It is a bit more difficult, especially if the system needs to be MUI. Also it requires you to periodically rebuild the trigger, if you want to prevent event leak.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
A region is comprised of map play field cells where as a rect is a rectangular area of the map. Unless specifically aligned, a region cannot represent the area of a rect perfectly.

It is worth noting that assigning a lot of map play field cells to regions can result in Warcraft III becoming extremely buggy. For example the unit path finder will break down and try to guide units straight into walls as opposed to running around them as normal. For this reason one should only ever use 1 "unit enters playable map area" style event, and get the actions of that trigger to run any separate triggers where the event is needed.
 
Why does it make a sort of copy if I trigger the region to be moved? You're saying the region isn't being moved at least properly? The tracing game text shows that the region is being moved from the initial point and the distance between it and the moving locust unit is 0.
Jampion explained it very well.

Tried with the within range again and it works... but also doesn't. This is bizarre. I think the problem now is the unit group being made around the locust unit as the text when it comes near a unit always appears.
Weird, it works every time if I set the range around the locust unit to 300 instead of 200. But that's too much because the locust unit looking like an FX will cause slow by visually not touching the enemy.

So what you are saying is that The Slow trigger triggers multiple times? If that so turn of the Slow trigger or just remove the ArcaneBlast01 unit rather than killing it after the Unit Group.Because the corpse of ArcaneBlast01 is still there and unit still can come within.
Also picking unit group around the locust every 0.03 is fine if you destroy the unit group and position. It might be better than unit comes within
 

deepstrasz

Map Reviewer
Level 69
Joined
Jun 4, 2009
Messages
18,847
So what you are saying is that The Slow trigger triggers multiple times?
No. I meant sometimes, the slow didn't appear at all. Now it works. I gotta make the damage only apply once per selected unit. I could do it by eliminating units who already have the slow buff but then if another arcane blast is cast and those units will have the slow buff, they won't get damaged. I'm thinking something with a picked unit variable but it's fuzzy.
 
Status
Not open for further replies.
Top