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

[vJASS] Moving through points

Status
Not open for further replies.
Level 7
Joined
Apr 5, 2011
Messages
245
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.
 
Level 7
Joined
Apr 5, 2011
Messages
245
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:
Level 7
Joined
Apr 5, 2011
Messages
245
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.
 
Level 7
Joined
Apr 5, 2011
Messages
245
Works:
JASS:
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:
JASS:
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.
 
Level 7
Joined
Apr 5, 2011
Messages
245
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.
 
Level 7
Joined
Apr 5, 2011
Messages
245
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:
attachment.php
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.
 

Attachments

  • WC3ScrnShot_050513_213450_02.jpg
    WC3ScrnShot_050513_213450_02.jpg
    143.3 KB · Views: 201
Level 7
Joined
Apr 5, 2011
Messages
245
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.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
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
 
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
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.
 
Level 7
Joined
Apr 5, 2011
Messages
245
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:
JASS:
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.
 

Attachments

  • SmartUnit.w3x
    81 KB · Views: 64
Status
Not open for further replies.
Top