1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. We have recently started the 16th edition of the Mini Mapping Contest. The theme is mini RPG. Do check it out and have fun.
    Dismiss Notice
  4. Dismiss Notice
  5. The Highway to Hell has been laid open. Come along and participate in the 5th Special Effect Contest.
    Dismiss Notice
  6. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[General] Tiny rects

Discussion in 'World Editor Help Zone' started by gusanomental, Jul 11, 2018.

  1. gusanomental

    gusanomental

    Joined:
    Oct 16, 2013
    Messages:
    239
    Resources:
    2
    Maps:
    2
    Resources:
    2
    I need kind of a precise way to detect whenever a unit enters a really small area. Is it possible to set a rect to lower than 32x32? If not, is there any workaround available?

    Thank you in advance.
     
  2. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,716
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Yes it is possible. I do not think there is a limit as to how small a rect can be.

    However be aware the unit enters/exits region event uses a region and not a rect. Regions work in map cells so the smallest region one can represent is 32x32 units.
     
  3. nedio95

    nedio95

    Joined:
    Mar 24, 2011
    Messages:
    1,055
    Resources:
    1
    Spells:
    1
    Resources:
    1
    That was a pretty roundabout way to say "No. Watch the terms you are using..." :|

    I guess you could have a region around the area you need and when a unit enters it start your own box collision checking if the coordinates of the unit correspond with the coordinates of the tiny area.

    @Dr Super Good Would that work, or ?


    -Ned
     
  4. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,716
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    That would work, however there might be scaling issues if you have dozens or thousands of such regions with units in them.
     
  5. gusanomental

    gusanomental

    Joined:
    Oct 16, 2013
    Messages:
    239
    Resources:
    2
    Maps:
    2
    Resources:
    2
    So rects can effectively have any size but now I can't find the way to prevent the leak when setting the point in 'Unit enters rect' event. Am I doing something wrong? For now, I'm using 'A unit comes within X of' along with invi dummies and I haven't found any bug... yet.

    Thanks for the help.
     
  6. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,656
    Resources:
    18
    Maps:
    1
    Spells:
    11
    Tutorials:
    6
    Resources:
    18
    More importantly, why do you need rects?

    They are mostly useless as there are better options available.
     
  7. gusanomental

    gusanomental

    Joined:
    Oct 16, 2013
    Messages:
    239
    Resources:
    2
    Maps:
    2
    Resources:
    2
    Well, my unit is fixed to vertical/horizontal rails and there's a region in every intersection where it can make 90-degree turns after stepping over. 32x32 is not small enough to make the rail change smooth.
     
  8. Kaijyuu

    Kaijyuu

    Joined:
    Jun 2, 2004
    Messages:
    848
    Resources:
    0
    Resources:
    0
    Stick a dummy unit there and use Unit Within Range events.
     
  9. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,716
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Sounds like it since the even does not even take a location object to leak...
    This is usually done by state machine of sorts. When entering a corner you use different movement logic than when going along straights, the movement is in a different state then.
     
  10. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    3,424
    Resources:
    1
    Spells:
    1
    Resources:
    1
    The solution without region enters or 'in range' events is to use a low-timeout (<0.5s) repeating timer that compare's the unit's coordinates to the min and max x/y coordinates of each rect. Store all the rest edges in arrays at map init and it won't be a memory hog, just real number comparison. You can turn the timer off when no units are moving.

    Code (vJASS):
    //pseudocode, you can do this in GUI
    loop through all such units you want to check, using index1 as counter
        Set U = units[index1]
        Set UX = X coordinate of U
        Set UY = Y coordinate of U

        loop though rects using index2 as counter
            Set mx = rectsmx[index2] //min x
            Set Mx = rectsMx[index2] //max x
            Set my = rectsmy[index2] //min y
            Set My = rectsMy[index2] //max y
            //There are functions to get these min and Max coords in jass, may have to look to locactions to do it in GUI

            if (UX <= Mx) and (UX >= mx) and (UY <= My) and (UY >= my) then
                //The index1'th unit is in the index2'th rect
                //Do whatever here
            endif
        endloop
    endloop