Warcraft III resources & community, 2003–2006 · archived

Create Aura

not rated
Submitted by fuglyFunctions0 downloads
A set of functions that create an aura around the "master" unit with in the range of the giving "range", string dowhat is the name of the function to be executed for when a unit comes with in the range of the aura, string endit is the name of the function for when a unit leaves the range of the aura. CreateAura returns a trigger, save that to a variable for when you want to destroy the aura, simply call DestroyAura and give it the trigger. This probably isn't the cleanist code but it works, enjoy

*REQUIRES HANDLE API*
*UPDATE: AURA NOW CANCELS WHEN MASTER UNIT DIES*
*NOTE: DO NOT GIVE A SINGLE UNIT MORE THAN 1 AURA!!*

Source

function H2G takes handle h returns group
return h
return null
endfunction

function H2U takes handle h returns unit
return h
return null
endfunction

function AuraChild takes nothing returns nothing
 call ExecuteFunc(bj_cineFadeContinueTex)
endfunction

function CreateAuraChild takes nothing returns nothing
  local group g = H2G(GetHandleHandle(GetTriggeringTrigger(), "group"))
  local location base = GetUnitLoc(H2U(GetHandleHandle(GetTriggeringTrigger(), "master")))
  local group g2 = GetUnitsInRangeOfLocAll(GetHandleReal(GetTriggeringTrigger(), "range"), base)
  set bj_cineFadeContinueTex  = GetHandleString(GetTriggeringTrigger(), "dowhat")
  call GroupRemoveGroup(g2,g)
  call ForGroup(g2,function AuraChild)
  call GroupRemoveGroup(g,g2)
  set bj_cineFadeContinueTex  = GetHandleString(GetTriggeringTrigger(), "endit")
  call ForGroup(g,function AuraChild)
  call SetHandleHandle(GetTriggeringTrigger(), "group", g2)
  call DestroyGroup(g)
  call RemoveLocation(base)
endfunction

function DestroyAura takes trigger t returns nothing
  local group g = H2G(GetHandleHandle(t, "group"))
  set bj_cineFadeContinueTex  = GetHandleString(t, "endit")
  call DestroyTrigger(t)
  call ForGroup(g,function AuraChild)
  call DestroyGroup(g)
endfunction

function DestroyAuraAction takes nothing returns nothing
  call DestroyAura(H2T(GetHandleHandle(GetTriggerUnit(), "auratrig")))
endfunction

function CreateAura takes unit master, real range, string dowhat, string endit returns trigger
 local trigger t = CreateTrigger()
 local trigger t2 = CreateTrigger()
 local location base = GetUnitLoc(master)
 local group g= GetUnitsInRangeOfLocAll(range, base)
 call TriggerRegisterTimerEventPeriodic( t, 0.50 )
 call TriggerAddAction(t, function CreateAuraChild)
 call SetHandleHandle(t,"group",g)
 call SetHandleHandle(t, "master",master)
 call SetHandleReal(t, "range", range)
 call SetHandleString(t, "endit", endit)
 call SetHandleString(t, "dowhat", dowhat)
 call SetHandleHandle(master, "auratrig", t)
 call TriggerRegisterUnitEvent( t2, master, EVENT_UNIT_DEATH )
 call TriggerAddAction( t2, function DestroyAuraAction )
set base = null
set t2 = null
set g = null
return t
endfunction

Comments

1
might be a stupid question, but how do i use this :?: