diff --git a/Blizzard.eai b/Blizzard.eai index 80a37cc50..43090bbd1 100644 --- a/Blizzard.eai +++ b/Blizzard.eai @@ -91,7 +91,7 @@ trigger ZoomSetx = null trigger AdjustZoomUp = null trigger AdjustZoomDown = null - real current_zoom = 1650 + real array current_zoom dialog game_start_dialog = null trigger game_start_trigger = null @@ -563,56 +563,58 @@ endfunction //=========================================================================== function ZoomSet takes nothing returns nothing local real Zoom = 0 + if SubStringBJ(GetEventPlayerChatString(), 6, 6) != " " then + set Zoom = S2R(SubStringBJ(GetEventPlayerChatString(), 6, 10)) + else + set Zoom = S2R(SubStringBJ(GetEventPlayerChatString(), 7, 11)) + endif if (GetTriggerPlayer() == GetLocalPlayer()) then - if SubStringBJ(GetEventPlayerChatString(), 6, 6) != " " then - set Zoom = S2R(SubStringBJ(GetEventPlayerChatString(), 6, 10)) - else - set Zoom = S2R(SubStringBJ(GetEventPlayerChatString(), 7, 11)) - endif - if Zoom < 1650 then call SetCameraFieldForPlayer( GetTriggerPlayer(), CAMERA_FIELD_TARGET_DISTANCE, 1650, 0 ) call DisplayTimedTextToPlayer(GetTriggerPlayer(), 0, 0, 7, "zoom min:|cff00ff001650|r" ) - set current_zoom = 1650 elseif Zoom > 3000 then call SetCameraFieldForPlayer( GetTriggerPlayer(), CAMERA_FIELD_TARGET_DISTANCE, 3000, 0 ) call DisplayTimedTextToPlayer(GetTriggerPlayer(), 0, 0, 7, "zoom max:|cff00ff003000|r" ) - set current_zoom = 3000 else call SetCameraFieldForPlayer( GetTriggerPlayer(), CAMERA_FIELD_TARGET_DISTANCE, Zoom, 0 ) - set current_zoom = Zoom endif endif + // Fix desync, variables must be same across players + if Zoom < 1650 then + set current_zoom[GetPlayerId(GetTriggerPlayer())] = 1650 + elseif Zoom > 3000 then + set current_zoom[GetPlayerId(GetTriggerPlayer())] = 3000 + else + set current_zoom[GetPlayerId(GetTriggerPlayer())] = Zoom + endif endfunction function ZoomDown takes nothing returns nothing - if current_zoom > 1650 and GetTriggerPlayer() == GetLocalPlayer() then - call SetCameraFieldForPlayer(GetTriggerPlayer(), CAMERA_FIELD_TARGET_DISTANCE, ( current_zoom - 50 ), 0 ) - set current_zoom = current_zoom - 50 + if current_zoom[GetPlayerId(GetTriggerPlayer())] > 1650 then + if GetTriggerPlayer() == GetLocalPlayer() then + call SetCameraFieldForPlayer(GetTriggerPlayer(), CAMERA_FIELD_TARGET_DISTANCE, ( current_zoom[GetPlayerId(GetTriggerPlayer())] - 50 ), 0 ) + endif + set current_zoom[GetPlayerId(GetTriggerPlayer())] = current_zoom[GetPlayerId(GetTriggerPlayer())] - 50 endif endfunction function ZoomUp takes nothing returns nothing - if current_zoom < 3000 and GetTriggerPlayer() == GetLocalPlayer() then - call SetCameraFieldForPlayer(GetTriggerPlayer(), CAMERA_FIELD_TARGET_DISTANCE, ( current_zoom + 50 ), 0 ) - set current_zoom = current_zoom + 50 + if current_zoom[GetPlayerId(GetTriggerPlayer())] < 3000 then + if GetTriggerPlayer() == GetLocalPlayer() then + call SetCameraFieldForPlayer(GetTriggerPlayer(), CAMERA_FIELD_TARGET_DISTANCE, ( current_zoom[GetPlayerId(GetTriggerPlayer())] + 50 ), 0 ) + endif + set current_zoom[GetPlayerId(GetTriggerPlayer())] = current_zoom[GetPlayerId(GetTriggerPlayer())] + 50 endif endfunction function InitZoom takes nothing returns nothing local integer i = 0 - local camerasetup theCam = null set ZoomSetx = CreateTrigger() set AdjustZoomUp = CreateTrigger() set AdjustZoomDown = CreateTrigger() call TriggerAddAction(ZoomSetx, function ZoomSet) call TriggerAddAction(AdjustZoomUp , function ZoomUp) call TriggerAddAction(AdjustZoomDown , function ZoomDown) - if (legacyCamera) then - set theCam = GetCurrentCameraSetup() - set current_zoom = CameraSetupGetFieldSwap(CAMERA_FIELD_TARGET_DISTANCE, theCam) - set theCam = null - endif loop exitwhen i >= GetBJMaxPlayers() if (GetPlayerController(Player(i)) != MAP_CONTROL_COMPUTER) then @@ -621,9 +623,10 @@ function InitZoom takes nothing returns nothing if (legacyCamera) then // Only required for legacy versions as no camera support built into the game call TriggerRegisterPlayerKeyEventBJ( AdjustZoomUp, Player(i), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_UP ) call TriggerRegisterPlayerKeyEventBJ( AdjustZoomDown, Player(i), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_DOWN ) + set current_zoom[i] = 1650 // Default expected in legacy systems if IsPlayerObserver(Player(i)) then call SetCameraFieldForPlayer(Player(i), CAMERA_FIELD_TARGET_DISTANCE, 1950, 0) - set current_zoom = 1950 + set current_zoom[i] = 1950 endif endif endif diff --git a/Jobs/CHAT_QUEUE.eai b/Jobs/CHAT_QUEUE.eai index 79ad6c067..a39ad1702 100644 --- a/Jobs/CHAT_QUEUE.eai +++ b/Jobs/CHAT_QUEUE.eai @@ -18,7 +18,9 @@ function FireChat takes nothing returns nothing elseif lockplayer == GetAiPlayer() then set i_locked_chat = true if chat_strategy != null then - call DisplayToPlayer(chat_strategy, GetLocalPlayer(), true) + if IsPlayerAlly(ai_player,GetLocalPlayer()) or IsPlayerObserver(GetLocalPlayer()) then + call DisplayToPlayer(chat_strategy, GetLocalPlayer(), true) + endif set chat_strategy = null else call DisplayToPlayer(chat_queue[0] , chat_queue_player[0], chat_queue_importance[0]) diff --git a/common.eai b/common.eai index 1d499b410..dd478ba7d 100644 --- a/common.eai +++ b/common.eai @@ -3091,23 +3091,21 @@ endfunction //============================================================================ function QueueChat takes string text, player p, boolean important returns nothing local integer i = 0 - if (p == GetLocalPlayer()) then - set chat_queue_size = chat_queue_size + 1 - set chat_queue[chat_queue_size] = text - set chat_queue_player[chat_queue_size] = p - set chat_queue_importance[chat_queue_size] = important - if (chat_queue_size > 5) then - // Remove oldest message - set i = 0 - loop - exitwhen i >= chat_queue_size - set chat_queue[i] = chat_queue[i+1] - set chat_queue_player[i] = chat_queue_player[i+1] - set chat_queue_importance[i] = chat_queue_importance[i+1] - set i = i + 1 - endloop - set chat_queue_size = chat_queue_size - 1 - endif + set chat_queue_size = chat_queue_size + 1 + set chat_queue[chat_queue_size] = text + set chat_queue_player[chat_queue_size] = p + set chat_queue_importance[chat_queue_size] = important + if (chat_queue_size > (5 * c_ai_total)) then + // Remove oldest message + set i = 0 + loop + exitwhen i >= chat_queue_size + set chat_queue[i] = chat_queue[i+1] + set chat_queue_player[i] = chat_queue_player[i+1] + set chat_queue_importance[i] = chat_queue_importance[i+1] + set i = i + 1 + endloop + set chat_queue_size = chat_queue_size - 1 endif endfunction @@ -3132,7 +3130,7 @@ function DisplayChat takes integer chat, boolean ally, boolean enemy, boolean ob set rand = GetRandomInt(0, chat_list_length - 1) endloop call SetChatVarsPlayer(p) - // Only send at most 8 greetings to a single player + // Only send a limited number of greetings to a single player if chat == C_Greet then if (HaveStoredInteger(amaiCache, Int2Str(GREETINGS_NUM), Int2Str(i))) then set chat_greet_count = GetStoredInteger(amaiCache, Int2Str(GREETINGS_NUM), Int2Str(i)) @@ -3167,9 +3165,9 @@ function Chat takes integer c returns nothing endif if c == C_STRATEGY then - if IsPlayerAlly(ai_player,GetLocalPlayer()) or IsPlayerObserver(GetLocalPlayer()) and chatting then + if chatting then call QueueStrategy(GetCurrentStrategyReport() + GetCurrentDynamicReport()) - endif + endif //call DisplayToAlliesImportant( GetCurrentStrategyReport() + GetCurrentDynamicReport() ) //call DisplayToObserversImportant( GetCurrentStrategyReport() + GetCurrentDynamicReport() ) else diff --git a/races.eai b/races.eai index ce33f2f05..2fc3ac931 100644 --- a/races.eai +++ b/races.eai @@ -820,7 +820,7 @@ function build_sequence_all takes nothing returns nothing if reportStrategy then set reportStrategy = false - if (IsPlayerObserver(GetLocalPlayer()) or IsPlayerAlly(GetLocalPlayer(), ai_player)) and chatting then + if chatting then call QueueStrategy(GetCurrentStrategyReport() + GetCurrentDynamicReport()) endif //call DisplayToAlliesImportant( GetCurrentStrategyReport() + GetCurrentDynamicReport())