Jump to content
Rich_R

Going from addaction to trigger

Recommended Posts

Gents

How would I take a script that works off an addaction menu such as this light switch script;

http://www.armaholic.com/page.php?id=24220

To using it in a trigger? Want a trigger to switch off the light and a trigger to put them back on.

Thanks!

Share this post


Link to post
Share on other sites

Ive used it as a radio call trigger and ive used it as part of an objective trigger.

These lines can go inside a trigger. Trigger can be tied to a specific building to be destroyed, a radio call or whatever you want. I believe you'd need 2 triggers, 1 for each action. like if radio call alpha then lights out, if radio call bravo then lights on. just put the line you need into the ON ACT. of each trigger. 0.99 works just fine to kill most lights. You can use whatever number you want long as it's below 1 just enough to disable but not destroy.

//Lights OUT
0 = [0.97] execVM "lights.sqf";
//Lights ON
0 = [0] execVM "lights.sqf";

Lights.sqf is this script. where it says 5000 in the script, that's the range of the event from the marker that you put down. I like to set it to a range of a town or military complex in my missions, then activated by destroying a power generator or something. Not sure if BIS has added any new lights to Arma 3, but if they have, just add them into the list of lights in the lights.sqf so they too will get shut off. Looks dumb if all but 3 lights in a town get knocked out.

// off: 0 = [0.97] execVM "lights.sqf";
// on: 0 = [0] execVM "lights.sqf";

_types = [
"Lamps_Base_F", 
   "Land_LampAirport_F", 
   "Land_LampSolar_F", 
   "Land_LampStreet_F", 
   "Land_LampStreet_small_F", 
   "PowerLines_base_F", 
   "Land_LampDecor_F", 
   "Land_LampHalogen_F", 
   "Land_LampHarbour_F", 
   "Land_LampShabby_F", 
   "Land_PowerPoleWooden_L_F", 
   "Land_NavigLight", 
   "Land_runway_edgelight", 
   "Land_runway_edgelight_blue_F", 
   "Land_Flush_Light_green_F", 
   "Land_Flush_Light_red_F", 
   "Land_Flush_Light_yellow_F", 
   "Land_Runway_PAPI", 
   "Land_Runway_PAPI_2", 
   "Land_Runway_PAPI_3", 
   "Land_Runway_PAPI_4", 
   "Land_fs_roof_F", // Fuel station roof lights 
   "Land_fs_sign_F"];
_onoff = _this select 0;

for [{_i=0},{_i < (count _types)},{_i=_i+1}] do
{
   // powercoverage is a marker I placed.
_lamps = getMarkerPos "LIGHTSOURCE" nearObjects [_types select _i, 5000];
sleep 1;
{_x setDamage _onoff} forEach _lamps;
};

Here's where it gets fun. I like to use the Download data script by t-800a http://www.armaholic.com/page.php?id=23069 that I modified a bit with different wording in the messages when activated. I think his is in German, so I changed a lot of the messages to english in the version I use.

So in my triggers on a mission where the team has to upload a virus into a power station computer, I do the following:

In the trigger CONDITION:

T8_pubVarDataTask_laptop01

ON ACT.

0 = [0.97] execVM "lights.sqf";

Timout set to 8 seconds MIN/MID/MAX to simulate the time of the power shutting down across the grid.

A second trigger I use to give a message that the virus is being uploaded to the grid is

in the CONDITION

T8_pubVarInUse_laptop01

in the ON ACT. for the message

hint "Virus being uploaded to the Power Grid, Stand By...."

in the ON ACT. for the message.

for the script to work, this goes into the init.sqf

call compile preprocessFile "downloadData.sqf";

waitUntil { !isNil "downloadDataDONE" };
if ( !isServer ) exitWith {}; 

sleep 10; // I dont know why, but some sleep is requied or the Actions on the Objects wont work ... this is beyond my knowledge 

//Line below, add names of any Items to be used for this script. 
[ [laptop01], "T8_fnc_addActionLaptop", true, true] spawn BIS_fnc_MP;

Here's the downloadData.sqf version that I use in some of my missions. just change the words for the messages to suit your needs;

/*
=======================================================================================================================

downloadData - script to download data from a laptop and because of this complete a task (as example)

File:		downloadData.sqf
Author:		T-800a

=======================================================================================================================
*/

T8_varFileSize = 32875;  								// Filesize ... smaller files will take shorter time to download!

T8_varTLine01 = "Upload Aborted!";				// download aborted
T8_varTLine02 = "Upload in progress by someone else!";			// download already in progress by someone else
T8_varTLine03 = "Upload started, stand by...";					// download started
T8_varTLine04 = "Upload complete!!";				// download finished
T8_varTLine05 = "##  Upload Virus  ##";				// line for the addaction

T8_varDiagAbort = false;
T8_varDownSucce = false;



////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

T8_fnc_abortActionLaptop =
{
if ( T8_varDownSucce ) then 
{
	// hint "DEBUG - DONE";
	T8_varDiagAbort = false;
	T8_varDownSucce = false;		

} else { 
	player sideChat T8_varTLine01; 
	T8_varDiagAbort = true; 
	T8_varDownSucce = false; 
};
};


T8_fnc_addActionLaptop =
{
{
	private [ "_DT", "_cDT" ];
	_DT = format [ "%1_%2", "T8_pubVarDataTask", _x ];
	_cDT = missionNamespace getVariable [ _pV, false ];
	if ( _cDT ) exitWith {};
	_x addAction [ T8_varTLine05, { call T8_fnc_ActionLaptop; }, [], 10, false, false ];
} forEach _this;	
};


T8_fnc_removeActionLaptop =
{
_laptop = _this select 0;
_id = _this select 1;
_laptop removeAction _id;
};


T8_fnc_ActionLaptop =
{
private [ "_laptop", "_caller", "_id", "_cIU", "_DT", "_IU" ];
_laptop = _this select 0;
_caller = _this select 1;
_id = _this select 2;

_DT = format [ "%1_%2", "T8_pubVarDataTask", _laptop ];
_IU = format [ "%1_%2", "T8_pubVarInUse", _laptop ];

_cIU = missionNamespace getVariable [ _IU, false ];
if ( _cIU ) exitWith { player sideChat T8_varTLine02; };

player sideChat T8_varTLine03;

missionNamespace setVariable [ _IU, true ];
publicVariable _IU;

[ _laptop, _id, _IU, _DT ] spawn 
{
	private [ "_laptop", "_id", "_newFile", "_dlRate" ];

	_laptop		= _this select 0;
	_id			= _this select 1;
	_IU			= _this select 2;
	_DT			= _this select 3;

	_newFile = 0;

	createDialog "T8_DataDownloadDialog";

	sleep 0.5;
	ctrlSetText [ 8001, "Connecting ..." ];
	sleep 0.5;
	ctrlSetText [ 8001, "Connected:" ];		
	ctrlSetText [ 8003, format [ "%1 kb", T8_varFileSize ] ];		
	ctrlSetText [ 8004, format [ "%1 kb", _newFile ] ];		

	while { !T8_varDiagAbort } do
	{
		_dlRate = 200 + random 80;
		_newFile = _newFile + _dlRate;

		if ( _newFile > T8_varFileSize ) then 
		{
			_dlRate = 0;		
			_newFile = T8_varFileSize;
			ctrlSetText [ 8001, "Download finished!" ];	
			T8_varDiagAbort = true;
			player sideChat T8_varTLine04;
			T8_varDownSucce = true;

			missionNamespace setVariable [ _DT, true ];
			publicVariable _DT;				

			[ [ _laptop, _id ], "T8_fnc_removeActionLaptop", true, true ] spawn BIS_fnc_MP;
		};

		ctrlSetText [ 8002, format [ "%1 kb/t", _dlRate ] ];		
		ctrlSetText [ 8004, format [ "%1 kb", _newFile ] ];				

		sleep 0.2;
	};

	T8_varDiagAbort = false;

	missionNamespace setVariable [ _IU, false ];
	publicVariable _IU;		
};
};

downloadDataDONE = true;

Anyways, that's how I like to use the lights.sqf script. You can get creative with it anyway you want. I like to tie it to objectives like uploading a virus into the power grid, or destroying a power generator. Fun couple scripts to play around with.

Edited by RTEK

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×