Posted: . At: 7:58 PM. This was 5 years ago. Post ID: 12882
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


Very useful Arma 3 scripting samples for making a nice mission easily.


To set the arsenal action on all crates in your base, use this code. This will give the Arsenal action to the Cargo Net Box item.

Put this in the initPlayerLocal.sqf file.

{
	[_x, "Open the Arsenal", "a3\Ui_f\data\GUI\Cfg\RespawnRoles\assault_ca.paa", "a3\Ui_f\data\GUI\Cfg\RespawnRoles\assault_ca.paa", "(_this distance _target < 6) && (isNull (findDisplay 162))", "isNull (findDisplay 162)", {}, BIS_holdActionProgress, {["Open",true] call BIS_fnc_arsenal;}, {}, [], 0.3, nil, false] call BIS_fnc_holdActionAdd;
} forEach (allMissionObjects "Misc_cargo_cont_net2");

Just place the item in your mission, and then you are set. It is automatic.

Make all buildings around your spawn point invulnerable. This stops trolls destroying it.

{ 
	_x allowdamage false
} foreach (nearestTerrainObjects [getMarkerPos "respawn_west",[],900]);

This code will spawn 3 heavy machine gunners randomly around the battlefield. This makes it unpredictable and more fun. A mission is boring if it just spawns the same things over and over again, make it more random and it is more fun.

_Center = _randPos2;
_Circle1 = [_Center, 150, 150, 0, 0, 20, 0] call BIS_fnc_findSafePos;
_Circle2 = [_Center, 250, 250, 0, 0, 20, 0] call BIS_fnc_findSafePos;
_Circle3 = [_Center, 350, 350, 0, 0, 20, 0] call BIS_fnc_findSafePos;
 
_gunners = createGroup [east, true];
 
_aiShooters = [_Circle1,_Circle2,_Circle3];
{
	sleep 1;
	_mg13 = createVehicle ["rhs_KORD_high_MSV", _x, [], 0, "CAN_COLLIDE"];
	_gunners = [[0,0,0], EAST, ["rhsgref_ins_machinegunner"],[],[],[],[],[],232] call BIS_fnc_spawnGroup;
	((units _gunners) select 0) moveInGunner _mg13;
	_gunners enableDynamicSimulation true;
	_gunners deleteGroupWhenEmpty true;
 
} forEach _aiShooters;

Spawning a random helicopter, that will attack an enemy emplacement. This is very easy to do, and provides a nice challenge for players to take it down.

private _elevPos1;
private _elevPos2;
 
_elevPos1 = [Loc, 1200, 100, 10] call BIS_fnc_findOverwatch;
 
_CounterHeloType = selectRandom ["RHS_Mi24P_vdv","RHS_Mi24V_vdv","RHS_Mi8MTV3_vdv","RHS_Mi8MTV3_heavy_vdv","rhs_mi28n_vvsc","RHS_Ka52_vvsc"];
 
_helo_Array = [[15000, _elevPos1 select 1, 2000], 20, "RHS_Mi24P_vdv", EAST] call BIS_fnc_spawnVehicle;
_helo_Patrol = _helo_Array select 0;
_helo_crew = _helo_Array select 1;
[_helo_Array select 2, Loc] call BIS_fnc_taskAttack;
 
_myvec = _helo_Array select 0;
 
_myvec addEventHandler ["Fired",{
	(_this select 0) setVehicleAmmo 1
}];

Finding a nearest road to the spawn position of a vehicle and then spawning a vehicle to perfectly align with the road.

OptimisedDir = getDir (_nearestRoads select 0);

This seems to be hard, but it is not.

Then spawning the vehicle.

		// Optimize positions (near roads if possible), prevent spawning near FOBs
		private _optimizedPos = _optimizedPos findEmptyPosition [0, 50, _truckClass];
 
		if (count _optimizedPos > 0) then {
			_optimizedPos set [2, (_optimizedPos select 2) + 1.3];
 
			// prepare terrain: spawn above, hide terrainObjects
			{_x hideObjectGlobal true} forEach (nearestTerrainObjects [_optimizedPos, [], 10]);
 
			private _truck = _truckClass createVehicle _optimizedPos;
			_truck enablesimulation false;
			_truck allowdamage false;
			_truck setVehicleLock "LOCKED";
			[_truck,["Enable vehicle","(_this select 0) enablesimulation true; (_this select 0) setVehicleLock 'UNLOCKED',(_this select 0) allowdamage true;",[],1,false,true,"","(_this distance _target) < 4"]] remoteExec ["addAction",0];
 
			//_truck enableDynamicSimulation; // Allow dynamic simulation if ai not used
			//_nVehicles = _nVehicles + 1;
			_truck setDir OptimisedDir;
		};
		sleep _timeout;

This was easy to work out, and now the vehicle is aligned with the road it spawns at. This is a heap of fun.


1 thought on “Very useful Arma 3 scripting samples for making a nice mission easily.”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.