Hello, haven't touched the editor in a while so I'm a little dusty. I've never had to create a MUI spell before because I usually just use local variables, so it's something out of my knowledge. Just asking for a hand to get started.
I have this custom triggered Death Coil, (so that it can heal non-Undead units)
Basically the animation is substituted with a unit that deals the damage when this unit touches the target. Problem is when it's cast a 2nd time, the existing unit is replaced with the new unit.
Is hash table the way to go? What's indexing?
Link to good tutorial?
Trigger to initiate the cast
Trigger to move the Death Coil animation towards target
Trigger to apply the damage
Trigger in the case the target dies or else, it will remove the death coil animation
I have this custom triggered Death Coil, (so that it can heal non-Undead units)
Basically the animation is substituted with a unit that deals the damage when this unit touches the target. Problem is when it's cast a 2nd time, the existing unit is replaced with the new unit.
Is hash table the way to go? What's indexing?
Link to good tutorial?
Trigger to initiate the cast
JASS:
function Trig_Death_Coil_Conditions takes nothing returns boolean
return GetSpellAbilityId()=='DanW' or GetSpellAbilityId()=='DanE' or GetSpellAbilityId()=='DanR'
endfunction
function Trig_Death_Coil_Precast_Actions takes nothing returns nothing
set udg_unit_deathcoil[0]=GetTriggerUnit()
set udg_unit_deathcoil[1]=GetSpellTargetUnit()
if IsUnitAlly(udg_unit_deathcoil[1],GetOwningPlayer(udg_unit_deathcoil[0]))==false then
if IsUnitType(udg_unit_deathcoil[1],UNIT_TYPE_MAGIC_IMMUNE)==true then
call IssueImmediateOrder(udg_unit_deathcoil[0],"stop")
endif
endif
endfunction
function Trig_Death_Coil_Actions takes nothing returns nothing
set udg_unit_deathcoil[2]=CreateUnit(GetOwningPlayer(udg_unit_deathcoil[0]),'e006',GetUnitX(udg_unit_deathcoil[0]),GetUnitY(udg_unit_deathcoil[0]),GetUnitFacing(udg_unit_deathcoil[0]))
set udg_integer_deathcoil=GetUnitAbilityLevel(udg_unit_deathcoil[0],GetSpellAbilityId())
call UnitApplyTimedLife(udg_unit_deathcoil[2],'BTLF',3.00)
call AttachSoundToUnit(gg_snd_DeathCoilMissileLaunch1,udg_unit_deathcoil[0])
call SetSoundVolume(gg_snd_DeathCoilMissileLaunch1,127)
call StartSound(gg_snd_DeathCoilMissileLaunch1)
// call KillSoundWhenDone(gg_snd_DeathCoilMissileLaunch1)
call TriggerRegisterUnitInRange(gg_trg_Death_Coil_Hit,udg_unit_deathcoil[2],50.00,null)
call EnableTrigger(gg_trg_Death_Coil_Timer)
call EnableTrigger(gg_trg_Death_Coil_Hit)
call EnableTrigger(gg_trg_Death_Coil_Target_Dies)
endfunction
//===========================================================================
function InitTrig_Death_Coil takes nothing returns nothing
local trigger t=CreateTrigger()
local integer i=0
set gg_trg_Death_Coil=CreateTrigger()
loop
exitwhen i==bj_MAX_PLAYER_SLOTS
call TriggerRegisterPlayerUnitEvent(gg_trg_Death_Coil,Player(i),EVENT_PLAYER_UNIT_SPELL_CAST,null)
call TriggerRegisterPlayerUnitEvent(t,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
set i=i+1
endloop
call TriggerAddCondition(gg_trg_Death_Coil,Condition(function Trig_Death_Coil_Conditions))
call TriggerAddAction(gg_trg_Death_Coil,function Trig_Death_Coil_Precast_Actions)
call TriggerAddCondition(t,Condition(function Trig_Death_Coil_Conditions))
call TriggerAddAction(t,function Trig_Death_Coil_Actions)
set t=null
endfunction
Trigger to move the Death Coil animation towards target
JASS:
function Trig_Death_Coil_Timer_Actions takes nothing returns nothing
local real xx=GetUnitX(udg_unit_deathcoil[2])
local real yy=GetUnitY(udg_unit_deathcoil[2])
local real X=xx+10.00*Cos(bj_RADTODEG*Atan2(GetUnitY(udg_unit_deathcoil[1])-yy,GetUnitX(udg_unit_deathcoil[1])-xx)*bj_DEGTORAD)
local real Y=yy+10.00*Sin(bj_RADTODEG*Atan2(GetUnitY(udg_unit_deathcoil[1])-yy,GetUnitX(udg_unit_deathcoil[1])-xx)*bj_DEGTORAD)
if GetUnitAbilityLevel(udg_unit_deathcoil[1],'Bcyc') > 0 then
call TriggerExecute(gg_trg_Death_Coil_Target_Dies)
else
call SetUnitPosition(udg_unit_deathcoil[2],X,Y)
endif
endfunction
//===========================================================================
function InitTrig_Death_Coil_Timer takes nothing returns nothing
set gg_trg_Death_Coil_Timer=CreateTrigger()
call DisableTrigger(gg_trg_Death_Coil_Timer)
call TriggerRegisterTimerEvent(gg_trg_Death_Coil_Timer,0.01,true)
call TriggerAddAction(gg_trg_Death_Coil_Timer,function Trig_Death_Coil_Timer_Actions)
endfunction
Trigger to apply the damage
JASS:
function Trig_Death_Coil_Hit_Conditions takes nothing returns boolean
return GetTriggerUnit()==udg_unit_deathcoil[1]
endfunction
function Trig_Death_Coil_Hit_Actions takes nothing returns nothing
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl",udg_unit_deathcoil[1],"origin"))
if IsUnitAlly(udg_unit_deathcoil[1],GetOwningPlayer(udg_unit_deathcoil[0]))==true then
call SetUnitState(udg_unit_deathcoil[1],UNIT_STATE_LIFE,GetUnitStateSwap(UNIT_STATE_LIFE,udg_unit_deathcoil[1])+(I2R(udg_integer_deathcoil)*200.00))
else
if IsUnitType(udg_unit_deathcoil[1],UNIT_TYPE_MAGIC_IMMUNE)==false then
call UnitDamageTarget(udg_unit_deathcoil[0],udg_unit_deathcoil[1],I2R(udg_integer_deathcoil)*100.00,true,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_UNIVERSAL,null)
endif
endif
call RemoveUnit(udg_unit_deathcoil[2])
set udg_unit_deathcoil[1]=null
call DisableTrigger(gg_trg_Death_Coil_Timer)
call DisableTrigger(gg_trg_Death_Coil_Target_Dies)
call DisableTrigger(GetTriggeringTrigger())
endfunction
//===========================================================================
function InitTrig_Death_Coil_Hit takes nothing returns nothing
set gg_trg_Death_Coil_Hit=CreateTrigger()
call DisableTrigger(gg_trg_Death_Coil_Hit)
call TriggerAddCondition(gg_trg_Death_Coil_Hit,Condition(function Trig_Death_Coil_Hit_Conditions))
call TriggerAddAction(gg_trg_Death_Coil_Hit,function Trig_Death_Coil_Hit_Actions)
endfunction
Trigger in the case the target dies or else, it will remove the death coil animation
JASS:
function Trig_Death_Coil_Target_Dies_Conditions takes nothing returns boolean
return GetTriggerUnit()==udg_unit_deathcoil[1]
endfunction
function Trig_Death_Coil_Target_Dies_Actions takes nothing returns nothing
call RemoveUnit(udg_unit_deathcoil[2])
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl",GetUnitX(udg_unit_deathcoil[2]),GetUnitY(udg_unit_deathcoil[2])))
set udg_unit_deathcoil[1]=null
call DisableTrigger(gg_trg_Death_Coil_Timer)
call DisableTrigger(gg_trg_Death_Coil_Hit)
call DisableTrigger(GetTriggeringTrigger())
endfunction
//===========================================================================
function InitTrig_Death_Coil_Target_Dies takes nothing returns nothing
local integer i=0
set gg_trg_Death_Coil_Target_Dies=CreateTrigger()
call DisableTrigger(gg_trg_Death_Coil_Target_Dies)
loop
exitwhen i==bj_MAX_PLAYER_SLOTS
call TriggerRegisterPlayerUnitEvent(gg_trg_Death_Coil_Target_Dies,Player(i),EVENT_PLAYER_UNIT_DEATH,null)
set i=i+1
endloop
call TriggerAddCondition(gg_trg_Death_Coil_Target_Dies,Condition(function Trig_Death_Coil_Target_Dies_Conditions))
call TriggerAddAction(gg_trg_Death_Coil_Target_Dies,function Trig_Death_Coil_Target_Dies_Actions)
endfunction