- Joined
- Aug 21, 2008
- Messages
- 533
I tried to make a system which allow me to easily make "chain" spells like chain healing or chain lightning. but it something do not work...
Jasshelper says everything is fine =/
JASS:
library chainspell
function Enemyfilter takes nothing returns boolean
return IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()),GetOwningPlayer(udg_tempunit))
endfunction
function Allyfilter takes nothing returns boolean
return IsPlayerAlly(GetOwningPlayer(GetFilterUnit()),GetOwningPlayer(udg_tempunit))
endfunction
function ReGroup takes nothing returns nothing
call GroupRemoveUnit(tempgroup,GetEnumUnit())
endfunction
function chainspell takes unit caster,unit target,integer baseSpell,integer spell,integer NrOfTargets,real range,boolean TargetEnemy returns nothing
local unit u = CreateUnit(GetOwningPlayer(caster),'h003',GetUnitX(caster),GetUnitY(caster),0)
local real x=GetUnitX(target)
local real y=GetUnitY(target)
local real oldx=GetUnitX(caster)
local real oldy=GetUnitY(caster)
local group Donot
//this messeage works
call BJDebugMsg("spell triggers")
call GroupAddUnit(Donot,u)
call UnitAddAbility(u,spell)
call SetUnitAbilityLevel(u,spell,GetUnitAbilityLevel(caster,baseSpell))
call GroupAddUnit(chaingroup,u)
call SaveReal( udg_HashTable, GetHandleId(u), StringHash("X"), x)
call SaveReal( udg_HashTable, GetHandleId(u), StringHash("Y"), y)
call SaveReal( udg_HashTable, GetHandleId(u), StringHash("oldX"), oldx)
call SaveReal( udg_HashTable, GetHandleId(u), StringHash("oldY"), oldy)
call SaveInteger( udg_HashTable, GetHandleId(u), StringHash("targets"), NrOfTargets)
call SaveInteger( udg_HashTable, GetHandleId(u), StringHash("spell"), spell)
call SaveUnitHandle( udg_HashTable, GetHandleId(u), StringHash("Target"), target)
call SaveBoolean( udg_HashTable, GetHandleId(u), StringHash("TargetEnemy"), TargetEnemy)
call SaveGroupHandle( udg_HashTable, GetHandleId(u), StringHash("DoNotTargets"), Donot)
set u = null
set caster = null
set target = null
endfunction
function chainspellEx2 takes nothing returns nothing
local group g
local unit u = GetEnumUnit()
local unit target = LoadUnitHandle( udg_HashTable, GetHandleId(u), StringHash("Target"))
local group DoNot = LoadGroupHandle( udg_HashTable, GetHandleId(u), StringHash("DoNotTargets"))
local real x = LoadReal( udg_HashTable, GetHandleId(u), StringHash("X"))
local real y = LoadReal( udg_HashTable, GetHandleId(u), StringHash("Y"))
local real oldx = LoadReal( udg_HashTable, GetHandleId(u), StringHash("oldX"))
local real oldy = LoadReal( udg_HashTable, GetHandleId(u), StringHash("oldY"))
local boolean boole =LoadBoolean( udg_HashTable, GetHandleId(u), StringHash("TargetEnemy"))
local integer RemainTargets= LoadInteger( udg_HashTable, GetHandleId(u), StringHash("targets"))
//this messeage does NOT work
call BJDebugMsg("it works!")
call SetUnitX(u,oldx)
call SetUnitY(u,oldy)
call UnitResetCooldown( u )
call IssueTargetOrderById(u,LoadInteger(udg_HashTable, GetHandleId(u), StringHash("spell")),target)
if RemainTargets == 0 then
call FlushChildHashtable(udg_HashTable,GetHandleId(u))
call UnitApplyTimedLife(u,'BTLF',0.01)
call GroupRemoveUnit(chaingroup,u)
else
call GroupAddUnit(DoNot,target)
set udg_tempunit=u
if boole == true then
call GroupEnumUnitsInRange(tempgroup,x,y,500.00,Condition(function Enemyfilter))
else
call GroupEnumUnitsInRange(tempgroup,x,y,500.00,Condition(function Allyfilter))
endif
call ForGroup(DoNot,function ReGroup)
set g= tempgroup
set target=FirstOfGroup(g)
set RemainTargets=RemainTargets-1
call SaveReal( udg_HashTable, GetHandleId(u), StringHash("X"), GetUnitX(target))
call SaveReal( udg_HashTable, GetHandleId(u), StringHash("Y"), GetUnitY(target))
call SaveReal( udg_HashTable, GetHandleId(u), StringHash("oldX"), x)
call SaveReal( udg_HashTable, GetHandleId(u), StringHash("oldY"), y)
call SaveInteger( udg_HashTable, GetHandleId(u), StringHash("targets"),RemainTargets)
call SaveGroupHandle( udg_HashTable, GetHandleId(u), StringHash("DoNotTargets"), DoNot)
endif
set u = null
set target = null
call DestroyGroup(tempgroup)
call DestroyGroup(g)
call DestroyGroup(DoNot)
set g = null
set DoNot=null
endfunction
function chainspellEx takes nothing returns nothing
//this messeage works
call BJDebugMsg("timer")
call ForGroup(chaingroup,function chainspellEx2)
endfunction
endlibrary