HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

SetUnitState vs SetWidgetLife

12-15-2007, 03:07 PM#1
zen87
Hmm not sure that this question had been asked before, well...
Collapse JASS:
//A
function AddLifeA takes unit u, real ammount returns nothing
    call SetUnitState(u,UNIT_STATE_LIFE,GetUnitState(u,UNIT_STATE_LIFE)+ammount)
endfunction

//B
function AddLifeB takes unit u, real ammount returns nothing
    call SetWidgetLife(u,GetWidgetLife(u)+ammount)
endfunction

which is faster? if B, will there be any side effect on using the widget function like these?
12-15-2007, 03:24 PM#2
darkwulfv
Widget is faster, but SetUnitState can be used for things like mana.

So if it's life you want, then use Get/SetWidgetLife. It can also be used for doodads and destructable if I'm not mistaken, whereas SetUnitState cannot.
12-15-2007, 03:41 PM#3
Toadcop
B) idk

destructs,items,units.

unit extends widget.
so for example
class widget{
...
double hp; // health
...
}

class unit:widget
{
...
// unit only params
...
}
but well PipeDream is expert in such things ^^
12-15-2007, 03:41 PM#4
cohadar
There will be no side-effects SetWidgetLife is 100% safe.
12-15-2007, 05:31 PM#5
zen87
i see i see, thanks guys :) +rep +rep~