Jump to content

DayZ-Style Portable Generators for A3E


Grahame

Recommended Posts

I got certain configs updated in the EpochCore client files allowing a few extra nice features to be deployed in A3/Epoch, and I'll start off by posting the information to set up portable generators to allow fuel pumps to be used for refueling vehicles if auto-refueling is turned off on your server. 

Installation Instructions

(1) Add the portable generator "kit" to your loot tables and trader price lists. The class name is KitGenerator

(2) Add the files in this downloadable archive to a folder in your mission called, for example, sounds:

https://www.dropbox.com/s/75gq2rezy1tcbe2/generator_sounds.zip?dl=0

The license file is required! It is a Creative Commons Attribution Only license for the sound file.

(3) Add the following lines to your mission file's custom description.ext (replacing the path for the generator1.ogg sound with the location in which you put it):

// Portable Generator Sounds

class CfgSFX
{
	class Generator
	{
		sounds[] = {"Generator"};
		name = "Generator";
		Generator[] = {"sounds\generator1.ogg","db+10",1,200,1,0,0,0};
		Empty[] = {"",0,0,0,0,0,0,0};
	};
};

class CfgVehicles // NOTE: CfgVehicles definitions are only permitted in description.ext for sound sources. It cannot be used for CfgVehicles customizations
{
	class PortableGenerator
	{
		sound = "Generator"; 
	};
};

(4) Create a file in the folder of your mission file where you store your own scripts, e.g. custom called PortableGenerator.sqf and paste the following code into it:

  Reveal hidden contents

(5) Add the following lines to your mission's init.sqf (replacing the path with whatever you used in step (4)):

if(hasInterface) then{
	PortableGenerator  = compileFinal  preprocessFileLineNumbers "custom\PortableGenerator.sqf";
};

(6) Add the following to epoch_config/Configs/CfgItemInteractions.hpp:

    class KitGenerator : Item_Build_base
    {
        buildClass = "Generator_EPOCH";
    };

(7) Add the following to epoch_config/Configs/CfgBaseBuilding.hpp:

	class Generator_EPOCH : Default
    {
        removeParts[] = {{"KitGenerator",1}};
        GhostPreview = "Generator_Ghost_EPOCH";
        staticClass = "Generator_EPOCH";
        simulClass = "Generator_SIM_EPOCH";
        limitNearby = 2;
        bypassJammer = 1;
    };
    class Generator_SIM_EPOCH : Generator_EPOCH
    {
        removeParts[] = {};
    };
    class Generator_Ghost_EPOCH : Generator_SIM_EPOCH {};

(8) Add the following code to epoch_config/Configs/CfgActionMenu/cfgActionMenu_target.hpp:

// Portable Generators

class generator_refill
{
	condition = "((dyna_cursorTarget isKindOf 'Generator_EPOCH') && !(dyna_cursorTarget getVariable [""GeneratorFueled"",false]) && !(dyna_cursorTarget getVariable [""GeneratorRunning"",false]))";
	action = "[dyna_cursorTarget, 2] call PortableGenerator;";
	icon = "x\addons\a3_epoch_code\Data\UI\buttons\vehicle_refuel.paa";
	tooltip = "Refuel generator";
};

class generator_start
{
	condition = "((dyna_cursorTarget isKindOf 'Generator_EPOCH') && (dyna_cursorTarget getVariable [""GeneratorFueled"",false]) && !(dyna_cursorTarget getVariable [""GeneratorRunning"",false]))";
	action = "[dyna_cursorTarget, 1] call PortableGenerator;";
	icon = "x\addons\a3_epoch_code\Data\UI\buttons\Replace_Engine.paa";
	tooltip = "Start generator";
};

class generator_stop
{
	condition = "((dyna_cursorTarget isKindOf 'Generator_EPOCH') && (dyna_cursorTarget getVariable [""GeneratorRunning"",false]))";
	action = "[dyna_cursorTarget, 0] call PortableGenerator;";
	icon = "x\addons\a3_epoch_code\Data\UI\buttons\Remove_Engine.paa";
	tooltip = "Stop generator";
};

RePBO your mission file and upload it to the server. That should be it.

Link to comment
Share on other sites

Just thought of one more thing that should be added - not a big thing but you should be not able to remove the generator and get the kit back if it is still running. Not a big thing cause the pumps do get zeroed at restart with autorefueling disabled but it would be important immersion wise

Will test code and update when I can (soon)

Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...