- Joined
- Nov 30, 2007
- Messages
- 1,202
it lacks proper de-allocation and deindexing...
To be more specific, I'm not sure how to flush that saved integer on deindex or get the thing to work properly.
I'm trying to make a system that if you select a object a menu appears and the options are depending on the SpellIndex here.
A example of the usage would be that if you click on a rune above a door. You get the Option to Open it. When you Open it, that spell is deindexed and Close Door Spell is added to the spellindex so that next time Open Door option appears instead.
JASS:
struct SpellIndex
integer array spell[15]
integer index = 0
static integer n = 0
static method giveSpellsToUnit takes unit u returns nothing
local thistype this = LoadInteger(hash, GetHandleId(u), 0)
local integer i = 0
call BJDebugMsg("ehh")
loop
exitwhen i == this.index
call BJDebugMsg("HELLO!")
call UnitAddAbility(u, this.spell[i])
set i = i + 1
endloop
endmethod
method add takes integer spell returns nothing
call SaveInteger(hash, this, spell, .index)
set .spell[.index] = spell
set .index = .index + 1
endmethod
method remove takes integer spell returns nothing
local integer i = LoadInteger(hash, this, spell)
set .index = .index -1
set .spell[i] = .spell[.index]
endmethod
static method create takes unit u returns SpellIndex
local thistype this = .allocate()
call SaveInteger(hash, GetHandleId(u), 0, this)
set SpellIndex.n = SpellIndex.n + 1
return this
endmethod
endstruct
To be more specific, I'm not sure how to flush that saved integer on deindex or get the thing to work properly.
I'm trying to make a system that if you select a object a menu appears and the options are depending on the SpellIndex here.
A example of the usage would be that if you click on a rune above a door. You get the Option to Open it. When you Open it, that spell is deindexed and Close Door Spell is added to the spellindex so that next time Open Door option appears instead.
Last edited by a moderator: