HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

How to order an unit to use an item

04-12-2007, 02:40 PM#1
Troll-Brain
I had read the ability Guide but i can't order an unit to use an item on a slot.
I try it with many items that don't need a target, like the potion of invulnerability ( 'pnvu' ).

This item is in slot 2.
So i've try this
Collapse JASS:
call IssueImmediateOrderById( udg_U, 852009 )

But nothing happens. udg_U is the good unit
And the unit never get an order (always stop)

Must i use an other fonction ? IssueImmediateOrderById is not the correct one ?
04-12-2007, 04:54 PM#2
blu_da_noob
Are you sure you know which slot is slot 2? Why not just try with the item in the top left slot and order id 852008?

(function is correct)
04-12-2007, 06:11 PM#3
Troll-Brain
That's right i completly mess this point but anyway i the id seems not the same for me

I 've tried this :

Collapse JASS:
function Test_Actions takes nothing returns nothing

local integer I=852007

loop

set I=I+1

"

    call BJDebugMsg( GetUnitName(udg_U) )
    call IssueImmediateOrderById( udg_U, 852008 )
    call TriggerSleepAction (0.5)

exitwhen I == 852013

endloop

call IssueImmediateOrderById( udg_U, I )

endfunction

//===========================================================================
function InitTrig_Test takes nothing returns nothing
    set gg_trg_Test = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_Test, Player(0), "test", true )
    call TriggerAddAction( gg_trg_Test, function Test_Actions )
endfunction

The inventory of udg_U is full with the same item type and the unit can use it '"manually"

I will try to get the id when i click on an item ...
04-12-2007, 06:22 PM#4
blu_da_noob
Quote:
Originally Posted by Troll-Brain
Collapse JASS:
function Test_Actions takes nothing returns nothing
//..blah

    call BJDebugMsg( GetUnitName(udg_U) )
    call IssueImmediateOrderById( udg_U, 852008 ) //this should have I instead of 852008
    call TriggerSleepAction (0.5)

//..blah
04-12-2007, 08:30 PM#5
Troll-Brain
My trigger wasn't correct sorry for this post, anyway cause of the loop it's better to use a timer.
@Blu_da_noob : That's right i completly mess this point but anyway the id seems to be different for me


Cuctom script :
Collapse JASS:
function CheckId takes nothing returns nothing

set udg_I=udg_I+1

    call BJDebugMsg( GetUnitName(udg_U) ) // no need, just for see if udg_U != null
    call BJDebugMsg(I2S(udg_I)) // no need too
    call BJDebugMsg(" ")
    call IssueImmediateOrderById( udg_U, udg_I )


endfunction

Trigger Init :

Trigger:
Init
Collapse Evénements
Map initialization
Conditions
Collapse Actions
Set U = Mage de sang 0000 <gen>
Set I = 852007


Trigger CheckId :

Collapse JASS:
function CheckId_Act takes nothing returns nothing

call TimerStart(udg_Timer,0.5,true,function CheckId)



endfunction

//===========================================================================
function InitTrig_CheckId takes nothing returns nothing
    set gg_trg_CheckId = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_CheckId, Player(0), "test", true )
    call TriggerAddAction( gg_trg_CheckId, function CheckId_Act )
endfunction

Trigger Stop :

Trigger:
Stop
Collapse Evénements
Unité - A unit Use an item
Conditions
Collapse Actions
Custom script: call DestroyTrigger(gg_trg_CheckId)
Partie - Display to (All players) the text: (a valid ID for use an item slot = + (String(I)))

Udg_U dont use any item ...
I will try to get the id of the order when i use an item in a slot ...

The only way i see, it's to make a loop and when it will display me : a valid ID for use an item slot =, i will get the right id.

But the question is :
Can you give me values ?.
Beetween X and Y. (orderId)
Cause i dont want to wait some hours xD
04-13-2007, 04:17 PM#6
Troll-Brain
Omg i didn't see there is a function in gui and in jass of course ..
Collapse JASS:
UnitItemInSlot

But i want to know if i can use the idOrder or not so I launch the test map in local area network and wait the defeat (instead of text message) . I increment udg_I by 6 cause these competences must follow themself