- Joined
- Jan 24, 2009
- Messages
- 606
Hi, I've resently refreshed an old spell of mine... but I cant get it to work, so I was wondering if there's something wrong with the script itself.
Here's the Script:
Please help me
Here's the Script:
JASS:
scope HolyExpl initializer Init
//-----------------Setup Start--------------------------
globals
private constant integer SPELL_ID = 'A000'
private constant attacktype A_TYPE = ATTACK_TYPE_MAGIC
private constant damagetype D_TYPE = DAMAGE_TYPE_NORMAL
private constant string EFFECT = "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl"
private constant string EFFECT2 = "Abilities\\Spells\\Human\\Resurrect\\ResurrectTarget.mdl"
private constant string EFFECT3 = "Abilities\\Spells\\NightElf\\Taunt\\TauntCaster.mdl"
endglobals
private function Damage takes integer level returns real
return level * 50.
endfunction
private function Heal takes integer level returns real
return level * 25.
endfunction
private function Loopdam takes integer level returns real
return level * 35.
endfunction
private function Target takes unit target returns boolean
return (GetWidgetLife(target) > 0.405) and (IsUnitType(target, UNIT_TYPE_STRUCTURE) == false) and (IsUnitType(target, UNIT_TYPE_MAGIC_IMMUNE) == false) and (IsUnitType(target, UNIT_TYPE_MECHANICAL) == false)
endfunction
//-----------------Setup End----------------------------
private function Pick takes nothing returns boolean
return Target(GetFilterUnit())
endfunction
globals
private boolexpr b
private group groups = CreateGroup()
private group loopgroup = CreateGroup()
endglobals
private function Loop_Action takes group whatGroup, unit caster, unit target, string Effect1, string Effect2, real x, real y returns nothing
call GroupEnumUnitsInRange( whatGroup, x, y, 125., null)
call DestroyEffect(AddSpecialEffect( Effect1, x, y))
call DestroyEffect(AddSpecialEffect(Effect2, x, y))
set target = FirstOfGroup(whatGroup)
if IsUnitAlly(target, GetOwningPlayer(caster)) then
call SetWidgetLife(target, GetWidgetLife(target) + Heal(level))
else
call UnitDamageTarget(caster, target, Loopdam(level), true, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_NORMAL, null)
endif
endfunction
private function c takes nothing returns boolean
return GetSpellAbilityId() == SPELL_ID
endfunction
private function a takes nothing returns nothing
local unit caster = GetTriggerUnit()
local timer t = CreateTimer()
local integer loopsec = 0
local integer level = GetUnitAbilityLevel(caster, SPELL_ID)
local real x = GetUnitX(caster)
local real y = GetUnitY(caster)
local real xRandom = GetRandomReal(x-250, x+250)
local real yRandom = GetRandomReal(y-250, y+250)
local real xEffect1 = xRandom+50
local real yEffect1 = yRandom-50
local real xEffect2 = xRandom-50
local real yEffect2 = yRandom+50
local real xEffect3 = xRandom-50
local real yEffect3 = yRandom-50
local real xEffect4 = xRandom+50
local real yEffect4 = yRandom+50
local unit target
call DestroyEffect(AddSpecialEffect(EFFECT, xRandom, yRandom))
call DestroyEffect(AddSpecialEffect(EFFECT, xEffect1, yEffect1))
call DestroyEffect(AddSpecialEffect(EFFECT, xEffect2, yEffect2))
call DestroyEffect(AddSpecialEffect(EFFECT, xEffect3, yEffect3))
call DestroyEffect(AddSpecialEffect(EFFECT, xEffect4, yEffect4))
call GroupEnumUnitsInRange(groups, xRandom, yRandom, 250., b)
loop
set target=FirstOfGroup(groups)
exitwhen target==null
call UnitDamageTarget(caster, target, Damage(level), true, false, A_TYPE, D_TYPE, null)
call GroupRemoveUnit(groups,target)
endloop
loop
set yRandom = GetRandomReal(y-250, y+250)
set xRandom = GetRandomReal(x-250, x+250)
exitwhen loopsec == 10
call TimerStart( t, 0.25, false, function Loop_Action(loopgroup, caster, target, EFFECT2, EFFECT3, xRandom, yRandom))
set target = null
set loopsec = loopsec + 1
call GroupClear(loopgroup)
endloop
call DestroyTimer(t)
set t = null
set loopsec = 0
set caster = null
set target = null
call GroupClear(groups)
endfunction
private function Init takes nothing returns nothing
local trigger Holy = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(Holy, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddAction(Holy, function a)
call TriggerAddCondition(Holy, Condition(function c))
set b = Condition( function Pick)
//preloading Effects
call Preload(EFFECT)
call Preload(EFFECT2)
call Preload(EFFECT3)
//preloading the spell
set bj_lastCreatedUnit = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'hpea', 0,0,0)
call UnitAddAbility(bj_lastCreatedUnit, SPELL_ID)
call RemoveUnit(bj_lastCreatedUnit)
endfunction
endscope
Please help me