mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Fix fnc_mortarInit, fnc_loadMagazine, some other stuff
This commit is contained in:
parent
901f55802c
commit
dfe7c07936
@ -5,7 +5,7 @@
|
||||
* Arguments:
|
||||
* 0: static <OBJECT>
|
||||
* 1: unit <OBJECT>
|
||||
* 2: magazineClassOptional <OPTIONAL><STRING>
|
||||
* 2: magazine class to check; if not given having any compatible magazine returns true <STRING> (default: "")
|
||||
*
|
||||
* Return Value:
|
||||
* canLoadMagazine <BOOL>
|
||||
@ -15,40 +15,39 @@
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_static","_unit",["_magazineClassOptional","",[""]]];
|
||||
private ["_canLoadMagazine","_currentMagazine","_weapon","_listOfMagNames",
|
||||
"_hasCompatibleMagazine","_count"];
|
||||
|
||||
if !(alive _static && {GVAR(useAmmoHandling)}) exitWith {false};
|
||||
if !(alive _static && GVAR(useAmmoHandling)) exitWith {false};
|
||||
|
||||
_canLoadMagazine = false;
|
||||
_hasCompatibleMagazine = false;
|
||||
|
||||
_currentMagazine = (magazinesAllTurrets _static) select 1;
|
||||
_weapon = (_static weaponsTurret [0]) select 0;
|
||||
|
||||
_listOfMagNames = getArray(configFile >> "cfgWeapons" >> _weapon >> "magazines");
|
||||
_hasCompatibleMagazine = false;
|
||||
_count = 0;
|
||||
|
||||
//If function is called with an optional string then check if player has that magzine otherwise check all magazines of the player to see if they are compatible with the static weapon
|
||||
if (_magazineClassOptional != "") then {
|
||||
if ([_unit,_magazineClassOptional] call EFUNC(common,hasMagazine)) then {
|
||||
if ([_unit,_magazineClassOptional] call EFUNC(common,hasMagazine)) then {
|
||||
_hasCompatibleMagazine = true;
|
||||
};
|
||||
}else{
|
||||
} else {
|
||||
{
|
||||
if ([_unit,_x] call EFUNC(common,hasMagazine)) exitWith {_hasCompatibleMagazine = true};
|
||||
} forEach _listOfMagNames;
|
||||
};
|
||||
//If static weapon has a magazine then find the ammo count
|
||||
if ((count (_static magazinesTurret [0])) > 0)then{
|
||||
if (count (_static magazinesTurret [0]) > 0) then {
|
||||
_count = _currentMagazine select 2;
|
||||
};
|
||||
//If the static weapon doesn't have a magzine or a magazine with no bullets, the player has a compatible magazine and the static weapon has a barrel then you can load a magazine
|
||||
if ( ( ((count (_static magazinesTurret [0])) == 0) || (_count == 0) ) && _hasCompatibleMagazine) then {
|
||||
if ((count (_static magazinesTurret [0]) == 0 || _count == 0 ) && _hasCompatibleMagazine) then {
|
||||
_canLoadMagazine = true;
|
||||
};
|
||||
_canLoadMagazine
|
||||
|
@ -19,7 +19,7 @@
|
||||
params ["_static","_unit"];
|
||||
private ["_canUnloadMagazine","_ammoCount"];
|
||||
|
||||
if !(alive _static && {GVAR(useAmmoHandling)}) exitWith {false};
|
||||
if !(alive _static && GVAR(useAmmoHandling)) exitWith {false};
|
||||
_canUnloadMagazine = false;
|
||||
|
||||
_ammoCount = ((magazinesAllTurrets _static) select 1) select 2;
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Arguments:
|
||||
* 0: static <OBJECT>
|
||||
* 1: unit <OBJECT>
|
||||
* 2: magazineClassOptional <OPTIONAL><STRING>
|
||||
* 2: magazine class to load; if not given the first compatible magazine is loaded <STRING> (default: "")
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
@ -21,45 +21,45 @@ params ["_static","_unit",["_magazineClassOptional","",[""]]];
|
||||
private ["_weapon","_currentMagazine","_count","_magazines","_magazineDetails","_listOfMagNames",
|
||||
"_magazineClass","_magazineClassDetails","_parsed","_roundsLeft"];
|
||||
|
||||
//Get weapon & magazine information of static weapon
|
||||
_weapon = (_static weaponsTurret [0]) select 0;
|
||||
_currentMagazine = (magazinesAllTurrets _static) select 1;
|
||||
_currentMagazineClass = _currentMagazine select 0;
|
||||
_count = _currentMagazine select 2;
|
||||
|
||||
//Check all of the players magazines to see if they are compatible with the static weapon. First magazine that is compatible is chosen
|
||||
//VKing: This section ought to be double checked.
|
||||
_magazines = magazines _unit;
|
||||
_magazineDetails = magazinesDetail _unit;
|
||||
_listOfMagNames = getArray(configFile >> "cfgWeapons" >> _weapon >> "magazines");
|
||||
_magazineClass = "";
|
||||
_magazineClassDetails = "";
|
||||
_parsed ="";
|
||||
_roundsLeft = 0;
|
||||
{
|
||||
if (_x in _listOfMagNames) exitWith {
|
||||
_magazineClass = _magazines select _forEachIndex;
|
||||
_magazineClassDetails = _magazineDetails select _forEachIndex;
|
||||
};
|
||||
} forEach _magazines;
|
||||
//If the static weapon already has an empty magazine then remove it
|
||||
if (_count == 0) then {
|
||||
[QGVAR(removeMagazine), [_static, _currentMagazineClass]] call EFUNC(common,globalEvent);
|
||||
};
|
||||
//Find out the ammo count of the compatible magazine found
|
||||
if (_magazineClassDetails != "") then{
|
||||
_parsed = _magazineClassDetails splitString "([]/: )";
|
||||
_parsed params ["_type", "", "", "_roundsLeftText", "_maxRoundsText"];
|
||||
_roundsLeft = parseNumber _roundsLeftText;
|
||||
_magType = _type;
|
||||
};
|
||||
|
||||
//If function has been called with an optional classname hten add that magazine to the static weapon. Otherwise add the compatible magazine
|
||||
if(_magazineClassOptional !="") then{
|
||||
_unit removeMagazine _magazineClassOptional;
|
||||
[QGVAR(addMagazine), [_static, _magazineClassOptional]] call EFUNC(common,globalEvent);
|
||||
}else{
|
||||
_unit removeMagazine _magazineClass;
|
||||
[QGVAR(addMagazine), [_static, _magazineClass]] call EFUNC(common,globalEvent);
|
||||
[QGVAR(setAmmo), _static, [_static, _magazineClass,_roundsLeft]] call EFUNC(common,targetEvent);
|
||||
if(_magazineClassOptional != "") then {
|
||||
_unit removeMagazine _magazineClassOptional;
|
||||
[QGVAR(addMagazine), [_static, _magazineClassOptional]] call EFUNC(common,globalEvent);
|
||||
} else {
|
||||
//Get weapon & magazine information of static weapon
|
||||
_weapon = (_static weaponsTurret [0]) select 0;
|
||||
_currentMagazine = (magazinesAllTurrets _static) select 1;
|
||||
_currentMagazineClass = _currentMagazine select 0;
|
||||
_count = _currentMagazine select 2;
|
||||
|
||||
//Check all of the players magazines to see if they are compatible with the static weapon. First magazine that is compatible is chosen
|
||||
//VKing: This section ought to be double checked.
|
||||
_magazines = magazines _unit;
|
||||
_magazineDetails = magazinesDetail _unit;
|
||||
_listOfMagNames = getArray(configFile >> "cfgWeapons" >> _weapon >> "magazines");
|
||||
_magazineClass = "";
|
||||
_magazineClassDetails = "";
|
||||
_parsed ="";
|
||||
_roundsLeft = 0;
|
||||
{
|
||||
if (_x in _listOfMagNames) exitWith {
|
||||
_magazineClass = _x;
|
||||
_magazineClassDetails = _magazineDetails select _forEachIndex;
|
||||
};
|
||||
} forEach _magazines;
|
||||
//If the static weapon already has an empty magazine then remove it
|
||||
if (_count == 0) then {
|
||||
[QGVAR(removeMagazine), [_static, _currentMagazineClass]] call EFUNC(common,globalEvent);
|
||||
};
|
||||
//Find out the ammo count of the compatible magazine found
|
||||
if (_magazineClassDetails != "") then{
|
||||
_parsed = _magazineClassDetails splitString "([]/: )";
|
||||
_parsed params ["_type", "", "", "_roundsLeftText", "_maxRoundsText"];
|
||||
_roundsLeft = parseNumber _roundsLeftText;
|
||||
_magType = _type;
|
||||
};
|
||||
|
||||
_unit removeMagazine _magazineClass;
|
||||
[QGVAR(addMagazine), [_static, _magazineClass]] call EFUNC(common,globalEvent);
|
||||
[QGVAR(setAmmo), _static, [_static, _magazineClass,_roundsLeft]] call EFUNC(common,targetEvent);
|
||||
};
|
||||
|
@ -27,7 +27,8 @@ if (count magazines _mortar > 0) then {
|
||||
|
||||
// Replace current weapon with ammo handling weapon
|
||||
private _currentWeapon = _mortar weaponsTurret [0] select 0;
|
||||
if (getText (configFile >> "CfgWeapons" >> _currentWeapon >> QGVAR(replaceWith)) != "") then {
|
||||
private _newWeapon = getText (configFile >> "CfgWeapons" >> _currentWeapon >> QGVAR(replaceWith));
|
||||
if (_newWeapon != "") then {
|
||||
_mortar removeWeaponGlobal _currentWeapon;
|
||||
_mortar addWeaponGlobal _newWeapon;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user