- Joined
- Sep 9, 2009
- Messages
- 658
I'm trying to do a spell where the Hero gets 400% animation speed and attacks a target 50 times. The 10th strike will deal damage. I want him to attack with .1 intervals so a periodic trigger is needed, right? Anyway, I can do this in GUI but I decided to go with JASS just for a change of pace. I just want someone to tell me the things I'm doing wrong with this spell.
Oh, and I need to use == when I'm using conditions right?
JASS:
function Aurora_Periodic takes nothing returns nothing
local unit u = GetTriggerUnit()//I have to declare them again right?
//Even though I already declared them in the bottom function?
//And since this is a periodic trigger, I'm declaring them more than once right?
//Is that a problem?
//And is there really no way for me to refer to the locals I've declared in Trig_Aurora_Strike_Actions?
local unit u1 = GetSpellTargetUnit()
local integer i = 0 //I have a feeling there's something wrong with this part.
set i = i + 1//Am I doing this right?
call SetUnitTimeScale(u,4)
call SetUnitAnimation(u,"attack")
call DestroyEffect(AddSpecialEffectTarget("IceNova.mdx",u1,"origin"))
if i == 5 then
call SetUnitTimeScale(u,1)
call UnitDamageTarget(u,u1,1000,false,false,ATTACK_TYPE_HERO,DAMAGE_TYPE_ENHANCED,WEAPON_TYPE_WHOKNOWS)
call DestroyEffect(AddSpecialEffectTarget("IceNova.mdx",u1,"origin"))
call PauseUnit(u,false)
call PauseUnit(u1,true)
set i = 0
endif
//Biggest question I have is how do I tell the trigger to stop?
//And how do I destroy the timer if I declared its local in another function?
set u = null
set u1 = null
endfunction
function Trig_Aurora_Strike_Actions takes nothing returns nothing
local timer t = CreateTimer()
local unit u = GetTriggerUnit()
local unit u1 = GetSpellTargetUnit()
call PauseUnit(u,true)
call PauseUnit(u1,true)
call SetUnitPosition(u,GetUnitX(u1)-75,GetUnitY(u1)-75)
call TimerStart(t,.20,true,function Aurora_Periodic)
set t = null
set u = null
set u1 = null
endfunction
function Trig_Aurora_Strike_Conditions takes nothing returns boolean
if GetSpellAbilityId() == 'A000' then
call Trig_Aurora_Strike_Actions()
endif
return false
endfunction
//===========================================================================
function InitTrig_Aurora_Strike takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( t, Condition( function Trig_Aurora_Strike_Conditions ) )
set t = null
endfunction
Oh, and I need to use == when I'm using conditions right?