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

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
 
Level 1
Joined
Apr 8, 2020
Messages
5
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!
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,540
  • 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

  • Fix Regions.w3m
    16.7 KB · Views: 33
Status
Not open for further replies.
Top