Looking for help, will donate

Vonstorm

Member
After playing (with help) with Matt Ls Booby trap script, moving it to a right click option to grenades, I wondered if it couldn't be generalized with more vars to work with more items and effects. I have some programming experience, but mostly PHP and the syntax, Arma2 engine stuff and lack of time is making it difficult for me to get this done the way I would like.

anyway here is the overview of what I think it should do and how..
Code:
script 1 - place Trigger item and trigger.

Variables:
- Item Clicked
- Item Placed
- Placement time
- Countdown Time - set to trigger placement
- Trigger Range
- Target Type (Unit, Player, Vehicle etc)
- Trigger effect

On right click of inventory item (DZE_click_actions) -

run animation - (and wait var placement time)
Remove item from inventory
Place visual item (item placed)
Place trigger (assign vars Range, Effect, Target type, run script detonate on trigger)


script 2 detonate

- Run effect (case based on trigger effect)
    case trigger effect grenade then -
    Case trigger effect flare then -
    case trigger effect smoke then -
    etc.

Now There may be barriers to this, but I know there are some extraordinary people on here, looking for a base frame that I can learn from and work with.

Thanks for your time
 
Here is my first runup on it (not tested yet)

settrap.sqf - called by right clicking grenade, flare, smoke, etc.
Code:
private ["_traptype","_mypos","_mags","_tool","_isAlive","_onLadder","canDo"];

_mags = magazines player;
_tool = items player;
_isAlive = alive cursorTarget;
_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
_canDo = (!r_drag_sqf and !r_player_unconscious and !_onLadder);
_traptype = "grenade" // Here is the effect classname of the traps effect. edit this and save sql as a name you remember, then set the right click option to this sql. Change item in if statement.

if ((speed player <= 1) && !_isAlive && _canDo) then { //another if statement because fn_self actions is not a while loop.
   
    if (("ItemToolbox" in _tool) && ("HandGrenade_East" in _mags)) then {

        player playActionNow "Medic";
        
        _mypos = getPosATL player;
        _bombOwnerUID =  getPlayerUID player;
        
        sleep 5;
        
       
        player removeMagazine "HandGrenade_East";
        
        DZ_boobyTrap = [_traptype,_myPos];
        publicVariableServer "DZ_boobyTrap"; //Send needed values to server.
        DZ_boobyTrap = []; //Clean up global variable.
        
        cutText [format["You have placed an explosive trap. 15 seconds till its live!!!"], "PLAIN DOWN"];
    }
   
    else {
        cutText [format["You do not have the required material. You need a toolbox & grenade"], "PLAIN DOWN"];
    };
};

createtrap.sqf - called from global var
Code:
private ["_traptype","_bombPos","_spawnStash","_bombTrigger","_objectUID"];
if (!isServer) exitWith {}; //Make sure this script runs only on server.
_traptype = (_this select 0) select 0;      //diag_log format ["Bomb owner's UID is %1",_bombOwnerUID];
_bombPos = (_this select 0) select 1;          //diag_log format ["Bomb's position is %1",_bombPos];
//Create the stash object
_spawnStash = createVehicle ["BeltBuckle_DZE", [0,0,0], [], 0, "NONE"];
//Prevent server from deleting the object by assigning it a blank UID.
_spawnStash setVariable ["ObjectUID",""];
sleep 15;
//Create the trigger object
_bombTrigger = createTrigger["EmptyDetector",[0,0,0]];
_bombTrigger setTriggerArea [5,5,0,false];
_bombTrigger setTriggerActivation ["ANY","PRESENT",true];
_bombTrigger setTriggerStatements ["{(_x isKindOf 'Man')} count thisList > 0;","0 = [thisTrigger,_spawnStash,thislist] execVM 'Scripts\detonatetrap.sqf'",""];
_bombTrigger setVariable ["traptype",_traptype];
cutText [format["Booby trap is now live until server restart"], "PLAIN DOWN"];
//Set position of stash and trigger
_spawnStash setPosATL _bombPos;
_bombTrigger setPosATL _bombPos;
DZ_boobyTrap = nil;

and finally detonatetrap.sqf
Code:
private ["_trigger","_stashObject","_nearbyUnits","_traptype","_nearbyPlayers","_theBomb"];

if (!isServer) exitWith {};

_trigger = _this select 0;              //The trigger object
_stashObject = _this select 1;  //The stash object
_nearbyUnits = _this select 2;  //All units in trigger area (may not be players).

//diag_log "Bomb is triggered.";

_traptype = _trigger getVariable "traptype"; //Retrieve owner's UID.
//Check if there is at least one unit in trigger area that isn't the bomb owner.
if (( count _nearbyUnits) > 0) then {
    //Create bomb on trigger object
    _theBomb = createVehicle [_traptype,getPosATL _trigger,[],0,"NONE"];
        //Remove trigger and stash after bomb is created and detonated.
    deleteVehicle _trigger;
    deleteVehicle _stashObject;
        //diag_log "Exploded bomb. units in trigger area.";
} else {
        //diag_log "No units present.";
};
 
Back
Top