Jump to content
OldManMike

creating tasks: randomized spawning on randomized positions

Recommended Posts

Hello, I searched the forums for hours but couldn't find a suitable answer: For example, I created 3 tasks in the eden editor: kill/save/interact. How can I make it so that all this 3 tasks do not appear at the same time but in a random order and also at random positions? Like a kind of mini mission generator. Is there the possibility of controlling the random location of the task in the module itself with a script in the init and the random selection of the task via extern script (f.e. myscript.ext)? And how could this work?

 

I also have to admit that I am still a beginner in scripting.

Share this post


Link to post
Share on other sites
On 1/21/2024 at 9:42 AM, OldManMike said:

How can I make it so that all this 3 tasks do not appear at the same time but in a random order and also at random positions?

 

There are 2 main ways to create tasks, via Task modules in the Editor or by calling the corresponding Task Framework function.

While it is possible to dynamically create task modules I wouldn't recommend it since you will quickly run into limitiations you have to work around.

I would ditch the modules and go for a fully scripted system.

 

Before I get into the code here are some things to keep in mind when working with tasks:

  • Tasks in and of themselves are nothing but some fancy text and HUD elements.
  • Tasks are merely a presentation tool to tell the player where the fun is or what to do.
  • Tasks don't automatically control the flow of mission logic, they can but don't have to.

Example:

Say you have the following objectives in your mission:

  1. Kill dude A
  2. Destory tank B
  3. Pickup intel C

Instead of creating 3 dynamic tasks which are created one after the other you could create one static tasks describing the mission and then dynamically place markers on the map where the player needs to go. The mission logic (what the players need to do) remains the same in both scenarios and so triggering the next objectives would be done in the same ways, the only difference between the 2 scenarios being how the information is presented.

 

Now for scripting tasks most of the information is available in the link I posted above so I recommend you do have a read after to know your options. Here's an example how you could show the tasks one after the other. To get a random location connect the destination parameter for the task to an object with a large placement radius. This should get you started.

Spoiler

//in initServer.sqf (we only want the server to do setup since the effect needs to be the same for all players)
TAG_allTasks = [
  	// This list is the same as the parameter list for BIS_fnc_taskCreate, by changing this values you controll how your tasks looks initially
	[owner, taskID, description, destination, state, priority, showNotification, type, visibleIn3D], // A task
  	[owner, taskID, description, destination, state, priority, showNotification, type, visibleIn3D], // Another task
 	[owner, taskID, description, destination, state, priority, showNotification, type, visibleIn3D], // Another task
  	[owner, taskID, description, destination, state, priority, showNotification, type, visibleIn3D] // Last entry, note the missing comma ',' at the end
];

private _shuffledList = TAG_allTasks call BIS_fnc_arrayShuffle;

TAG_taskHandler = _shuffledList spawn {
	private _tasks = +_this;
	
  	while { count _tasks > 0 } do {
		private _task = _tasks deleteAt 0;
      
      	_task call BIS_fnc_taskCreate;
		waitUntil { 
			sleep 1; 
			(_task # 1) call BIS_fnc_taskCompleted 
		};
    }
  
  	// Since no more tasks remain we can now end the mission on the server, if you do this elsewhere you can just delete these two lines
	sleep 3;
  	"EveryoneWon" call BIS_fnc_endMissionServer;
};

 

 

Any questions just ask 🙂

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

×