• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

Is there a way to combine regions?

Status
Not open for further replies.
  • Region - MoveRegion
This doesn't even make sense. You can't move a region >.<.

You can move a rect though
MoveRectTo

; )


You can combine rects by adding them to the same region.
JASS:
local region r = CreateRegion()
local rect r1 = Rect(xmin,ymin,xmax,ymax)
local rect r2 = Rect(xmin,ymin,xmax,ymax)
call RegionAddRect(r,r1)
call RegionAddRect(r,r2)


In GUI, rects placed on the map are automatically added to a single region so that each rect on the map can also act as a region. This makes many GUI users think that their rects are in fact regions when this is not the case.

Rect variable names are gg_rct_RECT_NAME where all spaces in your name are replaced with underscores. You can access the rects on your map directly doing this and add them to a single region. From here, you can access your GUI trigger and register it with that region : ). This requires a bit of JASS knowledge to pull off : P.
 
  • Region - MoveRegion
This doesn't even make sense. You can't move a region >.<.

You can move a rect though
MoveRectTo

; )


You can combine rects by adding them to the same region.
JASS:
local region r = CreateRegion()
local rect r1 = Rect(xmin,ymin,xmax,ymax)
local rect r2 = Rect(xmin,ymin,xmax,ymax)
call RegionAddRect(r,r1)
call RegionAddRect(r,r2)


In GUI, rects placed on the map are automatically added to a single region so that each rect on the map can also act as a region. This makes many GUI users think that their rects are in fact regions when this is not the case.

Rect variable names are gg_rct_RECT_NAME where all spaces in your name are replaced with underscores. You can access the rects on your map directly doing this and add them to a single region. From here, you can access your GUI trigger and register it with that region : ). This requires a bit of JASS knowledge to pull off : P.

Will i need to do all the triggers in JASS to reference the region? it seems (and you mightve said this, lol) that there are no regions in GUI, only rects
 
JASS:
native IsLocationInRegion takes region whichRegion, location whichLocation returns boolean
native IsPointInRegion takes region whichRegion, real x, real y returns boolean
native IsUnitInRegion takes region whichRegion, unit whichUnit returns boolean
native RegionAddCell takes region whichRegion, real x, real y returns nothing
native RegionAddCellAtLoc takes region whichRegion, location whichLocation returns nothing
native RegionAddRect takes region whichRegion, rect r returns nothing
native RegionClearCell takes region whichRegion, real x, real y returns nothing
native RegionClearCellAtLoc takes region whichRegion, location whichLocation returns nothing
native RegionClearRect takes region whichRegion, rect r returns nothing
native TriggerRegisterEnterRegion takes trigger whichTrigger, region whichRegion, boolexpr filter returns event
native TriggerRegisterLeaveRegion takes trigger whichTrigger, region whichRegion, boolexpr filter returns event
 
JASS:
native IsLocationInRegion takes region whichRegion, location whichLocation returns boolean
native IsPointInRegion takes region whichRegion, real x, real y returns boolean
native IsUnitInRegion takes region whichRegion, unit whichUnit returns boolean
native RegionAddCell takes region whichRegion, real x, real y returns nothing
native RegionAddCellAtLoc takes region whichRegion, location whichLocation returns nothing
native RegionAddRect takes region whichRegion, rect r returns nothing
native RegionClearCell takes region whichRegion, real x, real y returns nothing
native RegionClearCellAtLoc takes region whichRegion, location whichLocation returns nothing
native RegionClearRect takes region whichRegion, rect r returns nothing
native TriggerRegisterEnterRegion takes trigger whichTrigger, region whichRegion, boolexpr filter returns event
native TriggerRegisterLeaveRegion takes trigger whichTrigger, region whichRegion, boolexpr filter returns event

I was looking at those, but i didn't know if i missed the function that would do it. My homemade function =

JASS:
function GetRandomInteger takes integer a returns boolean
    return ( GetRandomInt(1, a) == 1 )
endfunction

function RandomSpawnInRegion takes integer unitid, integer chance, rect randomloc, region r  returns nothing
    set udg_Temp_Integer = 1
    loop
        exitwhen udg_Temp_Integer > 1
        set udg_Temp_Point = GetRandomLocInRect(randomloc)
            if (IsLocationInRegion(r, udg_Temp_Point)) then
            if (GetRandomInteger(chance)) then
                call CreateNUnitsAtLoc( 1, unitid, Player(PLAYER_NEUTRAL_AGGRESSIVE), udg_Temp_Point, bj_UNIT_FACING )
                call RemoveLocation(udg_Temp_Point)
            else
            call RemoveLocation(udg_Temp_Point)
            endif
            set udg_Temp_Integer = 2
        else
        call RemoveLocation(udg_Temp_Point)
        endif
    endloop
endfunction

Hopefully it works, ima test.
 
^The first two fixes I would do are to use CreateUnit instead of CreateNUnits...and only use the last RemoveLocation.

JASS:
library RandomSpawnInRegion
function GetRandomInteger takes integer a returns boolean
    return ( GetRandomInt(1, a) == 1 )
endfunction

function RandomSpawnInRegion takes integer unitid, integer chance, rect randomloc, region r  returns nothing
    set udg_Temp_Integer = 1
     call DisplayTextToForce(GetPlayersAll(), "triggered3")
    loop
        exitwhen udg_Temp_Integer > 1
        set udg_Temp_Point = GetRandomLocInRect(randomloc)
            if (IsLocationInRegion(r, udg_Temp_Point)) then
                call DisplayTextToForce(GetPlayersAll(), "triggered1")
                if (GetRandomInteger(chance)) then
                    call DisplayTextToForce(GetPlayersAll(), "triggered2")
                    call CreateNUnitsAtLoc( 1, unitid, Player(PLAYER_NEUTRAL_AGGRESSIVE), udg_Temp_Point, bj_UNIT_FACING )
                    call RemoveLocation(udg_Temp_Point)
                    call DisplayTextToForce(GetPlayersAll(), "triggered")
                     set udg_Temp_Integer = 2
                else
                call RemoveLocation(udg_Temp_Point)
                endif
            else
            call RemoveLocation(udg_Temp_Point)
            endif
    endloop
endfunction
endlibrary

This only returns "triggered3"....

call RandomSpawnInRegion('H00J', 1, gg_rct_Kobold_Overlap, KoboldSpawn) is what i used to call it. Whatd i do wrong? :s
 
JASS:
library RandomSpawnInRegion
function GetRandomInteger takes integer a returns boolean
    return ( GetRandomInt(1, a) == 1 )
endfunction

function RandomSpawnInRegion takes integer unitid, integer chance, rect randomloc, region r  returns nothing
    set udg_Temp_Integer = 1
     call DisplayTextToForce(GetPlayersAll(), "triggered3")
    loop
        exitwhen udg_Temp_Integer > 1
        set udg_Temp_Point = GetRandomLocInRect(randomloc)
            if (IsLocationInRegion(r, udg_Temp_Point)) then
                call DisplayTextToForce(GetPlayersAll(), "triggered1")
                if (GetRandomInteger(chance)) then
                    call DisplayTextToForce(GetPlayersAll(), "triggered2")
                    call CreateNUnitsAtLoc( 1, unitid, Player(PLAYER_NEUTRAL_AGGRESSIVE), udg_Temp_Point, bj_UNIT_FACING )
                    call RemoveLocation(udg_Temp_Point)
                    call DisplayTextToForce(GetPlayersAll(), "triggered")
                     set udg_Temp_Integer = 2
                else
                call RemoveLocation(udg_Temp_Point)
                endif
            else
            call RemoveLocation(udg_Temp_Point)
            endif
    endloop
endfunction
endlibrary

This only returns "triggered3"....

call RandomSpawnInRegion('H00J', 1, gg_rct_Kobold_Overlap, KoboldSpawn) is what i used to call it. Whatd i do wrong? :s

bump
 
Status
Not open for further replies.
Back
Top