Алгоритм сравнения 4 чисел
есть аванпост, есть 4 команды по 2 человека когда его захватывают то когда конец захвата нужно сделать сравнение если число захватчиков из команды 1 больше число захватчиков из команды 2 из команды 3 из команды 4 то создать такого то юнита за команду 1 а если они равны то сделать случайное число сколько из них равно а если 1 больше то создать за него а если нету больше и часть равна то сделать случайное число между этими частями а то что самое низкое того ненадо, есть ли формула для этого?

Лучший ответ:
поправьте если не правильно...
» смотреть сюда
//===========================================================================
// Trigger: beginsspellchannel
//===========================================================================
function destroyunit takes nothing returns nothing
local unit u = GetEnumUnit()
call RemoveUnit(u)
set u = null
endfunction
function unittypedefixportal takes nothing returns boolean
local unit u = GetFilterUnit()
if GetUnitTypeId(u) == 'hpea' then
return true
set u = null
else
return false
set u = null
endif
endfunction
function allavanpost1 takes nothing returns nothing
set udg_GGInteger = udg_GGInteger + 1
endfunction
function schitalochka takes nothing returns nothing
local unit u = GetEnumUnit()
local player p2 = Player(2)
local player p5 = Player(5)
local player p8 = Player(8)
local player p11 = Player(11)
if IsUnitAlly(u,p2) == true then
set udg_GInteger1 = udg_GInteger1 + 1
endif
if IsUnitAlly(u,p5) == true then
set udg_GInteger2 = udg_GInteger2 + 1
endif
if IsUnitAlly(u,p8) == true then
set udg_GInteger3 = udg_GInteger3 + 1
endif
if IsUnitAlly(u,p11) == true then
set udg_GInteger4 = udg_GInteger4 + 1
endif
set u = null
set p2 = null
set p5 = null
set p8 = null
set p11 = null
endfunction
function ivent takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u1 = LoadUnitHandle(udg_Hash,GetHandleId(t),1)
local real lifereal2 = LoadReal(udg_Hash,GetHandleId(t),2)
local unit u = null
local player p = null
local unitstate life = UNIT_STATE_LIFE
local unitstate maxlife = UNIT_STATE_MAX_LIFE
local player p0 = null
local player p6 = null
local player p13 = null
local player p14 = null
local unit u2 = null
local unit u4 = null
local unit u5 = null
local unit u3 = null
local group g = null
local code cot = null
local code cot1 = null
local code cot2 = null
local boolexpr filterkaka14 = null
local item i = null
local timer t1 = null
local integer i1 = 0
local integer i2 = 0
local integer i3 = 0
local integer i4 = 0
if GetUnitStatePercent(u1, life, maxlife) > lifereal2 then
call SaveReal(udg_Hash,GetHandleId(t),2,lifereal2+GetUnitStatePercent(u1, life, maxlife)-lifereal2)
endif
set cot1 = function allavanpost1
set udg_GGInteger = 0
call ForGroup(udg_G,cot1)
if GetUnitStatePercent(u1, life, maxlife) <= lifereal2 or udg_GGInteger == 0 then
call SaveReal(udg_Hash,GetHandleId(t),2,lifereal2+GetUnitStatePercent(u1, life, maxlife)-lifereal2)
call SetUnitState(u1, life, GetUnitState(u1, maxlife) * RMaxBJ(0,0.01) * 0.01)
call AddUnitAnimationProperties(u1, "alternate", false)
call SetUnitAnimation( u1, "stand ready" )
if udg_GGInteger == 0 then
call GroupClear(udg_G)
call DestroyGroup(udg_G)
set udg_G = null
set udg_G = CreateGroup()
endif
set u1 = null
set life = null
set maxlife = null
call PauseTimer(t)
call FlushChildHashtable(udg_Hash,GetHandleId(t))
call DestroyTimer(t)
set t = null
endif
set cot1 = null
if GetUnitStatePercent(u1, life, maxlife) == 100 then
set cot1 = function schitalochka
set udg_GInteger1 = 0
set udg_GInteger2 = 0
set udg_GInteger3 = 0
set udg_GInteger4 = 0
call ForGroup(udg_G,cot1)
set cot1 = null
call GroupClear(udg_G)
call DestroyGroup(udg_G)
set udg_G = null
set udg_G = CreateGroup()
set g = CreateGroup()
set cot =  function destroyunit
set cot2 = function unittypedefixportal
set filterkaka14 = Condition(cot2)
call GroupEnumUnitsInRange(g, GetUnitX(u1),GetUnitY(u1), 99999999999, filterkaka14)
call ForGroup(g,cot)
set i1 = IMaxBJ(udg_GInteger1,udg_GInteger2) 
set i2 = IMaxBJ(udg_GInteger3,udg_GInteger4)
set i3 = IMinBJ(udg_GInteger1,udg_GInteger2) 
set i4 = IMinBJ(udg_GInteger3,udg_GInteger4) 
if i1 > i2 then
set p13 = Player(PLAYER_NEUTRAL_PASSIVE)
set u4 = CreateUnit(p13,'hrtt',GetUnitX(u1),GetUnitY(u1),GetRandomReal(0,360))
call SetUnitState(u4,life,GetUnitState(u4,maxlife) * RMaxBJ(0,0.01) * 0.01)
if udg_GInteger1 > udg_GInteger2 then
set udg_AvanpostInteger = 1
set p = Player(2)
elseif udg_GInteger1 == udg_GInteger2 then
if GetRandomInt(1,2) == 1 then
set udg_AvanpostInteger = 1
set p = Player(2)
elseif GetRandomInt(1,2) == 2 then
set udg_AvanpostInteger = 2
set p = Player(5)
endif
elseif udg_GInteger1 < udg_GInteger2 then
set udg_AvanpostInteger = 2
set p = Player(5)
endif
set u2 = CreateUnit( p, 'hpea',  GetUnitX(u4),GetUnitY(u4),GetUnitFacing(u4) )
set u4 = null
set p13 = null
set p = null
set u2 = null
elseif i1 == i2 then
set p13 = Player(PLAYER_NEUTRAL_PASSIVE)
set u4 = CreateUnit(p13,'hrtt',GetUnitX(u1),GetUnitY(u1),GetRandomReal(0,360))
call SetUnitState(u4,life,GetUnitState(u4,maxlife) * RMaxBJ(0,0.01) * 0.01)
if udg_GInteger1  == udg_GInteger2 and udg_GInteger3 == udg_GInteger4 then
if GetRandomInt(1,4) == 1 then
set udg_AvanpostInteger = 1
set p = Player(2)
elseif GetRandomInt(1,4) == 2 then
set udg_AvanpostInteger = 2
set p = Player(5)
elseif GetRandomInt(1,4) == 3 then
set udg_AvanpostInteger = 3
set p = Player(8)
elseif GetRandomInt(1,4) == 4 then
set udg_AvanpostInteger = 4
set p = Player(11)
endif
elseif udg_GInteger1 == udg_GInteger2 and udg_GInteger3 > udg_GInteger4 then
if GetRandomInt(1,3) == 1 then
set udg_AvanpostInteger = 1
set p = Player(2)
elseif GetRandomInt(1,3) == 2 then
set udg_AvanpostInteger = 2
set p = Player(5)
elseif GetRandomInt(1,3) == 3 then
set udg_AvanpostInteger = 3
set p = Player(8)
endif
elseif udg_GInteger1 == udg_GInteger2 and udg_GInteger3 < udg_GInteger4 then
if GetRandomInt(1,3) == 1 then
set udg_AvanpostInteger = 1
set p = Player(2)
elseif GetRandomInt(1,3) == 2 then
set udg_AvanpostInteger = 2
set p = Player(5)
elseif GetRandomInt(1,3) == 3 then
set udg_AvanpostInteger = 3
set p = Player(11)
endif
elseif udg_GInteger1 > udg_GInteger2 and udg_GInteger3 == udg_GInteger4 then
if GetRandomInt(1,3) == 1 then
set udg_AvanpostInteger = 1
set p = Player(2)
elseif GetRandomInt(1,3) == 2 then
set udg_AvanpostInteger = 2
set p = Player(8)
elseif GetRandomInt(1,3) == 3 then
set udg_AvanpostInteger = 3
set p = Player(11)
endif
elseif udg_GInteger1 < udg_GInteger2 and udg_GInteger3 == udg_GInteger4 then
if GetRandomInt(1,3) == 1 then
set udg_AvanpostInteger = 1
set p = Player(5)
elseif GetRandomInt(1,3) == 2 then
set udg_AvanpostInteger = 2
set p = Player(8)
elseif GetRandomInt(1,3) == 3 then
set udg_AvanpostInteger = 3
set p = Player(11)
endif
elseif udg_GInteger1 > udg_GInteger2 and udg_GInteger3 > udg_GInteger4 then
if GetRandomInt(1,2) == 1 then
set udg_AvanpostInteger = 1
set p = Player(2)
elseif GetRandomInt(1,2) == 2 then
set udg_AvanpostInteger = 2
set p = Player(8)
endif
elseif udg_GInteger1 > udg_GInteger2 and udg_GInteger3 < udg_GInteger4 then
if GetRandomInt(1,2) == 1 then
set udg_AvanpostInteger = 1
set p = Player(2)
elseif GetRandomInt(1,2) == 2 then
set udg_AvanpostInteger = 2
set p = Player(11)
endif
elseif udg_GInteger1 < udg_GInteger2 and udg_GInteger3 < udg_GInteger4 then
if GetRandomInt(1,2) == 1 then
set udg_AvanpostInteger = 1
set p = Player(5)
elseif GetRandomInt(1,2) == 2 then
set udg_AvanpostInteger = 2
set p = Player(11)
endif
elseif udg_GInteger1 < udg_GInteger2 and udg_GInteger3 > udg_GInteger4 then
if GetRandomInt(1,2) == 1 then
set udg_AvanpostInteger = 1
set p = Player(5)
elseif GetRandomInt(1,2) == 2 then
set udg_AvanpostInteger = 2
set p = Player(8)
endif
endif
set u2 = CreateUnit( p, 'hpea',  GetUnitX(u4),GetUnitY(u4),GetUnitFacing(u4) )
set u4 = null
set p13 = null
set p = null
set u2 = null
//òóò ñàìîå ñëîæíîå
elseif i1 < i2 then
set p13 = Player(PLAYER_NEUTRAL_PASSIVE)
set u4 = CreateUnit(p13,'hrtt',GetUnitX(u1),GetUnitY(u1),GetRandomReal(0,360))
call SetUnitState(u4,life,GetUnitState(u4,maxlife) * RMaxBJ(0,0.01) * 0.01)
if udg_GInteger3 > udg_GInteger4 then
set udg_AvanpostInteger = 3
set p = Player(8)
elseif udg_GInteger3 == udg_GInteger4 then
if GetRandomInt(1,2) == 1 then
set udg_AvanpostInteger = 3
set p = Player(8)
elseif GetRandomInt(1,2) == 2 then
set udg_AvanpostInteger = 4
set p = Player(11)
endif
elseif udg_GInteger3 < udg_GInteger4 then
set udg_AvanpostInteger = 4
set p = Player(11)
endif
set u2 = CreateUnit( p, 'hpea',  GetUnitX(u4),GetUnitY(u4),GetUnitFacing(u4) )
set u4 = null
set p13 = null
set p = null
set u2 = null
endif
call RemoveUnit(u1)
set u1 = null
set cot = null
set cot2 = null
call DestroyBoolExpr(filterkaka14)
set filterkaka14 = null
call GroupClear(g)
call DestroyGroup(g)
set g = null
set u = null
set life = null
set maxlife = null
call PauseTimer(t)
call FlushChildHashtable(udg_Hash,GetHandleId(t))
call DestroyTimer(t)
set t = null
endif
set u = null
set life = null
set maxlife = null
set u1 = null
set t = null
endfunction
function allavanpost takes nothing returns nothing
set udg_GInteger = udg_GInteger + 1
endfunction
function stopsavanpost takes nothing returns nothing
local unit u = null
local code cot = null
local trigger trg = GetTriggeringTrigger()
if GetSpellAbilityId() == 'Ahrp' then
set u = GetSpellAbilityUnit()
if IsUnitInGroup(u,udg_G) == true then
call GroupRemoveUnit(udg_G,u)
endif
set cot = function allavanpost
call ForGroup(udg_G,cot)
if udg_GInteger == 0 then
call GroupClear(udg_G)
call DestroyGroup(udg_G)
set udg_G = null
set udg_G = CreateGroup()
endif
set cot = null
set u = null
endif
call DisableTrigger(trg)
call DestroyTrigger(trg)
set trg = null
endfunction
function Cexeport takes nothing returns nothing
local unit u = GetSpellAbilityUnit()
local unit u1 = GetSpellTargetUnit()
local timer t = null
local code cot = null
local unitstate life = null
local unitstate maxlife = null
local real lifereal2 = 0
local player p2 = Player(2)
local player p5 = Player(5)
local player p8 = Player(8)
local player p11 = Player(11)
local trigger trg = null
local unitevent evenk = null
if GetUnitTypeId(u1) == 'hrtt' and udg_AvanpostInteger != 1 and IsUnitAlly(u,p2) == true or udg_AvanpostInteger != 2 and IsUnitAlly(u,p5) == true or udg_AvanpostInteger != 3 and IsUnitAlly(u,p8) == true or udg_AvanpostInteger != 4 and IsUnitAlly(u,p11) == true then
set life = UNIT_STATE_LIFE
set maxlife = UNIT_STATE_MAX_LIFE
set lifereal2 = GetUnitStatePercent(u1, life, maxlife)
set life = null
set maxlife = null
call GroupAddUnit(udg_G,u)
set trg = CreateTrigger()
set evenk = EVENT_UNIT_SPELL_ENDCAST  
set cot = function stopsavanpost
call TriggerRegisterUnitEvent(trg,u,evenk)
call TriggerAddAction(trg,cot)
set evenk = null
set cot = null
set trg = null
set t = CreateTimer()
set cot = function ivent
call SaveUnitHandle(udg_Hash,GetHandleId(t),1,u1)
call SaveReal(udg_Hash,GetHandleId(t),2,lifereal2)
call SaveUnitHandle(udg_Hash,GetHandleId(t),3,u)
call AddUnitAnimationProperties(u1, "alternate", true)
call SetUnitAnimation(u1,"Stand Ready Alternate")
call TimerStart(t,0.10,true,cot)
set cot = null
set t = null
else
call IssueImmediateOrder(u,"stop")
set life = UNIT_STATE_LIFE
set maxlife = UNIT_STATE_MAX_LIFE
call SetUnitState(u1,life,GetUnitState(u1,maxlife) * RMaxBJ(0,0.01) * 0.01)
set life = null
set maxlife = null
endif
set p2 = null 
set p5 = null 
set p8 = null 
set p11 = null 
set u1 = null
set u = null
endfunction
function Trig_beginsspellchannel_Conditions takes nothing returns boolean
    local string s = GetObjectName(GetSpellAbilityId())
    if SubString(s, 0, 4) == "Cexe" then
        call ExecuteFunc(s)
    endif
    return false
endfunction
//===========================================================================
function InitTrig_beginsspellchannel takes nothing returns nothing
local trigger t = CreateTrigger(  )
local player p = null
local playerunitevent evenk = null
local code cot = function Trig_beginsspellchannel_Conditions
local boolexpr b = Condition( cot )
    local integer i = 0
call TriggerAddCondition( t, b )
    loop 
set p = Player(i)
set evenk = EVENT_PLAYER_UNIT_SPELL_CHANNEL
        call TriggerRegisterPlayerUnitEvent(t, p, evenk, null)
set p = null
set evenk = null
    set i = i + 1
exitwhen i == bj_MAX_PLAYER_SLOTS
    endloop
set cot = null
set b = null
set t = null
endfunction


Views: 142

dondonchakka #1 - 4 months ago (изм. ) 0
Голосов: +0 / -0
есть ли головастики?))
» смотреть сюда
set i1 = IMaxBJ(udg_GInteger1,udg_GInteger2) 
set i2 = IMaxBJ(udg_GInteger3,udg_GInteger4)
if i1 > i2 then
if udg_GInteger1 > udg_GInteger2 then
set p13 = Player(PLAYER_NEUTRAL_PASSIVE)
set u4 = CreateUnit(p13,'hrtt',GetUnitX(u1),GetUnitY(u1),GetRandomReal(0,360))
call SetUnitState(u4,life,GetUnitState(u4,maxlife) * RMaxBJ(0,0.01) * 0.01)
set p = Player(2)
set u2 = CreateUnit( p, 'hpea',  GetUnitX(u4),GetUnitY(u4),GetUnitFacing(u4) )
set u4 = null
set p13 = null
set p = null
set u2 = null
elseif udg_GInteger1 == udg_GInteger2 then
set p13 = Player(PLAYER_NEUTRAL_PASSIVE)
set u4 = CreateUnit(p13,'hrtt',GetUnitX(u1),GetUnitY(u1),GetRandomReal(0,360))
call SetUnitState(u4,life,GetUnitState(u4,maxlife) * RMaxBJ(0,0.01) * 0.01)
if GetRandomInt(1,2) == 1 then
set p = Player(2)
elseif GetRandomInt(1,2) == 2 then
set p = Player(5)
endif
set u2 = CreateUnit( p, 'hpea',  GetUnitX(u4),GetUnitY(u4),GetUnitFacing(u4) )
set u4 = null
set p13 = null
set p = null
set u2 = null
elseif udg_GInteger1 < udg_GInteger2 then
set p13 = Player(PLAYER_NEUTRAL_PASSIVE)
set u4 = CreateUnit(p13,'hrtt',GetUnitX(u1),GetUnitY(u1),GetRandomReal(0,360))
call SetUnitState(u4,life,GetUnitState(u4,maxlife) * RMaxBJ(0,0.01) * 0.01)
set p = Player(5)
set u2 = CreateUnit( p, 'hpea',  GetUnitX(u4),GetUnitY(u4),GetUnitFacing(u4) )
set u4 = null
set p13 = null
set p = null
set u2 = null
endif
elseif i1 == i2 then
//тут самое сложное
elseif i1 < i2 then
if udg_GInteger3 > udg_GInteger4 then
set p13 = Player(PLAYER_NEUTRAL_PASSIVE)
set u4 = CreateUnit(p13,'hrtt',GetUnitX(u1),GetUnitY(u1),GetRandomReal(0,360))
call SetUnitState(u4,life,GetUnitState(u4,maxlife) * RMaxBJ(0,0.01) * 0.01)
set p = Player(8)
set u2 = CreateUnit( p, 'hpea',  GetUnitX(u4),GetUnitY(u4),GetUnitFacing(u4) )
set u4 = null
set p13 = null
set p = null
set u2 = null
elseif udg_GInteger3 == udg_GInteger4 then
set p13 = Player(PLAYER_NEUTRAL_PASSIVE)
set u4 = CreateUnit(p13,'hrtt',GetUnitX(u1),GetUnitY(u1),GetRandomReal(0,360))
call SetUnitState(u4,life,GetUnitState(u4,maxlife) * RMaxBJ(0,0.01) * 0.01)
if GetRandomInt(1,2) == 1 then
set p = Player(8)
elseif GetRandomInt(1,2) == 2 then
set p = Player(11)
endif
set u2 = CreateUnit( p, 'hpea',  GetUnitX(u4),GetUnitY(u4),GetUnitFacing(u4) )
set u4 = null
set p13 = null
set p = null
set u2 = null
elseif udg_GInteger3 < udg_GInteger4 then
set p13 = Player(PLAYER_NEUTRAL_PASSIVE)
set u4 = CreateUnit(p13,'hrtt',GetUnitX(u1),GetUnitY(u1),GetRandomReal(0,360))
call SetUnitState(u4,life,GetUnitState(u4,maxlife) * RMaxBJ(0,0.01) * 0.01)
set p = Player(11)
set u2 = CreateUnit( p, 'hpea',  GetUnitX(u4),GetUnitY(u4),GetUnitFacing(u4) )
set u4 = null
set p13 = null
set p = null
set u2 = null
endif
endif
JableNine #2 - 4 months ago -1
Голосов: +0 / -1
Нужно по сути сравнить 4 раза по 4 числа. Но на деле 12 сравнений, так как сравнивать юнитов одного игрока с ним самим же не нужно.
Прикрепленные файлы
dondonchakka #3 - 4 months ago (изм. ) 0
Голосов: +0 / -0

поправьте если не правильно...
» смотреть сюда
//===========================================================================
// Trigger: beginsspellchannel
//===========================================================================
function destroyunit takes nothing returns nothing
local unit u = GetEnumUnit()
call RemoveUnit(u)
set u = null
endfunction
function unittypedefixportal takes nothing returns boolean
local unit u = GetFilterUnit()
if GetUnitTypeId(u) == 'hpea' then
return true
set u = null
else
return false
set u = null
endif
endfunction
function allavanpost1 takes nothing returns nothing
set udg_GGInteger = udg_GGInteger + 1
endfunction
function schitalochka takes nothing returns nothing
local unit u = GetEnumUnit()
local player p2 = Player(2)
local player p5 = Player(5)
local player p8 = Player(8)
local player p11 = Player(11)
if IsUnitAlly(u,p2) == true then
set udg_GInteger1 = udg_GInteger1 + 1
endif
if IsUnitAlly(u,p5) == true then
set udg_GInteger2 = udg_GInteger2 + 1
endif
if IsUnitAlly(u,p8) == true then
set udg_GInteger3 = udg_GInteger3 + 1
endif
if IsUnitAlly(u,p11) == true then
set udg_GInteger4 = udg_GInteger4 + 1
endif
set u = null
set p2 = null
set p5 = null
set p8 = null
set p11 = null
endfunction
function ivent takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u1 = LoadUnitHandle(udg_Hash,GetHandleId(t),1)
local real lifereal2 = LoadReal(udg_Hash,GetHandleId(t),2)
local unit u = null
local player p = null
local unitstate life = UNIT_STATE_LIFE
local unitstate maxlife = UNIT_STATE_MAX_LIFE
local player p0 = null
local player p6 = null
local player p13 = null
local player p14 = null
local unit u2 = null
local unit u4 = null
local unit u5 = null
local unit u3 = null
local group g = null
local code cot = null
local code cot1 = null
local code cot2 = null
local boolexpr filterkaka14 = null
local item i = null
local timer t1 = null
local integer i1 = 0
local integer i2 = 0
local integer i3 = 0
local integer i4 = 0
if GetUnitStatePercent(u1, life, maxlife) > lifereal2 then
call SaveReal(udg_Hash,GetHandleId(t),2,lifereal2+GetUnitStatePercent(u1, life, maxlife)-lifereal2)
endif
set cot1 = function allavanpost1
set udg_GGInteger = 0
call ForGroup(udg_G,cot1)
if GetUnitStatePercent(u1, life, maxlife) <= lifereal2 or udg_GGInteger == 0 then
call SaveReal(udg_Hash,GetHandleId(t),2,lifereal2+GetUnitStatePercent(u1, life, maxlife)-lifereal2)
call SetUnitState(u1, life, GetUnitState(u1, maxlife) * RMaxBJ(0,0.01) * 0.01)
call AddUnitAnimationProperties(u1, "alternate", false)
call SetUnitAnimation( u1, "stand ready" )
if udg_GGInteger == 0 then
call GroupClear(udg_G)
call DestroyGroup(udg_G)
set udg_G = null
set udg_G = CreateGroup()
endif
set u1 = null
set life = null
set maxlife = null
call PauseTimer(t)
call FlushChildHashtable(udg_Hash,GetHandleId(t))
call DestroyTimer(t)
set t = null
endif
set cot1 = null
if GetUnitStatePercent(u1, life, maxlife) == 100 then
set cot1 = function schitalochka
set udg_GInteger1 = 0
set udg_GInteger2 = 0
set udg_GInteger3 = 0
set udg_GInteger4 = 0
call ForGroup(udg_G,cot1)
set cot1 = null
call GroupClear(udg_G)
call DestroyGroup(udg_G)
set udg_G = null
set udg_G = CreateGroup()
set g = CreateGroup()
set cot =  function destroyunit
set cot2 = function unittypedefixportal
set filterkaka14 = Condition(cot2)
call GroupEnumUnitsInRange(g, GetUnitX(u1),GetUnitY(u1), 99999999999, filterkaka14)
call ForGroup(g,cot)
set i1 = IMaxBJ(udg_GInteger1,udg_GInteger2) 
set i2 = IMaxBJ(udg_GInteger3,udg_GInteger4)
set i3 = IMinBJ(udg_GInteger1,udg_GInteger2) 
set i4 = IMinBJ(udg_GInteger3,udg_GInteger4) 
if i1 > i2 then
set p13 = Player(PLAYER_NEUTRAL_PASSIVE)
set u4 = CreateUnit(p13,'hrtt',GetUnitX(u1),GetUnitY(u1),GetRandomReal(0,360))
call SetUnitState(u4,life,GetUnitState(u4,maxlife) * RMaxBJ(0,0.01) * 0.01)
if udg_GInteger1 > udg_GInteger2 then
set udg_AvanpostInteger = 1
set p = Player(2)
elseif udg_GInteger1 == udg_GInteger2 then
if GetRandomInt(1,2) == 1 then
set udg_AvanpostInteger = 1
set p = Player(2)
elseif GetRandomInt(1,2) == 2 then
set udg_AvanpostInteger = 2
set p = Player(5)
endif
elseif udg_GInteger1 < udg_GInteger2 then
set udg_AvanpostInteger = 2
set p = Player(5)
endif
set u2 = CreateUnit( p, 'hpea',  GetUnitX(u4),GetUnitY(u4),GetUnitFacing(u4) )
set u4 = null
set p13 = null
set p = null
set u2 = null
elseif i1 == i2 then
set p13 = Player(PLAYER_NEUTRAL_PASSIVE)
set u4 = CreateUnit(p13,'hrtt',GetUnitX(u1),GetUnitY(u1),GetRandomReal(0,360))
call SetUnitState(u4,life,GetUnitState(u4,maxlife) * RMaxBJ(0,0.01) * 0.01)
if udg_GInteger1  == udg_GInteger2 and udg_GInteger3 == udg_GInteger4 then
if GetRandomInt(1,4) == 1 then
set udg_AvanpostInteger = 1
set p = Player(2)
elseif GetRandomInt(1,4) == 2 then
set udg_AvanpostInteger = 2
set p = Player(5)
elseif GetRandomInt(1,4) == 3 then
set udg_AvanpostInteger = 3
set p = Player(8)
elseif GetRandomInt(1,4) == 4 then
set udg_AvanpostInteger = 4
set p = Player(11)
endif
elseif udg_GInteger1 == udg_GInteger2 and udg_GInteger3 > udg_GInteger4 then
if GetRandomInt(1,3) == 1 then
set udg_AvanpostInteger = 1
set p = Player(2)
elseif GetRandomInt(1,3) == 2 then
set udg_AvanpostInteger = 2
set p = Player(5)
elseif GetRandomInt(1,3) == 3 then
set udg_AvanpostInteger = 3
set p = Player(8)
endif
elseif udg_GInteger1 == udg_GInteger2 and udg_GInteger3 < udg_GInteger4 then
if GetRandomInt(1,3) == 1 then
set udg_AvanpostInteger = 1
set p = Player(2)
elseif GetRandomInt(1,3) == 2 then
set udg_AvanpostInteger = 2
set p = Player(5)
elseif GetRandomInt(1,3) == 3 then
set udg_AvanpostInteger = 3
set p = Player(11)
endif
elseif udg_GInteger1 > udg_GInteger2 and udg_GInteger3 == udg_GInteger4 then
if GetRandomInt(1,3) == 1 then
set udg_AvanpostInteger = 1
set p = Player(2)
elseif GetRandomInt(1,3) == 2 then
set udg_AvanpostInteger = 2
set p = Player(8)
elseif GetRandomInt(1,3) == 3 then
set udg_AvanpostInteger = 3
set p = Player(11)
endif
elseif udg_GInteger1 < udg_GInteger2 and udg_GInteger3 == udg_GInteger4 then
if GetRandomInt(1,3) == 1 then
set udg_AvanpostInteger = 1
set p = Player(5)
elseif GetRandomInt(1,3) == 2 then
set udg_AvanpostInteger = 2
set p = Player(8)
elseif GetRandomInt(1,3) == 3 then
set udg_AvanpostInteger = 3
set p = Player(11)
endif
elseif udg_GInteger1 > udg_GInteger2 and udg_GInteger3 > udg_GInteger4 then
if GetRandomInt(1,2) == 1 then
set udg_AvanpostInteger = 1
set p = Player(2)
elseif GetRandomInt(1,2) == 2 then
set udg_AvanpostInteger = 2
set p = Player(8)
endif
elseif udg_GInteger1 > udg_GInteger2 and udg_GInteger3 < udg_GInteger4 then
if GetRandomInt(1,2) == 1 then
set udg_AvanpostInteger = 1
set p = Player(2)
elseif GetRandomInt(1,2) == 2 then
set udg_AvanpostInteger = 2
set p = Player(11)
endif
elseif udg_GInteger1 < udg_GInteger2 and udg_GInteger3 < udg_GInteger4 then
if GetRandomInt(1,2) == 1 then
set udg_AvanpostInteger = 1
set p = Player(5)
elseif GetRandomInt(1,2) == 2 then
set udg_AvanpostInteger = 2
set p = Player(11)
endif
elseif udg_GInteger1 < udg_GInteger2 and udg_GInteger3 > udg_GInteger4 then
if GetRandomInt(1,2) == 1 then
set udg_AvanpostInteger = 1
set p = Player(5)
elseif GetRandomInt(1,2) == 2 then
set udg_AvanpostInteger = 2
set p = Player(8)
endif
endif
set u2 = CreateUnit( p, 'hpea',  GetUnitX(u4),GetUnitY(u4),GetUnitFacing(u4) )
set u4 = null
set p13 = null
set p = null
set u2 = null
//òóò ñàìîå ñëîæíîå
elseif i1 < i2 then
set p13 = Player(PLAYER_NEUTRAL_PASSIVE)
set u4 = CreateUnit(p13,'hrtt',GetUnitX(u1),GetUnitY(u1),GetRandomReal(0,360))
call SetUnitState(u4,life,GetUnitState(u4,maxlife) * RMaxBJ(0,0.01) * 0.01)
if udg_GInteger3 > udg_GInteger4 then
set udg_AvanpostInteger = 3
set p = Player(8)
elseif udg_GInteger3 == udg_GInteger4 then
if GetRandomInt(1,2) == 1 then
set udg_AvanpostInteger = 3
set p = Player(8)
elseif GetRandomInt(1,2) == 2 then
set udg_AvanpostInteger = 4
set p = Player(11)
endif
elseif udg_GInteger3 < udg_GInteger4 then
set udg_AvanpostInteger = 4
set p = Player(11)
endif
set u2 = CreateUnit( p, 'hpea',  GetUnitX(u4),GetUnitY(u4),GetUnitFacing(u4) )
set u4 = null
set p13 = null
set p = null
set u2 = null
endif
call RemoveUnit(u1)
set u1 = null
set cot = null
set cot2 = null
call DestroyBoolExpr(filterkaka14)
set filterkaka14 = null
call GroupClear(g)
call DestroyGroup(g)
set g = null
set u = null
set life = null
set maxlife = null
call PauseTimer(t)
call FlushChildHashtable(udg_Hash,GetHandleId(t))
call DestroyTimer(t)
set t = null
endif
set u = null
set life = null
set maxlife = null
set u1 = null
set t = null
endfunction
function allavanpost takes nothing returns nothing
set udg_GInteger = udg_GInteger + 1
endfunction
function stopsavanpost takes nothing returns nothing
local unit u = null
local code cot = null
local trigger trg = GetTriggeringTrigger()
if GetSpellAbilityId() == 'Ahrp' then
set u = GetSpellAbilityUnit()
if IsUnitInGroup(u,udg_G) == true then
call GroupRemoveUnit(udg_G,u)
endif
set cot = function allavanpost
call ForGroup(udg_G,cot)
if udg_GInteger == 0 then
call GroupClear(udg_G)
call DestroyGroup(udg_G)
set udg_G = null
set udg_G = CreateGroup()
endif
set cot = null
set u = null
endif
call DisableTrigger(trg)
call DestroyTrigger(trg)
set trg = null
endfunction
function Cexeport takes nothing returns nothing
local unit u = GetSpellAbilityUnit()
local unit u1 = GetSpellTargetUnit()
local timer t = null
local code cot = null
local unitstate life = null
local unitstate maxlife = null
local real lifereal2 = 0
local player p2 = Player(2)
local player p5 = Player(5)
local player p8 = Player(8)
local player p11 = Player(11)
local trigger trg = null
local unitevent evenk = null
if GetUnitTypeId(u1) == 'hrtt' and udg_AvanpostInteger != 1 and IsUnitAlly(u,p2) == true or udg_AvanpostInteger != 2 and IsUnitAlly(u,p5) == true or udg_AvanpostInteger != 3 and IsUnitAlly(u,p8) == true or udg_AvanpostInteger != 4 and IsUnitAlly(u,p11) == true then
set life = UNIT_STATE_LIFE
set maxlife = UNIT_STATE_MAX_LIFE
set lifereal2 = GetUnitStatePercent(u1, life, maxlife)
set life = null
set maxlife = null
call GroupAddUnit(udg_G,u)
set trg = CreateTrigger()
set evenk = EVENT_UNIT_SPELL_ENDCAST  
set cot = function stopsavanpost
call TriggerRegisterUnitEvent(trg,u,evenk)
call TriggerAddAction(trg,cot)
set evenk = null
set cot = null
set trg = null
set t = CreateTimer()
set cot = function ivent
call SaveUnitHandle(udg_Hash,GetHandleId(t),1,u1)
call SaveReal(udg_Hash,GetHandleId(t),2,lifereal2)
call SaveUnitHandle(udg_Hash,GetHandleId(t),3,u)
call AddUnitAnimationProperties(u1, "alternate", true)
call SetUnitAnimation(u1,"Stand Ready Alternate")
call TimerStart(t,0.10,true,cot)
set cot = null
set t = null
else
call IssueImmediateOrder(u,"stop")
set life = UNIT_STATE_LIFE
set maxlife = UNIT_STATE_MAX_LIFE
call SetUnitState(u1,life,GetUnitState(u1,maxlife) * RMaxBJ(0,0.01) * 0.01)
set life = null
set maxlife = null
endif
set p2 = null 
set p5 = null 
set p8 = null 
set p11 = null 
set u1 = null
set u = null
endfunction
function Trig_beginsspellchannel_Conditions takes nothing returns boolean
    local string s = GetObjectName(GetSpellAbilityId())
    if SubString(s, 0, 4) == "Cexe" then
        call ExecuteFunc(s)
    endif
    return false
endfunction
//===========================================================================
function InitTrig_beginsspellchannel takes nothing returns nothing
local trigger t = CreateTrigger(  )
local player p = null
local playerunitevent evenk = null
local code cot = function Trig_beginsspellchannel_Conditions
local boolexpr b = Condition( cot )
    local integer i = 0
call TriggerAddCondition( t, b )
    loop 
set p = Player(i)
set evenk = EVENT_PLAYER_UNIT_SPELL_CHANNEL
        call TriggerRegisterPlayerUnitEvent(t, p, evenk, null)
set p = null
set evenk = null
    set i = i + 1
exitwhen i == bj_MAX_PLAYER_SLOTS
    endloop
set cot = null
set b = null
set t = null
endfunction