Добавлен , опубликован
это я делал для друга, мы хотели посмотреть как подобное взаимодействие в варе смотреться будет, код я писал на коленке и никак соответственно не оформлял, так что если хочется блевануть, вы по адресу
это не точная копия само собой (над выстрелами я вообще поленился и взял пламя феникса) но мне в принципе понравилось, прикольно и необычно, буду доделывать
карта с видосом в комментах
`
ОЖИДАНИЕ РЕКЛАМЫ...
1
27
3 года назад
1
раскрыть
globals
    location LFZ = Location(0,0)
endglobals

native UnitAlive takes unit id returns boolean

library functions

function GetLocZ takes real x, real y returns real
    call MoveLocation(LFZ,x,y)
    return GetLocationZ(LFZ)
endfunction

function DBC takes real x, real y, real x1, real y1 returns real
   return SquareRoot((x-x1)*(x-x1)+(y-y1)*(y-y1)) 
endfunction

endlibrary

library mylib1 requires functions
globals
    private group TempG = CreateGroup()
    private item TempItem
endglobals

private function SetUnitPositionEx takes unit u, real x, real y returns nothing
    call SetItemPosition(TempItem,x,y)
    call SetItemVisible(TempItem,false)
    call SetUnitX(u,GetItemX(TempItem))
    call SetUnitY(u,GetItemY(TempItem))
endfunction

private struct mys1
    unit caster
    real angle
    real dist
endstruct

private struct mys
    unit caster
    unit dummy
    real angle
    real dist
    real time
    real time1
    real fly
    real a
    boolean b
    lightning l
    
    method Destroy takes nothing returns nothing
        call KillUnit(this.dummy)
        call DestroyLightning(this.l)
        call RemoveSavedBoolean(H,GetHandleId(this.caster),0)
        call RemoveSavedBoolean(H,GetHandleId(this.caster),2)
        call UnitRemoveAbility(this.caster,'A002')
        call UnitRemoveAbility(this.caster,'Abun')
        
        set this.caster = null
        set this.dummy = null
        set this.l = null
        call this.destroy()
    endmethod
endstruct


private function mycond takes nothing returns boolean
    set bj_lastReplacedUnit = GetFilterUnit()
    return UnitAlive(bj_lastReplacedUnit) and IsUnitEnemy(bj_lastReplacedUnit,GetOwningPlayer(bj_lastCreatedUnit))
endfunction

private function myfunc7 takes nothing returns nothing
    call UnitDamageTarget(bj_lastCreatedUnit,GetEnumUnit(),100,false,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,null)
endfunction

private function move1 takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local mys A = LoadInteger(H,GetHandleId(t),0)
    local real x = GetUnitX(A.dummy)+A.dist*Cos(A.angle)
    local real y = GetUnitY(A.dummy)+A.dist*Sin(A.angle)
    local unit u
    set A.angle = A.angle+A.a
    set A.time = A.time-.01
    
    call SetUnitPositionEx(A.caster,x,y)
    call MoveLightningEx(A.l,true,GetUnitX(A.caster),GetUnitY(A.caster),A.fly+GetUnitFlyHeight(A.caster),GetUnitX(A.dummy),GetUnitY(A.dummy),GetLocZ(GetUnitX(A.dummy),GetUnitY(A.dummy))+GetUnitFlyHeight(A.dummy))

    if A.time <= 0. or not UnitAlive(A.caster) or LoadBoolean(H,GetHandleId(A.caster),0) or DBC(GetUnitX(A.caster),GetUnitY(A.caster),x,y) > 10 then
        if not LoadBoolean(H,GetHandleId(A.caster),0) then
            set bj_lastCreatedUnit = A.caster
            set x = GetUnitX(A.caster)
            set y = GetUnitY(A.caster)
            
            set u = CreateUnit(GetOwningPlayer(A.caster),'u002',x,y,GetRandomReal(0,360))
            call SetUnitX(u,x)
            call SetUnitY(u,y)
            call KillUnit(u)
            set u = null
            
            call GroupEnumUnitsInRange(TempG,x,y,200,Condition(function mycond))
            call ForGroup(TempG,function myfunc7)
            call GroupClear(TempG)
        endif
        
        call FlushChildHashtable(H,GetHandleId(t))
        call PauseTimer(t)
        call DestroyTimer(t)
        call A.Destroy()
    endif
    
    set t = null
endfunction

private function myfunc5 takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local mys A = LoadInteger(H,GetHandleId(t),0)
    
    if A.b then
        set A.time1 = A.time1-.01
    else
        call FlushChildHashtable(H,GetHandleId(t))
        call PauseTimer(t)
        call DestroyTimer(t)
    endif
    
    if A.time1 <= 0. then
        call FlushChildHashtable(H,GetHandleId(t))
        call PauseTimer(t)
        call DestroyTimer(t)
        call A.Destroy()
    endif
    
    set t = null
endfunction

private function move takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local mys A = LoadInteger(H,GetHandleId(t),0)
    local real x = GetUnitX(A.dummy)+15*Cos(A.angle)
    local real y = GetUnitY(A.dummy)+15*Sin(A.angle)
    local real x1
    local real y1
    
    set A.dist = A.dist-15
    call SetUnitPositionEx(A.dummy,x,y)
    
    set x1 = GetUnitX(A.dummy)
    set y1 = GetUnitY(A.dummy)
    call MoveLightningEx(A.l,true,GetUnitX(A.caster),GetUnitY(A.caster),A.fly+GetUnitFlyHeight(A.caster),x1,y1,GetLocZ(x1,y1)+GetUnitFlyHeight(A.dummy))
    
    if A.dist <= 0 or DBC(x1,y1,x,y) > 0 or not UnitAlive(A.caster) then
        call PauseTimer(t)
        if DBC(x1,y1,x,y) > 0 and UnitAlive(A.caster) then
            call UnitAddAbility(A.caster,'Abun')
            call IssueImmediateOrder(A.caster,"stop")
            call SaveBoolean(H,GetHandleId(A.caster),0,false)
            call SaveBoolean(H,GetHandleId(A.caster),2,false)
            call SaveBoolean(H,GetHandleId(A.caster),3,true)
            call SetUnitTimeScale(A.dummy,0.)
            
            // ради звука удара об стену
            set bj_lastCreatedUnit = CreateUnit(Player(15),'u000',x1,y1,0)
            call SetUnitVertexColor(bj_lastCreatedUnit,0,0,0,0)
            call KillUnit(bj_lastCreatedUnit)
            set bj_lastCreatedUnit = null
            
            set A.dist = 700.-A.dist
            set A.time = 3.
            set A.time1 = 2.
            set A.angle = A.angle*bj_RADTODEG
            set A.b = true
            
            call SaveInteger(H,GetHandleId(A.caster),1,A)
            call TimerStart(t,.01,true,function myfunc5) // если в течении 2 секунд не полететь - уничтожить
        else
            call FlushChildHashtable(H,GetHandleId(t))
            call DestroyTimer(t)
            call A.Destroy()
        endif
    endif
    
    set t = null
endfunction

private function myfunc takes nothing returns nothing
    local timer t = CreateTimer()
    local mys A = mys.create()
    local real x
    local real y
    
    set A.caster = GetTriggerUnit()
    set x = GetUnitX(A.caster)
    set y = GetUnitY(A.caster)
    set A.angle = Atan2(GetSpellTargetY()-y,GetSpellTargetX()-x)
    set A.dummy = CreateUnit(GetOwningPlayer(A.caster),'u000',x,y,A.angle*bj_RADTODEG)
    set A.dist = 700.
    set A.fly = GetLocZ(x,y)+50
    set A.l = AddLightningEx("MFPB",true,x,y,A.fly+GetUnitFlyHeight(A.caster),x,y,GetLocZ(x,y)+50)
    
    call UnitAddAbility(A.dummy,'Arav')
    call SetUnitFlyHeight(A.dummy,50,0)
    call SetUnitPathing(A.dummy,false)
    call SetUnitX(A.dummy,x)
    call SetUnitY(A.dummy,y)
    
    call SaveInteger(H,GetHandleId(t),0,A)
    call TimerStart(t,.01,true,function move)
    
    set t = null
endfunction

function Trig_AkshanE_Actions takes nothing returns boolean
    if GetSpellAbilityId() == 'A001' then
        call myfunc()
    endif
    return false
endfunction

private function myfunc3 takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer i = GetHandleId(t)
    call IssueImmediateOrder(LoadUnitHandle(H,i,0),"stop")
    call SaveBoolean(H,GetHandleId(LoadUnitHandle(H,i,0)),2,true)
    call DestroyTimer(t)
    call FlushChildHashtable(H,i)
    set t = null
endfunction

private function myfunc2 takes nothing returns boolean
    local timer t
    local mys A
    local real a
    if LoadBoolean(H,GetHandleId(GetTriggerUnit()),3) then
        call RemoveSavedBoolean(H,GetHandleId(GetTriggerUnit()),3)
        set t = CreateTimer()
        set A = LoadInteger(H,GetHandleId(GetTriggerUnit()),1)
        set a = bj_RADTODEG * Atan2(GetOrderPointY()-GetUnitY(A.dummy), GetOrderPointX()-GetUnitX(A.dummy))
        set A.b = false
        
        if A.angle < 0 then
            set A.angle = 360.+A.angle
        endif
        if a < 0 then
            set a = a+360.
        endif
        
        if (A.angle < 180. and not(a > A.angle and a < A.angle + 180.)) or (A.angle > 180. and a > A.angle - 180. and a < A.angle) then 
            set A.a = 700*bj_DEGTORAD/A.dist
        else
            set A.a = -700*bj_DEGTORAD/A.dist
        endif
        
        set A.angle = Atan2(GetUnitY(A.caster)-GetUnitY(A.dummy),GetUnitX(A.caster)-GetUnitX(A.dummy))+A.a
        call SaveInteger(H,GetHandleId(t),0,A)
        call RemoveSavedInteger(H,GetHandleId(A.caster),1)
        call TimerStart(t,.01,true,function move1)

        call UnitAddAbility(A.caster,'A002')
        
        set t = CreateTimer()
        call SaveUnitHandle(H,GetHandleId(t),0,A.caster)
        call TimerStart(t,0.,false,function myfunc3)
        set t = null
    endif
    return false
endfunction

private function myfunc6 takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local mys1 A = LoadInteger(H,GetHandleId(t),0)
    local real x = GetUnitX(A.caster)+20*Cos(A.angle)
    local real y = GetUnitY(A.caster)+20*Sin(A.angle)
    
    set A.dist = A.dist-20
    call SetUnitPositionEx(A.caster,x,y)
    
    set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(A.caster),'u003',GetUnitX(A.caster),GetUnitY(A.caster),A.angle*bj_RADTODEG)
    call SetUnitVertexColor(bj_lastCreatedUnit,255,255,255,75)
    call UnitApplyTimedLife(bj_lastCreatedUnit,'BTLF',.1)
    
    if DBC(x,y,GetUnitX(A.caster),GetUnitY(A.caster)) > 10 or A.dist <= 0 or not UnitAlive(A.caster) then
        set bj_lastCreatedUnit = A.caster
        set x = GetUnitX(A.caster)
        set y = GetUnitY(A.caster)
        
        set A.caster = CreateUnit(GetOwningPlayer(bj_lastCreatedUnit),'u002',x,y,GetRandomReal(0,360))
        call SetUnitX(A.caster,x)
        call SetUnitY(A.caster,y)
        call KillUnit(A.caster)
        set A.caster = null
        
        call GroupEnumUnitsInRange(TempG,x,y,200,Condition(function mycond))
        call ForGroup(TempG,function myfunc7)
        call GroupClear(TempG)
        
        call FlushChildHashtable(H,GetHandleId(t))
        call PauseTimer(t)
        call DestroyTimer(t)
        
        call A.destroy()
    endif
    
    set t = null
endfunction

private function myfunc1 takes nothing returns boolean
    local timer t
    local mys1 A
    set bj_lastReplacedUnit = GetTriggerUnit()
    if LoadBoolean(H,GetHandleId(bj_lastReplacedUnit),2) then
        call SaveBoolean(H,GetHandleId(bj_lastReplacedUnit),0,true)
        call RemoveSavedBoolean(H,GetHandleId(bj_lastReplacedUnit),2)
        set t = CreateTimer()
        set A = mys1.create()
        
        set A.caster = bj_lastReplacedUnit
        set A.angle = Atan2(GetOrderPointY()-GetUnitY(bj_lastReplacedUnit),GetOrderPointX()-GetUnitX(bj_lastReplacedUnit))
        set A.dist = DBC(GetOrderPointX(),GetOrderPointY(),GetUnitX(bj_lastReplacedUnit),GetUnitY(bj_lastReplacedUnit))
        if A.dist > 300 then
            set A.dist = 300
        endif
        
        call SaveInteger(H,GetHandleId(t),0,A)
        call TimerStart(t,.01,true,function myfunc6)
        set t = null
    endif
    return false
endfunction
//===========================================================================
function InitTrig_AkshanE takes nothing returns nothing
    local trigger t = CreateTrigger()
    local trigger t1 = CreateTrigger()
    set gg_trg_AkshanE = CreateTrigger(  )
    
    set TempItem = CreateItem('spsh',0,0)
    call SetItemVisible(TempItem,false)
    call TriggerRegisterPlayerUnitEvent(t, Player(0x00), EVENT_PLAYER_UNIT_ISSUED_ORDER, null)
    call TriggerRegisterPlayerUnitEvent(t, Player(0x00), EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, null)
    call TriggerRegisterPlayerUnitEvent(t, Player(0x00), EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, null)
    call TriggerRegisterPlayerUnitEvent(t, Player(0x00), EVENT_PLAYER_UNIT_ISSUED_UNIT_ORDER, null)
    call TriggerRegisterPlayerUnitEvent(t1, Player(0x00), EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, null)
    call TriggerRegisterPlayerUnitEvent(t1, Player(0x00), EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, null)
    call TriggerRegisterPlayerUnitEvent(t1, Player(0x00), EVENT_PLAYER_UNIT_ISSUED_UNIT_ORDER, null)
    call TriggerRegisterPlayerUnitEvent(gg_trg_AkshanE, Player(0x00), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
    call TriggerAddCondition( gg_trg_AkshanE, Condition(function Trig_AkshanE_Actions) )
    call TriggerAddCondition(t,Condition(function myfunc1))
    call TriggerAddCondition(t1,Condition(function myfunc2))
endfunction

endlibrary
Загруженные файлы
0
14
3 года назад
0
Ща проверим на вкус
3
27
3 года назад
Отредактирован rsfghd
3
можно цепляться за юнитов
раскрыть
library mylib1 requires functions
globals
    private group TempG = CreateGroup()
    private item TempItem
    private real MaxX
    private real MinX
    private real MaxY
    private real MinY
    private unit CUEX
endglobals

private function SetUnitPositionEx takes unit u, real x, real y returns nothing
    if x > MaxX then
        set x = MaxX
    elseif x < MinX then
        set x = MinX
    endif
    if y > MaxY then
        set y = MaxY
    elseif y < MinY then
        set y = MinY
    endif
    call SetUnitX(u,x)
    call SetUnitY(u,y)
endfunction

private function CreateUnitEx takes player id, integer unitid, real x, real y, real face returns unit
    set CUEX = CreateUnit(id,unitid,x,y,face*bj_RADTODEG)
    call UnitAddAbility(CUEX,'Arav')
    call SetUnitPathing(CUEX,false)
    call SetUnitPositionEx(CUEX,x,y)
    
    return CUEX
endfunction

// булевые переменные для разных проверок
private struct mys2
    boolean b = false // отменить полёт, если рывок
    boolean b1 = false // возможность юзануть рывок во время полёта
    boolean b2 = false // условие, что можно выбрать направление при столкновении крюка с непроходимой точкой
    boolean b3 = false // условие, что во время полёта крюка было выбрано направление
    real x
    real y
    method Destroy takes nothing returns nothing
        set this.b = false
        set this.b1 = false
        set this.b2 = false
        set this.b3 = false
    endmethod
endstruct

// рывок после полёта
private struct mys1
    unit caster
    real angle
    real dist
endstruct

// полёт
private struct mys
    unit caster
    unit dummy
    unit target
    real angle
    real dist
    real time
    real time1
    real fly
    real a
    real tdist
    real ta
    boolean b
    lightning l
    
    method Destroy takes nothing returns nothing
        call KillUnit(this.dummy)
        call DestroyLightning(this.l)
        call UnitRemoveAbility(this.caster,'A002')
        call UnitRemoveAbility(this.caster,'Abun')
        
        set this.caster = null
        set this.dummy = null
        set this.target = null
        set this.l = null
        call this.destroy()
    endmethod
endstruct

private function DamageCond takes nothing returns boolean
    set bj_lastReplacedUnit = GetFilterUnit()
    return UnitAlive(bj_lastReplacedUnit) and IsUnitEnemy(bj_lastReplacedUnit,GetOwningPlayer(bj_lastCreatedUnit))
endfunction

private function Damage takes nothing returns nothing
    call UnitDamageTarget(bj_lastCreatedUnit,GetEnumUnit(),100,false,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,null)
endfunction

// рывок
private function Dash takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local mys1 A = LoadInteger(H,GetHandleId(t),0)
    local real x = GetUnitX(A.caster)+20*Cos(A.angle)
    local real y = GetUnitY(A.caster)+20*Sin(A.angle)
    local real x1
    local real y1
    
    set A.dist = A.dist-20
    call SetUnitPositionEx(A.caster,x,y)
    call SetItemPosition(TempItem,x,y)
    call SetItemVisible(TempItem,false)
    set x = GetUnitX(A.caster)
    set y = GetUnitY(A.caster)
    set x1 = GetItemX(TempItem)
    set y1 = GetItemY(TempItem)
    
    call CreateUnitEx(GetOwningPlayer(A.caster),'u003',x,y,A.angle)
    call SetUnitVertexColor(CUEX,255,255,255,75)
    call UnitApplyTimedLife(CUEX,'BTLF',.1)
    
    if DBC(x1,y1,x,y) > 0 or A.dist <= 0 or not UnitAlive(A.caster) then
        set bj_lastCreatedUnit = A.caster
        call KillUnit(CreateUnitEx(Player(15),'u002',x,y,GetRandomReal(0,360)))
        
        call GroupEnumUnitsInRange(TempG,x,y,250,Condition(function DamageCond))
        call ForGroup(TempG,function Damage)
        call GroupClear(TempG)
        
        call FlushChildHashtable(H,GetHandleId(t))
        call PauseTimer(t)
        call DestroyTimer(t)
        set A.caster = null
        call A.destroy()
    endif
    
    set t = null
endfunction

// отдать приказ стоп после того, как кастующий выбрал направление
private function stop takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer i = GetHandleId(t)
    local mys2 A = LoadInteger(H,GetHandleId(LoadUnitHandle(H,i,0)),0)
    call IssueImmediateOrder(LoadUnitHandle(H,i,0),"stop")
    set A.b1 = true // сохранить булевую о возможности юзануть рывок для функции MoveAndDash
    call DestroyTimer(t)
    call FlushChildHashtable(H,i)
    set t = null
endfunction

// движение кастера
private function MoveCaster takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local mys A = LoadInteger(H,GetHandleId(t),0)
    local mys2 A1 = LoadInteger(H,GetHandleId(A.caster),0)
    local real x = GetUnitX(A.dummy)+A.dist*Cos(A.angle)
    local real y = GetUnitY(A.dummy)+A.dist*Sin(A.angle)
    local real x1
    local real y1
    local unit u
    
    if not A1.b then
        set A.angle = A.angle+A.a
        set A.time = A.time-.01
        
        if A.target != null then
            call SetUnitPositionEx(A.dummy,GetUnitX(A.target)+A.tdist*Cos(A.ta),GetUnitY(A.target)+A.tdist*Sin(A.ta))
        endif
        
        call SetUnitPositionEx(A.caster,x,y)
        call SetItemPosition(TempItem,x,y)
        call SetItemVisible(TempItem,false)
        
        set x = GetUnitX(A.caster)
        set y = GetUnitY(A.caster)
        set x1 = GetItemX(TempItem)
        set y1 = GetItemY(TempItem)
        call MoveLightningEx(A.l,true,x,y,GetLocZ(x,y)+GetUnitFlyHeight(A.caster)+50,GetUnitX(A.dummy),GetUnitY(A.dummy),GetLocZ(GetUnitX(A.dummy),GetUnitY(A.dummy))+A.fly)
    endif
    
    if A.time <= 0. or not UnitAlive(A.caster) or A1.b or DBC(x,y,x1,y1) > 10 then
        if not A1.b then // не создавать взрыв если кастуется рывок
            set bj_lastCreatedUnit = A.caster
            set x = GetUnitX(A.caster)
            set y = GetUnitY(A.caster)
            
            set u = CreateUnit(GetOwningPlayer(A.caster),'u002',x,y,GetRandomReal(0,360))
            call SetUnitPositionEx(u,x,y)
            call KillUnit(u)
            set u = null
            
            call GroupEnumUnitsInRange(TempG,x,y,250,Condition(function DamageCond))
            call ForGroup(TempG,function Damage)
            call GroupClear(TempG)
        endif
        
        call FlushChildHashtable(H,GetHandleId(t))
        call PauseTimer(t)
        call DestroyTimer(t)
        call A.Destroy()
        call A1.Destroy()
    endif
    
    set t = null
endfunction

// направление и рывок
private function AngleAndDash takes nothing returns boolean
    local timer t
    local mys A
    local mys1 A1
    local mys2 A2
    local real a
    
    set bj_lastReplacedUnit = GetTriggerUnit()
    set A2 = LoadInteger(H,GetHandleId(bj_lastReplacedUnit),0)
    if A2 > 0 and OrderId2String(GetIssuedOrderId()) != "stop" then
        if A2.b1 then // рывок
            set A2.b = true // сохранить булевую о прекращении полёта для функции MoveCaster
            set A2.b1 = false
            set t = CreateTimer()
            set A1 = mys1.create()
            
            set A1.caster = bj_lastReplacedUnit
            set A1.angle = Atan2(GetOrderPointY()-GetUnitY(bj_lastReplacedUnit),GetOrderPointX()-GetUnitX(bj_lastReplacedUnit))
            set A1.dist = DBC(GetOrderPointX(),GetOrderPointY(),GetUnitX(bj_lastReplacedUnit),GetUnitY(bj_lastReplacedUnit))
            if A1.dist > 300 then
                set A1.dist = 300
            endif
            
            call SaveInteger(H,GetHandleId(t),0,A1)
            call TimerStart(t,.01,true,function Dash)
            set t = null
        endif
        
        if A2.b2 then // в какую сторону начать лететь
            set A2.b2 = false
            set t = CreateTimer()
            set A = LoadInteger(H,GetHandleId(bj_lastReplacedUnit),1)
            set a = bj_RADTODEG*Atan2(GetOrderPointY()-GetUnitY(A.dummy),GetOrderPointX()-GetUnitX(A.dummy))
            set A.b = false
            set A.fly = GetUnitFlyHeight(A.dummy)
            
            call RemoveSavedInteger(H,GetHandleId(A.caster),1)
            
            if A.angle < 0 then
                set A.angle = A.angle+360.
            endif
            if a < 0 then
                set a = a+360.
            endif
            
            if (A.angle < 180. and not (a > A.angle and a < A.angle + 180.)) or (A.angle > 180. and a > A.angle - 180. and a < A.angle) then 
                set A.a = 700*bj_DEGTORAD/A.dist
            else
                set A.a = -700*bj_DEGTORAD/A.dist
            endif
            
            set A.angle = Atan2(GetUnitY(A.caster)-GetUnitY(A.dummy),GetUnitX(A.caster)-GetUnitX(A.dummy))+A.a
            call SaveInteger(H,GetHandleId(t),0,A)
            call UnitAddAbility(A.caster,'A002')
            
            call TimerStart(t,.01,true,function MoveCaster)
            
            // отдать приказ стоп
            set t = CreateTimer()
            call SaveUnitHandle(H,GetHandleId(t),0,A.caster)
            call TimerStart(t,0.,false,function stop)
            set t = null
        endif
        
        set A2.b3 = true
        set A2.x = GetOrderPointX()
        set A2.y = GetOrderPointY()
    endif
    return false
endfunction

// удаление крюка если не полететь
private function DestroyHook takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local mys A = LoadInteger(H,GetHandleId(t),0)
    local mys2 A1 = LoadInteger(H,GetHandleId(A.caster),0)
    local real x
    local real y
    local real x1
    local real y1
    
    if A.target != null then
        set x = GetUnitX(A.target)+A.tdist*Cos(A.ta)
        set y = GetUnitY(A.target)+A.tdist*Sin(A.ta)
        set x1 = GetUnitX(A.caster)
        set y1 = GetUnitY(A.caster)
        set A.dist = DBC(x,y,x1,y1)
        call SetUnitPositionEx(A.dummy,x,y)
        call MoveLightningEx(A.l,true,x1,y1,GetLocZ(x1,y1)+GetUnitFlyHeight(A.caster)+50,x,y,GetLocZ(x,y)+GetUnitFlyHeight(A.dummy))
    endif
    
    if A.b then
        set A.time1 = A.time1-.01
        if A.time1 <= 0. then
            call FlushChildHashtable(H,GetHandleId(t))
            call PauseTimer(t)
            call DestroyTimer(t)
            call A.Destroy()
            call A1.Destroy()
        endif
    else
        call FlushChildHashtable(H,GetHandleId(t))
        call PauseTimer(t)
        call DestroyTimer(t)
    endif

    set t = null
endfunction

// движение зацепного крюка
private function move takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local timer t1
    local mys A = LoadInteger(H,GetHandleId(t),0)
    local mys2 A1
    local real x = GetUnitX(A.dummy)+15*Cos(A.angle)
    local real y = GetUnitY(A.dummy)+15*Sin(A.angle)
    local real x1
    local real y1
    local real a
    
    set A.dist = A.dist-15
    call SetUnitPositionEx(A.dummy,x,y)
    
    call SetItemPosition(TempItem,x,y)
    call SetItemVisible(TempItem,false)
    
    set x = GetUnitX(A.dummy)
    set y = GetUnitY(A.dummy)
    set x1 = GetItemX(TempItem)
    set y1 = GetItemY(TempItem)
    call MoveLightningEx(A.l,true,GetUnitX(A.caster),GetUnitY(A.caster),GetLocZ(GetUnitX(A.caster),GetUnitY(A.caster))+GetUnitFlyHeight(A.caster)+50,x,y,GetLocZ(x,y)+GetUnitFlyHeight(A.dummy))
    set bj_lastCreatedUnit = A.caster
    call GroupEnumUnitsInRange(TempG,x,y,100,Condition(function DamageCond))
    
    if A.dist <= 0 or DBC(x1,y1,x,y) > 0 or not UnitAlive(A.caster) or FirstOfGroup(TempG) != null then
        call PauseTimer(t)
        set bj_lastCreatedUnit = FirstOfGroup(TempG)
        call UnitDamageTarget(A.caster,bj_lastCreatedUnit,50,false,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,null)
        if (DBC(x1,y1,x,y) > 0 and UnitAlive(A.caster)) or bj_lastCreatedUnit != null then
            call IssueImmediateOrder(A.caster,"stop")
            call UnitAddAbility(A.caster,'Abun')
            call SetUnitTimeScale(A.dummy,0.)
            
            set A.dist = 700.-A.dist
            set A.time = 3.
            set A.angle = A.angle*bj_RADTODEG
            set A.target = bj_lastCreatedUnit
            
            if A.target != null then
                set A.tdist = DBC(x,y,GetUnitX(A.target),GetUnitY(A.target))
                set A.ta = Atan2(y-GetUnitY(A.target),x-GetUnitX(A.target))
            endif
            
            // ради звука удара об стену
            set bj_lastCreatedUnit = CreateUnit(Player(15),'u000',x,y,0)
            call SetUnitVertexColor(bj_lastCreatedUnit,0,0,0,0)
            call KillUnit(bj_lastCreatedUnit)
            set bj_lastCreatedUnit = null
            
            set A1 = LoadInteger(H,GetHandleId(A.caster),0)
            
            if A1.b3 then
                set A.b = false
                set A1.b1 = true
                set A1.b2 = false
                set A1.b3 = false
                
                set a = bj_RADTODEG*Atan2(A1.y-y,A1.x-x)
                set A.fly = GetUnitFlyHeight(A.dummy)
                
                call RemoveSavedInteger(H,GetHandleId(A.caster),1)
                
                if A.angle < 0 then
                    set A.angle = A.angle+360.
                endif
                if a < 0 then
                    set a = a+360.
                endif
                
                if (A.angle < 180. and not (a > A.angle and a < A.angle + 180.)) or (A.angle > 180. and a > A.angle - 180. and a < A.angle) then 
                    set A.a = 700*bj_DEGTORAD/A.dist
                else
                    set A.a = -700*bj_DEGTORAD/A.dist
                endif
                
                set A.angle = Atan2(GetUnitY(A.caster)-y,GetUnitX(A.caster)-x)+A.a
                call UnitAddAbility(A.caster,'A002')
                
                set t1 = CreateTimer()
                call SaveInteger(H,GetHandleId(t1),0,A)
                call TimerStart(t1,.01,true,function MoveCaster)
                set t1 = null
            else
                set A1 = LoadInteger(H,GetHandleId(A.caster),0)
                set A1.b2 = true // сохраняем, что кастер может выбрать куда полететь, для функции AngleAndDash
                set A.b = true
                set A.time1 = 2.
                call SaveInteger(H,GetHandleId(A.caster),1,A)
                call TimerStart(t,.01,true,function DestroyHook) // если в течении 2 секунд не полететь - уничтожить
            endif
        else
            call FlushChildHashtable(H,GetHandleId(t))
            call DestroyTimer(t)
            call A.Destroy()
        endif
        call GroupClear(TempG)
    endif
    
    set t = null
endfunction

// создание зацепного крюка
private function Trig_AkshanE_Actions takes nothing returns nothing
    local timer t = CreateTimer()
    local mys A = mys.create()
    local mys2 A1
    local real x
    local real y
    local real x1 = GetSpellTargetX()
    local real y1 = GetSpellTargetY()

    set A.dist = 700.
    set A.caster = GetTriggerUnit()
    set x = GetUnitX(A.caster)
    set y = GetUnitY(A.caster)
    set A.angle = Atan2(y1-y,x1-x)
    set x1 = x+50*Cos(A.angle)
    set y1 = y+50*Sin(A.angle)
    set A.dummy = CreateUnitEx(GetOwningPlayer(A.caster),'u000',x1,y1,A.angle)
    set A.l = AddLightningEx("MFPB",true,x,y,GetLocZ(x,y)+GetUnitFlyHeight(A.caster)+50,x1,y1,GetLocZ(x1,y1)+50)

    call SetUnitFlyHeight(A.dummy,50,0)

    call SaveInteger(H,GetHandleId(t),0,A)
    call TimerStart(t,.01,true,function move)
    
    set A1 = LoadInteger(H,GetHandleId(A.caster),0)
    if A1 == 0 then
        set A1 = mys2.create()
        call SaveInteger(H,GetHandleId(A.caster),0,A1)
    endif
    set A1.b3 = false
    
    set t = null
endfunction

function Trig_AkshanE_Conditions takes nothing returns boolean
    if GetSpellAbilityId() == 'A001' then
        call Trig_AkshanE_Actions()
    endif
    return false
endfunction
//===========================================================================
function InitTrig_AkshanE takes nothing returns nothing
    local trigger t = CreateTrigger()
    local trigger t1 = CreateTrigger()
    set gg_trg_AkshanE = CreateTrigger(  )
    
    set TempItem = CreateItem('spsh',0,0)
    call SetItemVisible(TempItem,false)
    
    call TriggerRegisterPlayerUnitEvent(t, Player(0x00), EVENT_PLAYER_UNIT_ISSUED_ORDER, null)
    call TriggerRegisterPlayerUnitEvent(t, Player(0x00), EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, null)
    call TriggerRegisterPlayerUnitEvent(t, Player(0x00), EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, null)

    call TriggerRegisterPlayerUnitEvent(gg_trg_AkshanE, Player(0x00), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
    
    call TriggerAddCondition( gg_trg_AkshanE, Condition(function Trig_AkshanE_Conditions) )
    call TriggerAddCondition(t,Condition(function AngleAndDash))
    
    set MaxX = GetRectMaxX(GetWorldBounds())
    set MaxY = GetRectMaxY(GetWorldBounds())
    set MinX = GetRectMinX(GetWorldBounds())
    set MinY = GetRectMinY(GetWorldBounds())

    set t = null
    set t1 = null
endfunction

endlibrary
Загруженные файлы
Чтобы оставить комментарий, пожалуйста, войдите на сайт.