- Joined
- Apr 23, 2011
- Messages
- 460
Hello everyone! I'm back from my short lived vacation to Michigan and on the way up and there I was working on a spell for a hero in my map and I'm not a spell creator so I would like some constructive feedback (what the hell is wrong with this) and suggestions for future spell creation (what did I do wrong, how can I fix it, whats the bottom line for practicing spell creation). All comments are welcome (no martians though...) so please feel free to critique what you wish. Please note that it's probably terrible, sorry.
Edit: Before anyone says anything, I'm aware that the effect is "". This is on purpose.
JASS:
library ArcDrain initializer init
globals
private real array duration
private real array drain
private unit caster
private unit target
private constant string effectString = ""
private constant integer SPELL = 'Arcd'
private constant integer BUFF = 'Arcs'
endglobals
scope BuffTick
private function FilterUnits takes nothing returns boolean
return (GetUnitAbilityLevel(GetFilterUnit(), BUFF) > 0)
endfunction
private function BuffTick takes nothing returns nothing
local group g = CreateGroup()
local unit u
local integer i
call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, Filter(function FilterUnits))
loop
set u = FirstOfGroup(g)
exitwhen u == null
set i = GetUnitTypeId(u)
call GroupRemoveUnit(g, u)
call SetUnitState(u, UNIT_STATE_MANA, (GetUnitState(u, UNIT_STATE_MANA) - drain[i]))
set duration[i] = duration[i] - 1
if duration[i] == 0 then
call UnitRemoveAbility(u, BUFF)
endif
set u = null
endloop
call DestroyGroup(g)
set g = null
endfunction
function Ticker takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEvent(t, 1., true)
call TriggerAddAction(t, function BuffTick)
set t = null
endfunction
endscope
private struct spell extends array
private static method buffApply takes nothing returns nothing
local unit dummy = CreateUnit(Player(12), 'dumy', GetUnitX(target), GetUnitY(target), 270.)
call UnitAddAbility(dummy, BUFF)
call IssueTargetOrder(dummy, "frostnova", target)
call RemoveUnit(dummy)
set dummy = null
endmethod
static method allocate takes nothing returns nothing
local integer sLevel
set caster = GetSpellAbilityUnit()
set sLevel = GetUnitAbilityLevel(caster, SPELL)
set target = GetSpellTargetUnit()
set drain[GetUnitTypeId(target)] = ((sLevel * 2) + 5)
set duration[GetUnitTypeId(target)] = ((sLevel * 2) + 5)
call .buffApply()
endmethod
endstruct
globals
spell array Cast
endglobals
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
call Ticker()
loop
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set i = i + 1
exitwhen i > 11
endloop
call TriggerAddAction(t, function spell.allocate)
set t = null
endfunction
endlibrary
Edit: Before anyone says anything, I'm aware that the effect is "". This is on purpose.
Last edited: