Wondering if Someone Could Help with a Script

  1. 9 years ago

    I have a bit of a problem with how my missions are creating the tasks that show in the Tasks window on the map because of how the first set of tasks are unknown before the mission begins and the admin sets the parameters.

    I figure someone here has to know how I could name and call back that name based on a random string using the format command since the C2ISTAR system, while not 100%, does at least do what I need fixed in my mission with how it can create and fail/succeed random tasks. My problem is that I can't figure out how to work with dynamic variable names correctly so that I can create the tasks and figure out which one is being completed by the player(s) so that they fail/succeed in the proper manner. Right now when you complete one of 3, any of the 3 tasks will be succeeded at random and not necessarily the one you actually completed.

    I'm just looking for a general idea on how I might do this, but if posting some code will help, I can post up the script that's creating the tasks shortly.

  2. Edited 9 years ago by SpyderBlack723

    Post the code if you can, would love to help but havent worked with tasks before so we'll see if im any help.

  3. _grpSelect = enemyGroupTypes call BIS_fnc_selectRandom;
    
    StartTask = ["StartTask", true, ["We have reports of pirate activity all over the Afrenian side of Duala. Informants are telling command it's for something major. We need your team to sweep the marked areas and collect any intel you find.","Gather Intel","Sweep Area"], [], "ASSIGNED", 1, true, true, "", true] call BIS_fnc_setTask;
    if (intelCount >= 3) then 
    {
    	{
    		_resgrp1 = [getMarkerPos _x, EAST, (_grpSelect)] call BIS_fnc_spawngroup;
    		_holder = (units _resgrp1) call bis_fnc_selectRandom;
    		_mkrname = format ["mkr_%1", _x];
    		_taskmkr = createMarker [_mkrname, getPos _holder];
    		_taskmkr setMarkerShape "ELLIPSE";
    		_taskmkr setMarkerType "Empty";
    		_taskmkr setMarkerSize [50,50];
    		_taskmkr setMarkerColor "ColorOPFOR";
    		_taskmkr setMarkerBrush "FDiagonal";
    		_taskmkr setMarkerText "Known Enemy Activity";
    		_taskmkr setMarkerAlpha 1;
    		TaskMarkers pushBack _taskmkr;
    		_holder addEventHandler ["killed", 
    		{
    			_unit = (_this select 0);
    			_dropPos = [_unit, 1, (random 360)] call bis_fnc_relpos;
    			_droppedIntel = "EvKobalt" createVehicle _dropPos;
    			_droppedIntel allowDamage false;
    			_droppedIntel enableSimulation false;
    			player sideChat "I think that one dropped something.";
    			PickUp = [["PickUp","StartTask"], true, ["One of the contacts dropped something. Pick it up.","Gather Intel","Pick Up"], [getPos _droppedIntel], "ASSIGNED", 1, true, true, "", true] call BIS_fnc_setTask;
    			_droppedIntel addAction ["Gather Intelligence", 
    			{
    				_del = _this select 0;
    				deleteVehicle _del;
    				gatheredIntel = gatheredIntel + 1;
    				if (gatheredIntel < intelCount) then
    				{
    					player sideChat "SPEARHEAD to PHALANX. We have neutralized an insurgent team and gathered some documents, over.";
    					sleep 3;
    					PHALANX sideChat "Excellent work, SPEARHEAD. Proceed to locate the rest of the files. PHALANX out.";
    					[PickUp, "Succeeded"] call BIS_fnc_taskSetState;
    				} else
    				{
    					if (gatheredIntel >= intelCount) then
    					{
    						player sideChat "SPEARHEAD to PHALANX. We have collected all the files. Sending details now. How copy? Over.";
    						sleep 5;
    						PHALANX sideChat "Roger, SPEARHEAD. After going over the documents, we've discovered a Molatian officer we need you to arrest.";
    						sleep 5;
    						PHALANX sideChat "Do not kill the officer. Repeat DO NOT KILL THE MOLATIAN OFFICER. We need to interrogate him to find out what he may know.";
    						sleep 5;
    						PHALANX sideChat "How copy, SPEARHEAD? Over.";
    						sleep 5;
    						player sideChat "Copy, PHALANX. Capture, not kill, the HVT. SPEARHEAD out.";
    						[PickUp, "Succeeded"] call BIS_fnc_taskSetState;
    						[StartTask, "Succeeded"] call BIS_fnc_taskSetState;
    						{
    							deleteMarker _x;
    						} forEach TaskMarkers;
    						Task2 = ["HVT", true, ["Capture the officer for interrogation in Bolabongo. Beforewarned, Captain, the Molatians are swarming all over the city, and the target is without doubt accompanied by guards.", "Arrest HVTs", "Capture the Officer"], [getMarkerPos "mkrHvt"], "ASSIGNED", 1, true, true, "", true] call BIS_fnc_setTask;
    						taskmk2 = createMarker ["AreaMarker2", getMarkerPos "mkrHVT"];
    						taskmk2 setMarkerShape "ELLIPSE";
    						taskmk2 setMarkerType "Empty";
    						taskmk2 setMarkerBrush "FDiagonal";
    						taskmk2 setMarkerColor "ColorOPFOR";
    						taskmk2 setMarkerSize [500,500];
    						taskmk2 setMarkerAlpha 1;
    						taskmk2 setMarkerText "Bolabongo - HOSTILE CITY";
    						_nil = execVM "midgame.sqf";
    					};
    				};
    			}];
    		}];
    	} forEach selectedStart;
    } else
    {
    	_resgrp1 = [getMarkerPos selectedStart, EAST, (_grpSelect)] call BIS_fnc_spawngroup;
    	_holder = (units _resgrp1) call bis_fnc_selectRandom;
    	task1 = createMarker ["AreaMarker", getPos _holder];
    	task1 setMarkerShape "ELLIPSE";
    	task1 setMarkerType "Empty";
    	task1 setMarkerSize [50,50];
    	task1 setMarkerColor "ColorOPFOR";
    	task1 setMarkerBrush "FDiagonal";
    	task1 setMarkerText "Known Enemy Activity";
    	task1 setMarkerAlpha 1;
    	_holder addEventHandler ["killed", 
    	{
    		_unit = (_this select 0);
    		_dropPos = [_unit, 1, (random 360)] call bis_fnc_relpos;
    		_droppedIntel = "EvKobalt" createVehicle _dropPos;
    		_droppedIntel allowDamage false;
    		_droppedIntel enableSimulation false;
    		player sideChat "I think that one dropped something.";
    		PickUp = [["PickUp","StartTask"], true, ["One of the contacts dropped something. Pick it up.","Gather Intel","Pick Up"], [getPos _droppedIntel], "ASSIGNED", 1, true, true, "", true] call BIS_fnc_setTask;
    		_droppedIntel addAction ["Gather Intelligence", 
    		{
    			_del = _this select 0;
    			deleteVehicle _del;
    			gatheredIntel = gatheredIntel + 1;
    			if (gatheredIntel < intelCount) then
    			{
    				player sideChat "SPEARHEAD to PHALANX. We have neutralized an insurgent team and gathered some documents, over.";
    				sleep 3;
    				PHALANX sideChat "Excellent work, SPEARHEAD. Proceed to locate the rest of the files. PHALANX out.";
    				[PickUp, "Succeeded"] call BIS_fnc_taskSetState;
    			} else
    			{
    				if (gatheredIntel >= intelCount) then
    				{
    					player sideChat "SPEARHEAD to PHALANX. We have collected all the files. Sending details now. How copy? Over.";
    					sleep 5;
    					PHALANX sideChat "Roger, SPEARHEAD. After going over the documents, we've discovered a Molatian officer we need you to arrest.";
    					sleep 5;
    					PHALANX sideChat "Do not kill the officer. Repeat DO NOT KILL THE MOLATIAN OFFICER. We need to interrogate him to find out what he may know.";
    					sleep 5;
    					PHALANX sideChat "How copy, SPEARHEAD? Over.";
    					sleep 5;
    					player sideChat "Copy, PHALANX. Capture, not kill, the HVT. SPEARHEAD out.";
    					[PickUp, "Succeeded"] call BIS_fnc_taskSetState;
    					deleteMarker task1;
    					Task2 = ["HVT", true, ["Capture the officer for interrogation in Bolabongo. Beforewarned, Captain, the Molatians are swarming all over the city, and the target is without doubt accompanied by guards.", "Arrest HVTs", "Capture the Officer"], [getMarkerPos "mkrHvt"], "ASSIGNED", 1, true, true, "", true] call BIS_fnc_setTask;
    					taskmk2 = createMarker ["AreaMarker2", getMarkerPos "mkrHVT"];
    					taskmk2 setMarkerShape "ELLIPSE";
    					taskmk2 setMarkerType "Empty";
    					taskmk2 setMarkerBrush "FDiagonal";
    					taskmk2 setMarkerColor "ColorOPFOR";
    					taskmk2 setMarkerSize [500,500];
    					taskmk2 setMarkerAlpha 1;
    					taskmk2 setMarkerText "Bolabongo - HOSTILE CITY";
    					_nil = execVM "midgame.sqf";
    				};
    			};
    		}];
    	}];
    };

    Here is the script with the trouble tasks.

    The goal is to create 1 parent, then 1-25 children, marking the destination. When you kill a unit that drops an intel item, the task of the unit you killed is completed and a new one (pick up the actual intel item) is added, and once you pick up the intel, that objective is completed then removed.

  4. Not sure if this will help but you might want to look at this for complicated task management:

    http://www.armaholic.com/page.php?id=21970

  5. Edited 9 years ago by SpyderBlack723

    Alright, haven't really looked into how to do anything but might have some a possible solution based off your original post.

    I figure someone here has to know how I could name and call back that name based on a random string using the format command

    You might be able to use a global array such as allTasks = [];, pushBack each task into allTasks upon creation, and then use find to search for the task variable within the array. You would have to keep track of the variable name one way or another if it is random but it might be a start.

    Maybe, if there are commands to do this, you could pushBack each of the tasks' names into the array and then use allTasks find (taskName _task) .. obviously with working code if there is a command to get a task's name.

  6. Edited 9 years ago by PillowTalk

    Using something like format and missionNamespace I can get the task names to be dynamic (if there's one, the task is just "tsk" but if there are, say, 3, then there is tsk1, tsk2, and tsk3). The thing I am having trouble doing is finding the nearest task to the player. I can call up task 1, 2 and 3 and end them; but the player might not do them in order so when they go to task 2 and finish it, it says they finished task 1.

    What was giving me problems was trying to find something by a class name so I could just create a trigger that checks for "EvKobalt" in it. Since the triggers statements would be in the same forEach loop as the tasks themselves, I *think* if I do it this way it should work as I have intended. Since I've got it working now to find for the classname I want, I just need to write it up and try it.

    Otherwise, I think the only thing I can do here is make it so that each new task to check the areas will pop up after you complete the previous one, instead of having 1-25 tasks all at once.

    I don't know how I never found the Find command before. It's actually what I needed to *find* the classname of the object I am basing the tasks around. XD

 

or Sign Up to reply!