Dirac
22710180
- Reaction score
- 147
JASS:
library HeroRealAttribute /* v1.00
*/uses/* one of the following
*/ optional AIDS /* thehelper.net/forums/showthread.php/130752-Advanced-Indexing-Data-Storage
*/ optional UnitIndexer /* hiveworkshop.com/forums/jass-functions-413/system-unit-indexer-172090/
An useful tool to accurately add stats to your hero
*****************************************************************************
API:
struct HeroReal
* Stores the hero's attributes as reals instead of integers.
--->
real Agi
real Str
real Int
static method operator [] takes unit whichUnit returns thistype
* HeroReal[unit].Stat=X
****************************************************************************/
struct HeroReal extends array
//! textmacro HERO_REAL_SETUP takes NAME
private real S_$NAME$
method operator $NAME$= takes real howMuch returns nothing
set this.S_$NAME$=howMuch-R2I(howMuch)
static if LIBRARY_UnitIndexer then
call SetHero$NAME$(GetUnitById(this),R2I(howMuch),true)
else
call SetHero$NAME$(GetIndexUnit(this),R2I(howMuch),true)
endif
endmethod
method operator $NAME$ takes nothing returns real
static if LIBRARY_UnitIndexer then
return this.S_$NAME$+GetHero$NAME$(GetUnitById(this),false)
else
return this.S_$NAME$+GetHero$NAME$(GetIndexUnit(this),false)
endif
endmethod
//! endtextmacro
//! runtextmacro HERO_REAL_SETUP("Str")
//! runtextmacro HERO_REAL_SETUP("Agi")
//! runtextmacro HERO_REAL_SETUP("Int")
static method operator [] takes unit whichUnit returns thistype
return GetUnitUserData(whichUnit)
endmethod
endstruct
endlibrary