• 🏆 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!

[Solved] Why does my lightning effect not work in multiplayer?

Status
Not open for further replies.
Level 9
Joined
Jul 7, 2007
Messages
229
This works fine in singleplayer, but the lightning effect doesn't show up in multiplayer.

This first trigger creates the effect.
JASS:
function Trig_Skeleton_King_Copy_Actions takes nothing returns nothing
    // Creating the Normal Wave
    set udg_Temp_Point = GetRectCenter(gg_rct_StuffSpawnsHere)
    call CreateNUnitsAtLoc( udg__CurrentSpawnNumberA[udg__CurrentPhase], udg__CurrentSpawnUnitA[udg__CurrentPhase], Player(7), udg_Temp_Point, bj_UNIT_FACING )
    set udg_Temp_Group = GetLastCreatedGroup()
    call CreateNUnitsAtLoc( udg__CurrentSpawnNumberB[udg__CurrentPhase], udg__CurrentSpawnUnitB[udg__CurrentPhase], Player(7), udg_Temp_Point, bj_UNIT_FACING )
    call GroupAddGroup( GetLastCreatedGroup(), udg_Temp_Group )
    call CreateNUnitsAtLoc( udg__CurrentSpawnNumberC[udg__CurrentPhase], udg__CurrentSpawnUnitC[udg__CurrentPhase], Player(7), udg_Temp_Point, bj_UNIT_FACING )
    call GroupAddGroup( GetLastCreatedGroup(), udg_Temp_Group )
    call CreateNUnitsAtLoc( udg__CurrentSpawnNumberD[udg__CurrentPhase], udg__CurrentSpawnUnitD[udg__CurrentPhase], Player(7), udg_Temp_Point, bj_UNIT_FACING )
    call GroupAddGroup( GetLastCreatedGroup(), udg_Temp_Group )
    // Creating the Lich and Phylacteries
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 4
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call CreateNUnitsAtLoc( 1, 'u003', Player(7), udg_Temp_Point, bj_UNIT_FACING )
        set udg__Phylacteries[GetForLoopIndexA()] = GetLastCreatedUnit()
        call GroupAddGroup( GetLastCreatedGroup(), udg_Temp_Group )
        call SetUnitUserData( GetLastCreatedUnit(), GetForLoopIndexA() )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call CreateNUnitsAtLoc( 1, 'U002', Player(7), udg_Temp_Point, bj_UNIT_FACING )
    set udg__LichKing = GetLastCreatedUnit()
    set udg__LichChainTempPoint = GetUnitLoc(udg__LichKing)
    call SetUnitInvulnerable( udg__LichKing, true )
    call SuspendHeroXPBJ( false, udg__LichKing )
    call GroupAddGroup( GetLastCreatedGroup(), udg_Temp_Group )
    call RemoveLocation(udg_Temp_Point)
    // Chains
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 4
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        set udg_Temp_Point = GetUnitLoc(udg__Phylacteries[GetForLoopIndexA()])
        set udg__LichChains[GetForLoopIndexA()] = AddLightningEx("DRAL", true, GetLocationX(udg__LichChainTempPoint), GetLocationY(udg__LichChainTempPoint), GetLocationZ(udg__LichChainTempPoint) + 70, GetLocationX(udg_Temp_Point), GetLocationY(udg_Temp_Point), GetLocationZ(udg_Temp_Point) + 70)
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    // Attack Order
    call EnableTrigger( gg_trg_Update_The_Lich_Chains )
    call GroupAddGroup( udg_Temp_Group, udg__CurrentWaveGroup )
    set udg_Temp_Point = GetRectCenter(gg_rct_StuffIsOrderedToAttackHere)
    call GroupPointOrderLocBJ( udg_Temp_Group, "attack", udg_Temp_Point )
endfunction

//===========================================================================
function InitTrig_Skeleton_King_Copy takes nothing returns nothing
    set gg_trg_Skeleton_King_Copy = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Skeleton_King_Copy, function Trig_Skeleton_King_Copy_Actions )
endfunction

And this updates the effect

JASS:
function Trig_Update_The_Lich_Chains_Actions takes nothing returns nothing
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 4
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        set udg_Temp_Point = GetUnitLoc(udg__Phylacteries[GetForLoopIndexA()])
        set udg__LichChainTempPoint = GetUnitLoc(udg__LichKing)
        call MoveLightningEx(udg__LichChains[GetForLoopIndexA()], true, GetLocationX(udg__LichChainTempPoint), GetLocationY(udg__LichChainTempPoint), GetLocationZ(udg__LichChainTempPoint) + 70, GetLocationX(udg_Temp_Point), GetLocationY(udg_Temp_Point), GetLocationZ(udg_Temp_Point) + 70)
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction

//===========================================================================
function InitTrig_Update_The_Lich_Chains takes nothing returns nothing
    set gg_trg_Update_The_Lich_Chains = CreateTrigger(  )
    call DisableTrigger( gg_trg_Update_The_Lich_Chains )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Update_The_Lich_Chains, 0.05 )
    call TriggerAddAction( gg_trg_Update_The_Lich_Chains, function Trig_Update_The_Lich_Chains_Actions )
endfunction
 
Level 9
Joined
Jul 7, 2007
Messages
229
First trigger has no event so will never fire?

It is launched by another trigger, and everything but the lightning effect works just fine, so it is firing.

Please don't post converted JASS code. The GUI triggers are way easier to read.

I understand that, I would have preferred that as well, but AddLightningEx and MoveLightningEx are not available as GUI and when I tried using them in the custom code action, the world editor kept crashing, so I was forced to take the whole trigger into code.
 
First trigger has no event so will never fire?

As said by DSG, it has no event which will help it respond, but I have to assume that this is just part of another trigger. In that case, I would clean up the function above and get this...

JASS:
function Trig_Skeleton_King_Copy_Actions takes nothing returns nothing
    local integer i = 1
    local unit enum

    // Checking if udg_Temp_Group is initialized
    if udg_Temp_Group == null then
        set udg_Temp_Group = CreateGroup()
    endif

    call GroupClear(udg_Temp_Group)
    
    // Creating the Normal Wave
    set udg_Temp_Point = GetRectCenter(gg_rct_StuffSpawnsHere)
    call CreateNUnitsAtLoc( udg__CurrentSpawnNumberA[udg__CurrentPhase], udg__CurrentSpawnUnitA[udg__CurrentPhase], Player(7), udg_Temp_Point, bj_UNIT_FACING )
    //set udg_Temp_Group = bj_lastCreatedGroup
    
    call CreateNUnitsAtLoc( udg__CurrentSpawnNumberB[udg__CurrentPhase], udg__CurrentSpawnUnitB[udg__CurrentPhase], Player(7), udg_Temp_Point, bj_UNIT_FACING )
    call GroupAddGroup( bj_lastCreatedGroup, udg_Temp_Group )
    call CreateNUnitsAtLoc( udg__CurrentSpawnNumberC[udg__CurrentPhase], udg__CurrentSpawnUnitC[udg__CurrentPhase], Player(7), udg_Temp_Point, bj_UNIT_FACING )
    call GroupAddGroup( bj_lastCreatedGroup, udg_Temp_Group )
    call CreateNUnitsAtLoc( udg__CurrentSpawnNumberD[udg__CurrentPhase], udg__CurrentSpawnUnitD[udg__CurrentPhase], Player(7), udg_Temp_Point, bj_UNIT_FACING )
    call GroupAddGroup( bj_lastCreatedGroup, udg_Temp_Group )
  
    // Creating the Lich and Phylacteries
    loop
        exitwhen i > 4
        set udg__Phylacteries[i] = CreateUnitAtLoc('u003', Player(7), udg_Temp_Point, bj_UNIT_FACING )
        call GroupAddUnit( udg_Temp_Group, udg__Phylacteries[i] )
        call SetUnitUserData( udg__Phylacteries[i], i )
        set i = i + 1
    endloop
    set udg__LichKing = CreateUnitAtLoc( 'U002', Player(7), udg_Temp_Point, bj_UNIT_FACING )
    set udg__LichChainTempPoint = GetUnitLoc(udg__LichKing)
    call SetUnitInvulnerable( udg__LichKing, true )
    call SuspendHeroXP( udg__LichKing, true )
    call GroupAddUnit( udg_Temp_Group, udg__LichKing )
    call RemoveLocation(udg_Temp_Point)

    // Chains
    set i = 1
    loop
        exitwhen i > 4
        set udg_Temp_Point = GetUnitLoc(udg__Phylacteries[i])
        set udg__LichChains[i] = AddLightningEx("DRAL", true, GetLocationX(udg__LichChainTempPoint), GetLocationY(udg__LichChainTempPoint), GetLocationZ(udg__LichChainTempPoint) + 70, GetLocationX(udg_Temp_Point), GetLocationY(udg_Temp_Point), GetLocationZ(udg_Temp_Point) + 70)
        //call RemoveLocation(udg_Temp_Point) // Added this one for a potential handle leak...
        set i = i + 1
    endloop

    // Attack Order
    call EnableTrigger( gg_trg_Update_The_Lich_Chains )
    call GroupAddGroup( udg_Temp_Group, udg__CurrentWaveGroup )
    set udg_Temp_Point = GetRectCenter(gg_rct_StuffIsOrderedToAttackHere)
    call GroupPointOrderLocBJ( udg_Temp_Group, "attack", udg_Temp_Point )

    //Suggested instead of the GroupPointOrderLocBJ
    /*
    loop
        set enum = FirstOfGroup(udg_Temp_Group)
        exitwhen enum == null
        call IssuePointOrderLoc( enum, "attack", udg_Temp_Point)
        call GroupRemoveUnit(udg_Temp_Group)
    endloop
    */

    //call RemoveLocation(udg_Temp_Point)
endfunction

//===========================================================================
function InitTrig_Skeleton_King_Copy takes nothing returns nothing
    set gg_trg_Skeleton_King_Copy = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Skeleton_King_Copy, function Trig_Skeleton_King_Copy_Actions )
endfunction
 
Last edited:
Level 9
Joined
Jul 7, 2007
Messages
229
As said by DSG, it has no event which will help it respond, but I have to assume that this is just part of another trigger. In that case, I would clean up the function above and get this...

JASS:
function Trig_Skeleton_King_Copy_Actions takes nothing returns nothing
    local integer i = 1
    local unit enum

    // Checking if udg_Temp_Group is initialized
    if udg_Temp_Group == null then
        set udg_Temp_Group = CreateGroup()
    endif

    call GroupClear(udg_Temp_Group)
   
    // Creating the Normal Wave
    set udg_Temp_Point = GetRectCenter(gg_rct_StuffSpawnsHere)
    call CreateNUnitsAtLoc( udg__CurrentSpawnNumberA[udg__CurrentPhase], udg__CurrentSpawnUnitA[udg__CurrentPhase], Player(7), udg_Temp_Point, bj_UNIT_FACING )
    //set udg_Temp_Group = bj_lastCreatedGroup
   
    call CreateNUnitsAtLoc( udg__CurrentSpawnNumberB[udg__CurrentPhase], udg__CurrentSpawnUnitB[udg__CurrentPhase], Player(7), udg_Temp_Point, bj_UNIT_FACING )
    call GroupAddGroup( bj_lastCreatedGroup, udg_Temp_Group )
    call CreateNUnitsAtLoc( udg__CurrentSpawnNumberC[udg__CurrentPhase], udg__CurrentSpawnUnitC[udg__CurrentPhase], Player(7), udg_Temp_Point, bj_UNIT_FACING )
    call GroupAddGroup( bj_lastCreatedGroup, udg_Temp_Group )
    call CreateNUnitsAtLoc( udg__CurrentSpawnNumberD[udg__CurrentPhase], udg__CurrentSpawnUnitD[udg__CurrentPhase], Player(7), udg_Temp_Point, bj_UNIT_FACING )
    call GroupAddGroup( bj_lastCreatedGroup, udg_Temp_Group )
 
    // Creating the Lich and Phylacteries
    loop
        exitwhen i > 4
        set udg__Phylacteries[i] = CreateUnitAtLoc('u003', Player(7), udg_Temp_Point, bj_UNIT_FACING )
        call GroupAddUnit( udg_Temp_Group, udg__Phylacteries[i] )
        call SetUnitUserData( udg__Phylacteries[i], i )
        set i = i + 1
    endloop
    set udg__LichKing = CreateUnitAtLoc( 'U002', Player(7), udg_Temp_Point, bj_UNIT_FACING )
    set udg__LichChainTempPoint = GetUnitLoc(udg__LichKing)
    call SetUnitInvulnerable( udg__LichKing, true )
    call SuspendHeroXP( udg__LichKing, true )
    call GroupAddUnit( udg_Temp_Group, udg__LichKing )
    call RemoveLocation(udg_Temp_Point)

    // Chains
    set i = 1
    loop
        exitwhen i > 4
        set udg_Temp_Point = GetUnitLoc(udg__Phylacteries[i])
        set udg__LichChains[i] = AddLightningEx("DRAL", true, GetLocationX(udg__LichChainTempPoint), GetLocationY(udg__LichChainTempPoint), GetLocationZ(udg__LichChainTempPoint) + 70, GetLocationX(udg_Temp_Point), GetLocationY(udg_Temp_Point), GetLocationZ(udg_Temp_Point) + 70)
        //call RemoveLocation(udg_Temp_Point) // Added this one for a potential handle leak...
        set i = i + 1
    endloop

    // Attack Order
    call EnableTrigger( gg_trg_Update_The_Lich_Chains )
    call GroupAddGroup( udg_Temp_Group, udg__CurrentWaveGroup )
    set udg_Temp_Point = GetRectCenter(gg_rct_StuffIsOrderedToAttackHere)
    call GroupPointOrderLocBJ( udg_Temp_Group, "attack", udg_Temp_Point )

    //Suggested instead of the GroupPointOrderLocBJ
    /*
    loop
        set enum = FirstOfGroup(udg_Temp_Group)
        exitwhen enum == null
        call IssuePointOrderLoc( enum, "attack", udg_Temp_Point)
        call GroupRemoveUnit(udg_Temp_Group)
    endloop
    */

    //call RemoveLocation(udg_Temp_Point)
endfunction

//===========================================================================
function InitTrig_Skeleton_King_Copy takes nothing returns nothing
    set gg_trg_Skeleton_King_Copy = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Skeleton_King_Copy, function Trig_Skeleton_King_Copy_Actions )
endfunction

This seems to have helped, thank you. And thank you for the JASS lesson as well.

Also be aware that lightning will go invisible if both source and destination go outside the camera proximity, even if the beam should pass by the camera.

That wasn't the problem here, but thank you, I didn't know that.

Most likely because the JASS code was too long. You will need to shorten it with the use of local variables.

I figured it was something like that. I will keep that in mind in the future, thank you.
 
Status
Not open for further replies.
Top