Search the Community
Showing results for tags 'random weapon'.
Found 2 results
-
Giving ammo based off random weapons chosen
GamersFortitude posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hi all, Im running a wasteland server with IFA3 and ive got the AI groups that spawn for missions being created with mod weapons, unfortunately they spawned in with no ammo. Looking through the A3 Wiki i found the 'if' statements and based off the SetAmmo command 'example 3' (as below), I made an attempt at giving the AI ammo. I originally posted this on the A3Wasteland forums but no one has been able to help, let alone reply. if (local vehicle player) then { vehicle player setAmmo [currentWeapon vehicle player, 5]; } else { hint "Vehicle must be local to this machine for 'setAmmo' to work"; }; I grabbed the code and tried to modify it so it grabs the current weapon and gives the appropriate ammo class. I originally based it off the uniform, and i had this in the code if (uniform _soldier isequalto _usrifleman) then ( _solder addMagazine "LIB_15Rnd_762x33_t"; _solder addMagazine "LIB_15Rnd_762x33_t"; _solder addMagazine "LIB_15Rnd_762x33_t"; _solder addWeapon "LIB_M1_Carbine"; ); Having the above code in the file resulted in the below error. So i removed it and tried a different method. 0:40:26 File mpmissions\__cur_mp.malden\server\missions\factoryMethods\createUnits\createRandomSoldierC.sqf..., line 33 0:40:26 Error in expression <_solder addMagazine "LIB_15Rnd_762x33_t"; _solder addMagazine "LIB_15Rnd_762x33_> 0:40:26 Error position: <; _solder addMagazine "LIB_15Rnd_762x33_> What you see below is what i attempted , starting at "If currentweapon _soldier =" (fig.2) I only did a few to test to see if it works. But alas it does not. (fig.2) // ****************************************************************************************** // * This project is licensed under the GNU Affero GPL v3. Copyright © 2014 A3Wasteland.com * // ****************************************************************************************** // @file Name: createRandomSoldierC.sqf if (!isServer) exitWith {}; private ["_soldierTypes", "_weaponTypes", "_group", "_position", "_soldier"]; _soldierTypes = ["LIB_US_rifleman", "LIB_US_FC_rifleman", "LIB_US_smgunner", "LIB_SOV_rifleman", "LIB_SOV_LC_rifleman","LIB_SOV_scout_smgunner", "LIB_GER_rifleman", "LIB_GER_ober_rifleman", "LIB_GER_mgunner"]; _weaponTypes = ["LIB_P38","LIB_MP40","LIB_K98","LIB_G43","LIB_TT33","LIB_M9130","LIB_M1895","LIB_PPSh41_m","lib_f1","LIB_M1A1_Thompson","LIB_M1_Carbine","LIB_M1_Garand","LIB_Colt_M1911","LIB_US_Mk_2"]; _group = _this select 0; _position = _this select 1; _soldier = _group createUnit [_soldierTypes call BIS_fnc_selectRandom, _position, [], 0, "NONE"]; [_soldier, _weaponTypes call BIS_fnc_selectRandom, 3] call BIS_fnc_addWeapon; //if (currentWeapon _soldier = LIB_P38) then setAmmo [LIB_8Rnd_9x19 _solder, 10]; if (currentWeapon _soldier = LIB_P38) then { _solder setAmmo [LIB_8Rnd_9x19 _solder, 5]; } else if (currentWeapon _soldier = LIB_MP40) then { _solder setAmmo [LIB_32rnd_9x19 _solder, 5]; { else if (currentWeapon _soldier = LIB_K98) then { _solder setAmmo [LIB_5Rnd_792x57 _solder, 5]; }; /* // Unsure about this & disabled switch (_condition) do { case 1: {if (currentWeapon _soldier = LIB_P38) then setAmmo [LIB_8Rnd_9x19 _solder, 10]}; case 2: {if (currentWeapon _soldier = LIB_MP40) then setAmmo [LIB_32rnd_9x19 _solder, 10]}; } */ _soldier call setMissionSkill; _soldier addEventHandler ["Killed", server_playerDied]; _soldier I decided to look into the switch command but im still learning with that aspect, thats why it's disabled. Is there anything i can do otherwise to get the appropriate ammo given to the AI? On a side note, a3wasteland comes with a "refilPrimaryAmmo" which only seems to work for mods that actually have a cfg file, where as IFA3 does not. Hense my attempt at giving ammo. Thanks to anyone who can help with this matter. -
Hello. How to get a random weapon and of course the ammunition (does not have to be random) removeAllWeapons _this; removeAllAssignedItems _this; removeAllContainers _this; removeGoggles _this; removeHeadgear _this; removeVest _this; removeUniform _this; //Clothing if (side player == east) then { _this addUniform "U_OG_Guerilla1_1"; _this addHeadgear "H_Cap_red"; _this addVest "V_TacVest_camo"; if ((daytime < 6) or (daytime > 19)) then { _this addItem "NVGoggles_OPFOR"; _this assignItem "NVGoggles_OPFOR"; }; }; if (side player == west) then { _this addUniform "U_BG_Guerilla2_3"; _this addHeadgear "H_Cap_blu"; _this addVest "V_TacVest_camo"; if ((daytime < 6) or (daytime > 19)) then { _this addItem "NVGoggles"; _this assignItem "NVGoggles"; }; }; //Items _this addWeapon "ItemMap"; _this addWeapon "ItemCompass"; _this addWeapon "ItemRadio"; _this addWeapon "ItemWatch"; _this addWeapon "ItemGPS"; _this addItem "FirstAidKit"; _this addItem "FirstAidKit";