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. The 18th Icon Contest is ON! Choose any ingame unit and give him/her Hero abilities. Good luck to all.
    Dismiss Notice
  4. The Secrets of Warcraft 3 have revealed interesting works. The RESULTS for Abelhawk's Mini-Mapping Contest #15 have come out!
    Dismiss Notice
  5. Contestants are to create a scene set in the Stone Age. Come and see what you can come up with. We wish you the best of luck!
    Dismiss Notice
  6. Colour outside the lines! Techtree Contest #13 is a go. The contest is optionally paired.
    Dismiss Notice
  7. Night Rider gained several songs for his journey. The poll for the 12th Music Contest has started. Check it out!
    Dismiss Notice
  8. Greetings cerebrates, our Swarm needs new spawners that will have numerous children. Join the HIVE's 31st Modeling Contest - Spawners and Spawned! The contest is optionally paired.
    Dismiss Notice
  9. Join other hivers in a friendly concept-art contest. The contestants have to create a genie coming out of its container. We wish you the best of luck!
    Dismiss Notice
  10. 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.

[Wurst] Pathing

Discussion in 'Submissions' started by Chaosy, Aug 16, 2019 at 12:48 PM.

  1. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,600
    Resources:
    18
    Maps:
    1
    Spells:
    11
    Tutorials:
    6
    Resources:
    18
    Straight up converted from: TerrainPathability - Wc3C.net

    Should save people some time though.

    Wurstbin

    Code (WurstScript):

    package pathable

    constant real    MAX_RANGE     = 10.
    constant integer DUMMY_ITEM_ID = 'wolg'

    item pathChecker = null
    rect find  = null
    item array hid
    integer hidMax = 0

    function moveBackItems()
        while(hidMax > 0)
            hidMax = hidMax - 1
            SetItemVisible(hid[hidMax], true)
            hid[hidMax] = null

    function hideItem()
        if IsItemVisible(GetEnumItem())
            hid[hidMax] = GetEnumItem()
            hid[hidMax].setVisible(false)
            hidMax = hidMax + 1

    function hideNearbyItems(real x, real y)
        MoveRectTo(find, x, y)
        EnumItemsInRect(find ,null, function hideItem)

    function isTerrainWalkable(real x, real y) returns boolean
        hideNearbyItems(x, y)
        pathChecker.setPos(vec2(x, y))

        real itemPosX = pathChecker.getX()
        real itemPosY = pathChecker.getY()

        pathChecker.setVisible(false)
        return (itemPosX-x)*(itemPosX-x)+(itemPosY-y)*(itemPosY-y) <= MAX_RANGE*MAX_RANGE and not IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY)

    public function vec2.isTerrainWalkable() returns boolean
        return isTerrainWalkable(this.x, this.y)

    public function isTerrainWalkable(vec2 pos) returns boolean
        return isTerrainWalkable(pos.x, pos.y)

    init  
        find = Rect(0., 0., 128., 128.)
        pathChecker = CreateItem(DUMMY_ITEM_ID, 0, 0)
        ..setVisible(false)
     
     
  2. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    7,994
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    Are there plans to change the conversion of Wurst from into JASS to into Lua? There is a lot more flexibility to be gained and in some cases even significant performance improvements.
     
  3. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,600
    Resources:
    18
    Maps:
    1
    Spells:
    11
    Tutorials:
    6
    Resources:
    18
    I'm afraid I am not the right person to ask about that. @Frotty

    edit: Or do you mean I should convert it to LUA and then to wurst myself? I assumed you meant the wurst compiler.
     
  4. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    7,994
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    I meant the Wurst compiler but yeah I guess Frotty is the right point of contact for that. Sorry been a long few weeks but this isn't exactly the right platform for said query of course.
     
  5. Frotty

    Frotty

    Wurst Reviewer

    Joined:
    Jan 1, 2009
    Messages:
    1,406
    Resources:
    11
    Models:
    3
    Tools:
    1
    Maps:
    5
    Tutorials:
    1
    Wurst:
    1
    Resources:
    11
    Experimental lua backend exists, you can try it out with `-lua` runargs, but it still has many issues.
    It's on the roadmap, but not really a high priority.
     
  6. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    7,994
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    Maybe it's easier to convert to TypeScript then?