Добавлен Стас Орлов
Имеется два кода для разных способностей, каждая из них движет юнита вокруг героя, но один код работает исправно, а другой притягивает юнитов к герою, хотя код и механика одинакова. В чём проблема?
Работает
function circlemotionsoul takes nothing returns nothing
local timer SoulMooveCircleTimer = GetExpiredTimer()
local integer id = GetHandleId(SoulMooveCircleTimer)
local unit Soul = LoadUnitHandle(H, id, 1)
local unit DeathKnight = LoadUnitHandle(H, id, 2)
local real SoulX = GetUnitX(Soul)
local real SoulY = GetUnitY(Soul)
local real SoulStealerX = GetUnitX(DeathKnight)
local real SoulStealerY = GetUnitY(DeathKnight)
local integer ds = LoadInteger(H, id, 3)
local real a
if Soul != null then
set a = bj_RADTODEG * Atan2(SoulStealerY + 250 * Sin((6 * ds) * bj_DEGTORAD) - SoulY, SoulStealerX + 250 * Cos((6 * ds) * bj_DEGTORAD) - SoulX)
call SetUnitPosition(Soul, SoulX + 10 * Cos(a * bj_DEGTORAD), SoulY + 10 * Sin(a * bj_DEGTORAD))
if ds == 60 then
set ds = 0
else
set ds = ds + 1
endif
call SaveInteger(H, id, 3, ds)
else
call DestroyTimer(SoulMooveCircleTimer)
call FlushChildHashtable(H, id)
endif
set SoulMooveCircleTimer = null
set Soul = null
set DeathKnight = null
endfunction
function motionsoul takes nothing returns nothing
local timer SoulMooveTimer = GetExpiredTimer()
local integer id = GetHandleId(SoulMooveTimer)
local unit Soul = LoadUnitHandle(H, id, 1)
local unit DeathKnight = LoadUnitHandle(H, id, 2)
local real SoulX = GetUnitX(Soul)
local real SoulY = GetUnitY(Soul)
local real SoulStealerX = GetUnitX(DeathKnight)
local real SoulStealerY = GetUnitY(DeathKnight)
local real a
local timer SoulMooveCircleTimer = CreateTimer()
local integer idt = GetHandleId(SoulMooveCircleTimer)
if SquareRoot((SoulStealerX - SoulX) * (SoulStealerX - SoulX) + (SoulStealerY - SoulY) * (SoulStealerY - SoulY)) >= 200 then
set a = bj_RADTODEG * Atan2(SoulStealerY - SoulY, SoulStealerX - SoulX)
call SetUnitPosition(Soul, SoulX + 25 * Cos(a * bj_DEGTORAD), SoulY + 25 * Sin(a * bj_DEGTORAD))
else
call DestroyTimer(SoulMooveTimer)
call FlushChildHashtable(H, id)
call TimerStart( SoulMooveCircleTimer, 0.04, true, function circlemotionsoul)
call SaveUnitHandle(H, idt, 1, Soul)
call SaveUnitHandle(H, idt, 2, DeathKnight)
call GroupAddUnit(KnifeGroup, Soul)
endif
set SoulMooveTimer = null
set Soul = null
set DeathKnight = null
set SoulMooveCircleTimer = null
endfunction
Не работает
function BladeDanceMoveAround2 takes nothing returns nothing
local unit Knife = GetEnumUnit()
local integer tid = GetHandleId(KnifeGroup)
local integer ds = LoadInteger(H, tid, 'Arnd')
local real Distance = LoadReal(H, tid, 'Dist')
local real CasterX = GetUnitX(Kolamana)
local real CasterY = GetUnitY(Kolamana)
local real KnifeX = GetUnitX(Knife)
local real KnifeY = GetUnitY(Knife)
local real a
set a = bj_RADTODEG * Atan2(CasterY + Distance * Sin(6 * ds * bj_DEGTORAD) - KnifeY, CasterX + Distance * Cos(6 * ds * bj_DEGTORAD) - KnifeX)
call SetUnitPosition(Knife, KnifeX + 10 * Cos(a * bj_DEGTORAD), KnifeY + 10 * Sin(a * bj_DEGTORAD))
call BJDebugMsg("Angle: " + R2S(a) + ". NewX " + R2S(KnifeX + 10 * Cos(a * bj_DEGTORAD)) + ". NewY " + R2S(KnifeY + 10 * Sin(a * bj_DEGTORAD)) + ". Ds " + R2S(ds))
if ds == 60 then
set ds = 0
else
set ds = ds + 1
endif
call SaveInteger(H, tid, 'Arnd', ds)
set Knife = null
endfunction
function BladeDanceMoveAround1 takes nothing returns nothing
call ForGroup(KnifeGroup, function BladeDanceMoveAround2)
endfunction
function Trig_BladeDance_Actions takes nothing returns nothing
local integer ingex = 0
local unit KnifeU
local player Owner = GetOwningPlayer(Kolamana)
local integer lvl = 3 + 2 * GetUnitAbilityLevel(Kolamana, BladeDance)
local real X = GetUnitX(Kolamana)
local real Y = GetUnitY(Kolamana)
local real NewX
local real NewY
local real angle = 0.00
local real Distance = 200.00
local timer Timer = CreateTimer()
loop
set KnifeU = FirstOfGroup(KnifeGroup)
exitwhen KnifeU == null
call GroupRemoveUnit(KnifeGroup, KnifeU)
call RemoveUnit(KnifeU)
endloop
call GroupClear(KnifeGroup)
loop
set angle = angle + 360.00 / lvl
set NewX = X + Distance * Cos(angle * bj_DEGTORAD)
set NewY = Y + Distance * Sin(angle * bj_DEGTORAD)
set KnifeU = CreateUnit(Owner, KnifeMoveId, NewX, NewY, angle)
call GroupAddUnit(KnifeGroup, KnifeU)
set ingex = ingex + 1
exitwhen ingex == lvl
endloop
call TimerStart(Timer, 0.04, true, function BladeDanceMoveAround1)
call SaveReal(H, GetHandleId(KnifeGroup), 'Dist', Distance)
call SaveTimerHandle(H, GetHandleId(KnifeGroup), 'BDMA', Timer)
set KnifeU = null
set Owner = null
set Timer = null
endfunction
function BladeDance_Conditions takes nothing returns boolean
return GetSpellAbilityId() == BladeDance
endfunction
//===========================================================================
function InitTrig_BladeDance takes nothing returns nothing
local integer index
local trigger T1 = CreateTrigger()
set index = 0
loop
call TriggerRegisterPlayerUnitEvent(T1, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition(T1,function BladeDance_Conditions)
call TriggerAddAction(T1, function Trig_BladeDance_Actions)
set T1 = null
endfunction
`
ОЖИДАНИЕ РЕКЛАМЫ...
Чтобы оставить комментарий, пожалуйста, войдите на сайт.
Отредактирован rsfghd
Отредактирован Гуванч
Отредактирован rsfghd
Отредактирован Стас Орлов