fireAtTarget: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "[[Category:Scripting_Commands_Take_On_Helicopters" to "[[Category:Scripting Commands Take On Helicopters")
m (Text replacement - "↵↵</sqf>" to " </sqf>")
 
(79 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Command|Comments=
{{RV|type=command
____________________________________________________________________________________________


| arma2oa |Game name=
|game1= arma2oa
|version1= 1.50


|1.51|Game version=
|game2= tkoh
____________________________________________________________________________________________
|version2= 1.00


| Remotely forces a unit to fire the given weapon. See also: [[BIS_fnc_fire]] |DESCRIPTION=
|game3= arma3
____________________________________________________________________________________________
|version3= 0.50


| sourceVehicle '''fireAtTarget''' [targetVehicle, weaponMuzzleName] |SYNTAX=
|gr1= Unit Control


|p1= sourceVehicle: [[Object]] - source vehicle to fire from |PARAMETER1=
|gr2= Weapons
|p2= [targetVehicle, weaponMuzzleName]: [[Array]]
|p3= targetVehicle: [[Object]] - target vehicle to fire at |PARAMETER2=
|p4= weaponMuzzleName (Optional): [[String]] - weapon muzzle classname, optional parameter |PARAMETER3=


| [[Boolean]] - [[true]] if fired, [[false]] if not|RETURNVALUE=
|descr= Remotely forces a unit to fire the given weapon. See also [[BIS_fnc_fire]].
____________________________________________________________________________________________
 
|x1= <code>_handle = this [[fireAtTarget]] [groundtarget1,"HellfireLauncher"];</code> |EXAMPLE1=
|x2= <code>_handle = Igla_AA_pod_TK_EP1 [[fireAtTarget]] [_helicopter,[[currentWeapon]] Igla_AA_pod_TK_EP1];</code> |EXAMPLE2=
|x3= <code>_handle = Igla_AA_pod_TK_EP1 [[fireAtTarget]] [helicopter];</code> |EXAMPLE3=
____________________________________________________________________________________________


| [[fire]], [[doFire]], [[commandFire]], [[canFire]], [[forceWeaponFire]], [[commandArtilleryFire]], [[commandSuppressiveFire]], [[doArtilleryFire]], [[doSuppressiveFire]], [[isManualFire]], [[aimedAtTarget]], [[BIS_fnc_fire]] |SEEALSO=
|s1= sourceVehicle [[fireAtTarget]] [targetVehicle, weaponMuzzleName]


|p1= sourceVehicle: [[Object]] - source vehicle to fire from
|p2= targetVehicle: [[Object]] - target vehicle to fire at
|p3= weaponMuzzleName: [[String]] - (Optional) weapon muzzle classname, optional parameter
|r1= [[Boolean]] - [[true]] if fired, [[false]] if not
|x1= <sqf>_handle = this fireAtTarget [groundtarget1, "HellfireLauncher"];</sqf>
|x2= <sqf>_handle = Igla_AA_pod_TK_EP1 fireAtTarget [_helicopter, currentWeapon Igla_AA_pod_TK_EP1];</sqf>
|x3= <sqf>_handle = Igla_AA_pod_TK_EP1 fireAtTarget [helicopter];</sqf>
|seealso= [[fire]] [[doFire]] [[commandFire]] [[canFire]] [[forceWeaponFire]] [[commandArtilleryFire]] [[commandSuppressiveFire]] [[doArtilleryFire]] [[doSuppressiveFire]] [[isManualFire]] [[aimedAtTarget]] [[BIS_fnc_fire]]
}}
}}


<h3 style="display:none">Notes</h3>
{{Note
<dl class="command_description">
|user= Dwarden
<!-- Note Section BEGIN -->
|timestamp= 20100916081700
<dd class="notedate">Posted on Sep 16, 2010 - 08:17
|text= Most likely only for missiles and for interaction with player only.
<dt class="note">'''[[User:Dwarden|Dwarden]]'''<dd class="note">
}}
Most likely only for missiles and for interaction with player only.
 
<dd class="notedate">Posted on Apr 8, 2014 - 16:50
{{Note
<dt class="note">'''[[User:ffur2007slx2_5|ffur2007slx2_5]]'''<dd class="note">
|user= ffur2007slx2_5
(A3 1.14) Source vehicle is only limited to manned vehicle while any other types won’t be able to active [[fireAtTarget]] handle, e.g.
|timestamp= 20140408165000
<code>
|text= ({{arma3}} 1.14) Source vehicle is only limited to manned vehicle while any other types won’t be able to active [[fireAtTarget]] handle, e.g.
_handle = _InfantryUnit [[fireAtTarget]] [_Infnatrytarget,([[weapons]] _Infantryunit [[select]] 0)];  
<sqf>
//false & no bullet shoot
_handle = _infantryUnit fireAtTarget [_infantryTarget, weapons _infantryUnit select 0];
</code>
// false & no bullet shoot
</sqf>
Target has no limitation and can be any object:
Target has no limitation and can be any object:
<code>
<sqf>
_handle = ([[vehicle]] _veh) [[fireAtTarget]] [ObjNull,([[weapons]] ([[vehicle]] _veh) [[select]] 0)];  
_handle = (vehicle _veh) fireAtTarget [objNull, weapons (vehicle _veh) select 0];
//true & a bullet shoot
// true & a bullet shoot
</code>
</sqf>
Handle returns false if weapon class name is inaccurate, e.g.
Handle returns false if weapon class name is inaccurate, e.g.
<code>
<sqf>
_Handle = ([[vehicle]] _veh) [[fireAtTarget]] [ObjNull,”UnknownWeapon”];
_handle = (vehicle _veh) fireAtTarget [ObjNull, "UnknownWeapon"];
//false & no bullet shoot.
// false & no bullet shoot
</code>
</sqf>
Handle still returns true even though the vehicle is unavailable to shoot any bullet:
Handle still returns true even though the vehicle is unavailable to shoot any bullet:
<code>
<sqf>
_weapon = [[weapons]] ([[vehicle]] _veh) [[select]] 0;
_weapon = weapons (vehicle _veh) select 0;
([[vehicle]] _veh) [[setAmmo]] [_weapon,0];
(vehicle _veh) setAmmo [_weapon, 0];
_Handle = ([[vehicle]] _veh) [[fireAtTarget]] [ObjNull,_weapon];
_handle = (vehicle _veh) fireAtTarget [objNull, _weapon];
//true & no bullet shoot
// true & no bullet shoot
</code>
</sqf>
=== difference ===
 
{| class="wikitable sortable"
=== Difference ===
 
{{{!}} class="wikitable sortable"


! command
! command
Line 68: Line 77:
! Workaround templets
! Workaround templets


|-
{{!}}-
| [[fire]]
{{!}} [[fire]]
| Either Unit or manned vehicle
{{!}} Either unit or manned vehicle
| N/A
{{!}} {{n/a}}
| Fired aiming at air for infantry rifle
{{!}} Fired aiming at air for infantry rifle
| Together with [[selectWeapon]],
{{!}} Together with [[selectWeapon]],
suggested to work with "throw","put" weapon type
suggested to work with "throw","put" weapon type
for infantry, or vehicle entity indeed.
for infantry, or vehicle entity indeed.


|-
{{!}}-
| [[fireAtTarget]]
{{!}} [[fireAtTarget]]
| Manned vehicle only
{{!}} Manned vehicle only
| Any object
{{!}} Any object
| Normal shoot, won’t aim at target automatically
{{!}} Normal shoot, won’t aim at target automatically
| _veh [[doWatch]] _target;
{{!}}
[[waitUntil]] {_veh [[aimedAtTarget]] [_target] > 0};
<sqf>
_veh [[fireAtTarget]] [_target];
_veh doWatch _target;
waitUntil { _veh aimedAtTarget [_target] > 0 };
_veh fireAtTarget [_target];
</sqf>


|-
{{!}}-
| [[forceWeaponFire]]
{{!}} [[forceWeaponFire]]
| Either Unit or manned aircraft (weapon operator)
{{!}} Either unit or manned aircraft (weapon operator)
| N/A
{{!}} {{n/a}}
| Normal shoot, can change fire mode
{{!}} Normal shoot, can change fire mode
| //E.g. unit won't shoot until he is facing the target.
{{!}}
  _unit [[doWatch]] _tar;
<sqf>
  [[waitUntil]] {
// e.g. unit won't shoot until he is facing the target
    _dir = [[direction]] _unit;
_unit doWatch _tar;
    _relative = [_unit,_tar] [[call]] [[BIS_fnc_relativeDirTo]];
waitUntil {
    [[if]] (_dir == _relative) [[exitWith]] {
_dir = direction _unit;
      _unit [[forceWeaponFire]] [ [[currentWeapon]] _unit,"single"];
_relative = [_unit,_tar] call BIS_fnc_relativeDirTo;
    };
if (_dir == _relative) exitWith {
    [[false]]
_unit forceWeaponFire [currentWeapon _unit, "single"];
  };
};
false
};
</sqf>
{{!}}-
{{!}} [[doFire]]
{{!}} Unit only
{{!}} Either unit or vehicle
{{!}} automatic aiming and shooting
{{!}} No special example.


|-
{{!}}-
| [[doFire]]
{{!}} [[commandFire]]
| Unit only
{{!}} Unit only
| Either unit or vehicle
{{!}} Either unit or vehicle
| automatic aiming and shooting
{{!}} automatic aiming and shooting
| No special example.
{{!}} No special example.


|-
{{!}}-
| [[commandFire]]
{{!}} [[Arma 3: Actions#USEWEAPON{{!}}action ["UseWeapon"]]]
| Unit only
{{!}} Either unit or manned vehicle  
| Either unit or vehicle
{{!}} {{n/a}}
| automatic aiming and shooting
{{!}} unexpected behavior
| No special example.
{{!}} {{n/a}}


|-
{{!}}}
| [[ArmA:_Actions#USEWEAPON|action ["UseWeapon"]]]
|game= arma3
| Either unit or manned vehicle
|version= 1.14
| N/A
}}
| unexpected behavior
| N/A
 
|}
<!-- Note Section END -->
</dl>
 
<h3 style="display:none">Bottom Section</h3>
 
[[Category:Arma 2: Operation Arrowhead: New Scripting Commands List|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Take On Helicopters|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]

Latest revision as of 19:48, 3 September 2024

Hover & click on the images for description

Description

Description:
Remotely forces a unit to fire the given weapon. See also BIS_fnc_fire.
Groups:
Unit ControlWeapons

Syntax

Syntax:
sourceVehicle fireAtTarget [targetVehicle, weaponMuzzleName]
Parameters:
sourceVehicle: Object - source vehicle to fire from
targetVehicle: Object - target vehicle to fire at
weaponMuzzleName: String - (Optional) weapon muzzle classname, optional parameter
Return Value:
Boolean - true if fired, false if not

Examples

Example 1:
_handle = this fireAtTarget [groundtarget1, "HellfireLauncher"];
Example 2:
_handle = Igla_AA_pod_TK_EP1 fireAtTarget [_helicopter, currentWeapon Igla_AA_pod_TK_EP1];
Example 3:
_handle = Igla_AA_pod_TK_EP1 fireAtTarget [helicopter];

Additional Information

See also:
fire doFire commandFire canFire forceWeaponFire commandArtilleryFire commandSuppressiveFire doArtilleryFire doSuppressiveFire isManualFire aimedAtTarget BIS_fnc_fire

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
Dwarden - c
Posted on Sep 16, 2010 - 08:17 (UTC)
Most likely only for missiles and for interaction with player only.
ffur2007slx2_5 - c
Posted on Apr 08, 2014 - 16:50 (UTC)

(Arma 3 1.14) Source vehicle is only limited to manned vehicle while any other types won’t be able to active fireAtTarget handle, e.g.

_handle = _infantryUnit fireAtTarget [_infantryTarget, weapons _infantryUnit select 0]; // false & no bullet shoot
Target has no limitation and can be any object:
_handle = (vehicle _veh) fireAtTarget [objNull, weapons (vehicle _veh) select 0]; // true & a bullet shoot
Handle returns false if weapon class name is inaccurate, e.g.
_handle = (vehicle _veh) fireAtTarget [ObjNull, "UnknownWeapon"]; // false & no bullet shoot
Handle still returns true even though the vehicle is unavailable to shoot any bullet:
_weapon = weapons (vehicle _veh) select 0; (vehicle _veh) setAmmo [_weapon, 0]; _handle = (vehicle _veh) fireAtTarget [objNull, _weapon]; // true & no bullet shoot

Difference

command Source Target Behavior Workaround templets
fire Either unit or manned vehicle N/A Fired aiming at air for infantry rifle Together with selectWeapon,

suggested to work with "throw","put" weapon type for infantry, or vehicle entity indeed.

fireAtTarget Manned vehicle only Any object Normal shoot, won’t aim at target automatically

_veh doWatch _target; waitUntil { _veh aimedAtTarget [_target] > 0 }; _veh fireAtTarget [_target];

forceWeaponFire Either unit or manned aircraft (weapon operator) N/A Normal shoot, can change fire mode

// e.g. unit won't shoot until he is facing the target _unit doWatch _tar; waitUntil { _dir = direction _unit; _relative = [_unit,_tar] call BIS_fnc_relativeDirTo; if (_dir == _relative) exitWith { _unit forceWeaponFire [currentWeapon _unit, "single"]; }; false };

doFire Unit only Either unit or vehicle automatic aiming and shooting No special example.
commandFire Unit only Either unit or vehicle automatic aiming and shooting No special example.
action ["UseWeapon"] Either unit or manned vehicle N/A unexpected behavior N/A