Name | Type | is_array | initial_value |
//TESH.scrollpos=5
//TESH.alwaysfold=0
//-=-=-=-=-=-=-=-=-=-=-
//-=- Ability Format -=-
//-=- CATD base -=-
//-=-=-=-=-=-=-=-=-=-=-
library YourLibraryHere initializer init
globals
private integer Ability = '????' // Ability ID
// ^- Rewrite the value based on what the Ability ID you've chosen is.
private integer dummy = '????' // UnitType ID
// ^- Rewrite the value based on what the UnitType ID you've chosen for your dummy unit.
// (A dummy model has been attached to the download)
private group abilGroup = CreateGroup( )
// ^- Do not modify. This will store your dummy units in a group for 'active spells'.
private integer mT = 10 // maximum Time
// ^- The amount of time the spell will exist before destroying itself as a fail.
private real v = 10 // velocity
// ^- The speed at which your dummy spell will travel.
private string seCi = "..."
// ^- Model string chosen for the Casting units initial effects
private string seTi = "..."
// ^- Model string chosen for the Target units initial effects
private string seTfA = "..."
// ^- Model string chosen for the Target units final effects (PART A)
private string seTfB = "..."
// ^- Model string chosen for the Target units final effects (PART B)
private string seD = "..."
// ^- Model string chosen for the dummy unit.
endglobals
private function results takes unit t, integer l returns nothing
// FINISH THIS FUNCTION WITH THE RESULTS YOU'VE DECIDED FOR THE TARGETED UNIT.
// THIS FUNCTION TAKES THE TARGETED UNIT (t) AND CASTER'S ABIlITY LEVEL (l).
endfunction
// Do not modify beyond this point, unless you understand what you're doing.
// The following is pre-coded to work itself given that you've finished the above.
private struct data
unit c // caster
integer a // ability level
unit t // target
unit d // dummy
effect eCi // effect Caster initial
effect eTi // effect Target initial
effect eTf // effect Target final
effect eD // effect Dummy
real exp // spell expiration Timer
static method create takes unit c, real x, real y, integer a, unit t returns data
local data d = data.allocate()
set d.c = c
set d.a = a
set d.t = t
set d.d = CreateUnit(GetOwningPlayer(d.c), dummy, x, y, GetUnitFacing(c))
call GroupAddUnit(abilGroup, d.d)
set d.eCi = AddSpecialEffectTarget(seCi, d.c, "origin")
set d.eTi = AddSpecialEffectTarget(seTi, d.t, "origin")
set d.eD = AddSpecialEffectTarget(seD, d.d, "origin")
set d.exp = 0
call DestroyEffect(d.eCi)
set d.eCi = null
call SetUnitUserData(d.d, d)
return d
endmethod
static method update takes nothing returns nothing
local unit u = GetEnumUnit()
local data d = GetUnitUserData(u)
local location loc = GetUnitLoc(u)
local location col = GetUnitLoc(d.t)
set d.exp = d.exp + .05 // update timer.
call SetUnitFacing(u, AngleBetweenPoints(loc,col))
call SetUnitX(u, GetUnitX(u) + v * Cos(GetUnitFacing(u) * bj_DEGTORAD))
call SetUnitY(u, GetUnitY(u) + v * Sin(GetUnitFacing(u) * bj_DEGTORAD))
if ( DistanceBetweenPoints(loc,col) <= v ) then // if spell hits.
set d.exp = mT
call results(d.t, d.a)
set d.eTf = AddSpecialEffectTarget(seTfA, d.t, "origin")
call DestroyEffect(d.eTf)
set d.eTf = AddSpecialEffectTarget(seTfB, d.t, "origin")
call DestroyEffect(d.eTf)
set d.eTf = null
endif
if ( d.exp >= mT ) then // if spell expires.
call DestroyEffect(d.eTi)
set d.eTi = null
call DestroyEffect(d.eD)
set d.eD = null
set d.c = null
set d.t = null
set d.d = null
call RemoveUnit(u)
call GroupRemoveUnit(abilGroup,u)
call d.destroy()
endif
set u = null
call RemoveLocation(loc)
set loc = null
call RemoveLocation(col)
set col = null
endmethod
endstruct
private struct store
unit target
static method create takes unit c, unit t returns store
local store s = store.allocate()
set s.target = t
call SetUnitUserData(c, s)
return s
endmethod
endstruct
private function cast takes nothing returns nothing
local unit u = GetTriggerUnit()
local store s = GetUnitUserData(u)
if ( GetSpellAbilityId() == Ability ) then
call data.create(u, GetUnitX(u), GetUnitY(u), GetUnitAbilityLevel(u, Ability), s.target)
// caster x y ability level target
call s.destroy()
endif
set u = null
endfunction
private function periodic takes nothing returns nothing
local integer i = CountUnitsInGroup(abilGroup)
if ( i > 0 ) then
call ForGroup(abilGroup, function data.update)
endif
endfunction
private function identify takes nothing returns nothing
if ( GetSpellAbilityId() == Ability ) then
call store.create(GetTriggerUnit(), GetSpellTargetUnit())
endif
endfunction
private function init takes nothing returns nothing
local trigger t
local integer i
set i = 0
set t = CreateTrigger( )
loop
if ( GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING ) then
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_CAST, null)
endif
set i = i + 1
exitwhen i > 11
endloop
call TriggerAddAction(t, function identify)
set i = 0
set t = CreateTrigger( )
loop
if ( GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING ) then
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_FINISH, null)
endif
set i = i + 1
exitwhen i > 11
endloop
call TriggerAddAction(t, function cast)
set t = CreateTrigger( )
call TriggerRegisterTimerEvent(t, .05, true)
call TriggerAddAction(t, function periodic)
set t = null
endfunction
endlibrary