View Single Post
Old 03-03-2015, 06:10 AM   #5
default string
Fledermaus's Avatar
Join Date: May 2006
Posts: 705

Submissions (1)

Fledermaus is a jewel in the rough (194)Fledermaus is a jewel in the rough (194)Fledermaus is a jewel in the rough (194)

Send a message via MSN to Fledermaus

The problem is that the GUI event
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)

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

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
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
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:
Fledermaus is offline   Reply With Quote