Jump to content
Sign in to follow this  
Barabara

Random spawn for fortifications, road blocks etc

Recommended Posts

I'm trying to create a mission with random objectives and random ao's, how do I create fortified positions and road blocks in the editor (complete with personell manning them) that are then moved to one out of several pre-defined locations when the mission begins?

Share this post


Link to post
Share on other sites

No one with a good idea how to accomplish this? It's the last big step towards creating missions with some decent replayability.

Share this post


Link to post
Share on other sites

You can use setPos to set object's position and setDir to set object's direction. Create an array of predefined positions, pick one of them with "random" command and then move roadblock on that position.

Share this post


Link to post
Share on other sites

You need to look into the object grabber from Arma2. You can create custom compositions (camps, roadblocks.. anything) and place them anywhere on the map, facing any direction. You'll need to edit things a tad bit though & take out any setVehicleInit / processInitCommands (as they are not supported by Arma3).

This works like a charm and i would recommend it to anyone who likes making compositions.

Edited by Iceman77

Share this post


Link to post
Share on other sites

iceman77 ". You'll need to edit things a tad bit though & take out any setVehicleInit / processInitCommands (as they are not supported by Arma3). ". hmm can i just delete those lines or what, maybe you can post your edited working versions of the script.. theyre not that big right??

Share this post


Link to post
Share on other sites

yeah just comment them out. Should just be 2 lines.

---------- Post added at 17:06 ---------- Previous post was at 17:04 ----------

updated - didn't understand your reply at first.

---------- Post added at 17:08 ---------- Previous post was at 17:06 ----------

here's what i used a couple months ago.

objectGrabber.sqf

scriptName "objectGrabber.sqf";
/*
File: objectGrabber.sqf
Author: Joris-Jan van 't Land

Description:
Converts a set of placed objects to an object array for the DynO mapper.
Places this information in the debug output for processing.

Parameter(s):
_this select 0: position of the anchor point
_this select 1: size of the covered area

Returns:
Success flag (Boolean)

init:
null = [getpos this,200] execvm "objectGrabber.sqf";
*/

//Validate parameter count
if ((count _this) < 2) exitWith {diag_log "Log: [objectGrabber] Function requires at least 2 parameter!"; false};

private ["_anchorPos", "_anchorDim"];
_anchorPos = _this select 0;
_anchorDim = _this select 1;

//Validate parameters
if ((typeName _anchorPos) != (typeName [])) exitWith {diag_log "Log: [objectGrabber] Anchor position (0) must be an Array!"; false};
if ((typeName _anchorDim) != (typeName 0)) exitWith {diag_log "Log: [objectGrabber] Covered area size (1) must be an Number!"; false};

private ["_objs"];
_objs = nearestObjects [_anchorPos, ["All"], _anchorDim];

diag_log "#####################################";
diag_log "### Log: objectGrabber: StartGrabbing";
diag_log "#####################################";

for "_i" from 0 to ((count _objs) - 1) do
{
 private ["_obj", "_type"];
_obj = _objs select _i;

_type = typeOf _obj;

//Exclude human objects.
private ["_sim"];
_sim = getText (configFile >> "CfgVehicles" >> _type >> "simulation");
if !(_sim in ["soldier"]) then
{
	private ["_objPos", "_dX", "_dY", "_z", "_azimuth", "_fuel", "_damage", "_vehicleinit"];
	_objPos = position _obj;
	_dX = (_objPos select 0) - (_anchorPos select 0);
	_dY = (_objPos select 1) - (_anchorPos select 1);
	_z = _objPos select 2;
	_azimuth = direction _obj;
	_fuel = fuel _obj;
	_damage = damage _obj;
	_vehicleinit = if (isnil {_obj getvariable "vehicleinit"}) then {{}} else {_obj getvariable "vehicleinit";};

	diag_log text(format ["%1,", [_type, [_dX, _dY, _z], _azimuth, _fuel, _damage, _vehicleinit]]);
};
};
diag_log "###################################";
diag_log "### Log: objectGrabber: EndGrabbing";
diag_log "###################################";

true

createComposition.sqf

/*
Original Script 
objectMapper.sqf Author: Joris-Jan van 't Land
Edited by armatec

Description:
Takes an array of data about a dynamic object template and creates the objects.

Parameter(s):
_this select 0: compositions name - "fuelDepot_us"
_this select 1: Direction in degrees - Number 
_this select 2: Location to start

Exsample:
["fuelDepot_us", 0, getpos player] execVM "Createcomposition.sqf";
*/
_script = _this select 0;
_azi 	= _this select 1;
_pos 	= _this select 2;

_objs = [];
_objs = call (compile (preprocessFileLineNumbers format ["compositions\%1.sqf",_script]));
private ["_posX", "_posY"];
_posX = _pos select 0;
_posY = _pos select 1;
_newObjs = [];
private ["_multiplyMatrixFunc"];
_multiplyMatrixFunc =
{
private ["_array1", "_array2", "_result"];
_array1 = _this select 0;
_array2 = _this select 1;
_result =
[
(((_array1 select 0) select 0) * (_array2 select 0)) + (((_array1 select 0) select 1) * (_array2 select 1)),
(((_array1 select 1) select 0) * (_array2 select 0)) + (((_array1 select 1) select 1) * (_array2 select 1))
];
_result
};
for "_i" from 0 to ((count _objs) - 1) do
{
	private ["_obj", "_type", "_relPos", "_azimuth", "_fuel", "_damage", "_newObj", "_vehicleinit"];
	_obj = _objs select _i;
	_type = _obj select 0;
	_relPos = _obj select 1;
	_azimuth = _obj select 2;
	_fuel = _obj select 3;
	_damage = _obj select 4;
	_vehicleinit = _obj select 5;

	private ["_rotMatrix", "_newRelPos", "_newPos"];
	_rotMatrix =[[cos _azi, sin _azi],[-(sin _azi), cos _azi]];
	_newRelPos = [_rotMatrix, _relPos] call _multiplyMatrixFunc;
	private ["_z"];
	if ((count _relPos) > 2) then {_z = _relPos select 2} else {_z = 0};
	_newPos = [_posX + (_newRelPos select 0), _posY + (_newRelPos select 1), _z];
	_newObj = _type createVehiclelocal _newPos;
	_newObj setDir (_azi + _azimuth);
	_newObj setPos _newPos;
	if (!isNil "_fuel") then {_newObj setFuel _fuel};
	if (!isNil "_damage") then {_newObj setDamage _damage};
	_newObjs = _newObjs + [_newObj];

};

Share this post


Link to post
Share on other sites

Whats wrong with BIS_fnc_objectsGrabber & BIS_fnc_objectsMapper under functions/spawning do they not work properly or something?? have not tried them myself.

Share this post


Link to post
Share on other sites

is it possible to hack it to eanble placing units?? just standing units that will guard and fire, no waypoints and stuff ?? i don't want to use the bis task defend function i want more control.

-----------------------------

Update, :)

------------------------------

i did some modifications to the object grabber so it can grab soldiers and their direction and stance if anyone is interested...

Example mission.

check the custom radio commands, you can use 0-0-4 to place a soldier at your current location.

with this you can use any RTE like MCC or virtual training space to build your base or whatever, the just walk around the base placing soldier where ever you want, just by standing in the spot facing the direction with the stance you prefer and spawn in a soldier right there. then grabb it all, the mapp it all

hope this is something for someone, thank you, any improvements are welcome, just PM me.

Big ups for the original authors of the scripts (objectgrabber/Objectmapper)

update ; http://filebin.ca/15OrhnNfc3Nf/Buildarea.Stratis.zip

Edited by Hansson0728

Share this post


Link to post
Share on other sites
Whats wrong with BIS_fnc_objectsGrabber & BIS_fnc_objectsMapper under functions/spawning do they not work properly or something?? have not tried them myself.

Hadn't even realized they existed. Been using those scripts lol.

Share this post


Link to post
Share on other sites
yeah just comment them out. Should just be 2 lines.

---------- Post added at 17:06 ---------- Previous post was at 17:04 ----------

updated - didn't understand your reply at first.

---------- Post added at 17:08 ---------- Previous post was at 17:06 ----------

here's what i used a couple months ago.

objectGrabber.sqf

scriptName "objectGrabber.sqf";
/*
File: objectGrabber.sqf
Author: Joris-Jan van 't Land

Description:
Converts a set of placed objects to an object array for the DynO mapper.
Places this information in the debug output for processing.

Parameter(s):
_this select 0: position of the anchor point
_this select 1: size of the covered area

Returns:
Success flag (Boolean)

init:
null = [getpos this,200] execvm "objectGrabber.sqf";
*/

//Validate parameter count
if ((count _this) < 2) exitWith {diag_log "Log: [objectGrabber] Function requires at least 2 parameter!"; false};

private ["_anchorPos", "_anchorDim"];
_anchorPos = _this select 0;
_anchorDim = _this select 1;

//Validate parameters
if ((typeName _anchorPos) != (typeName [])) exitWith {diag_log "Log: [objectGrabber] Anchor position (0) must be an Array!"; false};
if ((typeName _anchorDim) != (typeName 0)) exitWith {diag_log "Log: [objectGrabber] Covered area size (1) must be an Number!"; false};

private ["_objs"];
_objs = nearestObjects [_anchorPos, ["All"], _anchorDim];

diag_log "#####################################";
diag_log "### Log: objectGrabber: StartGrabbing";
diag_log "#####################################";

for "_i" from 0 to ((count _objs) - 1) do
{
 private ["_obj", "_type"];
_obj = _objs select _i;

_type = typeOf _obj;

//Exclude human objects.
private ["_sim"];
_sim = getText (configFile >> "CfgVehicles" >> _type >> "simulation");
if !(_sim in ["soldier"]) then
{
	private ["_objPos", "_dX", "_dY", "_z", "_azimuth", "_fuel", "_damage", "_vehicleinit"];
	_objPos = position _obj;
	_dX = (_objPos select 0) - (_anchorPos select 0);
	_dY = (_objPos select 1) - (_anchorPos select 1);
	_z = _objPos select 2;
	_azimuth = direction _obj;
	_fuel = fuel _obj;
	_damage = damage _obj;
	_vehicleinit = if (isnil {_obj getvariable "vehicleinit"}) then {{}} else {_obj getvariable "vehicleinit";};

	diag_log text(format ["%1,", [_type, [_dX, _dY, _z], _azimuth, _fuel, _damage, _vehicleinit]]);
};
};
diag_log "###################################";
diag_log "### Log: objectGrabber: EndGrabbing";
diag_log "###################################";

true

createComposition.sqf

/*
Original Script 
objectMapper.sqf Author: Joris-Jan van 't Land
Edited by armatec

Description:
Takes an array of data about a dynamic object template and creates the objects.

Parameter(s):
_this select 0: compositions name - "fuelDepot_us"
_this select 1: Direction in degrees - Number 
_this select 2: Location to start

Exsample:
["fuelDepot_us", 0, getpos player] execVM "Createcomposition.sqf";
*/
_script = _this select 0;
_azi 	= _this select 1;
_pos 	= _this select 2;

_objs = [];
_objs = call (compile (preprocessFileLineNumbers format ["compositions\%1.sqf",_script]));
private ["_posX", "_posY"];
_posX = _pos select 0;
_posY = _pos select 1;
_newObjs = [];
private ["_multiplyMatrixFunc"];
_multiplyMatrixFunc =
{
private ["_array1", "_array2", "_result"];
_array1 = _this select 0;
_array2 = _this select 1;
_result =
[
(((_array1 select 0) select 0) * (_array2 select 0)) + (((_array1 select 0) select 1) * (_array2 select 1)),
(((_array1 select 1) select 0) * (_array2 select 0)) + (((_array1 select 1) select 1) * (_array2 select 1))
];
_result
};
for "_i" from 0 to ((count _objs) - 1) do
{
	private ["_obj", "_type", "_relPos", "_azimuth", "_fuel", "_damage", "_newObj", "_vehicleinit"];
	_obj = _objs select _i;
	_type = _obj select 0;
	_relPos = _obj select 1;
	_azimuth = _obj select 2;
	_fuel = _obj select 3;
	_damage = _obj select 4;
	_vehicleinit = _obj select 5;

	private ["_rotMatrix", "_newRelPos", "_newPos"];
	_rotMatrix =[[cos _azi, sin _azi],[-(sin _azi), cos _azi]];
	_newRelPos = [_rotMatrix, _relPos] call _multiplyMatrixFunc;
	private ["_z"];
	if ((count _relPos) > 2) then {_z = _relPos select 2} else {_z = 0};
	_newPos = [_posX + (_newRelPos select 0), _posY + (_newRelPos select 1), _z];
	_newObj = _type createVehiclelocal _newPos;
	_newObj setDir (_azi + _azimuth);
	_newObj setPos _newPos;
	if (!isNil "_fuel") then {_newObj setFuel _fuel};
	if (!isNil "_damage") then {_newObj setDamage _damage};
	_newObjs = _newObjs + [_newObj];

};

I'm code illiterate, what is the step by step process for using this?

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
Sign in to follow this  

×