- Joined
- Dec 10, 2008
- Messages
- 850
Well, I've been wanting to make a spell to get back into things, and I've recently been trying to make a chain lightning spell. I think the problem with it might be the FilterFunc function, but it might not be. Any help is appreciated, but don't yell "OMGZ RIPZ OFFZ".
Pleaase note that theres some stuff in the globals block to be added to the script still, it isn't a major part of the script, thats why I havn't added it yet, as it wouldn't affect the lightning creation part.
JASS:
scope ChainLightning initializer init
globals
private constant integer SPELL_ID = 'A000'
private constant string Lightning = "CLSB"
private constant string LightningImpact = "Abilities/Weapons/boltBoltImpact.mdl"
private constant integer MAX_TARG = 3 // Change this to set what the max amount of targets is mutlitplied by the level.
private constant boolean Decrease = false
private constant real DMG = 100 // this will control how much damage is done per level
boolexpr BOOL
endglobals
private function FilterFunc takes nothing returns boolean
local unit u = GetFilterUnit()
local boolean ok = GetWidgetLife(u) > .045 and IsUnitEnemy(u,GetOwningPlayer(GetTriggerUnit()))
set u = null
return ok
endfunction
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELL_ID
endfunction
private function Actions takes nothing returns nothing
local unit U = GetTriggerUnit()
local real UX = GetUnitX(U)
local real UY = GetUnitY(U)
local real TX
local real TY
local integer Level = GetUnitAbilityLevel(U,SPELL_ID)
local integer Max1 = Level*MAX_TARG
local integer Max2 = 0
local unit T
local unit Y
local player P = GetOwningPlayer(U)
local real Damage = DMG*Level
local lightning array L
local integer Index = 0
local group G = CreateGroup()
call GroupEnumUnitsInRange(G,UX,UY,99999,BOOL)
loop
set T = FirstOfGroup(G)
exitwhen Max2==Max1
call GroupRemoveUnit(G,T)
set UX = GetUnitX(Y)
set UY = GetUnitY(Y)
set TX = GetUnitX(T)
set TY = GetUnitY(T)
set L[Index] = AddLightningEx(Lightning,false,UX,UY,50,TX,TY,50)
call UnitDamageTarget(U,T,Damage,true,false,ATTACK_TYPE_MAGIC,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
set Y = T
set Index = Index +1
call TriggerSleepAction(.5)
endloop
loop
exitwhen Index == 0
call DestroyLightning(L[Index])
set Index = Index - 1
endloop
call DestroyGroup(G)
set U = null
set T = null
endfunction
//======================================================================================
private function init takes nothing returns nothing
local trigger I = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(I,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(I,Condition(function Conditions))
call TriggerAddAction(I,function Actions)
set I = null
set BOOL = Filter(function FilterFunc)
endfunction
endscope
Pleaase note that theres some stuff in the globals block to be added to the script still, it isn't a major part of the script, thats why I havn't added it yet, as it wouldn't affect the lightning creation part.