Кто может помочь переделать триггерную способность - Автодобыча , без потери функционала..
Создает кучу точек которые не удаляются.
Способность работает так : нажал - появился баф и юнит пошел добывать ресурсы+бить разрушаемые объекты.
Если нажать еще раз на скил автодобыча прекращается.
function Trig_SahterRudokop_Func001Func001Func002Func002Func002Func001Func002C takes nothing returns boolean
	if(not(GetItemTypeId(udg_item01)=='I000' or GetItemTypeId(udg_item01)=='I002'))then  //  Только 2 предмета не ITEM_TYPE_POWERUP
		return false
	endif
	if(not((UnitInventorySizeBJ(udg_unit01)-UnitInventoryCount(udg_unit01))>0))then
		return false
	endif
	return true
endfunction

function Trig_SahterRudokop_Func001Func001Func002Func002Func002Func001C takes nothing returns boolean
	if((GetItemType(udg_item01)==ITEM_TYPE_POWERUP))then
		return true
	endif
	if(Trig_SahterRudokop_Func001Func001Func002Func002Func002Func001Func002C())then
		return true
	endif
	return false
endfunction

function Trig_SahterRudokop_Func001Func001Func002Func002Func002C takes nothing returns boolean
	if(not Trig_SahterRudokop_Func001Func001Func002Func002Func002Func001C())then
		return false
	endif
	return true
endfunction

function Trig_SahterRudokop_Func001Func001Func002Func002A takes nothing returns nothing
	set udg_item01=GetEnumItem()
	if(Trig_SahterRudokop_Func001Func001Func002Func002Func002C())then
		call IssueTargetItemOrder(udg_unit01,"smart",udg_item01)
		set udg_integer01=2
	endif
endfunction


function Trig_SahterRudokop_Func001Func001Func002Func003Func002A takes nothing returns nothing
	set udg_destructable01=GetEnumDestructable() // udg_destructable01 - все нужные разрушаемые объекты
	if(GetDestructableTypeId(udg_destructable01)!='B003' and IsDestructableAliveBJ(udg_destructable01)==true)then  //  Ненужный объект
		if(DistanceBetweenPoints(GetDestructableLoc(udg_destructable01),GetUnitLoc(udg_unit01))<DistanceBetweenPoints(GetDestructableLoc(udg_destructable03),GetUnitLoc(udg_unit01)))then
			set udg_integer01=1
			set udg_destructable03=udg_destructable01
		endif
	endif
endfunction


function Trig_SahterRudokop_Func001Func001Func002C takes nothing returns boolean
	if(not(UnitHasBuffBJ(udg_unit01,'BUF1')==true or UnitHasBuffBJ(udg_unit01,'BUF2') or UnitHasBuffBJ(udg_unit01,'BUF3')))then // Баф на юните при вкл.скила
		return false
	endif
	if(not(OrderId2StringBJ(GetUnitCurrentOrder(udg_unit01))==""))then
		return false
	endif
	return true
endfunction

function Trig_SahterRudokop_Func001Func001A takes nothing returns nothing
	set udg_unit01=GetEnumUnit()
	if(Trig_SahterRudokop_Func001Func001Func002C())then
		set udg_integer01=0
		if((GetUnitTypeId(udg_unit01)=='UNT1' or GetUnitTypeId(udg_unit01)=='UNT2' or GetUnitTypeId(udg_unit01)=='UNT3'))then  //  около 20 юнитов
		call EnumItemsInRectBJ(RectFromCenterSizeBJ(GetUnitLoc(udg_unit01),600.00,600.00),function Trig_SahterRudokop_Func001Func001Func002Func002A)
		endif
		if(udg_integer01==0)then
			call EnumDestructablesInCircleBJ(700.00,GetUnitLoc(udg_unit01),function Trig_SahterRudokop_Func001Func001Func002Func003Func002A)
		endif
		if(udg_integer01==0)then
			call IssuePointOrderLocBJ(udg_unit01,"move",GetRandomLocInRect(RectFromCenterSizeBJ(GetUnitLoc(udg_unit01),600.00,600.00)))
		endif
		if(udg_integer01==1)then
			if(DistanceBetweenPoints(GetDestructableLoc(udg_destructable03),GetUnitLoc(udg_unit01))<250.00)then
				call IssueTargetDestructableOrder(udg_unit01,"attack",udg_destructable03)
			else
				call IssuePointOrderLocBJ(udg_unit01,"move",GetDestructableLoc(udg_destructable03))
			endif
		endif
	endif
endfunction

function Trig_SahterRudokop_Actions takes nothing returns nothing  //  Автодобыча для всех игроков ( скилл только у некоторых юнитов )
	set bj_forLoopAIndex=1
	loop
		exitwhen bj_forLoopAIndex>11
		call ForGroupBJ(GetUnitsOfPlayerAll(ConvertedPlayer(bj_forLoopAIndex)),function Trig_SahterRudokop_Func001Func001A)
		set bj_forLoopAIndex=bj_forLoopAIndex+1
	endloop
endfunction
//===========================================================================
function InitTrig_SahterRudokop takes nothing returns nothing
    set gg_trg_SahterRudokop = CreateTrigger(  )
	call TriggerRegisterTimerEventPeriodic(gg_trg_SahterRudokop,0.50)
    call TriggerAddAction( gg_trg_SahterRudokop, function Trig_SahterRudokop_Actions )
endfunction

Вот, держи. Правда не тестил ибо писал на маке.
Нет мастурбации с созданием и удалением групп и ректов. Используется одна группа и рект.
Нет локалок, чтоб не париться с утечками.
Правда может не скомпилиться, но это уже дело третье.
native UnitAlive takes unit u returns boolean
//! zinc
    library MinerMiner {
        group g = CreateGroup();
        unit u;
        integer uid, action, itid, did;
        rect r = Rect(0, 0, 0, 0);
        real ux, uy, dx, dy;
        item it;
        destructable d, dt;

        function distance(destructable d, unit u) -> real {
            real dx = GetUnitX(u) - GetDestructableX(d);
            real dy = GetUnitY(u) - GetDestructableY(d);
            return dx * dx + dy * dy;
        }

        function onInit() {
            trigger t = CreateTrigger();
            TriggerRegisterTimerEventPeriodic(t, .5);
            TriggerAddAction( t, function() {
                integer i = 0;
                for (0 <= i < bj_MAX_PLAYER_SLOTS) {
                    GroupEnumUnitsOfPlayer(g, Player(i), null);
                    ForGroup(g, function() {
                        u = GetEnumUnit();
                        uid = GetUnitTypeId(u);
                        ux = GetUnitX(u);
                        uy = GetUnitY(u);
                        if (!UnitAlive(u)) {
                            return;
                        }
                        // Баф на юните при вкл.скила
                        if (GetUnitAbilityLevel(u, 'BUF1') == 0 && GetUnitAbilityLevel(u, 'BUF2') == 0 && GetUnitAbilityLevel(u, 'BUF3') == 0) {
                            return;
                        }
                        if (GetUnitCurrentOrder(u) != 0) {
                            return;
                        }
                        action = 0;

                        //  около 20 юнитов
                        if(uid == 'UNT1' || uid == 'UNT2' || uid == 'UNT3') {
                            SetRect(r, ux - 300, uy - 300, ux + 300, uy + 300);
                            EnumItemsInRect(r, null, function() {
                                it = GetEnumItem();
                                itid = GetItemTypeId(it);
                                //  Только 2 предмета не ITEM_TYPE_POWERUP
                                if (GetItemType(it) != ITEM_TYPE_POWERUP && itid != 'I000' && itid != 'I002') {
                                    return;
                                }
                                if(UnitInventorySize(u) - UnitInventoryCount(u) <= 0) {
                                    return;
                                }
                                IssueTargetOrder(u, "smart", it);
                                action = 2;                            
                            });
                        }

                        if (action == 0) {
                            SetRect(r, ux - 700, uy - 700, ux + 700, uy + 700);
                            dt = null;
                            EnumDestructablesInRect(r, null, function() {
                                d = GetEnumDestructable();
                                did = GetDestructableTypeId(d);
                                dx = GetDestructableX(d);
                                dy = GetDestructableY(d);

                                //  Ненужный объект
                                if (GetDestructableLife(d) <= 0 && did != 'B003') {
                                    return;
                                }

                                if (dt == null || distance(d, u) < distance(dt, u)) {
                                    action = 1;
                                    dt = d;
                                }
                            });
                        }

                        if (action == 0) {
                            IssuePointOrder(u, "move", GetRandomReal(ux - 300, ux + 300), GetRandomReal(uy - 300, uy + 300));
                        }

                        if (action == 1) {
                            if (distance(dt, u) < 62500) {
                                IssueTargetOrder( u, "attack", dt);
                            } else {
                                IssuePointOrder(u, "move", GetDestructableX(dt), GetDestructableY(dt));
                            }
                        }
                    });
                }
            });
            t = null;
        }
    }
//! endzinc
`
ОЖИДАНИЕ РЕКЛАМЫ...

Показан только небольшой набор комментариев вокруг указанного. Перейти к актуальным.
28
копец, зочем ты гуи в текст конвертировал

перепишу чуть позже если никто не преуспеет
30
копец, зочем ты гуи в текст конвертировал
Потому что jass быстрее гуи.
1
GUI у меня небыло. Это моя мод версия карты которой небыло в GUI, а авторов первой версии я не нашел
28
Electr0_H0use, ну попробуй это, работоспособность я не мог проверить потому что карты собственно нет
раскрыть
function Trig_SahterRudokop_Func001Func001Func002Func002A takes nothing returns nothing
	set udg_item01 = GetEnumItem( )
    
	if GetItemType( udg_item01 ) == ITEM_TYPE_POWERUP and GetItemTypeId( udg_item01 ) == 'I000' or GetItemTypeId( udg_item01 ) == 'I002' and UnitInventorySize( udg_unit01 ) - UnitInventoryCount( udg_unit01 ) > 0 then // Только 2 предмета не ITEM_TYPE_POWERUP
		call IssueTargetOrder( udg_unit01, "smart", udg_item01 )
		set udg_integer01 = 2
	endif
endfunction

function Trig_SahterRudokop_Func001Func001Func002Func003Func002A takes nothing returns nothing
	local real x
    local real y
    local real x1
    local real y1
    local real x2
    local real y2
    set udg_destructable01 = GetEnumDestructable( ) // udg_destructable01 - все нужные разрушаемые объекты
	
    if GetDestructableTypeId( udg_destructable01 ) != 'B003' and GetDestructableLife( udg_destructable01 ) > 0.00 then // Ненужный объект
		set x  = GetUnitX( udg_unit01 )
        set y  = GetUnitY( udg_unit01 )
        set x1 = GetDestructableX( udg_destructable01 )
        set y1 = GetDestructableY( udg_destructable01 )
        set x2 = GetDestructableX( udg_destructable03 )
        set y2 = GetDestructableY( udg_destructable03 )
        
        if SquareRoot( ( x - x1 ) * ( x - x1 ) + ( y - y1 ) * ( y - y1 ) ) < SquareRoot( ( x - x2 ) * ( x - x2 ) + ( y - y2 ) * ( y - y2 ) ) then
			set udg_integer01 = 1
			set udg_destructable03 = udg_destructable01
		endif
	endif
endfunction

function Trig_SahterRudokop_Func001Func001A takes nothing returns nothing
    local integer i
    local rect r
    local rect r1
    local real x
    local real y
    local real x1
    local real y1
	set udg_unit01 = GetEnumUnit( )
    
	if GetUnitCurrentOrder( udg_unit01 ) == 0 and ( GetUnitAbilityLevel( udg_unit01, 'BUF1' ) > 0 or GetUnitAbilityLevel( udg_unit01, 'BUF2' ) > 0 or GetUnitAbilityLevel( udg_unit01, 'BUF3' ) > 0 ) then // Баф на юните при вкл.скила
		set udg_integer01 = 0
		set i = GetUnitTypeId( udg_unit01 )
        set x = GetUnitX( udg_unit01 )
        set y = GetUnitY( udg_unit01 )
        set r = Rect( x - 300.00, y - 300.00, x + 300.00, y + 300.00 )
        
        if i == 'UNT1' or i == 'UNT2' or i == 'UNT3' then // около 20 юнитов
            call EnumItemsInRect( r, null, function Trig_SahterRudokop_Func001Func001Func002Func002A )
		endif
		
        if udg_integer01 == 0 then
            set r1 = Rect( x - 700.00, y - 700.00, x + 700.00, y + 700.00 )
            set bj_enumDestructableCenter = Location( x, y )
            set bj_enumDestructableRadius = 700.00
            
            call EnumDestructablesInRect( r, filterEnumDestructablesInCircleBJ, function Trig_SahterRudokop_Func001Func001Func002Func003Func002A )
            
            call RemoveLocation( bj_enumDestructableCenter )
            call RemoveRect( r1 )
            set r1 = null
        endif
		
        if udg_integer01 == 0 then
			call IssuePointOrder( udg_unit01, "move", x + GetRandomReal( -300.00, 300.00 ), y + GetRandomReal( -300.00, 300.00 ) )
		elseif udg_integer01 == 1 then
            set x1 = GetDestructableX( udg_destructable03 )
            set y1 = GetDestructableY( udg_destructable03 )
            
			if SquareRoot( ( x - x1 ) * ( x - x1 ) + ( y - y1 ) * ( y - y1 ) ) < 250.00 then
				call IssueTargetOrder( udg_unit01, "attack", udg_destructable03 )
			else
				call IssuePointOrder( udg_unit01, "move", x1, y1 )
			endif
		endif
        
        call RemoveRect( r )
        set r = null
	endif
endfunction

function Trig_SahterRudokop_Actions takes nothing returns nothing  //  Автодобыча для всех игроков ( скилл только у некоторых юнитов )
	local integer i = 11
    local group g = CreateGroup( )
    
    loop
        call GroupEnumUnitsOfPlayer( g, Player( i ), null )
        call ForGroup( g, function Trig_SahterRudokop_Func001Func001A )
        call GroupClear( g )
        
        set i = i - 1
        exitwhen i < 1
    endloop
    
    call DestroyGroup( g )
    
    set g = null
endfunction

//===========================================================================
function InitTrig_SahterRudokop takes nothing returns nothing
    set gg_trg_SahterRudokop = CreateTrigger(  )
    call TriggerRegisterTimerEvent(gg_trg_SahterRudokop, 0.50, true)
    call TriggerAddAction( gg_trg_SahterRudokop, function Trig_SahterRudokop_Actions )
endfunction
1
rsfghd,
Спасибо, Handle Counter показывает раза в 4+ меньше цифр если скил юзает много юнитов, но они всеравно повышаются но теперь меньше. Новые проблемы - юниты с автодобычей не подбирают предметы, скил не работает у Игрока 1 (красный), при запуске карты спустя пару секунд Handle Counter показывает небольшое увеличение цифр постоянное даже если не юзать скил (с старым триггером такого небыло если его не включать).
Показан только небольшой набор комментариев вокруг указанного. Перейти к актуальным.
Чтобы оставить комментарий, пожалуйста, войдите на сайт.