Spawn Sputtering Road Flares possible?

ok done:

I've tried to add a right click option to the e-tool which start a building process for a booby trap.
This is all untested so far, but hopefully should work ^^ otherwise i will check the whole thing till its working.

Anyway

Here are the files:
https://www.dropbox.com/s/45sfd0t1rqt85f5/new_Mission.rar?dl=0

Following changes i made in your mission and server.pbo:

compiles.sqf:
Code:
player_build =                compile preprocessFileLineNumbers "custom\player_build.sqf";
player_selectSlot =            compile preprocessFileLineNumbers "custom\ui_selectSlot.sqf";
_null = [] execVM "scripts\player_bomb.sqf";

ui_selectSlot.sqf
Code:
    if (_item == "ItemEtool") then
        {
        _menu =  _parent displayCtrl (1600 + _numActions);
        _menu ctrlShow true;
        _text =  "Flare Trap";
        _script = "[""Land_IED_v4_PMC"",[""ItemEtool""],[[""HandGrenade_West"", 1],[""PartGeneric"", 1]],[0,6,0]] execVM ""custom\player_build.sqf"";";
        _height = _height + (0.025 * safezoneH);
        uiNamespace setVariable ['uiControl', _control];
        _menu ctrlSetText _text;
        _menu ctrlSetEventHandler ["ButtonClick",_script];
        };

alot of things in the player_build.sqf better you compare it with the default to see the whole changes.

server_monitor:

Code:
//Handle Traps (Land_IED_v4_PMC)
            if (typeOf(_object) == "Land_IED_v4_PMC") then {
                    _object setVariable ["isBomb", 1, true];//this will be known as a bomb instead of checking with classnames in player_bomb
                    _object addEventHandler ["HandleDamage", {false}];
                };


I do not take any credits for this script, i just combined some scripts here and there to get this working. This is not tested but the right way, just test it and tell me the results. If its not working tell me or try to fix it for yourself :)

Anyway have fun with this so far
 
OK this is where I am at.
I got the positions and variables sorted out
The flare detonates, and I can hear the object (FlareCountermeasure), but not see it.
It seems to me that its creating underground (from the sound) even when z pos is set to 150.
There are no errors in the log.
Excuse the rem and diag lines, once it works Ill clean it up.

detonateFlare.sqf
Code:
private ["_trigger","_stashObject","_nearbyUnits","_bombOwnerUID","_nearbyPlayers","_theBomb","_lightArea","_lightSpark","_position","_pos1","_pos2","_flarepos","_flare","_v0","_inc"];

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).
_position = (getPosATL _trigger);
_pos1 = _position select 0;
_pos2 = _position select 1;
_pos3 = _position select 2;
//diag_log format[ "pos3 %1", _pos2];
//diag_log format["this %1,%2,%3",_this select 0, _this select 1,  _this select 2];
//diag_log format[ "trigger %1", _trigger];


// assign position
//_flarepos = [_pos1,_pos2,50];
if ((count _nearbyUnits) > 0) then {   
    //Create bomb on trigger object
  //  _theBomb = "F_40mm_Red" createVehicle [_position select 0, _position select 1, _position select 2];
   

_v0 = 30;
_inc = 0.5;
_flare = "FlareCountermeasure" createvehicle[_position select 0,_position select 1,150];
//lighting
//_isLocal = local _flare;
            //Area Light
            _lightArea = "#lightpoint" createVehicleLocal (getPosATL _flare);
            _lightArea setLightColor [0.5,0,0]; //[0.1,0.005,0.005];
            _lightArea setLightAmbient [0.2,0.01,0.01];
            _lightArea setLightBrightness 0.2;
            _lightArea lightAttachObject [_flare, [0,0,0]];
           
            //Spark Light
            _lightSpark = "#lightpoint" createVehicleLocal (getPosATL _flare);
            _lightSpark setLightColor [0.1,0.1,0.1];
            _lightSpark setLightAmbient [0.05,0.05,0.05];
            _lightSpark setLightBrightness 0.05;
            _lightSpark lightAttachObject [_flare, [0,0,0]];
           
            while {alive _flare} do {
                _lightArea setLightAmbient [((random 0.2) + 0.2),0.01,0.01];
                //_lightArea setLightColor [((random 0.1) + 0.1),0.005,0.005];
                sleep (random 0.1);
            };
            deleteVehicle _lightArea;
            deleteVehicle _lightSpark;


//deletevehicle flare1;
//player removeAction 0;

/*while {getpos(_flare) select 2 > 0} do
{
sleep 0.125;
//_pos = getpos(flare);
//Hint format ["Height: %1\nSpeed: %2",_pos select 2,_v0];
If ((alive _flare) and (_v0)>-1) then
{
_flare setVelocity [0,0,(_v0)];
_v0=(_v0) - (_inc);
};
};

hint "";
*/   
   
   
   
    diag_log format ["flare detonated"];
        //Remove trigger and stash after bomb is created and detonated.
    deleteVehicle _trigger;
    //deleteVehicle _stashObject;
        //diag_log "Exploded bomb. Players in trigger area are not bomb creator.";
} else {
        //diag_log "no trigger";
};
Thanks again for any input
 
working ... bored ... anxiously awaiting something to do here ... what about this line right here? did it output a height?
//Hint format ["Height: %1\nSpeed: %2",_pos select 2,_v0];
I
 
the _trigger variable is passed to this script to obtain its position. what is the height of the trigger?

ignore that , i see you set altitude manually to 150
 
well I did getPosATL _flare after its created and got
21:47:12 "countermeasure position [7198.6,2988.57,150]"

which seems correct. Im wondering if the FlareCountermeasure object is doing something...
Will try some more, any insights welcome.
 
WOOT!
Due to my density it has been a hard and much assisted birth, but it works. I changed the Countermeasure for a f_40mm_red and attached the lightpoints and it works. I would like to Thank you guys for not just the help in the script but helping me understand it, and to Matt L for the booby trap script that its based (almost entirely) on. Ill clean it up and post it later for anyone wanting to give it a try.
 
okay, so lets wrap up. you have a working script that launches a flare into the air when a player activates a trigger.
the flare descends like normal. it would be cool if it would take longer to descend, like 5 minutes, so a town could be lit up. every few seconds set the altitude to altitude x 1.1 or something like that. have to test the rate of descent to get an accurate adjustment.
that would make night more acceptable to players and add a unique atmosphere .. dibs on this idea for my unique 24/7 midnight server!
 
should be do-able in this bit:
Code:
/*while {getpos(_flare) select 2 > 0} do
{
sleep 0.125;
//_pos = getpos(flare);
//Hint format ["Height: %1\nSpeed: %2",_pos select 2,_v0];
If ((alive _flare) and (_v0)>-1) then
{
_flare setVelocity [0,0,(_v0)];
_v0=(_v0) - (_inc);
};
};

Ill clean it up and fiddle with it. at the moment the flare lasts around 10 seconds before hitting the ground and going out.
 
OK here are the 3 finished scripts. You need Road Flares and a toolbox.
I have the first setflare.sqf firing from a right click in roadflares.

setFlare.sqf
Code:
private ["_mypos","_bombOwnerUID","_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);
if ((speed player <= 1) && !_isAlive && _canDo) then { //another if statement because fn_self actions is not a while loop.
   
    if (("ItemToolbox" in _tool) && ("HandRoadFlare" in _mags)) then {

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

Add in init.sqf the following line (set to the path where you save the scripts)

Code:
if (isServer) then {
      "DZ_flareTrap" addPublicVariableEventHandler {[_this select 1] execVM 'Scripts\createFlare.sqf'};
};

CreateFlare.sqf
Code:
private ["_bombOwnerUID","_bombPos","_spawnStash","_bombTrigger","_objectUID"];
if (!isServer) exitWith {}; //Make sure this script runs only on server.
_bombOwnerUID = (_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 ["Land_IED_v4_PMC", [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\detonateFlare.sqf'",""];
_bombTrigger setVariable ["ownerUID",_bombOwnerUID];
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_flareTrapTrap = nil;

detonateFlare.sqf
Code:
private ["_trigger","_stashObject","_nearbyUnits","_bombOwnerUID","_nearbyPlayers","_theBomb","_lightArea","_lightSpark","_position","_flarepos","_flare","_v0","_inc"];

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).
_position = (getPosATL _trigger);




// assign position

if ((count _nearbyUnits) > 0) then {   
    //Create bomb on trigger object
 
// velocity constants - not played with these
_v0 = 30;
_inc = 0.5;
_flare = "F_40mm_Red" createvehicle[_position select 0,_position select 1,150];
//diag_log format[ "countermeasure position %1", getPosATL _flare];
//lighting
//_isLocal = local _flare;
            //Area Light
            _lightArea = "#lightpoint" createVehicleLocal (getPosATL _flare);
            _lightArea setLightColor [0.5,0,0]; //[0.1,0.005,0.005];
            _lightArea setLightAmbient [0.2,0.01,0.01];
            _lightArea setLightBrightness 0.2;
            _lightArea lightAttachObject [_flare, [0,0,0]];
diag_log format[ "-lightarea position %1", getPosATL _lightArea];           
            //Spark Light
            _lightSpark = "#lightpoint" createVehicleLocal (getPosATL _flare);
            _lightSpark setLightColor [0.1,0.1,0.1];
            _lightSpark setLightAmbient [0.05,0.05,0.05];
            _lightSpark setLightBrightness 0.05;
            _lightSpark lightAttachObject [_flare, [0,0,0]];
diag_log format[ "lightspark position %1", getPosATL _lightspark];           
            while {alive _flare} do {
                _lightArea setLightAmbient [((random 0.2) + 0.2),0.01,0.01];
                //_lightArea setLightColor [((random 0.1) + 0.1),0.005,0.005];
                sleep (random 0.1);
            };
            deleteVehicle _lightArea;
            deleteVehicle _lightSpark;



// below are the untested velocity vars
/*while {(getpos _flare) select 2 > 0} do
{
sleep 0.125;

If ((alive _flare) and (_v0)>-1) then
{
_flare setVelocity [0,0,(_v0)];
_v0=(_v0) - (_inc);
};
};

hint "";
*/   
   
       
//Remove trigger and stash after bomb is created and detonated.
    deleteVehicle _trigger;
   
} else {
        //diag_log "no trigger";
};

Its not pretty, and Im sure there are better ways, but it works :)
 
Back
Top