Posted: . At: 9:02 PM. This was 6 years ago. Post ID: 12346
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.



Sponsored



Arma 3 code snippets for making mods and missions.


This is a class that create a backpack that will unpack into a IED. It will detonate if shot at.

	class B_Carryall_EXP : Weapon_Bag_Base {
		scope = 2;
		class assembleInfo {
			assembleTo = "ModuleExplosive_IEDLandBig_F";
			base = "";
			displayName = "NATO Exp backpack.";
			dissasembleTo[] = {};
			primary = 1;
		};
		displayName = "NATO Exp backpack.";
		hiddenSelectionsTextures[] = {"\A3\weapons_f\ammoboxes\bags\data\backpack_small_mcamo_co.paa"};
		picture = "\A3\weapons_f\ammoboxes\bags\data\ui\icon_B_C_Small_mcamo.paa";
		model = "\A3\weapons_f\Ammoboxes\bags\Backpack_Small";
		editorPreview = "\A3\EditorPreviews_F\Data\CfgVehicles\Default\Prop.jpg";
		editorSubcategory = "EdSubcat_Backpacks";
		faction = BLU_F;
		mass = 1;
		dlc = "backpack";
		maximumLoad = 0; // 160;
		isbackpack = 1;
	};

Use this script to place a random ammo crate in buildings around a center point. This could be very useful for spawning loot.

#define AMMO "rhs_3Ya40_1_single","Box_IED_Exp_F","rhs_mags_crate","Box_East_Grenades_F","ACE_Box_Ammo"
 
_houseList = _randPos124 nearObjects ["House",300];
{
 _c = 0;
 while { format ["%1", _x buildingPos _c] != "[0,0,0]" } do {_c = _c + 1};
 if (_c > 0) then
    {
       _ranNum = floor(random _c);
       _crate = [AMMO] call BIS_fnc_selectRandom createVehicle [0,0,0];
       _crate setPos (_x buildingPos _ranNum);
    };
 sleep 0.123;
} forEach _houseList;

Spawn a machine gunner to guard an enemy HQ.

// Spawn a gunner to guard the HQ.
 
// -------------------------------------------------------------------------------------------
 
_randPos14 = [_randPos124, 0, 95, 12, 0, 0.3, 0] call BIS_fnc_findSafePos;
 
_mg13 = createVehicle ["rhs_KORD_high_MSV", _randPos14, [], 0, "CAN_COLLIDE"];
 
_mgguy13 = [_randPos14, EAST, ["rhsgref_ins_crew"],[],[],[],[],[],232] call BIS_fnc_spawnGroup;
 
((units _mgguy13) select 0) moveInGunner _mg13;
 
// -------------------------------------------------------------------------------------------

Select a random building in a city and then get the position of that building to spawn stuff around it.

_allHQ = getMarkerPos "aoMarker" nearObjects ["House", 600];
_building = selectRandom _allHQ;
_building setVehicleVarName "hq1"; hq1 = _building;
 
_randPos124 = getPos _building;

Find a random position in a circle shaped marker. Very useful for finding a position to spawn a HQ or other enemy installation.

_mrk = "aoCircle";
_area = markerSize _mrk;
_nul = _area pushBack markerDir _mrk;
_nul = _area pushBack ( markerShape _mrk isEqualTo "Ellipse" );
_pos11 = [ _mrk, _area ] call BIS_fnc_randomPosTrigger;
_randPos33 = [_pos11, 95, 400, 10, 0, 0.5, 0] call BIS_fnc_findSafePos;

Spawn an enemy CAS plane that will guard the TAOR from enemy attack. This is selecting a random plane from a list. The value in the square brackets is a location. Place an object in the editor, right-click on it and then use the log->position to clipboard option. This gives you the location of the object that can be used in a script.

// Spawn a CAS jet to patrol the AO.
 
#define PLANE_TYPE "O_Plane_Fighter_02_F","O_Plane_Fighter_02_Stealth_F","rhs_mig29s_vmf","RHS_Su25SM_vvsc","RHS_T50_vvs_generic","RHS_T50_vvs_generic_ext","RHS_T50_vvs_blueonblue"
 
_plane = createVehicle [([PLANE_TYPE] call BIS_fnc_selectRandom), [20479.1,1.69426,-0.00201988], [], 0, "FLY"];
 
_plane addEventHandler ["Fired",{
	(_this select 0) setVehicleAmmo 1
	}];
 
_pilotguy = [[20474.1,7.90055,-1.90735e-006], EAST, ["rhs_pilot"],[],[],[],[],[],232] call BIS_fnc_spawnGroup;
 
((units _pilotguy) select 0) moveInDriver _plane;
 
_wpcas = _pilotguy addWaypoint [getmarkerPos "aoMarker", 0];
_wpcas setWaypointBehaviour "SAFE";
_wpcas setWaypointCombatMode "RED";
_wpcas setWaypointCompletionRadius 1900;

This code will make all buildings in a 1900 meter radius of your base indestructible.

{ _x allowdamage false; } foreach (nearestTerrainObjects [[11540,17836.3,0],["house"],1900]);

Spawn some trees and a crane around your base.

//spawn a construction crane.
_posnew19 = [12621.9,17735.6,0];
_sol15 = createSimpleObject ["a3\structures_f\ind\crane\Crane_F.p3d", _posnew19];
_sol15 setPos [_posnew19 select 0, _posnew19 select 1, 36.6];
 
sleep 2;
 
_pos = [12514.7,17720.9,3.05176e-005]; 	//define a position, close to player
_tree = createSimpleObject ["a3\vegetation_f_exp\Tree\t_Cocos_tall_F.p3d", _pos]; 
_tree setPos [_pos select 0, _pos select 1,18];	//trees spawn below ground, so we move it up by 8 m
 
sleep 1;
 
_pos2 = [12486.7,17692.8,0]; 	//define a position, close to player
_tree2 = createSimpleObject ["a3\vegetation_f_exp\Tree\t_Cocos_tall_F.p3d", _pos2]; 
_tree2 setPos [_pos2 select 0, _pos2 select 1,18];	//trees spawn below ground, so we move it up by 8 m
 
sleep 1;
 
_pos3 = [11540,17836.3,0]; 	//define a position, close to player
_tree3 = createSimpleObject ["a3\vegetation_f_exp\Tree\t_Cocos_tall_F.p3d", _pos2];
_tree3 setPos [_pos3 select 0, _pos3 select 1,18];	//trees spawn below ground, so we move it up by 8 m
 
sleep 1;

Spawn a player in a random safe spot around the spawn point.

_randPos14 = [getMarkerPos "respawn_west", 90, 400, 12, 0, 0.3, 0] call BIS_fnc_findSafePos;
player setpos _randPos14;

Leave a Comment

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