1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The raddest synthwave tracks were chosen - Check out our Music Contest #12 - Results and congratulate the winners!
    Dismiss Notice
  4. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  5. Travel to distant realms and encounter scenes unknown to the common folk. The Greatest of Adventures is upon us with the 8th Cinematic Contest. Join in on a fun ride.
    Dismiss Notice
  6. The 18th Icon Contest is ON! Choose any ingame unit and give him/her Hero abilities. Good luck to all.
    Dismiss Notice
  7. Contestants are to create a scene set in the Stone Age. Come and see what you can come up with. We wish you the best of luck!
    Dismiss Notice
  8. Colour outside the lines! Techtree Contest #13 is a go. The contest is optionally paired.
    Dismiss Notice
  9. Greetings cerebrates, our Swarm needs new spawners that will have numerous children. Join the HIVE's 31st Modeling Contest - Spawners and Spawned! The contest is optionally paired.
    Dismiss Notice
  10. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

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

Discussion in 'Triggers & Scripts' started by Argus, Jun 28, 2017.

  1. Argus

    Argus

    Joined:
    Jul 7, 2007
    Messages:
    215
    Resources:
    4
    Models:
    2
    Maps:
    1
    Tutorials:
    1
    Resources:
    4
    This works fine in singleplayer, but the lightning effect doesn't show up in multiplayer.

    This first trigger creates the effect.
    Code (vJASS):
    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

    Code (vJASS):
    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

     
     
  2. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,476
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    First trigger has no event so will never fire?
     
  3. KILLCIDE

    KILLCIDE

    Administrator

    Joined:
    Jul 22, 2015
    Messages:
    3,497
    Resources:
    20
    Models:
    2
    Icons:
    10
    Spells:
    7
    Tutorials:
    1
    Resources:
    20
    Please don't post converted JASS code. The GUI triggers are way easier to read.
     
  4. TheLordOfChaos201

    TheLordOfChaos201

    Joined:
    Jul 2, 2011
    Messages:
    1,722
    Resources:
    0
    Resources:
    0
    I have the same problem on my map.

    area effect lighting like moon light and weather, don't work.

    I'm not sure what the reason is so I would be interested to find out
     
  5. Argus

    Argus

    Joined:
    Jul 7, 2007
    Messages:
    215
    Resources:
    4
    Models:
    2
    Maps:
    1
    Tutorials:
    1
    Resources:
    4
    It is launched by another trigger, and everything but the lightning effect works just fine, so it is firing.

    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.
     
  6. MyPad

    MyPad

    Spell Reviewer

    Joined:
    May 9, 2014
    Messages:
    1,282
    Resources:
    6
    Models:
    1
    Icons:
    1
    Spells:
    3
    JASS:
    1
    Resources:
    6
    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...

    Code (vJASS):

    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: Jun 29, 2017
  7. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,476
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    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.
     
  8. KILLCIDE

    KILLCIDE

    Administrator

    Joined:
    Jul 22, 2015
    Messages:
    3,497
    Resources:
    20
    Models:
    2
    Icons:
    10
    Spells:
    7
    Tutorials:
    1
    Resources:
    20
    Most likely because the JASS code was too long. You will need to shorten it with the use of local variables.
     
  9. Argus

    Argus

    Joined:
    Jul 7, 2007
    Messages:
    215
    Resources:
    4
    Models:
    2
    Maps:
    1
    Tutorials:
    1
    Resources:
    4
    This seems to have helped, thank you. And thank you for the JASS lesson as well.

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

    I figured it was something like that. I will keep that in mind in the future, thank you.