shiFt
Member
- Reaction score
- 8
I got this spell framework from a spell that KingKing helped me make a while ago, so i chopped the struct stuff and tried to make another spell but it doesn't work, and I don't know why. Caster goes invisible, and is able to run through units, damages all units in a small radius around the hero.
JASS:
scope WW initializer Init
globals
private constant integer SPELL_ID = 'A01X'
private hashtable ht = InitHashtable()
endglobals
private struct Data
unit cs
real x
real y
player p
real dur
integer ticks
integer timeScaleTicks
timer t
group g
real dmg
endstruct
globals
private unit U
private Data D
private real X
private real Y
private integer array TimerData
private conditionfunc cf
endglobals
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELL_ID
endfunction
private function Effect2 takes nothing returns boolean
set U = GetFilterUnit()
if GetWidgetLife(U) > .405 and IsUnitEnemy(U,D.p) and IsUnitType(U,UNIT_TYPE_STRUCTURE) == false then
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Undead\\DevourMagic\\DevourMagicBirthMissile.mdl", U, "chest"))
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\Feedback\\SpellBreakerAttack.mdl", U, "chest"))
call UnitDamageTargetEx(D.cs,U, D.dmg, false, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS )
endif
return false
endfunction
private function Effects takes nothing returns nothing
local Data d = LoadInteger(ht,GetHandleId(GetExpiredTimer()),0)
if d.ticks > 0 then
set d.ticks = d.ticks - 1
if d.timeScaleTicks > 0 then
set d.timeScaleTicks = d.timeScaleTicks - 1
else
set d.timeScaleTicks = 10000
endif
set d.x = GetUnitX(d.cs)
set d.y = GetUnitY(d.cs)
set D = d
call GroupEnumUnitsInRange(d.g,d.x,d.y,175.,cf)
return
endif
call PauseTimer(d.t)
call d.destroy()
endfunction
private function Actions takes nothing returns nothing
local Data d = Data.create()
set d.cs = GetTriggerUnit()
set d.p = GetOwningPlayer(d.cs)
set d.dur = 4.
set d.ticks = R2I(d.dur / .05)
set d.timeScaleTicks = R2I(1. / .05)
set d.dmg = 60 + ( 10* GetUnitAbilityLevel(d.cs,SPELL_ID))
if d.t == null then
set d.t = CreateTimer()
call SaveInteger(ht,GetHandleId(d.t),0,d)
endif
if d.g == null then
set d.g = CreateGroup()
endif
call TimerStart(d.t,.05,true,function Effects)
endfunction
//---------------------------------------------------------------------------------------------------------
private function Init takes nothing returns nothing
local trigger t = CreateTrigger( )
local integer i = 0
loop
exitwhen i > 11
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set i = i + 1
endloop
call TriggerAddCondition( t, Condition( function Conditions ) )
call TriggerAddAction( t, function Actions )
set cf = Condition(function Effect2)
set t = null
endfunction
endscope