• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

GetLocalPlayer() Ability

Status
Not open for further replies.
So I'm using abilities (specifically Asph - Sphere ability) to create a special effect on target unit and then remove the effect by removing the ability when needed.

I want this ability to be local, the target effect it causes to be invisible to other players.

Example:

I have created a new Asph ability and named it to "Selection Circle"

Then I detect when a unit is selected and add that ability to selected unit via triggers.

I don't want that ability to be seen by other players.


I'm not using special effects because It's easier to work with abilities, they don't leak and are easier to manipulate.

Would using GetLocalPlayer() to remove ability and add it locally cause a desync?
 
Level 13
Joined
May 10, 2009
Messages
868
I was curious about this too, and have done a simple test in order to find out the answer. So I did it using a virtual machine for a second player, and also created an ability based on Item Armor Bonus (0) to display some effects. Nothing wrong happened, even when I ordered units to kill themselves.

I guess it would only desync if I were to add/remove abilities that modify a unit's property. (life, mana, no selection, etc)

EDIT: I modified the amount of bonus armor from 0 to 1, and it didn't desync either, but then it did as soon as a different peasant for each client died. This is quite interesting.
 
Last edited:
I was curious about this too, and have done a simple test in order to find out the answer. So I did it using a virtual machine for a second player, and also created an ability based on Item Armor Bonus (0) to display some effects. Nothing wrong happened, even when I ordered units to kill themselves.

I guess it would only desync if I were to add/remove abilities that modify a unit's property. (life, mana, no selection, etc)

EDIT: I modified the amount of bonus armor from 0 to 1, and it didn't desync either, but then it did as soon as a different peasant for each client died. This is quite interesting.

So It's safe to use as long as it's just for effects?
 
Level 13
Joined
May 10, 2009
Messages
868
Unfortunately, it desyncs when using that function. Well, I am testing in another way, and it seems to be working fine so far. I created a "real" sfx ability and a "fake" one (both based on the same ability [item armor bonus], and only one displays the sfx). All players except one (red) get the fake ability, and red receives the real one. No desyncs so far (adding/removing ability while a unit dies and/or decays).
 
Level 13
Joined
May 10, 2009
Messages
868
Indeed, it'd be easier and faster to just stick to the old way. There might be some other factors related to the units and abilities that I haven't tested yet, and that could bring more trouble for you.


Anyway, I'm leaving my test map, so you can test it too, if you want.
JASS:
function Trig_AddLocalSFX takes nothing returns nothing
    local integer abil = 'A000' // Real Ability
    local integer fakeabil = 'A001' // Fake Ability
    local integer sfx
    // FoG
    local group g = CreateGroup()
    local unit u = null

    call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, null)
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
        call GroupRemoveUnit(g, u)
     
        if GetUnitTypeId(u) == 'hpea' and GetTriggerPlayer() == GetOwningPlayer(u) then
            set sfx = fakeabil
            if GetLocalPlayer() == GetOwningPlayer(u) then
                set sfx = abil
            endif
            
            // Toggle
            if not UnitRemoveAbility(u, sfx) and UnitAddAbility(u, sfx) then
            endif
        endif
    endloop
 
    call DestroyGroup(g)
    set g = null
endfunction

//===========================================================================
function InitTrig_AddLocalSFX takes nothing returns nothing
    local integer i = 0
    set gg_trg_AddLocalSFX = CreateTrigger()
    loop
        exitwhen i > 11
        call TriggerRegisterPlayerEvent(gg_trg_AddLocalSFX, Player(i), EVENT_PLAYER_END_CINEMATIC)
        set i = i + 1
    endloop
    call TriggerAddAction( gg_trg_AddLocalSFX, function Trig_AddLocalSFX)
endfunction
 

Attachments

  • Ability Desync.w3x
    18 KB · Views: 36
Status
Not open for further replies.
Top