• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

RectContainsUnit doesn't work

Status
Not open for further replies.
Level 1
Joined
Apr 8, 2020
Messages
5
Hi guys,
I'm encountering a big problem with triggers.
I've 2 trigger.
One of this is in GUI:
  • UnitEntersInSide
    • Events
      • Unit - A unit enters Region 042 <gen>
      • Unit - A unit enters Side Team 1 <gen>
      • Unit - A unit enters Side Team 2 <gen>
      • Unit - A unit enters Side Team 3 <gen>
      • Unit - A unit enters Side Team 4 <gen>
    • Conditions
      • ((Triggering unit) is A structure) Equal to Falso
    • Actions
      • Custom script: call Trig_DispatchUnitMove_Actions(GetTriggerUnit())
The second one is in JASS and it is:

Code:
function Trig_DispatchUnitMove_Actions takes unit unitToDispatch returns nothing
    call DisplayTextToForce( GetPlayersAll(), "HEY1" )
    if(RectContainsUnit(gg_rct_Center, unitToDispatch)) then
    call DisplayTextToForce( GetPlayersAll(), "HEY2" )
    call Trig_DispatchUnitFromCenter_Actions(unitToDispatch)
    endif
    set unitToDispatch = null
endfunction

The problem is that the if doesn't fire with gg_rct_Center. It shows "HEY1" and stop.
If I change region, it works.
My region is here:
View attachment 351910
I thought it was cause of regions inside the biggest and I've done them smaller. I've changed name at regions with "CenterH1" and similar, but still it doesn't fire.
Can you help me to understand why?
Thank you <3
 
Have you read the linked thread?
Yes, but I'd not understood what I could do to solve my problem, cause I'm not so expert in JASS and this point "There are functions to add rects and cells to a region." has not be so cloear to me.

Can the rect be considered a radius in your use case or does it need to be rectangular? Might be easier to just use IsUnitInRangeXY and fetch the region center with GetRectCenterX() and GetRectCenterY().
Really thank you! I'll give a look to it!
 
  • Fix Regions
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: local rect r
      • -------- --------
      • -------- Set this to the number of Regions you want to fix --------
      • Set VariableSet FixRegionCount = 1
      • -------- --------
      • -------- Assign each Region you want to fix --------
      • Set VariableSet FixRegions[1] = Some Region <gen>
      • -------- --------
      • -------- Once our variables are setup, loop through all of the FixRegions and adjust them so that they have the correct size --------
      • For each (Integer A) from 1 to FixRegionCount, do (Actions)
        • Loop - Actions
          • Custom script: set r = udg_FixRegions[bj_forLoopAIndex]
          • Custom script: call SetRect(r, GetRectMinX(r) - 32., GetRectMinY(r) - 32., GetRectMaxX(r) + 32., GetRectMaxY(r) + 32.)
          • Custom script: set r = null
 

Attachments

Status
Not open for further replies.
Back
Top