Jump to content
Valixx

Random Objectives / Sidemissions

Recommended Posts

Hey guys.

I'm looking for a script to create sidemissions / random objectives. I've found something in the Arma 2 forums from kylania but obviously it isn't working in Arma 3.

http://forums.bistudio.com/showthread.php?141233-Really-Stange-Missing-Errors&p=2237389&viewfull=1#post2237389

Do you know something else?

Cheers,

Valixx

Share this post


Link to post
Share on other sites

Great question. Was looking into this myself... A2 one doesn't work though? hmmm

Right now I have a spreadsheet typed up and roll Role-Playing dice for the mission

and other setup options, type, locations, times, weather, etc.

Have you looked into SHK_Taskmaster?

Edited by Goblin

Share this post


Link to post
Share on other sites

Nope. I have to take a look on SHK_Taskmaster and see what i can find/get.

Share this post


Link to post
Share on other sites

From my first look it appears most of the issue would be around the classnames and I have not done A2/OA scripting much so am unsure if "call RE" works in A3.

Share this post


Link to post
Share on other sites

We should use "BIS_fnc_MP" for "call RE" i think. I'm still learning Arma 3 scripting^^

So far i got this:

// Mission

_missionType = _this select 0;

sleep random 15;

fn_findMissionSpot = {

   //creating the position

   private ["_rad","_cnps","_hills","_hillcount","_hillnum","_hill","_marker","_boxes","_numb","_boxnum","_box"];

   _rad=20000;
   _cnps = getArray (configFile >> "CfgWorlds" >> worldName >> "centerPosition");
   _hills = nearestLocations [_cnps, ["FlatArea"], _rad];
   _hillcount = count _hills;
   _hillnum = floor (random _hillcount);
   _hill = _hills select _hillnum;

   //player sideChat format["Cnps: %1 Hills: %2 Cnt: %3 Num: %4 Result: %5", _cnps,_hills,_hillcount,_hillnum,_hill];
   getPos _hill
};



fn_spawnArtyMission = {

   hint "Capture the Artillery First!!!";
   //creating the marker 

   _marker = createMarker ["Mobile Artillery", call fn_findMissionSpot];
   _marker setMarkerType "mil_destroy";
   _marker setMarkerColor "ColorRed";
   _marker setMarkerText "Mobile Artillery";
   _marker setMarkerSize [1,1];

   //creating the vehicle

   _veh = ["O_Mortar_01_F"] call BIS_fnc_selectRandom;

   art = createVehicle [_veh,[(getMarkerpos _marker select 0) + 30, getMarkerpos _marker select 1,0],[], 0, "NONE"];
   art setFuel 1;
   art setVehicleAmmo 1;

   waitUntil { Player distance art < 20};

   deleteMarker _marker;

   [player,nil,rSIDECHAT,"Excellent work,use it to your advantage"] spawn BIS_fnc_MP;
   [nil,nil,rHINT,"Destroy some shit soldier!!"] spawn BIS_fnc_MP;
   sleep 3;
   hint "";
};

// MAIN LOGIC

_missionDetails = switch (_missionType) do {
   case "arty": {call fn_spawnArtyMission;}; // Ignoring the cases below for testing purposes. See if we can get one side mission to work.
   //case "tank": {call fn_spawnTankMission;}; 
   //case "heli": {call fn_spawnTankMission;};
   //case "truck": {call fn_spawnTruckMission;};
   //case "c130wreck": {call fn_spawnTankMission;};
   //case "harrier": {call fn_spawnHarrierMission;};

};    

nul = [] execVM "ADG\missionfinder.sqf";

After changing some things in the code it marks the spot on the map. Well, no task/mortar etc. added at the moment. I'm working on it.

4qtteyzp6zds.png

Edited by Valixx
Added Code

Share this post


Link to post
Share on other sites

There four main problems with that code.

1. Undefined variables.

2. OA/A2 classnames.

3. Use of RE instead of other MP communication solution.

but most importantly

4. Stratis apparently has absolutely no "FlatArea" in it's map config!

So the main method it uses to find a nice safe flat area doesn't work.

Share this post


Link to post
Share on other sites

If you are using BIS functions for finding locations replace with SHK_POS script. Works great.

Share this post


Link to post
Share on other sites

Gread idea Delta99, here it is with SHK_Pos and a few changes.

init.sqf:

call compile preprocessfile "SHK_pos\shk_pos_init.sqf";
call compile preprocessfile "globaltools.sqf";

globalTools.sqf:

//ENABLE GLOBAL HINT from Occupation by BangaBob
"GlobalHint" addPublicVariableEventHandler
{private ["_GHint"];_GHint = _this select 1;hint parseText format["%1", _GHint];
};

"GlobalSideChat" addPublicVariableEventHandler
{private ["_GSChat"];_GSChat = _this select 1;player sideChat _GSChat;
};

missionFinder.sqf:

//Mission Select
if(!isServer) exitWith {};

//waituntil {!isnil "bis_fnc_init"}; //waiting

_missions = ["arty","harrier","tank","heli","truck","c130wreck"]; //mission array

//_choose = _missions call BIS_fnc_selectRandom; // random mission 
_choose = "arty";
[_choose] execVM "makemission.sqf";  //call mission

missionMaker.sqf:

// Mission

_missionType = [_this, 0, ""] call BIS_fnc_param;

sleep random 15;

fn_findMissionSpot = {

private ["_mapCenter"];
_mapCenter = getArray (configFile >> "CfgWorlds" >> worldName >> "centerPosition");
[_mapCenter, random 4000, random 360, false] call SHK_pos;

};

fn_spawnArtyMission = {

hint "Capture the Artillery First!!!";
//creating the marker 

_marker = createMarker ["Mobile Artillery", call fn_findMissionSpot];
_marker setMarkerType "mil_destroy";
_marker setMarkerColor "ColorRed";
_marker setMarkerText "Mobile Artillery";
_marker setMarkerSize [1,1];

//creating the vehicle

_veh = ["B_MRAP_01_F","B_MRAP_01_F"] call BIS_fnc_selectRandom;

art = createVehicle [_veh,[(getMarkerpos _marker select 0) + 30, getMarkerpos _marker select 1,0],[], 0, "NONE"];
art setFuel 1;
art setVehicleAmmo 1;

waitUntil { Player distance art < 20};

deleteMarker _marker;

_myHint ="Destroy some stuff soldier!!";
GlobalHint = _myHint;
publicVariable "GlobalHint";
hintsilent parseText _myHint;

_mySChat ="Excellent work, use it to your advantage!";
GlobalSCHat = _mySChat;
publicVariable "GlobalSCHat";
player sideChat _mySChat;

sleep 3;
hint "";
};

// MAIN LOGIC

_missionDetails = switch (_missionType) do {
case "arty": {call fn_spawnArtyMission;};
};	

nul = [] execVM "missionfinder.sqf";

Edited by kylania

Share this post


Link to post
Share on other sites

Kylania in your code above is that everything that is needed to make these side missions. ? Or do you need more scripts etc ?

Skunk

Share this post


Link to post
Share on other sites

You need the SHK_Pos stuff linked in my post. Just drop that folder into you mission. Can't remember if the original guy had other things happening in the missions or not, but this script as is just spawned rewards kind of in random spots. So you'd probably want to put in some spawnGroups or OPFOR site modules or something to mix things up.

Share this post


Link to post
Share on other sites

ok ty for your help.

---------- Post added at 08:10 ---------- Previous post was at 07:50 ----------

getting an error m8

sorry I am useless with coding ....

How will i add the modules i use to the script please If I use sites for example.

Error in expression <= _this select 1;player sideChat _GSChat];
}>
 Error position: <];
}>
 Error Missing ;
Error in expression <= _this select 1;player sideChat _GSChat];
}>
 Error position: <];
}>
 Error Missing ;

Share this post


Link to post
Share on other sites

Oh, that's my bad. In globaltools.sqf remove that ] at the end of _GSChat there. Nothing you did wrong!

As for the modules, I have no idea how you script the creation of modules. :(

You can turn them on during play if placed on the map in the first place, but no idea how to move it around once activated. You can place it and move it once. But not repeatedly.

Edited by kylania

Share this post


Link to post
Share on other sites

Kylania.. thanks again for this. Simply awesome! I've got another questions though, sry to bother you.

I'm so far that the marker appears and the task is assigned to the player. When the player gets near the objective ( waitUntil { Player distance art < 20}; ) it's set to succeeded.

Problem: I've tested this on lan with my brother and he's not getting the first task. We haven't tested if he gets the second though. I think some JIP thing right? Maybe i'll have to test with FHQ_TaskTracker.

// Mission

_missionType = [_this, 0, ""] call BIS_fnc_param;

sleep random 60;

fn_findMissionSpot = {

   private ["_mapCenter"];
   _mapCenter = getArray (configFile >> "CfgWorlds" >> worldName >> "centerPosition");
   [_mapCenter, random 4000, random 360, false] call SHK_pos;

};

fn_spawnArtyMission = {

   hint "Capture the Artillery!";

   //creating the marker 

   _marker = createMarker ["mob_arty", call fn_findMissionSpot];
   _marker setMarkerType "mil_objective";
   _marker setMarkerColor "ColorRed";
   _marker setMarkerText "Mobile Artillery";
   _marker setMarkerSize [1,1];

   _task = player createsimpletask ["mob_arty"];
   _task setsimpletaskdescription ["Capture the Artillery and use it to your advantage.", "Capture the Artillery", "Capture the Artillery"];
   _task setsimpletaskdestination (getMarkerPos "mob_arty");
   _task settaskstate "Created";
   ["TaskCreated", ["Capture the Artillery"]] call bis_fnc_showNotification;

   //creating the vehicle

   _veh = ["B_Mortar_01_F","B_Mortar_01_F"] call BIS_fnc_selectRandom;

   art = createVehicle [_veh,[(getMarkerpos _marker select 0) + 30, getMarkerpos _marker select 1,0],[], 0, "NONE"];
   art setFuel 1;
   art setVehicleAmmo 1;

   waitUntil { Player distance art < 20};  

   deleteMarker _marker;

   _task settaskstate "Succeeded";
   ["TaskSucceeded", ["Capture the Artillery"]] call bis_fnc_showNotification;

   _myHint ="Destroy some stuff soldier!!";
   GlobalHint = _myHint;
   publicVariable "GlobalHint";
   hintsilent parseText _myHint;

   _mySChat ="Excellent work, use it to your advantage!";
   GlobalSCHat = _mySChat;
   publicVariable "GlobalSCHat";
   player sideChat _mySChat;

   sleep 3;
   hint "";
};

fn_spawnHeliMission = {

   hint "Capture the Heli!";

   //creating the marker 

   _marker = createMarker ["mob_heli", call fn_findMissionSpot];
   _marker setMarkerType "mil_objective";
   _marker setMarkerColor "ColorRed";
   _marker setMarkerText "Abandoned Helicopter";
   _marker setMarkerSize [1,1];

   _task = player createsimpletask ["mob_heli"];
   _task setsimpletaskdescription ["Capture the abandoned helicopter and use it to your advantage.", "Capture the Heli!", "Capture the Heli!"];
   _task setsimpletaskdestination (getMarkerPos "mob_heli");
   _task settaskstate "Created";
   ["TaskCreated", ["Capture the Heli!"]] call bis_fnc_showNotification;

   //creating the vehicle

   _veh = ["B_Heli_Transport_01_camo_F","B_Heli_Transport_01_camo_F"] call BIS_fnc_selectRandom;

   art = createVehicle [_veh,[(getMarkerpos _marker select 0) + 30, getMarkerpos _marker select 1,0],[], 0, "NONE"];
   art setFuel 1;
   art setVehicleAmmo 1;

   waitUntil { Player distance art < 20}; // If you read this, could we say like: If the heli is dead, then the scripts goes on...?

   deleteMarker _marker;

   _task settaskstate "Succeeded";
   ["TaskSucceeded", ["Capture the Heli!"]] call bis_fnc_showNotification;

   _myHint ="I hope you are a good pilot, soldier!!";
   GlobalHint = _myHint;
   publicVariable "GlobalHint";
   hintsilent parseText _myHint;

   _mySChat ="Excellent work, use it to your advantage!";
   GlobalSCHat = _mySChat;
   publicVariable "GlobalSCHat";
   player sideChat _mySChat;

   sleep 3;
   hint "";
};

// MAIN LOGIC

_missionDetails = switch (_missionType) do {
   case "arty": {call fn_spawnArtyMission;};
   case "heli": {call fn_spawnHeliMission;};
};    

nul = [] execVM "ADG\missionfinder.sqf";

If you know something, please give it to me. :)

Share this post


Link to post
Share on other sites

Instead of manually creating the tasks try this:

_null = [west, "mob_arty", ["Capture the Artillery and use it to your advantage.", "Capture the Artillery", "Capture the Artillery"], getMarkerPos "mob_arty", true] spawn BIS_fnc_taskCreate;  

To succeed it:

_null = ["mob_arty", "SUCCEEDED"] spawn BIS_fnc_taskSetState;

That'll do the notification for you.

Share this post


Link to post
Share on other sites

Thanks kylania.

Is there a bis_fnc_.... to remove a task out of the task-list? I don't want to have a list with 30 tasks in a longer gaming session. The only thing about those bis_functions i can find are the 14 functions in the wiki. :/

Cheers,

Valixx

Share this post


Link to post
Share on other sites

All the functions are under the Functions button in the editor, the fx button.

As for removing a task, you'd need to use the old style createSimpleTask commands in order to use removeSimpleTask later. Can't see any way to remove them via modules or new functions sadly.

Share this post


Link to post
Share on other sites

Well, then i'll have to take it like it is. Anyway, thank you kylania. :)

PS: Is there a task limit in the game?

Cheers,

Valixx

Share this post


Link to post
Share on other sites

I explained in one of your threads a week or so ago how you can get the TASK from a TASK_ID using BIS_fnc_taskReal.

Use something like this to remove a TASK via its TASK_ID.

player removeSimpleTask (["mob_arty",player] call bis_fnc_taskreal)

Share this post


Link to post
Share on other sites

Thanks Larrow.

____

Next post is at page 3.

Edited by Valixx
page 3

Share this post


Link to post
Share on other sites

Hey guys. Again a question.. Everything is working fine, except one thing. Steps of how the script works.

1. A hint in-game appears to notify the players that a side mission will be activated in 5 minutes.

2. After the 5 minutes, the script spawns a side mission and updates the player's tasks.

3. After they succeeded the task, the players get a hint and the task will be deleted. ( Out of the task list when pressing M )

4. Now the problem. When the side mission will be activated for the second time, the script does not add a task. The marker and everything appears and works except the adding task thing.

Heres my code:

// Mission

_missionType = [_this, 0, ""] call BIS_fnc_param;

sleep 10;
hintSilent parseText format ["<t align='center' color='#fffff' shadow='2' size='1.75'>Side Objective</t><br/><t align='center' color='#000000'>------------------------------</t><br/><t color='#ffffff' size='1.0'>Starting in 5 Minutes</t>"];
sleep 300;

fn_findMissionSpot = {

   private ["_mapCenter"];
   _mapCenter = getArray (configFile >> "CfgWorlds" >> worldName >> "centerPosition");
   [_mapCenter, random 4000, random 360, false] call SHK_pos;

};

fn_spawnArtyMission = {

   hintSilent parseText format ["<t align='center' color='#ffffff' shadow='2' size='1.75'>Side Objective</t><br/><t align='center' color='#000000'>------------------------------</t><br/><t color='#ffffff' size='1.0'>Capture the MK-6 Mortar and use it to your advantage.</t>"];

   //creating the marker 

   _marker = createMarker ["mob_arty", call fn_findMissionSpot];
   _marker setMarkerType "mil_objective";
   _marker setMarkerColor "ColorRed";
   _marker setMarkerText "Mobile Artillery";
   _marker setMarkerSize [1,1];

   _null = [west, "mob_arty", ["Capture the MK-6 Mortar and use it to your advantage.", "Capture the MK-6 Mortar", "Capture the MK-6 Mortar"], getMarkerPos "mob_arty", false] spawn BIS_fnc_taskCreate;

   //creating the vehicle

   _veh = ["B_Mortar_01_F","B_Mortar_01_F"] call BIS_fnc_selectRandom;

   art = createVehicle [_veh,[(getMarkerpos _marker select 0) + 30, getMarkerpos _marker select 1,0],[], 0, "NONE"];
   art setFuel 1;
   art setVehicleAmmo 1;

   waitUntil { Player distance art < 20};

   deleteMarker _marker;

   _null = ["mob_arty", "SUCCEEDED"] spawn BIS_fnc_taskSetState;

   _myHint ="Destroy some stuff soldier!!";
   GlobalHint = _myHint;
   publicVariable "GlobalHint";
   hintsilent parseText _myHint;

   _mySChat ="Excellent work, use it to your advantage!";
   GlobalSCHat = _mySChat;
   publicVariable "GlobalSCHat";
   player sideChat _mySChat;

   sleep 5;
   player removeSimpleTask (["mob_arty",player] call bis_fnc_taskreal);  // Delete task when done.
   hint "";
};

fn_spawnHeliMission = {

   hintSilent parseText format ["<t align='center' color='#ffffff' shadow='2' size='1.75'>Side Objective</t><br/><t align='center' color='#000000'>------------------------------</t><br/><t color='#ffffff' size='1.0'>A friendly heli is down. Get it for your Team!</t>"];

   //creating the marker 

   _marker = createMarker ["mob_heli", call fn_findMissionSpot];
   _marker setMarkerType "mil_objective";
   _marker setMarkerColor "ColorRed";
   _marker setMarkerText "Abandoned Helicopter";
   _marker setMarkerSize [1,1];

   _null = [west, "mob_heli", ["Capture the abandoned Helicopter and use it to your advantage.", "Capture the abandoned helicopter", "Capture the abandoned helicopter"], getMarkerPos "mob_heli", false] spawn BIS_fnc_taskCreate;  

   //creating the vehicle

   _veh = ["B_Heli_Transport_01_camo_F","B_Heli_Light_01_armed_F", "B_Heli_Light_01_F", "B_Heli_Attack_01_F"] call BIS_fnc_selectRandom;

   art = createVehicle [_veh,[(getMarkerpos _marker select 0) + 30, getMarkerpos _marker select 1,0],[], 0, "NONE"];
   art setFuel 1;
   art setVehicleAmmo 1;

   waitUntil { Player distance art < 20};

   deleteMarker _marker;

   _null = ["mob_heli", "SUCCEEDED"] spawn BIS_fnc_taskSetState;

   _myHint ="I hope you are a good pilot, soldier!!";
   GlobalHint = _myHint;
   publicVariable "GlobalHint";
   hintsilent parseText _myHint;

   _mySChat ="Excellent work, use it to your advantage!";
   GlobalSCHat = _mySChat;
   publicVariable "GlobalSCHat";
   player sideChat _mySChat;

   sleep 5;
   player removeSimpleTask (["mob_heli",player] call bis_fnc_taskreal);  // Delete task when done.
   hint "";
};

// MAIN LOGIC

_missionDetails = switch (_missionType) do {
   case "arty": {call fn_spawnArtyMission;};
   case "heli": {call fn_spawnHeliMission;};
};   

nul = [] execVM "ADG\missionfinder.sqf";

I thought the script works from top to bottom so that it adds the task everytime. What did i do wrong this time?

Share this post


Link to post
Share on other sites

I guessing its to do with how i told you to delete the task. Although the actual task is deleted the vars used by TASKID's still exist and may need clearing, give me a hour or two and ill have a quick look into it.

Share this post


Link to post
Share on other sites

Change the hintSilent parseText format stuff at the top of your missions to match the myHint stuff from the bottom of them. Or else only the server will see them.

Share this post


Link to post
Share on other sites

ok this is the stuff you have to remove/reset to get the task to show correctly. Still whittling down exactly what needs clearing but this does the job for now.

player removeSimpleTask (["task1",player] call bis_fnc_taskreal);
missionnamespace setVariable ["BIS_fnc_taskVar_task1",nil];
mytasks = player getVariable ["BIS_fnc_setTaskLocal_tasks",[]];
mytasks = mytasks - ["task1"];
player setVariable ["BIS_fnc_setTaskLocal_tasks",mytasks];
player setVariable ["BIS_fnc_taskvar_task1",nil];

This is just to give you an idea, most of these will need clearing/publicVariabling to all holders of the task.

Currently writing a function to take care of it for you in between watching tv and cooking dinner :D

Share this post


Link to post
Share on other sites

Thanks kylania. Like this, right?

_smhint = "HINT TEXT";
GlobalHint = _smhint;
publicVariable "GlobalHint";
hintsilent parseText _smhint;

ok this is the stuff you have to remove/reset to get the task to show correctly. Still whittling down exactly what needs clearing but this does the job for now.
player removeSimpleTask (["task1",player] call bis_fnc_taskreal);
missionnamespace setVariable ["BIS_fnc_taskVar_task1",nil];
mytasks = player getVariable ["BIS_fnc_setTaskLocal_tasks",[]];
mytasks = mytasks - ["task1"];
player setVariable ["BIS_fnc_setTaskLocal_tasks",mytasks];
player setVariable ["BIS_fnc_taskvar_task1",nil];

This is just to give you an idea, most of these will need clearing/publicVariabling to all holders of the task.

Currently writing a function to take care of it for you in between watching tv and cooking dinner :D

Awesome :D I have to read through the code above for a while, im not a pro.. so thanks Larrow. I'm waiting :P

Edited by Valixx

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

×