[Release] Booby Trap

Matt L

OpenDayZ Rockstar!
The Booby Trap
Version 1.0
What it does....
Creates a small stash underneath the player that then spawns a grenade that detonates if a player gets to close.


Requirements -
  • Notepad ++
  • Patience
  • More Patience
Installation Steps -
  1. You will need a custom fn_selfActions.sqf and compiles.sqf, i'll continue that on a new post.
  2. You will also need a Scripts folder and a Fixes folder within your mission.pbo (or the knowledge to change the filepaths)
  3. In your init.sqf add
    Code:
    if (isServer) then {
          "DZ_boobyTrap" addPublicVariableEventHandler {[_this select 1] execVM 'Scripts\createBomb.sqf'};
    };
  4. You may need to add a BE exception for a publicvariable, should be something like !"DZ_boobyTrap"
FAQ -
  • What does it do exactly? ~ It's just a proximity bomb. Spawns a nade when a person gets to close and goes boom.
  • What do you need to make it? ~ An Etool, an M67 Frag, and a Wood pile.
Credits -
CommanderRetra
Buttface



For a version where the booby trap can be placed on bodies, of zombies players and animals ( can be changed by you) refer to http://opendayz.net/threads/release-body-traps.13433/
 
For the fn_selfActions.sqf and compiles.sqf grab them from your dayz_code.pbo and place them in your Fixes folder. Go into your init and locate the preprocessfile line that calls the compiles.sqf (should be just above progressloading screen 1 and change it to Fixes\compiles.sqf

Next find fnc_usec_selfActions = compile preprocessFileLineNumbers and change that filepath to Fixes\fn_selfActions.sqf

At the bottom of your custom fn_selfActions.sqf add in this code:
Code:
updated code, check bottom post
 
For only bandits being able to place a bomb, use this fn_selfActions code :
Code:
if ((player getVariable"humanity") <= 0) then {
    if (("ItemEtool" in weapons player) && ("PartWoodPile" in _mags)) then {
        hasBombItem = true;
    } else {
        hasBombItem = false;
    };
    if ((speed player <= 1) && hasBombItem) then {
        hasBomb = true;
    } else {
        hasBomb = false;
    };
    if ((hasBomb) && ("HandGrenade_West" in _mags)) then {
        if (s_player_makeBomb < 0) then {
            s_player_makeBomb = player addAction [("<t color=""#c30000"">" + ("Place Exploding Booby Trap") +"</t>"),"Scripts\setBomb.sqf","",5,false,true,"",""];
        };
    } else {
        player removeAction s_player_makeBomb;
        s_player_makeBomb = -1;
    }; // End toggling of Matt L's Bomb
};

for heroes it would be
Code:
if ((player getVariable"humanity") >= 4999) then {
    if (("ItemEtool" in weapons player) && ("PartWoodPile" in _mags)) then {
        hasBombItem = true;
    } else {
        hasBombItem = false;
    };
    if ((speed player <= 1) && hasBombItem) then {
        hasBomb = true;
    } else {
        hasBomb = false;
    };
    if ((hasBomb) && ("HandGrenade_West" in _mags)) then {
        if (s_player_makeBomb < 0) then {
            s_player_makeBomb = player addAction [("<t color=""#c30000"">" + ("Place Exploding Booby Trap") +"</t>"),"Scripts\setBomb.sqf","",5,false,true,"",""];
        };
    } else {
        player removeAction s_player_makeBomb;
        s_player_makeBomb = -1;
    }; // End toggling of Matt L's Bomb
};
 
For the bomb to only detonate when a hero walks over it use
Code:
_bombTrigger = createTrigger["EmptyDetector",[0,0,0]];
_bombTrigger setTriggerArea [5,5,0,false];
_bombTrigger setTriggerActivation ["ANY","PRESENT",true];
_bombTrigger setTriggerStatements ["{(isPlayer _x) && (_x isKindOf 'Man') && ((_x getVariable ["humanity",0]) >= 5000)} count thisList > 0;","0 = [thisTrigger,_spawnStash,thislist] execVM 'Scripts\detonateBomb.sqf'",""]; //You don't want a vehicle like a helicopter to set off the trigger.
_bombTrigger setVariable ["ownerUID",_bombOwnerUID];
or for when a bandit walks over it
Code:
_bombTrigger = createTrigger["EmptyDetector",[0,0,0]];
_bombTrigger setTriggerArea [5,5,0,false];
_bombTrigger setTriggerActivation ["ANY","PRESENT",true];
_bombTrigger setTriggerStatements ["{(isPlayer _x) && (_x isKindOf 'Man') && ((_x getVariable ["humanity",0]) <= 0)} count thisList > 0;","0 = [thisTrigger,_spawnStash,thislist] execVM 'Scripts\detonateBomb.sqf'",""]; //You don't want a vehicle like a helicopter to set off the trigger.
_bombTrigger setVariable ["ownerUID",_bombOwnerUID];

In createBomb.sqf
 
fn_selfActions (modifiable) :
Code:
if ((speed player <= 1)) then {
    if (s_player_makeBomb < 0) then {
        s_player_makeBomb = player addAction [("<t color=""#c30000"">" + ("Place Exploding Booby Trap") +"</t>"),"Scripts\setBomb.sqf","",5,false,true,"",""];
    };
} else {
    player removeAction s_player_makeBomb;
    s_player_makeBomb = -1;
}; // End toggling of Matt L's Bomb

I changed how the fn_selfActions points to the script, an option will appear so long as the player is slow moving, instead of them requiring all the items ( most players had no clue there was such an option, because rarely does anyone have all the materials at once). To counter this I added the supply check to setBomb.sqf, so even if they click it and don't have the materials it will display a cutText saying what is needed.
DOWNLOAD LINK
 
Back
Top