unitReady: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "[[Category:Scripting Commands ArmA|" to "[[Category:Scripting Commands Armed Assault|")
m (Text replacement - ">Posted on November ([0-9]{2})[ a-zA-Z]*, ([0-9]{4})" to ">Posted on $2-11-$1")
 
(54 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Command|Comments=
{{RV|type=command
____________________________________________________________________________________________


| ofp |Game name=
|game1= ofp
|version1= 1.00


|1.00|Game version=
|game2= ofpe
____________________________________________________________________________________________
|version2= 1.00


| Check if the unit is ready. Unit is busy when it is given some command like [[move]], until the command is finished. |DESCRIPTION=
|game3= arma1
____________________________________________________________________________________________
|version3= 1.00


| [[unitReady]] unitName |SYNTAX=
|game4= arma2
|version4= 1.00


|p1= unitName: [[Object]] |PARAMETER1=
|game5= arma2oa
|version5= 1.50


| [[Boolean]] |RETURNVALUE=
|game6= tkoh
____________________________________________________________________________________________
|version6= 1.00
 
|x1= <code>[[private]] _it = [[unitReady]] _soldierOne;</code> |EXAMPLE1=
____________________________________________________________________________________________


| [[move]] |SEEALSO=
|game7= arma3
}}
|version7= 0.50


<h3 style="display:none">Notes</h3>
|gr1= Unit Control
<dl class="command_description">
<!-- Note Section BEGIN -->


<dd class="notedate">Posted on August 26, 2010
|descr= Check if the unit is ready. Unit is busy when it is given some command like [[move]], until the command is finished.
<dt class="note">[[User:Rübe|Rübe]]
<dd class="note">
Keep in mind that a) dead units are [[unitReady]] and b) that it takes a while until it get's known to group members that a unit is not [[alive]] anymore, which leads to c) the current [[leader]] of a group might be actually dead (until another group member takes command).<br>
Why this is important? I'll give you an example: if you're using [[unitReady]] as a condition inside one of your fsm to advance whatever the fsm/group is doing, you really might wanna check that this unit is actually still alive. Otherwise you might end up with really fast and nasty loops in your fsm, eventually accompanied by a stream of radio commands that will last until finally a living leader is in command again.. and that could take a while... nasty, I tell you :)


|s1= [[unitReady]] unitName


<dt class="note">[[User:Rübe|Rübe]]
|p1= unitName: [[Object]]
<dd class="note">
Regarding vehicles, there is only one single unit (from the vehicle crew) whose unitReady-status is affected by giving that vehicle (or that unit) commands. While it's the driver unit for a truck, it is the gunner unit for a mg-jeep or the commander for a tank. Generally it's always the unit "in control" of the vehicle. (because it's only that unit, that is seen as "full unit" to the "outside world". Only he can be adressed with commands.)<br>
In consequence you can't just send vehicles around and check if they've arrived with something like:


  waitUntil{(unitReady (driver _vehicle))}; // don't do this!
|r1= [[Boolean]]


Because it's ''not guaranteed, that the driver is in command of the vehicle'' and only that unit will have it's unitReady status affected.<br>
|x1= <sqf>private _it = unitReady _soldierOne;</sqf>
So in conclusion, '''if you need to check if a vehicle is ready''', try something like this:<pre>_vehicleReady = {
    private ["_veh", "_ready"];
    _veh = _this;
    _ready = true;
    {
        if (!(isNull _x)) then
        {
            _ready = _ready && (unitReady _x);
        };
    } forEach [
        (commander _veh),
        (gunner _veh),
        (driver _veh)
    ];
    _ready
};</pre>


|seealso= [[move]]
}}


<!-- Note Section END -->
<dl class="command_description">
</dl>


<h3 style="display:none">Bottom Section</h3>
<dt><dt>
<dd class="notedate">Posted on 2010-08-26</dd>
<dt class="note">[[User:Rübe|Rübe]]</dt>
<dd class="note">
Keep in mind that a) dead units are [[unitReady]] and b) that it takes a while until it get's known to group members that a unit is not [[alive]] anymore, which leads to c) the current [[leader]] of a group might be actually dead (until another group member takes command).<br>
Why this is important? I'll give you an example: if you're using [[unitReady]] as a condition inside one of your fsm to advance whatever the fsm/group is doing, you really might wanna check that this unit is actually still alive. Otherwise you might end up with really fast and nasty loops in your fsm, eventually accompanied by a stream of radio commands that will last until finally a living leader is in command again.. and that could take a while... nasty, I tell you :)
<dt><dt>
<dd class="notedate">Posted on 2011-01-17</dd>
<dt class="note">[[User:Rübe|Rübe]]</dt>
<dd class="note">
Regarding vehicles, there is only one single unit (from the vehicle crew) whose unitReady-status is affected by giving that vehicle (or that unit) commands.
While it is the driver unit for a truck, it is the gunner unit for a mg-jeep or the commander for a tank. Generally it is always the unit "in control" of the vehicle.
(because it is only that unit, that is seen as "full unit" to the "outside world". Only he can be adressed with commands.)<br>


[[Category:Scripting Commands OFP 1.46|{{uc:{{PAGENAME}}}}]]
In consequence you can't just send vehicles around and check if they've arrived with something like:
[[Category:Scripting Commands OFP 1.96|{{uc:{{PAGENAME}}}}]]
<sqf>waitUntil { unitReady driver _vehicle }; // don't do this!</sqf>
[[Category:Scripting Commands OFP 1.99|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Armed Assault|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Take On Helicopters|{{uc:{{PAGENAME}}}}]]


<!-- CONTINUE Notes -->
Because it is ''not guaranteed that the driver is in command of the vehicle'' and only that unit will have its unitReady status affected.<br>
<dl class="command_description">
So in conclusion, '''if you need to check if a vehicle is ready''', try something like this:
<dd class="notedate">Posted on November 21, 2015 - 22:40 (UTC)</dd>
<sqf>
_vehicleReady = {
private ["_veh", "_ready"];
_veh = _this;
_ready = true;
{
if (not isNull _x) then
{
_ready = _ready && (unitReady _x);
};
} forEach [
commander _veh,
gunner _veh,
driver _veh
];
_ready
};
</sqf>
<dt><dt>
<dd class="notedate">Posted on 2015-11-21 - 22:40 (UTC)</dd>
<dt class="note">[[User:Kastenbier|Kastenbier]]</dt>
<dt class="note">[[User:Kastenbier|Kastenbier]]</dt>
<dd class="note">
<dd class="note">
To check readiness of a vehicle, don't check it's crew, driver, gunner, commander, etc., but the vehicle itself, e.g.:
To check readiness of a vehicle, don't check its crew, driver, gunner, commander, etc., but the vehicle itself, e.g.:
<code>unitReady (vehicle driver _YourVehicle);</code><br>
<sqf>unitReady _yourVehicle;</sqf>
Only tested 11/21/2015 by me with A2 1.63.131129 and A3 1.52.132676 but possibly true since 1964. :P
Only tested 11/21/2015 by me with A2 1.63.131129 and A3 1.52.132676 but possibly true since 1964. :P
</dd>
</dd>
</dl>
</dl>
<!-- DISCONTINUE Notes -->

Latest revision as of 23:13, 13 May 2023

Hover & click on the images for description

Description

Description:
Check if the unit is ready. Unit is busy when it is given some command like move, until the command is finished.
Groups:
Unit Control

Syntax

Syntax:
unitReady unitName
Parameters:
unitName: Object
Return Value:
Boolean

Examples

Example 1:
private _it = unitReady _soldierOne;

Additional Information

See also:
move

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 2010-08-26
Rübe
Keep in mind that a) dead units are unitReady and b) that it takes a while until it get's known to group members that a unit is not alive anymore, which leads to c) the current leader of a group might be actually dead (until another group member takes command).
Why this is important? I'll give you an example: if you're using unitReady as a condition inside one of your fsm to advance whatever the fsm/group is doing, you really might wanna check that this unit is actually still alive. Otherwise you might end up with really fast and nasty loops in your fsm, eventually accompanied by a stream of radio commands that will last until finally a living leader is in command again.. and that could take a while... nasty, I tell you :)
Posted on 2011-01-17
Rübe
Regarding vehicles, there is only one single unit (from the vehicle crew) whose unitReady-status is affected by giving that vehicle (or that unit) commands. While it is the driver unit for a truck, it is the gunner unit for a mg-jeep or the commander for a tank. Generally it is always the unit "in control" of the vehicle. (because it is only that unit, that is seen as "full unit" to the "outside world". Only he can be adressed with commands.)
In consequence you can't just send vehicles around and check if they've arrived with something like:
waitUntil { unitReady driver _vehicle }; // don't do this!
Because it is not guaranteed that the driver is in command of the vehicle and only that unit will have its unitReady status affected.
So in conclusion, if you need to check if a vehicle is ready, try something like this:
_vehicleReady = { private ["_veh", "_ready"]; _veh = _this; _ready = true; { if (not isNull _x) then { _ready = _ready && (unitReady _x); }; } forEach [ commander _veh, gunner _veh, driver _veh ]; _ready };
Posted on 2015-11-21 - 22:40 (UTC)
Kastenbier
To check readiness of a vehicle, don't check its crew, driver, gunner, commander, etc., but the vehicle itself, e.g.:
unitReady _yourVehicle;
Only tested 11/21/2015 by me with A2 1.63.131129 and A3 1.52.132676 but possibly true since 1964. :P