- Joined
- Apr 5, 2011
- Messages
- 245
While other resources "under work" I am here again =]
This is extremely simple code that is designed to work with custom buffs
Interface does not use unit argument, but its direct index (to prevent GetUnitUserData() spamming)
There are unit single operation and unit multiple operations interfaces. Last one is recommended if you work with same unit few times.
Example:
Buff field should be inited before gets used
This is extremely simple code that is designed to work with custom buffs
Interface does not use unit argument, but its direct index (to prevent GetUnitUserData() spamming)
There are unit single operation and unit multiple operations interfaces. Last one is recommended if you work with same unit few times.
Example:
Unit single operation:
call Buff.add(GetUnitUserData(u), BUFF_ASTONISHED)
Unit multiple operations:
call Buffy.setup(GetUnitUserData(u))
call Buffy.add(BUFF_HAS_LEG)
call Buffy.add(BUFF_HAS_HAND)
call Buffy.add(BUFF_HAS_HEAD)
call Buffy.add(BUFF_FIGHT_VAMPIRE)
Buff field should be inited before gets used
JASS:
//-=-=-=-=-=-=-=-=-=-=-=-=-=-
//-=-=-=-] BuffField [-=-=-=-
//-=-=-=-=- v0.900 =-=-=-=-=-
library BuffField
globals
private integer N
private boolean array B
endglobals
function InitBuffField takes integer n returns nothing
set N = n
endfunction
//Unit single operation interface
struct Buff extends array
static method has takes integer ui, integer buffcode returns boolean
return B[ui * N + buffcode]
endmethod
static method add takes integer ui, integer buffcode returns nothing
set B[ui * N + buffcode] = true
endmethod
static method remove takes integer ui, integer buffcode returns nothing
set B[ui * N + buffcode] = false
endmethod
endstruct
//Unit multiple operations interface
struct Buffy extends array
private static integer i
static method setup takes integer ui returns nothing
set i = ui * N
endmethod
static method has takes integer buffcode returns boolean
return B[i + buffcode]
endmethod
static method add takes integer buffcode returns nothing
set B[i + buffcode] = true
endmethod
static method remove takes integer buffcode returns nothing
set B[i + buffcode] = false
endmethod
endstruct
endlibrary
Last edited: