• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

desync (or something like that)

Status
Not open for further replies.
Level 5
Joined
Sep 19, 2006
Messages
152
I've been testing this map for a little while now, and I've noticed that my friend usually gets disconnected right around 10-15 seconds after the game begins. As close as I can tell, this trigger might be somehow involved:

JASS:
function Every15Seconds_EnumAction01 takes nothing returns nothing
    local item i                 = GetEnumItem ()
//
    if GetItemUserData (i) == 200 then
        call SetItemInvulnerable (i, true)
    else
        call SetWidgetLife (i, (GetWidgetLife (i) - 10.00))
    endif
    set i = null
endfunction

function Every15Seconds_Action02 takes nothing returns nothing
    local timer t                = GetExpiredTimer ()
    local integer tJ             = GetHandleId (t)
    local hashtable tH           = udg_MasterHash
    local unit merc_unit         = LoadUnitHandle (tH, tJ, 0)
    local integer n              = LoadInteger (tH, tJ, 1)
//
    if n == 11 then
        call PauseTimer (t)
        call DestroyTimer (t)
        call FlushChildHashtable (tH, tJ)
    elseif (n / 2) * 2 == n then
        call SetUnitVertexColor (merc_unit, 255, 255, 255, 255)
        set n = n + 1
        call SaveInteger (tH, tJ, 1, n)
    else
        call SetUnitVertexColor (merc_unit, 255, 0, 0, 255)
        set n = n + 1
        call SaveInteger (tH, tJ, 1, n)
    endif
    set merc_unit = null
    set t = null
    set tH = null
endfunction

function Every15Seconds_Action01 takes nothing returns nothing
    local rect r                = GetEntireMapRect()
    local integer q             = 1
    local integer n
    local integer n_2297        = bj_randDistID [2297]
    local integer n_2298        = bj_randDistID [2298]
    local integer n_1180
    local unit hero_unit
    local real hero_unitX
    local real hero_unitY
    local integer hero_unitD
    local integer hero_unitZ
    local unit merc_unit
    local integer x
    local timer t
    local integer tJ
    local hashtable tH
//
    call EnumItemsInRect (r, null, function Every15Seconds_EnumAction01)
    set r = null
    loop
        exitwhen q > 11
        set hero_unit = bj_ghoul [q + 1000]
        set hero_unitD = GetUnitUserData (hero_unit)
        if n_2297 == q then
            if bj_randDistID [q + 1180] == 1 and bj_randDistID [q + 1160] == 0 then
                set hero_unitX = GetUnitX (hero_unit)
                set hero_unitY = GetUnitY (hero_unit)
                set merc_unit = CreateUnit (Player (q), 'nlv1', hero_unitX, hero_unitY, 0.00)
                call UnitApplyTimedLife (merc_unit, 'BTLF', 30.00)
                set merc_unit = null
            endif
        endif
        set n_1180 = bj_randDistID [q + 1180]
        if bj_randDistID [q + 1300] > 140000 and n_1180 == 1 then
            call PingMinimapEx (GetUnitX (hero_unit), GetUnitY (hero_unit), 5.00, 0, 255, 0, false)
        endif
        if bj_randDistID [q + 2800] == 1 then
            if bj_randDistID [q + 920] == 1 then
                call IssueTargetOrder (hero_unit, "smart", gg_unit_nmra_0393)
            endif
        else
            if GetRandomInt (1, 6) == 6 and bj_randDistID [q + 1620] > 0 and n_1180 == 1 then
                set hero_unitZ = 0
                loop
                    exitwhen hero_unitZ > 5
                    if GetItemTypeId (UnitItemInSlot (hero_unit, hero_unitZ)) == 'tst2' then //  Gump's Footwear
                        call UnitRemoveItemFromSlot (hero_unit, hero_unitZ)
                        set hero_unitZ = 6
                    else
                        set hero_unitZ = hero_unitZ + 1
                    endif
                endloop
            endif
            set n = bj_randDistID [q + 980]
            if n > 0 then
                set x = GetPlayerState (Player (q), PLAYER_STATE_RESOURCE_GOLD) - n
                if x > -1 then
                    call SetPlayerState (Player (q), PLAYER_STATE_RESOURCE_GOLD, x)
                else
                    set n = bj_randDistID [q + 1040] - 1
                    set bj_randDistID [q + 1040] = n
                    if n == 0 then
                        set bj_randDistID [q + 980] = -3
                        set merc_unit = bj_ghoul [q + 1020]
                        call AddUnitToStock (gg_unit_ntav_0199, GetUnitTypeId (merc_unit), 0, 1)
                        call RemoveUnit (merc_unit)
                        set merc_unit = null
                        set bj_ghoul [q + 1020] = null
                        set udg_UnitTypeHired [q] = 0
                        call DisplayTimedTextToPlayer (Player (q), 0.0, 0.0, 1.50, "                                           |cffffcc00Your mercenary has abandoned you.|r")
                    else
                        set merc_unit = bj_ghoul [q + 1020]
                        set t = CreateTimer ()
                        set tJ = GetHandleId (t)
                        set tH = udg_MasterHash
                        call SaveUnitHandle (tH, tJ, 0, merc_unit)
                        call SaveInteger (tH, tJ, 1, 1)
                        call TimerStart (t, 0.50, true, function Every15Seconds_Action02)
                        set t = null
                        set tH = null
                    endif
                endif
            endif
        endif
        set q = q + 1
    endloop
    set hero_unit = null
    set merc_unit = null
endfunction

function InitTrig_Every15Seconds takes nothing returns nothing
    set gg_trg_Every15Seconds = CreateTrigger ()
    call TriggerAddAction (gg_trg_Every15Seconds, function Every15Seconds_Action01)
endfunction

Does anything stick out as obvious?
 
Last edited by a moderator:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,208
Make sure you and your friend have both restarted the game client before playing your map if you have been playing other maps. Maps that are widgitized will curropt the client's memory so that they can only play a specific map reliably. Restarting the client fixes this.
 
Level 5
Joined
Sep 19, 2006
Messages
152
Hmm.

Hmm. Let me try posting that trigger again.

JASS:
function Every3Seconds_Action01 takes nothing returns nothing
    local rect r                 = gg_rct_NeutralRegion
    local group g                = CreateGroup ()
    local integer ScoreCap       = udg_ScoreCap
    local integer TotalPlayers   = 0
    local integer TotalScore     = 0
    local boolean winner_boo     = false
    local multiboard Mb          = udg_Multiboard
    local multiboarditem Mbi
    local unit hero_unit
    local real hero_unitA
    local real hero_unitI
    local real hero_unitL
    local real hero_unitS
    local real hero_unitX
    local real hero_unitY
    local integer hero_unitD
    local integer n
    local integer n_1180
    local integer n_1300
    local integer n_1360
    local integer q_1360
    local integer n_1380
    local integer n_1520
    local integer n_3080
    local integer n_5001         = bj_randDistID [5001]
    local integer n_5003         = bj_randDistID [5003]
    local integer q              = 1
    local integer PSco_low       = 200000
    local unit u
    local real uX
    local real uY
    local real m
//
    set bj_randDistID [5001] = 100
    set bj_randDistID [5003] = 0
    set udg_HypothermiaActive = false
    call GroupEnumUnitsInRect (g, r, null)
    loop
        set u = FirstOfGroup (g)
        exitwhen u == null
        call GroupRemoveUnit (g, u)
        if GetUnitAbilityLevel (u, 'BOhx') == 0 then
            set m = GetUnitState (u, UNIT_STATE_LIFE) 
            call SetUnitState (u, UNIT_STATE_LIFE, (((GetUnitState (u, UNIT_STATE_MAX_LIFE)) - m) * 0.20) + m)
        endif
    endloop
    call DestroyGroup (g)
    set g = null
    set r = null
    loop
        exitwhen q > 11
        set hero_unit = bj_ghoul [q + 1000]
        set hero_unitA = GetHeroAgi (hero_unit, true)
        set hero_unitD = GetUnitUserData (hero_unit)
        set hero_unitI = GetHeroInt (hero_unit, true)
        set hero_unitS = GetHeroStr (hero_unit, true)
        set hero_unitX = GetUnitX (hero_unit)
        set hero_unitY = GetUnitY (hero_unit)
        set n_1180 = bj_randDistID [q + 1180]
        if n_1180 == 1 and bj_randDistID [q + 980] > 0 then
            set u = bj_ghoul [q + 1020]
            set uX = GetUnitX (u)
            set uY = GetUnitY (u)
            set m = SquareRoot (((hero_unitX - uX) * (hero_unitX - uX)) + ((hero_unitY - uY) * (hero_unitY - uY)))
            if m > 1300.00 and GetUnitAbilityLevel (hero_unit, 'BOwk') == 0 then
                call IssueTargetOrder (u, "smart", hero_unit)
            endif
        endif
        if n_1180 == 1 and bj_randDistID [q + 2800] == 2 then
            call ResetToGameCameraForPlayer (Player (q), 1.00 )
            call SetCameraFieldForPlayer (Player (q), CAMERA_FIELD_TARGET_DISTANCE, 2600.00, 1.00)
            call SetCameraTargetControllerNoZForPlayer (Player (q), hero_unit, 0, 0, false)
            set n_1520 = bj_randDistID [q + 1520] // Doomlord, Bone Warrior count
            if n_1520 > 0 then
                set m = GetUnitState (hero_unit, UNIT_STATE_MANA) - I2R (n_1520 * 5)
                if m > 0.00 then
                    call SetUnitState (hero_unit, UNIT_STATE_MANA, m)
                    set n = (q * 10) + 3000
                    loop
                        exitwhen n > (q * 10) + 3008
                        set u = bj_ghoul [n]
                        set uX = GetUnitX (u)
                        set uY = GetUnitY (u)
                        set m = SquareRoot (((hero_unitX - uX) * (hero_unitX - uX)) + ((hero_unitY - uY) * (hero_unitY - uY)))
                        if m > 800.00 then 
                            call IssueTargetOrder (u, "smart", hero_unit)
                        endif
                        set n = n + 1
                    endloop
                    set u = null
                else
                    call SetUnitState (hero_unit, UNIT_STATE_MANA, 0.00)
                    if bj_randDistID [q + 1160] == 0 then
                        call SetUnitInvulnerable (hero_unit, false)
                    endif
                    set bj_randDistID [q + 1520] = 0
                    set n = (q * 10) + 3000
                    loop
                        exitwhen n > (q * 10) + 3008
                        set u = bj_ghoul [n]
                        call SetUnitOwner (u, Player (15), true)
                        call KillUnit (u)
                        set bj_ghoul [n] = null
                        call RemoveUnit (bj_ghoul [n + 100])
                        set bj_ghoul [n + 100] = null
                        set n = n + 1
                    endloop
                    set u = null
                endif
            elseif hero_unitD == 25 then  //  Cavalier
                set u = bj_ghoul [q + 1040]
                set uX = GetUnitX (u)
                set uY = GetUnitY (u)
                set m = SquareRoot (((hero_unitX - uX) * (hero_unitX - uX)) + ((hero_unitY - uY) * (hero_unitY - uY)))
                if m > 1300.00 then 
                    call IssueTargetOrder (u, "smart", hero_unit)
                endif
            elseif hero_unitD == 27 then  //  Warlock
                set u = bj_ghoul [q + 1040]
                set uX = GetUnitX (u)
                set uY = GetUnitY (u)
                set m = SquareRoot (((hero_unitX - uX) * (hero_unitX - uX)) + ((hero_unitY - uY) * (hero_unitY - uY)))
                if m > 1300.00 then 
                    call IssueTargetOrder (u, "smart", hero_unit)
                endif
                call SetUnitAbilityLevel (u, 'A0DM', (R2I (hero_unitA) + 2) / 3)
                set u = bj_ghoul [q + 1060]
                set uX = GetUnitX (u)
                set uY = GetUnitY (u)
                set m = SquareRoot (((hero_unitX - uX) * (hero_unitX - uX)) + ((hero_unitY - uY) * (hero_unitY - uY)))
                if m > 3000.00 then 
                    call IssueTargetOrder (u, "smart", hero_unit)
                else
                    call IssuePointOrder (u, "attack", hero_unitX + GetRandomReal (-300.00, 300.00), hero_unitY + GetRandomReal (-300.00, 300.00))
                endif
            elseif hero_unitD == 35 then  //  Tree Entity
                set n_3080 = bj_randDistID [q + 3080]
                if n_3080 > 1 and GetRandomInt (1, 2) == 1 then
                    call SetUnitAbilityLevel (hero_unit, 'A0AW', n_3080 - 1)
                    set bj_randDistID [q + 3080] = n_3080 - 1
                endif
            endif
        endif
        set udg_RealArray [q + 100] = ((hero_unitA * udg_RealArray [q + 120]) + hero_unitI) * 0.25
        call SetPlayerHandicapXP (Player (q), ((hero_unitA * 0.10)) / udg_RealArray [q + 20])
        set n_1380 = bj_randDistID [q + 1380]
        set bj_randDistID [q + 1380] = 0
        if n_5003 == 0 then
            set n = n_1380 * R2I (hero_unitI)
            set n = GetRandomInt (0, n) * bj_randDistID [q + 880] / 120
            call SetPlayerState (Player (q), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState (Player (q), PLAYER_STATE_RESOURCE_GOLD) + n)
        endif
        set n_1300 = (n_1380 * R2I (hero_unitS)) + bj_randDistID [q + 1300]
        if n_1300 > ScoreCap then
            set n_1300 = ScoreCap
        endif
        if bj_randDistID [q + 3160] == 1 then
            set bj_randDistID [q + 3160] = 0
        else
            set n_1300 = (n_1300 * n_5001) / 100
        endif
        set q_1360 = bj_randDistID [q + 1360]
        set n_1360 = bj_randDistID [q_1360 + 1300]
        if q > q_1360 then
            if n_1300 > n_1360 then
                set TotalScore = TotalScore + (n_1300 - n_1360)
                set bj_randDistID [q_1360 + 1300] = n_1300
            elseif n_1300 < n_1360 then
                set TotalScore = TotalScore + (n_1360 - n_1300)
                set n_1300 = n_1360
            endif
        endif
        if n_1300 < PSco_low then
            set PSco_low = n_1300
        endif
        set bj_randDistID [q + 1300] = n_1300
        set TotalPlayers = TotalPlayers + 1
        set TotalScore = TotalScore + n_1300
        set q = q + 1
    endloop
    set hero_unit = null
    set u = null
//
    set q = 1
    if bj_randDistID [5000] == 1 then
        set bj_randDistID [5000] = 0
        set n = TotalScore / TotalPlayers
        loop
            exitwhen q > 11 or bj_randDistID [q + 1480] > 0
            set q = q + 1
        endloop
        loop
            exitwhen q > 11
            if bj_randDistID [q + 1480] == 1 then
                set bj_randDistID [q + 1300] = n
                set Mbi = MultiboardGetItem (Mb, q - 1, 2)
                call MultiboardSetItemValue (Mbi, udg_PlayerString [q + 100] + I2S (n) + "|r")
                if bj_randDistID [q + 1000] == 21 then
                    set hero_unit = bj_ghoul [q + 1000]
                    call SetUnitAbilityLevel (hero_unit, 'A0EX', 2)
                endif
            endif
            set q = q + 1
        endloop
    else
        loop
            exitwhen q > 11
            if bj_randDistID [q + 1480] == 1 then
                set Mbi = MultiboardGetItem (Mb, q - 1, 2)
                set n_1300 = bj_randDistID [q + 1300]
                if n_1300 > 149999 then
                    set winner_boo = true
                    set bj_randDistID [q + 1300] = 150000
                    call MultiboardSetItemValue (Mbi, "|cffffdead150000|r")
                elseif n_1300 > ScoreCap - 1 then
                    set n_1300 = ScoreCap
                    set bj_randDistID [q + 1300] = ScoreCap
                    call MultiboardSetItemValue (Mbi, "|cffffdead" + I2S (n_1300) + "|r")
                elseif n_1300 > 0 then
                    call MultiboardSetItemValue (Mbi, udg_PlayerString [q + 100] + I2S (n_1300) + "|r")
                else
                    set bj_randDistID [q + 1300] = 0
                    call MultiboardSetItemValue (Mbi, udg_PlayerString [q + 100] + I2S (0) + "|r")
                endif
                if bj_randDistID [q + 1000] == 21 then
                    set hero_unit = bj_ghoul [q + 1000]
                    if n_1300 == PSco_low then
                        call SetUnitAbilityLevel (hero_unit, 'A0EX', 2)
                    else
                        call SetUnitAbilityLevel (hero_unit, 'A0EX', 1)
                    endif
                endif
            endif
            set q = q + 1
        endloop
    endif
    set hero_unit = null
    set Mb = null
    set Mbi = null
    if winner_boo == true then
        call DisableTrigger (gg_trg_CreepsDeath)
        call DisableTrigger (gg_trg_CreepsDeathUndead)
        call DisableTrigger (gg_trg_Every1Seconds)
        call TriggerExecute (gg_trg_GameFinish)
    elseif GetPlayerState (Player (12), PLAYER_STATE_RESOURCE_FOOD_USED) < 300 then
        call TriggerExecute (gg_trg_CreepsCreation)
    endif
endfunction

function InitTrig_Every3Seconds takes nothing returns nothing
    set gg_trg_Every3Seconds = CreateTrigger ()
    call TriggerAddAction (gg_trg_Every3Seconds, function Every3Seconds_Action01)
endfunction
 
Last edited by a moderator:
Level 5
Joined
Sep 19, 2006
Messages
152
I noticed that disabling the following lines SEEMS to have remedied the issue:

local rect r = GetEntireMapRect()

call EnumItemsInRect (r, null, function Every15Seconds_EnumAction01)
set r = null

Any thoughts?
 
Level 5
Joined
Sep 19, 2006
Messages
152
Are you ever hiding or showing items in GetLocalPlayer() blocks?
Maybe that could be it.

Actually, I don't believe I have a single GetLocalPlayer line anywhere in my map; it seems that using them causes more problems than it solves.

P.S. Thank you to whoever re-posted my original triggers in the "pretty" JASS way. I must have monkeyed up the code to do it myself.
 
Status
Not open for further replies.
Top