agents: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "<dt class="note">([^<>]+) " to "<dt class="note">$1</dt> ")
m (Some wiki formatting)
Line 1: Line 1:
<br>
{{RV|type=command
{{RV|type=command


| arma2
|game1= arma2


|1.00
|version1= 1.00


|gr1= Teams
|gr1= Teams
Line 10: Line 9:
|gr2= Object Detection
|gr2= Object Detection


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


| '''agents'''
|s1= '''agents'''


|p1=
|r1= [[Array]] of [[Team Member|Team Members]]
 
|p2=
 
|p3=
 
| [[Array]] of [[Team Member|Team Members]]


|x1= <code>{[[agent]] _x [[moveTo]] [[position]] [[player]]} [[forEach]] '''agents''';</code>
|x1= <code>{[[agent]] _x [[moveTo]] [[position]] [[player]]} [[forEach]] '''agents''';</code>


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


Line 40: Line 33:
<dd class="notedate">Posted on May 26, 2020 - 14:10 (GMT)</dd>
<dd class="notedate">Posted on May 26, 2020 - 14:10 (GMT)</dd>
<dt class="note">[[User:PierreMGI|PierreMGI]]</dt>
<dt class="note">[[User:PierreMGI|PierreMGI]]</dt>
<dd class="note">In debug console, pointing at an agent:<br>
<dd class="note">In debug console, pointing at an agent:
{| class="wikitable"
{| class="wikitable"
|-
|-
Line 47: Line 40:
| ''[[teamMember]] cursorObject'' || // returns the same value Agent 0xcbce41c0, but now it is the agent
| ''[[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)
| ''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
| ''teamMember cursorObject in Agents'' || // returns true. TeamMember allows to refer to the agent under the cursorObject
Line 53: Line 46:
| ''[[agent]] teamMember cursorObject isEqualTo cursorObject'' || // True, same object.
| ''[[agent]] teamMember cursorObject isEqualTo cursorObject'' || // True, same object.
|}
|}
<br>
</dd>


<!-- Note Section END -->
<!-- Note Section END -->
Line 62: Line 55:
{{GameCategory|arma3|Scripting Commands}}
{{GameCategory|arma3|Scripting Commands}}
{{GameCategory|tkoh|Scripting Commands}}
{{GameCategory|tkoh|Scripting Commands}}
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]

Revision as of 01:00, 1 February 2021

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:
{agent _x moveTo position player} forEach agents;

Additional Information

See also:
agentcreateAgentisAgentforEachMemberAgententitiesallCuratorsallGroupsallDeadplayableUnitsswitchableUnitsvehiclesallUnitsUAVallDeadMen

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
Posted on April 4, 2012 - 10:48 (GMT)
Rocket
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];
Posted on August 1, 2013 - 21:55 (GMT)
Killzone_Kid
Alternatively, to get object from agent reference use agent command.
Posted on May 26, 2020 - 14:10 (GMT)
PierreMGI
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 // 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.