• 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.

Creating a boolexpr with localplayer usage

Status
Not open for further replies.
Hello fellows, seems I need some more theory knowledge to get an answer on my question.

JASS:
scope a initializer i
    globals
        boolexpr VALID_ALLY = null
    endglobals
    
    private function v takes nothing returns boolean
        return IsUnitAlly(GetFilterUnit(),GetLocalPlayer())
    endfunction
    
    private function i takes nothing returns nothing
        set VALID_ALLY = Filter(function v)
    endfunction
endscope

Will this thing desync on usage and why so? Please explain it to me, thank you a lot!
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
Just this scope code to create boolexpr won't cause desync by itself, it depends on where you use it.


JASS:
// This function shouldnt cause desync
function something takes nothing returns nothing
    local group g = ...
    local unit u
    call GroupEnumUnıtsInRange(g............., VALID_ALLY)
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
        call SetUnitAnimation(u, "spell")
        call GroupRemoveUnit(g, u)
    endloop
endfunction

// This causes desync
function anotherthing takes nothing returrns nothing
    local group g = ...
    local unit u
    call GroupEnumUnıtsInRange(g............., VALID_ALLY)
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
        call DestroyEffect(AddSpecialEffectTarget(u, "effectpath", "origin"))
        call GroupRemoveUnit(g, u)
    endloop
endfunction
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
JASS:
        return IsUnitAlly(GetFilterUnit(),GetLocalPlayer())

As Ceday mentioned, this function won't desync but it is volatile. If you perform any actions that will change the course of gameplay in any way whatsoever, modify handle stacks, etc. as a result of the boolexpr than it will desync.

To clarify, if you have a group of three units and one player is an ally with one unit and another is a player with two units. The units will be different per player, thats fine, but lets say you want to kill every unit in the group. On player 1's screen the first unit dies but on player 2's screen the second two units die, which desyncs.
 
Status
Not open for further replies.
Top