fireAtTarget: Difference between revisions
Lou Montana (talk | contribs) m (Text replacement - ";[ ]+ " to "; ") |
Lou Montana (talk | contribs) m (Some wiki formatting) |
||
Line 14: | Line 14: | ||
|gr2= Weapons | |gr2= Weapons | ||
|descr= Remotely forces a unit to fire the given weapon. See also | |descr= Remotely forces a unit to fire the given weapon. See also [[BIS_fnc_fire]]. | ||
|s1= sourceVehicle [[fireAtTarget]] [targetVehicle, weaponMuzzleName] | |s1= sourceVehicle [[fireAtTarget]] [targetVehicle, weaponMuzzleName] | ||
|p1= sourceVehicle: [[Object]] - source vehicle to fire from | |p1= sourceVehicle: [[Object]] - source vehicle to fire from | ||
|p2 | |||
|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 | |r1= [[Boolean]] - [[true]] if fired, [[false]] if not | ||
|x1= <code>_handle = this [[fireAtTarget]] [groundtarget1,"HellfireLauncher"];</code> | |x1= <code>_handle = this [[fireAtTarget]] [groundtarget1,"HellfireLauncher"];</code> | ||
|x2= <code>_handle = Igla_AA_pod_TK_EP1 [[fireAtTarget]] [_helicopter,[[currentWeapon]] Igla_AA_pod_TK_EP1];</code> | |||
|x2= <code>_handle = Igla_AA_pod_TK_EP1 [[fireAtTarget]] [_helicopter, [[currentWeapon]] Igla_AA_pod_TK_EP1];</code> | |||
|x3= <code>_handle = Igla_AA_pod_TK_EP1 [[fireAtTarget]] [helicopter];</code> | |x3= <code>_handle = Igla_AA_pod_TK_EP1 [[fireAtTarget]] [helicopter];</code> | ||
Line 32: | Line 35: | ||
}} | }} | ||
{{Note | |||
|user= Dwarden | |||
|timestamp= 20100916081700 | |||
|text= Most likely only for missiles and for interaction with player only. | |||
}} | |||
{{Note | |||
|user= ffur2007slx2_5 | |||
|timestamp= 20140408165000 | |||
|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. | |||
( | |||
<code>_handle = _InfantryUnit [[fireAtTarget]] [_Infnatrytarget,([[weapons]] _Infantryunit [[select]] 0)]; | <code>_handle = _InfantryUnit [[fireAtTarget]] [_Infnatrytarget,([[weapons]] _Infantryunit [[select]] 0)]; | ||
{{cc|false & no bullet shoot}} | |||
</code> | </code> | ||
Target has no limitation and can be any object: | Target has no limitation and can be any object: | ||
<code>_handle = ([[vehicle]] _veh) [[fireAtTarget]] [ObjNull,([[weapons]] ([[vehicle]] _veh) [[select]] 0)]; | <code>_handle = ([[vehicle]] _veh) [[fireAtTarget]] [ObjNull,([[weapons]] ([[vehicle]] _veh) [[select]] 0)]; | ||
{{cc|true & a bullet shoot}} | |||
</code> | </code> | ||
Handle returns false if weapon class name is inaccurate, e.g. | Handle returns false if weapon class name is inaccurate, e.g. | ||
<code>_Handle = ([[vehicle]] _veh) [[fireAtTarget]] [ObjNull,”UnknownWeapon”]; | <code>_Handle = ([[vehicle]] _veh) [[fireAtTarget]] [ObjNull,”UnknownWeapon”]; | ||
{{cc|false & no bullet shoot}} | |||
</code> | </code> | ||
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: | ||
Line 58: | Line 60: | ||
([[vehicle]] _veh) [[setAmmo]] [_weapon,0]; | ([[vehicle]] _veh) [[setAmmo]] [_weapon,0]; | ||
_Handle = ([[vehicle]] _veh) [[fireAtTarget]] [ObjNull,_weapon]; | _Handle = ([[vehicle]] _veh) [[fireAtTarget]] [ObjNull,_weapon]; | ||
{{cc|true & no bullet shoot}} | |||
</code> | </code> | ||
=== difference === | === difference === | ||
{ | {{{!}} class="wikitable sortable" | ||
! command | ! command | ||
Line 69: | Line 71: | ||
! Workaround templets | ! 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 | suggested to work with "throw","put" weapon type | ||
for infantry, or vehicle entity indeed. | for infantry, or vehicle entity indeed. | ||
{{!}}- | |||
{{!}} [[fireAtTarget]] | |||
{{!}} Manned vehicle only | |||
{{!}} Any object | |||
{{!}} Normal shoot, won’t aim at target automatically | |||
{{!}} | |||
[[waitUntil]] {_veh [[aimedAtTarget]] [_target] > 0}; | <code>_veh [[doWatch]] _target; | ||
[[waitUntil]] { _veh [[aimedAtTarget]] [_target] > 0 }; | |||
_veh [[fireAtTarget]] [_target]; | _veh [[fireAtTarget]] [_target]; | ||
</code> | |||
{{!}}- | |||
{{!}} [[forceWeaponFire]] | |||
{{!}} Either unit or manned aircraft (weapon operator) | |||
{{!}} {{n/a}} | |||
{{!}} Normal shoot, can change fire mode | |||
| | {{!}} | ||
<code>{{cc|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]] [<nowiki/>[[currentWeapon]] _unit, "single"]; | |||
}; | |||
[[false]] | |||
}; | |||
</code> | |||
{{!}}- | |||
{{!}} [[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. | |||
{{!}}- | |||
{{!}} [[Arma 3: Actions#USEWEAPON{{!}}action ["UseWeapon"]]] | |||
{{!}} Either unit or manned vehicle | |||
{{!}} {{n/a}} | |||
{{!}} unexpected behavior | |||
{{!}} {{n/a}} | |||
{{!}}} | |||
| | |game= arma3 | ||
| | |version= 1.14 | ||
}} | |||
Revision as of 22:22, 21 September 2021
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:
- firedoFirecommandFirecanFireforceWeaponFirecommandArtilleryFirecommandSuppressiveFiredoArtilleryFiredoSuppressiveFireisManualFireaimedAtTargetBIS_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
- Posted on Sep 16, 2010 - 08:17 (UTC)
- Most likely only for missiles and for interaction with player only.
- 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 [_Infnatrytarget,(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