- Joined
- Feb 3, 2013
- Messages
- 277
Hi all, I've been trying to create a channeling spell that gives a hero to heal a friendly units mana/health at the expense of its mana;; i'm not sure if this is the best way to go about - but i wanted to give structs/methods a try
The main issue is that i keep getting an expected returns error on the line 'static method create .... returns data'
i have NO idea why, and it giving me bonkers
also if someone can help suggest other ways of doing this, or some tips on using structs/methods to make spells that would be great
thanks in advance
The main issue is that i keep getting an expected returns error on the line 'static method create .... returns data'
i have NO idea why, and it giving me bonkers
also if someone can help suggest other ways of doing this, or some tips on using structs/methods to make spells that would be great
thanks in advance
JASS:
scope Surge initializer init
globals
private constant hashtable HASH = InitHashtable()
endglobals
private struct data
unit c
unit t
real r
integer i
method hurt takes nothing returns nothing
set this.r = I2R(GetUnitAbilityLevel(this.c, 'A00A')) * .33 * .2 * GetHeroInt(this.c, TRUE)
if this.i < 25 then
call SetUnitState(this.c, UNIT_STATE_MANA, GetUnitState(this.c, UNIT_STATE_MANA) - r)
call SetUnitState(this.t, UNIT_STATE_MANA, GetUnitState(this.t, UNIT_STATE_MANA) + r)
call SetUnitState(this.t, UNIT_STATE_LIFE, GetUnitState(this.t, UNIT_STATE_LIFE) + r)
else
call this.destroy()
endif
set this.i = this.i + 1
endmethod
static method create takes unit C takes unit T takes returns data
local data this = data.allocate()
set this.c = C
set this.t = T
call TimerStart(CreateTimer(), 0.2, TRUE, function this.hurt)
endmethod
method destroy takes nothing returns nothing
set this.c = null
set this.t = null
call this.deallocate()
endmethod
endstruct
private function S_Add takes nothing returns nothing
local unit C = GetTriggerUnit()
local unit T = GetSpellTargetUnit()
local data d
if GetSpellAbilityId() == 'A00A' then
set C = GetTriggerUnit()
set T = GetSpellTargetUnit()
set d = data.create(C, T)
call SaveInteger(HASH, GetHandleId(C), 0, data.d)
set C = null
set T = null
endif
endfunction
private function S_Remove takes nothing returns nothing
local data d
local unit C = GetTriggerUnit()
if GetSpellAbilityId() == 'A00A' then
set data.d = LoadInteger(HASH, GetHandleId(C), 0)
call d.destroy
set C = null
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddAction(t, function S_Add)
call TriggerRegisterAnyUnitEventBJ(t2, EVENT_PLAYER_UNIT_SPELL_ENDCAST)
call TriggerAddAction(t2, function S_Remove)
endfunction
endscope