Status
Coding Type : GUI/JASS/VJASS
Spell Type : MUI
Ability Description
Unleash a ward around the targeted unit that would attack it, the ward would also release a energy bolt that destroy the hp of nearby enemy unit. Targeted unit get stun for 5 seconds by this ability.
Level 1 - Lasts 10 seconds.
Level 2 - Lasts 15 seconds.
Level 3 - Lasts 20 seconds.
Version 1.07 Update
Create a VJASS version of it (Full credit for VJASS version goes to Dark Dragon).
Version 1.06
Add additional code in order to remove 16 memory leaks of type boolexpr cause by TriggerRegisterAnyUnitEventBJ
Version 1.05
Create a JASS version of it.
Version 1.04
Further optimize the maths to enable beginner to modify this spell easier.
Version 1.03
Fix minor flaw.
Version 1.02
Improve coding.
Version 1.01
Disable documentation sample.
Trigger:
- Lightning Ward GUI
- Events
- Unit - A unit Starts the effect of an ability
- Conditions
- (Ability being cast) Equal to Lightning Ward (GUI)
- Actions
- Set LW_Target_Unit = (Target unit of ability being cast)
- Set LW_Target_Point = (Target point of ability being cast)
- Set LW_Target_Position = (Position of LW_Target_Unit)
- Set LW_Level = (Level of Lightning Ward (GUI) for (Triggering unit))
- Set LW_Duration = (5.00 + (5.00 x (Real(LW_Level))))
- Set LW_Loop_Number = 5
- For each (Integer LW_Integer) from 1 to LW_Loop_Number, do (Actions)
- Loop - Actions
- Set LW_Spawn_Point = (LW_Target_Position offset by 500.00 towards (360.00 x ((Real(LW_Integer)) / (Real(LW_Loop_Number)))) degrees)
- Unit - Create 1 Lightning Ward for (Owner of (Triggering unit)) at LW_Spawn_Point facing LW_Target_Point
- Unit - Add a LW_Duration second Generic expiration timer to (Last created unit)
- Unit - Add Lightning Bolt to (Last created unit)
- Unit - Order (Last created unit) to Undead Crypt Lord - Locust Swarm
- Unit - Order (Last created unit) to Attack LW_Target_Unit
- Custom script: call RemoveLocation(udg_LW_Spawn_Point)
- Loop - Actions
- Custom script: call RemoveLocation(udg_LW_Target_Point)
- Custom script: call RemoveLocation(udg_LW_Target_Position)
- Events
JASS:
function Trig_Lightning_Ward_JASS_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 039;A003039;
endfunction
function Trig_Lightning_Ward_JASS_Actions takes nothing returns nothing
local unit LTR = GetTriggerUnit()
local unit LV = GetSpellTargetUnit()
local location LP = GetSpellTargetLoc()
local location LT = GetUnitLoc(LV)
local location LSP
local integer LL = GetUnitAbilityLevel(LTR, 039;A003039;)
local real LD = 5.00 + 5.00 * LL
local integer LI = 1
local unit LU
local real FA = AngleBetweenPoints(LT, LP)
local integer DU = 5
local real Deg = 360/DU
loop
exitwhen LI > DU
set LSP = PolarProjectionBJ(LT, 500.00, LI * Deg)
set LU = CreateUnitAtLoc(GetOwningPlayer(LTR), 039;o000039;, LSP, FA)
call UnitApplyTimedLife(LU, 039;BTLF039;, LD)
call UnitAddAbility(LU, 039;A002039;)
call IssueImmediateOrder(LU, "locustswarm" )
call IssueTargetOrder(LU, "attack", LV )
call RemoveLocation(LSP)
set LU = null
set LI = (LI+1)
endloop
call RemoveLocation(LP)
call RemoveLocation(LT)
set LP = null
set LT = null
set LTR = null
set LV = null
set LSP = null
endfunction
constant function DummyFilter takes nothing returns boolean
return true
endfunction
function Lightning_Ward_JASS takes nothing returns nothing
local trigger T = CreateTrigger()
local integer TI = 0
local filterfunc FF = Filter(function DummyFilter)
loop
exitwhen (TI >= bj_MAX_PLAYER_SLOTS)
call TriggerRegisterPlayerUnitEvent(T, Player(TI), EVENT_PLAYER_UNIT_SPELL_EFFECT, FF)
set TI = TI + 1
endloop
call DestroyFilter(FF)
set FF = null
set T = null
endfunction
//===========================================================================
function InitTrig_Lightning_Ward_JASS takes nothing returns nothing
set gg_trg_Lightning_Ward_JASS = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Lightning_Ward_JASS, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Lightning_Ward_JASS, Condition( function Trig_Lightning_Ward_JASS_Conditions ) )
call TriggerAddAction( gg_trg_Lightning_Ward_JASS, function Trig_Lightning_Ward_JASS_Actions )
endfunction
JASS:
library_once LightningWard initializer Init
globals
private constant integer LIGHTNING_WARD = 039;A004039;
private constant integer DUMMY_RAWCODE = 039;o000039;
private constant integer SWARM_RAWCODE = 039;A002039;
private constant real OFFSET_DISTANCE = 500.
private constant integer MAX_WARDS = 5
endglobals
private function LightningWard takes nothing returns boolean
local unit LTU
local unit LV
local player P
local real X
local real Y
local real LD
local integer LI
local unit LU
local real RAD
if (GetSpellAbilityId() == LIGHTNING_WARD) then
set LTU = GetTriggerUnit()
set LV = GetSpellTargetUnit()
set X = GetUnitX(LV)
set Y = GetUnitY(LV)
set LD = (GetUnitAbilityLevel(LTU, LIGHTNING_WARD)*5)+5.
set RAD = (2.*bj_PI)/MAX_WARDS
set P = GetOwningPlayer(LTU)
set LI = 0
loop
exitwhen (LI >= MAX_WARDS)
set LU = CreateUnit(P, DUMMY_RAWCODE, X+OFFSET_DISTANCE*Cos(RAD*LI), Y+OFFSET_DISTANCE*Sin(RAD*LI), 0.)
call UnitApplyTimedLife(LU, 039;BTLF039;, LD)
call UnitAddAbility(LU, SWARM_RAWCODE)
call IssueImmediateOrder(LU, "locustswarm" )
call IssueTargetOrder(LU, "attack", LV)
set LI = LI + 1
endloop
set LU = null
set P = null
set LTU = null
set LV = null
endif
return (FALSE)
endfunction
// ===========================================================================
private constant function DummyFilter takes nothing returns boolean
return true
endfunction
private function Init takes nothing returns nothing
local trigger T = CreateTrigger()
local integer I = 0
local filterfunc FF = Filter(function DummyFilter)
loop
exitwhen (I >= bj_MAX_PLAYER_SLOTS)
call TriggerRegisterPlayerUnitEvent(T, Player(I), EVENT_PLAYER_UNIT_SPELL_EFFECT, FF)
set I = I + 1
endloop
call TriggerAddCondition(T, Condition(function LightningWard))
call DestroyFilter(FF)
set FF = null
set T = null
endfunction
endlibrary