• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Can hiding an item locally for a player cause a desync?

Status
Not open for further replies.
Level 25
Joined
Jul 10, 2006
Messages
3,315
  • Hide Item
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: if GetLocalPlayer() == Player(0) then
      • Item - Hide Claws of Attack +15 0000 <gen>
      • Item - Hide Claws of Attack +15 0001 <gen>
      • Custom script: endif
This successfully hides the items only for player 0 (tested using kloader), and there was no desync when player 1 picked up the hidden item.

I'd like to make this into a Diablo 3-style item drop system for RPG makers to use.
 
Hm. Perhaps you should test on two different computers. The only reason I'm skeptic is because widget interactions generally cause problems in terms of desyncs.

I'm curious whether kLoader can desync if you are the player running it. To test that, add this code:
  • Custom script: if GetLocalPlayer() == Player(0) then
  • Item - Destroy <Item>
  • Custom script: endif
Run it after two seconds elapsed or something and then see if it desyncs. It should desync. If it does, then perhaps you have found a neat way to test for desyncs. :) If not, then sadface.
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
Update on kLoader: I got a desync pausing the game for one player. Trying your code now!

EDIT: Removing the item did not cause a desync, but the moment player blue was ordered to pick up the item, it desynced.

EDIT2: Some more testing done.

Hiding item - no desync
Selecting hidden item - no desync
Ordered targeting hidden item (not yet acquired) - no desync
Acquired hidden item - no desync
Come into vision range of player the item is hidden from (item in blue's inventory) - desynced

EDIT3: Found a solution for hiding items.

Hides the item:
  • Test Item
    • Events
      • Player - Player 1 (Red) types a chat message containing test as An exact match
    • Conditions
    • Actions
      • Custom script: if GetLocalPlayer() == Player(0) then
      • Item - Hide Skeletal Artifact 0004 <gen>
      • Custom script: endif
Shows the item:
  • Unhide Item
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • Hero - Drop (Item being manipulated) from (Triggering unit)
      • Custom script: if GetLocalPlayer() == Player(0) then
      • Item - Show Skeletal Artifact 0004 <gen>
      • Custom script: endif
      • Trigger - Turn off (This trigger)
      • Hero - Give Skeletal Artifact 0004 <gen> to (Triggering unit)
      • Trigger - Turn on (This trigger)
(show/hide item only works for items on the ground)

No longer desyncs when player 0 notices the item or acquires it.
 
Last edited:
Level 19
Joined
Aug 8, 2007
Messages
2,765
nope. ive been playing with this for a while (check my sig lol). it will desync (Triggering Unit) has a full inventory

JASS:
library CustomDrop initializer init
    globals
        private hashtable Hash_t = InitHashtable()
        private location SendToItem = Location(0,0)
    endglobals
    
    private function OnDeath takes nothing returns nothing
        local unit u = GetDyingUnit()
        local integer unitId = GetUnitTypeId(u)
        local integer count = LoadInteger(Hash_t,unitId,0) // if the unit type was not registred for drop it will be equal to 0, else it will be > 0
        local real random
        local integer i
        local item drop
        local integer dummy = 'I01Q'
        
        loop // loop on all dropable item for unitID
            exitwhen count == 0 
            set i = 0
            loop // player loop
            exitwhen i == 11
                set dummy = 'I01Q'
                if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(Player(i)) == MAP_CONTROL_USER then
                    set random = GetRandomReal(0,100)
                    if random < LoadReal(Hash_t,unitId,count) then
                        if GetLocalPlayer() == Player(i) then
                            set dummy = LoadInteger(Hash_t,unitId,count)
                        endif
                        set drop = CreateItem(dummy,GetUnitX(u),GetUnitY(u))
                        call SetItemUserData(drop, LoadInteger(Hash_t,unitId,count))
                    endif
                endif
            set i = i+1
           endloop
     
        set count = count-1
        endloop
        set u = null
        set drop = null
    endfunction
    
    private function RegisterDrop takes integer unitId , integer itemId, real chanceToDrop returns nothing // chanceToDrop in percent
        local integer n = LoadInteger(Hash_t,unitId,0)
        /* integer : unitId ; 0 -> number of possible item drop for the unit type unitId
           integer : unitId ; x -> rawcode of the item to drop ; x > 0
           real : unitId ; x -> chance of the item x to drop
        */
        set n = n+1
        call SaveInteger(Hash_t,unitId,0,n)
        call SaveInteger(Hash_t,unitId,n,itemId)
        call SaveReal(Hash_t,unitId,n,chanceToDrop)
    endfunction
    private function onItemPickup takes nothing returns nothing
        local item it = GetManipulatedItem()
        local unit u = GetTriggerUnit()
        local boolean b
        local integer i = 0
        local integer i2 = 0
        local item dummy
//        set rawcode = GetItemUserData(it)
//        call RemoveItem(it)
//        set it = CreateItem(rawcode, GetUnitX(u), GetUnitY(u))
 //       call SetItemUserData(it,rawcode)
        if GetItemTypeId(it) == GetItemUserData(it) or GetItemTypeId(it) == 'I01Q' then
            set dummy = CreateItem(GetItemUserData(it), GetItemX(it), GetItemY(it))
            call RemoveItem(it)
            call UnitAddItem(u,dummy)
            set it = null
            set u = null
            return
        endif
  /*      loop
            set b = UnitItemInSlot(u, i) == null
            set i = i + 1
            exitwhen i == 5 or b == true
        endloop
        if b == true then
            call UnitAddItem(u, it)
        else
            set u = udg_Backpack[GetConvertedPlayerId(GetTriggerPlayer())]
            set i = 0
            loop
                set b = UnitItemInSlot(u, i) == null
                set i = i + 1
                exitwhen i == 6 or b == true
            endloop
            if b == true then
                call UnitAddItem(u, it)
                call print("The item has been sent to your backpack")
            else
                call print("You do not have enough room for that item")
            endif
        endif*/
    endfunction

 //    private function RegisterDrop takes integer unitId , integer itemId, real chanceToDrop returns nothing //
    private function init takes nothing returns nothing
        local trigger trig = CreateTrigger()
        local trigger trig2 = CreateTrigger()
        
        call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_DEATH)
        call TriggerRegisterAnyUnitEventBJ(trig2, EVENT_PLAYER_UNIT_PICKUP_ITEM  )
        call TriggerAddAction(trig,function OnDeath)
        call TriggerAddAction(trig2, function onItemPickup)
        call RegisterDrop('n000','I00U',7)
        call RegisterDrop('n001','I00U',7)
        call RegisterDrop('n002','I00U',7)
        call RegisterDrop('n00H','I00U',7)
        call RegisterDrop('n00G','I00U',7)
        call RegisterDrop('n00B','I01M',10)
        call RegisterDrop('n00C','I01M',10)
        call RegisterDrop('n00D','I01M',10)
        call RegisterDrop('n003','I01M',10)
        call RegisterDrop('n005','I01N',10)
        call RegisterDrop('n009','I01N',10)
        call RegisterDrop('n004','I01N',10)
        call RegisterDrop('n007','I01O',25)
        
    endfunction
    
endlibrary

this will desync if the item being dropped and 'I01Q' have different abilities, but I use it because i use a custom equipment system and all items either have no ability or the ability that makes them clickable. (which is also the reason why i didnt publish the library :\ )
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
Items have a pathing texture as well, and hiding them does change the pathing map. So they actually should cause a desync. Just like hiding units locally. (I'm only like 90% sure, but I recally reading it somewhere)

should, but dont.
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
Have you tested if it desyncs when a player attempts to use that pathing?

E.g. if you have a building placement cursor (green with red bits for cannot build) moving over the item?

your method still desyncs nonetheless.

my method still affects pathing because the item is still there the model is just invisble
 
Status
Not open for further replies.
Top