Bury Corpses

seaweeduk

OpenDayZ Rockstar!
What it does....


Some of the heroes on my server noted that the bandits had been using my cannibalism mod to keep their humanity lower. This got me thinking yesterday about a heroic alternative to gutting a body for food and this script is my solution.

You can bury a body provided it has not been gutted (if you don't use my cannibalism script you can bury all bodies) and you have an entrenching tool.

The body is replaced with a grave and a random cross, a medical box filled with the bodies gear is left sunken in the grave so the dead players inventory can still be accessed. Burying a body yields an extra 100 humanity.

Thanks to everyone who shared their code on here without it I wouldn't have been able to write this mod, churchies strip clothes mod was especially helpful.

Requirements
A brain and the ability to read and edit text, fn_selfactions.sqf already in mission file
Easy - 5 mins

Code:
private["_corpse","_type","_isBuried","_mound","_cross","_gun"];
_corpse = _this select 3;
_type = typeOf _corpse;
_isBuried = _corpse getVariable["isBuried",false];
_hasHarvested = _corpse getVariable["meatHarvested",false];
_name = _corpse getVariable["bodyName","unknown"];

player removeAction s_player_bury_human;
s_player_bury_human = -1;

if (!_isBuried) then {
    if (!_hasHarvested) then {

          _corpse setVariable["isBuried",true,true];
        player playActionNow "Medic";
        sleep 10;

        _position = getPosATL _corpse;
        _dir = getDir _corpse;
private ["_newBackpackType","_backpackWpn","_backpackMag"];
        dayz_myBackpack = unitBackpack _corpse;
_newBackpackType = (typeOf dayz_myBackpack);
        _corpse; private ["_weapons","_magazines","_primweapon","_secweapon"];
        _weapons = weapons _corpse;
        _magazines = magazines _corpse;
        if(_newBackpackType != "") then {
_backpackWpn = getWeaponCargo unitBackpack _corpse;
_backpackMag = getMagazineCargo unitBackpack _corpse;
};
  _box = createVehicle ["Foodbox0", _position, [], 0, "CAN_COLLIDE"];
        _box setpos [(getposATL _box select 0),(getposATL _box select 1)+1.2, 0];
        clearWeaponCargoGlobal _box;
        clearMagazineCargoGlobal _box;
        { _box addWeaponCargoGlobal [_x, 1] } forEach weapons _corpse;
        { _box addMagazineCargoGlobal [_x ,1] } forEach magazines _corpse;
deleteVehicle _corpse;

        _mound = createVehicle ["Grave", _position, [], 0, "CAN_COLLIDE"];
        _mound setpos [(getposATL _mound select 0),(getposATL _mound select 1), 0];
        _crosstype = ["GraveCross1","GraveCross2","GraveCrossHelmet"]  call BIS_fnc_selectRandom;
        _cross = createVehicle [_crosstype, _position, [], 0, "CAN_COLLIDE"];
        _cross setpos [(getposATL _cross select 0),(getposATL _cross select 1)-1.2, 0];

        if(_newBackpackType != "") then {
            _backpackWpnTypes = [];
            _backpackWpnQtys = [];
            if (count _backpackWpn > 0) then {
                _backpackWpnTypes = _backpackWpn select 0;
                _backpackWpnQtys = _backpackWpn select 1;
            };
            _countr = 0;
            { _box addWeaponCargoGlobal [_x,(_backpackWpnQtys select _countr)];
            _countr = _countr + 1;
            } forEach _backpackWpnTypes;
            _backpackmagTypes = [];
            _backpackmagQtys = [];
            if (count _backpackmag > 0) then {
                _backpackmagTypes = _backpackMag select 0;
                _backpackmagQtys = _backpackMag select 1;
            };
            _countr = 0; { _box addMagazineCargoGlobal [_x,(_backpackmagQtys select _countr)];
            _countr = _countr + 1;
            } forEach _backpackmagTypes;
            _box addBackpackCargoGlobal [_newBackpackType, 1];
        };

        //Permaloot
        _box setVariable ["permaLoot", true];

        _deathMessage = format["Rest in Peace, %1...",_name];
        cutText [_deathMessage, "PLAIN DOWN"];
        [player,100] call player_humanityChange;
        _id = [player,50,true,(getPosATL player)] spawn player_alertZombies;
        player playMove "AmovPercMstpSlowWrflDnon_Salute";
    } else {
        cutText ["The poor bastards been eaten, there's not much left to bury", "PLAIN DOWN"];
    };
};

Save the above code as bury_human.sqf and place it inside your mission file, in a "fixes" folder




Find the following code in fn_selfActions.sqf

Code:
    /*
    if (_isMan and !_isAlive) then {
        if (s_player_dragbody < 0) then {
            s_player_dragbody = player addAction [localize "str_action_studybody", "\z\addons\dayz_code\actions\drag_body.sqf",cursorTarget, 0, false, true, "",""];
        };
        } else {
        player removeAction s_player_dragbody;
        s_player_dragbody = -1;
    };
    */

Above it add this code:

Code:
    if (!_isAlive and !_isZombie and !_isAnimal and _hasETool and _isMan and _canDo) then {
        if (s_player_bury_human < 0) then {
            s_player_bury_human = player addAction [format["Bury Body"], "fixes\bury_human.sqf",cursorTarget, 0, false, true, "", ""];
        }
    } else {
        player removeAction s_player_bury_human;
        s_player_bury_human = -1;
    };

Near the end (its in there twice) of the same file find

Code:
player removeAction s_player_flipveh;

After add:

Code:
    player removeAction s_player_bury_human;
    s_player_bury_human = -1;

At the top of the file look for:

Code:
} forEach boil_tin_cans;

After it add:

Code:
_hasETool = "ItemEtool" in items player;

For battle eye kicks add the following to the first line of your setvariable.txt after the 5

Code:
!="isburied"


You will need to whitelist this action if you use anti hack: s_player_bury_human


This is the first release of the script, if you make any additions or improvements or you have any suggestions or comments let me know. I used the medbox instead of dropping the loot to avoid the loot getting cleaned up by the server.



edit: I was using clearMagazineCargo addWeaponCargo etc instead of clearMagazineCargoGlobal in my first release. This meant the contents of the box only changed for the person to bury the body. I have updated the OP the global commands are multiplayer synced. I also moved the box to the ground instead of inside the grave as it was confusing people.

Terms & Conditions - When you download or copy this code you agree to not charge any money for installing this script. You may not use the code for profit in any way and all modifications with the original code must be shared publicly.
 
Last edited:
Top