- Joined
- Apr 23, 2011
- Messages
- 460
Hey, this spell appears to work fine, doesn't seem to leak, and has no overall noticeable problems. But are there any underlying coding errors that I should look for?
JASS:
library EnergyPass initializer init uses RegisterPlayerUnitEvent
globals
private constant string EYECANDY = ""
private constant real TRANS = .2
private constant integer SPELL_ID = 'EngP'
private constant string ERROR = "|cffffcc00Your target is at max mana.|r"
endglobals
scope EnergyPass
private function spell takes nothing returns nothing
local unit caster = GetSpellAbilityUnit()
local unit target = GetSpellTargetUnit()
local real casterMana = GetUnitState(caster, UNIT_STATE_MANA)
local real targetMana = GetUnitState(target, UNIT_STATE_MANA)
local real manaTransfer = (casterMana * TRANS)
call DestroyEffect(AddSpecialEffectTarget(EYECANDY, target, "origin"))
call DestroyEffect(AddSpecialEffectTarget(EYECANDY, caster, "origin"))
if targetMana != GetUnitState(target, UNIT_STATE_MAX_MANA) then
call SetUnitState(caster, UNIT_STATE_MANA, casterMana - manaTransfer)
call SetUnitState(target, UNIT_STATE_MANA, GetUnitState(target, UNIT_STATE_MANA) + manaTransfer)
else
call DisplayTimedTextToPlayer(GetOwningPlayer(caster), 0, 0, 8.5, ERROR)
endif
set caster = null
set target = null
endfunction
function cast takes nothing returns nothing
if GetSpellAbilityId() == SPELL_ID and IsUnitAlly(GetSpellAbilityUnit(), GetOwningPlayer(GetSpellTargetUnit())) then
call spell()
endif
endfunction
endscope
private function init takes nothing returns nothing
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_SPELL_CAST, function cast)
endfunction
endlibrary
Last edited: