• 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] Fog Fade System

Status
Not open for further replies.
Hello, I've been creating a kind of Fog fade System, that slowly will fade the fog to the fog I want it to.

I'm using both GUI and JASS, because I'm slowly learning JASS (local variables, loops, if's and more). So I'd ask you to check the system code for me and see if it can get any improvements or give me any feedback? :)
Thanks!


JASS:
function AddFogForPlayer takes real start, real end, real Red, real Green, real Blue, player whichplayer returns nothing

   // Local Variables

      local integer i = 0

   // ----------------

   if (udg_Player_FogFading[GetConvertedPlayerId(whichplayer)] == false) then

      if (udg_Player_CurrentFogRed[GetConvertedPlayerId(whichplayer)] == Red) then
         set i = i + 1
      endif
          
      if (udg_Player_CurrentFogGreen[GetConvertedPlayerId(whichplayer)] == Green) then
         set i = i + 1
      endif

      if (udg_Player_CurrentFogBlue[GetConvertedPlayerId(whichplayer)] == Blue) then
         set i = i + 1
      endif

      if (i < 3) then

         set udg_Player_CurrentFogRed[GetConvertedPlayerId(whichplayer)] = udg_Player_FogRed[GetConvertedPlayerId(whichplayer)]
         set udg_Player_CurrentFogBlue[GetConvertedPlayerId(whichplayer)] = udg_Player_FogBlue[GetConvertedPlayerId(whichplayer)]
         set udg_Player_CurrentFogGreen[GetConvertedPlayerId(whichplayer)] = udg_Player_FogGreen[GetConvertedPlayerId(whichplayer)]

         set udg_Player_FogZ_Start[GetConvertedPlayerId(whichplayer)] = start
         set udg_Player_FogZ_End[GetConvertedPlayerId(whichplayer)] = end
         set udg_Player_FogRed[GetConvertedPlayerId(whichplayer)] = Red
         set udg_Player_FogBlue[GetConvertedPlayerId(whichplayer)] = Blue
         set udg_Player_FogGreen[GetConvertedPlayerId(whichplayer)] = Green
         
         set udg_Player_FogFading[GetConvertedPlayerId(whichplayer)] = true
   
         call EnableTrigger( gg_trg_Fog_Fade_System )
   
      endif
   endif
   
endfunction

  • Fog Fade System
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Custom script: local real red = 0
      • Custom script: local real green = 0
      • Custom script: local real blue = 0
      • Custom script: local real start = 0
      • Custom script: local real end = 0
      • Custom script: local integer i = 0
      • Custom script: local integer check = 0
      • For each (Integer FogInt) from 1 to 10, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Player_FogFading[FogInt] Equal to True
            • Then - Actions
              • Set p[0] = (Player(FogInt))
              • -------- --------------- --------
              • -------- --------SET BLUE------- --------
              • -------- --------------- --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Player_CurrentFogBlue[FogInt] Less than Player_FogBlue[FogInt]
                • Then - Actions
                  • Set Player_CurrentFogBlue[FogInt] = (Player_CurrentFogBlue[FogInt] + 1.00)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Player_CurrentFogBlue[FogInt] Greater than Player_FogBlue[FogInt]
                    • Then - Actions
                      • Set Player_CurrentFogBlue[FogInt] = (Player_CurrentFogBlue[FogInt] - 1.00)
                    • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Player_CurrentFogBlue[FogInt] Equal to Player_FogBlue[FogInt]
                • Then - Actions
                  • Set Player_CurrentFogBlue[FogInt] = Player_FogBlue[FogInt]
                  • Custom script: set check = check + 1
                • Else - Actions
              • -------- --------------- --------
              • -------- --------SET GREEN------- --------
              • -------- --------------- --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Player_CurrentFogGreen[FogInt] Less than Player_FogGreen[FogInt]
                • Then - Actions
                  • Set Player_CurrentFogGreen[FogInt] = (Player_CurrentFogGreen[FogInt] + 1.00)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Player_CurrentFogGreen[FogInt] Greater than Player_FogGreen[FogInt]
                    • Then - Actions
                      • Set Player_CurrentFogGreen[FogInt] = (Player_CurrentFogGreen[FogInt] - 1.00)
                    • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Player_CurrentFogGreen[FogInt] Equal to Player_FogGreen[FogInt]
                • Then - Actions
                  • Set Player_CurrentFogGreen[FogInt] = Player_FogGreen[FogInt]
                  • Custom script: set check = check + 1
                • Else - Actions
              • -------- --------------- --------
              • -------- --------SET RED------ --------
              • -------- --------------- --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Player_CurrentFogRed[FogInt] Less than Player_FogRed[FogInt]
                • Then - Actions
                  • Set Player_CurrentFogRed[FogInt] = (Player_CurrentFogRed[FogInt] + 1.00)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Player_CurrentFogRed[FogInt] Greater than Player_FogRed[FogInt]
                    • Then - Actions
                      • Set Player_CurrentFogRed[FogInt] = (Player_CurrentFogRed[FogInt] - 1.00)
                    • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Player_CurrentFogRed[FogInt] Equal to Player_FogRed[FogInt]
                • Then - Actions
                  • Set Player_CurrentFogRed[FogInt] = Player_FogRed[FogInt]
                  • Custom script: set check = check + 1
                • Else - Actions
              • -------- --------------- --------
              • -------- SET FOG --------
              • -------- --------------- --------
              • Custom script: set red = udg_Player_CurrentFogRed[udg_FogInt]
              • Custom script: set green = udg_Player_CurrentFogGreen[udg_FogInt]
              • Custom script: set blue = udg_Player_CurrentFogBlue[udg_FogInt]
              • Custom script: set start = udg_Player_FogZ_Start[udg_FogInt]
              • Custom script: set end = udg_Player_FogZ_End[udg_FogInt]
              • -------- --------------- --------
              • Custom script: if GetLocalPlayer() == udg_p[0] then
              • Custom script: call SetTerrainFogExBJ( 0, start, end, 0, red, green, blue )
              • Custom script: endif
              • -------- --------------- --------
              • Custom script: if (check >= 3) then
              • Game - Display to (All players) the text: FogDone
              • Set Player_FogFading[FogInt] = False
              • Custom script: endif
            • Else - Actions
              • Custom script: set i = i + 1
      • -------- ------------ --------
      • Custom script: if (i >= 10) then
      • Trigger - Turn off Fog Fade System <gen>
      • Custom script: endif


By the way, this isn't a system I'll release (I think), I'll just use it in a map :)
 
Status
Not open for further replies.
Top