• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[JASS] Combining element

Status
Not open for further replies.

ABM

ABM

Level 7
Joined
Jul 13, 2005
Messages
279
hi,
is there a way to combine in the same line
create item for unit and set charge in created item.?
or even better create unit and add item in same line + charge if possible ?
[Jass=]
call CreateUnitAtLoc( Player(PLAYER_NEUTRAL_AGGRESSIVE), 'u001', udg_Loc, bj_UNIT_FACING )
call UnitAddItemById( GetLastCreatedUnit(), 'I0AG' )
call SetItemCharges( GetLastCreatedItem(), GetRandomInt(1, 5) )
[/code]

for example:
[Jass=]
call UnitAddItemById( CreateUnitAtLoc( Player(PLAYER_NEUTRAL_AGGRESSIVE), 'u001', udg_Loc, bj_UNIT_FACING ), 'I0AG' )
[/code]
is this ok?

[Jass=]
call SetItemCharges( UnitAddItemById( CreateUnitAtLoc( Player(PLAYER_NEUTRAL_AGGRESSIVE), 'u001', udg_Loc, bj_UNIT_FACING ), 'I0AG' ), GetRandomInt(1, 5) )
[/code]
what about this?
 
the last one should work(it compiled at least)
be aware that GetLastCreatedItem and GetLastCreatedUnit will return null in your case, those are useful only when you are working with BJ versions of those function calls, you have to set variable to that, example:
JASS:
    local unit u = CreateUnit(...)
    local item i = UnitAddItemById(u, ...)
    call SetItemCharges(i, GetRandomInt(1, 5))

etc
 
hum i see...

but if i add them all together would it work even without using variable?
by replacing variable by function call, like the last one?

i will try it in a test map to see what happen

EDIT
Well it work perfectly fine... ^^
 
Status
Not open for further replies.
Back
Top