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 poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  4. Travel to distant realms and encounter scenes unknown to the common folk. The Greatest of Adventures is upon us with the 8th Cinematic Contest. Join in on a fun ride.
    Dismiss Notice
  5. The 18th Icon Contest is ON! Choose any ingame unit and give him/her Hero abilities. Good luck to all.
    Dismiss Notice
  6. 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
  7. Colour outside the lines! Techtree Contest #13 is a go. The contest is optionally paired.
    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. 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.

[vJASS] Moving through points

Discussion in 'Triggers & Scripts' started by Krogoth, May 5, 2013.

  1. Krogoth

    Krogoth

    Joined:
    Apr 5, 2011
    Messages:
    247
    Resources:
    0
    Resources:
    0
    1. When I order unit to move from point A to point C, he goes not directly, but to point B and then to point C. I need it not breaking order list.
    2. And how can I get an order list, if I can? Any possible way is good for me.
     
  2. rulerofiron99

    rulerofiron99

    Joined:
    Jul 10, 2006
    Messages:
    3,129
    Resources:
    14
    Maps:
    4
    Spells:
    9
    Tutorials:
    1
    Resources:
    14
    You'd have to code your own movement system.

    I'm not aware of any method to get the points aside from doing your own calculation to see which path the unit would take.

    AFAIK flying units move straight.
     
  3. Krogoth

    Krogoth

    Joined:
    Apr 5, 2011
    Messages:
    247
    Resources:
    0
    Resources:
    0
    So, how can I get order list (Shift+RMB) in my own movement system?

    Added:
    Okay, I can move unit instantly and get list in very short time.
    But besides that, does normal method exist?

    Added:
    Hm, strange, SetUnitPosition breaks order list. What a broken func.
     
    Last edited: May 5, 2013
  4. deathismyfriend

    deathismyfriend

    Joined:
    Oct 24, 2012
    Messages:
    6,532
    Resources:
    14
    Spells:
    12
    Tutorials:
    2
    Resources:
    14
    what do u mean setunitx/y breaks the order list ? if ur tlking about the given order then yes it may. but when moving units u dont need an order. u just move them towards the next point. use an array to see what point they hit.
     
  5. Krogoth

    Krogoth

    Joined:
    Apr 5, 2011
    Messages:
    247
    Resources:
    0
    Resources:
    0
    No, I was wrong. SetUnitX/Y fine. SetUnitPosition broken. I order unit to move A, then B, and then C, wait 1 sec (points are far enough from each other) and call SetUnitPosition. Order list breaks immediately.
     
  6. deathismyfriend

    deathismyfriend

    Joined:
    Oct 24, 2012
    Messages:
    6,532
    Resources:
    14
    Spells:
    12
    Tutorials:
    2
    Resources:
    14
    can u plz show the trigger. also i suggest using .03 as it looks a lot better when manually moving units.
     
  7. Krogoth

    Krogoth

    Joined:
    Apr 5, 2011
    Messages:
    247
    Resources:
    0
    Resources:
    0
    Works:
    Code (vJASS):
    function Trig_gfdgfg_Actions takes nothing returns nothing
        local unit u = GetTriggerUnit()
        call PolledWait( 1.00 )
        call SetUnitX(u, 0)
        call SetUnitY(u, 0)
        set u = null
    endfunction

    //===========================================================================
    function InitTrig_gfdgfg takes nothing returns nothing
        set gg_trg_gfdgfg = CreateTrigger(  )
        call TriggerRegisterAnyUnitEventBJ( gg_trg_gfdgfg, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
        call TriggerAddAction( gg_trg_gfdgfg, function Trig_gfdgfg_Actions )
    endfunction

    Not works:
    Code (vJASS):
    function Trig_gfdgfg_Actions takes nothing returns nothing
        local unit u = GetTriggerUnit()
        call PolledWait( 1.00 )
        call SetUnitPosition(u, 0, 0)
        set u = null
    endfunction

    //===========================================================================
    function InitTrig_gfdgfg takes nothing returns nothing
        set gg_trg_gfdgfg = CreateTrigger(  )
        call TriggerRegisterAnyUnitEventBJ( gg_trg_gfdgfg, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
        call TriggerAddAction( gg_trg_gfdgfg, function Trig_gfdgfg_Actions )
    endfunction


    Added:
    I click orders much faster than 1 sec.
     
  8. Krogoth

    Krogoth

    Joined:
    Apr 5, 2011
    Messages:
    247
    Resources:
    0
    Resources:
    0
    Lol, I finally understood. It's impossible.
    How can I differentiate order and shift+order if their event is common? O_O
    What to do ...

    Added:
    Okay, I do not need this. I will make each selectable unit dummy and move it manually. It's lame but what to do.
     
  9. deathismyfriend

    deathismyfriend

    Joined:
    Oct 24, 2012
    Messages:
    6,532
    Resources:
    14
    Spells:
    12
    Tutorials:
    2
    Resources:
    14
    u can always use .03 seconds and use a timer if using jass.

    y do u even need the polled wait ? ive ur trying to stop there movement just make it instant. or use a stop unit order.
     
  10. Krogoth

    Krogoth

    Joined:
    Apr 5, 2011
    Messages:
    247
    Resources:
    0
    Resources:
    0
    Haha, u just did not get it. That 1 sec is needed to make a short order list, then I see how it breaks.

    Okay, I went another way. This is what I achieved:
    Nice image
    [​IMG]
    As you see, unit has an order list but moves from blue circle symmetrically by Y. :grin:
    So, it allows to make a lot of intermediate orders until unit gets its target point.
     

    Attached Files:

  11. deathismyfriend

    deathismyfriend

    Joined:
    Oct 24, 2012
    Messages:
    6,532
    Resources:
    14
    Spells:
    12
    Tutorials:
    2
    Resources:
    14
    plz explain better then. the way u explain it is hard to understand what u want done.
     
  12. Krogoth

    Krogoth

    Joined:
    Apr 5, 2011
    Messages:
    247
    Resources:
    0
    Resources:
    0
    I order unit to
    1. move A,
    2. kill someone
    3. move B.
    This order list consists of 3 orders.
    When unit is ordered I can add some orders between current and next until current gets done. So I have for example:
    1. move C,
    2. move D,
    3. move A,
    4. kill someone,
    5. kill someone else,
    6. move B.

    With this I can make some automatical scenarios like tactical retreat/defence while unit is ordered to get location. Or just manually choose the way how to get location.
    I believe I will get a normal library tomorrow.
     
  13. edo494

    edo494

    Joined:
    Apr 16, 2012
    Messages:
    3,855
    Resources:
    5
    Spells:
    1
    JASS:
    4
    Resources:
    5
    you will have to make your own queue of orders

    It shouldnt be that hard

    you marked this as vJass problem, so I think you know Jass:
    Just make a function with an array of strings(or integers, depending on what you use for orders). If the current order isnt stop, hold position or something like that(the unit is not doing anything), order the unit to do the first order in Que.
    Start a timer with lets say 0.5 second timeout, then check if the unit has no order, if it has, order it to do next order etc...

    You will need hashtable for this, because you need 2 dimensions([unit][orderStack])

    if you are not in total hurry, I could make something like that for you but tomorrow because Im running out of time today
     
  14. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,791
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    I think the OP was referring to order queuing. the thing that happens when you hold shift before clicking the right mousebutton.

    And no, unfortunately, there is no way to detect queued orders, so you can not interfere with them. As soon as someone makes a new order without holding shift, the old order queue is cancelled.
    Also, you can not get wether an issued order was a queued order or a normal order, as there is no event response to that, so you can not even script a manual order queuing system.

    What you can do, is coding a order queuing system that *does not* use shift key. For example, you give each unit a "record orders" ability and when you click it, all orders issued afterwards will be tracked by events (Store order string, order target, order X and order Y) until you deactivate the ability again (use immolation or defence stance ability for instant on/off switching without interrupting existing orders).
    And then while the unit is doing its stuff, you can always track all orders issued during queue execution and place them before the current order (use a linked list for better performance!).

    The "stop" order should automaticly kill the order queue.
     
  15. Krogoth

    Krogoth

    Joined:
    Apr 5, 2011
    Messages:
    247
    Resources:
    0
    Resources:
    0
    Finally!

    I made it. Its realisation is holy crap (!) but it works. You can get demo map in attachments.

    So...

    I called system SmartUnit. It creates special "smart" units that can get intermediate orders between orders you make by clicks.
    Here is the demo code:
    Code (vJASS):
    library Demo requires SmartUnit
        globals
            unit mine
        endglobals
       
        struct Demo extends array
            static method onSmartUnitIssuesOrder takes nothing returns nothing
                call Units.clearOrderList(Event.index)
                call Units.addOrder(Event.index, ORDER_MOVE, 0, 0, mine)
                call Units.executeOrder(Event.index)
            endmethod

            private static method onInit takes nothing returns nothing
                set mine = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'ngol', -600, 300, 0)
                call CreateSmartUnit(Player(0), FOOTMAN, 0, 0, 0)
            endmethod
        endstruct
    endlibrary
    What am I doing here?
    1. I create Gold Mine.
    2. I create "smart" Footman.
    3. I move to onSmartUnitIssuesOrder() which processes event when "smart" unit gets an order.
    4. I create list of intermediate orders consisting of 1 - moving to Gold Mine.
    5. I run this order list for unit.
    So, what I have from this?
    Each time Footman is ordered to move somewhere he gets Gold Mine at first, and only then walks to destination. He performs all shift-clicks this way.
    I would appreciate if you test it and comment.

    Added:
    This system has a lot of disadvantages, but for my map it's acceptable. So, maybe, for yours too.
     

    Attached Files: