Jump to content

Zombie-Free Bases


Recommended Posts

I've been fielding complaints from some of my players that there just isn't a way to build a base in towns, as the zombie spawn just means they get killed while trying to build (and I personally feel that you should be able to have a base in a town and a way to keep it safe from zombies that run through the walls and barricades).  I decided to address that by modifying the ZombieShield script I've been using to keep my admin base safe.

 

What this does, is gives a predefined area around the plot pole where zombies will be automatically teleported away when they spawn.  For starters, in your configuration area of the init.sqf, add the following:

dayz_poleSafeArea = 30; // Default = 30m, the buildable distance

At the bottom of your init.sqf, add the following:

[] execVM "custom\base_SafeArea.sqf";

Now, create a folder in the same directory as your mission's init.sqf called "custom".  Within that folder, create a new file called "base_SafeArea,sqf" with the following contents:

//---------------------------------------------------------------------
// Epoch Base Safe Area
// By MadMartyr
// Modified from generic ZombieShield code by felixberndt and meat
// http://opendayz.net/threads/prevent-zombie-spawning.8799/#post-32461
//---------------------------------------------------------------------


while {true} do {
  sleep 10;


  // No Zeds near Plot Poles
  _playerPos = getPos player;
  _nearPole = nearestObject [_playerPos, "Plastic_Pole_EP1_DZ"];
  if (!isNull _nearPole) then {
    _pos2 = getPos _nearPole;
    _zombies2 = _pos2 nearEntities ["zZombie_Base", dayz_poleSafeArea];
    _count2 = count _zombies2;
    for "_i" from 0 to (_count2 -1) do
    {
      _zombie2 = _zombies2 select _i;
      _zombie2 setpos [-3367.739,-120.84577,-8247.0625];
    };
  };
};
You might get some BattlEye script restrictions on getPos and setPos, just add an exception for base_SafeArea.sqf.

 

Not thoroughly tested yet, as I just did this in the last hour, so let me know if you try it out and if it works well for you.

 

UPDATE:

arma2oaserver.rpt spam fixed.

Link to comment
Share on other sites

hmmm that mean you need to keep the plot pole placed down... to keep your base clean...kinda balanced but peaople could exploid it... they place one down in elektro or any other town and can keep looting without any problem.

the idea is nice but i would switch that from plot pole to the light thing you can build... so it requires some of the lights and a generator running to keep the base clean.

Link to comment
Share on other sites

Not for every server, but for mine it works.  Of course you could couple this with automatic removal of objects from the server (or adding a custom SQL operation on a schedule to remove plot poles every once in a while).

Link to comment
Share on other sites

Decided to write an event for MySQL to delete plot poles once a day, should be enough of a deterrent.

CREATE DEFINER=`root`@`localhost` EVENT `removePlotPoles` ON SCHEDULE EVERY 1 DAY STARTS '2013-06-02 02:52:01' ON COMPLETION NOT PRESERVE ENABLE COMMENT 'Removes plot poles every day' DO DELETE FROM dayz_epoch.object_data WHERE Classname = 'Plastic_Pole_EP1_DZ'
Link to comment
Share on other sites

but this placeable device is a nice idea... maybe it could get modifyed so it dont kill zombies and just pushes/teleport them away... but make it only be placeable inside the plotpole radius and make be supplied with fuel so you have have to keep it filled otherwise it would stop working

Link to comment
Share on other sites

Trying to work out an error I'm getting for type conversion (even though the script still works).  I believe it's caused by the script running on the server, when it should only be running on the client (if I remember correctly, zombies are client-controlled...correct me if I'm wrong).  Stay tuned.

Link to comment
Share on other sites

  • 1 month later...

Alternatively, instead of teleporting them away, this config kills them immediately.

while {true} do {
  sleep 10;


  // No Zeds near Plot Poles
  _playerPos = getPos player;
  _nearPole = nearestObject [_playerPos, "Plastic_Pole_EP1_DZ"];
  if (!isNull _nearPole) then {
    _pos2 = getPos _nearPole;
    _zombies2 = _pos2 nearEntities ["zZombie_Base", dayz_poleSafeArea];
    _count2 = count _zombies2;
    for "_i" from 0 to (_count2 -1) do
    {
      _zombie2 = _zombies2 select _i;
      _zombie2 setDamage 1;
    };
  };
};
Link to comment
Share on other sites

  • 1 month later...

How would some one go about changing this to use the Light Pole and Generator Idea?

 

"light thing you can build... so it requires some of the lights and a generator running to keep the base clean."

 

I would try to mod the code my self but i dont want to cause an zombie apoclypsy melt down.

 

Link to comment
Share on other sites

  • 1 month later...

Anyone know the code for LIT Campfire and LIT fire barrel?

I'm using this now on my server using the buildable campfire, but it works even when it's not lit..

Maybe insert the "if inflamed" code somewhere.

 

Anyhelp would be most appreciated.

 

 

How would some one go about changing this to use the Light Pole and Generator Idea?

 

"light thing you can build... so it requires some of the lights and a generator running to keep the base clean."

 

I would try to mod the code my self but i dont want to cause an zombie apoclypsy melt down.

 

Hey spindale,

This shouldn't be too hard, this scrip will use probly anything with a classname. Very versitile.

 

Just go to the line:

_nearPole = nearestObject [_playerPos, "Plastic_Pole_EP1_DZ"];

and change the Plastic_Pole_EP1_DZ to whatever you want to repell zeds.

I don't know what the Generator deployed classname is but i think it's Generator_DZ (correct me if I'm wrong). So change the line to:

_nearPole = nearestObject [_playerPos, "Generator_DZ"];

That should make all deployed generators repell zeds.

Link to comment
Share on other sites

  • 2 weeks later...

How would this be configured to work with the craftable fire barrels?

 

while {true} do {
  sleep 10;


  // No Zeds near Plot Poles
  _playerPos = getPos player;
  _nearPole = nearestObject [_playerPos, "FireBarrel_DZ"];
  if (!isNull _nearPole) then {
    _pos2 = getPos _nearPole;
    _zombies2 = _pos2 nearEntities ["zZombie_Base", dayz_poleSafeArea];
    _count2 = count _zombies2;
    for "_i" from 0 to (_count2 -1) do
    {
      _zombie2 = _zombies2 select _i;
      _zombie2 setpos [-3367.739,-120.84577,-8247.0625];
    };
  };
};

 

I replaced the pole with a fire barrel. I used the Epoch version so it'd have to be one you build, and not one that's seen around the map.

 

How can this be tweaked so that it's only active when it's burning, but inactive when it's not? So that way it's like when there's a fire, the zombies dont come around, but when the fire is out, they come.

 

"FireBarrel_DZ" is the Epoch version

"Land_Fire_barrel" is the unlit version of the Arma barrel.

"Land_Fire_barrel_burning" is the lit version of the Arma barrel.

I listed these for reference. I'm not good at scripting at all, but I'm sure it's possible to make it so the script works when lit, but deactivates when the fire isnt burning on the Epoch version, or atleast I hope it's possible.

 

Thanks in advance if anyone can help with this.

Link to comment
Share on other sites

How would this be configured to work with the craftable fire barrels?

 

while {true} do {

  sleep 10;

  // No Zeds near Plot Poles

  _playerPos = getPos player;

  _nearPole = nearestObject [_playerPos, "FireBarrel_DZ"];

  if (!isNull _nearPole) then {

    _pos2 = getPos _nearPole;

    _zombies2 = _pos2 nearEntities ["zZombie_Base", dayz_poleSafeArea];

    _count2 = count _zombies2;

    for "_i" from 0 to (_count2 -1) do

    {

      _zombie2 = _zombies2 select _i;

      _zombie2 setpos [-3367.739,-120.84577,-8247.0625];

    };

  };

};

 

I replaced the pole with a fire barrel. I used the Epoch version so it'd have to be one you build, and not one that's seen around the map.

 

How can this be tweaked so that it's only active when it's burning, but inactive when it's not? So that way it's like when there's a fire, the zombies dont come around, but when the fire is out, they come.

 

"FireBarrel_DZ" is the Epoch version

"Land_Fire_barrel" is the unlit version of the Arma barrel.

"Land_Fire_barrel_burning" is the lit version of the Arma barrel.

I listed these for reference. I'm not good at scripting at all, but I'm sure it's possible to make it so the script works when lit, but deactivates when the fire isnt burning on the Epoch version, or atleast I hope it's possible.

 

Thanks in advance if anyone can help with this.

 

This could be possible with some conditional statements:

//Set it to false to begin with
_burningBarrel = false;

while {true} do {
  sleep 10;
//If fire is lit, switch variable to true
if (!isNil "classNameOfBurningBarrel") then {
_burningBarrel = true;
};

  // No Zeds near Plot Poles
  _playerPos = getPos player;
  _nearPole = nearestObject [_playerPos, "FireBarrel_DZ"];
  if (_burningBarrel = true) then {//If fire is lit then...
           //blah blah
    };
  };
};

No idea if this will work,

That's just how it looks in my head :P but something along those  lines. you need to have "when the fires lit, some variable set to true",

then while that's true, the "safeBase" will be activated.

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...