forceWeaponFire: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
m (Text replacement - "<sqf>([^↵][^<]*↵[^<]*)<\/sqf>" to "<sqf> $1 </sqf>")
 
(91 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


| arma3 |= Game name
|game1= arma3
|version1= 0.50


|0.50|= Game version
|arg= local


|arg= local |= Arguments in MP
|eff= global


|eff= global |= Effects in MP
|gr1= Unit Control
____________________________________________________________________________________________


| The unit will be forced to fire from the given weapon. The weapon will not fire if firemode passed as parameter is not supported by the weapon. Command must be executed where unit is [[local]]. |= Description
|gr2= Weapons
____________________________________________________________________________________________


| unit '''forceWeaponFire''' [weapon, firemode] |= Syntax
|descr= The unit will be forced to fire weapon from the given muzzle. The weapon will not fire if firemode passed as parameter is not supported by the given muzzle. The muzzle could belong to a vehicle weapon and unit in this case will be the unit operating this weapon. Doesnt't seem to work for units in FFV positions. Works on [[player]]. See also: [[BIS_fnc_fire]]


|p1= unit: [[Object]] |= PARAMETER1
|s1= unit [[forceWeaponFire]] [muzzle, firemode]


|p2= [weapon, firemode]: [[Array]] |= PARAMETER2
|p1= unit: [[Object]] - unit alone or in vehicle


|p3= weapon: [[String]] |= PARAMETER3
|p2= muzzle: [[String]]


|p4= firemode: [[String]] - Common options are "Single", "Burst", "FullAuto". For the full list of a weapon firemodes:
|p3= firemode: [[String]] - common options are "Single", "Burst", "FullAuto". For the full list of a weapon firemodes:


<code>[[hint]] [[str]] ([[getArray]] ([[configFile]] >> "CfgWeapons" >> [[currentWeapon]] [[player]] >> "modes"));</code> If ''modes[]'' param in config for the weapon says ''{"this"}'', then the same classname as for the weapon param should be used as firemode param. |= PARAMETER4
<sqf>hint str (getArray (configFile >> "CfgWeapons" >> currentWeapon player >> "modes"));</sqf> If ''modes[]'' param in config for the weapon says ''{"this"}'', then the same classname as for the weapon param ([[currentWeapon]] [[player]]) should be used as firemode param.


| [[Nothing]] |= RETURNVALUE
|r1= [[Nothing]]


|x1= <sqf>
_unit forceWeaponFire ["arifle_MX_F", "Single"];
_unit forceWeaponFire ["hgun_ACPC2_F", "hgun_ACPC2_F"];
_unit forceWeaponFire ["HandGrenadeMuzzle","HandGrenadeMuzzle"];
_unit forceWeaponFire ["MiniGrenadeMuzzle","MiniGrenadeMuzzle"];
_unit forceWeaponFire ["HandGrenade_Stone","HandGrenade_Stone"];
_unit forceWeaponFire ["SmokeShellMuzzle","SmokeShellMuzzle"];
_unit forceWeaponFire ["ChemlightGreenMuzzle","ChemlightGreenMuzzle"];
_unit forceWeaponFire ["IRGrenade","IRGrenade"];
_unit forceWeaponFire ["Laserdesignator","Laserdesignator"];
</sqf>


|x1= <code>soldierOne [[forceWeaponFire]] ["arifle_MX_F", "Single"];</code>|= EXAMPLE1
|x2= <sqf>gunner blackfoot forceWeaponFire ["gatling_20mm", "close"];</sqf>
|x2= <code>[[player]] [[forceWeaponFire]] ["hgun_ACPC2_F", "hgun_ACPC2_F"];</code>|= EXAMPLE2
|x3= <code>_unit [[forceWeaponFire]] ["HandGrenadeMuzzle","HandGrenadeMuzzle"];
_unit [[forceWeaponFire]] ["MiniGrenadeMuzzle","MiniGrenadeMuzzle"];
_unit [[forceWeaponFire]] ["HandGrenade_Stone","HandGrenade_Stone"];
_unit [[forceWeaponFire]] ["SmokeShellMuzzle","SmokeShellMuzzle"];
_unit [[forceWeaponFire]] ["ChemlightGreenMuzzle","ChemlightGreenMuzzle"];
_unit [[forceWeaponFire]] ["IRGrenade","IRGrenade"];</code>|= EXAMPLE3
____________________________________________________________________________________________


| [[currentWeapon]], [[currentWeaponMode]], [[fire]], [[setWeaponReloadingTime]], [[selectWeapon]], [[doFire]], [[commandFire]], [[fireAtTarget]] |= SEEALSO
|seealso= [[currentWeapon]] [[currentWeaponMode]] [[setWeaponReloadingTime]] [[selectWeapon]] [[fire]] [[doFire]] [[commandFire]] [[canFire]] [[fireAtTarget]] [[commandArtilleryFire]] [[commandSuppressiveFire]] [[doArtilleryFire]] [[doSuppressiveFire]] [[isManualFire]] [[BIS_fnc_fire]]
}}


|  |= MPBEHAVIOUR
<dl class="command_description">
____________________________________________________________________________________________
}}


<h3 style='display:none'>Notes</h3>
<dt><dt>
<dl class='command_description'>
<dd class="notedate">Posted on 2013-08-25</dd>
<!-- Note Section BEGIN -->
<dt class="note">[[User:Killzone_Kid|Killzone_Kid]]</dt>
<dd class="notedate">Posted on August 25, 2013
<dt class="note">'''[[User:Killzone_Kid|Killzone_Kid]]'''
<dd class="note">Here is a neat workaround trick for firemode change from a script:
<dd class="note">Here is a neat workaround trick for firemode change from a script:
<code>_weapon = [[currentWeapon]] [[player]];
<sqf>
_ammo = [[player]] [[ammo]] _weapon;
_weapon = currentWeapon player;
[[player]] [[setAmmo]] [_weapon, 0];
_ammo = player ammo _weapon;
[[player]] [[forceWeaponFire]] [_weapon, "FullAuto"];
player setAmmo [_weapon, 0];
[[player]] [[setAmmo]] [_weapon, _ammo];</code>
player forceWeaponFire [_weapon, "FullAuto"];
<dd class="notedate">Posted on April 14, 2014
player setAmmo [_weapon, _ammo];
<dt class="note">[[User:ffur2007slx2_5|ffur2007slx2_5]]
</sqf>
<dd class="notedate">Posted on 2014-04-14</dd>
<dt class="note">[[User:ffur2007slx2_5|ffur2007slx2_5]]</dt>
<dd class="note">(A3 1.16) [[forceWeaponFire]] is no longer only limited to units, but can remote aircrafts weapon firing as well. Passed source unit should be the correct one who controls the weapon, if passed mode is "this", use the weapon name instead:
<dd class="note">(A3 1.16) [[forceWeaponFire]] is no longer only limited to units, but can remote aircrafts weapon firing as well. Passed source unit should be the correct one who controls the weapon, if passed mode is "this", use the weapon name instead:
<code>
<sqf>
_weapon = ([[weapons]] _veh) [[select]] 3;
_weapon = (weapons _veh) select 3;
_mode = ([[getArray]] ([[configFile]] >> "cfgweapons" >> _weapon >> "modes")) [[select]] 0;
_mode = (getArray (configFile >> "cfgweapons" >> _weapon >> "modes")) select 0;
[[if]] (_mode == "this") [[then]] {_mode = _weapon;};
if (_mode == "this") then {_mode = _weapon;};
([[driver]] _veh) [[forceWeaponFire]] [_weapon, _mode];
(driver _veh) forceWeaponFire [_weapon, _mode];
//Force a CAS fire a rocket.
//Force a CAS fire a rocket.
</code>
</sqf>
Currently this command is not available for land vehicle remote fire.
Currently this command is not available for land vehicle remote fire.
 
<dt><dt>
<dd class="notedate">Posted on September 02, 2014
<dd class="notedate">Posted on 2014-09-02</dd>
<dt class="note">'''[[User:Benargee|Benargee]]'''
<dt class="note">[[User:Benargee|Benargee]]</dt>
<dd class="note">
<dd class="note">
Similar to Killzone Kid's note, This fires the units current weapon in its current firemode.
Similar to Killzone_Kid's note, This fires the units current weapon in its current firemode.
<code>_unit [[forceWeaponFire]] [ [[weaponState]] _unit [[select]] 1, [[weaponState]] _unit [[select]] 2];</code>
<sqf>_unit forceWeaponFire [weaponState _unit select 1, weaponState _unit select 2];</sqf>
<!-- Note Section END -->
<dt><dt>
</dl>
<dd class="notedate">Posted on 2015-01-03 - 14:55 (UTC)</dd>
 
<dt class="note">[[User:Killzone_Kid|Killzone_Kid]]</dt>
<h3 style='display:none'>Bottom Section</h3>
[[Category:Arma_3:_New_Scripting_Commands_List|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
 
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on January 3, 2015 - 14:55 (UTC)</dd>
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
<dd class="note">
<dd class="note">
[[fireAtTarget]] command can be used to gunner weapon fire in vehicles. A gunner must be present. <code>_veh [[fireAtTarget]] <nowiki>[</nowiki>[[objNull]]];</code> Will fire one shot even if player is gunner.
fireAtTarget command can be used to force fire gunner weapon in vehicles. A gunner must be present. <sqf>_veh fireAtTarget [objNull];</sqf> Will fire one shot even if player is gunner.
[[fire]] command can also be used to fire vehicle weapon, like smoke launcher for example:
<sqf>vehicle player fire "SmokeLauncher";</sqf> And if this doesn't work, it is possible to force fire via action <sqf>tank action ["UseWeapon", tank, commander tank, 0];</sqf>
</dd>
</dd>
</dl>
</dl>
<!-- DISCONTINUE Notes -->

Latest revision as of 19:43, 3 September 2024

Hover & click on the images for description

Description

Description:
The unit will be forced to fire weapon from the given muzzle. The weapon will not fire if firemode passed as parameter is not supported by the given muzzle. The muzzle could belong to a vehicle weapon and unit in this case will be the unit operating this weapon. Doesnt't seem to work for units in FFV positions. Works on player. See also: BIS_fnc_fire
Groups:
Unit ControlWeapons

Syntax

Syntax:
unit forceWeaponFire [muzzle, firemode]
Parameters:
unit: Object - unit alone or in vehicle
muzzle: String
firemode: String - common options are "Single", "Burst", "FullAuto". For the full list of a weapon firemodes:
hint str (getArray (configFile >> "CfgWeapons" >> currentWeapon player >> "modes"));
If modes[] param in config for the weapon says {"this"}, then the same classname as for the weapon param (currentWeapon player) should be used as firemode param.
Return Value:
Nothing

Examples

Example 1:
_unit forceWeaponFire ["arifle_MX_F", "Single"]; _unit forceWeaponFire ["hgun_ACPC2_F", "hgun_ACPC2_F"]; _unit forceWeaponFire ["HandGrenadeMuzzle","HandGrenadeMuzzle"]; _unit forceWeaponFire ["MiniGrenadeMuzzle","MiniGrenadeMuzzle"]; _unit forceWeaponFire ["HandGrenade_Stone","HandGrenade_Stone"]; _unit forceWeaponFire ["SmokeShellMuzzle","SmokeShellMuzzle"]; _unit forceWeaponFire ["ChemlightGreenMuzzle","ChemlightGreenMuzzle"]; _unit forceWeaponFire ["IRGrenade","IRGrenade"]; _unit forceWeaponFire ["Laserdesignator","Laserdesignator"];
Example 2:
gunner blackfoot forceWeaponFire ["gatling_20mm", "close"];

Additional Information

See also:
currentWeapon currentWeaponMode setWeaponReloadingTime selectWeapon fire doFire commandFire canFire fireAtTarget commandArtilleryFire commandSuppressiveFire doArtilleryFire doSuppressiveFire isManualFire 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
Posted on 2013-08-25
Killzone_Kid
Here is a neat workaround trick for firemode change from a script:
_weapon = currentWeapon player; _ammo = player ammo _weapon; player setAmmo [_weapon, 0]; player forceWeaponFire [_weapon, "FullAuto"]; player setAmmo [_weapon, _ammo];
Posted on 2014-04-14
ffur2007slx2_5
(A3 1.16) forceWeaponFire is no longer only limited to units, but can remote aircrafts weapon firing as well. Passed source unit should be the correct one who controls the weapon, if passed mode is "this", use the weapon name instead:
_weapon = (weapons _veh) select 3; _mode = (getArray (configFile >> "cfgweapons" >> _weapon >> "modes")) select 0; if (_mode == "this") then {_mode = _weapon;}; (driver _veh) forceWeaponFire [_weapon, _mode]; //Force a CAS fire a rocket.
Currently this command is not available for land vehicle remote fire.
Posted on 2014-09-02
Benargee
Similar to Killzone_Kid's note, This fires the units current weapon in its current firemode.
_unit forceWeaponFire [weaponState _unit select 1, weaponState _unit select 2];
Posted on 2015-01-03 - 14:55 (UTC)
Killzone_Kid
fireAtTarget command can be used to force fire gunner weapon in vehicles. A gunner must be present. Will fire one shot even if player is gunner. fire command can also be used to fire vehicle weapon, like smoke launcher for example:
vehicle player fire "SmokeLauncher";
And if this doesn't work, it is possible to force fire via action
tank action ["UseWeapon", tank, commander tank, 0];