[Release] Fred's Zombie Bait (WIP)

Exploding Zombie Bait! by Freaking Fred

I have added two sets of installation instructions to the original posts. People who already have Zombie Bait installed can just update to v 1.1.0 and people installing for the first time can use the full installation instructions that start on post #2.

[EDIT] There may possibly be a createVehicle restriction for "grenade". Let me know if anyone has any issues with this and we can get an exception made for it.
 
=> ability to use any raw meat.
I haven't tested this yet but it looks like it will work fine.

In the zombiebait.sqf file change
player removeMagazine "ItemBloodbag";
player removeMagazine "FoodbeefRaw";

to
if ("FoodbeefRaw" in magazines player) then { _rawmeat = "FoodbeefRaw";};
if ("FoodmuttonRaw" in magazines player) then { _rawmeat = "FoodmuttonRaw";};
if ("FoodchickenRaw" in magazines player) then { _rawmeat = "FoodchickenRaw";};
if ("FoodbaconRaw" in magazines player) then { _rawmeat = "FoodbaconRaw";};
player removeMagazine "ItemBloodbag";
player removeMagazine _rawmeat;
in fn_selfactions.sqf
if (("ItemBloodbag" in magazines player) && ("FoodbeefRaw" in magazines player)) then {
hasBait = true;
} else {
hasBait = false;
to
if ("ItemBloodbag" in magazines player) then {
if ("FoodbeefRaw" in magazines player) then { hasBait = true;};
if ("FoodmuttonRaw" in magazines player) then { hasBait = true;};
if ("FoodchickenRaw" in magazines player) then { hasBait = true;};
if ("FoodbaconRaw" in magazines player) then { hasBait = true;};
} else {
hasBait = false;
};
I like the exploding zombie bait. One problem that has to be addressed the same way is only using handgrenade_west as we also have handgrenade_east on our server. But that would be addressed the same as the beef. Should be a simple fix.
 
Here is the code for fn_selfactions.sqf zombiebait.sqf and zombiebomb.sqf
Its been tested and working on my server to use any kind of meat and either hand grenade. Of course come monday there is an additional type of meat being added I think with the 1.7.7 release so will require another small edit.

fn_selfactions.sqf
Code:
// Zombie Bait****************************************************
if ("ItemBloodbag" in magazines player) then {
    if ("FoodbeefRaw" in magazines player) then { hasBait = true;};
    if ("FoodmuttonRaw" in magazines player) then { hasBait = true;};
    if ("FoodchickenRaw" in magazines player) then { hasBait = true;};
    if ("FoodbaconRaw" in magazines player) then { hasBait = true;};
} else {
    hasBait = false;
};
if (hasBait) then {
    if (zombieBait < 0) then {
zombieBait = player addAction [("<t color=""#c30000"">" + ("Place Zombie Bait") +"</t>"),"scripts\zombiebait\zombiebait.sqf","",5,false,true,"",""];
    };
} else {
    player removeAction zombieBait;
    zombieBait = -1;
};
// Exploding Zombie Bait
if ((hasBait) then {
    if (("HandGrenade_West" in magazines player) || ("HandGrenade_East" in magazines player)) then {
        if (zombieBomb < 0) then {
        zombieBomb = player addAction [("<t color=""#c30000"">" + ("Place Exploding Bait") +"</t>"),"scripts\zombiebait\zombiebomb.sqf","",5,false,true,"",""];
        };
} else {
player removeAction zombieBomb;
zombieBomb = -1;
};

zombiebait.sqf
Code:
player playActionNow "Medic";
sleep 1;
titleText ["You have placed Zombie Bait. You should run.","PLAIN DOWN"]; titleFadeOut 5;
 
_mypos = getposATL player;
_dir = getdir player;
_mypos = [(_mypos select 0)+2*sin(_dir),(_mypos select 1)+2*cos(_dir), (_mypos select 2)];
_createBait = createVehicle ["Land_Bucket_EP1", _mypos, [], 0, "CAN_COLLIDE"];
_createBait setDir _dir;
_createBait setposATL _mypos;
sleep 1;
 
if ("FoodbeefRaw" in magazines player) then { _rawmeat = "FoodbeefRaw";};
if ("FoodmuttonRaw" in magazines player) then { _rawmeat = "FoodmuttonRaw";};
if ("FoodchickenRaw" in magazines player) then { _rawmeat = "FoodchickenRaw";};
if ("FoodbaconRaw" in magazines player) then { _rawmeat = "FoodbaconRaw";};
player removeMagazine "ItemBloodbag";
player removeMagazine _rawmeat;
sleep 10;
 
_i = 0;
_bait = nearestObject [player, "Land_Bucket_EP1"];
_setBait = (getPosATL _bait) nearEntities ["zZombie_Base",50];
{
    _group = group _x;
    if (isNull group _x) then {
        _group = _x;
    };
    _x reveal [_bait,4];
    _targets = _group getVariable ["targets",[]];
    if (!(_bait in _targets)) then {
        _targets set [count _targets,_bait];
        _group setVariable ["targets",_targets,true];
    };
    _i = _i + 1;
} forEach _setBait;
 
sleep 120;
titleText ["You're Zombie Bait is gone.","PLAIN DOWN"]; titleFadeOut 5;
deleteVehicle _createBait;
 
player removeAction zombieBait;

zombiebomb.sqf
Code:
player playActionNow "Medic";
sleep 1;
titleText ["You have placed Explosive Zombie Bait. You should run.","PLAIN DOWN"]; titleFadeOut 5;
 
_mypos = getposATL player;
_dir = getdir player;
_mypos = [(_mypos select 0)+2*sin(_dir),(_mypos select 1)+2*cos(_dir), (_mypos select 2)];
_createBait = createVehicle ["Land_Bucket_EP1", _mypos, [], 0, "CAN_COLLIDE"];
_createBait setDir _dir;
_createBait setposATL _mypos;
sleep 1;
 
 
if ("FoodbeefRaw" in magazines player) then { _rawmeat = "FoodbeefRaw";};
if ("FoodmuttonRaw" in magazines player) then { _rawmeat = "FoodmuttonRaw";};
if ("FoodchickenRaw" in magazines player) then { _rawmeat = "FoodchickenRaw";};
if ("FoodbaconRaw" in magazines player) then { _rawmeat = "FoodbaconRaw";};
if ("HandGrenade_West" in magazines player) then { _nade = "HandGrenade_West";};
if ("HandGrenade_East" in magazines player) then { _nade = "HandGrenade_East";};
player removeMagazine "ItemBloodbag";
player removeMagazine _rawmeat;
sleep 10;
 
player removeMagazine "ItemBloodbag";
player removeMagazine _rawmeat;
player removeMagazine _nade;
sleep 10;
 
_i = 0;
_bait = nearestObject [player, "Land_Bucket_EP1"];
_setBait = (getPosATL _bait) nearEntities ["zZombie_Base",50];
{
    _group = group _x;
    if (isNull group _x) then {
        _group = _x;
    };
    _x reveal [_bait,4];
    _targets = _group getVariable ["targets",[]];
    if (!(_bait in _targets)) then {
        _targets set [count _targets,_bait];
        _group setVariable ["targets",_targets,true];
    };
    _i = _i + 1;
} forEach _setBait;
 
sleep 10;
titleText ["You're Explosive Zombie Bait will detonate in 2 minutes.","PLAIN DOWN"]; titleFadeOut 5;
sleep 60;
titleText ["You're Explosive Zombie Bait will detonate in 1 minute.","PLAIN DOWN"]; titleFadeOut 5;
sleep 30;
titleText ["You're Explosive Zombie Bait will detonate in 30 seconds.","PLAIN DOWN"]; titleFadeOut 5;
sleep 20;
titleText ["You're Explosive Zombie Bait will detonate in 10 seconds.","PLAIN DOWN"]; titleFadeOut 5;
sleep 10;
 
_zombieBomb = createVehicle ["grenade",position _createBait, [], 0, "NONE"];
sleep 1;
deleteVehicle _createBait;
 
Here is the code for fn_selfactions.sqf zombiebait.sqf and zombiebomb.sqf
Its been tested and working on my server to use any kind of meat and either hand grenade. Of course come monday there is an additional type of meat being added I think with the 1.7.7 release so will require another small edit.

fn_selfactions.sqf
Code:
// Zombie Bait****************************************************
if ("ItemBloodbag" in magazines player) then {
    if ("FoodbeefRaw" in magazines player) then { hasBait = true;};
    if ("FoodmuttonRaw" in magazines player) then { hasBait = true;};
    if ("FoodchickenRaw" in magazines player) then { hasBait = true;};
    if ("FoodbaconRaw" in magazines player) then { hasBait = true;};
} else {
    hasBait = false;
};
if (hasBait) then {
    if (zombieBait < 0) then {
zombieBait = player addAction [("<t color=""#c30000"">" + ("Place Zombie Bait") +"</t>"),"scripts\zombiebait\zombiebait.sqf","",5,false,true,"",""];
    };
} else {
    player removeAction zombieBait;
    zombieBait = -1;
};
// Exploding Zombie Bait
if ((hasBait) then {
    if (("HandGrenade_West" in magazines player) || ("HandGrenade_East" in magazines player)) then {
        if (zombieBomb < 0) then {
        zombieBomb = player addAction [("<t color=""#c30000"">" + ("Place Exploding Bait") +"</t>"),"scripts\zombiebait\zombiebomb.sqf","",5,false,true,"",""];
        };
} else {
player removeAction zombieBomb;
zombieBomb = -1;
};

zombiebait.sqf
Code:
player playActionNow "Medic";
sleep 1;
titleText ["You have placed Zombie Bait. You should run.","PLAIN DOWN"]; titleFadeOut 5;
 
_mypos = getposATL player;
_dir = getdir player;
_mypos = [(_mypos select 0)+2*sin(_dir),(_mypos select 1)+2*cos(_dir), (_mypos select 2)];
_createBait = createVehicle ["Land_Bucket_EP1", _mypos, [], 0, "CAN_COLLIDE"];
_createBait setDir _dir;
_createBait setposATL _mypos;
sleep 1;
 
if ("FoodbeefRaw" in magazines player) then { _rawmeat = "FoodbeefRaw";};
if ("FoodmuttonRaw" in magazines player) then { _rawmeat = "FoodmuttonRaw";};
if ("FoodchickenRaw" in magazines player) then { _rawmeat = "FoodchickenRaw";};
if ("FoodbaconRaw" in magazines player) then { _rawmeat = "FoodbaconRaw";};
player removeMagazine "ItemBloodbag";
player removeMagazine _rawmeat;
sleep 10;
 
_i = 0;
_bait = nearestObject [player, "Land_Bucket_EP1"];
_setBait = (getPosATL _bait) nearEntities ["zZombie_Base",50];
{
    _group = group _x;
    if (isNull group _x) then {
        _group = _x;
    };
    _x reveal [_bait,4];
    _targets = _group getVariable ["targets",[]];
    if (!(_bait in _targets)) then {
        _targets set [count _targets,_bait];
        _group setVariable ["targets",_targets,true];
    };
    _i = _i + 1;
} forEach _setBait;
 
sleep 120;
titleText ["You're Zombie Bait is gone.","PLAIN DOWN"]; titleFadeOut 5;
deleteVehicle _createBait;
 
player removeAction zombieBait;

zombiebomb.sqf
Code:
player playActionNow "Medic";
sleep 1;
titleText ["You have placed Explosive Zombie Bait. You should run.","PLAIN DOWN"]; titleFadeOut 5;
 
_mypos = getposATL player;
_dir = getdir player;
_mypos = [(_mypos select 0)+2*sin(_dir),(_mypos select 1)+2*cos(_dir), (_mypos select 2)];
_createBait = createVehicle ["Land_Bucket_EP1", _mypos, [], 0, "CAN_COLLIDE"];
_createBait setDir _dir;
_createBait setposATL _mypos;
sleep 1;
 
 
if ("FoodbeefRaw" in magazines player) then { _rawmeat = "FoodbeefRaw";};
if ("FoodmuttonRaw" in magazines player) then { _rawmeat = "FoodmuttonRaw";};
if ("FoodchickenRaw" in magazines player) then { _rawmeat = "FoodchickenRaw";};
if ("FoodbaconRaw" in magazines player) then { _rawmeat = "FoodbaconRaw";};
if ("HandGrenade_West" in magazines player) then { _nade = "HandGrenade_West";};
if ("HandGrenade_East" in magazines player) then { _nade = "HandGrenade_East";};
player removeMagazine "ItemBloodbag";
player removeMagazine _rawmeat;
sleep 10;
 
player removeMagazine "ItemBloodbag";
player removeMagazine _rawmeat;
player removeMagazine _nade;
sleep 10;
 
_i = 0;
_bait = nearestObject [player, "Land_Bucket_EP1"];
_setBait = (getPosATL _bait) nearEntities ["zZombie_Base",50];
{
    _group = group _x;
    if (isNull group _x) then {
        _group = _x;
    };
    _x reveal [_bait,4];
    _targets = _group getVariable ["targets",[]];
    if (!(_bait in _targets)) then {
        _targets set [count _targets,_bait];
        _group setVariable ["targets",_targets,true];
    };
    _i = _i + 1;
} forEach _setBait;
 
sleep 10;
titleText ["You're Explosive Zombie Bait will detonate in 2 minutes.","PLAIN DOWN"]; titleFadeOut 5;
sleep 60;
titleText ["You're Explosive Zombie Bait will detonate in 1 minute.","PLAIN DOWN"]; titleFadeOut 5;
sleep 30;
titleText ["You're Explosive Zombie Bait will detonate in 30 seconds.","PLAIN DOWN"]; titleFadeOut 5;
sleep 20;
titleText ["You're Explosive Zombie Bait will detonate in 10 seconds.","PLAIN DOWN"]; titleFadeOut 5;
sleep 10;
 
_zombieBomb = createVehicle ["grenade",position _createBait, [], 0, "NONE"];
sleep 1;
deleteVehicle _createBait;


In the zombiebomb.sqf, you have some duplicate entries.
Code:
player removeMagazine "ItemBloodbag";
player removeMagazine _rawmeat;
sleep 10;
 
player removeMagazine "ItemBloodbag";
player removeMagazine _rawmeat;
player removeMagazine _nade;
sleep 10;

Other than that, it looks good. Thanks for sharing! :)
 
Ahh, yeah. I had just copy/pasted the zombiebait into the zombiebomb and forgot to delete the default code.
And I am sure there is a more elegant solution to test for multiple items within the magazines in a single line of code but off the top of my head I don't know it so this one works.
Probably something along the lines of If ([cow,sheep,goat,pig] in magazine player).

Which reminds me .. forgot about rabbit. So have to add another line for FoodbunnyRaw.
 
By default you need raw COW, try that for the zombiebomb, it worked fine for me.

I will check again but I am sure the meat is removed on my server.
 
I left out a }; in the Zombiebomb part of the fn_selfactions.sqf file

here is the corrected code:
Code:
// Zombie Bait
if ("ItemBloodbag" in magazines player) then {
    if ("FoodbeefRaw" in magazines player) then { hasBait = true;};
    if ("FoodmuttonRaw" in magazines player) then { hasBait = true;};
    if ("FoodchickenRaw" in magazines player) then { hasBait = true;};
    if ("FoodbaconRaw" in magazines player) then { hasBait = true;};
} else {
    hasBait = false;
};
if (hasBait) then {
    if (zombieBait < 0) then {
zombieBait = player addAction [("<t color=""#c30000"">" + ("Place Zombie Bait") +"</t>"),"scripts\zombiebait\zombiebait.sqf","",5,false,true,"",""];
    };
} else {
    player removeAction zombieBait;
    zombieBait = -1;
};
// Exploding Zombie Bait
if ((hasBait) then {
    if (("HandGrenade_West" in magazines player) || ("HandGrenade_East" in magazines player)) then {
        if (zombieBomb < 0) then {
        zombieBomb = player addAction [("<t color=""#c30000"">" + ("Place Exploding Bait") +"</t>"),"scripts\zombiebait\zombiebomb.sqf","",5,false,true,"",""];
        };
    }; //***************this is the forgotten curly brace**************
 
} else {
player removeAction zombieBomb;
zombieBomb = -1;
};
 
Please update the tutorial, because i m not English and i have more difficulty for understand all, and I feel that over the posts you have made many changes, which are not necessarily useful or correct.

Regards
 
I don't think the script works at all in 1.7.7.1 ... at least the menu does not appear on my server. Not sure why. I agree though, need a single new install post with updated script.
I expect the scripts problem is in the part where it checks for a player having a bloodbag and raw meat since on my server the menu doesn't appear at all. I haven't tested much as so many other things are now broken in 1.7.7.1
 
Here is the code for fn_selfactions.sqf zombiebait.sqf and zombiebomb.sqf
Its been tested and working on my server to use any kind of meat and either hand grenade. Of course come monday there is an additional type of meat being added I think with the 1.7.7 release so will require another small edit.

fn_selfactions.sqf
Code:
// Zombie Bait****************************************************
if ("ItemBloodbag" in magazines player) then {
    if ("FoodbeefRaw" in magazines player) then { hasBait = true;};
    if ("FoodmuttonRaw" in magazines player) then { hasBait = true;};
    if ("FoodchickenRaw" in magazines player) then { hasBait = true;};
    if ("FoodbaconRaw" in magazines player) then { hasBait = true;};
} else {
    hasBait = false;
};
if (hasBait) then {
    if (zombieBait < 0) then {
zombieBait = player addAction [("<t color=""#c30000"">" + ("Place Zombie Bait") +"</t>"),"scripts\zombiebait\zombiebait.sqf","",5,false,true,"",""];
    };
} else {
    player removeAction zombieBait;
    zombieBait = -1;
};
// Exploding Zombie Bait
if ((hasBait) then {
    if (("HandGrenade_West" in magazines player) || ("HandGrenade_East" in magazines player)) then {
        if (zombieBomb < 0) then {
        zombieBomb = player addAction [("<t color=""#c30000"">" + ("Place Exploding Bait") +"</t>"),"scripts\zombiebait\zombiebomb.sqf","",5,false,true,"",""];
        };
} else {
player removeAction zombieBomb;
zombieBomb = -1;
};

zombiebait.sqf
Code:
player playActionNow "Medic";
sleep 1;
titleText ["You have placed Zombie Bait. You should run.","PLAIN DOWN"]; titleFadeOut 5;
 
_mypos = getposATL player;
_dir = getdir player;
_mypos = [(_mypos select 0)+2*sin(_dir),(_mypos select 1)+2*cos(_dir), (_mypos select 2)];
_createBait = createVehicle ["Land_Bucket_EP1", _mypos, [], 0, "CAN_COLLIDE"];
_createBait setDir _dir;
_createBait setposATL _mypos;
sleep 1;
 
if ("FoodbeefRaw" in magazines player) then { _rawmeat = "FoodbeefRaw";};
if ("FoodmuttonRaw" in magazines player) then { _rawmeat = "FoodmuttonRaw";};
if ("FoodchickenRaw" in magazines player) then { _rawmeat = "FoodchickenRaw";};
if ("FoodbaconRaw" in magazines player) then { _rawmeat = "FoodbaconRaw";};
player removeMagazine "ItemBloodbag";
player removeMagazine _rawmeat;
sleep 10;
 
_i = 0;
_bait = nearestObject [player, "Land_Bucket_EP1"];
_setBait = (getPosATL _bait) nearEntities ["zZombie_Base",50];
{
    _group = group _x;
    if (isNull group _x) then {
        _group = _x;
    };
    _x reveal [_bait,4];
    _targets = _group getVariable ["targets",[]];
    if (!(_bait in _targets)) then {
        _targets set [count _targets,_bait];
        _group setVariable ["targets",_targets,true];
    };
    _i = _i + 1;
} forEach _setBait;
 
sleep 120;
titleText ["You're Zombie Bait is gone.","PLAIN DOWN"]; titleFadeOut 5;
deleteVehicle _createBait;
 
player removeAction zombieBait;

zombiebomb.sqf
Code:
player playActionNow "Medic";
sleep 1;
titleText ["You have placed Explosive Zombie Bait. You should run.","PLAIN DOWN"]; titleFadeOut 5;
 
_mypos = getposATL player;
_dir = getdir player;
_mypos = [(_mypos select 0)+2*sin(_dir),(_mypos select 1)+2*cos(_dir), (_mypos select 2)];
_createBait = createVehicle ["Land_Bucket_EP1", _mypos, [], 0, "CAN_COLLIDE"];
_createBait setDir _dir;
_createBait setposATL _mypos;
sleep 1;
 
 
if ("FoodbeefRaw" in magazines player) then { _rawmeat = "FoodbeefRaw";};
if ("FoodmuttonRaw" in magazines player) then { _rawmeat = "FoodmuttonRaw";};
if ("FoodchickenRaw" in magazines player) then { _rawmeat = "FoodchickenRaw";};
if ("FoodbaconRaw" in magazines player) then { _rawmeat = "FoodbaconRaw";};
if ("HandGrenade_West" in magazines player) then { _nade = "HandGrenade_West";};
if ("HandGrenade_East" in magazines player) then { _nade = "HandGrenade_East";};
player removeMagazine "ItemBloodbag";
player removeMagazine _rawmeat;
sleep 10;
 
player removeMagazine "ItemBloodbag";
player removeMagazine _rawmeat;
player removeMagazine _nade;
sleep 10;
 
_i = 0;
_bait = nearestObject [player, "Land_Bucket_EP1"];
_setBait = (getPosATL _bait) nearEntities ["zZombie_Base",50];
{
    _group = group _x;
    if (isNull group _x) then {
        _group = _x;
    };
    _x reveal [_bait,4];
    _targets = _group getVariable ["targets",[]];
    if (!(_bait in _targets)) then {
        _targets set [count _targets,_bait];
        _group setVariable ["targets",_targets,true];
    };
    _i = _i + 1;
} forEach _setBait;
 
sleep 10;
titleText ["You're Explosive Zombie Bait will detonate in 2 minutes.","PLAIN DOWN"]; titleFadeOut 5;
sleep 60;
titleText ["You're Explosive Zombie Bait will detonate in 1 minute.","PLAIN DOWN"]; titleFadeOut 5;
sleep 30;
titleText ["You're Explosive Zombie Bait will detonate in 30 seconds.","PLAIN DOWN"]; titleFadeOut 5;
sleep 20;
titleText ["You're Explosive Zombie Bait will detonate in 10 seconds.","PLAIN DOWN"]; titleFadeOut 5;
sleep 10;
 
_zombieBomb = createVehicle ["grenade",position _createBait, [], 0, "NONE"];
sleep 1;
deleteVehicle _createBait;


this did work for me in 1.7.7.1 but only problem iam getting is its not removing the raw meat i have tried
FoodbeefRaw,FoodSteakRaw,FoodmeatRaw,FoodrabbitRaw,FoodgoatRaw,FoodmuttonRaw,FoodchickenRaw,FoodbaconRaw

and it does not remove it from my inventory. it removes the bloodbag fine just not the rawmeat
 
This will work with the update, you just have to use the updated fn_selfActions from your dayz_code.pbo.
 
Im working on adding this to the BreakingPointSP mod, can you email me with updates on the progress of the addon?

Cheers, BossMann
 
Back
Top