HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Detecting Cancel Orders

09-08-2009, 08:02 AM#1
Spellbound
How do you catch a 'cancel' type order? The order string 851976 doesn't work anymore. Is there any way to detect this particular order?
09-08-2009, 08:51 AM#2
Anachron
Checked if this works?

Collapse JASS:
if GetIssuedOrderId() == 0 or OrderId2String(GetIssuedOrderId()) = "stop"
09-08-2009, 10:02 AM#3
Spellbound
if GetIssuedOrderId() == 0 <-- doesn't work
OrderId2String(GetIssuedOrderId()) = "stop" <-- makes the editor crash, lol

Also, I'm not very skilled with JASS, so I might be doing it wrong, but I replaced the above code in the condition, which is:

Collapse JASS:
if ( not ( GetIssuedOrderIdBJ() == String2OrderIdBJ("851976") ) ) then
09-08-2009, 10:07 AM#4
Anachron
But the 851976 is an integer ID, why converting it again to an order?
Collapse JASS:
OrderId2String(GetIssuedOrderId()) = "stop"  // makes the editor crash, lol
Because I forgot one "=".

So its
Collapse JASS:
OrderId2String(GetIssuedOrderId()) == "stop" 
09-08-2009, 10:16 AM#5
Spellbound
Okay, it's still crashing, so I guess I'm doing it wrong.

Also
"But the 851976 is an integer ID, why converting it again to an order?"

I don't really know what that means... I just converted the GUI trigger to custom text and replaced it. I'll paste the whole trigger in custom text:

Collapse JASS:
function Trig_Out_of_Build_Mode_Copy_Func002C takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetTriggerUnit()) == 'u00A' ) ) then
        return false
    endif
    if ( not ( GetIssuedOrderIdBJ() == String2OrderIdBJ("851976") ) ) then
        return false
    endif
    return true
endfunction

function Trig_Out_of_Build_Mode_Copy_Conditions takes nothing returns boolean
    if ( not Trig_Out_of_Build_Mode_Copy_Func002C() ) then
        return false
    endif
    return true
endfunction

function Trig_Out_of_Build_Mode_Copy_Func003001003001 takes nothing returns boolean
    return ( IsUnitAlly(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == true )
endfunction

function Trig_Out_of_Build_Mode_Copy_Func003001003002001 takes nothing returns boolean
    return ( GetUnitTypeId(GetFilterUnit()) == 'u000' )
endfunction

function Trig_Out_of_Build_Mode_Copy_Func003001003002002001 takes nothing returns boolean
    return ( GetUnitTypeId(GetFilterUnit()) == 'u008' )
endfunction

function Trig_Out_of_Build_Mode_Copy_Func003001003002002002 takes nothing returns boolean
    return ( GetUnitTypeId(GetFilterUnit()) == 'u007' )
endfunction

function Trig_Out_of_Build_Mode_Copy_Func003001003002002 takes nothing returns boolean
    return GetBooleanAnd( Trig_Out_of_Build_Mode_Copy_Func003001003002002001(), Trig_Out_of_Build_Mode_Copy_Func003001003002002002() )
endfunction

function Trig_Out_of_Build_Mode_Copy_Func003001003002 takes nothing returns boolean
    return GetBooleanAnd( Trig_Out_of_Build_Mode_Copy_Func003001003002001(), Trig_Out_of_Build_Mode_Copy_Func003001003002002() )
endfunction

function Trig_Out_of_Build_Mode_Copy_Func003001003 takes nothing returns boolean
    return GetBooleanAnd( Trig_Out_of_Build_Mode_Copy_Func003001003001(), Trig_Out_of_Build_Mode_Copy_Func003001003002() )
endfunction

function Trig_Out_of_Build_Mode_Copy_Func003A takes nothing returns nothing
    call SelectUnitForPlayerSingle( GetEnumUnit(), GetOwningPlayer(GetTriggerUnit()) )
endfunction

function Trig_Out_of_Build_Mode_Copy_Actions takes nothing returns nothing
    call ForGroupBJ( GetUnitsInRangeOfLocMatching(100.00, GetUnitLoc(GetTriggerUnit()), Condition(function Trig_Out_of_Build_Mode_Copy_Func003001003)), function Trig_Out_of_Build_Mode_Copy_Func003A )
endfunction

//===========================================================================
function InitTrig_Out_of_Build_Mode_Copy takes nothing returns nothing
    set gg_trg_Out_of_Build_Mode_Copy = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Out_of_Build_Mode_Copy, EVENT_PLAYER_UNIT_ISSUED_ORDER )
    call TriggerAddCondition( gg_trg_Out_of_Build_Mode_Copy, Condition( function Trig_Out_of_Build_Mode_Copy_Conditions ) )
    call TriggerAddAction( gg_trg_Out_of_Build_Mode_Copy, function Trig_Out_of_Build_Mode_Copy_Actions )
endfunction
09-08-2009, 12:04 PM#6
Opossum
Quote:
Originally Posted by Spellbound
if GetIssuedOrderId() == 0 <-- doesn't work
OrderId2String(GetIssuedOrderId()) = "stop" <-- makes the editor crash, lol

Also, I'm not very skilled with JASS, so I might be doing it wrong, but I replaced the above code in the condition, which is:

Collapse JASS:
if ( not ( GetIssuedOrderIdBJ() == String2OrderIdBJ("851976") ) ) then
The "" indicate that what you put for the order is a string, not the actual integer. This is what it should be:
Collapse JASS:
if GetIssuedOrderId() != 851976 then
09-08-2009, 01:05 PM#7
Spellbound
Nope, still nothing happens when I click on cancel to exit the summon building menu.
09-08-2009, 01:50 PM#8
Anachron
Display the current order of a unit everytime it does any action and check the ID while doing cancel.
09-08-2009, 02:33 PM#9
Spellbound
Wow, that's clever. Never would have thought of that.

EDIT: it doesn't seem to have an ID. I got the display of the order from pretty much everything, from right-clicks to 'necropolis' when an acolyte was ordered to build a necropolis (and even (null) for ordering a research to start and wateelemental for summoning a water elemental). Alas, it didn't detect the 'cancel' order.
09-08-2009, 02:38 PM#10
Anachron
Have you used the Event A unit gets an order or have you checked periodicly units current order?
09-08-2009, 02:58 PM#11
Spellbound
I did:

Trigger:
Events
Unit - A unit is issued an order targeting a point
Unit - A unit is issued an order targeting an object
Unit - A unit is issued an order with no target
Conditions
Actions
Game - Display to (All Players) for 10.00 seconds the text: (String((Current Order of (Triggering Unit)))
09-08-2009, 03:22 PM#12
Fledermaus
try this:
Trigger:
Custom script: call BJDebugMsg("OrderId is: "+I2S(GetIssuedOrderId()))

EDIT: I just tested and apparently there is no order issued when canceling the build menu, or the hero skill menu. Although when canceling a building/unit, 851976 is given.
09-08-2009, 04:07 PM#13
Spellbound
Quote:
Originally Posted by Fledermaus
try this:
Trigger:
Custom script: call BJDebugMsg("OrderId is: "+I2S(GetIssuedOrderId()))

EDIT: I just tested and apparently there is no order issued when canceling the build menu, or the hero skill menu. Although when canceling a building/unit, 851976 is given.
Hmm, that's troublesome. I would have used Spellbook to circumvent this problem, but the build structure ability (based off Build Tiny Farm) only builds one type of structure despite having different versions. So right now, I have a skill which selects a dummy builder which in turn builds stuff. Problem is, when you exit build menu, its the dummy builder that's selected and not the building that supposedly is building stuff. Another way to circumvent this would be if anyone knows how to give a structure the ability to build stuff without having to turn it into a non-building unit.
09-09-2009, 01:57 PM#14
Anachron
After some checking of ORDERS, I found this one as
the stop order ID:
851972

in a few lists.

Maybe check for that one too.

Edit:
Oh,
the cancel order ID is:
851976

Try these aswell:
851991
851987
851973
851975
852019
09-09-2009, 03:15 PM#15
Spellbound
Dusnt wurk :(