Beetlebomb
New Member
- Reaction score
- 43
Hey guys,
I've created a simple mana burn spell that could use some help in optimizing. My problem is that I need to use the TriggerSleepAction so that I dont cause a leak. I also need to remove that pesky Lightning effect, or else it'll be there forever. It there a nice way for me to clean the following JASS spell up? All tips will be greatly appreciated ^^,
Now remember, go easy on me-- I'm new!(ie: "ZOMG WTF, U B DOINGZ IT ALL WRONG")
Thx ^^
I've created a simple mana burn spell that could use some help in optimizing. My problem is that I need to use the TriggerSleepAction so that I dont cause a leak. I also need to remove that pesky Lightning effect, or else it'll be there forever. It there a nice way for me to clean the following JASS spell up? All tips will be greatly appreciated ^^,
Now remember, go easy on me-- I'm new!(ie: "ZOMG WTF, U B DOINGZ IT ALL WRONG")
JASS:
scope ManaBurn initializer Unstable
private function CorrectSpell takes nothing returns boolean
return GetSpellAbilityId() == 039;A001039;
endfunction
private function BurnIt takes nothing returns nothing
local lightning light
local texttag tag = CreateTextTag()
local unit caster = GetTriggerUnit()
local location casterloc = GetUnitLoc(caster)
local integer level = GetUnitAbilityLevel(caster, 039;A001039;)
local integer rannum
local unit tar = GetSpellTargetUnit()
local location tarloc = GetUnitLoc(GetSpellTargetUnit())
set rannum = GetRandomInt(level*15+25,level*15+100)
set light = AddLightningLoc("AFOD", casterloc, tarloc)
call SetUnitState(tar, UNIT_STATE_MANA, GetUnitState(tar, UNIT_STATE_MANA) - rannum)
set tag = CreateTextTagLocBJ("-"+I2S(rannum), tarloc, 0, 10, 0, 0, 100, 0)
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Demon\\DemonBoltImpact\\DemonBoltImpact.mdl", GetUnitX(tar), GetUnitY(tar)))
call SetTextTagVelocityBJ(tag, 64, 90)
call SetTextTagFadepoint(tag, 2.00 )
call SetTextTagPermanent(tag, false)
call TriggerSleepAction(0.25)
call DestroyLightning(light)
call TriggerSleepAction(1.75)
call DestroyTextTag(tag)
call RemoveLocation(casterloc)
call RemoveLocation(tarloc)
endfunction
private function Unstable takes nothing returns nothing
local trigger t = CreateTrigger()
local integer index = 0
loop
exitwhen index == bj_MAX_PLAYER_SLOTS
call TriggerRegisterPlayerUnitEvent(t, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set index = index+1
endloop
call TriggerAddCondition(t, Condition(function CorrectSpell))
call TriggerAddAction(t, function BurnIt)
endfunction
endscope
Thx ^^