|
估计除虫得花好久时间,而且效果不会太完美
//init.sqf
has_spare_magazine=
{
_has=false;
{
scopeName "check";
if( (getText(configFile>>"cfgMagazines">>_x select 0>>"ammo")==_this select 0)&&(_x select 1>0) ) then {_has=true;breakout "check";};
}foreach (magazinesAmmo player);
_has;
};
reload_keyDown=
{
_key=_this select 1;if(_key!=[false, false, false, 19])exitWith{false;};
_wpn=weaponstate player select 0;if(_wpn=="")exitWith{false;};
_mag=weaponstate player select 3;if(_mag=="")exitWith{false;};
_ammocount=weaponstate player select 4;if(_ammocount==0)exitWith{false;};
_ammo=getText(configFile>>"cfgMagazines">>_mag>>"ammo");
_muzzle=weaponstate player select 1;
if (!(_mag in getArray(configFile>>"CfgWeapons">>GL_3GL_F>>"magazines"))&&{[_ammo] call has_spare_magazine}&&(vehicle player==player)) then
{
_wpntype=0;
if (_wpn==secondaryWeapon player) then {_wpntype=1;};
if (_wpn==handgunWeapon player) then {_wpntype=2;};
if ((_muzzle!=weapon_loaded select _wpntype)||(_ammo!=ammo_loaded select _wpntype)) then {
weapon_loaded select _wpntype=_muzzle;
ammo_loaded select _wpntype=_ammo;
player setAmmo [_muzzle, _ammocount-1];
hint "Loading a bullet into chamber, remove a bullet from current mag";
}
else{
hint "Already has a bullet in chamber, no need to remove anything";
};
};
false;
};
load_chambered=
{
_wpn=weaponstate player select 0;if(_wpn=="")exitWith{false;};
_mag=weaponstate player select 3;if(_mag=="")exitWith{false;};
_ammocount=weaponstate player select 4;if(_ammocount==0)exitWith{false;};
_ammo=getText(configFile>>"cfgMagazines">>_mag>>"ammo");
_muzzle=weaponstate player select 1;
_wpntype=0;
if (_wpn==secondaryWeapon player) then {_wpntype=1;};
if (_wpn==handgunWeapon player) then {_wpntype=2;};
if ((_muzzle==weapon_loaded select _wpntype)&&(_ammo==ammo_loaded select _wpntype)) then {
weapon_loaded select _wpntype="";
ammo_loaded select _wpntype="";
player setAmmo [_muzzle, _ammocount+1];
hint "Loading a bullet from chamber to current mag";
}
else{
hint "Wrong muzzle, bullet not add";
};
};
weapon_loaded=["","",""];
ammo_loaded=["","",""];
waitUntil {!(isNull (findDisplay 46))};
(findDisplay 46) displayAddEventHandler ["KeyDown", "_this call reload_keyDown;"];
//waitUntil {alive player};
player addEventHandler ["fired", "_this call load_chambered;"]
systemChat "Tactical Reload Ammo Count Mod Initialized";
|
|