Добавлен , опубликован
Алгоритмы, Наработки и Способности
Способ реализации:
vJass
Тип:
Наработка
Версия Warcraft:
1.26a+
Данная библиотека предназначена для быстрой синхронизации данных между игроками. Передача происходит через вызовы локального события клика по юниту.
Установка
Для установки скопируйте папку UnitSync, скопируйте dummy из РО, убедитесь что равкод dummy совпадает со значением UNIT_ID в триггере USync. Пользуйтесь. В карте также есть два примера периодической синхронизации данных, передача integer и real.
Передача integer
function event_kill_count takes nothing returns nothing
    local integer data = USync.integer
    local integer player_id = USync.player_id
    call BJDebugMsg("sync kill_count"+I2S(data))
    call BJDebugMsg("sync player_id"+R2S(player_id))
endfunction

function send_my_value takes nothing returns nothing
	if GetLocalPlayer() == Player(0) then
 	   call USync.send("kill_count", 37)
	endif
endfunction

function trigger_init takes nothing returns nothing
    call USync.register_integer("kill_count", 0, 1000, true, function event_kill_count)
endfunction
В данном примере мы сначала регистрируем сообщение с помощью USync.register_integer() куда передаем callback - функцию, которая будет вызвана после получения данных.
Передача real
function event_damage_multiplier takes nothing returns nothing
    local real data = USync.real
    call BJDebugMsg("sync damage_multiplier"+R2S(data))
endfunction

function send_my_value takes nothing returns nothing
	if GetLocalPlayer() == Player(0) then
 	   call USync.send("damage_multiplier", 15.)
	endif
endfunction

function trigger_init takes nothing returns nothing
    call USync.register_real("damage_multiplier", -50, 50, 0.1, true, function event_damage_multiplier)
endfunction
Числа типа real всегда приходят с погрешностью потому что мы не передаем все 32 бита. В данном примере 0.1 это максимально допустимая погрешность. Например если вы отправите 15.0, то ожидайте, что прийти может число от 14.9 до 15.1
Передача координат
function send_position takes nothing returns nothing
    local real x = GetCameraTargetPositionX()
    local real y = GetCameraTargetPositionY()
    
    if GetLocalPlayer() == Player(0) then
        call USync.send_coordinate("unit_position", x, y)
    endif
endfunction

function event_get_position takes nothing returns nothing
    local real x = USync.x
    local real y = USync.y
    call SetUnitX(UNIT, x)
    call SetUnitY(UNIT, y)
    call send_position()
endfunction

function trigger_init takes nothing returns nothing
    call USync.register_coordinate("unit_position", 1, true, function event_get_position )
endfunction
Функция USync.register_coordinate() предназначена для регистрации событий отправки данных тип которых это координаты плоскости игровой карты. В примере мы синхронизируем координаты камеры локального игрока и перемещаем туда юнита.
Описание функций
register_real() - зарегистрировать сообщение. Возвращает количество кликов, которые необходимы для отправки данных.
 method register_real takes string name, real min, real max, real maximum_error, boolean buffering, code callback returns integer
name - название, используется для создания/отправки сообщения. Повторная регистрация выведет сообщение об ошибке.
min - минимально возможное передаваемое значение. Передача значения меньше min выдаст сообщение об ошибке.
max - максимально возможное передаваемое значение. Передача значения больше max выдаст сообщение об ошибке.
maximum_error - максимально возможная погрешность при передачи. Обычно принимает значения [1, 0.1, 0.01]. Передача больших диапазонов значений с большой точностью может быть затруднительно.
buffering - буферизация событий, по-умолчанию true, более подробно ниже.
callback - функция которая будет вызвана после синхронизации данных.

register_integer() - зарегистрировать сообщение. Возвращает количество кликов, которые необходимы для отправки данных.
method register_integer takes string name, integer min, integer max, boolean buffering, code callback returns integer
name - название, используется для создания/отправки сообщения. Повторная регистрация выведет сообщение об ошибке.
min - минимально возможное передаваемое значение. Передача значения меньше min выдаст сообщение об ошибке.
max - максимально возможное передаваемое значение. Передача значения больше max выдаст сообщение об ошибке.
buffering - буферизация событий, по-умолчанию true, более подробно ниже.
callback - функция которая будет вызвана после синхронизации данных.
PS Значение maximum_error выставляется автоматически, для integer == 1.

register_coordinate() - зарегистрировать сообщение. Возвращает количество кликов, которые необходимы для отправки данных.
method register_coordinate takes string name, real maximum_error, boolean buffering, code callback returns integer
name - название, используется для создания/отправки сообщения. Повторная регистрация выведет сообщение об ошибке.
maximum_error - максимально возможная погрешность при передачи. Обычно принимает значения [1, 0.1]
buffering - буферизация событий, по-умолчанию true, более подробно ниже.
callback - функция которая будет вызвана после синхронизации данных.
PS Значения min и max автоматически устанавливаются равными границам карты.

send() - отправить данные по сохраненному сообщению. Возвращает логическое значение успеха.
method send takes string name, real value returns boolean
name - название сообщения, которое было указано при регистрации.
value - само передаваемое значение, полезная нагрузка.

send_coordinate() - отправить данные по сохраненному сообщению. Возвращает логическое значение успеха.
method send_coordinate takes string name, real x, real y returns boolean
name - название сообщения, которое было указано при регистрации.
x - значение по оси x.
y - значение по оси y.

Buffering
Для того чтобы понять как работает буферизация рассмотрим следующий код
function test_buffering takes boolean buffering returns nothing
    call USync.register_integer("data", 0, 10, buffering , function event_callback)
    if GetLocalPlayer() == Player(0) then
        call USync.send("data", 1)
	    call USync.send("data", 2)
	    call USync.send("data", 3)
	    call USync.send("data", 4)
	    call USync.send("data", 5)
    endif
endfunction
Если buffering == true, то через время будет вызвано пять событий с данными 1, 2, 3, 4, 5
Если buffering == false, то через время будет вызвано два события со значениями 1, 5 поскольку попытки отправить и 2 и 3 и 4 и 5 были в тот момент времени, когда 1 еще не синхронизировалось, а после синхронизации было отправлено последнее востребованное обновление.
Где это нужно? Например если вы решите слать сообщения быстрее, чем они будут доходить - каждые 0.15с - то сообщения будут скапливаться в очередь, которая будет бесконечно расти, и из за этого время от момента отправки события до момента его синхронизации тоже начнет бесконечно расти. Возможно вы синхронизируете координату мыши или около того, и вам важно как можно быстрее получить как можно более актуальные данные, и совершенно без разницы в каких координатах находилась мышь до этого. Один из способов разрешить проблему накапливания очереди событий получения данных это установить buffering == false. В таком случае все новые попытки отправить данные будут лишь обновлять "следующую отправку", которая произойдет только после того как последние отправленные данные синхронизируются.
Второй способ избавится от накапливания очереди событий получения данных это не создавать такие очереди. Вы можете обновлять данные не только с помощью периодического таймера, а, например, отправлять данные только после получения предыдущих. В этом случае вы будете поддерживать максимально возможную скорость передачи данных.
`
ОЖИДАНИЕ РЕКЛАМЫ...
2 комментария удалено
28
для структур есть метод onInit, чтоб не запускать отдельной функцией

Загруженные файлы
18
Обновление
  • Исправлен баг который не давал пользоваться библиотекой из за кликов по обычным юнитам, спасибо rsfghd
  • Оптимизация, уменьшено количество вызовов триггеров
15
код из Sync.w3x
globals
//globals from LibUSync:
constant boolean LIBRARY_LibUSync=true
constant integer LibUSync___MAX_MESSAGE_LEN= 3
constant integer LibUSync___POINT_COUNT= 25
constant real LibUSync___MAX_MESSAGE_POWER= Pow(LibUSync___POINT_COUNT, LibUSync___MAX_MESSAGE_LEN) - 1
    
constant integer LibUSync___UNIT_COUNT= LibUSync___POINT_COUNT
constant integer LibUSync___UNIT_ID= 'h000'
constant player LibUSync___UNIT_PLAYER= Player(PLAYER_NEUTRAL_PASSIVE)
    // if the value is 0.12345, the unit will automatically be moved to the edge of the map
real LibUSync___UNIT_X= 0.12345
real LibUSync___UNIT_Y= 0.12345
    
unit array LibUSync___UNITS
real array LibUSync___POWERS
constant hashtable LibUSync___IS_UNIT= InitHashtable()
//endglobals from LibUSync
    // Generated
trigger gg_trg_USync= null
trigger gg_trg_CameraSync= null
trigger gg_trg_CameraSync1= null
trigger gg_trg_DataSync= null
trigger gg_trg_Init= null
unit gg_unit_hpea_0001= null
unit gg_unit_opeo_0002= null
real real_data= - 50
integer int_data= - 100

trigger l__library_init

//JASSHelper struct globals:
constant integer si__LibUSync___PendingData=1
integer si__LibUSync___PendingData_F=0
integer si__LibUSync___PendingData_I=0
integer array si__LibUSync___PendingData_V
real array s__LibUSync___PendingData_value
real array s__LibUSync___PendingData_x
real array s__LibUSync___PendingData_y
constant integer si__LibUSync___BasicMetadata=2
integer si__LibUSync___BasicMetadata_F=0
integer si__LibUSync___BasicMetadata_I=0
integer array si__LibUSync___BasicMetadata_V
real array s__LibUSync___BasicMetadata_min
real array s__LibUSync___BasicMetadata_max
real array s__LibUSync___BasicMetadata_dist
boolean array s__LibUSync___BasicMetadata_is_int
integer array s__LibUSync___BasicMetadata_message_len
constant integer si__LibUSync___CoordinateMetadata=3
integer si__LibUSync___CoordinateMetadata_F=0
integer si__LibUSync___CoordinateMetadata_I=0
integer array si__LibUSync___CoordinateMetadata_V
integer array s__LibUSync___CoordinateMetadata_message_len_x
integer array s__LibUSync___CoordinateMetadata_message_len_y
integer array s__LibUSync___CoordinateMetadata_message_len
real s__LibUSync___CoordinateMetadata_min_x
real s__LibUSync___CoordinateMetadata_max_x
real s__LibUSync___CoordinateMetadata_dist_x
real s__LibUSync___CoordinateMetadata_min_y
real s__LibUSync___CoordinateMetadata_max_y
real s__LibUSync___CoordinateMetadata_dist_y
constant integer si__LibUSync___MessageType=4
integer si__LibUSync___MessageType_F=0
integer si__LibUSync___MessageType_I=0
integer array si__LibUSync___MessageType_V
integer s__LibUSync___MessageType_BASIC= 1
integer s__LibUSync___MessageType_COORDINATE= 2
constant integer si__LibUSync___Message=5
integer si__LibUSync___Message_F=0
integer si__LibUSync___Message_I=0
integer array si__LibUSync___Message_V
string array s__LibUSync___Message_name
integer array s__LibUSync___Message_point_id
integer array s__LibUSync___Message_meta_type
integer array s__LibUSync___Message_metadata
integer array s__LibUSync___Message_len
trigger array s__LibUSync___Message_trigger
boolean array s__LibUSync___Message_buffering
boolean array s__LibUSync___Message_is_reached
boolean array s__LibUSync___Message_need_update
integer array s__LibUSync___Message_pending_data
hashtable s__LibUSync___Message_NAME_TO_MESSAGE= InitHashtable()
hashtable s__LibUSync___Message_POINT_TO_MESSAGE= InitHashtable()
constant integer si__LibUSync___Registrar=6
integer si__LibUSync___Registrar_F=0
integer si__LibUSync___Registrar_I=0
integer array si__LibUSync___Registrar_V
integer s__LibUSync___Registrar_point_id= - 1
boolean s__LibUSync___Registrar_register_is_over= false
constant integer si__LibUSync___EventData=7
integer si__LibUSync___EventData_F=0
integer si__LibUSync___EventData_I=0
integer array si__LibUSync___EventData_V
integer s__LibUSync___EventData_player_id
integer array s__LibUSync___EventData_unit_count
constant integer si__USync=9
integer si__USync_F=0
integer si__USync_I=0
integer array si__USync_V
boolean array s__USync_is_start
integer array s__USync_current_data_len
integer array s__USync_need_data_len
integer array s___USync_data
constant integer s___USync_data_size=3
integer array s__USync_data
integer array s__USync_message
integer array s__USync_metadata
integer array s__USync_meta_type
integer s__USync_player_id
real s__USync_real
integer s__USync_integer
real s__USync_x
real s__USync_y
real s__USync_int_error= 0.499
real s__USync_min
real s__USync_dist
boolean s__USync_is_int
constant integer si__LibUSync___EventTrigger=11
integer si__LibUSync___EventTrigger_F=0
integer si__LibUSync___EventTrigger_I=0
integer array si__LibUSync___EventTrigger_V
boolean s__LibUSync___EventTrigger_is_select_start= false
integer s__LibUSync___EventTrigger_player_id
integer s__LibUSync___EventTrigger_player_count
integer array s__LibUSync___EventTrigger_players
timer s__LibUSync___EventTrigger_selection_timer= CreateTimer()
unit array s__s__LibUSync___EventData_units

endglobals


//Generated allocator of LibUSync___PendingData
function s__LibUSync___PendingData__allocate takes nothing returns integer
 local integer this=si__LibUSync___PendingData_F
    if (this!=0) then
        set si__LibUSync___PendingData_F=si__LibUSync___PendingData_V[this]
    else
        set si__LibUSync___PendingData_I=si__LibUSync___PendingData_I+1
        set this=si__LibUSync___PendingData_I
    endif
    if (this>8190) then
        return 0
    endif

    set si__LibUSync___PendingData_V[this]=-1
 return this
endfunction

//Generated destructor of LibUSync___PendingData
function s__LibUSync___PendingData_deallocate takes integer this returns nothing
    if this==null then
        return
    elseif (si__LibUSync___PendingData_V[this]!=-1) then
        return
    endif
    set si__LibUSync___PendingData_V[this]=si__LibUSync___PendingData_F
    set si__LibUSync___PendingData_F=this
endfunction

//Generated allocator of LibUSync___EventTrigger
function s__LibUSync___EventTrigger__allocate takes nothing returns integer
 local integer this=si__LibUSync___EventTrigger_F
    if (this!=0) then
        set si__LibUSync___EventTrigger_F=si__LibUSync___EventTrigger_V[this]
    else
        set si__LibUSync___EventTrigger_I=si__LibUSync___EventTrigger_I+1
        set this=si__LibUSync___EventTrigger_I
    endif
    if (this>8190) then
        return 0
    endif

    set si__LibUSync___EventTrigger_V[this]=-1
 return this
endfunction

//Generated destructor of LibUSync___EventTrigger
function s__LibUSync___EventTrigger_deallocate takes integer this returns nothing
    if this==null then
        return
    elseif (si__LibUSync___EventTrigger_V[this]!=-1) then
        return
    endif
    set si__LibUSync___EventTrigger_V[this]=si__LibUSync___EventTrigger_F
    set si__LibUSync___EventTrigger_F=this
endfunction

//Generated allocator of USync
function s__USync__allocate takes nothing returns integer
 local integer this=si__USync_F
    if (this!=0) then
        set si__USync_F=si__USync_V[this]
    else
        set si__USync_I=si__USync_I+1
        set this=si__USync_I
    endif
    if (this>2729) then
        return 0
    endif
    set s__USync_data[this]=(this-1)*3
    set si__USync_V[this]=-1
 return this
endfunction

//Generated destructor of USync
function s__USync_deallocate takes integer this returns nothing
    if this==null then
        return
    elseif (si__USync_V[this]!=-1) then
        return
    endif
    set si__USync_V[this]=si__USync_F
    set si__USync_F=this
endfunction

//Generated allocator of LibUSync___EventData
function s__LibUSync___EventData__allocate takes nothing returns integer
 local integer this=si__LibUSync___EventData_F
    if (this!=0) then
        set si__LibUSync___EventData_F=si__LibUSync___EventData_V[this]
    else
        set si__LibUSync___EventData_I=si__LibUSync___EventData_I+1
        set this=si__LibUSync___EventData_I
    endif
    if (this>8190) then
        return 0
    endif

    set si__LibUSync___EventData_V[this]=-1
 return this
endfunction

//Generated destructor of LibUSync___EventData
function s__LibUSync___EventData_deallocate takes integer this returns nothing
    if this==null then
        return
    elseif (si__LibUSync___EventData_V[this]!=-1) then
        return
    endif
    set si__LibUSync___EventData_V[this]=si__LibUSync___EventData_F
    set si__LibUSync___EventData_F=this
endfunction

//Generated allocator of LibUSync___Registrar
function s__LibUSync___Registrar__allocate takes nothing returns integer
 local integer this=si__LibUSync___Registrar_F
    if (this!=0) then
        set si__LibUSync___Registrar_F=si__LibUSync___Registrar_V[this]
    else
        set si__LibUSync___Registrar_I=si__LibUSync___Registrar_I+1
        set this=si__LibUSync___Registrar_I
    endif
    if (this>8190) then
        return 0
    endif

    set si__LibUSync___Registrar_V[this]=-1
 return this
endfunction

//Generated destructor of LibUSync___Registrar
function s__LibUSync___Registrar_deallocate takes integer this returns nothing
    if this==null then
        return
    elseif (si__LibUSync___Registrar_V[this]!=-1) then
        return
    endif
    set si__LibUSync___Registrar_V[this]=si__LibUSync___Registrar_F
    set si__LibUSync___Registrar_F=this
endfunction

//Generated allocator of LibUSync___Message
function s__LibUSync___Message__allocate takes nothing returns integer
 local integer this=si__LibUSync___Message_F
    if (this!=0) then
        set si__LibUSync___Message_F=si__LibUSync___Message_V[this]
    else
        set si__LibUSync___Message_I=si__LibUSync___Message_I+1
        set this=si__LibUSync___Message_I
    endif
    if (this>8190) then
        return 0
    endif

    set si__LibUSync___Message_V[this]=-1
 return this
endfunction

//Generated destructor of LibUSync___Message
function s__LibUSync___Message_deallocate takes integer this returns nothing
    if this==null then
        return
    elseif (si__LibUSync___Message_V[this]!=-1) then
        return
    endif
    set si__LibUSync___Message_V[this]=si__LibUSync___Message_F
    set si__LibUSync___Message_F=this
endfunction

//Generated allocator of LibUSync___MessageType
function s__LibUSync___MessageType__allocate takes nothing returns integer
 local integer this=si__LibUSync___MessageType_F
    if (this!=0) then
        set si__LibUSync___MessageType_F=si__LibUSync___MessageType_V[this]
    else
        set si__LibUSync___MessageType_I=si__LibUSync___MessageType_I+1
        set this=si__LibUSync___MessageType_I
    endif
    if (this>8190) then
        return 0
    endif

    set si__LibUSync___MessageType_V[this]=-1
 return this
endfunction

//Generated destructor of LibUSync___MessageType
function s__LibUSync___MessageType_deallocate takes integer this returns nothing
    if this==null then
        return
    elseif (si__LibUSync___MessageType_V[this]!=-1) then
        return
    endif
    set si__LibUSync___MessageType_V[this]=si__LibUSync___MessageType_F
    set si__LibUSync___MessageType_F=this
endfunction

//Generated allocator of LibUSync___CoordinateMetadata
function s__LibUSync___CoordinateMetadata__allocate takes nothing returns integer
 local integer this=si__LibUSync___CoordinateMetadata_F
    if (this!=0) then
        set si__LibUSync___CoordinateMetadata_F=si__LibUSync___CoordinateMetadata_V[this]
    else
        set si__LibUSync___CoordinateMetadata_I=si__LibUSync___CoordinateMetadata_I+1
        set this=si__LibUSync___CoordinateMetadata_I
    endif
    if (this>8190) then
        return 0
    endif

    set si__LibUSync___CoordinateMetadata_V[this]=-1
 return this
endfunction

//Generated destructor of LibUSync___CoordinateMetadata
function s__LibUSync___CoordinateMetadata_deallocate takes integer this returns nothing
    if this==null then
        return
    elseif (si__LibUSync___CoordinateMetadata_V[this]!=-1) then
        return
    endif
    set si__LibUSync___CoordinateMetadata_V[this]=si__LibUSync___CoordinateMetadata_F
    set si__LibUSync___CoordinateMetadata_F=this
endfunction

//Generated allocator of LibUSync___BasicMetadata
function s__LibUSync___BasicMetadata__allocate takes nothing returns integer
 local integer this=si__LibUSync___BasicMetadata_F
    if (this!=0) then
        set si__LibUSync___BasicMetadata_F=si__LibUSync___BasicMetadata_V[this]
    else
        set si__LibUSync___BasicMetadata_I=si__LibUSync___BasicMetadata_I+1
        set this=si__LibUSync___BasicMetadata_I
    endif
    if (this>8190) then
        return 0
    endif

    set si__LibUSync___BasicMetadata_V[this]=-1
 return this
endfunction

//Generated destructor of LibUSync___BasicMetadata
function s__LibUSync___BasicMetadata_deallocate takes integer this returns nothing
    if this==null then
        return
    elseif (si__LibUSync___BasicMetadata_V[this]!=-1) then
        return
    endif
    set si__LibUSync___BasicMetadata_V[this]=si__LibUSync___BasicMetadata_F
    set si__LibUSync___BasicMetadata_F=this
endfunction

//library LibUSync:


function LibUSync___get_message_len takes real dist,real maximum_error,string name returns integer
    local real need_count= dist / maximum_error
    local integer message_len= 1

    if need_count > LibUSync___MAX_MESSAGE_POWER then
        call BJDebugMsg("USyncWarring: it is impossible to meet the required accuracy when registering '" + name + "'")
        call BJDebugMsg("Increase MAX_MESSAGE_LEN or decrease dist or increase accuracy_error")
        return LibUSync___MAX_MESSAGE_LEN
    endif

    loop
    exitwhen message_len >= LibUSync___MAX_MESSAGE_LEN
        if LibUSync___POWERS[message_len] - 1 >= need_count then
            exitwhen true
        endif
    set message_len=message_len + 1
    endloop
    
    return message_len
endfunction


function LibUSync___round takes real val returns integer
    if val - R2I(val) < R2I(val + 1.) - val then
        return R2I(val)
    else
        return R2I(val) + 1
    endif
endfunction


function LibUSync___select_unit takes integer ind returns nothing
    call SelectUnit(LibUSync___UNITS[ind], true)
    call SelectUnit(LibUSync___UNITS[ind], false)
endfunction


function LibUSync___is_unit takes unit u returns boolean
    return HaveSavedBoolean(LibUSync___IS_UNIT, 0, GetHandleId(u))
endfunction







    function s__LibUSync___BasicMetadata_create takes real min,real max,real maximum_error,boolean is_int,string name returns integer
        local integer this= s__LibUSync___BasicMetadata__allocate()
        if is_int then
            set maximum_error=1.
        endif
        set s__LibUSync___BasicMetadata_min[this]=min
        set s__LibUSync___BasicMetadata_max[this]=max
        set s__LibUSync___BasicMetadata_dist[this]=max - min
        set s__LibUSync___BasicMetadata_is_int[this]=is_int
        set s__LibUSync___BasicMetadata_message_len[this]=LibUSync___get_message_len(s__LibUSync___BasicMetadata_dist[this] , maximum_error , name)
        return this
    endfunction






    function s__LibUSync___CoordinateMetadata_create takes real maximum_error,string name returns integer
        local integer this= s__LibUSync___CoordinateMetadata__allocate()
        set s__LibUSync___CoordinateMetadata_message_len_x[this]=LibUSync___get_message_len(s__LibUSync___CoordinateMetadata_dist_x , maximum_error , name)
        set s__LibUSync___CoordinateMetadata_message_len_y[this]=LibUSync___get_message_len(s__LibUSync___CoordinateMetadata_dist_y , maximum_error , name)
        set s__LibUSync___CoordinateMetadata_message_len[this]=s__LibUSync___CoordinateMetadata_message_len_x[this] + s__LibUSync___CoordinateMetadata_message_len_y[this]
        return this
    endfunction


    function s__LibUSync___CoordinateMetadata_init takes nothing returns nothing
        local rect world_rect= GetWorldBounds()
        set s__LibUSync___CoordinateMetadata_min_x=GetRectMinX(world_rect)
        set s__LibUSync___CoordinateMetadata_max_x=GetRectMaxX(world_rect)
        set s__LibUSync___CoordinateMetadata_dist_x=s__LibUSync___CoordinateMetadata_max_x - s__LibUSync___CoordinateMetadata_min_x
        set s__LibUSync___CoordinateMetadata_min_y=GetRectMinY(world_rect)
        set s__LibUSync___CoordinateMetadata_max_y=GetRectMaxY(world_rect)
        set s__LibUSync___CoordinateMetadata_dist_y=s__LibUSync___CoordinateMetadata_max_y - s__LibUSync___CoordinateMetadata_min_y
        set world_rect=null
    endfunction




    



    function s__LibUSync___Message_load_from_name takes string name returns integer
         return LoadInteger(s__LibUSync___Message_NAME_TO_MESSAGE, 0, StringHash(name))
    endfunction
    
    
    function s__LibUSync___Message_load_from_point takes integer point_id returns integer
        local integer mess= LoadInteger(s__LibUSync___Message_POINT_TO_MESSAGE, 0, point_id)
        return mess
    endfunction


    function s__LibUSync___Message_is_valid takes integer this returns boolean
        return this != 0
    endfunction

    function s__LibUSync___Message_save takes string name,integer point_id,integer message returns nothing
        call SaveInteger(s__LibUSync___Message_NAME_TO_MESSAGE, 0, StringHash(name), message)
        call SaveInteger(s__LibUSync___Message_POINT_TO_MESSAGE, 0, point_id, message)
    endfunction
    

    function s__LibUSync___Message_can_save takes string name returns boolean
        if s__LibUSync___Message_load_from_name(name) != 0 then
            call BJDebugMsg("USyncWarring: name '" + name + "' is already taken")
            return false
        endif
        return true
    endfunction


    function s__LibUSync___Message_create takes string name,integer point_id,integer mess_type,integer metadata,boolean buffering,code callback returns integer
        local integer this= s__LibUSync___Message__allocate()
        set s__LibUSync___Message_name[this]=name
        set s__LibUSync___Message_point_id[this]=point_id
        set s__LibUSync___Message_meta_type[this]=mess_type
        set s__LibUSync___Message_metadata[this]=metadata
        set s__LibUSync___Message_buffering[this]=buffering
        set s__LibUSync___Message_trigger[this]=CreateTrigger()
        call TriggerAddCondition(s__LibUSync___Message_trigger[this], Filter(callback))
        if not buffering then
            set s__LibUSync___Message_is_reached[this]=true
            set s__LibUSync___Message_pending_data[this]=s__LibUSync___PendingData__allocate()
        endif

        if mess_type == s__LibUSync___MessageType_BASIC then
            set s__LibUSync___Message_len[this]=s__LibUSync___BasicMetadata_message_len[(metadata)]
        elseif mess_type == s__LibUSync___MessageType_COORDINATE then
            set s__LibUSync___Message_len[this]=s__LibUSync___CoordinateMetadata_message_len[(metadata)]
        else
            call BJDebugMsg("USyncError: unknown metadata type " + I2S(mess_type))
            return 0
        endif
        
        if not s__LibUSync___Message_can_save(name) then
            return 0
        endif

        call s__LibUSync___Message_save(name , point_id , this)
        return this
    endfunction




    function s__LibUSync___Registrar_can_register takes string name,integer point_id returns boolean
        if s__LibUSync___Registrar_register_is_over or point_id >= LibUSync___POINT_COUNT then
            call BJDebugMsg("USyncError: too many registered events")
            call BJDebugMsg("Unable to register '" + name + "'")
            return false
        endif
        if not s__LibUSync___Message_can_save(name) then
            return false
        endif
        return true
    endfunction


    function s__LibUSync___Registrar_lenght_message takes integer message returns integer
        if not s__LibUSync___Message_is_valid(message) then
            return 0
        endif
        return s__LibUSync___Message_len[message]
    endfunction


    function s__LibUSync___Registrar_basic_register takes string name,real min,real max,real maximum_error,boolean is_int,boolean buffering,code callback returns integer
        local integer metadata
        local integer message

        if not s__LibUSync___Registrar_can_register(name , s__LibUSync___Registrar_point_id + 1) then
            return 0
        endif

        set s__LibUSync___Registrar_point_id=s__LibUSync___Registrar_point_id + 1

        set metadata=s__LibUSync___BasicMetadata_create(min , max , maximum_error , is_int , name)
        set message=s__LibUSync___Message_create(name , s__LibUSync___Registrar_point_id , s__LibUSync___MessageType_BASIC , metadata , buffering , callback)
        return s__LibUSync___Registrar_lenght_message(message)
    endfunction


    function s__LibUSync___Registrar_coordinate_register takes string name,real maximum_error,boolean buffering,code callback returns integer
        local integer metadata
        local integer message
        
        if not s__LibUSync___Registrar_can_register(name , s__LibUSync___Registrar_point_id + 1) then
            return 0
        endif
        
        set s__LibUSync___Registrar_point_id=s__LibUSync___Registrar_point_id + 1
        
        set metadata=s__LibUSync___CoordinateMetadata_create(maximum_error , name)
        set message=s__LibUSync___Message_create(name , s__LibUSync___Registrar_point_id , s__LibUSync___MessageType_COORDINATE , metadata , buffering , callback)
        return s__LibUSync___Registrar_lenght_message(message)
    endfunction




    
    // public data



    function s__USync_register_real takes string name,real min,real max,real maximum_error,boolean buffering,code callback returns integer
        return s__LibUSync___Registrar_basic_register(name , min , max , maximum_error , false , buffering , callback)
    endfunction


    function s__USync_register_integer takes string name,integer min,integer max,boolean buffering,code callback returns integer
        return s__LibUSync___Registrar_basic_register(name , min , max , 1. , true , buffering , callback)
    endfunction
    
    
    function s__USync_register_coordinate takes string name,real maximum_error,boolean buffering,code callback returns integer
        return s__LibUSync___Registrar_coordinate_register(name , maximum_error , buffering , callback)
    endfunction


    function s__USync_send_header takes integer point_id returns nothing
        call LibUSync___select_unit(point_id)
    endfunction


    function s__USync_send_data takes real val,integer message_len,real min,real dist returns integer
        local integer num
        local integer i= message_len - 1
        local integer kt

        // (0. - 1.) * (POINT_COUNT**message_len-1)
        set num=LibUSync___round(( ( val - min ) / dist ) * ( LibUSync___POWERS[message_len] - 1 ))
        loop
        exitwhen i < 0
            set kt=R2I(num / LibUSync___POWERS[i]) // 0 - POINT_COUNT-1
            set num=num - kt * R2I(LibUSync___POWERS[i])
            call LibUSync___select_unit(kt)
        set i=i - 1
        endloop
        return message_len
    endfunction


    function s__USync_can_send takes integer message,integer metadata,real val returns boolean
        if message == 0 then
            call BJDebugMsg("USyncWarring: Error send '" + s__LibUSync___Message_name[message] + "'")
            return false
        endif
        if val < s__LibUSync___BasicMetadata_min[metadata] or val > s__LibUSync___BasicMetadata_max[metadata] then
            call BJDebugMsg("USyncWarring: Sending an incorrect value " + R2S(val) + " to '" + s__LibUSync___Message_name[message] + "'")
            return false
        endif
        return true
    endfunction


    function s__USync_can_send_coordinate takes integer message,real x,real y returns boolean
        if message == 0 then
            call BJDebugMsg("USyncWarring: Error send '" + s__LibUSync___Message_name[message] + "'")
            return false
        endif
        if x < s__LibUSync___CoordinateMetadata_min_x or x > s__LibUSync___CoordinateMetadata_max_x then
            call BJDebugMsg("USyncWarring: Sending an incorrect x " + R2S(x) + " to '" + s__LibUSync___Message_name[message] + "'")
            return false
        endif
        if y < s__LibUSync___CoordinateMetadata_min_y or y > s__LibUSync___CoordinateMetadata_max_y then
            call BJDebugMsg("USyncWarring: Sending an incorrect y " + R2S(y) + " to '" + s__LibUSync___Message_name[message] + "'")
            return false
        endif
        return true
    endfunction


    function s__USync_send takes string name,real val returns boolean
        local integer message= s__LibUSync___Message_load_from_name(name)
        local integer metadata= (s__LibUSync___Message_metadata[message])

        if not s__USync_can_send(message , metadata , val) then
            return false
        endif

        if not s__LibUSync___Message_buffering[message] then
            if s__LibUSync___Message_is_reached[message] then
                set s__LibUSync___Message_is_reached[message]=false
            else
                set s__LibUSync___Message_need_update[message]=true
                set s__LibUSync___PendingData_value[s__LibUSync___Message_pending_data[message]]=val
                return true
            endif
        endif

        call s__USync_send_header(s__LibUSync___Message_point_id[message])
        call s__USync_send_data(val , s__LibUSync___Message_len[message] , s__LibUSync___BasicMetadata_min[metadata] , s__LibUSync___BasicMetadata_dist[metadata])
        return true
    endfunction


    function s__USync_send_coordinate takes string name,real x,real y returns boolean
        local integer message= s__LibUSync___Message_load_from_name(name)
        local integer metadata= (s__LibUSync___Message_metadata[message])

        if not s__USync_can_send_coordinate(message , x , y) then
            return false
        endif

        if not s__LibUSync___Message_buffering[message] then
            if s__LibUSync___Message_is_reached[message] then
                set s__LibUSync___Message_is_reached[message]=false
            else
                set s__LibUSync___Message_need_update[message]=true
                set s__LibUSync___PendingData_x[s__LibUSync___Message_pending_data[message]]=x
                set s__LibUSync___PendingData_y[s__LibUSync___Message_pending_data[message]]=y
                return true
            endif
        endif
        call s__USync_send_header(s__LibUSync___Message_point_id[message])
        call s__USync_send_data(x , s__LibUSync___CoordinateMetadata_message_len_x[metadata] , s__LibUSync___CoordinateMetadata_min_x , s__LibUSync___CoordinateMetadata_dist_x)
        call s__USync_send_data(y , s__LibUSync___CoordinateMetadata_message_len_y[metadata] , s__LibUSync___CoordinateMetadata_min_y , s__LibUSync___CoordinateMetadata_dist_y)
        return true
    endfunction


    function s__USync_start_collection takes integer this,integer point_id returns nothing
        local integer message= s__LibUSync___Message_load_from_point(point_id)
        if not s__LibUSync___Message_is_valid(message) then
            call BJDebugMsg("USyncError: received data error " + I2S(message))
            return
        endif
        set s__USync_message[this]=message
        set s__USync_metadata[this]=s__LibUSync___Message_metadata[message]
        set s__USync_meta_type[this]=s__LibUSync___Message_meta_type[message]
        set s__USync_current_data_len[this]=0
        set s__USync_need_data_len[this]=s__LibUSync___Message_len[message]
        set s__USync_is_start[this]=true
    endfunction


    function s__USync_build_number takes integer this,integer start,integer data_len returns real
        local integer end= start + data_len
        local integer num= 0
        local real result

        loop
        exitwhen start >= end
            set num=num * LibUSync___POINT_COUNT + s___USync_data[s__USync_data[this]+start]
        set start=start + 1
        endloop

        set result=s__USync_dist * ( num / ( LibUSync___POWERS[data_len] - 1 ) )

        if s__USync_is_int then
            set result=LibUSync___round(result)
        endif

        return s__USync_min + result
    endfunction


    function s__USync_build_and_update_data takes integer this returns nothing
        local integer message= s__USync_message[this]
        local integer message_len_x

        set s__LibUSync___Message_is_reached[message]=true

        if s__USync_meta_type[this] == s__LibUSync___MessageType_BASIC then
            set s__USync_min=s__LibUSync___BasicMetadata_min[(s__USync_metadata[this])]
            set s__USync_dist=s__LibUSync___BasicMetadata_dist[(s__USync_metadata[this])]
            set s__USync_is_int=s__LibUSync___BasicMetadata_is_int[(s__USync_metadata[this])]
            set s__USync_real=s__USync_build_number(this,0 , s__USync_need_data_len[this])

            if s__USync_is_int then
                set s__USync_integer=R2I(s__USync_real)
            endif

            if s__LibUSync___Message_need_update[message] then
                set s__LibUSync___Message_need_update[message]=false
                call s__USync_send(s__LibUSync___Message_name[message] , s__LibUSync___PendingData_value[s__LibUSync___Message_pending_data[message]])
            endif

        elseif s__USync_meta_type[this] == s__LibUSync___MessageType_COORDINATE then
            set message_len_x=s__LibUSync___CoordinateMetadata_message_len_x[(s__USync_metadata[this])]
            set s__USync_min=s__LibUSync___CoordinateMetadata_min_x
            set s__USync_dist=s__LibUSync___CoordinateMetadata_dist_x
            set s__USync_is_int=false
            set s__USync_x=s__USync_build_number(this,0 , message_len_x)

            set s__USync_min=s__LibUSync___CoordinateMetadata_min_y
            set s__USync_dist=s__LibUSync___CoordinateMetadata_dist_y
            set s__USync_y=s__USync_build_number(this,message_len_x , s__LibUSync___CoordinateMetadata_message_len_y[(s__USync_metadata[this])])

            if s__LibUSync___Message_need_update[message] then
                set s__LibUSync___Message_need_update[message]=false
                call s__USync_send_coordinate(s__LibUSync___Message_name[message] , s__LibUSync___PendingData_x[s__LibUSync___Message_pending_data[message]] , s__LibUSync___PendingData_y[s__LibUSync___Message_pending_data[message]])
            endif
        endif
    endfunction


   function s__USync_push takes integer this,integer num returns nothing
        if not s__USync_is_start[this] then
            call s__USync_start_collection(this,num)
            return
        endif
        set s___USync_data[s__USync_data[this]+s__USync_current_data_len[this]]=num
        set s__USync_current_data_len[this]=s__USync_current_data_len[this] + 1

        if s__USync_current_data_len[this] >= s__USync_need_data_len[this] then
            call s__USync_build_and_update_data(this)
            set s__USync_is_start[this]=false
            call TriggerEvaluate(s__LibUSync___Message_trigger[s__USync_message[this]])
        endif
   endfunction


    function s__USync_event_select takes nothing returns boolean
        local integer pid= s__LibUSync___EventData_player_id
        local integer event_count= s__LibUSync___EventData_unit_count[pid]
        local integer uplayer= (pid + 1)
        local integer i= 0
        set s__USync_player_id=pid
        loop
        exitwhen i >= event_count
            call s__USync_push(uplayer,GetUnitUserData(s__s__LibUSync___EventData_units[(pid)*(100)+i]))
        set i=i + 1
        endloop

        return false
    endfunction





    function s__LibUSync___EventTrigger_select_with_timer takes nothing returns nothing
        local integer i= 0
        set s__LibUSync___EventTrigger_is_select_start=false
        loop
        exitwhen i >= s__LibUSync___EventTrigger_player_count
            set s__LibUSync___EventData_player_id=s__LibUSync___EventTrigger_players[i]
            call s__USync_event_select()
        set i=i + 1
        endloop
    endfunction


    function s__LibUSync___EventTrigger_add_player takes integer pid returns nothing
        local integer i= 0
        loop
        exitwhen i >= s__LibUSync___EventTrigger_player_count
            if s__LibUSync___EventTrigger_players[i] == pid then
                return
            endif
        set i=i + 1
        endloop
        set s__LibUSync___EventTrigger_players[s__LibUSync___EventTrigger_player_count]=pid
        set s__LibUSync___EventTrigger_player_count=s__LibUSync___EventTrigger_player_count + 1

        set s__LibUSync___EventTrigger_player_id=pid
        set s__LibUSync___EventData_unit_count[pid]=0
    endfunction


    function s__LibUSync___EventTrigger_trigger_select takes nothing returns boolean
        local integer pid= GetPlayerId(GetTriggerPlayer())
        if not LibUSync___is_unit(GetTriggerUnit()) then
            return false
        endif
        if not s__LibUSync___EventTrigger_is_select_start then

            set s__LibUSync___EventTrigger_is_select_start=true

            set s__LibUSync___EventTrigger_players[0]=pid
            set s__LibUSync___EventTrigger_player_count=1

            set s__LibUSync___EventTrigger_player_id=pid
            set s__LibUSync___EventData_unit_count[pid]=0

            call TimerStart(s__LibUSync___EventTrigger_selection_timer, 0., false, function s__LibUSync___EventTrigger_select_with_timer)
        endif
        
        if s__LibUSync___EventTrigger_player_id != pid then
            call s__LibUSync___EventTrigger_add_player(pid)
        endif

        set s__s__LibUSync___EventData_units[(pid)*(100)+s__LibUSync___EventData_unit_count[pid]]= GetTriggerUnit()
        set s__LibUSync___EventData_unit_count[pid]=s__LibUSync___EventData_unit_count[pid] + 1
        return false
    endfunction


    function s__LibUSync___EventTrigger_init takes nothing returns nothing
        local trigger trig= CreateTrigger()
        local integer i= bj_MAX_PLAYERS
        loop
        exitwhen i < 0
            call TriggerRegisterPlayerUnitEvent(trig, Player(i), EVENT_PLAYER_UNIT_SELECTED, null)
        set i=i - 1
        endloop
        call TriggerAddCondition(trig, Condition(function s__LibUSync___EventTrigger_trigger_select))
        set trig=null
    endfunction


function LibUSync___initialization_unit takes nothing returns nothing
    local integer i= 0
    if LibUSync___UNITS[i] != null then
        return
    endif
    if LibUSync___UNIT_X == 0.12345 then
        set LibUSync___UNIT_X=s__LibUSync___CoordinateMetadata_min_x
    endif
    if LibUSync___UNIT_Y == 0.12345 then
        set LibUSync___UNIT_Y=s__LibUSync___CoordinateMetadata_min_y
    endif

    loop
    exitwhen i >= LibUSync___UNIT_COUNT
        set LibUSync___UNITS[i]=CreateUnit(LibUSync___UNIT_PLAYER, LibUSync___UNIT_ID, LibUSync___UNIT_X, LibUSync___UNIT_Y, 0.)
        call SetUnitUserData(LibUSync___UNITS[i], i)
        call SaveBoolean(LibUSync___IS_UNIT, 0, GetHandleId(LibUSync___UNITS[i]), true)
    set i=i + 1
    endloop
endfunction


function LibUSync___initialization_powers takes nothing returns nothing
    local integer i= 0
    
    loop
    exitwhen i > LibUSync___MAX_MESSAGE_LEN
        set LibUSync___POWERS[i]=Pow(LibUSync___POINT_COUNT, i)
    set i=i + 1
    endloop
endfunction


function LibUSync___initialization takes nothing returns nothing
    call s__LibUSync___EventTrigger_init()
    call s__LibUSync___CoordinateMetadata_init()
    call LibUSync___initialization_unit()
    call LibUSync___initialization_powers()
endfunction

//library LibUSync ends
//===========================================================================
// 
// Sync
// 
//   Warcraft III map script
//   Generated by the Warcraft III World Editor
//   Date: Sat Feb 04 16:16:15 2023
//   Map Author: Vlod
// 
//===========================================================================

//***************************************************************************
//*
//*  Global Variables
//*
//***************************************************************************


function InitGlobals takes nothing returns nothing
endfunction

//***************************************************************************
//*
//*  Unit Creation
//*
//***************************************************************************

//===========================================================================
function CreateUnitsForPlayer0 takes nothing returns nothing
    local player p= Player(0)
    local unit u
    local integer unitID
    local trigger t
    local real life

    set gg_unit_hpea_0001=CreateUnit(p, 'hpea', - 78.7, 125.3, 325.799)
endfunction

//===========================================================================
function CreateUnitsForPlayer1 takes nothing returns nothing
    local player p= Player(1)
    local unit u
    local integer unitID
    local trigger t
    local real life

    set gg_unit_opeo_0002=CreateUnit(p, 'opeo', - 71.7, 211.5, 251.441)
endfunction

//===========================================================================
function CreatePlayerBuildings takes nothing returns nothing
endfunction

//===========================================================================
function CreatePlayerUnits takes nothing returns nothing
    call CreateUnitsForPlayer0()
    call CreateUnitsForPlayer1()
endfunction

//===========================================================================
function CreateAllUnits takes nothing returns nothing
    call CreatePlayerBuildings()
    call CreatePlayerUnits()
endfunction

//***************************************************************************
//*
//*  Triggers
//*
//***************************************************************************

//===========================================================================
// Trigger: USync
//===========================================================================




//===========================================================================
// Trigger: CameraSync
//===========================================================================


function sync_xy takes nothing returns nothing
    local real x= GetCameraTargetPositionX()
    local real y= GetCameraTargetPositionY()
    
    if GetLocalPlayer() == Player(0) then
        call s__USync_send_coordinate("camera 0" , x , y)
    endif
endfunction


function event_camera_pl_0 takes nothing returns nothing
    local real x= s__USync_x
    local real y= s__USync_y
    call SetUnitX(gg_unit_hpea_0001, x)
    call SetUnitY(gg_unit_hpea_0001, y)
    call sync_xy()
endfunction


function Trig_CameraSync_Actions takes nothing returns nothing
    call s__USync_register_coordinate("camera 0" , 1 , true , function event_camera_pl_0)
    call sync_xy()
endfunction

//===========================================================================
function InitTrig_CameraSync takes nothing returns nothing
    set gg_trg_CameraSync=CreateTrigger()
    call TriggerAddAction(gg_trg_CameraSync, function Trig_CameraSync_Actions)
endfunction

//===========================================================================
// Trigger: CameraSync1
//===========================================================================


function event_camera_1 takes nothing returns nothing
    local real x= s__USync_x
    local real y= s__USync_y
    call SetUnitX(gg_unit_opeo_0002, x)
    call SetUnitY(gg_unit_opeo_0002, y)
endfunction


function timer_sync takes nothing returns nothing
    local real x= GetCameraTargetPositionX()
    local real y= GetCameraTargetPositionY()
    
    if GetLocalPlayer() == Player(1) then
        call s__USync_send_coordinate("camera 1" , x , y)
    endif
endfunction


function Trig_CameraSync1_Actions takes nothing returns nothing
    call s__USync_register_coordinate("camera 1" , 1 , false , function event_camera_1)
    call TimerStart(CreateTimer(), 0.15, true, function timer_sync)
endfunction

//===========================================================================
function InitTrig_CameraSync1 takes nothing returns nothing
    set gg_trg_CameraSync1=CreateTrigger()
    call TriggerAddAction(gg_trg_CameraSync1, function Trig_CameraSync1_Actions)
endfunction

//===========================================================================
// Trigger: DataSync
//===========================================================================


function event_real takes nothing returns nothing
    local real data= s__USync_real
    call BJDebugMsg("sync real_data " + R2S(data))
    call BJDebugMsg("sync player_id " + I2S(s__USync_player_id))
    call BJDebugMsg("--------------")
endfunction


function event_int takes nothing returns nothing
    local integer data= s__USync_integer
    call BJDebugMsg("sync int_data " + I2S(data))
    call BJDebugMsg("sync player_id " + I2S(s__USync_player_id))
    call BJDebugMsg("--------------")
endfunction


function timer_send_data takes nothing returns nothing
    local integer rand= GetRandomInt(0, 1)
    if GetLocalPlayer() == Player(0) then
        if rand == 0 then
            call BJDebugMsg("real_data " + R2S(real_data))

            call s__USync_send("data real" , real_data)
            set real_data=real_data + 0.5

        else
            call BJDebugMsg("int_data " + I2S(int_data))

            call s__USync_send("data int" , int_data)
            set int_data=int_data + 1
        endif
    endif
endfunction



function Trig_DataSync_Actions takes nothing returns nothing
    call s__USync_register_real("data real" , - 50 , 50 , 0.5 , true , function event_real)
    call s__USync_register_integer("data int" , - 100 , 100 , true , function event_int)
    call TimerStart(CreateTimer(), 3, true, function timer_send_data)
endfunction

//===========================================================================
function InitTrig_DataSync takes nothing returns nothing
    set gg_trg_DataSync=CreateTrigger()
    call TriggerAddAction(gg_trg_DataSync, function Trig_DataSync_Actions)
endfunction

//===========================================================================
// Trigger: Init
//===========================================================================
function Trig_Init_Actions takes nothing returns nothing
    call CreateFogModifierRectBJ(true, Player(0), FOG_OF_WAR_VISIBLE, GetPlayableMapRect())
endfunction

//===========================================================================
function InitTrig_Init takes nothing returns nothing
    set gg_trg_Init=CreateTrigger()
    call TriggerAddAction(gg_trg_Init, function Trig_Init_Actions)
endfunction

//===========================================================================
function InitCustomTriggers takes nothing returns nothing
    //Function not found: call InitTrig_USync()
    call InitTrig_CameraSync()
    call InitTrig_CameraSync1()
    call InitTrig_DataSync()
    call InitTrig_Init()
endfunction

//===========================================================================
function RunInitializationTriggers takes nothing returns nothing
    call ConditionalTriggerExecute(gg_trg_CameraSync)
    call ConditionalTriggerExecute(gg_trg_CameraSync1)
    call ConditionalTriggerExecute(gg_trg_DataSync)
    call ConditionalTriggerExecute(gg_trg_Init)
endfunction

//***************************************************************************
//*
//*  Players
//*
//***************************************************************************

function InitCustomPlayerSlots takes nothing returns nothing

    // Player 0
    call SetPlayerStartLocation(Player(0), 0)
    call SetPlayerColor(Player(0), ConvertPlayerColor(0))
    call SetPlayerRacePreference(Player(0), RACE_PREF_HUMAN)
    call SetPlayerRaceSelectable(Player(0), true)
    call SetPlayerController(Player(0), MAP_CONTROL_USER)

    // Player 1
    call SetPlayerStartLocation(Player(1), 1)
    call SetPlayerColor(Player(1), ConvertPlayerColor(1))
    call SetPlayerRacePreference(Player(1), RACE_PREF_ORC)
    call SetPlayerRaceSelectable(Player(1), true)
    call SetPlayerController(Player(1), MAP_CONTROL_USER)

endfunction

function InitCustomTeams takes nothing returns nothing
    // Force: TRIGSTR_005
    call SetPlayerTeam(Player(0), 0)
    call SetPlayerTeam(Player(1), 0)

endfunction

function InitAllyPriorities takes nothing returns nothing

    call SetStartLocPrioCount(0, 1)
    call SetStartLocPrio(0, 0, 1, MAP_LOC_PRIO_HIGH)

    call SetStartLocPrioCount(1, 1)
    call SetStartLocPrio(1, 0, 0, MAP_LOC_PRIO_HIGH)
endfunction

//***************************************************************************
//*
//*  Main Initialization
//*
//***************************************************************************

//===========================================================================
function main takes nothing returns nothing
    call SetCameraBounds(- 1280.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), - 1536.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM), 1280.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), 1024.0 - GetCameraMargin(CAMERA_MARGIN_TOP), - 1280.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), 1024.0 - GetCameraMargin(CAMERA_MARGIN_TOP), 1280.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), - 1536.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM))
    call SetDayNightModels("Environment\\DNC\\DNCLordaeron\\DNCLordaeronTerrain\\DNCLordaeronTerrain.mdl", "Environment\\DNC\\DNCLordaeron\\DNCLordaeronUnit\\DNCLordaeronUnit.mdl")
    call NewSoundEnvironment("Default")
    call SetAmbientDaySound("LordaeronSummerDay")
    call SetAmbientNightSound("LordaeronSummerNight")
    call SetMapMusic("Music", true, 0)
    call CreateAllUnits()
    call InitBlizzard()

call ExecuteFunc("jasshelper__initstructs168507546")
call ExecuteFunc("LibUSync___initialization")

    call InitGlobals()
    call InitCustomTriggers()
    call RunInitializationTriggers()

endfunction

//***************************************************************************
//*
//*  Map Configuration
//*
//***************************************************************************

function config takes nothing returns nothing
    call SetMapName("TRIGSTR_002")
    call SetMapDescription("")
    call SetPlayers(2)
    call SetTeams(2)
    call SetGamePlacement(MAP_PLACEMENT_TEAMS_TOGETHER)

    call DefineStartLocation(0, 0.0, 0.0)
    call DefineStartLocation(1, 0.0, 0.0)

    // Player setup
    call InitCustomPlayerSlots()
    call SetPlayerSlotAvailable(Player(0), MAP_CONTROL_USER)
    call SetPlayerSlotAvailable(Player(1), MAP_CONTROL_USER)
    call InitGenericPlayerSlots()
    call InitAllyPriorities()
endfunction




//Struct method generated initializers/callers:

//Functions for BigArrays:

function jasshelper__initstructs168507546 takes nothing returns nothing












endfunction

Чтобы оставить комментарий, пожалуйста, войдите на сайт.