Jump to content

Recommended Posts

Hey there, running into some trouble here.

 

So I'm doing this SP mission, and I want the player to do a set of tasks (3 actually) within a certain ammount of time (lets say 5 min. (300 sec.). 

 

Just a little briefing about what I'm trying to do:

 

- Dude get's out of the Heli, visits this unit and prety much this units tells him that he has 5 min. to gear up and then get into another heli before this one takes off.

 

So my point here is, if the player isn't inside of that Heli within 5 min. mission ends (failed) and has to restart, however if he is there in time, I want the mission to keep going, so it would just mean that the task was completed and the timer would stop.

 

There must be a very simple way of doing this, currently using task modules and triggers that are sync to the player (trigger owner). Any help would be appreciated!

Share this post


Link to post
Share on other sites

This would be overly complicated to do with task modules, triggers and whatnot.

With scripting it's probably just a few lines.

 

Cheers

Share this post


Link to post
Share on other sites

I see, alright thanks for the info, I'll probably just work around it.

Share this post


Link to post
Share on other sites

Take a look at this demo mission I just made.

Quick showcase how to handle these things via a single script, easy to read and change/add stuff.

 

The script itself:

0 fadesound 0;
12 fadesound 1;


_heli = YourHeli;
_unit = player;
_debug = true;
_timer = 300;//set to 300 here for 5 minutes to complete all tasks
//make sure these 3 are identical inside the _makeTaskN arrays
_myTaskIDs = ["Task01","Task02","Task03"];

//this task will be the parent task and checks if all three sub tasks are complete
_makeParentTask = ["ParentTask01",player,[format ["Complete all three tasks within %1 seconds! Double time!",_timer],"Complete all three tasks!",""],objNull,"ASSIGNED",3,true,true,"run"];

_makeTask1 = [["Task01","ParentTask01"],player,["Move to the location!","Task 1 - Move","Task01Pos"],getMarkerPos "Task01Pos","ASSIGNED",3,true,true,"move"];
_makeTask2 = [["Task02","ParentTask01"],player,["Free the hostage!","Task 2 - Hostage",""],getposATL YourHostage,"ASSIGNED",2,true,true,"interact"];
_makeTask3 = [["Task03","ParentTask01"],player,["Take the suitcase!","Task 3 - Suitcase",""],getposATL YourSuitcase,"ASSIGNED",1,true,true,"interact"];


waitUntil {time > 0};

if (_debug) then {systemchat "Mission running."};



TexTask1 = false;
TexTask2 = false;
TexTask3 = false;


waitUntil {!(player in crew _heli)};

if (_debug) then {systemchat "Player is outside of heli, starting tasks."};

TaskTimeOut = time + _timer;
//timer starts now, displaying in hint for debug purposes, delete this if not needed:
onEachFrame {hintsilent format ["Time left:\n%1",[TaskTimeOut - time] call BIS_fnc_timetoString]};

//spawning loops to handle individual task conditions
//this is an easy way to edit and read/handle task conditions and results
_watchTask1 = [] spawn {

waitUntil {sleep 0.5;player distance2d (getMarkerPos "Task01Pos") < 25};
["Task01", "SUCCEEDED",true] spawn BIS_fnc_taskSetState;
TexTask1 = true;

};

_watchTask2 = [] spawn {


YourHostage switchMove "Acts_ExecutionVictim_Loop";

	YourHostage addAction ["Free the hostage!",{

		params ["_hostage","_caller","_ID"];
		_hostage removeAction _ID;
		_hostage playMove "Acts_ExecutionVictim_Unbow";
		_hostage linkItem "ItemRadio";
		_hostage setVariable ["Tag_fnc_HostageFreed",true];

		}];


	waitUntil {sleep 0.5;YourHostage getVariable ["Tag_fnc_HostageFreed",false]};
	["Task02", "SUCCEEDED",true] spawn BIS_fnc_taskSetState;
	TexTask2 = true;
	sleep 2;
	YourHostage globalRadio "SentCheering";



};


_watchTask3 = [] spawn {

	YourSuitcase addAction ["Take the suitcase!",{

		params ["_suitcase","_caller","_ID"];
		_suitcase removeAction _ID;
		deleteVehicle _suitcase;

		}];


	waitUntil {sleep 0.5;!alive YourSuitcase};
	["Task03", "SUCCEEDED",true] spawn BIS_fnc_taskSetState;
	TexTask3 = true;
	sleep 2;

};

_watchParentTask = [] spawn {



	waitUntil {sleep 1;(TexTask1 AND TexTask2 AND TexTask3) OR time > TaskTimeOut};

	if (time < TaskTimeOut AND (TexTask1 AND TexTask2 AND TexTask3)) then {

		["ParentTask01", "SUCCEEDED",true] spawn BIS_fnc_taskSetState;
		systemchat "All completed within time!";

		//delete this if time countdown is not needed
		onEachFrame {};


	};

	if (time > TaskTimeOut AND !(TexTask1 AND TexTask2 AND TexTask3)) then {

		systemchat "Failed";
		//delete this if time countdown is not needed
		onEachFrame {};
	["epicFail",false,2] spawn BIS_fnc_endMission;
	};



};



{_x call BIS_fnc_setTask;sleep 3;} foreach [_makeParentTask,_makeTask1,_makeTask2,_makeTask3];

Nothing too complicated, read the comments.

Only things done in the editor are object placement. Placed one suitcase for the grab suitcase task, one hostage to free and one move point to reach.

 

Creates a parent task, with three child tasks. Once the three child tasks are complete and the timeout has not been reached the mission continues.

If one of the three child tasks has not been completed and the timeout has been reached the mission exits with the debriefing.

 

Tasks start once the player is outside the chopper, can be completed in any order.

Watch out for those (dumbed down) hostagetakers!

 

Feel free to ask if you got questions.

 

Cheers

  • Like 2

Share this post


Link to post
Share on other sites
58 minutes ago, Grumpy Old Man said:

Take a look at this demo mission I just made.

Quick showcase how to handle these things via a single script, easy to read and change/add stuff.

 

The script itself:


0 fadesound 0;
12 fadesound 1;


_heli = YourHeli;
_unit = player;
_debug = true;
_timer = 300;//set to 300 here for 5 minutes to complete all tasks
//make sure these 3 are identical inside the _makeTaskN arrays
_myTaskIDs = ["Task01","Task02","Task03"];

//this task will be the parent task and checks if all three sub tasks are complete
_makeParentTask = ["ParentTask01",player,[format ["Complete all three tasks within %1 seconds! Double time!",_timer],"Complete all three tasks!",""],objNull,"ASSIGNED",3,true,true,"run"];

_makeTask1 = [["Task01","ParentTask01"],player,["Move to the location!","Task 1 - Move","Task01Pos"],getMarkerPos "Task01Pos","ASSIGNED",3,true,true,"move"];
_makeTask2 = [["Task02","ParentTask01"],player,["Free the hostage!","Task 2 - Hostage",""],getposATL YourHostage,"ASSIGNED",2,true,true,"interact"];
_makeTask3 = [["Task03","ParentTask01"],player,["Take the suitcase!","Task 3 - Suitcase",""],getposATL YourSuitcase,"ASSIGNED",1,true,true,"interact"];


waitUntil {time > 0};

if (_debug) then {systemchat "Mission running."};



TexTask1 = false;
TexTask2 = false;
TexTask3 = false;


waitUntil {!(player in crew _heli)};

if (_debug) then {systemchat "Player is outside of heli, starting tasks."};

TaskTimeOut = time + _timer;
//timer starts now, displaying in hint for debug purposes, delete this if not needed:
onEachFrame {hintsilent format ["Time left:\n%1",[TaskTimeOut - time] call BIS_fnc_timetoString]};

//spawning loops to handle individual task conditions
//this is an easy way to edit and read/handle task conditions and results
_watchTask1 = [] spawn {

waitUntil {sleep 0.5;player distance2d (getMarkerPos "Task01Pos") < 25};
["Task01", "SUCCEEDED",true] spawn BIS_fnc_taskSetState;
TexTask1 = true;

};

_watchTask2 = [] spawn {


YourHostage switchMove "Acts_ExecutionVictim_Loop";

	YourHostage addAction ["Free the hostage!",{

		params ["_hostage","_caller","_ID"];
		_hostage removeAction _ID;
		_hostage playMove "Acts_ExecutionVictim_Unbow";
		_hostage linkItem "ItemRadio";
		_hostage setVariable ["Tag_fnc_HostageFreed",true];

		}];


	waitUntil {sleep 0.5;YourHostage getVariable ["Tag_fnc_HostageFreed",false]};
	["Task02", "SUCCEEDED",true] spawn BIS_fnc_taskSetState;
	TexTask2 = true;
	sleep 2;
	YourHostage globalRadio "SentCheering";



};


_watchTask3 = [] spawn {

	YourSuitcase addAction ["Take the suitcase!",{

		params ["_suitcase","_caller","_ID"];
		_suitcase removeAction _ID;
		deleteVehicle _suitcase;

		}];


	waitUntil {sleep 0.5;!alive YourSuitcase};
	["Task03", "SUCCEEDED",true] spawn BIS_fnc_taskSetState;
	TexTask3 = true;
	sleep 2;

};

_watchParentTask = [] spawn {



	waitUntil {sleep 1;(TexTask1 AND TexTask2 AND TexTask3) OR time > TaskTimeOut};

	if (time < TaskTimeOut AND (TexTask1 AND TexTask2 AND TexTask3)) then {

		["ParentTask01", "SUCCEEDED",true] spawn BIS_fnc_taskSetState;
		systemchat "All completed within time!";

		//delete this if time countdown is not needed
		onEachFrame {};


	};

	if (time > TaskTimeOut AND !(TexTask1 AND TexTask2 AND TexTask3)) then {

		systemchat "Failed";
		//delete this if time countdown is not needed
		onEachFrame {};
	["epicFail",false,2] spawn BIS_fnc_endMission;
	};



};



{_x call BIS_fnc_setTask;sleep 3;} foreach [_makeParentTask,_makeTask1,_makeTask2,_makeTask3];

Nothing too complicated, read the comments.

Only things done in the editor are object placement. Placed one suitcase for the grab suitcase task, one hostage to free and one move point to reach.

 

Creates a parent task, with three child tasks. Once the three child tasks are complete and the timeout has not been reached the mission continues.

If one of the three child tasks has not been completed and the timeout has been reached the mission exits with the debriefing.

 

Tasks start once the player is outside the chopper, can be completed in any order.

Watch out for those (dumbed down) hostagetakers!

 

Feel free to ask if you got questions.

 

Cheers

Appreciated, so in terms of tasking, is all the tasking being called through this script or can I still use the task modules ID's and just place their ID's in here?

Share this post


Link to post
Share on other sites

All the tasking happens in the script to keep it central.

You could probably still work with modules but editing and changing would require you to hop back and forth between text editor and game.

 

Cheers

Share this post


Link to post
Share on other sites
34 minutes ago, Grumpy Old Man said:

All the tasking happens in the script to keep it central.

You could probably still work with modules but editing and changing would require you to hop back and forth between text editor and game.

 

Cheers

Gotcha, thanks again, this is very helpfull! 

Cheers.

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

×