Создавал способность и вдруг в один момент способность перестала проигрываться до конца. Думаю дело в лимите. Что можно сделать?

Принятый ответ

Maniac_91, да нет. Это тестовая карта. В ней нет никаких триггеров. У меня там одна функция на ~ 350 строк, которая запускается через таймер каждые 0.03125 сек., а внутри функции куча if'ов, loop'ов... Пока что думаю разделить код на несколько таймеров.

Показан только небольшой набор комментариев вокруг указанного. Перейти к актуальным.
2
27
6 лет назад
Отредактирован MpW
2
ScopteRectuS, тоже такое делал. Помню, надо было найти площадку для стройки, задавал вопрос, и там перебирал каждую точку loop'ами. Но выяснил, что такую работу до конца не выполняет, обрыв. Приходилось там где есть лупы, отделять, и в другую функцию вставлять эти циклы. чтобы потом отдельный поток создавать через ExcecuteFunc.Только так он работал у меня
0
17
6 лет назад
0
Как вам удалось одной способности сорвать поток,если подлагивает может цикл бесконечен,а так около 30к действий
0
21
6 лет назад
0
ledoed, сам не понимаю , как такое могло произойти . Бесконечных циклов нету , все циклу выполняются определённое количество раз через i = i + 1, exitwhen ( i == n )
0
17
6 лет назад
0
Код покажи
0
21
6 лет назад
Отредактирован scopterectus
0
Я уже переделал код, и удалил большую часть, которая вызывала остановку потока. Это то, что осталось после. Сейчас я заново пишу код, с 3-мя таймерами.
- это всё одна функция.
		private static method iterate takes nothing returns nothing
            local  thistype  this   =  thistype( 0 ).next
            local  integer   index  =  0

            loop
                exitwhen ( this == 0 )

                set  this.duration  =  this.duration + FPS

                if ( this.duration <= this.circleDuration ) and IsUnitAlive( this.caster ) then

//                  Изменение прозрачности героя.
                    set  this.casterA  =  this.casterA - ( 155 / ( this.circleDuration / FPS ) )
                    call SetUnitVertexColor( this.caster, 255, 255, 255, R2I( this.casterA ) )
//                  ...

//                  Pасстановка двойников.
                    loop
                        if ( not this.illusionReady[ index ] ) and ( ( RAbsBJ( this.illusionX[ index ] - this.illusionTargetX[ index ] ) >= 12.0 ) or ( RAbsBJ( this.illusionY[ index ] - this.illusionTargetY[ index ] ) >= 12.0 ) ) then
                            set  this.dx                       =  this.illusionTargetX[ index ] - this.illusionX[ index ]
                            set  this.dy                       =  this.illusionTargetY[ index ] - this.illusionY[ index ]
                            set  this.dist                     =  SquareRoot( this.dx * this.dx + this.dy * this.dy )

                            set  this.illusionX[ index ]       =  GetUnitX( this.illusion[ index ] ) + 16.0 * ( this.dx / this.dist )
                            set  this.illusionY[ index ]       =  GetUnitY( this.illusion[ index ] ) + 16.0 * ( this.dy / this.dist )

                            call SetUnitX( this.illusion[ index ], this.illusionX[ index ] )
                            call SetUnitY( this.illusion[ index ], this.illusionY[ index ] )

                        elseif ( not this.illusionReady[ index ] ) then
                            set  this.illusionReady[ index ]  =  true
                            set  this.illusionReadyCount      =  this.illusionReadyCount + 1

                            call PauseUnit       ( this.illusion[ index ], false )
                            call SetUnitAnimation( this.illusion[ index ], "stand" )
                            call SetUnitMoveSpeed( this.illusion[ index ], 0.000000000000000001 )
                            call SetUnitFacing   ( this.illusion[ index ], bj_RADTODEG * Atan2( this.targetY - this.illusionY[ index ], this.targetX - this.illusionX[ index ] ) )
                        else
                            call BJDebugMsg( "WHATA" )
                        endif

                        set  index  =  index + 1
                        exitwhen ( index >= this.maxIllusionCount )
                    endloop
//                  ...

                    if ( this.illusionReadyCount == this.maxIllusionCount ) then
//                      Oбозначение круга.
                        set  this.circleAngle  =  this.circleAngle + 3.60
                        call DestroyEffect( AddSpecialEffect( "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageCaster.mdl", this.targetX + this.circleRadius * Cos( ( this.circleAngle + 0.000 ) * bj_DEGTORAD ), this.targetY + this.circleRadius * Sin( ( this.circleAngle + 0.000 ) * bj_DEGTORAD ) ) )
                        call DestroyEffect( AddSpecialEffect( "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageCaster.mdl", this.targetX + this.circleRadius * Cos( ( this.circleAngle + 120.0 ) * bj_DEGTORAD ), this.targetY + this.circleRadius * Sin( ( this.circleAngle + 120.0 ) * bj_DEGTORAD ) ) )
                        call DestroyEffect( AddSpecialEffect( "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageCaster.mdl", this.targetX + this.circleRadius * Cos( ( this.circleAngle + 240.0 ) * bj_DEGTORAD ), this.targetY + this.circleRadius * Sin( ( this.circleAngle + 240.0 ) * bj_DEGTORAD ) ) )
//                      ...

//                      Cоздание эффектов внутри круга.
                        set  this.randomX  =  this.targetX + GetRandomReal( -this.circleRadius, this.circleRadius ) * Cos( GetRandomReal( 0.0, 360.0 ) * bj_DEGTORAD )
                        set  this.randomY  =  this.targetY + GetRandomReal( -this.circleRadius, this.circleRadius ) * Sin( GetRandomReal( 0.0, 360.0 ) * bj_DEGTORAD )
                        call DestroyEffect( AddSpecialEffect( "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageDeathCaster.mdl", this.randomX, this.randomY ) )
//                      ...

//                      Hанесение урона всем врагажеским воинам в круге и их проклинание ( 100 %-ые промахи  ).
                        set  casterUnit  =  CreateUnit( this.owner, DUMMY_UNIT_ID, this.targetX, this.targetY, 0.0 )
                        call SetUnitInvulnerable( casterUnit, true )
                        call UnitAddAbility     ( casterUnit, 'Aloc' )
                        call UnitRemoveAbility  ( casterUnit, 'Amov' )
                        call UnitAddAbility     ( casterUnit, 'A003' )

                        call GroupEnumUnitsInRange( tGroup, this.targetX, this.targetY, this.circleRadius, null )
                        loop
                            set  this.enumUnit  =  FirstOfGroup( tGroup )
                            exitwhen ( this.enumUnit == null )
                            call GroupRemoveUnit( tGroup, this.enumUnit )

                            if IsUnitEnemy( this.enumUnit, this.owner ) and IsUnitAlive( this.enumUnit ) and ( not IsUnitType( this.enumUnit, UNIT_TYPE_STRUCTURE ) ) then
                                call UnitDamageTarget( this.caster, this.enumUnit, this.damage, true, false, ATTACK_TYPE, DAMAGE_TYPE, WEAPON_TYPE )
                                call DestroyEffect( AddSpecialEffectTarget( "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageDeathCaster.mdl", this.enumUnit, "origin" ) )
                                call SetUnitX( casterUnit, GetUnitX( this.enumUnit ) )
                                call SetUnitY( casterUnit, GetUnitY( this.enumUnit ) )
                                call IssueTargetOrder( casterUnit, "curse", this.enumUnit )
                            endif
                        endloop

                        call RemoveUnit( casterUnit )
                        set  casterUnit  =  null
//                      ...

                    endif

                elseif ( this.duration > this.circleDuration ) and ( this.duration <= ( this.circleDuration + HERO_SLAM_ANIMATION_TIME ) ) and IsUnitAlive( this.caster ) then

//                  Удаление способнсоти для прыжка.
                    call UnitRemoveAbility( this.caster, DEACTIVATE_SPELL_ID )
                    call UnitAddAbility( this.caster, ACTIVATE_SPELL_ID )
//                  ...

//                  Прыжок героя.
                    if ( this.jumpMaxRange  ==  0.0 ) and ( this.jumpStep  ==  0.0 ) then
                        set  this.casterX           =  GetUnitX( this.caster )
                        set  this.casterY           =  GetUnitY( this.caster )
                        set  this.jumpMaxRange      =  SquareRoot( ( this.targetX - this.casterX ) * ( this.targetX - this.casterX ) + ( this.targetY - this.casterY ) * ( this.targetY - this.casterY ) )
                        set  this.jumpStep          =  this.jumpMaxRange  / ( HERO_SLAM_ANIMATION_TIME / FPS )

                        call SetUnitFacing( this.caster, bj_RADTODEG * Atan2( this.targetY - this.casterY, this.targetX - this.casterX ) )
                        call PauseUnit( this.caster, true )
                        call SetUnitPathing( this.caster, false )
                        call SetUnitAnimation( this.caster, "stand" )
                        call SetUnitAnimation( this.caster, "slam" )
                    endif

                    set  this.dx             =  this.targetX - this.casterX
                    set  this.dy             =  this.targetY - this.casterY
                    set  this.dist           =  SquareRoot( this.dx * this.dx + this.dy * this.dy )

                    set  this.casterX        =  this.casterX + this.jumpStep * ( this.dx / this.dist )
                    set  this.casterY        =  this.casterY + this.jumpStep * ( this.dy / this.dist )

                    call SetUnitX          ( this.caster, this.casterX )
                    call SetUnitY          ( this.caster, this.casterY )
                    call SetUnitFlyHeight  ( this.caster, GetParabolaZ( this.jumpHeight, this.jumpMaxRange, this.jumpMaxRange - this.dist ), 0.0 )
//                  ...

//                  Изменение прозрачности героя.
                    set  this.casterA  =  this.casterA + ( 155 / ( this.circleDuration / FPS ) )

//                  call SetUnitVertexColor( this.caster, 255, 255, 255, R2I( this.casterA ) )
                    call SetUnitVertexColor( this.caster, 255, 255, 255, 0 )
//                  ...

//                  Создание "хвоста" во время прыжка.
                    call imagealpha.create( this.caster, R2I( this.casterA ), bj_RADTODEG * Atan2( this.targetY - this.casterY, this.targetX - this.casterX ) )
//                  ...

//                  Анимация двойников и их удаление.
                    loop
                        if ( not this.illusionReady[ index ] ) then
                            call SetUnitVertexColor( this.illusion[ index ], 100, 100, 255, this.illusionA[ index ] )
                            set  this.illusionA[ index ]  =  this.illusionA[ index ] - 15

                            if ( this.illusionA[ index ] > 0 ) then
                                set  this.dx                       =  this.targetX - this.illusionX[ index ]
                                set  this.dy                       =  this.targetY - this.illusionY[ index ]
                                set  this.dist                     =  SquareRoot( this.dx * this.dx + this.dy * this.dy )

                                set  this.illusionX[ index ]  =  GetUnitX( this.illusion[ index ] ) + 16.0 * ( this.dx / this.dist )
                                set  this.illusionY[ index ]  =  GetUnitY( this.illusion[ index ] ) + 16.0 * ( this.dy / this.dist )

                                call SetUnitX( this.illusion[ index ], this.illusionX[ index ] )
                                call SetUnitY( this.illusion[ index ], this.illusionY[ index ] )

                            elseif ( this.illusionA[ index ] <= 0 ) then
                                call RemoveUnit( this.illusion[ index ] )
                                set  this.illusion[ index ]  =  null
                            endif

                        elseif ( this.illusionReady[ index ] ) then
                            set  this.illusionReady[ index ]  =  false
                            call PauseUnit( this.illusion[ index ], true )
                            call SetUnitAnimationByIndex( this.illusion[ index ], 6 )
                        endif

                        set  index  =  index + 1
                        exitwhen ( index >= this.maxIllusionCount )
                    endloop
//                  ...

                elseif ( this.duration > ( this.circleDuration + HERO_SLAM_ANIMATION_TIME ) ) and IsUnitAlive( this.caster ) then

//                  3авершение работы способности.
                    call DestroyEffect( AddSpecialEffect( "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl", this.targetX, this.targetY ) )
                    call SetUnitVertexColor( this.caster, 255, 255, 255, 255 )
                    call SetUnitFlyHeight  ( this.caster, 0.0, 0.0 )
                    call PauseUnit         ( this.caster, false )
                    call SetUnitPathing    ( this.caster, true )
//                  ...

//                  Замедление всех вражеских воинов в области действия.
                    set  casterUnit  =  CreateUnit( this.owner, DUMMY_UNIT_ID, this.targetX, this.targetY, 0.0 )
                    call SetUnitInvulnerable( casterUnit, true )
                    call UnitAddAbility     ( casterUnit, 'Aloc' )
                    call UnitRemoveAbility  ( casterUnit, 'Amov' )
                    call UnitAddAbility     ( casterUnit, 'A002' )
                    call IssueImmediateOrder( casterUnit, "thunderclap" )
                    call RemoveUnit( casterUnit )
                    set  casterUnit  =  null
//                  ...

//                  Hанесение финиального урона после прыжка.
                    call GroupEnumUnitsInRange( tGroup, this.targetX, this.targetY, this.circleRadius, null )
                    loop
                        set  this.enumUnit  =  FirstOfGroup( tGroup )
                        exitwhen ( this.enumUnit == null )
                        call GroupRemoveUnit( tGroup, this.enumUnit )

                        if IsUnitEnemy( this.enumUnit, this.owner ) and IsUnitAlive( this.enumUnit ) and ( not IsUnitType( this.enumUnit, UNIT_TYPE_STRUCTURE ) ) then
                            call UnitDamageTarget( this.caster, this.enumUnit, this.damage, true, false, ATTACK_TYPE, DAMAGE_TYPE, WEAPON_TYPE )
                            call DestroyEffect( AddSpecialEffectTarget( "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageDeathCaster.mdl", this.enumUnit, "origin" ) )
                        endif
                    endloop
//                  ...

//                  Очистка ячейки массива.
                    set this.prev.next  =  this.next
                    set this.next.prev  =  this.prev

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

                    call thistype.deallocate( this )
//                  ...

                elseif ( not IsUnitAlive( this.caster ) ) then
//                  Удаление всех двойников, если они имеются.
                    loop
                        if ( this.illusion[ index ] != null ) then
                            call DestroyEffect( AddSpecialEffect( "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageDeathCaster.mdl", this.illusionX[ index ], this.illusionY[ index ] ) )
                            call RemoveUnit( this.illusion[ index ] )
                        endif

                        set  index = index + 1
                        exitwhen ( index >= this.maxIllusionCount )
                    endloop
//                  ...

//                  Очистка ячейки массива.
                    set this.prev.next  =  this.next
                    set this.next.prev  =  this.prev

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

                    call thistype.deallocate( this )
//                  ...
                endif

                set  this = this.next
            endloop
        endmethod
0
17
6 лет назад
0
а дебагом посори в конце функции может просто чтото неработает
и ты че создаешь и сразу удаляешь бойцов
0
21
6 лет назад
0
ledoed, функции, которая вызывала остановку потока уже нету. Я код уже переписал. А код, что скинул сверху, это код к которому я добавлял что-то, после чего она начала останавливать поток. Как то так.
Показан только небольшой набор комментариев вокруг указанного. Перейти к актуальным.
Чтобы оставить комментарий, пожалуйста, войдите на сайт.