Jump to content
Sign in to follow this  
Cryptdik

Task creation in an .sqf

Recommended Posts

I'm trying to write a basic script to create a task, spawn certain units and then set the task state to completed when said units are killed. In this case, I have the script being called from an objective board object in the mission to spawn boats (starting with just one for now) in a random part in the ocean for the player to hunt down in an A-10. It's calling the script fine because the hint is visible, but I haven't figured out the actual task creation and unit spawning part. Here's what I've got:

 

hint "task1";

_randomPosMapNoLand = [nil, ["ground"]] call BIS_fnc_randomPos;

_task1 = ["Assault Boats", {[west, ["Task1"], ["Eliminate the assault boats", "Eliminate boats", _randomPosMapNoLand], _randomPosMapNoLand, 1, 1, true] call BIS_fnc_taskCreate;}]

_boat1 = [getMarkerPos "_randomPosMapNoLand", 180, "O_T_Boat_Armed_01_hmg_F", east] call BIS_fnc_spawnVehicle;

waitUntil{!(alive _boat1)};
["Task1", "SUCCEEDED",true] spawn BIS_fnc_taskSetState;


Any tips on getting this working are super appreciated!

Share this post


Link to post
Share on other sites

To make a unit a destructible task,

Spoiler

paste this in init.sqf or Attributes Init dialog,


you_fnc_destroyThis=
{	params ["_target"];
	["task1",[_target,true]] call BIS_fnc_taskSetDestination; ["task1","ASSIGNED"] call BIS_fnc_taskSetState;
waitUntil {sleep 1; !alive _target};
					systemChat "Objective Destroyed";
					["task1",[objNull,false]] call BIS_fnc_taskSetDestination;
};

[true,["task1"],["Mission Objective","Mission","Target"],objNULL,1,3,false] call BIS_fnc_taskCreate;
["task1","assigned"] call BIS_fnc_taskSetState;

to create the target vehicle from script include this function with the above,


you_fnc_spawnVeh=
{ params [["_pos", getpos player], ["_type", "O_T_Boat_Armed_01_hmg_F"], ["_area", 1000]];
	private	_veh = _type createVehicle _pos;
			createVehicleCrew _veh;
	private	_grp=group _veh;
	[_grp, _pos, _area] call BIS_fnc_taskPatrol;
	[_veh] spawn you_fnc_destroyThis;
};

so just establish your random position, like you did, and call,


[your_random_pos, "O_T_Boat_Armed_01_hmg_F", 1000] call you_fnc_spawnVeh;

of course the functions can be called again and with different parameters.


Have fun!

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  

×