agents: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\[\[Category:[ _]?Scripting[ _]Commands[ _]Arma[ _]3(\|.*)]]" to "{{GameCategory|arma3|Scripting Commands}}")
m (Some wiki formatting)
 
(47 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<br>
{{RV|type=command
{{Command|Comments=
____________________________________________________________________________________________


| arma2 |Game name=
|game1= arma2
|version1= 1.00


|1.00|Game version=
|game2= arma2oa
|version2= 1.50


|gr1= Teams |GROUP1=
|game3= tkoh
|version3= 1.00


|gr2= Object Detection |GROUP2=
|game4= arma3
____________________________________________________________________________________________
|version4= 0.50


| Return a list of agents in the current mission. |DESCRIPTION=
|gr1= Teams
____________________________________________________________________________________________


| '''agents''' |SYNTAX=
|gr2= Object Detection


|p1= |PARAMETER1=  
|descr= Return a list of agents in the current mission.


|p2= |PARAMETER2=  
|s1= [[agents]]


|p3= |PARAMETER3=  
|r1= [[Array]] of [[Team Member]]s


| [[Array]] of [[Team Member|Team Members]]|RETURNVALUE=  
|x1= <sqf>{ agent _x moveTo position player } forEach agents;</sqf>


|seealso= [[teams]] [[agent]] [[createAgent]] [[isAgent]] [[forEachMemberAgent]] [[entities]] [[allCurators]] [[allGroups]] [[allDead]] [[playableUnits]] [[switchableUnits]] [[vehicles]] [[allUnitsUAV]] [[allDeadMen]]
}}


|x1= <code>{[[agent]] _x [[moveTo]] [[position]] [[player]]} [[forEach]] '''agents''';</code>|EXAMPLE1=
{{Note
|user= Rocket
|timestamp= 20120404104800
|text= Note that agents returns a reference to the agent itself, not the object. For example: <sqf>{ alive _x } count agents;</sqf> would return an error
But you can assign the agent a reference using [[setVariable]], and then reference it, for example: <sqf>{ alive (_x getVariable ["agentObject", objNull]) } count agents;</sqf> would return the number of agents still alive - BUT you would need to define "agentObject" after you create the agent, for example:
<sqf>_agent = createAgent [_type, _position, [], _radius, "NONE"];_agent setVariable["agentObject",_agent,true];</sqf>
}}


____________________________________________________________________________________________
{{Note
|user= Killzone_Kid
|timestamp= 20130801215500
|text= Alternatively, to get object from agent reference use [[agent]] command.
}}


| [[agent]], [[createAgent]], [[isAgent]], [[forEachMemberAgent]], [[entities]], [[allCurators]], [[allGroups]], [[allDead]], [[playableUnits]], [[switchableUnits]], [[vehicles]], [[allUnitsUAV]], [[allDeadMen]] |SEEALSO=
{{Note
 
|user= PierreMGI
|  |MPBEHAVIOUR=
|timestamp= 20200526141000
____________________________________________________________________________________________
|text= In debug console, pointing at an agent:
<sqf>
cursorObject; // seems to refer to an agent (ex.: Agent 0xcbce41c0), but it is an object
teamMember cursorObject; // returns the same value Agent 0xcbce41c0, but now it is the agent
cursorObject in agents; // will return false (even if you can read the value Agent 0xcbce41c0 in the agents array)
teamMember cursorObject in agents; // returns true. TeamMember allows to refer to the agent under the cursorObject
agent teamMember cursorObject isEqualTo cursorObject; // true, same object.
</sqf>
}}
}}
<h3 style='display:none'>Notes</h3>
<dl class='command_description'>
<!-- Note Section BEGIN -->
<dd class="notedate">Posted on April 4, 2012 - 10:48 (GMT)
<dt class="note">[[User:Rocket|Rocket]]
<dd class="note">Note that agents returns a reference to the agent itself, not the object. For example: '''{alive _x} count agents;''' would return an error. But you can assign the agent a reference using setVariable, and then reference it, for example: '''{alive (_x getVariable ["agentObject",objNull]) count agents;''' would return the number of agents still alive - BUT you would need to define "agentObject" after you create the agent, for example:
'''_agent = createAgent [_type, _position, [], _radius, "NONE"];_agent setVariable["agentObject",_agent,true];'''
<dd class="notedate">Posted on August 1, 2013 - 21:55 (GMT)
<dt class="note">[[User:Killzone_Kid|Killzone_Kid]]
<dd class="note">Alternatively, to get object from agent reference use [[agent]] command.
<dd class="notedate">Posted on May 26, 2020 - 14:10 (GMT)
<dt class="note">[[User:PierreMGI|PierreMGI]]
<dd class="note">In debug console, pointing at an agent:<br>
{| class="wikitable"
|-
| ''[[cursorObject]]'' || // seems to refer to an agent (ex.: Agent 0xcbce41c0), but it is an object
|-
| ''[[teamMember]] cursorObject'' || // returns the same value Agent 0xcbce41c0, but now it is the agent
|-
| ''cursorObject in [[Agents]]'' || // so, will return false (even if you can read the value Agent 0xcbce41c0 in the agents array)
|-
| ''teamMember cursorObject in Agents'' || // returns true. TeamMember allows to refer to the agent under the cursorObject
|-
| ''[[agent]] teamMember cursorObject isEqualTo cursorObject'' || // True, same object.
|}
<br>
<!-- Note Section END -->
</dl>
<h3 style='display:none'>Bottom Section</h3>
[[Category:Scripting Commands Arma 2|{{uc:{{PAGENAME}}}}]]
{{GameCategory|arma3|Scripting Commands}}
[[Category:Scripting Commands Take On Helicopters|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]

Latest revision as of 22:48, 13 May 2023

Hover & click on the images for description

Description

Description:
Return a list of agents in the current mission.
Groups:
TeamsObject Detection

Syntax

Syntax:
agents
Return Value:
Array of Team Members

Examples

Example 1:

Additional Information

See also:
teams agent createAgent isAgent forEachMemberAgent entities allCurators allGroups allDead playableUnits switchableUnits vehicles allUnitsUAV allDeadMen

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
Rocket - c
Posted on Apr 04, 2012 - 10:48 (UTC)
Note that agents returns a reference to the agent itself, not the object. For example:
{ alive _x } count agents;
would return an error But you can assign the agent a reference using setVariable, and then reference it, for example:
{ alive (_x getVariable ["agentObject", objNull]) } count agents;
would return the number of agents still alive - BUT you would need to define "agentObject" after you create the agent, for example:
_agent = createAgent [_type, _position, [], _radius, "NONE"];_agent setVariable["agentObject",_agent,true];
Killzone_Kid - c
Posted on Aug 01, 2013 - 21:55 (UTC)
Alternatively, to get object from agent reference use agent command.
PierreMGI - c
Posted on May 26, 2020 - 14:10 (UTC)
In debug console, pointing at an agent:
cursorObject; // seems to refer to an agent (ex.: Agent 0xcbce41c0), but it is an object teamMember cursorObject; // returns the same value Agent 0xcbce41c0, but now it is the agent cursorObject in agents; // will return false (even if you can read the value Agent 0xcbce41c0 in the agents array) teamMember cursorObject in agents; // returns true. TeamMember allows to refer to the agent under the cursorObject agent teamMember cursorObject isEqualTo cursorObject; // true, same object.