- Joined
- Dec 16, 2007
- Messages
- 252
This is a spell I requested, but I'm getting error upon saving and I cannot test the spell.
I'm getting "Cannot convert codereturnboolean to boolexpr" error on this line:
I'm getting "Cannot convert codereturnboolean to boolexpr" error on this line:
JASS:
call TriggerAddCondition(t , function GoldGain__Condition)
JASS:
library GoldGain initializer Init uses TimerUtils
globals
private constant real TimeInterval = 60
private integer array GoldPerInterval
private constant integer AbID = 'A000' //Change this to rawcode of your Ability!
endglobals
struct GG
unit u
timer t
static method Loop takes nothing returns nothing
local timer t = GetExpiredTimer()
local GG g = GetTimerData(t)
if GetUnitAbilityLevel(g.u, AbID) != 0 then
call SetPlayerState(GetOwningPlayer(g.u), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(GetOwningPlayer(g.u), PLAYER_STATE_RESOURCE_GOLD) + GoldPerInterval[GetUnitAbilityLevel(g.u, AbID)])
else
call PauseTimer(g.t)
call ReleaseTimer(g.t)
call g.destroy()
endif
set t = null
endmethod
static method Start takes nothing returns nothing
local GG g = g.allocate()
set g.u = GetTriggerUnit()
set g.t = NewTimer()
call SetTimerData(g.t, g)
call TimerStart(g.t, TimeInterval, true, function GG.Loop)
endmethod
method onDestroy takes nothing returns nothing
set .u = null
set .t = null
endmethod
endstruct
private function Condition takes nothing returns boolean
return GetSpellAbilityId() == AbID
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
local player p
local integer i = 0
loop
exitwhen i == bj_MAX_PLAYER_SLOTS
set p = Player(i)
call TriggerRegisterPlayerUnitEvent(t, p, EVENT_PLAYER_HERO_SKILL, null)
set p = null
set i = i + 1
endloop
call TriggerAddCondition(t, function Condition)
call TriggerAddAction(t, function GG.Start)
set GoldPerInterval[1] = 40
set GoldPerInterval[2] = 100
set GoldPerInterval[3] = 160
set GoldPerInterval[4] = 220
set t = null
endfunction
endlibrary