ante185 2 Posted June 12, 2013 Hello, I am working on a little private mission with WOO rts mod and I44 and i want all units including units created from the buildings to have unlimited ammo. i know how to do for units i place in the editor: this addeventhandler ["fired", {(_this select 0) setvehicleammo 1}] And i think, that if there's like somesort of "All" instead of "this" then my problem might be gone? Share this post Link to post Share on other sites
RommelFuchs 10 Posted June 12, 2013 You can simply create a trigger which covers the whole area of operation. Set activation to anyone. The "All" in script language could be translated as follows: {_x addeventhandler ["fired", {(_this select 0) setvehicleammo 1}]} forEach thisList; . Share this post Link to post Share on other sites
ante185 2 Posted June 12, 2013 You can simply create a trigger which covers the whole area of operation. Set activation to anyone. The "All" in script language could be translated as follows: {_x addeventhandler ["fired", {(_this select 0) setvehicleammo 1}]} forEach thisList; . Thanks alot Wonder if you can do the same but infinte magazines? Share this post Link to post Share on other sites
RommelFuchs 10 Posted June 12, 2013 Thanks alotWonder if you can do the same but infinte magazines? You can, but as far as I know that would require you to delcare in the script which weapon you are talking about. Since you want unlimited ammos for everyone, you would need quite an advanced script I guess. This is a code I found on the forums using the Search function which gives unlimited reloads to the player: _ammo = createTrigger["EmptyDetector",getPos player]; _ammo setTriggerStatements["needReload player == 1", "reload player; player setVehicleAmmo 1", ""]; It might sound strange, but at present I don't have any idea on how setting this to work for everyone. Share this post Link to post Share on other sites
Joe98 93 Posted June 12, 2013 To add 6 magazines to a specific rifle you wouls use: {this addMagazine "20Rnd_762x51_B_SCAR"} forEach [1,2,3,4,5,6]; If you continue beyond 6 to say 50 it is almost the same as having unlimited ammunition. I have done this with aircraft bombs and aircraft machine gun ammunition so they don't run out in the middle of a mission. Share this post Link to post Share on other sites
RommelFuchs 10 Posted June 13, 2013 To add 6 magazines to a specific rifle you wouls use:{this addMagazine "20Rnd_762x51_B_SCAR"} forEach [1,2,3,4,5,6]; If you continue beyond 6 to say 50 it is almost the same as having unlimited ammunition. I have done this with aircraft bombs and aircraft machine gun ammunition so they don't run out in the middle of a mission. Yup, but he wants all the guys in his maps, AI included, to have unlimited or almost unlimited reloads. Your code does the trick if we suppose that they all have the same weapon. Am I wrong? Share this post Link to post Share on other sites
xxanimusxx 2 Posted June 13, 2013 (edited) Okay, I wrote a small function which will automatically add as much magazines as you want to the unit if the count of magazines is under that threshold. _unit = _this select 0; _ammoCount = _this select 1; _primeWpn = ""; _prevWpn = ""; _magazineType = ""; _foundMags = 0; while {alive _unit} do { waitUntil {sleep 0.5; currentWeapon _unit != ""}; _primeWpn = currentWeapon _unit; if (_primeWpn != _prevWpn) then { _prevWpn = _primeWpn; _magazineType = getArray(configFile >> "cfgWeapons" >> _primeWpn >> "magazines") select 0; }; _foundMags = 0; { if (_x == _magazineType) then { _foundMags = _foundMags + 1; }; } forEach (magazines _unit); if (_foundMags < _ammoCount) then { for "_i" from 1 to (_ammoCount - _foundMags) do { _unit addMagazine _magazineType; }; }; sleep 1; }; So all you have to do is put that code into a sqf-file and compile it at mission start (in the top of your init.sqf): // ..... grantUnlimitedAmmo = compile preprocessFileLineNumbers "unlimitedAmmo.sqf"; // ..... If you want the players in your mission to have unlimited ammo, just add this under the code above in your init.sqf: // ..... grantUnlimitedAmmo = compile preprocessFileLineNumbers "unlimitedAmmo.sqf"; // ..... [player, 2] spawn grantUnlimitedAmmo; The two means the script will fill up the magazines until two of them are in your gear. If you want this script to be executed on AIs, just add this into their init-field: [this, 2] spawn grantUnlimitedAmmo; This is a straigth forward script so there could be some problems due to full gear or smth else :D Edited June 27, 2013 by XxAnimusxX changed for compatibility with vehicles Share this post Link to post Share on other sites
avibird 1 155 Posted June 23, 2013 XxAnimusXx do you have a working sample of this that you could link to this site. There is a script that give AT 136 and RPG 18 units unlimited ammo. I would love for all AI AT/AA units to have unlimited ammo during a long mission. The AI squad leaders does give orders for units to get more ammo during a mission at this time. I hope BOHEMIA will ADD to ARMA3 (: ---------- Post added at 17:45 ---------- Previous post was at 17:12 ---------- The script works well however not for AT/AA weapons? Could this be adjust IN YOUR SCRIPT for AT/AA weapons for AI units. ---------- Post added at 18:00 ---------- Previous post was at 17:45 ---------- Hey is the script by Pogoman that I took out of a BTC mission. I cant get it to work for other AT weapons BTC_fired = { //From Pogoman if ((_this select 1) == "M136" || (_this select 1) == "RPG18") then {[] spawn {sleep 0.5;if (player hasweapon "M136") then {player removeWeapon "M136";};if (player hasweapon "RPG18") then {player removeWeapon "RPG18";};};}; }; BTC_M136 = { //From Pogoman if (currentWeapon player == "M136" && !("M136" in magazines player)) then { player removeWeapon "M136"; player addMagazine "M136"; player addWeapon "M136"; player selectWeapon "M136"; }; if (currentWeapon player != "M136" && "M136" in magazines player) then {player removeMagazine "M136";}; if (currentWeapon player == "RPG18" && !("RPG18" in magazines player)) then { player removeWeapon "RPG18"; player addMagazine "RPG18"; player addWeapon "RPG18"; player selectWeapon "RPG18"; }; if (currentWeapon player != "RPG18" && "RPG18" in magazines player) then {player removeMagazine "RPG18";}; }; Share this post Link to post Share on other sites
avibird 1 155 Posted June 27, 2013 @ XxAnimusXx could you add AT/AA rounds to your script? Share this post Link to post Share on other sites
xxanimusxx 2 Posted June 27, 2013 Ah, sry I forgot to answer despite having the solution xD I just changed "primaryWeapon" to "currentWeapon" and now its also working for vehicles of all sorts (I did test it with 5 different vehicle types and it worked everytime). Edited my post above so you can just copy the code or change primaryWeapon to currentWeapon. PS: Don't use the AI's reference in the parameters but the one from the vehicle, in this case the M136/RPG18, because you want that the vehicle should have unlimited ammo, not the AI mounting it. Share this post Link to post Share on other sites
avibird 1 155 Posted June 27, 2013 @ XxanimusxX Thank you! I will in my mission. The vehicle is a bonus but I real care about is the AI AT and AA units that use the ammo on other infantry units and have no more rounds for armor units. BI needs to fix that issue and for the AI leader to order units to get ammo if ammo is in a general area of that unit. I can't understand why this was not corrected at this point the ma series. Share this post Link to post Share on other sites
avibird 1 155 Posted June 30, 2013 @ XxAnimusxX Thank you for your work!! but I would love for the AI to have unlimited Ammo mostly for AT/AA units. The issues is I mostly using scripting for placement of AI during a mission now. I know you said just place [this, 2] spawn grantUnlimitedAmmo; into the AI inti but if my AI have no inti because I spawn them in at the start and/or middle of the mission how can I get your this great script to work with AI that are not placed down via editor. Avibird Share this post Link to post Share on other sites
xxanimusxx 2 Posted June 30, 2013 The command createUnit has a parameter (the third one) which is the init-field (the same as the one in the editor). So if you want to grant some of your AI soldiers unlimited ammo, you'd use it like this: "SoldierType" createUnit [_somePosition, group player, "[this, 2] spawn grantUnlimitedAmmo;"]; This would create a soldier of type "SoldierType" and place it to "_somePosition" with granting unlimited ammo. If you have AntiAir-Vehicles, you'd just pass the reference to the vehicle after creating it. Share this post Link to post Share on other sites
avibird 1 155 Posted June 30, 2013 I am a little lost! Where did I add this code. In your unlimitedammo.sqf or in the ones that spawn in the units during and at the start of the mission. I have mylripe scripts that my missions uses to create units. Share this post Link to post Share on other sites
xxanimusxx 2 Posted June 30, 2013 In your scripts that spawn the units, I suppose you do it using createUnit, am I right? If you use BIS_fnc-functions though, you have to check the function syntax in order to spot the parameter which handles the init-code. You could also post a small part of one of your multiple scripts you meantioned so we can see how you actually spawn those. Share this post Link to post Share on other sites
avibird 1 155 Posted July 1, 2013 (edited) Thanks I have been working on updating a support script for a while //GOOD TO GO FOR MISSION! AVIBIRD.//Marine Firebase Raven 1 USMC Combat Infantry Squad Crow! [] execVM "lkscripts\menu\ci_menu_close.sqf"; USMCinfHQ1 = false; publicvariable "USMCinfHQ1"; hq1d removeaction hq1dac1a; _pos = [(getPosATL Player select 0) + (100 * sin(45)), (getPosATL Player select 1) + (100 * cos(45)), 0]; HQ1USMCinf = CreateGroup WEST; HQ1USMCinf = CreateGroup WEST; infUSMC1 = HQ1USMCinf createUnit ["USMC_Soldier_SL", _pos, [], 0, "FORM"]; infUSMC2 = HQ1USMCinf createUnit ["USMC_Soldier_GL", _pos, [], 0, "FORM"]; infUSMC3 = HQ1USMCinf createUnit ["USMC_Soldier_GL", _pos, [], 0, "FORM"]; infUSMC4 = HQ1USMCinf createUnit ["USMC_Soldier_MG", _pos, [], 0, "FORM"]; infUSMC5 = HQ1USMCinf createUnit ["USMC_Soldier_AR", _pos, [], 0, "FORM"]; infUSMC6 = HQ1USMCinf createUnit ["USMC_Soldier_LAT", _pos, [], 0, "FORM"]; infUSMC7 = HQ1USMCinf createUnit ["USMC_Soldier_LAT", _pos, [], 0, "FORM"]; infUSMC8 = HQ1USMCinf createUnit ["USMC_Soldier_AT", _pos, [], 0, "FORM"]; infUSMC9 = HQ1USMCinf createUnit ["USMC_Soldier_AT", _pos, [], 0, "FORM"]; infUSMC10 = HQ1USMCinf createUnit ["USMC_SoldierS", _pos, [], 0, "FORM"]; infUSMC11 = HQ1USMCinf createUnit ["USMC_SoldierS_Engineer", _pos, [], 0, "FORM"]; infUSMC12 = HQ1USMCinf createUnit ["USMC_Soldier_HAT", _pos, [], 0, "FORM"]; infUSMC13 = HQ1USMCinf createUnit ["USMC_Soldier_AA", _pos, [], 0, "FORM"]; infUSMC14 = HQ1USMCinf createUnit ["USMC_SoldierM_Marksman", _pos, [], 0, "FORM"]; infUSMC15 = HQ1USMCinf createUnit ["USMC_Soldier_Medic", _pos, [], 0, "FORM"]; infUSMC1 = leader HQ1USMCinf; {_x setSkill 1} foreach units HQ1USMCinf; sleep 15; hint "Squad Leader advance to the sector Position that you want Marine Infantry Squad Crow to engage in combat, deployment time ETA 2 minutes from Firebase Raven"; //staging sector wp1 = HQ1USMCinf addwaypoint [position Player, 75]; //wp1 waypointAttachVehicle vehicle player; wp1 setwaypointtype "MOVE"; wp1 setWaypointCombatMode "YELLOW"; wp1 setWaypointFormation "DIAMOND"; wp1 setWaypointSpeed "FULL"; wp1 setWaypointBehaviour "AWARE"; wp1 setWaypointCompletionRadius 50; wp1 setWaypointStatements ["true", "hint 'Marine Infantry Squad Crow Moving out of Firebase Raven towards your Current location';"]; wp1 setWaypointTimeout [120,120,120]; //Alpha waypoint wp2 = HQ1USMCinf addwaypoint [position Player, 50]; wp2 waypointAttachVehicle vehicle player; wp2 setwaypointtype "MOVE"; wp2 setWaypointCombatMode "Yellow"; wp2 setWaypointFormation "STAG COLUMN"; wp2 setWaypointSpeed "FULL"; wp2 setWaypointBehaviour "AWARE"; //wp2 setWaypointCompletionRadius 10; wp2 setWaypointStatements ["true", "hint 'A';"]; wp2 setWaypointTimeout [10,10,10]; //Bravo waypoint wp3 = HQ1USMCinf addwaypoint [position Player, 50]; wp3 waypointAttachVehicle vehicle player; wp3 setwaypointtype "MOVE"; wp3 setWaypointCombatMode "YELLOW"; wp3 setWaypointFormation "WEDGE"; wp3 setWaypointSpeed "FULL"; wp3 setWaypointBehaviour "AWARE"; //wp3 setWaypointCompletionRadius 10; wp3 setWaypointStatements ["true", "hint 'Marine Infantry Squad Crow will Conducted a sweep and Secure maneuver at your Current sector';"]; wp3 setWaypointTimeout [15,15,15]; //Charlie waypoint wp4 = HQ1USMCinf addwaypoint [position Player, 50]; wp4 waypointAttachVehicle vehicle player; wp4 setwaypointtype "SAD"; wp4 setWaypointCombatMode "YELLOW"; wp4 setWaypointFormation "WEDGE"; wp4 setWaypointSpeed "FULL"; wp4 setWaypointBehaviour "AWARE"; //wp4 setWaypointCompletionRadius 10; wp4 setWaypointStatements ["true", "hint 'Marine Infantry Squad Crow Will regroup at your Current sector';"]; wp4 setWaypointTimeout [10,10,10]; //New staging waypoint wp5 = HQ1USMCinf addwaypoint [position Player, 50]; wp5 waypointAttachVehicle vehicle player; wp5 setwaypointtype "MOVE"; wp5 setWaypointCombatMode "YELLOW"; wp5 setWaypointFormation "DIAMOND"; wp5 setWaypointSpeed "FULL"; wp5 setWaypointBehaviour "AWARE"; //wp5 setWaypointCompletionRadius 10; wp5 setWaypointStatements ["true", "hint 'Marine Infantry Crow moving Back towards your Current position';"]; wp5 setWaypointTimeout [60,60,60]; //cycle waypoint wp6 = HQ1USMCinf addwaypoint [position Player, 50]; wp6 setwaypointtype "Cycle"; HQ1USMCinfT = createTrigger ["EmptyDetector", getPos player]; HQ1USMCinfT setTriggerArea [0, 0, 0, false]; HQ1USMCinfT setTriggerActivation ["NONE", "NOT PRESENT", false]; HQ1USMCinfT setTriggerStatements ["!(alive infUSMC1) && !(alive infUSMC2) && !(alive infUSMC3) && !(alive infUSMC4) && !(alive infUSMC5) && !(alive infUSMC6) && !(alive infUSMC7) && !(alive infUSMC8) && !(alive infUSMC9) && !(alive infUSMC10) && !(alive infUSMC11) && !(alive infUSMC12) && !(alive infUSMC13) && !(alive infUSMC14) && !(alive infUSMC15)","player sideChat ""Sir Firebase Raven Reports: Marine Infantry Squad Crow was Killed in action""; HQ1USMCinf execVM ""lkscripts\fob-bu\doneHQ1infUSMC.sqf""" , ""]; This is one of many scripts that a player can call in from the FOB's from the script. If you can get this to work that would be great. It sucks balls when your three squads of AI move 6000 meters and no one has one round to put into a BMP that rolls up on you lol. Management of the AI needs to be improved for ARMA3. It would be nice if AMMO was in a set distance from a AI unit and that AI was not under fire they would get the Ammo and return back to formation. Edited July 1, 2013 by AVIBIRD 1 Share this post Link to post Share on other sites
xxanimusxx 2 Posted July 1, 2013 Okay, first of all, you should consider putting your arma-script code into PHP-tags, these will automatically add a scrollbar if you have much code to display :D //GOOD TO GO FOR MISSION! AVIBIRD. //Marine Firebase Raven 1 USMC Combat Infantry Squad Crow! [] execVM "lkscripts\menu\ci_menu_close.sqf"; USMCinfHQ1 = false; publicvariable "USMCinfHQ1"; hq1d removeaction hq1dac1a; _pos = [(getPosATL Player select 0) + (100 * sin(45)), (getPosATL Player select 1) + (100 * cos(45)), 0]; HQ1USMCinf = CreateGroup WEST; HQ1USMCinf = CreateGroup WEST; infUSMC1 = HQ1USMCinf createUnit ["USMC_Soldier_SL", _pos, [], 0, "FORM"]; infUSMC2 = HQ1USMCinf createUnit ["USMC_Soldier_GL", _pos, [], 0, "FORM"]; infUSMC3 = HQ1USMCinf createUnit ["USMC_Soldier_GL", _pos, [], 0, "FORM"]; infUSMC4 = HQ1USMCinf createUnit ["USMC_Soldier_MG", _pos, [], 0, "FORM"]; infUSMC5 = HQ1USMCinf createUnit ["USMC_Soldier_AR", _pos, [], 0, "FORM"]; infUSMC6 = HQ1USMCinf createUnit ["USMC_Soldier_LAT", _pos, [], 0, "FORM"]; infUSMC7 = HQ1USMCinf createUnit ["USMC_Soldier_LAT", _pos, [], 0, "FORM"]; infUSMC8 = HQ1USMCinf createUnit ["USMC_Soldier_AT", _pos, [], 0, "FORM"]; infUSMC9 = HQ1USMCinf createUnit ["USMC_Soldier_AT", _pos, [], 0, "FORM"]; infUSMC10 = HQ1USMCinf createUnit ["USMC_SoldierS", _pos, [], 0, "FORM"]; infUSMC11 = HQ1USMCinf createUnit ["USMC_SoldierS_Engineer", _pos, [], 0, "FORM"]; infUSMC12 = HQ1USMCinf createUnit ["USMC_Soldier_HAT", _pos, [], 0, "FORM"]; infUSMC13 = HQ1USMCinf createUnit ["USMC_Soldier_AA", _pos, [], 0, "FORM"]; infUSMC14 = HQ1USMCinf createUnit ["USMC_SoldierM_Marksman", _pos, [], 0, "FORM"]; infUSMC15 = HQ1USMCinf createUnit ["USMC_Soldier_Medic", _pos, [], 0, "FORM"]; infUSMC1 = leader HQ1USMCinf; { _x setSkill 1; [_x, 2] spawn grantUnlimitedAmmo; } foreach units HQ1USMCinf; sleep 15; hint "Squad Leader advance to the sector Position that you want Marine Infantry Squad Crow to engage in combat, deployment time ETA 2 minutes from Firebase Raven"; //staging sector wp1 = HQ1USMCinf addwaypoint [position Player, 75]; //wp1 waypointAttachVehicle vehicle player; wp1 setwaypointtype "MOVE"; wp1 setWaypointCombatMode "YELLOW"; wp1 setWaypointFormation "DIAMOND"; wp1 setWaypointSpeed "FULL"; wp1 setWaypointBehaviour "AWARE"; wp1 setWaypointCompletionRadius 50; wp1 setWaypointStatements ["true", "hint 'Marine Infantry Squad Crow Moving out of Firebase Raven towards your Current location';"]; wp1 setWaypointTimeout [120,120,120]; //Alpha waypoint wp2 = HQ1USMCinf addwaypoint [position Player, 50]; wp2 waypointAttachVehicle vehicle player; wp2 setwaypointtype "MOVE"; wp2 setWaypointCombatMode "Yellow"; wp2 setWaypointFormation "STAG COLUMN"; wp2 setWaypointSpeed "FULL"; wp2 setWaypointBehaviour "AWARE"; //wp2 setWaypointCompletionRadius 10; wp2 setWaypointStatements ["true", "hint 'A';"]; wp2 setWaypointTimeout [10,10,10]; //Bravo waypoint wp3 = HQ1USMCinf addwaypoint [position Player, 50]; wp3 waypointAttachVehicle vehicle player; wp3 setwaypointtype "MOVE"; wp3 setWaypointCombatMode "YELLOW"; wp3 setWaypointFormation "WEDGE"; wp3 setWaypointSpeed "FULL"; wp3 setWaypointBehaviour "AWARE"; //wp3 setWaypointCompletionRadius 10; wp3 setWaypointStatements ["true", "hint 'Marine Infantry Squad Crow will Conducted a sweep and Secure maneuver at your Current sector';"]; wp3 setWaypointTimeout [15,15,15]; //Charlie waypoint wp4 = HQ1USMCinf addwaypoint [position Player, 50]; wp4 waypointAttachVehicle vehicle player; wp4 setwaypointtype "SAD"; wp4 setWaypointCombatMode "YELLOW"; wp4 setWaypointFormation "WEDGE"; wp4 setWaypointSpeed "FULL"; wp4 setWaypointBehaviour "AWARE"; //wp4 setWaypointCompletionRadius 10; wp4 setWaypointStatements ["true", "hint 'Marine Infantry Squad Crow Will regroup at your Current sector';"]; wp4 setWaypointTimeout [10,10,10]; //New staging waypoint wp5 = HQ1USMCinf addwaypoint [position Player, 50]; wp5 waypointAttachVehicle vehicle player; wp5 setwaypointtype "MOVE"; wp5 setWaypointCombatMode "YELLOW"; wp5 setWaypointFormation "DIAMOND"; wp5 setWaypointSpeed "FULL"; wp5 setWaypointBehaviour "AWARE"; //wp5 setWaypointCompletionRadius 10; wp5 setWaypointStatements ["true", "hint 'Marine Infantry Crow moving Back towards your Current position';"]; wp5 setWaypointTimeout [60,60,60]; //cycle waypoint wp6 = HQ1USMCinf addwaypoint [position Player, 50]; wp6 setwaypointtype "Cycle"; HQ1USMCinfT = createTrigger ["EmptyDetector", getPos player]; HQ1USMCinfT setTriggerArea [0, 0, 0, false]; HQ1USMCinfT setTriggerActivation ["NONE", "NOT PRESENT", false]; HQ1USMCinfT setTriggerStatements ["!(alive infUSMC1) && !(alive infUSMC2) && !(alive infUSMC3) && !(alive infUSMC4) && !(alive infUSMC5) && !(alive infUSMC6) && !(alive infUSMC7) && !(alive infUSMC8) && !(alive infUSMC9) && !(alive infUSMC10) && !(alive infUSMC11) && !(alive infUSMC12) && !(alive infUSMC13) && !(alive infUSMC14) && !(alive infUSMC15)","player sideChat ""Sir Firebase Raven Reports: Marine Infantry Squad Crow was Killed in action""; HQ1USMCinf execVM ""lkscripts\fob-bu\doneHQ1infUSMC.sqf""" , ""]; Okay, just inserted the line into your foreach setting the skill of your AIs and that's it :D Don't forget to compile the unlimitedAmmo-script in your init.sqf like shown in my post above. Share this post Link to post Share on other sites
avibird 1 155 Posted July 2, 2013 @XxAnimusxX First thing you are a genius! that works great for the AI units that I call in during the mission. The only problem is I need to cut down on the amount of AI AT/AA units in a squad now(: Don't want to much of an advantage during the mission. The code you said to put into the AI units that are place down via editor does not work. I get a type script, expected nothing error. [this, 2] spawn grantUnlimitedAmmo; Giving the human player extra AMMO is a nice little bonus but I don't think I will use it. To much of an advantage for the human players. I hope Bohemia will really look into improving the AI ability to rearm during a mission. Micromanagement of a lot of AI during a mission can get out of hand fast. It should be simple. If an AI is in a set distance of the ammo it has use for and not in current combat/red mode then they should retrieve the ammo and then return back into squad formation. I really think you should write a little demo mission with your script for other players and post it on Armaholic. It is a simple short script but something that was lacking with the AI with ARMA. Share this post Link to post Share on other sites
xxanimusxx 2 Posted July 2, 2013 Concerning the error the editor gives you: It's because the editor expects you to use the returning value of the spawned function. Use this syntax to prevent any errors: nil = [this, 2] spawn grantUnlimitedAmmo; Share this post Link to post Share on other sites