fire: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\|seealso= *\[\[([^ ]+)\]\], \[\[([^ ]+)\]\]" to "|seealso= $1 $2")
m (Text replacement - "<sqf>([^↵][^\/]*↵[^\/]*)<\/sqf>" to "<sqf> $1 </sqf>")
 
(35 intermediate revisions by 2 users not shown)
Line 31: Line 31:


|descr= Forces a unit to fire the given weapon.
|descr= Forces a unit to fire the given weapon.
{{Feature | Informative | Just like with [[forceWeaponFire]] it is possible to pass remote unit as argument, but this could be unreliable. Considering this command might need to be used in combination with [[selectWeapon]], which takes only [[Multiplayer Scripting#Locality|local]] arguments, it would make sense to execute the [[fire]] command where the unit is [[Multiplayer Scripting#Locality|local]] as well.}}
{{Feature|informative|Just like with [[forceWeaponFire]] it is possible to pass remote unit as argument, but this could be unreliable. Considering this command might need to be used in combination with [[selectWeapon]], which takes only [[Multiplayer Scripting#Locality|local]] arguments, it would make sense to execute the [[fire]] command where the unit is [[Multiplayer Scripting#Locality|local]] as well.}}


|s1= unit [[fire]] muzzle
|s1= unit [[fire]] muzzle
Line 49: Line 49:
|p23= mode: [[String]]
|p23= mode: [[String]]


|p24= magazine: [[String]] (Optional)
|p24= magazine: [[String]] - (Optional)


|r2= [[Nothing]]
|r2= [[Nothing]]


|x1= <code>_soldier [[fire]] "M16";</code>
|x1= <sqf>_soldier fire "M16";</sqf>


|x2= <code>_soldier [[fire]] "SmokeShellMuzzle";</code>
|x2= <sqf>_soldier fire "SmokeShellMuzzle";</sqf>


|x3= <code>_soldier [[fire]] ["SmokeShellMuzzle", "SmokeShellMuzzle", "SmokeShellRed"];</code>
|x3= <sqf>_soldier fire ["SmokeShellMuzzle", "SmokeShellMuzzle", "SmokeShellRed"];</sqf>


|x4= <code>[[player]] [[playActionNow]] "PutDown";
|x4= <sqf>
[[player]] [[selectWeapon]] "DemoChargeMuzzle";
player playActionNow "PutDown";
[[player]] [[fire]] ["DemoChargeMuzzle", "DemoChargeMuzzle", "DemoCharge_Remote_Mag"];
player selectWeapon "DemoChargeMuzzle";
[[player]] [[setWeaponReloadingTime]] [<nowiki/>[[player]], "DemoChargeMuzzle", 0];</code>
player fire ["DemoChargeMuzzle", "DemoChargeMuzzle", "DemoCharge_Remote_Mag"];
player setWeaponReloadingTime [player, "DemoChargeMuzzle", 0];
</sqf>


|seealso= [[BIS_fnc_fire]] [[doFire]] [[commandFire]] [[canFire]] [[fireAtTarget]] [[forceWeaponFire]] [[commandArtilleryFire]] [[commandSuppressiveFire]] [[doArtilleryFire]] [[doSuppressiveFire]], [[isManualFire]], [[selectWeapon]], [[ArmA:_Actions#USEWEAPON|action ["UseWeapon"]]], [[:Category:Weapons]]
|seealso= [[BIS_fnc_fire]] [[doFire]] [[commandFire]] [[canFire]] [[fireAtTarget]] [[forceWeaponFire]] [[commandArtilleryFire]] [[commandSuppressiveFire]] [[doArtilleryFire]] [[doSuppressiveFire]] [[isManualFire]] [[selectWeapon]] [[ArmA:_Actions#USEWEAPON|action ["UseWeapon"]]] [[:Category:Weapons]]
}}
}}


Line 70: Line 72:


<dt></dt>
<dt></dt>
<dd class="notedate">Posted on August 17, 2006</dd>
<dd class="notedate">Posted on 2006-08-17</dd>
<dt class="note">[[User:Str|Str]]</dt>
<dt class="note">[[User:Str|Str]]</dt>
<dd class="note">Sometimes AI won't shoot when you use this command. It can be fixed by placing [[selectWeapon]] command before it.</dd>
<dd class="note">Sometimes AI won't shoot when you use this command. It can be fixed by placing [[selectWeapon]] command before it.</dd>


<dt><dt>
<dt><dt>
<dd class="notedate">Posted on February 2, 2007</dd>
<dd class="notedate">Posted on 2007-02-02</dd>
<dt class="note">[[User:Ceeeb|Ceeeb]]</dt>
<dt class="note">[[User:Ceeeb|Ceeeb]]</dt>
<dd class="note">
<dd class="note">
Line 82: Line 84:


<dt><dt>
<dt><dt>
<dd class="notedate">Posted on January 20, 2007</dd>
<dd class="notedate">Posted on 2007-01-20</dd>
<dt class="note">[[User:Bdfy|Bdfy]]</dt>
<dt class="note">[[User:Bdfy|Bdfy]]</dt>
<dd class="note">In '''ArmA v1.02''', this command is not working with weapons in the secondary turrets (like "DSHKM" in T-72)</dd>
<dd class="note">In '''ArmA v1.02''', this command is not working with weapons in the secondary turrets (like "DSHKM" in T-72)</dd>


<dt><dt>
<dt><dt>
<dd class="notedate">Posted on Jan 15, 2008</dd>
<dd class="notedate">Posted on 2008-01-15</dd>
<dt class="note">[[User:Kronzky|Kronzky]]</dt>
<dt class="note">[[User:Kronzky|Kronzky]]</dt>
<dd class="note">
<dd class="note">
Line 97: Line 99:


<dt><dt>
<dt><dt>
<dd class="notedate">Posted on March 18, 2010</dd>
<dd class="notedate">Posted on 2010-03-18</dd>
<dt class="note">[[User:Mr.g-c|Mr.g-c]]</dt>
<dt class="note">[[User:Mr.g-c|Mr.g-c]]</dt>
<dd class="note">In {{arma2}}, AI will automatically shoot straight up. Command seems to be broken.</dd>
<dd class="note">In {{arma2}}, AI will automatically shoot straight up. Command seems to be broken.</dd>


<dt><dt>
<dt><dt>
<dd class="notedate">Posted on November 24, 2010</dd>
<dd class="notedate">Posted on 2010-11-24</dd>
<dt class="note">[[User:Mikhail|Mikhail]]</dt>
<dt class="note">[[User:Mikhail|Mikhail]]</dt>
<dd class="note">Command is broken - confirmed. Use action [[ArmA:_Actions#USEWEAPON|"USEWEAPON"]] instead.
<dd class="note">Command is broken - confirmed. Use action [[ArmA:_Actions#USEWEAPON|"USEWEAPON"]] instead.
Place a game logic in the editor. Name it '''MyGameLogic'''.
Place a game logic in the editor. Name it '''MyGameLogic'''.
Use this code to make '''unit1''' fire his primaryweapon:
Use this code to make '''unit1''' fire his primaryweapon:
<code>MyGameLogic [[action]] ["useWeapon", [[primaryWeapon]] unit1, unit1, 0];</code></dd>
<sqf>MyGameLogic action ["useWeapon", primaryWeapon unit1, unit1, 0];</sqf></dd>


<dt><dt>
<dt><dt>
<dd class="notedate">Posted on Feburary 25, 2011</dd>
<dd class="notedate">Posted on 2011-02-25</dd>
<dt class="note">[[User:kju|kju]]</dt>
<dt class="note">[[User:.kju|.kju]]</dt>
<dd class="note">Command works just fine in A2/OA. Make sure to execute it on '''local''' AI.</dd>
<dd class="note">Command works just fine in A2/OA. Make sure to execute it on '''local''' AI.</dd>


<dt><dt>
<dt><dt>
<dd class="notedate">Posted on April 06, 2012</dd>
<dd class="notedate">Posted on 2012-04-06</dd>
<dt class="note">[[User:Max Power|Max Power]]</dt>
<dt class="note">[[User:Max Power|Max Power]]</dt>
<dd class="note">If it did work at one time, it does no longer.  The AI (or player) is forced to look upwards or reacts to a massive recoil force before getting his shot off.</dd>
<dd class="note">If it did work at one time, it does no longer.  The AI (or player) is forced to look upwards or reacts to a massive recoil force before getting his shot off.</dd>


<dt><dt>
<dt><dt>
<dd class="notedate">Posted on Feburary 16, 2013</dd>
<dd class="notedate">Posted on 2013-02-16</dd>
<dt class="note">[[User:hcpookie|hcpookie]]</dt>
<dt class="note">[[User:hcpookie|hcpookie]]</dt>
<dd class="note">Command did not work with {{Name|arma2acr|short}} v1.62.  Use [[fireAtTarget]] instead.</dd>
<dd class="note">Command did not work with {{Name|arma2acr|short}} v1.62.  Use [[fireAtTarget]] instead.</dd>


<dt></dt>
<dt></dt>
<dd class="notedate">Posted on June 4, 2014 - 21:14 (UTC)</dd>
<dd class="notedate">Posted on 2014-06-04 - 21:14 (UTC)</dd>
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
<dt class="note">[[User:Killzone_Kid|Killzone_Kid]]</dt>
<dd class="note">
<dd class="note">
In {{arma3}} in order for AI to place Claymore, for example, it is necessary to execute 3 statements - an animation, weapon select and the actual [[fire]] command. Animation is most likely for forcing unit to leave rest state, weapon select and fire kinda both go together anyway:
In {{arma3}} in order for AI to place Claymore, for example, it is necessary to execute 3 statements - an animation, weapon select and the actual [[fire]] command. Animation is most likely for forcing unit to leave rest state, weapon select and fire kinda both go together anyway:
<code>_unit [[playActionNow]] "PutDown";
<sqf>
_unit [[selectWeapon]] "DirectionalMineRemoteMuzzle";
_unit playActionNow "PutDown";
_unit [[fire]] [
_unit selectWeapon "DirectionalMineRemoteMuzzle";
_unit fire [
"DirectionalMineRemoteMuzzle",
"DirectionalMineRemoteMuzzle",
"DirectionalMineRemoteMuzzle",
"DirectionalMineRemoteMuzzle",
"ClaymoreDirectionalMine_Remote_Mag"
"ClaymoreDirectionalMine_Remote_Mag"
];</code>
];
</sqf>
</dd>
</dd>


<dt><dt>
<dt><dt>
<dd class="notedate">Posted on November 25th, 2017</dd>
<dd class="notedate">Posted on 2017-11-25</dd>
<dt class="note">[[User:SteveStevenson|Steve]]</dt>
<dt class="note">[[User:SteveStevenson|Steve]]</dt>
<dd class="note">
<dd class="note">
In {{arma3}}, as of version 1.76, examples 2 and 3 in the section above for smoke grenades are no longer working.
In {{arma3}}, as of version 1.76, examples 2 and 3 in the section above for smoke grenades are no longer working.
As a workaround (throwing green smoke grenades for example), you can use:
As a workaround (throwing green smoke grenades for example), you can use:
<code>[_soldier, "SmokeShellGreenMuzzle"] [[call]] [[BIS_fnc_fire]];</code></dt>
<sqf>[_soldier, "SmokeShellGreenMuzzle"] call BIS_fnc_fire;</sqf></dt>
</dd>
</dd>


</dl>
</dl>

Latest revision as of 11:34, 3 September 2024

Hover & click on the images for description

Description

Description:
Forces a unit to fire the given weapon.
Just like with forceWeaponFire it is possible to pass remote unit as argument, but this could be unreliable. Considering this command might need to be used in combination with selectWeapon, which takes only local arguments, it would make sense to execute the fire command where the unit is local as well.
Groups:
Unit ControlWeapons

Syntax

Syntax:
unit fire muzzle
Parameters:
unit: Object - unit that is supposed to fire
muzzle: String - name of the muzzle to be fired
Return Value:
Nothing

Alternative Syntax

Syntax:
unit fire [muzzle, mode, magazine]
Parameters:
unit: Object
muzzle: String
mode: String
magazine: String - (Optional)
Return Value:
Nothing

Examples

Example 1:
_soldier fire "M16";
Example 2:
_soldier fire "SmokeShellMuzzle";
Example 3:
_soldier fire ["SmokeShellMuzzle", "SmokeShellMuzzle", "SmokeShellRed"];
Example 4:
player playActionNow "PutDown"; player selectWeapon "DemoChargeMuzzle"; player fire ["DemoChargeMuzzle", "DemoChargeMuzzle", "DemoCharge_Remote_Mag"]; player setWeaponReloadingTime [player, "DemoChargeMuzzle", 0];

Additional Information

See also:
BIS_fnc_fire doFire commandFire canFire fireAtTarget forceWeaponFire commandArtilleryFire commandSuppressiveFire doArtilleryFire doSuppressiveFire isManualFire selectWeapon action ["UseWeapon"] Category:Weapons

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 2006-08-17
Str
Sometimes AI won't shoot when you use this command. It can be fixed by placing selectWeapon command before it.
Posted on 2007-02-02
Ceeeb
In OFP v1.96, when a man class unit is given this command, he will aim up in the air before firing his weapon. This makes it rather useless if you want to make him shoot a target. It does work with vehicles, when the vehicle is first given a doWatch or doTarget command.
Posted on 2007-01-20
Bdfy
In ArmA v1.02, this command is not working with weapons in the secondary turrets (like "DSHKM" in T-72)
Posted on 2008-01-15
Kronzky
To place a satchel (pipebomb) the syntax is:
OFP: unitname Fire ["put", "pipebomb"]
ArmA: unitname Fire ["pipebombmuzzle", "pipebombmuzzle", "pipebomb"];
The triggering is done via a "TOUCHOFF" action.
Posted on 2010-03-18
Mr.g-c
In Arma 2, AI will automatically shoot straight up. Command seems to be broken.
Posted on 2010-11-24
Mikhail
Command is broken - confirmed. Use action "USEWEAPON" instead. Place a game logic in the editor. Name it MyGameLogic. Use this code to make unit1 fire his primaryweapon:
MyGameLogic action ["useWeapon", primaryWeapon unit1, unit1, 0];
Posted on 2011-02-25
.kju
Command works just fine in A2/OA. Make sure to execute it on local AI.
Posted on 2012-04-06
Max Power
If it did work at one time, it does no longer. The AI (or player) is forced to look upwards or reacts to a massive recoil force before getting his shot off.
Posted on 2013-02-16
hcpookie
Command did not work with Arma 2:ACR v1.62. Use fireAtTarget instead.
Posted on 2014-06-04 - 21:14 (UTC)
Killzone_Kid
In Arma 3 in order for AI to place Claymore, for example, it is necessary to execute 3 statements - an animation, weapon select and the actual fire command. Animation is most likely for forcing unit to leave rest state, weapon select and fire kinda both go together anyway:
_unit playActionNow "PutDown"; _unit selectWeapon "DirectionalMineRemoteMuzzle"; _unit fire [ "DirectionalMineRemoteMuzzle", "DirectionalMineRemoteMuzzle", "ClaymoreDirectionalMine_Remote_Mag" ];
Posted on 2017-11-25
Steve
In Arma 3, as of version 1.76, examples 2 and 3 in the section above for smoke grenades are no longer working. As a workaround (throwing green smoke grenades for example), you can use:
[_soldier, "SmokeShellGreenMuzzle"] call BIS_fnc_fire;