[Release] Fred's Zombie Bait

Discussion in 'Script/Addon releases' started by Freaking Fred, May 29, 2013.

  1. Freaking Fred

    Freaking Fred OpenDayZ Rockstar!

    Joined:
    Feb 1, 2013
    Messages:
    380
    Likes Received:
    171
    Fred's Zombie Bait
    Created By Freaking Fred
    Info

    Fred's Zombie Bait allows players to combine Raw Beef and Bloodbags to create Zombie Bait that can be placed on the ground. In my testing, I have found the bait to be very effective at keeping the zombies attention away from the player.

    Versions

    v 1.1.0 - Added Exploding Zombie Bait. Requires M67 Frag Grenade.
    v 1.0.0 - Initial release.

    Tutorials

    Custom dayz_code files. (compiles.sqf and fn_selfActions.sqf)
    Open the spoiler for the tutorial.
    Step 1:Go to your arma 2 operation arrowhead installation folder on your PC and find your @DayZ folder.

    Step 2: In your @DayZ folder, go into the addons folder and find the dayz_code.pbo. Make a copy of dayz_code.pbo on your desktop.

    Step 3: Unpack the dayz_code.pbo that you have placed on your desktop. Inside the dayz_code folder find the compile folder.

    Step 4: Inside the compile folder you will find the fn_selfActions.sqf. Make a copy of that and place it on your desktop.

    Step 5: Back out to the main dayz_code folder and find the init folder. Inside the init folder you will find compiles.sqf. Make a copy of that and place it on your desktop.

    Step 6: In your server's mission folder, create a fixes folder, if you don't already have one. Move the fn_selfActions.sqf and compiles.sqf from your desktop into this folder.

    Step 7: In your compiles.sqf find the following line.
    Code:
    fnc_usec_selfActions =        compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_selfActions.sqf";        //Checks which actions for self
    Change it to
    Code:
    fnc_usec_selfActions =      compile preprocessFileLineNumbers "fixes\fn_selfActions.sqf";        //Checks which actions for self

    Step 8: In your init.sqf find the following line.
    Code:
    call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\compiles.sqf";              //Compile regular functions
    Change it to
    Code:
    call compile preprocessFileLineNumbers "fixes\compiles.sqf";              //Compile regular functions

    Installation

    Update to v1.1.0
    Open the spoiler for installation.
    Step 1: In your scripts\zombiebait folder, create a new text document and name it zombiebomb.sqf.

    Step 2: Copy and paste the following code into 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;
     
    player removeMagazine "ItemBloodbag";
    player removeMagazine "FoodbeefRaw";
    player removeMagazine "HandGrenade_West";
    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;

    Step 3: Open your fn_selfActions.sqf and replace your original zombie bait section with
    Code:
    // Zombie Bait
    if (("ItemBloodbag" in magazines player) && ("FoodbeefRaw" 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) && ("HandGrenade_West" 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;
    };

    Full Installation instructions start on post #2.
     
    Jokaru, Villain, Bungle and 5 others like this.
  2. Freaking Fred

    Freaking Fred OpenDayZ Rockstar!

    Joined:
    Feb 1, 2013
    Messages:
    380
    Likes Received:
    171
    Full Installation (Zombie Bait and Exploding Zombie Bait)

    Open the spoiler for installation.
    Step 1: In your server's mission folder, create two new folders and name them scripts and fixes, if you don't already have them.

    Step 2: In your scripts folder, create a new folder and name it zombiebait. In the zombiebait folder, create two new text documents and name them zombiebait.sqf and zombiebomb.sqf.

    Step 3: Copy and paste the following code into 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;
     
    player removeMagazine "ItemBloodbag";
    player removeMagazine "FoodbeefRaw";
    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;

    Step 4:Copy and paste the following code intozombiebomb.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;
     
    player removeMagazine "ItemBloodbag";
    player removeMagazine "FoodbeefRaw";
    player removeMagazine "HandGrenade_West";
    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;
    Step 5: In your fixes folder, create a new folder and name it zombiebait. In thiszombiebait folder, create a new text document and name itzombie_findTargetAgent.sqf.

    Step 6: Copy and paste the following code into zombie_findTargetAgent.sqf.
    Code:
    private["_agent","_target","_targets","_targetDis","_c","_man","_manDis","_targets","_agent","_agentheight","_nearEnts","_rnd","_assigned","_range","_objects"];
    _agent = _this;
    _target = objNull;
    /*
    _local = [];
    _remote = [];
    */
    _targets = [];
    _targetDis = [];
    _range = 120;
    _manDis = 0;
    _refobj = vehicle player;
     
    /*
    _local =    _agent getVariable ["target",[]];
    //diag_log ("Local is: " + str(_local));
    _remote =    _agent getVariable ["targets",[]];
    //diag_log ("Remote is: " + str(_remote));
     
    if (count _remote == 0) then
    {
        _targets = _local;
        //diag_log ("Targets is: " + str(_targets));
    }
    else
    {
        _targets = _local + _remote;
        //diag_log ("Local + Remote targets is: " + str(_targets));
    };
    */
     
    _targets = _agent getVariable ["targets",[]];
     
    if (isNil "_targets") exitWith {};
    //Search for objects
    if (count _targets == 0) then
    {
        _objects = nearestObjects [_agent,["ThrownObjects","GrenadeHandTimedWest","SmokeShell","Land_Bucket_EP1"],500];
        {
            private["_dis"];
            if (!(_x in _targets)) then
            {
                _targets set [count _targets,_x];
                _targetDis set [count _targetDis,_dis];
            _move = "ZombieFeed";
            [objNull, _objects,rPlayMove, _move] call RE;
            };
        } forEach _objects;
    };
     
    //Find best target
    if (count _targets > 0) then
    {
        _man = _targets select 0;
        _manDis = _man distance _agent;
        {
            private["_dis"];
            _dis =  _x distance _agent;
            if (_dis < _manDis) then
            {
                _man = _x;
                _manDis = _dis;
            };
            if (_dis > _range) then
            {
                _targets = _targets - [_x];
            };
            if (_x isKindOf "SmokeShell") then
            {
                _man = _x;
                _manDis = _dis;
            };
        } forEach _targets;
     
        _target = _man;
    };
     
    //Check if too far
    if (_manDis > _range) then
    {
        _targets = _targets - [_target];
        _target = objNull;
    };
     
    _target


    Step 7: Open your fn_selfActions.sqf and copy and paste the following code to the bottom of the file.
    Code:
    // Zombie Bait
    if (("ItemBloodbag" in magazines player) && ("FoodbeefRaw" 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) && ("HandGrenade_West" 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;
    };


    Step 8: Open your compiles.sqf and find the following code on line 56.
    Code:
    zombie_findTargetAgent =    compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\zombie_findTargetAgent.sqf";
    Change it to
    Code:
    zombie_findTargetAgent =    compile preprocessFileLineNumbers "fixes\zombiebait\zombie_findTargetAgent.sqf";

    Step 9: You will have to add an exception in your createvehicle.txt. Find the following line.
    Code:
    5 "Land_" !="Land_Fire_DZ"
    Change it to
    Code:
    5 "Land_" !="Land_Fire_DZ" !="Land_Bucket_EP1"



    Media

    Zombie Bait in action! by andy1978


    Exploding Zombie Bait! by Freaking Fred



    How To Use
    Step 1: Make sure you have at least 1 Raw Beef and 1 Bloodbag in your inventory.

    Step 2: Scroll wheel and select the Place Zombie Bait option.

    Step 3: Get the hell away from the bait!


    FAQ
    Q: I have Raw Beef and Bloodbags in my inventory but I am not getting a Place Zombie Bait option.
    A: Try dropping the required items on the ground and picking them back up. I am currently looking into a permanent fix for the issue.

    Q: I have raw meat in my inventory but I am not getting the option.
    A: Make sure you are using Raw Beef specifically.
     
    Rite, Suldani, shinkicker and 7 others like this.
  3. slayterson

    slayterson New Member

    Joined:
    Oct 25, 2013
    Messages:
    8
    Likes Received:
    1
    Put these into your dayz_resetSelfActions = { section in variables.sqf. they will show as intended on login.

    zombieBait = -1;
    zombieBomb = -1;
    zombieShield = -1;
     

Share This Page