BIS fnc initIntelObject: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "|= |x3=" to "|Example2= |x3=")
m (Text replacement - " +\] +" to "] ")
 
(27 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{RV|type=function


{{Function|Comments=
|game1= arma3
____________________________________________________________________________________________
|version1= 1.00


| arma3 |Game name=
|gr1= Interaction


|1.00|Game version=
|descr= This function sets up an object as intel retrievable by the players by adding a "Take Intel" [[addAction]] to it.<br>
____________________________________________________________________________________________
When a player uses the action, they will play an animation to pick the object up and the object will be deleted from the mission.<br>
The player and any defined recipients will then receive a diary entry which can contain a ''title'', ''description'' and ''picture''.<br>
The diary entry will also contain a marker shortcut showing where the intel was found.<br><br>
This function is similar to placing an intel object as Zeus, but the Zeus interface provides some extra options like:<br>
* Which sides can interact with the action
* The picture, title and description used in the diary entry
<br>
When using this function from script there are several variables that need to be set up to acquire the same results (see the examples below).<br>
Without this extra setup the functionality provided is minimal and only includes:
* The "Take Intel" action on the object
* The object can be picked up by a player from any side
* When picked up it will have no title or description and the picture will be a default exclamation mark
* The diary entry will only be given to the person who picked it up
<br>
There are some optional features of intel objects that can be used:
* The diary entry's ''description'' can be further enhanced by using the supported tags found on the [[createDiaryRecord]] page.
* There is also a [[BIS_fnc_addScriptedEventHandler|scripted eventhandler]] called ''"IntelObjectFound"'' that can be registered  on the intel object. The event provides the parameters [object, caller] where ''object'' is the intel object and ''caller'' the person who picked it up.
* A Zeus who has the intel object registered as a curator editable object can also receive feedback that the intel has been picked up if the [[BIS_fnc_addScriptedEventHandler|scripted eventhandler]] called ''"intelObjectFound"'' was registered on the curator module. The event provides the parameters [zeus, caller, object] where ''zeus'' is the curator module, ''caller'' the person who picked it up and ''object'' is the intel object.
The usage of these scripted event handlers is shown in {{Link|#Example 3}}.<br>


| The function sets up an object as intel retrievable by the players by adding a "Take Intel" [[addAction]] to it.<br/>
|s1= [object] call [[BIS_fnc_initIntelObject]]
When a player uses the action, they will play an animation to pick the object up and the object will be deleted from the mission.<br/>
The player and any defined recipients will then receive a diary entry which can contain a ''title'', ''description'' and ''picture''.<br/>
The diary entry will also contain a marker shortcut showing where the intel was found.<br/><br/>
This function is similar to when placing an Intel object as Zeus, whose interface provides settings for some of the extra options like..<br/>
*Which sides can interact with the action
*The picture, title and description used in the diary entry
<br/>
However when using this function from script there are several variables that need to be set up to acquire the same results and can be seen in the examples below.<br/>
Without this extra setup the functionality provided is minimal and only includes..
*The "Take Intel" action on the object
*The object can be picked up by a player from any side
*When picked up will have no title or description and the picture will be a default exclamation mark
*Diary entry will only be given to the person who picked it up
<br/>
There are some optional features of intel objects that can be used..
*The diary entries ''description'' can be further enhanced by using any of the supported tags as found on the [[createDiaryRecord]] page.
*There is also a [[BIS_fnc_addScriptedEventHandler|scripted eventhandler]] that can be registered too called ''"IntelObjectFound"'' on the '''intel object'''. The event provides the parameters [ object, caller ] where ''object'' is the intel object and ''caller'' the person who picked it up.
*A Zeus who has the intel object registered as an curator editable object can also receive feedback that the intel has been picked up via registering too the [[BIS_fnc_addScriptedEventHandler|scripted eventhandler]] called ''"intelObjectFound"'' on the '''curator module'''. The event provides the parameters [ zeus, caller, object ] where ''zeus'' is the curator module, ''caller'' the person who picked it up and ''object'' is the intel object
The usage of scripted eventhandlers is shown in '''Example 3'''<br/>
<!---{{Informative|All the code examples provide comments ( // ) to describe each setting, please make sure you remove each commented line when copying to object inits otherwise you will receive errors}}---> |DESCRIPTION=
____________________________________________________________________________________________


| [ '''object''' ] call [[BIS_fnc_initIntelObject]]; |SYNTAX=
|p1= object: [[Object]] - object to place intel action on


|p1= '''object''': [[Object]] - Object to place intel action on |PARAMETER1=
|r1= [[Boolean]] - [[true]] when done


| [[true]] |RETURNVALUE=
|x1= Setup an object as intel from its init attribute in the editor.<br>
____________________________________________________________________________________________
Basic version including ''picture'', ''title'', ''description'', ''recipients'' and ''sides that can interact with it'':
{{Informative|}}
<sqf>
|x1= Setup an object as intel from its init attribute in the editor.<br/>
[this] call BIS_fnc_initIntelObject;
Basic version including ''picture'', ''title'', ''description'', ''recipients'' and ''which sides can interact with it''.<br/>
<code>[ this ] call BIS_fnc_initIntelObject;


if (isServer) then {
if (isServer) then
{
[[comment]] "Diary picture";
// Diary picture:
this setVariable [
this setVariable [
"RscAttributeDiaryRecord_texture",
"RscAttributeDiaryRecord_texture",
[[comment]] "Path to picture";
"a3\structures_f_epc\Items\Documents\Data\document_secret_01_co.paa", // Path to picture
"a3\structures_f_epc\Items\Documents\Data\document_secret_01_co.paa",
true
true
];
];
 
[[comment]] "Diary Title and Description";
// Diary Title and Description:
[
[
this,
this,
"RscAttributeDiaryRecord",
"RscAttributeDiaryRecord",
[[comment]] "[ Title, Description]";
["New Intel", "The enemies have a cave troll!"] // Array in format [Title, Description]
["Top Secret Docs","These Docs outline the enemies defenses"]
] call BIS_fnc_setServerVariable;
] call BIS_fnc_setServerVariable;
 
[[comment]] "Diary entry shared with.. follows [[BIS_fnc_MP]] target rules";
// Diary entry shared with (follows BIS_fnc_MP target rules):
this setVariable ["recipients", west, true];
this setVariable ["recipients", west, true];
 
[[comment]] "Sides that can interact with intelObject";
// Sides that can interact with the intel object:
this setVariable ["RscAttributeOwners", [west], true];
this setVariable ["RscAttributeOwners", [west], true];
};
</sqf>


};</code> |=
|x2= To set up an object as intel from its init attribute in the editor with a custom [[addAction]] title, replace the first line of {{Link|#Example 1}} with the following:
<br/>
<sqf>
|x2= Setup an object as intel from its init attribute in the editor with custom [[addAction]] title<br/>Replace the first line of '''Example 1''' with..<code>if ( hasInterface ) then {
if (hasInterface) then
{
this addAction [
this addAction [
[[comment]] "Custom addAction Title";
"Pick up laptop", // custom addAction title
"Pick up laptop",
{ [_this, "action"] spawn BIS_fnc_initIntelObject },
{[_this,"action"] spawn BIS_fnc_initIntelObject;},
[],
[],
10,
10,
Line 78: Line 74:
true,
true,
"",
"",
"isplayer _this && {_this distance _target < 2} &&
"isPlayer _this && { _this distance _target < 2 } &&
{(side group _this) in (_target getvariable ['RscAttributeOwners',[west,east,resistance,civilian]])}"
{ (side group _this) in (_target getVariable ['RscAttributeOwners', [west, east, resistance, civilian]]) }"
];
];
};</code> |Example2=
};
|x3= Setup an object as intel from its init attribute in the editor.<br/>
</sqf>
Basic version plus curator and object scripted eventhandlers.<br/>
 
<code>[ this ] call BIS_fnc_initIntelObject;
|x3= Set up an object as intel from its init attribute in the editor.<br>
Basic version plus curator and scripted event handlers:
<sqf>
[this] call BIS_fnc_initIntelObject;


if (isServer) then {
if (isServer) then
{
[[comment]] "Diary picture";
// Diary picture:
this setVariable [
this setVariable [
"RscAttributeDiaryRecord_texture",
"RscAttributeDiaryRecord_texture",
[[comment]] "Path to picture";
"a3\structures_f_epc\Items\Documents\Data\document_secret_01_co.paa", // Path to picture
"a3\structures_f_epc\Items\Documents\Data\document_secret_01_co.paa",
true
true
];
];
 
[[comment]] "Diary Title and Description";
// Diary Title and Description:
[
[
this,
this,
"RscAttributeDiaryRecord",
"RscAttributeDiaryRecord",
[[comment]] "[ Title, Description]";
["New Intel", "The enemies have a cave troll!"] // Array in format [Title, Description]
["Top Secret Docs","These Docs outline the enemies defenses"]
] call BIS_fnc_setServerVariable;
] call BIS_fnc_setServerVariable;
 
[[comment]] "Diary entry shared with.. follows [[BIS_fnc_MP]] target rules";
// Diary entry shared with (follows BIS_fnc_MP target rules):
this setVariable ["recipients", west, true];
this setVariable ["recipients", west, true];
 
[[comment]] "Sides that can interact with intelObject";
// Sides that can interact with the intel object:
this setVariable ["RscAttributeOwners", [west], true];
this setVariable ["RscAttributeOwners", [west], true];
[[comment]] "Optional scripted event handlers";


[[comment]] "Register intel object with Zeus as curator editable, Where _zeus is the curator module";
// Register intel object with Zeus as curator editable (_zeus is the curator module):
_zeus addCuratorEditableObjects [ [ this ], false ];
_zeus addCuratorEditableObjects [[this], false];
[[comment]] "Add Zeus scripted event, Where _zeus is the curator module";
[ _zeus, "IntelObjectFound", { hint "Intel found" } ] call BIS_fnc_addScriptedEventHandler;


[[comment]] "Add intel object scripted event that systemchats to all clients when found and by who";
// Add Zeus scripted event:
[_zeus, "IntelObjectFound", {hint "Intel found"}] call BIS_fnc_addScriptedEventHandler;
 
// Add a scripted event that notifies all clients via systemChat when the intel is found:
[
[
this,
this,
"IntelObjectFound",
"IntelObjectFound",
{
{
params[ "", "_foundBy" ];
params ["", "_foundBy"];
private _msg = format[ "Intel Found by %1", name _foundBy ];
private _msg = format ["Intel found by %1", name _foundBy];
_msg remoteExec[ "systemChat" ];
_msg remoteExec ["systemChat", 0];
}
}
] call BIS_fnc_addScriptedEventHandler;
] call BIS_fnc_addScriptedEventHandler;
};</code> Although both scripted eventhandlers supply a reference to the intel object it is deleted from the mission almost immediately so could possibly be [[objNull|null]] when queried. |=
};
____________________________________________________________________________________________
</sqf>
 
Although both scripted event handlers supply a reference to the intel object, it is deleted from the mission almost immediately, so it could already be [[objNull|null]] when queried.
| |SEEALSO=


|seealso=
}}
}}
<h3 style="display:none">Notes</h3>
<dl class="command_description">
<!-- Note Section BEGIN -->
<!-- Note Section END -->
</dl>
<h3 style="display:none">Bottom Section</h3>
[[Category:Function Group: Objects|{{uc:initIntelObject}}]]
[[Category:Functions|{{uc:initIntelObject}}]]
[[Category:{{Name|arma3}}: Functions|{{uc:initIntelObject}}]]

Latest revision as of 17:49, 8 November 2023

Hover & click on the images for description

Description

Description:
This function sets up an object as intel retrievable by the players by adding a "Take Intel" addAction to it.
When a player uses the action, they will play an animation to pick the object up and the object will be deleted from the mission.
The player and any defined recipients will then receive a diary entry which can contain a title, description and picture.
The diary entry will also contain a marker shortcut showing where the intel was found.

This function is similar to placing an intel object as Zeus, but the Zeus interface provides some extra options like:
  • Which sides can interact with the action
  • The picture, title and description used in the diary entry

When using this function from script there are several variables that need to be set up to acquire the same results (see the examples below).
Without this extra setup the functionality provided is minimal and only includes:
  • The "Take Intel" action on the object
  • The object can be picked up by a player from any side
  • When picked up it will have no title or description and the picture will be a default exclamation mark
  • The diary entry will only be given to the person who picked it up

There are some optional features of intel objects that can be used:
  • The diary entry's description can be further enhanced by using the supported tags found on the createDiaryRecord page.
  • There is also a scripted eventhandler called "IntelObjectFound" that can be registered on the intel object. The event provides the parameters [object, caller] where object is the intel object and caller the person who picked it up.
  • A Zeus who has the intel object registered as a curator editable object can also receive feedback that the intel has been picked up if the scripted eventhandler called "intelObjectFound" was registered on the curator module. The event provides the parameters [zeus, caller, object] where zeus is the curator module, caller the person who picked it up and object is the intel object.
The usage of these scripted event handlers is shown in Example 3.
Execution:
call
Groups:
Interaction

Syntax

Syntax:
[object] call BIS_fnc_initIntelObject
Parameters:
object: Object - object to place intel action on
Return Value:
Boolean - true when done

Examples

Example 1:
Setup an object as intel from its init attribute in the editor.
Basic version including picture, title, description, recipients and sides that can interact with it:
[this] call BIS_fnc_initIntelObject; if (isServer) then { // Diary picture: this setVariable [ "RscAttributeDiaryRecord_texture", "a3\structures_f_epc\Items\Documents\Data\document_secret_01_co.paa", // Path to picture true ]; // Diary Title and Description: [ this, "RscAttributeDiaryRecord", ["New Intel", "The enemies have a cave troll!"] // Array in format [Title, Description] ] call BIS_fnc_setServerVariable; // Diary entry shared with (follows BIS_fnc_MP target rules): this setVariable ["recipients", west, true]; // Sides that can interact with the intel object: this setVariable ["RscAttributeOwners", [west], true]; };
Example 2:
To set up an object as intel from its init attribute in the editor with a custom addAction title, replace the first line of Example 1 with the following:
if (hasInterface) then { this addAction [ "Pick up laptop", // custom addAction title { [_this, "action"] spawn BIS_fnc_initIntelObject }, [], 10, true, true, "", "isPlayer _this && { _this distance _target < 2 } && { (side group _this) in (_target getVariable ['RscAttributeOwners', [west, east, resistance, civilian]]) }" ]; };
Example 3:
Set up an object as intel from its init attribute in the editor.
Basic version plus curator and scripted event handlers:
[this] call BIS_fnc_initIntelObject; if (isServer) then { // Diary picture: this setVariable [ "RscAttributeDiaryRecord_texture", "a3\structures_f_epc\Items\Documents\Data\document_secret_01_co.paa", // Path to picture true ]; // Diary Title and Description: [ this, "RscAttributeDiaryRecord", ["New Intel", "The enemies have a cave troll!"] // Array in format [Title, Description] ] call BIS_fnc_setServerVariable; // Diary entry shared with (follows BIS_fnc_MP target rules): this setVariable ["recipients", west, true]; // Sides that can interact with the intel object: this setVariable ["RscAttributeOwners", [west], true]; // Register intel object with Zeus as curator editable (_zeus is the curator module): _zeus addCuratorEditableObjects [[this], false]; // Add Zeus scripted event: [_zeus, "IntelObjectFound", {hint "Intel found"}] call BIS_fnc_addScriptedEventHandler; // Add a scripted event that notifies all clients via systemChat when the intel is found: [ this, "IntelObjectFound", { params ["", "_foundBy"]; private _msg = format ["Intel found by %1", name _foundBy]; _msg remoteExec ["systemChat", 0]; } ] call BIS_fnc_addScriptedEventHandler; };
Although both scripted event handlers supply a reference to the intel object, it is deleted from the mission almost immediately, so it could already be null when queried.

Additional Information

See also:
See also needed

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note