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

The Flood's Fog System 1.2.1a

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
This system is created by The_Flood (Flood @ hiveworkshop). Give credits when used or modified.

You may edit this system how much you want, but don't contact me if your changes does not work properly,
because that isn't my problem, but if you haven't modified anything and the system isn't working as it
should, please contact me then! =)


The_Flood's Fog System is a system that allow you to create an original way of changing the fog in-game.
The system is very useful for RPG maps, when you can make the areas more unique with different fogs. The
bonus of this system is that the fog you will change to, will not be changes directly, it will be changed
smoothly to the numbers you've chosen.

This system is also MPI, allowing up to 12 players use it at the same time. I'm using
GetLocalPlayer() to make sure each player has it's own fog.

This system is user-friendly and has no leaks at all, so have fun using it!

This system was actually created in my dead project An Undiscovered World, but I decided to release it here.

Triggers



JASS:
###########################################################################################################
###########################################################################################################
################################ THE_FLOOD'S FOG SYSTEM ###################################################
################################     VERSION: 1.2.0a      #################################################
###########################################################################################################

This system is created by The_Flood (Flood at hiveworkshop). Give credits when used or modified.

You may edit this system how much you want, but don't contact me if your changes does not work properly,
because that isn't my problem, but if you haven't modified anything and the system isn't working as it
should, please contact me then! =)


The_Flood's Fog System is a system that allow you to create an original way of changing the fog in-game.
The system is very useful for RPG maps, when you can make the areas more unique with different fogs. The
bonus of this system is that the fog you will change to, will not be changes directly, it will be changed
smoothly to the numbers you've chosen.

This system is also MPI, allowing up to 12 players use it at the same time. I'm using 
GetLocalPlayer() to make sure each player has it's own fog.

This system is user-friendly and has no leaks at all, so have fun using it!



###########################################################################################################
                    [How do I import this system?]

It's simple. Paste the whole folder "The_Flood's Fog System" into your map and make sure you've checked the 
"[X] Automatically create unknown variables while pasting trigger data" in File > Preferences.

Also, you need to copy some script that can be found under the script folder called: "The_Floods_FogSystem.w3x" and
paste it at the same place in your map.

When you've done this, you can start using this system!

###########################################################################################################
                    [How do I use this system?]

It's very simple! If you check the EXAMPLE triggers you'll see. Only ONE function call will change the fog as
you want it to. So, what is what? Check below.

Custom script:   call AddFogForPlayer(400, 2500, 10, 10, 10, udg_Fog_Player[0])

400 = This is the number of where the fog will start (z).
2500 = This is the number of where the fog will end (z).
1st 10 = This is the % of how much of the color RED the fog will use.
2nd 10 = This is the % of how much of the color GREEN the fog will use.
3rd 10 = This is the % of how much of the color BLUE the fog will use.
udg_Fog_Okayer[0] = This is the player that will have its fog changed.

Simple isn't it? Remember that the % has a maximum of 100!

Also, in the Fog Fade System Initialization trigger you can change the start fog to the one you want.
You can also change the speed of the fog change. A higher value will make the fog changing faster.

Set Fog_ChangeSpeed = 2.00


Note: As you can see in the EXAMPLE triggers, I'm using a region as the event. If you will also use regions, make sure
you leave a small space between the "fog regions", like in this test map.


JASS:
function AddFogForPlayer takes real start, real end, real Red, real Green, real Blue, player whichplayer returns nothing
    local integer i = 0

    if (udg_Fog_Player_CurrentFogRed[GetPlayerId(whichplayer) + 1] == Red) then
        set i = i + 1
    endif
          
    if (udg_Fog_Player_CurrentFogGreen[GetPlayerId(whichplayer) + 1] == Green) then
        set i = i + 1
    endif

    if (udg_Fog_Player_CurrentFogBlue[GetPlayerId(whichplayer) + 1] == Blue) then
        set i = i + 1
    endif

    if (i < 3) then
        set udg_Fog_Player_FogZ_Start[GetPlayerId(whichplayer) + 1] = start
        set udg_Fog_Player_FogZ_End[GetPlayerId(whichplayer) + 1] = end
        set udg_Fog_Player_FogRed[GetPlayerId(whichplayer) + 1] = Red
        set udg_Fog_Player_FogBlue[GetPlayerId(whichplayer) + 1] = Blue
        set udg_Fog_Player_FogGreen[GetPlayerId(whichplayer) + 1] = Green
        set udg_Fog_Player_FogFading[GetPlayerId(whichplayer) + 1] = true
   
        call EnableTrigger( gg_trg_Fog_Fade_System )
    endif
endfunction


  • Fog Fade System Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- This is the initialization trigger. Change the values to the ones you want at the beginning of the map. --------
      • -------- ------ --------
      • -------- This allow you to change the speed of the fog change. A higher value will make the fog changing faster. --------
      • Set Fog_ChangeSpeed = 2.00
      • -------- ------ --------
      • For each (Integer Fog_FogInt) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player(Fog_FogInt)) controller) Equal to User
              • ((Player(Fog_FogInt)) slot status) Equal to Is playing
            • Then - Actions
              • Set Fog_Player[0] = (Player(Fog_FogInt))
              • Set Fog_Player_CurrentFogBlue[Fog_FogInt] = 50.00
              • Set Fog_Player_CurrentFogGreen[Fog_FogInt] = 50.00
              • Set Fog_Player_CurrentFogRed[Fog_FogInt] = 50.00
              • Set Fog_Player_FogZ_Start[Fog_FogInt] = 400.00
              • Set Fog_Player_FogZ_End[Fog_FogInt] = 5000.00
              • -------- ----------------------------------------------------------------------- --------
              • -------- Below, this is the fog values that will be applied as the start fog. --------
              • Custom script: call AddFogForPlayer(400, 3000, 100, 100, 100, udg_Fog_Player[0])
            • Else - Actions


  • 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
      • -------- --------------- --------
      • -------- The_Flood's Fog Fade System (Do not change if you don't know what you are doing) --------
      • -------- --------------- --------
      • For each (Integer Fog_FogInt) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Fog_Player_FogFading[Fog_FogInt] Equal to True
            • Then - Actions
              • Set Fog_Player[0] = (Player(Fog_FogInt))
              • -------- --------SET BLUE------- --------
              • -------- --------------- --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Fog_Player_CurrentFogBlue[Fog_FogInt] Equal to Fog_Player_FogBlue[Fog_FogInt]
                • Then - Actions
                  • Set Fog_Player_CurrentFogBlue[Fog_FogInt] = Fog_Player_FogBlue[Fog_FogInt]
                  • Custom script: set check = check + 1
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Fog_Player_CurrentFogBlue[Fog_FogInt] Greater than Fog_Player_FogBlue[Fog_FogInt]
                    • Then - Actions
                      • Set Fog_Player_CurrentFogBlue[Fog_FogInt] = (Fog_Player_CurrentFogBlue[Fog_FogInt] - Fog_ChangeSpeed)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Fog_Player_CurrentFogBlue[Fog_FogInt] Less than Fog_Player_FogBlue[Fog_FogInt]
                        • Then - Actions
                          • Set Fog_Player_CurrentFogBlue[Fog_FogInt] = (Fog_Player_CurrentFogBlue[Fog_FogInt] + Fog_ChangeSpeed)
                        • Else - Actions
              • -------- --------SET GREEN------- --------
              • -------- --------------- --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Fog_Player_CurrentFogGreen[Fog_FogInt] Equal to Fog_Player_FogGreen[Fog_FogInt]
                • Then - Actions
                  • Set Fog_Player_CurrentFogGreen[Fog_FogInt] = Fog_Player_FogGreen[Fog_FogInt]
                  • Custom script: set check = check + 1
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Fog_Player_CurrentFogGreen[Fog_FogInt] Greater than Fog_Player_FogGreen[Fog_FogInt]
                    • Then - Actions
                      • Set Fog_Player_CurrentFogGreen[Fog_FogInt] = (Fog_Player_CurrentFogGreen[Fog_FogInt] - Fog_ChangeSpeed)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Fog_Player_CurrentFogGreen[Fog_FogInt] Less than Fog_Player_FogGreen[Fog_FogInt]
                        • Then - Actions
                          • Set Fog_Player_CurrentFogGreen[Fog_FogInt] = (Fog_Player_CurrentFogGreen[Fog_FogInt] + Fog_ChangeSpeed)
                        • Else - Actions
              • -------- --------SET RED------ --------
              • -------- --------------- --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Fog_Player_CurrentFogRed[Fog_FogInt] Equal to Fog_Player_FogRed[Fog_FogInt]
                • Then - Actions
                  • Set Fog_Player_CurrentFogRed[Fog_FogInt] = Fog_Player_FogRed[Fog_FogInt]
                  • Custom script: set check = check + 1
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Fog_Player_CurrentFogRed[Fog_FogInt] Greater than Fog_Player_FogRed[Fog_FogInt]
                    • Then - Actions
                      • Set Fog_Player_CurrentFogRed[Fog_FogInt] = (Fog_Player_CurrentFogRed[Fog_FogInt] - Fog_ChangeSpeed)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Fog_Player_CurrentFogRed[Fog_FogInt] Less than Fog_Player_FogRed[Fog_FogInt]
                        • Then - Actions
                          • Set Fog_Player_CurrentFogRed[Fog_FogInt] = (Fog_Player_CurrentFogRed[Fog_FogInt] + Fog_ChangeSpeed)
                        • Else - Actions
              • -------- --------------- --------
              • Custom script: if (check >= 3) then
              • Set Fog_Player_FogFading[Fog_FogInt] = False
              • Custom script: else
              • -------- --------------- --------
              • -------- SET FOG --------
              • -------- --------------- --------
              • Custom script: set red = udg_Fog_Player_CurrentFogRed[udg_Fog_FogInt]
              • Custom script: set green = udg_Fog_Player_CurrentFogGreen[udg_Fog_FogInt]
              • Custom script: set blue = udg_Fog_Player_CurrentFogBlue[udg_Fog_FogInt]
              • Custom script: set start = udg_Fog_Player_FogZ_Start[udg_Fog_FogInt]
              • Custom script: set end = udg_Fog_Player_FogZ_End[udg_Fog_FogInt]
              • Custom script: if GetLocalPlayer() == udg_Fog_Player[0] then
              • Custom script: call SetTerrainFogEx(0,start,end,0,red*0.01,green*0.01,blue*0.01)
              • Custom script: endif
              • Custom script: endif
            • Else - Actions
              • Custom script: set i = i + 1
      • -------- ------------ --------
      • Custom script: if (i >= 12) then
      • Trigger - Turn off Fog Fade System <gen>
      • Custom script: endif



  • EXAMPLE Enter the Cave
    • Events
      • Unit - A unit enters TheCave <gen>
    • Conditions
    • Actions
      • -------- Action can be changed into one that suits you. --------
      • -------- ------------------- --------
      • -------- This will change the fog for the entering player. --------
      • Set Fog_Player[0] = (Owner of (Triggering unit))
      • Custom script: call AddFogForPlayer(400, 3000, 10, 10, 10, udg_Fog_Player[0])


  • EXAMPLE Enter the IcyArea
    • Events
      • Unit - A unit enters TheIcyArea <gen>
    • Conditions
    • Actions
      • -------- Action can be changed into one that suits you. --------
      • -------- ------------------- --------
      • -------- This will change the fog for the entering player. --------
      • Set Fog_Player[0] = (Owner of (Triggering unit))
      • Custom script: call AddFogForPlayer(400, 3000, 100, 100, 100, udg_Fog_Player[0])


  • EXAMPLE Enter the Forest
    • Events
      • Unit - A unit enters TheForest <gen>
    • Conditions
    • Actions
      • -------- Action can be changed into one that suits you. --------
      • -------- ------------------- --------
      • -------- This will change the fog for the entering player. --------
      • Set Fog_Player[0] = (Owner of (Triggering unit))
      • Custom script: call AddFogForPlayer(100, 4000, 20, 100, 20, udg_Fog_Player[0])


Changelog


  • Release.


  • Improved the READ ME file.
  • Optimized and improved the system code.
  • Hopefully removed the lightning flash issue.
  • Added an option to allow users to change how fast the fog will change.
  • Improved the test map.


  • Improved and added more documentation.
  • Improved the READ ME.
  • Improved the test map.
  • Removed the BJ's (thanks to Dr. Boom)
  • Only playing players will have their fog values initialized in the "Fog Fade System Initialization" trigger now.
  • Renamed all examples and added a new example.


  • Removed more BJ's (thanks to baassee)

Keywords:
System, Fog, The_Flood, Flood, Change, Changing, Value, Mist, Cloud, GetLocalPlayer, Player,
Contents

The_Flood's Fog System 1.2.1a (Map)

Reviews
http://www.hiveworkshop.com/forums/spells-569/identify-system-1-00-a-183934/?prev=r%3D20%26status%3Dr2%26page%3D4117:06, 1st Mar 2011 Bribe: http://www.wc3c.net/showthread.php?t=105964 AmbienceTester already does this and so, so much more. I...

Moderator

M

Moderator

http://www.hiveworkshop.com/forums/spells-569/identify-system-1-00-a-183934/?prev=r%3D20%26status%3Dr2%26page%3D4117:06, 1st Mar 2011
Bribe:

http://www.wc3c.net/showthread.php?t=105964

AmbienceTester already does this and so, so much more. I advise learning from it.

Rejected until updated.
 
Level 16
Joined
May 1, 2008
Messages
1,605
The Flood's Fog System 1.0a

Moin moin =)

==== My personal vote: No approval, rejection [1/5] ====

Ok after downloading an testing, I got the following review:

That's all? Sorry but you got so many triggers and only this low effect, just a fog changing. I bet the same effects can be created with a fade filter where you just need an event, a condition and some actions.

Also I'm wondering, why you mix up GUI and Custom Script (jass) that's like. In addition you use this bj "SetTerrainFogExBJ" which can be changed into: "SetTerrainFogEx".

Third, if I path the rect, the fog is not well changed. If I walk from the ice to Dirt terrain place, I get blended by a lightning, that isn't good for the eyes.

And one more point, if you create something like that, you should remember the blink ability. If someone just blinks over the both rects, then the "system" don't show up.

=== Ok what we have now ===
Sorry but for me it isn't something special. You can use a advanced fade filter to create the same effect, without mixing GUI and Jass and lot of triggers. Then you use the BJ and if a unit blink over these rects away, the player will not see the fog fading. All in all, somehow I give a small point for the idea, but thats all and I give rejection, because this doesn't make any sense!

Note: This review is NOTHING against you and NOTHING against your system. This is just my own opinion, who I notice this system.

Greetings and Peace
Dr. Boom
 
Level 19
Joined
Aug 16, 2007
Messages
881
@Dr.Boom,
There's just two triggers for the system? You can actually remove the initialization trigger if you don't want any start fog, so the system can use 1 trigger and the map-script.

Fade filter and fog is not the same?

About the BJ, it came up when I converted the GUI function into JASS, because I didn't knew it in my head.

About the lightning thing, I don't know why it appears as that. Probably because the value changes doesn't appear so good with eachother, it isn't as that with every fog change.

The "enter region" example is just an example. You don't have to do it in this way to change the fog, you may have your own actions.

Thanks for your review though. I'll update this system to try make it better with more options. Hopefully someone finds this useul.

@Super-Sheep,
Complicated? It's one function call to change the fog and the fog is already for local player. The fog will be unique for every player in the map.




EDIT: Dr.Boom, first you rated 2/5 and voted for approve and now you changed it to 1/5 and for rejection, why?
 
Level 16
Joined
May 1, 2008
Messages
1,605
Simple, because I tested it again and more and more I test it, it's become senseless.

Seconds I didn't say fade filter and fog filter are the same, but if you know how, you can have the same effect. Also even if you do it with a fog filter, first it doesn't make sense that you mix GUI and Jass that's like. Use GUI or Jass and you don't need thats like mass actions to create something like this.

That's why I changed the personal vote and this isn't a "system" at all I think.

Also, normally people know that from me, if I see changes, I review the whole thing and change my voting. And if you say, you do more options and improve this, I increase the rating then.

And the last thing, I didn't vote for approve!

Greetings and Peace
Dr. Boom
 
Level 19
Joined
Aug 16, 2007
Messages
881
@Dr. Boom,
Mass actions? Well, it's optimized now. I did update the system to version 1.1a with some changes, read the changelog. Also about fog and fade filters. Doesn't fade filters ruin some of the UI things? Like when you hold your mouse pointer at an ability to read it's description it won't show up if you have an active fade filter?

In my opinion it's a system, I'd like you to review it again and give me some feedback of what things that can be improved?


@88WaRCraFT3,
I'm glad you liked it! :) Also, I've updated the system to version 1.1a, make sure you download this version if you're using the system.
 
Level 16
Joined
May 1, 2008
Messages
1,605
The Flood's Fog System 1.1a

Moin moin =)

== Update review for 1.1a No approve, no rejection, no rating [for now] ==

First of all, I should know I don't hate this system and I don't want harass here. I just note points, why this system isn't approve able and I still got some.

1) In the initialization you set the fog, without checking where there the start unit is. This means if I put the unit on the Dirt Terrain type, the fog still change into the "ice terrain fog".

2) Replace
JASS:
call SetTerrainFogExBJ( 0, start, end, 0, red, green, blue )
with
JASS:
call SetTerrainFogEx(0,start,end,0,red,green,blue)

3) Why you use in both main triggers a loop from 1 - 12?
  • Set TempPlayerGroup = (All players matching ((((Matching player) controller) Equal to User) and (((Matching player) slot status) Equal to Is playing)))
  • Set TempInteger = (Number of players in TempPlayerGroup)
  • Custom script: call DestroyForce(udg_TempPlayerGroup)
and then refer to the TempInteger variable.

If 1 to 12 doesn't mean the amount of players, ignore this!

4) Still, when I move from the ice region to the dirt region, I get blinded by a bright light and when I move from the dirt region to the ice region, the fog directly change to normal. Maybe you can add something like a fading, that if I change the region, the fog fades to normal for 1 or 2 seconds and then change to the matching terrain fog. Looks better in my opinion.

=== This is all for now, so what we got ===
First I agree, MAYBE the rejection was a little to hard at the beginning, but I find this way how you trigger it, complicated. But I look closer to it now and tried to see this system with other mainpoints.
There still are some improvements and for me point 1, 2 and 4 are very important, there for I just change my rejection to non rejection but the rating I gave is still the same.
After I see those changes, I WILL! come back and change it - don't worry

NOTE: .. You know the note! just know that I don't harass you or your system ok? Thanks

Greetings and Peace
Dr. Boom
 
Level 19
Joined
Aug 16, 2007
Messages
881
@Dr. Boom,
1. The initialization trigger is a place there users can modify the start fog for a player. It's just an example and doesn't have to be like that, right? If users want to check where the players' units are and change the fog, then let them. In this example the test units original position is on the "icy" area and is not supposed to be changed.

2. I tried to replace, but somehow it reverted the fog change, I don't know why. The cave area became the icy fog and the icy area became the cave fog...

3. I'll see what I'll do about that.

4. First of all, I didn't get blinded by a bright light when I tested the system before I released it. Are you sure you've got the latest version? Did you change any of the values? Maybe that's the reason then. Also, the fog do fade? It will take x seconds to change the fog depending on the difference between two fogs (the current fog and the new fog).

Anyway, I'll update this ASAP, see what I can do for the moment. Also, I don't think you harass someone, I'm just glad as long you give feedback and such. :)
 
Level 16
Joined
May 1, 2008
Messages
1,605
Moin moin =)

Ok I have to say sorry at this thread. I open the old map not the new one my mistake don't know what happen.

1) In the new version this "blinding" is removed.

bodu7elgayfwwqr9q.jpg


This light was more brighter just for a short period of a second.


2) Also I failed with the new custom script it's:
  • Custom script: call SetTerrainFogEx(0,start,end,0,red*0.01,green*0.01,blue*0.01)
I tested it, the same effect, but without a BJ.

3) But now I detect another thing. You have to leave a small space between the rects like this:
bodudguke8ty5is9a.jpg

Without this space between these rects, you can move very slowly ( right click on the feet on your hero if you want so ) until the fog change into the darker fog. But now if you walk back on the ice, the fog still stay black.
Maybe you should note this in the configurations with a command, that the rects must have a small space.

4) About the init trigger, no I just notice, that you make a comment line and say that you use this fog type in the init, because the hero start in your test map on the ice. Just to make everything clear.

5) The thing is about the from 1 - 12, if that is the value of the played, you have to now, that if there are only 4 players on the map, this waste memory if you always use the full amount of players. ( Nothing noticeable I think, but it's still there ^^ )


Ok but now I'm sure I make the correct thing, notice the correct things and testes the correct map. I wait until you upload next version with this changes, sorry about my last mistake that I open the wrong map ( don't know why I did this .... ) and hope to see a good fog system from you ;)

Greetings and Peace
Dr. Boom
 
Level 16
Joined
May 1, 2008
Messages
1,605
Moin moin =)

BJ's are bad ( not all but most ). But this doesn't make any sense to fix your BJ's because you use GUI and GUI is full of BJ's, so actually ....

( If you use JNGP ( Jass newgen pack ) and convert your GUI trigger to custom text (jass) then you see many red marked things, that are BJ's then ). The most hated Bj is btw:
  • Do nothing
Greetings and Peace
Dr. Boom
 
Level 22
Joined
Nov 14, 2008
Messages
3,256
BJ's are a sub function in JASS which usually calls a native (in C which WC3 is built with). Therefore instead of just calling the native, you call another function which calls the native.

Basic order. Calls a BJ which is a function in the Blizzard.j . That BJ will either call a new BJ or call a native in the Common.j which contains all natives (except UnitAlive and such from Common.ai).

Although some BJs are a huge mess, contains lots of stuff like Turning Cinematic Mode On which contains even more BJ's and more of those.

Since this is not a huge problem in GUI as many GUI functions are small BJ's. But as it was your JASS part of this I thought that you could change that one :D
 
I've decided to give this another looking over, a detailed review, apologies for not doing so before because this deserves some constructive feedback for areas I'm looking at for improvement.

JASS:
function AddFogForPlayer takes real start, real end, real Red, real Green, real Blue, player whichplayer returns nothing
    local integer i = 0

    if (udg_Fog_Player_CurrentFogRed[GetPlayerId(whichplayer) + 1] == Red) then
        set i = i + 1
    endif
          
    if (udg_Fog_Player_CurrentFogGreen[GetPlayerId(whichplayer) + 1] == Green) then
        set i = i + 1
    endif

    if (udg_Fog_Player_CurrentFogBlue[GetPlayerId(whichplayer) + 1] == Blue) then
        set i = i + 1
    endif

    if (i < 3) then
        set udg_Fog_Player_FogZ_Start[GetPlayerId(whichplayer) + 1] = start
        set udg_Fog_Player_FogZ_End[GetPlayerId(whichplayer) + 1] = end
        set udg_Fog_Player_FogRed[GetPlayerId(whichplayer) + 1] = Red
        set udg_Fog_Player_FogBlue[GetPlayerId(whichplayer) + 1] = Blue
        set udg_Fog_Player_FogGreen[GetPlayerId(whichplayer) + 1] = Green
        set udg_Fog_Player_FogFading[GetPlayerId(whichplayer) + 1] = true
   
        call EnableTrigger( gg_trg_Fog_Fade_System )
    endif
endfunction

Here, GetPlayerId(whichPlayer) + 1 is found over and over. That should just be in a local variable "local integer id = GetPlayerId(whichPlayer)"

Red, Green, Blue are names for your "local variables". You don't have to make this change, but local variables are uniformly lowercased first letter, it's one of those things like indenting exactly four spaces. It's common syntax which makes it easier to read and figure out what's what in the script, easier to look over/review.

Your "0.03" timer trigger is very inefficient. I don't quite follow the approach you're using but this does not need arrays to store each player's fog values, just use a normal variable and set it locally for the player. As for the transition, here is a script I used last year for my Time Warp spell's fog-fading:

JASS:
//! zinc

library RetroFade {
/*
 *  The current fade-functionality is very primitive at the moment.  If you have dynamic fog in your
 *  map that changes sometimes, I don't recommend this library for you.
 */
    constant real
    
        DURATION                = 2.00      ,
        MAX_DISTANCE            = 1000.0    ,   /* Players whose cameras are out of this range will not see the fog fade */
        FLICKER_MAGNITUDE       = 300.0     ;   /* Factors between Z-End + this & Z-End - this */
        
    constant boolean
    
        FLICKER                 = true      ;
    
    real fog[];
    integer units[];
    boolean paused = true, want = false, to = true;
    constant integer Fz = 18, FZ = 19, Fd = 20, Fr = 21, Fg = 22, Fb = 23;
    
    function onInit() {
        integer i;  /*    Your fog settings     Retro's fog settings
    Fog type                     |                       |                   Allowed values
    ¯¯¯¯¯¯¯¯                     V                       V                   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯
    |  Z-Start */    fog[0]  = 3000.00   ;     fog[6]  = 1250.0    ; /*      0.00  to  ????
    ---------------------------------------------------------------------------------------
    |    Z-End */    fog[1]  = 5000.00   ;     fog[7]  = 3250.00   ; /*      0.00  to  ????
    ---------------------------------------------------------------------------------------
    |  Density */    fog[2]  = 0.50      ;     fog[8]  = 0.1       ; /*      0.00  to  1.00
    ---------------------------------------------------------------------------------------
    |      Red */    fog[3]  = 1.00      ;     fog[9]  = 0.35      ; /*      0.00  to  1.00
    ---------------------------------------------------------------------------------------
    |    Green */    fog[4]  = 1.00      ;     fog[10] = 0.35      ; /*      0.00  to  1.00
    ---------------------------------------------------------------------------------------
    |     Blue */    fog[5]  = 1.00      ;     fog[11] = 0.00      ; /*      0.00  to  1.00
    ---------------------------------------------------------------------------------------
 */
        for (i = 0; i < 24; i+= 1)  i:units = 0;
        for (i = 0; i < 6;  i+= 1) {
        
            if (i:fog==fog[i + 6]) {
                if (i:fog < 0.999)  i:fog+= 0.001;
                else                i:fog-= 0.001;
            }
            
            fog[i + 12] = (i:fog - fog[i + 6])/(DURATION / RETRO_TIMEOUT);
            fog[i + 18] =  i:fog;
        }
    }
        
    public struct retrofade [] {
    
        private static method handler()-> boolean {
            integer i = 18;
            
            if (!want && paused)
                return false;
         
            static if (FLICKER) {
                if (GetRandomReal(0.0, 2.0)<=RETRO_TIMEOUT)
                    SetTerrainFogEx(0, Fz:fog, GetRandomReal(FZ:fog - FLICKER_MAGNITUDE, FZ:fog + FLICKER_MAGNITUDE), Fd:fog, Fr:fog, Fg:fog, Fb:fog);
            }
            
            if (paused)
                return false;
            
            if (to) while (i < 24) { /* Fade into retro-fog */
            
                if   ( i:fog <= fog[i - 12]) {
                       i:fog  = fog[i - 12];        paused = true;  break;
                } else i:fog -= fog[i -  6];                        i+= 1;
            }
            else while (i < 24) { /* Fade into normal-fog */
            
                if   ( i:fog >= fog[i - 18]) {
                       i:fog  = fog[i - 18];        paused = true;  break;
                } else i:fog += fog[i -  6];                        i+= 1;
            }
            
            SetTerrainFogEx (0, Fz:fog, FZ:fog, Fd:fog, Fr:fog, Fg:fog, Fb:fog);
            
            return false;
        }
    
        module RetroTimerModule;
        
        static method CamCheck (real centerX, real centerY) -> boolean {
         real   cam_x= GetCameraTargetPositionX(), cam_y= GetCameraTargetPositionY();
         return(cam_x >= centerX - MAX_DISTANCE && cam_y >= centerY - MAX_DISTANCE &&
                cam_x <= centerX + MAX_DISTANCE && cam_y <= centerY + MAX_DISTANCE );
        }
        
        static method yes (player whichPlayer, real x, real y) {
            integer id = GetPlayerId(whichPlayer);
            if (GetLocalPlayer() != whichPlayer || whichPlayer == null || id > 11)
                return;
                
            if (CamCheck(x, y)) {
                to = true;
                want = true;
                if (paused)
                    paused = false;
            }
            
            units[id]+= 1;
        }
        
        static method no (player whichPlayer) {
            integer id = GetPlayerId(whichPlayer);
            if (GetLocalPlayer() != whichPlayer || whichPlayer==null || id > 11) 
                return;
                
            units[id]-= 1;
            if (units[id] <= 0) { 
                units[id] = 0;
                to = false;
                want = false;
                if (paused)
                    paused = false;
            }
        }
        
    }
}
//! endzinc

I understand this is in Zinc and I will convert it to JASS, but essentially this is an alternative method which doesn't need a chain of if's during the loop, has an overall shorter loop, and efficiency is extremely important in a 0.03 timer interval. If you are having trouble read it (especially this crappy format I used to code it, even I can barely read it), I will convert it to JASS syntax to make it a more clear, but it is an example approach I would like to see from this library.
 
Top