-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #219 from commy2/fixselectweapon
fix CBA_fnc_selectWeapon, add CBA_fnc_isPerson and CBA_fnc_canUseWeapon
- Loading branch information
Showing
4 changed files
with
115 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* ---------------------------------------------------------------------------- | ||
Function: CBA_fnc_canUseWeapon | ||
Description: | ||
Checks if the unit can currently use a weapon. | ||
Parameters: | ||
_unit - A unit <OBJECT> | ||
Returns: | ||
True if the unit is not in a vehicle or in a FFV position <BOOLEAN> | ||
Examples: | ||
(begin example) | ||
_result = player call CBA_fnc_canUseWeapon; | ||
(end) | ||
Author: | ||
commy2 | ||
---------------------------------------------------------------------------- */ | ||
#include "script_component.hpp" | ||
SCRIPT(canUseWeapon); | ||
|
||
params [["_unit", objNull, [objNull]]]; | ||
|
||
if (_unit == vehicle _unit) exitWith {true}; | ||
|
||
private _config = configFile >> "CfgMovesMaleSdr" >> "States" >> animationState _unit; | ||
|
||
isClass _config && {getNumber (_config >> "canPullTrigger") == 1} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* ---------------------------------------------------------------------------- | ||
Function: CBA_fnc_isPerson | ||
Description: | ||
Checks if an object is a person - soldier or civilian. | ||
Parameters: | ||
_unit - A unit or classname <OBJECT, STRING> | ||
Returns: | ||
True if object is a person, otherwise false <BOOLEAN> | ||
Examples: | ||
(begin example) | ||
player call CBA_fnc_isPerson; | ||
-> true | ||
"CAManBase" call CBA_fnc_isPerson; | ||
-> true | ||
(vehicle player) call CBA_fnc_isPerson; | ||
-> false | ||
_projectile call CBA_fnc_isPerson; | ||
-> false | ||
(end) | ||
Author: | ||
commy2 | ||
---------------------------------------------------------------------------- */ | ||
#include "script_component.hpp" | ||
SCRIPT(isPerson); | ||
|
||
params [["_unit", "", [objNull, ""]]]; | ||
|
||
if (_unit isEqualType objNull) then { | ||
_unit = typeOf _unit; | ||
}; | ||
|
||
private _config = configFile >> "CfgVehicles" >> _unit; | ||
|
||
isClass _config && {getNumber (_config >> "isMan") == 1} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters