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

[JASS] Lightning effects dont show

Status
Not open for further replies.
Level 4
Joined
Jan 20, 2011
Messages
65
hi

i am trying to use lightning effects in my map, from beginning on i had troubles with it , i am useing AddLightning and AddLightningEx
they used to show when the boolean was false
but now i added some more, and they dont show at all
i played around with it alot, when i change the lightning type i get different results
sometimes the boolean doesnt seem to do anything, it sometimes shows when its true and sometimes when its false, its pretty random
i also imported a new LightningData.slk where i made a new custom lightning effect as shown in some tutorials, but i dont think it has todo with it since it bugged before aswell

here is the function in which i create the lightning effects, its the only place i use them

lightning effects are at the top, its called by a timer started in the init
JASS:
function StartTournament takes nothing returns nothing
local integer i = 0
local integer i2 = 0
local integer tempi
local real realx
local real realy
local real maxy = udg_OtteRects[udg_OTTEGROUPS_AMOUNT*4+3]
local real miny = udg_OtteRects[udg_OTTEGROUPS_AMOUNT*4+1]
local real maxx = udg_OtteRects[udg_OTTEGROUPS_AMOUNT*4+2]
local real minx = udg_OtteRects[udg_OTTEGROUPS_AMOUNT*4+0]
local real centerx = (maxx-minx) * 0.5 + minx
local real centery = (maxy-miny) * 0.5 + miny
local real tempr1
local real tempr2
local integer playercount = CountPlayersInForceBJ(udg_AllPlayers)
local integer multiplier = 1
local group tempg = CreateGroup()
local unit fog
local integer TOURSCORES_HEIGHT = 100
local integer TOURSCORES_WIDTH = 150

    set udg_TournamentLightning1 = AddLightning( "INIT" , false ,minx+100,miny+100,maxx-100,miny+100)
    set udg_TournamentLightning2 = AddLightning( "INIT" , false ,maxx-100,miny+100,maxx-100,maxy-100)
    set udg_TournamentLightning3 = AddLightning( "INIT" , false ,maxx-100,maxy-100,minx+100,maxy-100)
    set udg_TournamentLightning4 = AddLightning( "INIT" , false ,minx+100,maxy-100,minx+100,miny+100)

    set realx = centerx - 500
    set realy = centery + (playercount-1) * TOURSCORES_HEIGHT*0.5
    set tempi = playercount-1
    loop
        loop
            set tempr1 = realx-TOURSCORES_WIDTH*i
            set tempr2 = realy-((TOURSCORES_HEIGHT*multiplier)*i2)
            set udg_TourScorePointsX[i*13+i2] = tempr1
            set udg_TourScorePointsY[i*13+i2] = tempr2
            //set udg_TourScoresLightning[i*13+i2] = AddLightning( "CLA" , false ,tempr1,tempr2,realx-TOURSCORES_WIDTH*(i+1),tempr2+(TOURSCORES_HEIGHT*multiplier*0.5)*((ModuloInteger(i2,2)*2)-1))
            set udg_TourScoresTextTag[i*13+i2] = CreateTextTag()
            call SetTextTagPos(udg_TourScoresTextTag[i*13+i2],tempr1,tempr2-4,0)
            call SetTextTagText(udg_TourScoresTextTag[i*13+i2],"------",0.023)
            call SetTextTagColor(udg_TourScoresTextTag[i*13+i2],140,140,140,255)
        exitwhen i2 == tempi
        set i2=i2+1
        endloop
    set udg_TourScoresLightning[i*13+i2+1] = null
    set udg_TourScoresTextTag[i*13+i2+1] = null
    exitwhen tempi == 1
    set i=i+1
    set i2 = 0
    set realy = realy - (TOURSCORES_HEIGHT*(multiplier)*0.5)
    set tempi = R2I( ( tempi+1 + ModuloInteger(tempi+1,2) ) / 2 ) - 1
    set multiplier = multiplier * 2
    endloop

    call StopSound( udg_CurrentlyPlayingMusic[i] , false , true )
    set udg_CurrentlyPlayingMusic[i] = null

    call FogEnable(false)
    call FogMaskEnable(false)

    set udg_TournamentStarted = true
    call ForForce( udg_AllPlayers , function AddEnumToTourWinnerForce )
    set udg_OtteOwningPlayer[udg_OTTEGROUPS_AMOUNT] = Player(15)
    set udg_OtteOwningPlayer[udg_OTTEGROUPS_AMOUNT-1] = Player(15)
    call ForGroup( GetUnitsOfTypeIdAll('h00F') , function UnPowerAllLevers )
    set realx = minx+(maxx-minx)*0.5
    set realy = miny+(maxy-miny)*0.5
    set i = 0
    loop
    exitwhen udg_SteamTanks[i] == null
        set udg_OtteUnitIsInGroup[udg_OtteBooleansIndex[GetUnitUserData(udg_SteamTanks[i])]+udg_OTTEGROUPS_AMOUNT-1] = true
        call SetUnitAbilityLevel( udg_SteamTanks[i] , 'A000' , udg_PeasantAbilityLevel[GetPlayerId(GetOwningPlayer(udg_SteamTanks[i]))] )
        call GroupAddGroup(udg_Peasants[GetPlayerId(GetOwningPlayer(udg_SteamTanks[i]))],tempg)
        loop
            set fog = FirstOfGroup(tempg)
            exitwhen fog == null
            call GroupRemoveUnit(tempg,fog)
            call RemoveUnitWrap(GetUnitUserData(fog))
        endloop
        if( GetPlayerTechCount(GetOwningPlayer(udg_SteamTanks[i]),'R000',true) == 0) then
            call SetPlayerTechResearched( GetOwningPlayer(udg_SteamTanks[i]),'R000' ,1 )
        endif
    set i=i+1
    endloop
    
    call ForForce( udg_AllPlayers , function ForAllPlayersAtTourStart )
    
    set udg_ButtonTrigger[0] = CreateTrigger()
    call TriggerAddAction( udg_ButtonTrigger[0], function TournamentButton )
    set udg_ButtonTrigger[1] = CreateTrigger()
    call TriggerAddAction( udg_ButtonTrigger[1], function TournamentButton )
    call TriggerRegisterEnterRectSimple( udg_ButtonTrigger[0] , Rect(realx-280,realy-80,realx-120,realy+80) )
    call TriggerRegisterEnterRectSimple( udg_ButtonTrigger[1] , Rect(realx+120,realy-80,realx+280,realy+80) )
    set udg_TournamentButtons[0] = CreateUnit(Player(15) , 'h00H', realx-200 , realy , 0 )
    set udg_TournamentButtons[1] = CreateUnit(Player(15) , 'h00H', realx+200 , realy , 0 )
    
    set udg_TournamentTextTags[2] = CreateTextTag()
    call SetTextTagColor( udg_TournamentTextTags[2], 255 , 100 , 100 , 255 )
    call SetTextTagPos( udg_TournamentTextTags[2] , realx-50,realy,0)
    call SetTextTagText( udg_TournamentTextTags[2] , "VS" , 0.060 )
    set udg_TournamentTextTags[0] = CreateTextTag()
    call SetTextTagPos( udg_TournamentTextTags[0] , GetUnitX(udg_TournamentButtons[0])-50,GetUnitY(udg_TournamentButtons[0])+100,0)
    call SetTextTagText( udg_TournamentTextTags[0] , "" , 0.027 )
    set udg_TournamentTextTags[1] = CreateTextTag()
    call SetTextTagPos( udg_TournamentTextTags[1] , GetUnitX(udg_TournamentButtons[1])-50,GetUnitY(udg_TournamentButtons[1])+100,0)
    call SetTextTagText( udg_TournamentTextTags[1] , "" , 0.027 )
    
    call HideStuff()
    
    set maxy = udg_OtteRects[(udg_OTTEGROUPS_AMOUNT-1)*4+3]
    set miny = udg_OtteRects[(udg_OTTEGROUPS_AMOUNT-1)*4+1]
    set maxx = udg_OtteRects[(udg_OTTEGROUPS_AMOUNT-1)*4+2]
    set minx = udg_OtteRects[(udg_OTTEGROUPS_AMOUNT-1)*4+0]
    call CreateForest( minx+100,miny-500, minx-612,maxy+500,192,192,0.9)
    call CreateForest( maxx-100,miny-500, maxx+612,maxy+500,192,192,0.9)
    call CreateForest( minx+292,maxy-100, maxx-292,maxy+612,192,192,0.9)
    call CreateForest( minx+292,miny+100, maxx-292,miny-612,192,192,0.7)
    
    call DestroyGroup(tempg)
    set tempg = null
    set fog = null
    call StartTournamentLobby()
endfunction

oh and also i replace a lightning in this function, its triggerd by a unit enters region event, this is the lightning effect which doesnt show at the moment
JASS:
function TournamentButton takes nothing returns nothing
local integer i
local real angle
local real unitx
local real unity
local boolean fight = false
if( GetUnitTypeId(GetTriggerUnit()) == 'h000' ) then
    if( GetTriggeringTrigger() == udg_ButtonTrigger[0] ) then
        set unitx = GetUnitX(udg_TournamentButtons[0])
        set unity = GetUnitY(udg_TournamentButtons[0])
    else
        set unitx = GetUnitX(udg_TournamentButtons[1])
        set unity = GetUnitY(udg_TournamentButtons[1])
    endif
    if( IsPlayerInForce( GetOwningPlayer(GetTriggerUnit()) ,udg_TournamentForce )  )then
        set i = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
        if( GetTriggeringTrigger() == udg_ButtonTrigger[0] ) then
            call SetUnitAnimation( udg_TournamentButtons[0] , "death" )
            call SetTextTagColor( udg_TournamentTextTags[0], udg_PlayerColorsRGB[i+0] , udg_PlayerColorsRGB[i+1] , udg_PlayerColorsRGB[i+2] , 255 )
            call SetTextTagText( udg_TournamentTextTags[0] , GetPlayerName(Player(i)) , 0.027 )
            set udg_TournamentFightingPlayers[0] = GetOwningPlayer(GetTriggerUnit())
            call ForceRemovePlayer(udg_TournamentForce,udg_TournamentFightingPlayers[0])
            call DisableTrigger(udg_ButtonTrigger[0])
            if( udg_TournamentFightingPlayers[1] != null ) then
                set fight = true
            endif
        else
            call SetUnitAnimation( udg_TournamentButtons[1] , "death" )
            call SetTextTagColor( udg_TournamentTextTags[1], udg_PlayerColorsRGB[i+0] , udg_PlayerColorsRGB[i+1] , udg_PlayerColorsRGB[i+2] , 255 )
            call SetTextTagText( udg_TournamentTextTags[1] , GetPlayerName(Player(i)) , 0.027 )
            set udg_TournamentFightingPlayers[1] = GetOwningPlayer(GetTriggerUnit())
            call ForceRemovePlayer(udg_TournamentForce,udg_TournamentFightingPlayers[1])
            call DisableTrigger(udg_ButtonTrigger[1])
            if( udg_TournamentFightingPlayers[0] != null ) then
                set fight = true
            endif
        endif  
        call DestroyLightning(udg_TourScoresLightning[(udg_TournamentRoundCount-1)*13+udg_TourScoresCurrentPos])
        set udg_TourScoresLightning[(udg_TournamentRoundCount-1)*13+udg_TourScoresCurrentPos] = AddLightning("CLA", false , udg_TourScorePointsX[(udg_TournamentRoundCount-1)*13+udg_TourScoresCurrentPos] , udg_TourScorePointsY[(udg_TournamentRoundCount-1)*13+udg_TourScoresCurrentPos] , udg_TourScorePointsX[(udg_TournamentRoundCount)*13+(udg_TourScoresCurrentPos+ModuloInteger(udg_TourScoresCurrentPos,2))/2] , udg_TourScorePointsY[(udg_TournamentRoundCount)*13+(udg_TourScoresCurrentPos+ModuloInteger(udg_TourScoresCurrentPos,2))/2] )
        call SetLightningColor(udg_TourScoresLightning[(udg_TournamentRoundCount-1)*13+udg_TourScoresCurrentPos], udg_PlayerColorsRGB[i+0] , udg_PlayerColorsRGB[i+1] , udg_PlayerColorsRGB[i+2] , 255 )
        call SetTextTagText(udg_TourScoresTextTag[(udg_TournamentRoundCount-1)*13+udg_TourScoresCurrentPos], GetPlayerName(Player(i)) , 0.020 )
        call SetTextTagColor(udg_TourScoresTextTag[(udg_TournamentRoundCount-1)*13+udg_TourScoresCurrentPos], udg_PlayerColorsRGB[i+0] , udg_PlayerColorsRGB[i+1] , udg_PlayerColorsRGB[i+2] , 255 )
        set udg_TourScoresCurrentPos = udg_TourScoresCurrentPos + 1
        if( fight ) then
            call ForForce(udg_AllPlayers,function ForAllPlayersAtButtonPush385 )
            if( GetOwningPlayer(GetTriggerUnit()) != GetLocalPlayer() ) then
                call PanCameraToTimed(unitx,unity,1)
            endif
            call TriggerSleepAction(1)
            if( GetOwningPlayer(GetTriggerUnit()) != GetLocalPlayer() ) then
                call SetCameraTargetController( GetTriggerUnit() , 0, 0, false )
            endif
            call TimerStart(udg_TournamentTimer,5,false,function AfterTournamentButton)
        endif
    else
        set angle = GetRandomReal(0,360)
        set udg_xVelocity[GetUnitUserData(GetTriggerUnit())] = 50 * CosBJ(angle)
        set udg_yVelocity[GetUnitUserData(GetTriggerUnit())] = 50 * SinBJ(angle)
        call DisplayTextToPlayer( GetOwningPlayer(GetTriggerUnit()) ,0,0, "|cffff0000You allready participated in this round" )
        set bj_lastCreatedEffect = AddSpecialEffect("Abilities\\Spells\\Other\\HowlOfTerror\\HowlCaster.mdl",unitx,unity)
        call DestroyEffect(bj_lastCreatedEffect)
    endif
endif
endfunction

so i duno :S
any ideas?!?!
some all known lightning effect bug which everybody falls for?^^
help plz :)
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
some all known lightning effect bug which everybody falls for?^^

No, never had problems with lightnings. Why has your "CLA"-Lightning only 3 letters?

If the boolean parameter is true, the lightning will only be created if at least one of the ending points is visible to the player. DestroyLightning should not be called with an invalid parameter.
 
Level 4
Joined
Jan 20, 2011
Messages
65
changed the specifier to "CLEA" but didnt change anything
so with false it should allways be created?
 
Level 4
Joined
Jan 20, 2011
Messages
65
yes u can add ur own thingy there in the LightningData.slk
i created CLEA and it works just like all the others
but still they randomly dont show : S and im allways useing false
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Yes but I cannot check it when you use your custom one. Since you say that they show up at times, I guess the type is properly set up. Well, validate if the code reaches those points when not being displayed and print out the parameters and maybe id of the new lightnings to be sure that they get created.
 
Level 4
Joined
Jan 20, 2011
Messages
65
ok i did some more tests, i found why its not shown sometimes, its the SetLightningColor functions alpha value...
when i set it to 0 it is invisible
but also when i set it to 255...
on 1 it is visible but a bit transparent
and the colors are wrong too, instead of red it is teal kinda ( the 'CLEA' has completly white texture, so u can see if u change color )
 
Level 4
Joined
Jan 20, 2011
Messages
65
ok now there is next problem
the lightning effects allways are a bit transparent as soon as i give them a color
white lightnings are fine, cant look through them
but as soon as i make it red it gets transparent
and purple is allmost invisible for some reason
i tried all 3 methods to give them color
1. i used SetLightningColor
2. i set colors in the LightningData.slk
3. i made a colored texture

srsly how can it still be transparent when haveing red texture -_-

i want the ability to draw lines on the map and give them player colors
any ideas?

edit: i think its like, the lightning consists out of 3 images, one has its red values one its green and one blue, when u make one color with a method from the above to zero, it is really just tempering with the transparency of the red image from the texture
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Yes, 3rd option should work.

Your white texture consists equally of red, green and blue parts. When you decrease the red part to 0 by SetLightningColor or in LightningData.slk, then this red part will be filtered out but it also contains one third of the alpha, so resulting opacity will be 2/3, the alpha parameter in SetLightningColor/LightningData.slk is an additional overall factor.
 
Level 4
Joined
Jan 20, 2011
Messages
65
ye i have, when i have completly red texture, and i remove the red part, then its invisble cuz there only red parts^^
 
Level 4
Joined
Jan 20, 2011
Messages
65
yes i know, i tried to explain that if i remove the red part its completly invisible, means there is no green and blue part , means the colors of the textures are allready split into the 3 rgb parts

if i only use red texture, no other color modifications , it is still transparent
so i need to find a 4th method :S
 
Level 4
Joined
Jan 20, 2011
Messages
65
ok now i got it maybe!
i will just create 2 lightnings in the same position
one is white and the other one has its color
its like im createing a white canvas for the colored lightning
 
Level 4
Joined
Jan 20, 2011
Messages
65
ok a white canvas makes it kinda .. white again^^
also tried to make 2 lightnings red over each other, looks same :S
 
Status
Not open for further replies.
Top