Jump to content

Zombie Shield Generator


N340

Recommended Posts

Many thanks to NR30 for porting this to Epoch.

 

I reworked the scripts from NR30 to add several features:

  - An ability to limit the number of zombie shield generator's that a player has running at any time which by defalt is set to 1.

 - a requirement that the generator be filled with something after each server restart in order for it to be activated which by default is set to 1 jerry can of fuel and one bag of zombie parts.

 -modified the recipie used to build the generator (2 brief cases gold, 2 metal panels, 2 metal poles, 2 engine parts).

 -moved the code for the shield to a separate file that is called when the player joins the game and which scans an array of known generators for any generators that are on, then deletes or kills zombies near that active generator.

 

Credits:

 

 Freakin Fred for the original zombie shield

 Rosska85, Daimyo21 and the Basebuilding 1.3 team for their implementation

 NR30 for the port to Epoch.

WGC GeekGarage for the original Right Click custom build

Maca134's for the right click script.

KamikazeXeX for porting the right click buildables to epoch 1.0.5.1 with snapBuildPro and PP4L 2.26

 

Implementation:

 

1) download and install the appropriate version of the custom player_build.sqf based on whether or not you run SnapBuild and/or Raymx' Plot Pole for ever.

download the shield folder and place it in your mission folder.

 

 

2) Download the shield folder and place it in your mission folder:

 

https://www.dropbox.com/sh/imlq4wegt1kymh6/AAA5LqTfwNyoCDkfkd_-rsfYa?dl=0

 

3) Install the right click buildables mod from GeekGarage. See the link below for more information.

 

 

 

2)  if you do not have a file called extra_rc.hpp by now, then you can use the one provided in the shield folder. To do this, open your description.ext file, add this at the end.

 

#include "shield\extra_rc.hpp"

 

Otherwise, merge the one I have provided with your existing extra_rc.hpp.

 

4) The Zombie Shield requires that several variables be defined. Either merge the contents of the variables.sqf in the shield folder with your existing custom variables.sqf, if you have one, or add this to your init.sqf

 

call compile preprocessFileLineNumbers "shield\variables.sqf";                //Initilize the Custom Variables

 

after this

 

//Load in compiled functions
call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\variables.sqf";                //Initilize the Variables (IMPORTANT: Must happen very early)

 

 

5) At the end of your init.sqf 

Add this:

// Start Zombie Shield code
[] execVM "shield\ZombieShield.sqf";

 6) If you do not already have a customized fn_selfActions.sqf somewhere, you will need to set one up. An example of a modified fn_selfActions.sqf is included in the shield folder. See the link below for information as to how to do so.

 

http://opendayz.net/threads/self-blood-bag.9063/

 

Modify your fn_selfActions.sqf as shown below.

 

} else {


player removeAction s_player_feeddog;
s_player_feeddog = -1;
player removeAction s_player_waterdog;
s_player_waterdog = -1;
player removeAction s_player_staydog;
s_player_staydog = -1;
player removeAction s_player_trackdog;
s_player_trackdog = -1;
player removeAction s_player_barkdog;
s_player_barkdog = -1;
player removeAction s_player_warndog;
s_player_warndog = -1;
player removeAction s_player_followdog;
s_player_followdog = -1;
};

 

add this:

 

// =======================================Zombie Shield Generator ===============================================


if(_cursorTarget isKindOf "Garbage_container") then {
private ["_running","_filled","_hasParts"];
_running = _cursorTarget getVariable ["ZombieShieldOn",false];
_filled = _cursorTarget getVariable ["ZombieShieldFilled",false];
if (_running) then {
if (s_player_ZombieShield_off < 0) then {
s_player_ZombieShield_off = player addAction [format[("" + ("Stop Zombie Shield") +""),_adminText], "shield\Toggle.sqf", [_cursorTarget, "stop"], 6, true, true, "", ""];
};
} else {
if (_filled) then {
if (s_player_ZombieShield_on < 0) then {
s_player_ZombieShield_on = player addAction [format[("" + ("Start Zombie Shield") +""),_adminText], "shield\Toggle.sqf", [_cursorTarget, "start"], 6, true, true, "", ""];
};
} else {
if (s_player_ZombieShield_fill < 0) then {
// Check for needed parts: ItemZombieParts and ItemJerrycan
_hasParts = (("ItemJerrycan" in _magazinesPlayer) && ("ItemZombieParts" in _magazinesPlayer));
if (_hasParts) then {
s_player_ZombieShield_fill = player addAction [format[("" + ("Fill and Start Zombie Shield (requires 1 filled Jerry Can and 1 bag Zombie Parts)") +""),_adminText], "shield\Toggle.sqf", [_cursorTarget, "fill"], 6, true, true, "", ""];
} else {
if (s_player_ZombieShield_fill < 0) then {
s_player_ZombieShield_fill = player addAction [format[("" + ("You need 1 filled Jerry Can and 1 bag Zombie Parts to Start the Shield") +""),_adminText], "shield\Toggle.sqf", [_cursorTarget, "void"], 6, true, true, "", ""];
};
};
};
};
};

} else {
player removeAction s_player_ZombieShield_on;
s_player_ZombieShield_on = -1;
player removeAction s_player_ZombieShield_off;
s_player_ZombieShield_off = -1;
player removeAction s_player_ZombieShield_fill;
s_player_ZombieShield_fill = -1;
};
// End Zombie Shield Generator

 

and below this:

 

player removeAction s_player_barkdog;


s_player_barkdog = -1;
player removeAction s_player_warndog;
s_player_warndog = -1;
player removeAction s_player_followdog;
s_player_followdog = -1;

 

add this:

 

// Handles for Zombie Shield Generator


player removeAction s_player_ZombieShield_on;
s_player_ZombieShield_on = -1;
player removeAction s_player_ZombieShield_off;
s_player_ZombieShield_off = -1;
player removeAction s_player_ZombieShield_fill;
s_player_ZombieShield_fill = -1;

 

Pack your mission.pbo and you are done.

Link to comment
Share on other sites

  • 1 month later...

Many thanks to NR30 for porting this to Epoch.

 

I reworked the scripts from NR30 to add several features:

  - An ability to limit the number of zombie shield generator's that a player has running at any time which by defalt is set to 1.

 - a requirement that the generator be filled with something after each server restart in order for it to be activated which by default is set to 1 jerry can of fuel and one bag of zombie parts.

 -modified the recipie used to build the generator (2 brief cases gold, 2 metal panels, 2 metal poles, 2 engine parts).

 -moved the code for the shield to a separate file that is called when the player joins the game and which scans an array of known generators for any generators that are on, then deletes or kills zombies near that active generator.

 

Credits:

 

 Freakin Fred for the original zombie shield

 Rosska85, Daimyo21 and the Basebuilding 1.3 team for their implementation

 NR30 for the port to Epoch.

WGC GeekGarage for the original Right Click custom build

Maca134's for the right click script.

 

Implementation:

 

In your custom variables.sqf, add this block of code at the end:

 

/**************************************************** Zombie Shield Generator Settings ****************************************************/

EnableZShield = 1; //Enable toggleable zombie shield generator/ 1 = Enabled // 0 = Disabled (If disabled, players can still build shield generators, they just wont do anything)

//TypeOfZShield = "CDF_WarfareBUAVterminal"; //Type of object used for Zombie Shield, included this only in case some maps have this object banned

//AllZShieldTypes = ["CDF_WarfareBUAVterminal"]; //DO NOT REMOVE ITEMS FROM THIS ARRAY, you can ADD an object class if you want a different building to be used as a Zombie Shield Generator!

ActivatedZombieShields = [];

MaxZShields = 1; //Maximum number of zombie shield generators a player can be added to, default is 1

ZShieldRadius = 50; //Radius for zombie shield generator, default is 50

ZShieldClean = 1; //Delete Zombies when they enter active shield radius/ 1 = Enabled // 0 = Disabled (If disabled, zombies will be killed but not deleted, could lead to zombie loot farming)

/******************************************************** END *************************************************************************/

 

At the end of your init.sqf 

Add this:

// Start Zombie Shield code
[] execVM "shield\ZombieShield.sqf";

 in your fn_selfActions.sqf below this:

 

} else {

player removeAction s_player_feeddog;

s_player_feeddog = -1;

player removeAction s_player_waterdog;

s_player_waterdog = -1;

player removeAction s_player_staydog;

s_player_staydog = -1;

player removeAction s_player_trackdog;

s_player_trackdog = -1;

player removeAction s_player_barkdog;

s_player_barkdog = -1;

player removeAction s_player_warndog;

s_player_warndog = -1;

player removeAction s_player_followdog;

s_player_followdog = -1;

};

 

add this:

 

// =======================================Zombie Shield Generator ===============================================

if(_cursorTarget isKindOf "Garbage_container") then {

private ["_running","_filled","_hasParts"];

_running = _cursorTarget getVariable ["ZombieShieldOn",false];

_filled = _cursorTarget getVariable ["ZombieShieldFilled",false];

if (_running) then {

if (s_player_ZombieShield_off < 0) then {

s_player_ZombieShield_off = player addAction [format[("" + ("Stop Zombie Shield") +""),_adminText], "shield\Toggle.sqf", [_cursorTarget, "stop"], 6, true, true, "", ""];

};

} else {

if (_filled) then {

if (s_player_ZombieShield_on < 0) then {

s_player_ZombieShield_on = player addAction [format[("" + ("Start Zombie Shield") +""),_adminText], "shield\Toggle.sqf", [_cursorTarget, "start"], 6, true, true, "", ""];

};

} else {

if (s_player_ZombieShield_fill < 0) then {

// Check for needed parts: ItemZombieParts and ItemJerrycan

_hasParts = (("ItemJerrycan" in _magazinesPlayer) && ("ItemZombieParts" in _magazinesPlayer));

if (_hasParts) then {

s_player_ZombieShield_fill = player addAction [format[("" + ("Fill and Start Zombie Shield (requires 1 filled Jerry Can and 1 bag Zombie Parts)") +""),_adminText], "shield\Toggle.sqf", [_cursorTarget, "fill"], 6, true, true, "", ""];

} else {

if (s_player_ZombieShield_fill < 0) then {

s_player_ZombieShield_fill = player addAction [format[("" + ("You need 1 filled Jerry Can and 1 bag Zombie Parts to Start the Shield") +""),_adminText], "shield\Toggle.sqf", [_cursorTarget, "void"], 6, true, true, "", ""];

};

};

};

};

};

} else {

player removeAction s_player_ZombieShield_on;

s_player_ZombieShield_on = -1;

player removeAction s_player_ZombieShield_off;

s_player_ZombieShield_off = -1;

player removeAction s_player_ZombieShield_fill;

s_player_ZombieShield_fill = -1;

};

// End Zombie Shield Generator

 

and below this:

 

player removeAction s_player_barkdog;

s_player_barkdog = -1;

player removeAction s_player_warndog;

s_player_warndog = -1;

player removeAction s_player_followdog;

s_player_followdog = -1;

 

add this:

 

// Handles for Zombie Shield Generator

player removeAction s_player_ZombieShield_on;

s_player_ZombieShield_on = -1;

player removeAction s_player_ZombieShield_off;

s_player_ZombieShield_off = -1;

player removeAction s_player_ZombieShield_fill;

s_player_ZombieShield_fill = -1;

 

Open your extra_rc.hpp and add this- note that you must adjust the path to player_build.sqf to match its location in your mission.pbo  :

 

class PartEngine {

class ZombieShield {

text = "Zombie Shield";

script = "[""Garbage_container"",[""ItemToolbox"",""ItemEtool""],[[""ItemPole"", 2],[""metal_panel_kit"", 2],[""PartEngine"", 2],[""ItemBriefcase100oz"", 2]],[0,3,0.5]] execVM ""custom\PlotForLifev2\player_build.sqf"";";

};

};

 

Download the shield folder containing the toggle.sqf and shield.sqf files which run the generator and drop it into your mission folder:

 

https://www.dropbox.com/sh/imlq4wegt1kymh6/AAA5LqTfwNyoCDkfkd_-rsfYa?dl=0

 

Heya mate, 

 

Ive tried this, but i dont get the right click option? Is there something i forgot to do maybe? Thanks in advance.

Link to comment
Share on other sites

AFTER 4 HOURS OF TRYING TO INSTALL THIS SCRIPT 

 

 

i get the rightclick option to build Zombie Shield then nothing happened, then when i go to build again, it just says crafting in progress !! !

Edit: Actually messed up the ExtraRc, i get the option too now, and same thing what he said.

Anyone know how to fix this?

Link to comment
Share on other sites

Edit: Actually messed up the ExtraRc, i get the option too now, and same thing what he said.

Anyone know how to fix this?

I realize looking at my post that I left out one step. You need to download a custom ui_selectSlot.sqf (for which I credit maca) which I have added to the drop box.

Add this file to whatever folder you keep custom scripts in.

Once you have done that, you need to add the following to your custom compiles.sqf, or create one and call it from your init.sqf. There are quite a few posts around on how to do this, but if you get stuck i'm happy to try to help.

 

// Maca's Right Click Script

// Used to actuate all of the custom buildables, build bike, and suicide scripts

player_selectSlot =  compile preprocessFileLineNumbers "YOUR_PATH\ui_selectSlot.sqf";

Link to comment
Share on other sites

  • 5 months later...

I've adapted this script to work with Extended Vehicle Deployment () so I can pack the generator, I have added this to my fn_selfActions.sqf for EVD, which allows packing of anything deployed with it:

	//Pack Vehicles - EVD
	if (_typeOfCursorTarget in EVDVehicleArray && !(locked _cursorTarget) && (damage _cursorTarget < 1) && (_cursorTarget distance player <= 3)) then {
		if (s_player_packvehicle < 0) then {
			s_player_packvehicle = player addAction ["Pack Vehicle", "custom\EVD\EVD_pack.sqf",_cursorTarget, 0, false, true, "",""];
		};
	} else {
		player removeAction s_player_packvehicle;
		s_player_packvehicle = -1;
	};

I use "SkeetMachine" for the model for the zombie shield and I added that to the EVDVEhicleArray. What I am wondering about is this: The option to turn the shield on or off is always there when looking at the shield generator, no matter it's status, so if it's on, I still have the option to turn it on (Although doing so does nothing). Is there a way to make it so only the option to turn it off will show up when it's running, and is there a way to make it so only the option to turn it on will show up when it's off? Also, anyway to make a sound loop so that sound you hear when you turn it on keeps going so long as it's running?

Link to comment
Share on other sites

 

So, using the original script on the first page, will the generator get saved to the database so it's persistent across restarts? I'm going to test this on my server in a bit and was just wondering.

 

Also, what does this part of the script = line do?

[0,6.5,2.5]

That's the offset from the player's position. 

Link to comment
Share on other sites

Sorry to double post, but I am having an issue where the "Zombie Shield On" option stays on the scroll menu until I exit the server and come back. Obviously it's an issue with my fn_selfActions.sqf. Could someone look it over and tell me if they see something wrong?

 

http://pastebin.com/6Y6prJ0X

 

Anyone able to take a look? I can't figure it out.

Link to comment
Share on other sites

Anyone able to take a look? I can't figure it out.

} else {
                        s_player_ZombieShield_on = -1;
                        player removeAction s_player_ZombieShield_off;
                        s_player_ZombieShield_off = -1;
                };

Should be

} else {
                        player removeAction s_player_ZombieShield_on;
                        s_player_ZombieShield_on = -1;
                        player removeAction s_player_ZombieShield_off;
                        s_player_ZombieShield_off = -1;
                };
Link to comment
Share on other sites

  • 10 months later...
if(_player_deleteBuild) then {
		if (s_player_deleteBuild < 0) then {
			s_player_deleteBuild = player addAction [format[localize "str_actions_delete",_text], "\z\addons\dayz_code\actions\remove.sqf",_cursorTarget, 1, true, true, "", ""];
		};
	} else {
		player removeAction s_player_deleteBuild;
		s_player_deleteBuild = -1;
	};
Then past this under it:

_lever = cursorTarget;

//Zombie Shield
	if (_cursorTarget isKindof TypeOfZShield) then {
		if (EnableZShield == 1) then {
			if (s_player_ZombieShield_on < 0) then {
				s_player_ZombieShield_on = player addAction [format[("<t color=""#FFF700"">" + ("Zombie Shield On") +"</t>"),_adminText], "shield\ZombieShield.sqf", [_lever, true], 6, true, true, "", ""];
			};
			if (s_player_ZombieShield_off < 0) then {
				s_player_ZombieShield_off = player addAction [format[("<t color=""#FFF700"">" + ("Zombie Shield Off") +"</t>"),_adminText], "shield\ZombieShield.sqf", [_lever, false], 6, false, true, "", ""];
			};
		} else {
			if (s_player_ZombieShield_on < 0) then {
				s_player_ZombieShield_on = player addAction [format[("<t color=""#FFF700"">" + ("Zombie Shields are disabled on this server") +"</t>"),_adminText], "", [], 6, false, true, "", ""];
			};
			player removeAction s_player_ZombieShield_off;
			s_player_ZombieShield_off = -1;
		};
	} else {
		player removeAction s_player_ZombieShield_on;
		s_player_ZombieShield_on = -1;
		player removeAction s_player_ZombieShield_off;
		s_player_ZombieShield_off = -1;
	};
//End Shield
4. Then find this line in fn_selfactions.sqf

if(DZE_AllowForceSave) then {
		//Allow player to force save
		if((_isVehicle or _isTent) and !_isMan) then {
			if (s_player_forceSave < 0) then {
				s_player_forceSave = player addAction [format[localize "str_actions_save",_text], "\z\addons\dayz_code\actions\forcesave.sqf",_cursorTarget, 1, true, true, "", ""];
			};
		} else {

***************Replace STUFF IN HERE
		
			};
	};
Where I put *******************Replace STUFF IN HERE, delete everything there and add this in its place:

			s_player_ZombieShield_on = -1;
			player removeAction s_player_ZombieShield_off;
			s_player_ZombieShield_off = -1;
			player removeAction s_player_forceSave;
			s_player_forceSave = -1;
5. Open your custom variable.sqf and paste this at the bottom, this is also where you can customize all your settings.

/**************************************************** Zombie Shield Generator Settings ****************************************************/
/**************************************************** Zombie Shield Generator Settings ****************************************************/
	EnableZShield				= 1; //Enable toggleable zombie shield generator/ 1 = Enabled // 0 = Disabled (If disabled, players can still build shield generators, they just wont do anything)
	TypeOfZShield				= "LightPole_DZ"; //Type of object used for Zombie Shield, included this only in case some maps have this object banned
	AllZShieldTypes			= ["LightPole_DZ"]; //DO NOT REMOVE ITEMS FROM THIS ARRAY, you can ADD an object class if you want a different building to be used as a Zombie Shield Generator!
	MaxZShields				= 1; //Maximum number of zombie shield generators a player can be added to, default is 1
	ZShieldRadius				= 50; //Radius for zombie shield generator, default is 50
	ZShieldClean				= 0; //Delete Zombies when they enter active shield radius/ 1 = Enabled // 0 = Disabled (If disabled, zombies will be killed but not deleted, could lead to zombie loot farming)
                                       
                                       

 

I have tested this on my servers and works fine. If you have any complications please let me know and ill be happy to help.

 

Here is a pre compiled Cherno mission PBO with a working zombie shield and the extra_RC.hpp included. You can build it with an Engine and 2 poles like you would any other object

https://www.dropbox.com/s/gmibobakfec80za/ZHIELD.pbo

 

Credit for the original code goes to the guys from original BB 1.2.

Use the light pole it is cleaner and less bulky best of all no work LOL 

Link to comment
Share on other sites

  • 10 months later...
  • 8 months later...

So Zed Shield Generator works fine for 1.0.6.1A but there is one problem I'm having. It duplicates on the mouse wheel menu infinitely. I edited my selfactions.sqf and moved the coding around to different places and managed to get it to where it's not so aggressively doing. It still duplicates the Zed Shield On option, but only does it based on how many times you look at the object. The options will not clear from the mousewheel menu until you lobby log either. 


Otherwise it works, I just don't know where I should place the code to keep it from doing an infinite loop. Leaving it in the positions that worked in previous updates causes aggressive spamming. I moved them around closer to locations where virtual garage seems to work fine, and it still spams but like I said not nearly as badly.

Any thoughts?

Link to comment
Share on other sites

1 hour ago, Runewulv said:

So Zed Shield Generator works fine for 1.0.6.1A but there is one problem I'm having. It duplicates on the mouse wheel menu infinitely. I edited my selfactions.sqf and moved the coding around to different places and managed to get it to where it's not so aggressively doing. It still duplicates the Zed Shield On option, but only does it based on how many times you look at the object. The options will not clear from the mousewheel menu until you lobby log either. 


Otherwise it works, I just don't know where I should place the code to keep it from doing an infinite loop. Leaving it in the positions that worked in previous updates causes aggressive spamming. I moved them around closer to locations where virtual garage seems to work fine, and it still spams but like I said not nearly as badly.

Any thoughts?

added it to your variables.sqf? aswell as the bottom of your self actions.sqf?

Link to comment
Share on other sites

On 8/13/2017 at 5:37 AM, Runewulv said:

yes, i've used this same script for a long time. 

could you inbox your selfactions.sqf and the generator script? Happy to have a look :)

Runewulv was missing

 //Engineering

    player removeAction s_player_ZombieShield_on;

from fn_selfactions.sqf

All fixed up now :D

Link to comment
Share on other sites

  • 1 year later...

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
×
×
  • Create New...