Функции варкрафта связанные с действиями над молнией, к примеру MoveLightning приводят к КРАШУ. Как это исправить. Выше прикладываю код, который создает молнию и через заданное время ее удаляет. Что можно поменять чтоб избежать этого краша?

Чтоб игра перестала крашить, молния не должна касаться рельефа,потому как теряется ее координата, достаточно приподнять ее хотя бы на 30, а лучше больше. Странно, что никто об этом на форуме не сообщил.
`
ОЖИДАНИЕ РЕКЛАМЫ...
Этот комментарий удален
32
Ну смотри как двигать молнии нормально, уже не раз выкладывали, можно в стркутуре пребирать циклом все молнии на карте и двигать их 1 таймером. Так же меняем плавно прозрачность и берем GetUnitImpactZ

struct LightningData
    private static constant timer period = CreateTimer( )
    private thistype prev
    private thistype next
    private lightning bolt
    private unit a1
    private unit a2
    private real ax1
    private real ay1
    private real ax2
    private real ay2
    private real alpha
    private real ticks
    private real time
    private boolean flag


    private stub method destroy takes nothing returns nothing

    call SetLightningColor( this.bolt, 0.00, 0.00, 0.00, 0.00 )
    call DestroyLightning( this.bolt )
    set this.a1 = null
    set this.a2 = null
    set this.bolt = null
    set this.alpha = 0.00

    set this.prev.next = this.next
    set this.next.prev = this.prev

    if ( thistype( 0 ).next == 0 ) then
        call PauseTimer( thistype.period )
    endif

    call thistype.deallocate( this )
endmethod
        
private static method iterate takes nothing returns nothing
    local thistype this = thistype( 0 ).next

    loop
        exitwhen ( this == 0 )
                
        if not IsUnitDead( this.a1 ) then
            set this.ax1 = GetUnitX( this.a1 )
            set this.ay1 = GetUnitY( this.a1 )
            if this.flag then
                set this.ax1 = this.ax1 + 25.00
                set this.ay1 = this.ay1 - 25.00
            endif
        endif
                    
        if not IsUnitDead( this.a2 ) then
            set this.ax2 = GetUnitX( this.a2 )
            set this.ay2 = GetUnitY( this.a2 )
        endif
                
        set TempAZ = GetLocationZ( bj_TempPoint ) + GetUnitFlyHeight( this.a1 ) + GetUnitImpactZ( this.a1 ) + 1.00
        call MoveLocation( bj_TempPoint, this.ax2, this.ay2 )
        set TempBZ = GetLocationZ( bj_TempPoint ) + GetUnitFlyHeight( this.a2 ) + GetUnitImpactZ( this.a2 ) + 1.00
        call MoveLightningEx( this.bolt, true, this.ax1, this.ay1, TempAZ, this.ax2, this.ay2, TempBZ )
                    
        if GetLightningColorA( this.bolt ) > this.alpha then
            call SetLightningColor( this.bolt, GetLightningColorR( this.bolt ), GetLightningColorG( this.bolt ), GetLightningColorB( this.bolt ), GetLightningColorA( this.bolt ) - this.alpha )
        endif
                    
        set this.ticks = ( this.ticks + 0.03125 ) * 1.00
        if this.ticks > this.time then
            call this.destroy( )
        endif
                    
        set this = this.next
    endloop

endmethod

static method CreateBolt takes unit a, unit b, string CodeName, real timeout, boolean IsCaster returns thistype
    local thistype this = thistype.allocate( )

    set this.next = thistype( 0 )
    set this.prev = thistype( 0 ).prev
    set this.next.prev = this
    set this.prev.next = this
    set this.a1 = a
    set this.a2 = b
    set this.ax1 = GetUnitX( this.a1 )
    set this.ay1 = GetUnitY( this.a1 )
    set this.ax2 = GetUnitX( this.a2 )
    set this.ay2 = GetUnitY( this.a2 )
    set this.alpha = ( 1.00 / ( timeout / 0.03125 ) )
    set this.ticks = 0
    set this.time = timeout
    set this.flag = IsCaster
            
    call MoveLocation( bj_TempPoint, this.ax1, this.ay1 )
    set TempAZ = GetLocationZ( bj_TempPoint ) + GetUnitFlyHeight( this.a1 ) + GetUnitHeight( this.a1 )
    call MoveLocation( bj_TempPoint, this.ax2, this.ay2 )
    set TempBZ = GetLocationZ( bj_TempPoint ) + GetUnitFlyHeight( this.a2 ) + GetUnitHeight( this.a2 )
    if this.flag then
        set this.ax1 = this.ax1 + 25.00
        set this.ay1 = this.ay1 - 25.00
    endif
    set this.bolt = AddLightningEx( CodeName, true, this.ax1, this.ay1, TempAZ, this.ax2, this.ay2, TempBZ )
    if ( this.prev == 0 ) then
        call TimerStart( thistype.period, 0.03125, true, function thistype.iterate )
    endif
    return this
endmethod
endstruct
Для Impaxt X\Y\Z нужен либо мемхак либо база данных.
1
Принятый ответ
Чтоб игра перестала крашить, молния не должна касаться рельефа,потому как теряется ее координата, достаточно приподнять ее хотя бы на 30, а лучше больше. Странно, что никто об этом на форуме не сообщил.
Чтобы оставить комментарий, пожалуйста, войдите на сайт.