HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Move Region Trigger Broken?

03-02-2015, 08:21 AM#1
NotAnotherGlitch
Whenever i try and center a region on a point through triggers, the region simply does not move.
All specified regions are variables and points are valid so i don't know what is wrong.
I feel like i'm missing something really simple.
03-02-2015, 03:56 PM#2
Anitarf
How do you know that it does not move?
03-03-2015, 01:04 AM#3
NotAnotherGlitch
The trigger i'm using is supposed to center the region on a casting unit.
i added another trigger which kills any unit entering the specified region to test this.

however, when i cast the spell (which works because all other triggered actions fire) no units entering where i want the region to be will die.

furthermore, after the trigger is fired, when i move any unit to where the region was originally located the kill trigger fires.

so the region is not moving.
03-03-2015, 01:45 AM#4
NotAnotherGlitch
Here are the test triggers



And here are the triggers for one my abilities which is dependant on moving regions.
It is just Stasis Trap but using a custom stun buff so it looks like enemies are ensnared.

03-03-2015, 05:10 AM#5
Fledermaus
The problem is that the GUI event
Trigger:
Unit - A unit enters Region 000 <gen>
isn't actually registering a region. Instead it's registering a rect (which is what all "Regions" created on the map actually are).

When converted into jass it becomes this function:
Collapse JASS:
function TriggerRegisterEnterRectSimple takes trigger trig, rect r returns event
    local region rectRegion = CreateRegion()
    call RegionAddRect(rectRegion, r)
    return TriggerRegisterEnterRegion(trig, rectRegion, null)
endfunction

It creates a local region, adds the rect to it and then registers the enter event for the local region.

The
Trigger:
Region - Center Region 000 <gen> on (Center of (Playable map area))
action only moves the rec.
There is no way to actually move a region. If you had a reference to it you could clear it, move the rect and then re-add the rect but that's overly complicated and not do-able with GUI (since TriggerRegisterEnterRectSimple doesn't return the region).

A better solution would be to use the
Trigger:
Unit Group - Pick every unit in (Units within 666.00 of (Position of (Triggering unit)) matching (((Owner of (Matching unit)) is an enemy of (Owner of (Triggering unit))) Equal to True)) and do (Actions)
Loop - Actions
action.
This has the added benefit that it will select in a circular area around the unit, rather than a square/rectangle.
This action does leak a UnitGroup (and in this example a Point - Position of (Triggering unit)) but this can be fixed easily. Here's a tutorial on memory leaks.

Expand Region creation trigger from a map: