Code
function Trig_All_Random_Filter takes nothing returns boolean
if ( not ( GetPlayerSlotState(Player(bj_forLoopAIndex - 1) == PLAYER_SLOT_STATE_PLAYING ) ) then
return false
endif
return true
endfunction
function Trig_All_Random_Actions takes nothing returns nothing
if (IsPlayerInForce(GetLocalPlayer(), bj_FORCE_ALL_PLAYERS)) then
DisplayTextToPlayer(GetLocalPlayer(), 0, 0, ( GetPlayerName(GetTriggerPlayer()) + ( " включил " + "|cFF008AFFAll Random|r" ) ))
endif
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 12
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
if ( Trig_All_Random_Filter() ) then
unit u = CreateUnitAtLoc(Player(bj_forLoopAIndex - 1), udg_Hero[GetRandomInt(1, 9)], GetStartLocationLoc(GetPlayerStartLocation(Player(bj_forLoopAIndex - 1))), 180.00)
if (GetLocalPlayer() == Player(bj_forLoopAIndex - 1)) then
SetCameraPosition(GetLocationX(GetStartLocationLoc(GetPlayerStartLocation(GetLocalPlayer()))), GetLocationY(GetStartLocationLoc(GetPlayerStartLocation(GetLocalPlayer()))))
endif
if (IsPlayerInForce(GetLocalPlayer(), bj_FORCE_ALL_PLAYERS)) then
DisplayTextToPlayer(GetLocalPlayer(), 0, 0, (udg_Player_Colors[GetPlayerId(Player(bj_forLoopAIndex - 1)) + 1] + ( GetPlayerName(Player(bj_forLoopAIndex - 1)) + "|r" ) ) + ( " выбрал " + GetUnitName(u)))
endif
u = null
call SetPlayerTechMaxAllowed(Player(bj_forLoopAIndex - 1), 'HERO', 0)
else
endif
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
call DisableTrigger( GetTriggeringTrigger() )
endfunction
function InitTrig_All_Random takes nothing returns nothing
set gg_trg_All_Random = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_All_Random, Player(1), "-ar", true )
call TriggerAddAction( gg_trg_All_Random, function Trig_All_Random_Actions )
endfunction
собственно вопрос- как можно сделать фильтр для произвольного выбора? GetRandomInt() работает плохо, в этом никто не сомневался. Все рав-коды героев занесены в переменную с массивом Hero[] при инициализации (это я думаю поняли все). Заранее спасибо