Nestharus
o-o
- Reaction score
- 84
JASS:
library SaveUnitLife /*
*************************************************************************************
*
* Saves unit's life
*
*************************************************************************************
*
* */uses/*
*
* */ NumberStack /* hiveworkshop.com/forums/1993458-post521.html
* */ UnitStatePercent /* hiveworkshop.com/forums/jass-functions-413/snippet-unit-state-percent-189943/
* */ optional Buffer /* hiveworkshop.com/forums/2002936-post568.html
*
************************************************************************************
*
* function SaveUnitLife takes NumberStack stack, unit whichUnit returns nothing
*
* -> No Buffer <-
*
* function LoadUnitLife takes NumberStack stack, unit whichUnit returns nothing
*
* -> Buffer <-
*
* function LoadUnitLifeToBuffer takes NumberStack stack returns nothing
* function LoadUnitLifeFromBuffer takes unit whichUnit returns nothing
*
************************************************************************************/
function SaveUnitLife takes NumberStack stack, unit whichUnit returns nothing
call stack.push(GetPercentUnitLife(whichUnit),100)
endfunction
static if LIBRARY_Buffer then
function LoadUnitLifeToBuffer takes NumberStack stack returns nothing
call Buffer.write(stack.pop(100))
endfunction
function LoadUnitLifeFromBuffer takes unit whichUnit returns nothing
call SetPercentUnitLife(whichUnit,Buffer.read())
endfunction
else
function LoadUnitLife takes NumberStack stack, unit whichUnit returns nothing
call SetPercentUnitLife(whichUnit,stack.pop(100))
endfunction
endif
endlibrary
JASS:
library SaveUnitMana /*
*************************************************************************************
*
* Saves unit's mana if unit max mana isn't 0
*
*************************************************************************************
*
* */uses/*
*
* */ NumberStack /* hiveworkshop.com/forums/1993458-post521.html
* */ UnitStatePercent /* hiveworkshop.com/forums/jass-functions-413/snippet-unit-state-percent-189943/
* */ optional Buffer /* hiveworkshop.com/forums/2002936-post568.html
*
************************************************************************************
*
* function SaveUnitMana takes NumberStack stack, unit whichUnit returns nothing
*
* -> No Buffer <-
*
* function LoadUnitMana takes NumberStack stack, unit whichUnit returns nothing
*
* -> Buffer <-
*
* function LoadUnitManaToBuffer takes NumberStack stack, unit whichUnit returns nothing
* function LoadUnitManaFromBuffer takes unit whichUnit returns nothing
*
************************************************************************************/
function SaveUnitMana takes NumberStack stack, unit whichUnit returns nothing
if (0<GetUnitState(whichUnit,UNIT_STATE_MAX_MANA)) then
call stack.push(GetPercentUnitMana(whichUnit),100)
endif
endfunction
static if LIBRARY_Buffer then
function LoadUnitManaToBuffer takes NumberStack stack, unit whichUnit returns nothing
if (0<GetUnitState(whichUnit,UNIT_STATE_MAX_MANA)) then
call Buffer.write(stack.pop(100))
endif
endfunction
function LoadUnitManaFromBuffer takes unit whichUnit returns nothing
if (0<GetUnitState(whichUnit,UNIT_STATE_MAX_MANA)) then
call SetPercentUnitMana(whichUnit,Buffer.read())
endif
endfunction
else
function LoadUnitMana takes NumberStack stack, unit whichUnit returns nothing
if (0<GetUnitState(whichUnit,UNIT_STATE_MAX_MANA)) then
call SetPercentUnitMana(whichUnit,stack.pop(100))
endif
endfunction
endif
endlibrary