Jump to content
Guest

Rearm SmokeLauncher and Flares.

Recommended Posts

Guest

Hello everyone, I've been messing around with different functions to create a ground service script.

But unfortunately I'm now stuck on the "Rearming" part.

In fact I can't figure out how to rearm / get the ammo left in the SmokeLauncher / Flare part without using https://community.bistudio.com/wiki/setVehicleAmmo.

If someone can tell me how this works with the Ifrit for example I tried :

(vehicle player) addMagazine ["SmokeLauncherMag",[-1]];

(vehicle player) addMagazine ["SmokeLauncherMag",[0]];

I tried functions like https://community.bistudio.com/wiki/addMagazineTurret and https://community.bistudio.com/wiki/addMagazine_array

 

Here is what I got for now

13CC8AB483FE4FC145BADCC562903FAD9ABBC529

 

I didn't get into GUI stuff for now, I use the stringtable for the most part of the text displayed.

 

Many thanks to those who took their precious time to read this lines.

And I apologize for my bad English, or should I say my Baguette English.

Share this post


Link to post
Share on other sites
vehicle player magazinesTurret [-1]; 

vehicle player addMagazineTurret ["SmokeLauncherMag",[-1]];

Problem is, that the smoke launcher doesn't really reload.

Share this post


Link to post
Share on other sites

f_reloadAT.sqf

 

 

_unit = _this select 0;_mag = _this select 5;
if (player == _unit) then{ player addMagazines [_mag, 
1];};

I'm not Shure if this is usable but I'm looking (found this in an older mission) .

Share this post


Link to post
Share on other sites

This reloaded all created by [KH]Jman

 

 

/* 
 * Filename:
 * vehicle_service.sqf 
 *
 * Description:
 * Repair/Rearm/Refuel script
 * 
 * Created by [KH]Jman
 * Creation date: 05/09/2013
 * Email: jman@kellys-heroes.eu
 * Web: http://www.kellys-heroes.eu
 * 
 * */

// ====================================================================================

private ["_config","_count","_i","_magazines","_object","_type","_type_name"];

_object = _this select 0;
_type = typeof _object;
if (_object isKindOf "ParachuteBase") exitWith {};
if (isNil "reloadTime") then {reloadTime = 1;};
if (!alive _object) exitWith {};
_object setFuel 0;
_object setVehicleAmmo 1;
_type_name = typeOf _object;
_object vehicleChat format ["Servicing %1... Please stand by...", _type];
_magazines = getArray(configFile >> "CfgVehicles" >> _type >> "magazines");

if (count _magazines > 0) then {
	_removed = [];
	{
		if (!(_x in _removed)) then {
			_object removeMagazines _x;
			_removed set [count _removed, _x];
		};
	} forEach _magazines;
	{
		_object vehicleChat format ["Reloading %1", _x];
		sleep reloadTime;
		if (!alive _object) exitWith {};
		_object addMagazine _x;
	} forEach _magazines;
};

_count = count (configFile >> "CfgVehicles" >> _type >> "Turrets");

if (_count > 0) then {
	for "_i" from 0 to (_count - 1) do {
		scopeName "reloadIt";
		_config = (configFile >> "CfgVehicles" >> _type >> "Turrets") select _i;
		_magazines = getArray(_config >> "magazines");
		_removed = [];
		{
			if (!(_x in _removed)) then {
				_object removeMagazines _x;
				_removed set [count _removed, _x];
			};
		} forEach _magazines;
		{
			_object vehicleChat format ["Reloading %1", _x];
			sleep reloadTime;
			if (!alive _object) then {breakOut "reloadIt"};
			_object addMagazine _x;
			sleep reloadTime;
			if (!alive _object) then {breakOut "reloadIt"};
		} forEach _magazines;
		_count_other = count (_config >> "Turrets");
		if (_count_other > 0) then {
			for "_i" from 0 to (_count_other - 1) do {
				_config2 = (_config >> "Turrets") select _i;
				_magazines = getArray(_config2 >> "magazines");
				_removed = [];
				{
					if (!(_x in _removed)) then {
						_object removeMagazines _x;
						_removed set [count _removed, _x];
					};
				} forEach _magazines;
				{
					_object vehicleChat format ["Reloading %1", _x]; 
					sleep reloadTime;
					if (!alive _object) then {breakOut "reloadIt"};
					_object addMagazine _x;
					sleep reloadTime;
					if (!alive _object) then {breakOut "reloadIt"};
				} forEach _magazines;
			};
		};
	};
};

_object setVehicleAmmo 1;
sleep reloadTime;
if (!alive _object) exitWith {};
_object vehicleChat "Repairing vehicle...";
_object setDamage 0;
sleep reloadTime;
if (!alive _object) exitWith {};
_object vehicleChat "Refueling vehicle...";
while {fuel _object < 0.99} do {
	_object setFuel 1;
	sleep 0.01;
};
sleep reloadTime;
if (!alive _object) exitWith {};
_object vehicleChat format ["%1 is ready...", _type_name];
if (true) exitWith {};

Share this post


Link to post
Share on other sites
Guest

@R3vo What do you mean by that ?

 

@davidoss

Yeah, but it's the 

_object setVehicleAmmo 1;

witch is actually rearming the smoke launcher

Share this post


Link to post
Share on other sites
vehicle player magazinesTurret [-1]; //That's gonna return the amount of ammunition left 

vehicle player addMagazineTurret ["SmokeLauncherMag",[-1]]; //This will add a new magazine

How I said above, you can add new magazines to the smoke launcher but it doesn't load the new magazines in for some reason

Share this post


Link to post
Share on other sites

there's a weapon config line for autoreloading - might be that autoreload is 0 for smoke launchers?

Share this post


Link to post
Share on other sites

Yes that could be, I believe smoke launchers were never meant to have multiple magazines but only 2 rounds.

Share this post


Link to post
Share on other sites
Guest

Quick update.
 
 

vehicle player magazinesTurret [-1]; //That's gonna return the amount of ammunition left 

vehicle player addMagazineTurret ["SmokeLauncherMag",[-1]]; //This will add a new magazine
How I said above, you can add new magazines to the smoke launcher but it doesn't load the new magazines in for some reason

 

 

vehicle player magazinesTurret [-1]; 

 

That does not return any ammo.

 

I tried 

(vehicle player) ammo "SmokeLauncherMag"

It's returning 0 instead of 2.

 

Well I don't think this is possible atm. Maybe a thing to add to the Feedback.

Share this post


Link to post
Share on other sites

Maybe I should have been more precise:

count (vehicle player magazinesTurret [-1]); //This will return the amount of magazines

Share this post


Link to post
Share on other sites

If you use addMagazinesTurret on smoke launchers they do reload but take along time after much whirring and clanking. After this magazinesTurretAmmo never seems to display properly again for smoke launchers and always returns 0 no matter how much ammo is actually in the magazine.

You can use setMagazineTurretAmmo to add ammo straight into the loaded magazine and if you do this before addMagazinesTurret then the count dosent mess up.

From some quick tests this seems to fill all vehicle turret weapons both magazines and ammo..

h = [] spawn {

	_veh = vehicle player;

	{
		_turretPath = _x;
		_turretMags = [];
		
		//Find default magazine loadout for each turret
		if ( _turretPath isEqualTo [ -1 ] ) then {
			_turretMags = getArray( configFile >> "CfgVehicles" >> typeOf _veh >> "magazines" );
		}else{
			_baseCfg = ( configFile >> "CfgVehicles" >> typeOf _veh );
			{
				_baseCfg = ( _baseCfg >> "turrets" ) select _x;
			}forEach _turretPath;
			_turretMags = getArray( _baseCfg >> "magazines" );
		};
		
		//Make unique list
		_magTypes = _turretMags arrayIntersect _turretMags;
		
		{
			_mag = _x;
			//Get default ammo count for mag
			_ammoCount = getNumber( configFile >> "CfgMagazines" >> _mag >> "count" );
			
			//Set current mag to default amount
			_veh setMagazineTurretAmmo [ _mag, _ammoCount, _turretPath ];
			
			//Then replace any missing magazines
			_count = { _mag == _x }count _turretMags;
			_current = { _mag == _x }count ( _veh magazinesTurret _turretPath );
			for "_i" from 1 to ( _count - _current ) do {
				_veh addMagazineTurret [ _mag, _turretPath ];
			};
		}forEach _magTypes;

	}forEach ( allTurrets _veh + [ [ -1 ] ] );
};

Share this post


Link to post
Share on other sites


vehname addeventhandler ["fired", {(_this select 0) setvehicleammo 1}];

Share this post


Link to post
Share on other sites

_mags = magazinesAllTurrets vehicle player;

 

this command was recently added to the game, so I throw it in here, in case you have a use for it.

Share this post


Link to post
Share on other sites

_veh = vehicle player;

_turret = [-1];

 

_veh removeWeaponTurret ["CMFlareLauncher", _turret];
_veh addMagazineTurret ["120Rnd_CMFlare_Chaff_Magazine", _turret];
_veh addWeaponTurret ["CMFlareLauncher", _turret];

Share this post


Link to post
Share on other sites

vehicle player setVehicleAmmo 0; - removes all ammo from all weapons on vehicle (inc. flares too)
vehicle player setVehicleAmmo 1; - fill up all vehicle weapons with ammo (inc. flares too)

 

but if u can't use this because you want fill up only the flares then follow this 4 step:


vehicle player removeMagazinesTurret ["SmokeLauncherMag",[0,0]]; - remove ALL smokelauncher magazines (important: removemagazinesturret and not removemagazineturret) from tank commander path [0,0]
vehicle player removeWeaponTurret ["SmokeLauncher",[0,0]]; - remove smokelauncher
vehicle player addMagazineTurret ["SmokeLauncherMag",[0,0]]; - add 1 smokelauncher magazine (important: add magazine before you add the weapon and then not need rearm when you get the weapon back)
vehicle player addWeaponTurret ["SmokeLauncher",[0,0]]; - add smokelauncher back to commander path

 

[-1] - driver ifrit/strider (hunter not have flares but you can add)
[0,0] - tank commander

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×