Jump to content

[WIP] Fog On Command


Deathcall

Recommended Posts

Hello everyone.

 

I'm Deathcall. I used to work as a scripter and general maintenance guy for the DayZ Lingor server "The Hunting Grounds". Sadly, with all the screwy things happening with DayZ Commander and the player base steady decline, I've found myself without work.

 

So well, after that small intro, I guess we should get down to business.

 

I've seen that a LOT of people seem to have problems making "fog" work in their servers, so I'd like to give something back to the community and share with you all how I managed to do it.

 

First, you'll need the Admin Tools script installed. The commands to bring in and despawn the fog have been worked into the admin tools script for easy handling. You could probably just make up your own admin action panel and work the commands in there, but if you are able to do that you probably don't need my help telling you how to adapt these scripts.

 

Okay, so... step by step:

 

1. Unpack your mission.pbo (with AdminTools already installed in it).

2. Go into your admin tools folder.

3. Open up admintoolsmain.sqf

4. Below this  (line 3 aprox)

_pathtovehicles = "admintools\vehicles\";

add this

_pathtoadminfog = "admintools\custom\Admin_Fog\";

5. Below this (line 13 aprox)

_EXECscript6 = '["%1"] execVM "admintools\crates\%2"';

add this

_EXECscript10 = 'player execVM "'+_pathtoadminfog+'%1"';

6. Now, look for this block (should be right below what you just modified)

if ((getPlayerUID player) in AdminList) then { // Admins
	epochmenustart = [
	["",true],
		["-- Epoch Admin Tools (Level: Admin) --", [], "", -5, [["expression", ""]], "1", "0"],
		["Admin Menu >>", [], "#USER:AdminMenu", -5, [["expression", ""]], "1", "1"],
		["Vehicle Menu >>",[],"#USER:VehicleMenu",-5,[["expression",""]],"1","1"],	
		["Crate Menu >>",[],"#USER:CrateMenu",-5,[["expression",""]],"1","1"],
		["Epoch Menu >>", [], "#USER:EpochMenu", -5, [["expression", ""]], "1", "1"],			
		["Weapon/Item Kits >>", [], "#USER:WeaponMenu", -5, [["expression", ""]], "1", "1"],
		["Skin Change Menu >>", [], "#USER:AdminSkinsMenu", -5, [["expression", ""]], "1", "1"],
		["", [], "", -5, [["expression", ""]], "1", "0"],
			["Main Menu", [20], "#USER:epochmenustart", -5, [["expression", ""]], "1", "1"]		
	];

and add this line just below "Skin Change Menu"

["Admin Fun Menu >>", [], "#USER:AdminFunMenu", -5, [["expression", ""]], "1", "1"],

7. Now, go to the end of the file and just above this

showCommandingMenu "#USER:epochmenustart";

add the following

AdminFunMenu = 
[
	["",true],

                ["Admin Fog", [2], "#USER:AdminFog", -5, [["expression", ""]], "1", "1"],
		["", [-1], "", -5, [["expression", ""]], "1", "0"],
				["Exit", [13], "", -3, [["expression", ""]], "1", "1"]
];
AdminFog =
[
    ["",true],
        ["Spawn Fog", [2],  "", -5, [["expression", format[_EXECscript10,"AF - Bring_Fog.sqf"]]], "1", "1"],
        ["Remove Fog", [3],  "", -5, [["expression", format[_EXECscript10,"AF - Remove_Fog.sqf"]]], "1", "1"],
        ["", [-1], "", -5, [["expression", ""]], "1", "0"],
            ["Exit", [13], "", -3, [["expression", ""]], "1", "1"]
];

8. Save and close the file.

9. Go to the AdminTools folder again and create a folder inside it named "custom".

10. Inside the "custom" folder create yet another folder named "Admin_Fog".

11. Inside the "Admin_Fog" folder create a new .sqf file named "AF - Bring_Fog.sqf" and add the following code to it

AF_FogPos = getPosATL player;

AdminFog = createMarker ["AdminFog", AF_FogPos];
AdminFog setMarkerType "Empty";
AdminFog setMarkerBrush "Solid";

_nil = ["AdminFog",
        500,    // Maximumdistance
        1,      // Minimumdistance
        200,    // Count of clouds
        20,     // Minimumsize of clouds
        40,     // Maximumsize of clouds
        0.5,    // Height of clouds (must be a bit below the ground to look realistic)
        0.5,    // Respawntime of clouds
        0.6,    // Transparency
        1,1,1,  // Color of clouds
        13,     // Remove-speed of clouds
        12,     // Minimumlifetime of clouds
        15,     // Maximumlifetime of clouds
        true,   // true = The fog will be effected by wind (for no wind effect: false)
        0.5,    // Windstrength (acts only when the wind effect is 'true')
        2.1,    // Random-direction-period(in seconds) (acts only when the wind effect is 'true')
        0.1,    // Random-direction-intensity (acts only when the wind effect is 'true')
        4,6,0,  // Move-direction-speed (x,y,z) - same effect as wind, but constant and adjustable(acts only when the wind effect is 'false')
        0,      // Stardaytime (the fog will spawn when the ingametime is 00:00)
        24]     // Enddaytime (the fog will despawn when the ingametime is 24:00)
        execFSM "custom\scripts\Fog.fsm";

// _nil = ["AdminFog",500,1,200,20,40,0.5,0.5,0.6,1,1,1,13,12,15,true,0.5,2.1,0.1,4,6,0,0,24]execFSM "custom\scripts\Fog.fsm";

AF_bringFog = true;
publicVariable "AF_bringFog";

sleep 1;

AF_bringFog_JIP = true;
publicVariable "AF_bringFog_JIP";

12. Inside the same folder create another fresh .sqf, name it "AF - Remove_Fog.sqf" and paste the following code in it

deleteMarker "AdminFog";

sleep 1;

AF_bringFog_JIP = false;
PublicVariable "AF_bringFog_JIP";

publicVariable "AF_removeFog";

13. Open up your init.sqf file (mission root folder) and paste the following code at the bottom

// SERVER EVENT HANDLERS
[] execVM "custom\compiles\serverEventHandlers.sqf";

14. If you don't have it, create a folder named "custom" on your mission root folder.

15. If you don't have it, create a folder named "compiles" inside your "custom" folder.

16. Create a fresh .sqf inside your "compiles" folder, name it "serverEventHandlers.sqf" and paste the following code in it

/*------------------------------------------------------------------------------*/
/***************************ADMIN FOG HANDLERS***********************************/
/*------------------------------------------------------------------------------*/
//////////////////////////////////////////////////////////////////////////////////

if (isNil "AF_bringFog") then {AF_bringFog = false};

"AF_bringFog" addPublicVariableEventHandler {_nil = ["AdminFog",500,1,200,20,40,0.5,0.5,0.6,1,1,1,13,12,15,true,0.5,2.1,0.1,4,6,0,0,24]execFSM "custom\scripts\Fog.fsm";};

if (isNil "AF_bringFog_JIP") then {AF_bringFog_JIP = false};

if (AF_bringFog_JIP) then {_nil = ["AdminFog",500,1,200,20,40,0.5,0.5,0.6,1,1,1,13,12,15,true,0.5,2.1,0.1,4,6,0,0,24]execFSM "custom\scripts\Fog.fsm";};

"AF_removeFog" addPublicVariableEventHandler {deleteMarker "AdminFog"};

17. If you don't have it, create a "scripts" folder inside your "custom" folder.

18. Download the file named "Fog.fsm" from this site (armaholic) and paste it inside the "scripts" folder.

19. Pack your mission.pbo and upload.

20. You are done.

 

------

 

So that's my tutorial on how to allow admins to spawn fog on command.

 

Did you make the fog script?

 

No, the actual Fog Script, the thing that creates the clouds and makes them move and stuff was made by Rockhound. All credit goes to him. I just came up with an "easy" way to make it so admins can use it at their will.

 

How does it actually work?

 

Well, I've added a new menu to your admin tools panel named "Admin Fun". When you access it in-game, you'll see another menu named "Admin Fog" (I have some other fun things in my own menu but this thread is about fog), once you access THAT you'll see two options. One to bring in the fog and another one to despawn it.

 

Is it JIP (join in progress) compatible?

 

YES... And it took me a lot of work to make it so to be honest. I'm by no means a savvy guy when it comes to scripting, so to make it so the fog doesn't despawn when you log out and come back in took me a good day or two of hair-pulling and cursing.

 

Does it affect performance?

 

I know for a fact that heavy fog can adversely affect players with low end machines. It might even affect people with medium end ones to be honest. I myself am in the middle range and I do suffer an FPS drop when I bring it in, but I also play with a lot of latency so I don't know just HOW much is the fog and how much is the ping. Bottom line, YES, it does cost you a few frames.

 

Can I tweak the fog?

 

Yes you can. There's a tutorial for this in the "fog.fsm" file made by the creator of the script. I copied it to the "AF - Bring_Fog.sqf" file as well as an easy reference. Tweaks to the fog should be done on the "AF - Bring_Fog.sqf" file and then be copied over to the "serverEventHandlers.sqf". Make sure all your values are the same or people might be seeing different types of fog.

 

Can more than one admin spawn fog at the same time?

 

No, currently not. The way I scripted it, the marker that gives the fog it's position only has one name... not sure what would happen if two admins tried to bring in fog at the same time. Best way to use this is to always use the despawn command before you bring in another batch of fog. I'm sure someone with a bit more knowledge can solve this problem though.

 

Does it work with this or that antihack script?

 

Probably not. I've never had to work in a server with one of those payed antihack tools, so I scripted it without them in mind. If I had to guess, I'd say you'll probably have to whitelist a bunch of things to make this script work.

 

Does it work in this or that map?

 

I tried it in Lingor, worked with no problems. I haven't tested it, but I think it should work on any map.

 

Does it work in this or that mod?

 

I know for sure it works in DayZ Lingor and DayZ Epoch Lingor. Most likely will work with most Epoch mods... not so sure with others. Mods that have their own fog mechanics might have conflicts with it, but I'm not sure.

 

Can you help me make it work in my server?

 

I could try, but no promises.

 

----

 

That's all the possible questions I could think off, if you have another, don't hesitate to ask.

Link to comment
Share on other sites

this works but only I can see the fog...

 

anyone know how to get it serverside for all to see ???

 

Everyone should be able to see the fog. That's why I added in the event handlers in step 16.

 

Check your personal and server rpt logs for errors. Maybe there's a problem loading them up.

Link to comment
Share on other sites

This works perfectly for me, I load it in through Infistar as I don't use epoch admin tools but it works just the same.

Add's a nice effect at night with full moon nights enabled.

 

Glad to hear it works with Infistar, did you have to do anything in particular or it just worked "out the box"?

Link to comment
Share on other sites

any pictures or a video?

I seen the fog first hand when I was Deathcalls server waay back in the dayz, dunno if you want to take my word for it but it looked pretttty neat IMO.

@Deathcall

Thanks for the tut, seen you explain how to use the fog.fsm on open dayz minus the whole admin tools functionality. I have been trying to make a custom menu however without admin tools using the following guide...

Sorry if it is a dumb question but could I just follow along here but instead of using admin tools, apply hambeast's guide more in specifically "Lesson 3: PV security" to this process?

I was trying to get this all working through the server pbo, did not work out to well however, I assume it needs to be a client side event?

Link to comment
Share on other sites

This works perfectly for me, I load it in through Infistar as I don't use epoch admin tools but it works just the same.

Add's a nice effect at night with full moon nights enabled.

Oh I did not see this, I guess that answered my question! Mind letting me know how you got infistar to use this? PM or something *shrugs*

Link to comment
Share on other sites

 @justcametomind

 

From my personal experience, trying to do this through the server.pbo was not possible... at least not for me. There might be a more intricate way using variables and such, but as I said, my coding skills are sub-par... I'm just a guy with a lot of time and a lot of patience.

 

I actually used Hambeast guide to craft this script too. It was really handy.

Link to comment
Share on other sites

Basically for Infistar, make yourself a new menu entry (I put mine in weather under all the other weather settings). Make a function called spawnfog (or similar) and removefog and link those menu items to them.

Use the code from the 2 SQF files Bring_Fog and Remove_Fog and paste those directly into the functions. Since this is executed on each client it has to be mission side, so the Fog.fsm file must go in your mission folder and you have to create the serverEventHandler.sqf file in the mission root as well which is called from the mission init as above.

 

From there, Infistar just alters the values of the variables and publishes them to all clients as this version does. pretty simple.

If anyone want's a proper code run through to get it working just let me know.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...