- Joined
- Sep 16, 2008
- Messages
- 47
Co my problem is that there is no damage to unit in group, also loop function does not end, When i remove everything about that unit group loop function ends and everything works but i need to caster damage units in Damage_Range.
How to fix it?
If you see anything wrong just tell me
How to fix it?
If you see anything wrong just tell me
JASS:
constant function SpellID takes nothing returns integer
return 'A000'
endfunction
constant function MaxHeight takes nothing returns real
return 350.00
endfunction
constant function FPS takes nothing returns real
return 0.03125
endfunction
constant function Damage takes nothing returns real
return 200
endfunction
constant function Damage_Range takes nothing returns real
return 200
endfunction
function ParabolicMovement takes real h, real d, real x returns real
local real a = -4*h/(d*d)
local real b = 4*h/d
return a*x*x + b*x
endfunction
function GetDistance takes real x, real y, real xt, real yt returns real
return SquareRoot((xt - x) * (xt - x) + (yt - y) * (yt - y))
endfunction
function GetAngles takes real ax2, real ax, real ay2, real ay returns real
return bj_RADTODEG*Atan2(ay2 - ay, ax2 - ax)
endfunction
function IsUnitAlive takes unit id returns boolean
return not IsUnitType(id, UNIT_TYPE_DEAD) and GetUnitTypeId(id) != 0
endfunction
function Loop takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId(t)
local unit caster = LoadUnitHandle(udg_HL_Table, id, 0)
local real speed = LoadReal(udg_HL_Table, id, 1)
local real distance = LoadReal(udg_HL_Table, id, 2)
local real angle = LoadReal(udg_HL_Table, id, 3)
local real Cdistance = LoadReal(udg_HL_Table, id, 4)
local real damage = LoadReal(udg_HL_Table, id, 5)
local real x = GetLocationX(GetUnitLoc(caster)) + speed * Cos(angle* bj_DEGTORAD)
local real y = GetLocationY(GetUnitLoc(caster)) + speed * Sin(angle* bj_DEGTORAD)
local real Height
local group g
local unit u
if Cdistance < distance then
call SetUnitX(caster, x)
call SetUnitY(caster, y)
call SaveReal(udg_HL_Table, id, 4, Cdistance + speed)
set Height = ParabolicMovement(MaxHeight(), distance, Cdistance)
call SetUnitFlyHeight(caster, Height, 0)
else
set g = GetUnitsInRangeOfLocAll(Damage_Range(), GetUnitLoc(caster))
loop
exitwhen u == null
set u = FirstOfGroup(g)
if IsUnitEnemy(u, GetOwningPlayer(caster)) == true then
call UnitDamageTarget(caster, u, damage, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_CLAW_MEDIUM_SLICE)
call GroupRemoveUnit(g, u)
endif
endloop
call DestroyGroup(g)
call UnitRemoveAbility(caster, 'A001')
call PauseUnit(caster, false)
call FlushChildHashtable(udg_HL_Table, id)
call DestroyTimer(t)
endif
set caster = null
set t = null
endfunction
function Actions takes nothing returns nothing
local unit caster = GetTriggerUnit()
local real distance = GetDistance(GetLocationX(GetUnitLoc(caster)), GetLocationY(GetUnitLoc(caster)), GetLocationX(GetSpellTargetLoc()), GetLocationY(GetSpellTargetLoc()))
local real cx = GetUnitX(caster)
local real cy = GetUnitY(caster)
local real tx = GetLocationX(GetSpellTargetLoc())
local real ty = GetLocationY(GetSpellTargetLoc())
local real angle = GetAngles(tx, cx, ty, cy)
local real speed = distance / 50
local real damage = GetUnitAbilityLevel(caster, SpellID()) * Damage()
local real Cdistance = 0.00
local timer t = CreateTimer()
local integer id = GetHandleId(t)
call UnitAddAbility(caster, 'A001')
call PauseUnit(caster, true)
call SaveUnitHandle(udg_HL_Table, id, 0, caster)
call SaveReal(udg_HL_Table, id, 1, speed)
call SaveReal(udg_HL_Table, id, 2, distance)
call SaveReal(udg_HL_Table, id, 3, angle)
call SaveReal(udg_HL_Table, id, 4, Cdistance)
call SaveReal(udg_HL_Table, id, 5, damage)
call TimerStart(t, FPS(), true, function Loop)
set caster = null
set t = null
endfunction
function Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == SpellID() ) ) then
return false
endif
return true
endfunction
//===========================================================================
function InitTrig_Heroic_Leap_Cast takes nothing returns nothing
set gg_trg_Heroic_Leap_Cast = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Heroic_Leap_Cast, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Heroic_Leap_Cast, Condition( function Conditions ) )
call TriggerAddAction( gg_trg_Heroic_Leap_Cast, function Actions )
endfunction