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

[General] Newgen Odd Region Scripts

Status
Not open for further replies.
Level 6
Joined
Sep 11, 2006
Messages
172
Hello Hive,

So, I'm using a version of Newgen World Editor that appears to have a lot options added into the GUI to help manage JASS regions. Which is certainly interesting to me.

Problem is though, that a simple check if unit in region (ie GUI Rect) condition will not work.

Here's an example that won't work.

  • Example Trigger
    • Events
      • Unit - A unit enters Gate Rect <gen>
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Gate Rect <gen> contains (Triggering unit)) Equal to True
        • Then - Actions
          • Game - Display to (All players) the text: Hi! :) ------------...
        • Else - Actions
The IF/THEN action will not fire even though it should fire immediately after the trigger begins, because the triggering unit is still in the triggering region.

A major trigger block in the GUI relies on this type of function working for my map.

What is Newgen doing differently with the rects and regions?
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
This is not something about editor difference.Unit enters region event fires when a part of unit enters region, but that condition check if center of the unit is in the region.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,190
This is not something about editor difference.Unit enters region event fires when a part of unit enters region, but that condition check if center of the unit is in the region.
Not entirely true. When the event fires this should return true.

JASS:
native IsUnitInRegion takes region whichRegion,unit whichUnit returns boolean

The problem is because he is not testing if the unit is in the region, but rather if the origin point of the unit is inside the rect he used to create the region for the event. This is why people really should learn JASS as WC3 triggers are a real mess.

This is the JASS for the "Unit - A unit enters" event.
JASS:
function TriggerRegisterEnterRectSimple takes trigger trig,rect r returns event
    local region rectRegion = CreateRegion()
    call RegionAddRect(rectRegion, r)
    return TriggerRegisterEnterRegion(trig, rectRegion, null)
endfunction

I recall someone in the past saying that the "RegionAddRect" native is slightly buggy. It will incorrectly fill the cells for the rect such that even a cell aligned rect will not be reproduced correctly as a region. I forget if it was 1 cell too many or too few on both axis or if it was the minimum or maximum bound that it occurred at (I think maximum). As such testing if a point is inside a region by testing if the point is inside the filling rect is incorrect logic since they do not represent the same area.
 
Status
Not open for further replies.
Top