Jump to content
zagor64bz

Inspect leaflet as task

Recommended Posts

As the title suggest, I set up few leaflets with custom texture to be inspected by the player. How can I make this a task condition, so when you read all the leaflet a task is succeeded?  You can't really pick them up, so the usual !alive is not applicable.

Any help appreciated, thanks. 

  • Like 1

Share this post


Link to post
Share on other sites

I asked a similar question on discord a couple of weeks ago. I'd placed a map on the wall and use the inspect function so that when the players looked at the map inspecting it would show intel on the mission they had to carry out, but then I wanted it to assign a task once they had done that.

From what I gather there's no EH or anything that you can tap into to find out if a player has actually inspected the leaflets

 

Hopefully that's not the case as that would make a much better way of dealing with intel. 

Share this post


Link to post
Share on other sites

in init field of the leaflet:

[this, "examine", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_search_ca.paa", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_search_ca.paa", "_this distance _target < 3", "_caller distance _target < 3", {}, {}, {[] spawn { hintc "add your task here"}}, {}, [], 4, 0, true, false] call BIS_fnc_holdActionAdd

 

You see the principle.

Share this post


Link to post
Share on other sites
1 hour ago, pierremgi said:

in init field of the leaflet:

[this, "examine", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_search_ca.paa", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_search_ca.paa", "_this distance _target < 3", "_caller distance _target < 3", {}, {}, {[] spawn { hintc "add your task here"}}, {}, [], 4, 0, true, false] call BIS_fnc_holdActionAdd

 

You see the principle.

Great, but how do I add a custom texture to that? Right now this is what I have in the init of the leaflet:

["init", [this, "myCustomimage.jpg", "Text message"]] call BIS_fnc_initLeaflet

Thank you.

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, zagor64bz said:

Great, but how do I add a custom texture to that? Right now this is what I have in the init of the leaflet:


["init", [this, "myCustomimage.jpg", "Text message"]] call BIS_fnc_initLeaflet

Thank you.

custom texture is something apart. You can add it by setObjectTextureGlobal (I guess) or in Eden attributes (object specific).

  • Like 1

Share this post


Link to post
Share on other sites
//Create leaflet
["init", [this, "myCustomimage.jpg", "Text message"]] call BIS_fnc_initLeaflet;

//Add inspect leaflet task
[
	player,
	"Read leaflet",
	[ "Read a Custom leaflet", "Read leaflet" ],
	this,
	true,
	1,
	true,
	"interact",
	false
] call BIS_fnc_taskCreate;

//Add event for when leaflet is read
[ missionNamespace, "objectInspected", {
	params[ "_leaflet", "_texture", "_text", "_sound", "_textureRatio" ];
	
	//If leaflets texture is of type myCustom.jpg
	if ( _texture == "myCustomimage.jpg" ) then {
		[ "Read leaflet", "SUCCEEDED", true ] call BIS_fnc_taskSetState;
	};
}] call BIS_fnc_addScriptedEventHandler;

Example Mission

  • Like 4
  • Thanks 6

Share this post


Link to post
Share on other sites
57 minutes ago, Larrow said:

...

 

MP dedicated server capable?

Share this post


Link to post
Share on other sites
30 minutes ago, BadHabitz said:

MP dedicated server capable?

Can be if handled correctly. Of course the BIS_fnc_initLeaflet will need to be added to each client, as with all things action orientated. The event will also need to be added on each client, but once it fires BIS_fnc_taskSetState will set the tasks state globally (if the tasks targets requires it).

Share this post


Link to post
Share on other sites
5 hours ago, Larrow said:

//Create leaflet
["init", [this, "myCustomimage.jpg", "Text message"]] call BIS_fnc_initLeaflet;

//Add inspect leaflet task
[
	player,
	"Read leaflet",
	[ "Read a Custom leaflet", "Read leaflet" ],
	this,
	true,
	1,
	true,
	"interact",
	false
] call BIS_fnc_taskCreate;

//Add event for when leaflet is read
[ missionNamespace, "objectInspected", {
	params[ "_leaflet", "_texture", "_text", "_sound", "_textureRatio" ];
	
	//If leaflets texture is of type myCustom.jpg
	if ( _texture == "myCustomimage.jpg" ) then {
		[ "Read leaflet", "SUCCEEDED", true ] call BIS_fnc_taskSetState;
	};
}] call BIS_fnc_addScriptedEventHandler;

Example Mission

THANK YOU LARROW!!!

  • Like 2

Share this post


Link to post
Share on other sites
8 hours ago, zagor64bz said:

3 hours ago, Larrow said:

Spoiler

//Create leaflet
["init", [this, "myCustomimage.jpg", "Text message"]] call BIS_fnc_initLeaflet;

//Add inspect leaflet task
[
	player,
	"Read leaflet",
	[ "Read a Custom leaflet", "Read leaflet" ],
	this,
	true,
	1,
	true,
	"interact",
	false
] call BIS_fnc_taskCreate;

//Add event for when leaflet is read
[ missionNamespace, "objectInspected", {
	params[ "_leaflet", "_texture", "_text", "_sound", "_textureRatio" ];
	
	//If leaflets texture is of type myCustom.jpg
	if ( _texture == "myCustomimage.jpg" ) then {
		[ "Read leaflet", "SUCCEEDED", true ] call BIS_fnc_taskSetState;
	};
}] call BIS_fnc_addScriptedEventHandler;

 

It work beautifully! Now..what if i want to create a task where the leaflet to be inspected are 2 or more?

 i.e.  "myCustomimage.jpg" AND "myCustomimage_2.jpg"?

Thanks man!

Share this post


Link to post
Share on other sites
16 hours ago, zagor64bz said:

It work beautifully! Now..what if i want to create a task where the leaflet to be inspected are 2 or more?

A task where A leaflet has to be read that could be one of many textures?

//If leaflets texture is one of type myCustom#.jpg
if ( toLower _texture in ( [ "myCustomimage.jpg", "myCustomimage2.jpg" ] apply{ toLower _x } ) ) then {
	[ "Read leaflet", "SUCCEEDED", true ] call BIS_fnc_taskSetState;
};

A task where many different leaflets need to be read?

//Leaflets that need to be read to complete the task
//DO NOT place this in entities init field as it will get reset upon any JIP
//Maybe place it in the initServer
TAG_taskLeafletsToRead = [ "myCustomimage.jpg", "myCustomimage2.jpg" ] apply{ toLower _x };
//Then PV to all clients and JIP
publicVariable "TAG_taskLeafletsToRead";


//Replace on client
//Add event for when leaflet is read
[ missionNamespace, "objectInspected", {
	params[ "_leaflet", "_texture", "_text", "_sound", "_textureRatio" ];
	
	_texture = toLower _texture;
	
	//If leaflets texture is of type that still needs to be read
	if ( _texture in TAG_taskLeafletsToRead ) then {
		//Remove leaflet texture from toRead list and PV
		missionNamespace setVariable[ "TAG_taskLeafletsToRead", TAG_taskLeafletsToRead - [ _texture ], true ];
		//If there are no more leaflets that need reading
		if ( count TAG_taskLeafletsToRead isEqualTo 0 ) then {
			[ "Read leaflet", "SUCCEEDED", true ] call BIS_fnc_taskSetState;
		};
	};
}] call BIS_fnc_addScriptedEventHandler;

Of course this could also be done with child tasks for each leaflet type and when all child task are done complete the parent.

 

Untested and yes I have been overcautious with the use of toLower so as no mistakes can be made.

  • Thanks 3

Share this post


Link to post
Share on other sites
1 hour ago, Larrow said:

A task where many different leaflets need to be read?

:yeahthat:..and since is SP, should be like this? :

 

this in the init.sqf

TAG_taskLeafletsToRead = [ "myCustomimage.jpg", "myCustomimage2.jpg" ] apply{ toLower _x };

publicVariable "TAG_taskLeafletsToRead";//?????

and the rest in a parent-child task that I have already set up:

Spoiler


_myTaskIDs = ["Task01","Task02","Task03"];


_makeParentTask = ["ParentTask01",player,[format ["Put the CERBERUS Crime Inc. out of business!"],"Put the CERBERUS Crime Inc. out of business!",""],objNull,"ASSIGNED",4,true,true,"target"];


_makeTask1 = [["Task01","ParentTask01"],player,["Destroy ALL STOCKPILES","Destroy ALL NARCOTICS,MONEY and WEAPONS stockpiles",""],objNull,"ASSIGNED",1,true,true,"destroy"];
_makeTask2 = [["Task02","ParentTask01"],player,["Clear ALL HIDEOUTS","Clear all the CRIMINALS hideouts",""],objNull,"ASSIGNED",2,true,true,"attack"];
_makeTask3 = [["Task03","ParentTask01"],player,["Eliminate ALL the CERBERUS HVT","Eliminate ALL the MAFIA's HVT",""],objNull,"ASSIGNED",3,true,true,"kill"];
_makeTask4 = [["Task04","ParentTask01"],player,["read leaflets","read leaflets",""],objNull,"ASSIGNED",0,true,true,"interact"];


TexTask1 = false;
TexTask2 = false;
TexTask3 = false;
TexTask4 = false;
ParentTask01 = false;




_watchTask1 = [] spawn {
	
	_box = [];
	waitUntil {sleep 0.5;!alive (drugBox) AND !alive (drugBox2) AND !alive (drugBox3) AND !alive (moneyBox) AND !alive (moneyBox2) AND !alive (moneyBox3) AND !alive (weaponBox) AND !alive (weaponBox2) AND !alive (weaponBox3)};
	["Task01", "SUCCEEDED",true] spawn BIS_fnc_taskSetState;
	TexTask1 = true;
	sleep 5;
	//waitUntil {sleep 0.5; (!alive drugBox};
    //deleteMarker "drugBoxMarker1";
	//sleep 1;
	saveGame;
};

_watchTask2 = [] spawn {


	_areas = ["NARCOS","NARCOS_1","NARCOS_2","NARCOS_3","NARCOS_4","NARCOS_5","NARCOS_6","NARCOS_7","NARCOS_8","NARCOS_9","NARCOS_10","NARCOS_11","NARCOS_12","NARCOS_13","NARCOS_14","NARCOS_15","NARCOS_16","WEAPONS","WEAPONS_1","WEAPONS_2","WEAPONS_3","WEAPONS_4","WEAPONS_5","WEAPONS_6","WEAPONS_7","WEAPONS_8","WEAPONS_9","WEAPONS_10","WEAPONS_11","WEAPONS_12","WEAPONS_13","WEAPONS_14","WEAPONS_15","MONEY","MONEY_1","MONEY_2","MONEY_3","MONEY_4","MONEY_5","MONEY_6","MONEY_7","MONEY_8","MONEY_9","MONEY_10","MONEY_11","MONEY_12"]; //list of markers using EOS //list of markers using EOS

	//you don't need an if condition here but more likely waitUntil
	waitUntil {sleep 1; { getMarkerColor _x == "ColorGreen"; } count _areas == count _areas};


	["Task02", "SUCCEEDED",true] spawn BIS_fnc_taskSetState;
	TexTask2 = true;
	sleep 5;
	saveGame;

};


_watchTask3 = [] spawn {

	waitUntil {sleep 0.5;!alive (ZAG_HVT1) AND !alive (ZAG_HVT2) AND !alive (ZAG_HVT3)};
	["Task03", "SUCCEEDED",true] spawn BIS_fnc_taskSetState;
	TexTask3 = true;
	sleep 5;
	saveGame;

};

_watchTask4 = [ missionNamespace, "objectInspected", {
	params[ "_leaflet", "_texture", "_text", "_sound", "_textureRatio" ];
	
	_texture = toLower _texture;
	
	//If leaflets texture is of type that still needs to be read
	if ( _texture in TAG_taskLeafletsToRead ) then {
		//Remove leaflet texture from toRead list and PV
		missionNamespace setVariable[ "TAG_taskLeafletsToRead", TAG_taskLeafletsToRead - [ _texture ], true ];
		//If there are no more leaflets that need reading
		if ( count TAG_taskLeafletsToRead isEqualTo 0 ) then {
			[ "Read leaflet", "SUCCEEDED", true ] call BIS_fnc_taskSetState;
		TexTask4 = true;
		sleep 5;
		saveGame;
		};
	};
}] call BIS_fnc_addScriptedEventHandler;


_watchParentTask = [] spawn {



	waitUntil {sleep 1;(TexTask1 AND TexTask2 AND TexTask3 AND TexTask4)};

	if (TexTask1 AND TexTask2 AND TexTask3 AND TexTask4) then {

		["ParentTask01", "SUCCEEDED",true] spawn BIS_fnc_taskSetState;
		systemchat "ALL TASK COMPLETED";
		ParentTask01 = true;
		sleep 5;
		"END1" call BIS_fnc_endMission;
	    //saveGame;

	};
};

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

 

 

Share this post


Link to post
Share on other sites

Yes would be fine in the init.sqf for SP, although would be no different if in initServer.sqf.

Dont need any of the publicVariable stuff for SP either.

Share this post


Link to post
Share on other sites
9 minutes ago, Larrow said:

Yes would be fine in the init.sqf for SP, although would be no different if in initServer.sqf.

Dont need any of the publicVariable stuff for SP either.

Awesome! Is the task tree correct, then?

Thank you again man.

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

×