kenoxite 156 Posted April 3, 2013 (edited) This is something I wanted to post several weeks (months?) ago, but never got to do. It's a series of scripts, single and packs, that some of you might find useful.Beware that some of them aren't properly tested or simply unfinished (meaning that they basically work, but might contain bugs as aren't properly tested or developed). I'll tag those as I list them (and as I remember).--MAP AI RUCKSACK - WW4v1.0REQUIRES: MapFact's rucksacks - WW4Gives rucksacks to WW4 units and allows them to use the ammo stored there when needed.Every time the unit runs out of ammo it'll check its rucksack.If compatible mags are found it'll proceed to use the rucksack the same way a player does (crouching, etc).If no magazines are found and the unit has a LMG it'll ask to his mates for ammo. If any other unit in his group has compatible ammo that will be auto-magically* transferred to the unit requesting it.Tents, etc aren't supported by this script. Only rifle, pistol, etc mags and grenades (hand, smoke, launcher).*This is done to prevent breaking missions, scripts, player orders, or simply to avoid AI units pingponging between locations.DOWNLOAD: http://www.mediafire.com/download.php?jwdzaj12bpspvbt--HEAL GROUPv1.0This script pack will automate the healing process of a whole group, as long as there's a medic in their group.It is initiated by selecting the corresponding option in the player's action menu.When using the MapFact's rucksacks - WW4 addon, units lightly damaged will try to heal by using their own bandages before calling for a medic.DOWNLOAD: http://www.mediafire.com/download.php?93ks69dru11n1s9--kVEHICLESv0.1Unfinished/UntestedSeveral fixes and features related to vehicles in OFP.FEATURES- Replaces empty vehicles with clones, to force AI units in the player's group stop firing at it- Crew bails out if vehicle can't move, can't fire or has no ammo- Cargo of land vehicles dismount if vehicle is hit or in danger- It might work in MP (I'm not sure if I included it in this version)IMPORTANT: In kVeh\start.sqs you'll probably want to change this: kVeh set [ 0, "wgl_units"] to this kVeh set [ 0, "list allUnits"]Or whatever array you use to keep track of all units. This is needed in order to vehicles to know when they're in dangerDOWNLOAD: http://www.mediafire.com/download.php?98ck2f6aewysu2b--WGL AI RUCKSACKv1.0Allows AI units to use items stored in their WGL rucksack.Every time the unit runs out of ammo it'll check its rucksack.If compatible mags are found it'll proceed to use the rucksack the same way a player does (crouching, etc).If no magazines are found and the unit has a LMG, MG or some type of rocket launcher it'll ask to his mates for ammo. If any other unit in his group has compatible ammo that will be auto-magically* transferred to the unit requesting it.Bandages and other items aren't handled by this system. Hand grenades (explosive and smoke) are, though.*This is done to prevent breaking missions, scripts, player orders, or simply to avoid AI units pingponging between locations.DOWNLOAD: http://www.mediafire.com/download.php?bi15575ln8w3y3a--REASSIGN WEAPONS WW4v4.2This had its own thread somewhere, but I'm adding it here for convenience.Equips individual units or whole groups with predefined sets of weapons. The weapon sets are based on the ones being used by the different types of WW4 units.It can also equip high dispersion (HD) ammo, suppressors, night vision goggles, antimaterial rifles (for the snipers) and grenade vests or flare pouches (for the grenadiers).CHANGELOG: v4.2 - Readd ww4 radio to unit if assigned before running this script - Readd binocular or nv goggles to unit if assigned before running this script, regardless script parameters or unit class - You can now specify the classes of the units passed (so they can be equipped with gear from other classes than their own) DOWNLOAD: http://www.mediafire.com/download.php?af5f2gjl4ycc62h--kFLARESv1.0The passed unit will be equipped with a grenade launcher and flares and will shoot them during nighttime if it detects enemies closeDOWNLOAD: http://www.mediafire.com/download.php?3ttaelx2na4dopy--kINFOSHAREv1.2 Allows group leaders to automatically share information about enemy units with each other.The distance at which they can transmit this information will depend on their side and wether or not they have an RTO or a vehicle with a radio in their group (in this case they can transmit to all friendlies on the map, without distance restrictions). Singleplayer and multiplayer.DOWNLOAD: https://www.mediafire.com/download/isz92piv9bawpe8/kInfoshare_v12.zip--REFILL CRATE WW4v1.0Refills crates or vehicles with ammunition (and weapons) associated to a given sideThe type and amount of ammo and weapons to be used as cargo is predefined in the codeYou can fill a cargo with ammo and weapons from several sides at once.You can also fill it as many times as you want from a single call, or fill it only with high dispersion (HD) variants of the ammoDOWNLOAD: http://www.mediafire.com/download.php?qdbejdjsj2868k0--BAS STAND AND CROUCHv1.0Modification of the BASriverStandup.sqs scriptOriginal script by RomThese are two separate scripts, one for stand up and the other for crouch.Periodically forces all the units inside a trigger area to crouch, and reverts them to auto when they are outside.Those units that can't stand up (hurt legs), are inside a vehicle, don't have any ammo left or are players are automatically excludedDOWNLOAD: http://www.mediafire.com/download.php?g7lkx5sv39a71go--WALKERS MANAGERv1.0Standalone version of the CivPopulate scriptAdds a unit to the walker managerThe walker manager then will take care of moving them around at random intervals to random positions[i just noticed I didn't include a proper readme for this, so I'll post the instructions below]INSTRUCTIONSPut this line somewhere (like in init.sqs): [] exec "walkersManager.sqs"Add this line to any units you want to walk randomly (values are just examples): [this,getPos this,30,"full","careless"] exec "addWalker.sqs"It has this format: [<unit>,<current position>, <wander range>,<speed>,<default behaviour>] exec "addWalker.sqs"DOWNLOAD: http://www.mediafire.com/download.php?0623ap6rnp5q114--HD AMMO WW4v1.0Changes every magazine of any array of units to its HD (high dispersion) equivalent, if it existsDOWNLOAD: http://www.mediafire.com/download.php?vcyfkgrokcusldm--That's all, folks. Edited September 7, 2015 by kenoxite updated reassignweapons to 4.2 1 1 Share this post Link to post Share on other sites
kenoxite 156 Posted May 4, 2013 Added two new script packs: * MAP AI RUCKSACK - WW4 * HEAL GROUP Share this post Link to post Share on other sites
Icarus 12 Posted May 4, 2013 Great Script pack, kenoxite! Is kINFOSHARE script based on the one used in ECP mod? Share this post Link to post Share on other sites
NacroxNicke 11 Posted May 4, 2013 kInfoshare and WGL AI Ruckpack are very useful, thanks!. Share this post Link to post Share on other sites
Tyrsero 10 Posted May 4, 2013 These will surely be useful, good job on the pack! Share this post Link to post Share on other sites
ProfTournesol 956 Posted May 4, 2013 That's very nice, i must say i didn't notice it at first :) Could you pack them in a all_in_one file ? Share this post Link to post Share on other sites
kenoxite 156 Posted May 4, 2013 (edited) Thanks, guys. It's always nice to see that the stuff you make is useful to someone. Is kINFOSHARE script based on the one used in ECP mod? The name is actually based on InfoShare, by General Barron. I'm not familiar with the inner parts of ECP apart from the DSAI addons and the external config files, mainly for the single array solution to savegame crashes (which is the only stuff I've needed to tinker with to use for my scripts and updates). Does ECP also use General Barron's version? The reason I decided to create my own version was because I wasn't able to find a download for that InfoShare script, and I needed a similar solution for other projects. Once I finally found it (inside SLX, I think) my version was already started, so I just checked it to see how he did it. The main difference, the one you'll notice first, is that it only uses a single script for all the stuff it does. It also adds other features like allowing different communication ranges for each side (which you can edit), more range for those with an RTO, and virtually infinite range when a group has a vehicle that would be equipped with a radio in real life. At the end of the script there's an extensive comment section where I expand on the reasons behind all this, and provide more in-depth instructions for advanced users. That's very nice, i must say i didn't notice it at first :)Could you pack them in a all_in_one file ? Heh, I think I screwed it up at the title. I should have tagged it with [script Pack] Assorted scripts... so the purpose of this thread is clearer. But, well, I'm a mess. And, sure, I'll look into it later. Edited May 4, 2013 by kenoxite added reply to the Professor Share this post Link to post Share on other sites
Tyrsero 10 Posted May 4, 2013 Hrm, sorry for a double-post, but unfortunately I have forgot where do I put the script files, could somebody please tell me where do I put them? Thanks in advance. Share this post Link to post Share on other sites
kenoxite 156 Posted May 4, 2013 Inside your mission's folder. You'll find it at: <path to your OFP/CWA>\Users\<your user name>\missions\<name of the mission>.<name of the map> So, if your in game nick is Tyrsero and your mission is "TestMission.intro" the path would be: <path to your OFP/CWA>\Users\Tyrsero\missions\TestMission.intro Share this post Link to post Share on other sites
Tyrsero 10 Posted May 4, 2013 Inside your mission's folder.You'll find it at: <path to your OFP/CWA>\Users\<your user name>\missions\<name of the mission>.<name of the map> So, if your in game nick is Tyrsero and your mission is "TestMission.intro" the path would be: <path to your OFP/CWA>\Users\Tyrsero\missions\TestMission.intro Alright, I get it now. Thanks for the explanation and quick response! Share this post Link to post Share on other sites
kenoxite 156 Posted May 4, 2013 No problem. Also remember that if you don't have an "init.sqs" file already there and you need one then you'll have to create it yourself. BTW, I've updated REASSIGN WEAPONS WW4 to 4.2. Added a changelog to its entry in the first post. Share this post Link to post Share on other sites
cpt_smagnet 10 Posted June 18, 2013 Sorry to disturb you kenoxite, but I have problems accessing mediafire down here (somehow blocked in mainland China, donno why), and I really love that AI rucksack script and kInfoshare... Can you plz kindly offer me another download link, or something else? Thx~ Share this post Link to post Share on other sites
kenoxite 156 Posted June 18, 2013 Too bad Mediafire is blocked there. Here's a mirror using multiupload.nl. Tell me if you can download from there: - kInfoshare: http://www.multiupload.nl/YVM3LULGCK - WGL_AIrucksack: http://www.multiupload.nl/O2YYE9S5ND Alternatively, you can also download them from my OFP site. It was basically created to have mirrors for some of my files. Share this post Link to post Share on other sites
cpt_smagnet 10 Posted June 22, 2013 Thanks kenoxite! really much! Still got trouble getting to the mirrors (WTF), but since I am working on my own infoshare script, it won't be so desperate now... Thanks again! BTW, can I ask how the AI rucksack script works? because my mag dropping method is different, I basically need to rewrite the script myself, but have no idea how. Thanks in advance! Share this post Link to post Share on other sites
kenoxite 156 Posted June 22, 2013 You can see it by yourself. Feel free to edit, adapt, distribute, etc my stuff, all .As you can't access my google sites page, here's what the section about permissions says: All my released work falls under the Attribution-NonCommercial 3.0 Unported license.Basically, as long as you don't try to earn money with my stuff and you put me somewhere in the credits all will be fine. You don't need to contact me, but it'd be appreciated.Some of my work might include content by other authors. My permission doesn't extend to their work, so you should contact them if that's the case. That stance includes anything released by me in this community.Now, for the good stuff:kInfoshare v1.0kInfoshare.sqs ; ----------------- ; kINFOSHARE v1.0 ; by kenoxite ; ; Allows group leaders to automatically share information about enemy units with each other. ; The distance at which they can transmit this information will depend on their side ; and wether or not they have an RTO or a vehicle with a radio in their group. ; ; USE: ; 1) Place a trigger as big as the area of your mission, set it to be activated by Anybody and name it allUnits ; 2) Init the script wherever you like (like in init.sqs): [] exec "kInfoshare.sqs" ; ; For MP you'll need to place a game logic and name it: server ; If you use CoC NS2 or CoC UA that's not needed. ; ; Advanced instructions at the end of this script. ; ----------------- ; Don't remove this wait ~1 ; Execute this only on the server ?(!local server or !local CoC_Server): exit _null = format["%1",_nullstring] ; Deactivate if ECP infoshare or SLX/GL is running ? (format["%1",ECP_public] != _null): if (ECP_public select 37) then { exit } ? (format["%1",SLX_GL3_Path] != _null): exit _arrUnits = if (count _this > 0) then { call (_this select 0) } else { list allUnits } _maxDist = if (count _this > 1) then { _this select 1 } else { [4000,50,50,50,0] } _radioCl = if (count _this > 2) then { _this select 2 } else { if (wgl_on) then { ["WGL_ANPRC77_Alice","WGL_ANPRC77_Raid","WGL_P159_RD90","WGL_P159_RD54","WGL_P159_RD99"] } else { [] } } ; Define function ? (format["%1",in2Darray]==_null) : in2Darray = preprocessfile "in2Darray.sqf" _kA = 0.105 _wait = 5 _simulateSoviet = true _debug = false ; Side group arrays will contain a list of groups belonging to its side, plus the list of enemy units known by that group and if the group has a radio _westGrps = [] _eastGrps = [] _guerGrps = [] _civGrps = [] #loop ?(_debug): player globalchat "#NEXT CHECK" ; Clean side arrays _sideArr = ["west","east","guer","civ"] { call format ["_c = 0; { if (({alive _x} count units (_x select 0)) < 1) then { _%1Grps set [_c,-1]; _%1Grps = _%1Grps - [-1] }; _c = _c + 1 } forEach _%1Grps", _x] } forEach _sideArr ; Build side arrays { if (!isNull _x and alive _x) then { call format ["_ind = [group _x, _%1Grps] call in2Darray; if (_ind < 0) then { _%1Grps set [count _%1Grps, [group _x,false]] };",side _x] }} forEach _arrUnits ~0.1 _c = 0 #checkAll _sideGrps = call format ["_%1Grps",_sideArr select _c] ?(count _sideGrps == 0): goto "wait" ; Set max distance based on side _sMaxDist = _maxDist select _c ; Build enemy groups list _enmGrps = [] { if (_x != (_sideArr select _c)) then { _enmGrps = _enmGrps + (call format ["_%1Grps",_x]) } } forEach _sideArr ?(count _enmGrps == 0): goto "wait" ; Build enemy units list _enmUnits = [] { _enmUnits = _enmUnits + (units (_x select 0)) } forEach _enmGrps _c1 = 0 #check _grpArr = (_sideGrps select _c1) _uGrp = units (_grpArr select 0) ?(({alive _x} count _uGrp) < 1): goto "wait1" _ldr = leader (_uGrp select 0) _side = side _ldr ; Check if there's a vehicle with a radio in the group _grpRad = if ((("Helicopter" countType _uGrp) > 0 and ("ParachuteBase" countType _uGrp) == 0) or ("Plane" countType _uGrp) > 0 or ("Tank" countType _uGrp) > 0) then { true } else { false } ; Simulate soviet motorized infantry communications. Only Company comms while mounted ?(_grpRad and _simulateSoviet and _side == east and (vehicle _ldr) == _ldr): _grpRad = false ; Check if there's a radio in the group _u = objNull ?(!_grpRad and count _radioCl > 0): { _u = _x; { if (_x in (weapons _u)) then { _grpRad = true } } forEach _radioCl } forEach _uGrp ; Update radio value in groups array _grpArr set [1, _grpRad] ; Add new enemy units detected by this group _det = [] { if ((_ldr knowsAbout (vehicle _x)) >= _kA and !((vehicle _x) in _det) and (_ldr countEnemy [vehicle _x]) > 0) then { _det set [count _det, vehicle _x] } } forEach _enmUnits ?(_debug and player in _uGrp): player globalchat format ["_det by player: %1", _det]; ~0.01 ; Find close friendly groups _closeGrps = [] { if (((vehicle leader (_x select 0)) distance (vehicle _ldr)) <= _sMaxDist or (_grpRad and (_x select 1))) then { _closeGrps set [count _closeGrps, _x] } } forEach _sideGrps ~0.01 ; Share detected array with close groups { _l = leader (_x select 0); { _l reveal (vehicle _x) } forEach _det } forEach _closeGrps #wait1 _c1 = _c1 + 1 ~0.05 ?(_c1 < count _sideGrps): goto "check" #wait _c = _c + 1 ~0.1 ?(_c < count _sideArr): goto "checkAll" ; Undefine vars _sideArr = nil _sideGrps = nil _enmGrps = nil _enmUnits = nil _grpArr = nil _uGrp = nil _det = nil _ldr = nil _c = nil _c1 = nil _l = nil _u = nil _grpRad = nil _closeGrps = nil ~_wait goto "loop" exit ; ----------------- ; kINFOSHARE ; ; ADVANCED: ; ; Parameters: ; - Array listing all units. This can be either a trigger list or a hand made array of units. Note that only units in this array will be able to detect AND be detected ; Default value: list allUnits ; - Array of maximum communication distances. First element: distance for west side; Second elem: distance for east side; Third: resistance; Fourth: civilians; Fifth: renegades ; - Array of radio classes recognized by this script. It will be an empty array as default ; ; USE: [<array of units>,<array of max distances>,<array of recognized radios>] exec "kInfoshare.sqs" ; EXAMPLE: ["list allUnits",[4000,50,50,50,0],["wgl_anprc77_alice","wgl_p159_rd90"]] exec "scripts\kInfoshare.sqs" ; ; ; NOTES ON COMM DISTANCES: ; ; All men in US army squads in the 80s had a AN/PRC-68 radio (walkie-talkie) with a range of about 5km, ; while soviets had to rely on an RTO or platoon leader carrying a P-159 VHF on their back. ; So, by default, all western units will have a far greater communication range than any other side. ; This can be edited by the user. ; ; Groups with a tank, plane or helicopter vehicle will be able to use that vehicle's radio to broadcast ; virtually anywhere. ; ----------------- ; RANGES ; ; US: ; AN/PRC-77: 8km/16km - 50km ; AN/PRC-68: 3km - 5km ; ; USSR: ; P-159 VHF: 10km - 50km ; ; SINCGARS: 300m -35km ; AN/PRC-148: 6km - 30km You'll also need this function:in2Darray.sqf /* in2Darray Searchs for an element in a 2D array and returns the index of its parent array in the main array If nothing is found it'll return -1. USE: [<element>,<main array>] call in2Darray by kenoxite */ private ["_ele","_arr","_i","_result"]; _ele = _this select 0; _arr = _this select 1; _result = -1; _i = 0; { if (_ele in _x) then { _result = _i; }; _i = _i + 1; } forEach _arr; _result ---------- Post added at 17:48 ---------- Previous post was at 17:40 ----------WGL AI RUCKSACK v1.0Readme: WGL AI Rucksack v1.0 by kenoxite Allows AI units to use items stored in their WGL rucksack. Everytime the unit runs out of ammo it'll check its rucksack. If compatible mags are found it'll proceed to use the rucksack the same way a player does (crouching, etc). If no magazines are found and the unit has a LMG, MG or some type of rocket launcher it'll ask to his mates for ammo. If any other unit in his group has compatible ammo that will be auto-magically* transferred to the unit requesting it. Bandages and other items aren't handled by this system. Hand grenades (explosive and smoke) are, though. *This is done to prevent breaking missions, scripts, player orders, or simply to avoid AI units pingponging between locations. INSTALLATION - Place the WGL_scripts directory inside that of your mission USE: <unit> addEventHandler ["fired",loadfile "WGL_scripts\eh\WGL_AIrucksack.sqf"]; EXAMPLE: this addEventHandler ["fired",loadfile "WGL_scripts\eh\WGL_AIrucksack.sqf"]; Place the files below in a folder named "WGL_scripts".WGL_AIrucksack_check.sqs ; WGL AI RUCKSACK - CHECK ; by kenoxite ; ; Checks if the AI unit has extra ammo on his rucksack ; and if so makes it drop it _u = _this select 0; _wep = _this select 1; _mu = _this select 2; _mo = _this select 3; _types = [] _secWep = secondaryWeapon _u _players = [player] ?(!alive _u or isNull _u): exit ; Check if unit has a rucksack _rucksacks = ["WGL_RucksackAlice","WGL_RucksackRaid","WGL_RucksackAliceOld","WGL_RucksackRD90","WGL_RucksackRD91","WGL_RucksackRD92","WGL_RucksackRD54","WGL_RucksackRD99"] ?(_wep in _rucksacks): exit ; Check if unit has bullets left ?((_u ammo _mu) > 0): exit ; Rucksack magazine types ; ; West ?(_mu == "WGL_M16Muzzle" or _wep == "WGL_M16"): _types = ["WGL_M16_PDM"], _mags = ["WGL_M16Mag"] ?(_mu == "WGL_M203Muzzle"): _types = ["WGL_GrenadeW_PDM"], _mags = ["WGL_M433grenade"] ?(_mu == "WGL_M4A1Muzzle" or _wep == "WGL_M4A1" or _wep == "WGL_M4A1ACOG" or _wep == "WGL_M4A1Reflex"): _types = ["WGL_M4_PDM"], _mags = ["WGL_M4A1Mag"] ?(_wep == "WGL_M4A1SD"): _types = ["WGL_M4SD_PDM"], _mags = ["WGL_M4A1SDMag"] ;?(_wep == "WGL_M240" or _wep == "WGL_M60"): _types = ["WGL_M240_PDM","WGL_M60_PDM"], _mags = ["WGL_M60Mag","WGL_M240Mag"] ?(_wep == "WGL_M249" or _wep == "WGL_M249Para"): _types = ["WGL_M249_PDM"], _mags = ["WGL_M249Mag"] ?(_wep == "WGL_M21"): _types = ["WGL_M21_PDM"], _mags = ["WGL_M21Mag"] ?(_wep == "WGL_M24"): _types = ["WGL_M24_PDM"], _mags = ["WGL_M24Mag"] ?(_wep == "WGL_M40A1"): _types = ["WGL_M40A1_PDM"], _mags = ["WGL_M40A1Mag"] ?(_wep == "WGL_M40A3"): _types = ["WGL_M40A3_PDM"], _mags = ["WGL_M40A3Mag"] ?(_wep == "WGL_M82A1" or _wep == "WGL_M82A1_300"): _types = ["WGL_M82_PDM"], _mags = ["WGL_M82A1Mag"] ?(_wep == "WGL_AALauncher"): _types = ["WGL_AA_PDM"], _mags = ["WGL_AAMag"] ?(_wep == "WGL_CarlGustavLauncher"): _types = ["WGL_CarlGustav_PDM","WGL_FFV502_PDM"], _mags = ["WGL_CarlGustavMag","WGL_FFV502Mag"] ?(_wep == "WGL_DragonLauncher"): _types = ["WGL_Dragon_PDM"], _mags = ["WGL_DragonMag"] ?(_wep == "WGL_JavelinLauncher"): _types = ["WGL_Javelin_PDM"], _mags = ["WGL_JavelinMag"] ; East ?(_mu == "WGL_AK47Muzzle" or _wep == "WGL_AK47"): _types = ["WGL_AK47_PDM"], _mags = ["WGL_AK47Mag"] ?(_mu == "WGL_GP25Muzzle" or _mu == "WGL_GP30Muzzle"): _types = ["WGL_GrenadeE_PDM"], _mags = ["WGL_VOG25Grenade"] ?(_mu == "WGL_AK74Muzzle" or _mu == "WGL_AKS74Muzzle" or _wep == "WGL_AK74" or _wep == "WGL_AKS74" or _wep == "WGL_AKS74PSO1" or _wep == "WGL_AKS74U"): _types = ["WGL_AK74_PDM","WGL_AK74SU_PDM"], _mags = ["WGL_AK74Mag","WGL_AKS74UMag"] ?(_wep == "WGL_AKS74SD"): _types = ["WGL_AK74SD_PDM","WGL_AK74SUSD_PDM"], _mags = ["WGL_AK74SDMag","WGL_AKS74USDMag"] ?(_wep == "WGL_PKM"): _types = ["WGL_PKM_PDM"], _mags = ["WGL_PKMMag"] ?(_wep == "WGL_RPK47"): _types = ["WGL_RPK47_PDM","WGL_AK47_PDM"], _mags = ["WGL_RPK47Mag","WGL_AK47Mag"] ?(_wep == "WGL_RPK74"): _types = ["WGL_RPK74_PDM","WGL_AK74_PDM"], _mags = ["WGL_RPK74Mag","WGL_AK74Mag"] ?(_wep == "WGL_OSV96"): _types = ["WGL_OSV96_PDM"], _mags = ["WGL_OSV96Mag"] ?(_wep == "WGL_SV98"): _types = ["WGL_SV98_PDM"], _mags = ["WGL_SV98Mag"] ?(_wep == "WGL_SVD"): _types = ["WGL_SVD_PDM"], _mags = ["WGL_SVDMag"] ?(_wep == "WGL_9K32Launcher"): _types = ["WGL_9K32_PDM"], _mags = ["WGL_9K32Mag","9K32Launcher"] ?(_wep == "WGL_RPG7Launcher" or _wep == "WGL_RPG7VLLauncher"): _types = ["WGL_RPG7_PDM","WGL_RPG7VL_PDM","WGL_RPG7VR_PDM","WGL_TBG7V_PDM"], _mags = ["WGL_RPG7Mag","WGL_RPG7VLMag","WGL_RPG7VRMag","WGL_TBG7VMag"] ; All ?(_wep == "WGL_Throw" and _mo == "WGL_HandGrenade"): _types = ["WGL_HandGrenade_PDM"], _mags = ["WGL_HandGrenade"] ?(_wep == "WGL_Throw" and (_mo == "WGL_SmokegrenadeWhite" or _mo == "WGL_SmokegrenadeRed" or _mo == "WGL_SmokegrenadeGreen" or _mo == "WGL_SmokegrenadeYellow" or _mo == "WGL_SmokegrenadeViolet")): _types = ["WGL_SmokeShell_PDM","WGL_SmokeShellGreen_PDM","WGL_SmokeShellRed_PDM","WGL_SmokeShellViolet_PDM","WGL_SmokeShellYellow_PDM"], _mags = ["WGL_SmokegrenadeWhite","WGL_SmokegrenadeRed","WGL_SmokegrenadeGreen","WGL_SmokegrenadeYellow","WGL_SmokegrenadeViolet"] ; LMGs. Need another unit to carry extra ammo _lmgs = ["WGL_M240","WGL_M60","WGL_M249","WGL_M249Para","WGL_PKM","WGL_RPK47","WGL_RPK74"] ; Launchers. Need another unit to carry extra ammo _launchers = ["WGL_AALauncher","WGL_CarlGustavLauncher","WGL_DragonLauncher","WGL_JavelinLauncher","WGL_9K32Launcher","WGL_RPG7Launcher","WGL_RPG7VLLauncher"] ; Check if unit has any mags left _magsLeft = 0 _uMags = (magazines _u) { if (_x in _mags ) then { _magsLeft = _magsLeft + 1 } } forEach _uMags ?(_magsLeft > 1): exit ; Check if unit has usable mags in its rucksack _type = "" _mag = "" { _mag = _x; { if (_mag == _x and _type == "") then { _type = _mag } } forEach _types } forEach _uMags ?(_type == ""): if (_wep in _launchers or _wep in _lmgs) then { goto "findBearer" } else { exit } ?(_u in _players): exit ; Drop the rucksack magazine ~1 _u selectWeapon _secWep ~0.1 ?(!alive _u or isNull _u): exit _u fire [_secWep, _type, _type] [_u,_type,_mu] exec "WGL_scripts\WGL_AIrucksack_take.sqs" exit #findBearer ?(!alive _u or isNull _u): exit ; Find another unit in the group with the desired ammo _units = units group _u _bearer = objNull _tU = objNull _type = "" { _tU = _x; { if (_x in _types and isNull _bearer and alive _tU) then { _bearer = _tU; _type = _x } } forEach (magazines _tU) } forEach _units ?(isNull _bearer): exit ; Magically move the magazine from the bearer to the current unit _bearer removeMagazine _type _magtype = "" call loadfile "WGL_scripts\WGL_AIrucksack_mags.sqf" #takeMag ~5 _u removeMagazine _magtype ~0.1 _u addMagazine _magtype exit WGL_AIrucksack_take.sqs ; WGL AI RUCKSACK - TAKE ; by kenoxite ; ; Makes AIs take ammo dropped from their rucksack ; ; Some code from \wglevents\weaponfx\ruck_dropstuff.sqs _u = _this select 0 _type = _this select 1 _mu = _this select 2 _maxWait = 10 ?(!alive _u or isNull _u): exit ; Check for type of mag dropped and create it _magtype = "" call loadfile "WGL_scripts\WGL_AIrucksack_mags.sqf" #takeMag _t = 0 _holder = objNull #wait1 ?(!alive _u or isNull _u or _t >= _maxWait): exit _holder=nearestObject[_u,"WeaponHolder"] ~1 _t = _t + 1 ?(isNull _holder): goto "wait1" ?(!alive _u or isNull _u): exit _u action ["TAKE MAGAZINE",_holder,0,0,_magtype] ~1 _u selectWeapon _mu exit #takeWep _t = 0 _holder = objNull #wait2 ?(!alive _u or isNull _u or _t >= _maxWait): exit _holder=nearestObject[_u,"SecondaryWeaponHolder"] ~1 _t = _t + 1 ?(isNull _holder): goto "wait1" ?(!alive _u or isNull _u): exit _u action ["TAKE WEAPON",_holder,0,0,_magtype] ~1 _u selectWeapon _mu exit WGL_AIrucksack_mags.sqf if (_type=="WGL_M16_PDM") then {_magtype="WGL_M16Mag";goto"takeMag"}; if (_type=="WGL_M60_PDM") then {_magtype="WGL_M60Mag";goto"takeMag"}; if (_type=="WGL_M240_PDM") then {_magtype="WGL_M240Mag";goto"takeMag"}; if (_type=="WGL_M249_PDM") then {_magtype="WGL_M249Mag";goto"takeMag"}; if (_type=="WGL_M4_PDM") then {_magtype="WGL_M4A1Mag";goto"takeMag"}; if (_type=="WGL_M4SD_PDM") then {_magtype="WGL_M4A1SDMag";goto"takeMag"}; if (_type=="WGL_M21_PDM") then {_magtype="WGL_M21Mag";goto"takeMag"}; if (_type=="WGL_M24_PDM") then {_magtype="WGL_M24Mag";goto"takeMag"}; if (_type=="WGL_M82_PDM") then {_magtype="WGL_M82A1Mag";goto"takeMag"}; if (_type=="WGL_M40A1_PDM") then {_magtype="WGL_M40A1Mag";goto"takeMag"}; if (_type=="WGL_M40A3_PDM") then {_magtype="WGL_M40A3Mag";goto"takeMag"}; if (_type=="WGL_AUG_PDM") then {_magtype="WGL_AUGMag";goto"takeMag"}; if (_type=="WGL_FAL_PDM") then {_magtype="WGL_FALMag";goto"takeMag"}; if (_type=="WGL_G3_PDM") then {_magtype="WGL_G3Mag" ;goto"takeMag"}; if (_type=="WGL_G36_PDM") then {_magtype="WGL_G36Mag";goto"takeMag"}; if (_type=="WGL_HK_PDM") then {_magtype="WGL_HKMag" ;goto"takeMag"}; if (_type=="WGL_AK47_PDM") then {_magtype="WGL_AK47Mag";goto"takeMag"}; if (_type=="WGL_AK74_PDM") then {_magtype="WGL_AK74Mag";goto"takeMag"}; if (_type=="WGL_AK74SD_PDM") then {_magtype="WGL_AK74SDMag";goto"takeMag"}; if (_type=="WGL_AK74SU_PDM") then {_magtype="WGL_AKS74UMag";goto"takeMag"}; if (_type=="WGL_AK74SUSD_PDM") then {_magtype="WGL_AKS74USDMag";goto"takeMag"}; if (_type=="WGL_AK103_PDM") then {_magtype="WGL_AK103Mag";goto"takeMag"}; if (_type=="WGL_AK107_PDM") then {_magtype="WGL_AK107Mag";goto"takeMag"}; if (_type=="WGL_RPK47_PDM") then {_magtype="WGL_RPK47Mag";goto"takeMag"}; if (_type=="WGL_RPK74_PDM") then {_magtype="WGL_RPK74Mag";goto"takeMag"}; if (_type=="WGL_PKM_PDM") then {_magtype="WGL_PKMMag";goto"takeMag"}; if (_type=="WGL_SVD_PDM") then {_magtype="WGL_SVDMag";goto"takeMag"}; if (_type=="WGL_SV98_PDM") then {_magtype="WGL_SV98Mag";goto"takeMag"}; if (_type=="WGL_OSV96_PDM") then {_magtype="WGL_OSV96Mag";goto"takeMag"}; if (_type=="WGL_LAW_PDM") then {_magtype="WGL_LAWLauncher";goto"takeWep"}; if (_type=="WGL_CarlGustav_PDM") then {_magtype="WGL_CarlGustavMag";goto"takeMag"}; if (_type=="WGL_FFV502_PDM") then {_magtype="WGL_FFV502Mag";goto"takeMag"}; if (_type=="WGL_Dragon_PDM") then {_magtype="WGL_DragonMag";goto"takeMag"}; if (_type=="WGL_Javelin_PDM") then {_magtype="WGL_JavelinMag";goto"takeMag"}; if (_type=="WGL_RPG22_PDM") then {_magtype="WGL_RPG22Launcher";goto"takeWep"}; if (_type=="WGL_RPG7_PDM") then {_magtype="WGL_RPG7Mag";goto"takeMag"}; if (_type=="WGL_RPG7VL_PDM") then {_magtype="WGL_RPG7VLMag";goto"takeMag"}; if (_type=="WGL_RPG7VR_PDM") then {_magtype="WGL_RPG7VRMag";goto"takeMag"}; if (_type=="WGL_TBG7V_PDM") then {_magtype="WGL_TBG7VMag";goto"takeMag"}; if (_type=="WGL_AA_PDM") then {_magtype="WGL_AAMag";goto"takeMag"}; if (_type=="WGL_9k32_PDM") then {_magtype="WGL_9k32Mag";goto"takeMag"}; if (_type=="WGL_SmokeShell_PDM") then {_magtype="WGL_SmokegrenadeWhite";goto"takeMag"}; if (_type=="WGL_SmokeShellRed_PDM") then {_magtype="WGL_SmokegrenadeRed";goto"takeMag"}; if (_type=="WGL_SmokeShellGreen_PDM") then {_magtype="WGL_SmokegrenadeGreen";goto"takeMag"}; if (_type=="WGL_SmokeShellYellow_PDM") then {_magtype="WGL_SmokegrenadeYellow";goto"takeMag"}; if (_type=="WGL_SmokeShellViolet_PDM") then {_magtype="WGL_SmokegrenadeViolet";goto"takeMag"}; if (_type=="WGL_Timebomb_PDM") then {_magtype="WGL_Timebomb";goto"takeMag"}; if (_type=="WGL_Pipebomb_PDM") then {_magtype="WGL_Pipebomb";goto"takeMag"}; if (_type=="WGL_Claymore_PDM") then {_magtype="WGL_Claymore";goto"takeMag"}; if (_type=="WGL_MON200_PDM") then {_magtype="WGL_MON200";goto"takeMag"}; if (_type=="WGL_Mine_PDM") then {_magtype="WGL_Mine";goto"takeMag"}; if (_type=="WGL_MineE_PDM") then {_magtype="WGL_MineE";goto"takeMag"}; if (_type=="WGL_IEDSML_PDM") then {_magtype="WGL_IEDSML";goto"takeMag"}; if (_type=="WGL_IEDMED_PDM") then {_magtype="WGL_IEDMED";goto"takeMag"}; if (_type=="WGL_IEDLRG_PDM") then {_magtype="WGL_IEDLRG";goto"takeMag"}; if (_type=="WGL_NSV_PDM") then {_magtype="WGL_NSV_PDM";goto"takeMag"}; if (_type=="WGL_M2_PDM") then {_magtype="WGL_M2_PDM";goto"takeMag"}; if (_type=="WGL_AGS17_PDM") then {_magtype="WGL_AGS17_PDM";goto"takeMag"}; if (_type=="WGL_Mortar60W_PDM") then {_magtype="WGL_Mortar60W_PDM";goto"takeMag"}; if (_type=="WGL_Mortar81W_PDM") then {_magtype="WGL_Mortar81W_PDM";goto"takeMag"}; if (_type=="WGL_Mortar82E_PDM") then {_magtype="WGL_Mortar82E_PDM";goto"takeMag"}; if (_type=="WGL_Mortar60WP_PDM") then {_magtype="WGL_Mortar60WP_PDM";goto"takeMag"}; if (_type=="WGL_Mortar81WP_PDM") then {_magtype="WGL_Mortar81WP_PDM";goto"takeMag"}; if (_type=="WGL_Mortar82WP_PDM") then {_magtype="WGL_Mortar82WP_PDM";goto"takeMag"}; if (_type=="WGL_Mortar60PF_PDM") then {_magtype="WGL_Mortar60PF_PDM";goto"takeMag"}; if (_type=="WGL_Mortar81PF_PDM") then {_magtype="WGL_Mortar81PF_PDM";goto"takeMag"}; if (_type=="WGL_Mortar82PF_PDM") then {_magtype="WGL_Mortar82PF_PDM";goto"takeMag"}; if (_type=="WGL_NVGoggles_PDM") then {_magtype="NVGoggles";goto"takeWep"}; if (_type=="WGL_Binocular_PDM") then {_magtype="Binocular";goto"takeWep"}; if (_type=="WGL_HandGrenade_PDM") then {_magtype="WGL_HandGrenade";goto"takeMag"}; if (_type=="WGL_GrenadeW_PDM") then {_magtype="WGL_M433grenade";goto"takeMag"}; if (_type=="WGL_GrenadeE_PDM") then {_magtype="WGL_VOG25grenade";goto"takeMag"}; if (_type=="WGL_Bandage_PDM") then {_magtype="WGLBandage";goto"takeMag"}; And this in a directory inside "WGL_scripts" named "eh".WGL_AIrucksack.sqf _u = _this select 0; _w = _this select 1; _mu = _this select 2; _mo = _this select 3; if (vehicle _u == _u and alive _u and !isNull _u) then { [_u,_w,_mu,_mo] exec "WGL_scripts\WGL_AIrucksack_check.sqs" }; Share this post Link to post Share on other sites
cpt_smagnet 10 Posted June 23, 2013 Thank you soooooooooooooooooooooo much!!!!!! Love it man!!!!!!!!!!!!!!!!!!!!!!!!!! Cannot explain my feelings right now... so bloody thankful!!!!!!!!!!!!!!!!!!! Thx kenoxite!!!!!!!!!!!! Share this post Link to post Share on other sites
kenoxite 156 Posted September 3, 2015 kInfoshare updated to 1.1 Download: https://www.mediafire.com/download/rmngdot59902tti/kInfoshare_v11.zip Changelog: * CHANGE: in2Darray function is now embedded in the main script * CHANGE: revised parameter parsing and assignment of defaults * CHANGE: Expanded comments and descriptions The script itself, for those who can't access mediafire: ; ----------------- ; kINFOSHARE v1.1 ; by kenoxite ; ; Allows group leaders to automatically share information about enemy units with each other. ; The distance at which they can transmit this information will depend on their side ; and wether or not they have an RTO or a vehicle with a radio in their group ; (in this case they can transmit to all friendlies on the map, without distance restrictions). ; ; USE: ; 1) Place a trigger as big as the area of your mission, set it to be activated by Anybody and name it: allUnits ; 2) Init the script wherever you like (like in init.sqs): [] exec "kInfoshare.sqs"; ; ; * For multiplayer, and unless you already have placed a CoC NS2 or CoC UA logic, you'll need to place a game logic and name it: server ; ; Advanced instructions at the end of this script. ; ----------------- ; Don't remove this wait ~1 ; Execute this only on the server ?(!local server or !local CoC_Server): exit; _nil = format["%1",_nilstring]; ; Deactivate if ECP infoshare or SLX/GL is running ? (format["%1",ECP_public] != _nil): if (ECP_public select 37) then { exit }; ? (format["%1",SLX_GL3_Path] != _nil): exit; ; Check parameters _arrUnits = if (count _this > 0) then { if ((_this select 0) != "") then { _this select 0 } else { "" } } else { "" }; _maxDist = if (count _this > 1) then { if (count (_this select 1) > 0) then { _this select 1 } else { [] } } else { [] }; _radioCl = if (count _this > 2) then { if (count (_this select 2) > 0) then { _this select 2 } else { [] } } else { [] }; ; Set defaults if (_arrUnits == "") then { _arrUnits = list allUnits } else { _arrUnits = call _arrUnits }; if (count _maxDist == 0 || count _maxDist < 5) then { _maxDist = [4000,50,50,50,0] }; if (count _radioCl == 0) then { if (wgl_on) then { _radioCl = ["WGL_ANPRC77_Alice","WGL_ANPRC77_Raid","WGL_P159_RD90","WGL_P159_RD54","WGL_P159_RD99"] } else { _radioCl = [] } }; ; Define function ? (format["%1",in2Darray]==_nil) : in2Darray = { private ["_ele","_arr","_i","_result"]; _ele = _this select 0; _arr = _this select 1; _result = -1; _i = 0;{ if (_ele in _x) then { _result = _i; }; _i = _i + 1;} forEach _arr; _result}; _nil = nil; ; --------------------- ; SETTINGS ; --------------------- ; KnowsAbout value where an enemy unit is considered to have been fully detected _kA = 0.105; ; Waiting time between each cycle of this script _wait = 5; ; Simulate soviet motorized infantry communications. Only Company comms when mounted. ; Unless there's an RTO in the group, East will only have radio comms over all the map as long as the leader is mounted on a vehicle with radio (BTR, BMP, etc) _simulateSoviet = false; ; Debugging _debug = false; ; --------------------- ?(_debug): player globalchat format ["_arrUnits (count): %1, _maxDist: %2, _radioCl: %3", count _arrUnits, _maxDist, _radioCl]; ; Side group arrays will contain a list of groups belonging to its side, plus the list of enemy units known by that group and if the group has a radio _westGrps = []; _eastGrps = []; _guerGrps = []; _civGrps = []; #loop ?(_debug): player globalchat "#NEXT CHECK"; ; Clean side arrays _sideArr = ["west","east","guer","civ"]; { call format ["_c = 0; { if (({alive _x} count units (_x select 0)) < 1) then { _%1Grps set [_c,-1]; _%1Grps = _%1Grps - [-1] }; _c = _c + 1 } forEach _%1Grps", _x] } forEach _sideArr; ; Build side arrays { if (!isNull _x and alive _x) then { call format ["_ind = [group _x, _%1Grps] call in2Darray; if (_ind < 0) then { _%1Grps set [count _%1Grps, [group _x,false]] };",side _x] }} forEach _arrUnits ; ~0.1 _c = 0; #checkAll _sideGrps = call format ["_%1Grps",_sideArr select _c]; ?(count _sideGrps == 0): goto "wait"; ; Set max distance based on side _sMaxDist = _maxDist select _c; ; Build enemy groups list _enmGrps = []; { if (_x != (_sideArr select _c)) then { _enmGrps = _enmGrps + (call format ["_%1Grps",_x]) } } forEach _sideArr; ?(count _enmGrps == 0): goto "wait"; ; Build enemy units list _enmUnits = []; { _enmUnits = _enmUnits + (units (_x select 0)) } forEach _enmGrps; _c1 = 0; #check _grpArr = (_sideGrps select _c1); _uGrp = units (_grpArr select 0); ?(({alive _x} count _uGrp) < 1): goto "wait1"; _ldr = leader (_uGrp select 0); _side = side _ldr; ; Check if there's a vehicle with a radio in the group _grpRad = if ((("Helicopter" countType _uGrp) > 0 and ("ParachuteBase" countType _uGrp) == 0) or ("Plane" countType _uGrp) > 0 or ("Tank" countType _uGrp) > 0) then { true } else { false }; ; Simulate soviet motorized infantry communications. Only Company comms when mounted ?(_grpRad and _simulateSoviet and _side == east and (vehicle _ldr) == _ldr): _grpRad = false; ; Check if there's a radio in the group _u = objNull; ?(!_grpRad and count _radioCl > 0): { _u = _x; { if (_x in (weapons _u)) then { _grpRad = true } } forEach _radioCl } forEach _uGrp; ; Update radio value in groups array _grpArr set [1, _grpRad]; ; Add new enemy units detected by this group _det = []; { if ((_ldr knowsAbout (vehicle _x)) >= _kA and !((vehicle _x) in _det) and (_ldr countEnemy [vehicle _x]) > 0) then { _det set [count _det, vehicle _x] } } forEach _enmUnits; ?(_debug and player in _uGrp): player globalchat format ["#Enemies detected by player group: %1", _det]; ~0.01 ; Find close friendly groups _closeGrps = []; { if (((vehicle leader (_x select 0)) distance (vehicle _ldr)) <= _sMaxDist or (_grpRad and (_x select 1))) then { _closeGrps set [count _closeGrps, _x] } } forEach _sideGrps; ~0.01 ; Share detected array with close groups { _l = leader (_x select 0); { _l reveal (vehicle _x) } forEach _det } forEach _closeGrps; #wait1 _c1 = _c1 + 1; ~0.05 ?(_c1 < count _sideGrps): goto "check"; #wait _c = _c + 1; ~0.1 ?(_c < count _sideArr): goto "checkAll"; ; Undefine vars _sideArr = nil; _sideGrps = nil; _enmGrps = nil; _enmUnits = nil; _grpArr = nil; _uGrp = nil; _det = nil; _ldr = nil; _c = nil; _c1 = nil; _l = nil; _u = nil; _grpRad = nil; _closeGrps = nil; ~_wait goto "loop"; exit; ; ----------------- ; kINFOSHARE ; ----------------- ; ADVANCED INSTRUCTIONS: ; ; Parameters: ; - Array listing all units. This can be either a trigger list or a hand made array of units. Note that only units in this array will be able to detect AND be detected ; Default value: list allUnits ; - Array of maximum communication distances. First element: distance for west side; Second elem: for east; Third: for resistance; Fourth: for civilians; Fifth: for renegades ; - Array of radio classes recognized by this script. It will be an empty array as default ; ; USE: [<array of units>,<array of max distances>,<array of recognized radios>] exec "kInfoshare.sqs"; ; EXAMPLE: ["list allUnits",[4000,50,50,50,0],["ww4_radio"]] exec "kInfoshare.sqs"; ; ; You can leave parameters empty when calling the script, so the default values are used. ; This comes handy when you want to, say, keep the defaults of the array of units and radios but want to change the comm distances. ; To skip values and set defaults use: ; _arrUnits = "" ; _maxDist = [] ; _radioCl = [] ; For the mentioned example, you could use: ; ["",[200,200,200,0],[]] exec "kInfoshare.sqs"; ; or just: ; ["",[200,200,200,0]] exec "kInfoshare.sqs"; ; ; NOTES ON COMM DISTANCES: ; ; US army squads in the 80s had a AN/PRC-68 radio (walkie-talkie) with a range of about 5km, ; while soviets had to rely on an RTO or platoon leader carrying a P-159 VHF on their back. ; So, by default, all western units will have a far greater communication range than any other side. ; This can be edited by the user. ; ; Groups with a tank, plane or helicopter vehicle will be able to use that vehicle's radio to broadcast ; virtually anywhere. ; ----------------- ; ; Extra info: ; ; RANGES ; ; US: ; AN/PRC-77: 8km/16km - 50km ; AN/PRC-68: 3km - 5km ; ; USSR: ; P-159 VHF: 10km - 50km ; ; SINCGARS: 300m -35km ; AN/PRC-148: 6km - 30km ; ; ----------------- ; CHANGELOG ; - v1.1 ; * CHANGE: in2Darray is now defined in this same script ; * CHANGE: revised parameter parsing and assignment of defaults ; * CHANGE: Expanded comments and descriptions ; - v1.0 ; * Initial release ; ----------------- Share this post Link to post Share on other sites
kenoxite 156 Posted September 6, 2015 kInfoshare updated to v1.2 Download: https://www.mediafire.com/download/isz92piv9bawpe8/kInfoshare_v12.zip Changelog * NEW: Added distance limits at which enemy units won't be reported depending on the type of group of the receiving friendly group (infantry, air, land or water vehicles). Editable in the SETTINGS area. * CHANGE: Removed requeriment to set comm distance for renegade groups (as it was unused anyway) The script: ; ----------------- ; kINFOSHARE v1.2 ; by kenoxite ; ; Allows group leaders to automatically share information about enemy units with each other. ; The distance at which they can transmit this information will depend on their side ; and wether or not they have an RTO or a vehicle with a radio in their group ; (in this case they can transmit to all friendlies on the map, without distance restrictions). ; ; USE: ; 1) Place a trigger as big as the area of your mission, set it to be activated by Anybody and name it: allUnits ; 2) Init the script wherever you like (like in init.sqs): [] exec "kInfoshare.sqs"; ; ; * For multiplayer, and unless you already have placed a CoC NS2 or CoC UA logic, you'll need to place a game logic and name it: server ; ; Advanced instructions at the end of this script. ; ----------------- ; Don't remove this wait ~1 ; Execute only on the server ?(!local server or !local CoC_Server): exit; _nil = format["%1",_nilstring]; ; Deactivate if ECP infoshare or SLX/GL is running ? (format["%1",ECP_public] != _nil): if (ECP_public select 37) then { exit }; ? (format["%1",SLX_GL3_Path] != _nil): exit; ; Check parameters _arrUnits = if (count _this > 0) then { if ((_this select 0) != "") then { _this select 0 } else { "" } } else { "" }; _maxDist = if (count _this > 1) then { if (count (_this select 1) > 0) then { _this select 1 } else { [] } } else { [] }; _radioCl = if (count _this > 2) then { if (count (_this select 2) > 0) then { _this select 2 } else { [] } } else { [] }; ; Set defaults if (_arrUnits == "") then { _arrUnits = list allUnits } else { _arrUnits = call _arrUnits }; if (count _maxDist == 0 || count _maxDist < 4) then { _maxDist = [4000,50,50,50] }; if (count _radioCl == 0) then { if (wgl_on) then { _radioCl = ["WGL_ANPRC77_Alice","WGL_ANPRC77_Raid","WGL_P159_RD90","WGL_P159_RD54","WGL_P159_RD99"] } else { _radioCl = [] } }; ; Define function ? (format["%1",in2Darray]==_nil) : in2Darray = { private ["_ele","_arr","_i","_result"]; _ele = _this select 0; _arr = _this select 1; _result = -1; _i = 0;{ if (_ele in _x) then { _result = _i; }; _i = _i + 1;} forEach _arr; _result}; _nil = nil; ; --------------------- ; SETTINGS ; --------------------- ; KnowsAbout value where an enemy unit is considered to have been fully detected _kA = 0.105; ; WW4 Extended recommended knowsAbout value: ;_kA = 0.38; ; Enemies beyond the distances set below won't be reported to friendly groups of the specified type (infantry, land, air and water vehicles). This is to avoid weird AI behaviour (constant combat mode) and stupid "engage" orders that sent units all over the map, particularly noticeable for infantry groups. _engDistInf = 300; _engDistLand = 800; _engDistAir = 2000; _engDistWater = 500; ; Waiting time between each cycle of this script _wait = 5; ; Simulate soviet motorized infantry communications. Only Company comms when leader is mounted. ; Unless there's an RTO in the group, East will only have radio comms over all the map as long as the leader is mounted on a vehicle with radio (BTR, BMP, etc) _simulateSoviet = false; ; Debugging _debug = false; ; --------------------- ?(_debug): player globalchat format ["_arrUnits (count): %1, _maxDist: %2, _radioCl: %3", count _arrUnits, _maxDist, _radioCl]; ; Side group arrays will contain a list of groups belonging to each side, plus the list of enemy units known by that group and if the group has a radio _westGrps = []; _eastGrps = []; _guerGrps = []; _civGrps = []; #loop ?(_debug): player globalchat "#NEXT CHECK"; ; Clean side arrays _sideArr = ["west","east","guer","civ"]; { call format ["_c = 0; { if (({alive _x} count units (_x select 0)) < 1) then { _%1Grps set [_c,-1]; _%1Grps = _%1Grps - [-1] }; _c = _c + 1 } forEach _%1Grps", _x] } forEach _sideArr; ; Build side arrays { if (!isNull _x and alive _x) then { call format ["_ind = [group _x, _%1Grps] call in2Darray; if (_ind < 0) then { _%1Grps set [count _%1Grps, [group _x,false]] };",side _x] }} forEach _arrUnits ; ~0.1 _c = 0; #checkAll _sideGrps = call format ["_%1Grps",_sideArr select _c]; ?(count _sideGrps == 0): goto "wait"; ; Set max distance based on side _sMaxDist = _maxDist select _c; ; Build enemy groups list _enmGrps = []; { if (_x != (_sideArr select _c)) then { _enmGrps = _enmGrps + (call format ["_%1Grps",_x]) } } forEach _sideArr; ?(count _enmGrps == 0): goto "wait"; ; Build enemy units list _enmUnits = []; { _enmUnits = _enmUnits + (units (_x select 0)) } forEach _enmGrps; _c1 = 0; #check _grpArr = (_sideGrps select _c1); _uGrp = units (_grpArr select 0); ?(({alive _x} count _uGrp) < 1): goto "wait1"; _ldr = leader (_uGrp select 0); _side = side _ldr; ; Check if there's a vehicle with a radio in the group _grpRad = if ((("Helicopter" countType _uGrp) > 0 and ("ParachuteBase" countType _uGrp) == 0) or ("Plane" countType _uGrp) > 0 or ("Tank" countType _uGrp) > 0) then { true } else { false }; ; Simulate soviet motorized infantry communications. Only Company comms when leader is mounted ?(_grpRad and _simulateSoviet and _side == east and (_vLdr) == _ldr): _grpRad = false; ; Check if there's a radio in the group _u = objNull; ?(!_grpRad and count _radioCl > 0): { _u = _x; { if (_x in (weapons _u)) then { _grpRad = true } } forEach _radioCl } forEach _uGrp; ; Update radio value in groups array _grpArr set [1, _grpRad]; ; Add new enemy units detected by this group _det = []; { _v = vehicle _x; if ((_ldr knowsAbout (_v)) >= _kA and !((_v) in _det) and (_ldr countEnemy [_v]) > 0) then { _det set [count _det, _v] } } forEach _enmUnits; ?(_debug and player in _uGrp): player globalchat format ["#Enemies detected by player group: %1", _det]; ~0.01 ; Find close friendly groups _closeGrps = []; { if (((vehicle leader (_x select 0)) distance (_vLdr)) <= _sMaxDist or (_grpRad and (_x select 1))) then { _closeGrps set [count _closeGrps, _x] } } forEach _sideGrps; ~0.01 ; Share detected array with close groups. Skip enemies beyond engagement distance of friendly group { _l = leader (_x select 0); _vL = vehicle _l; _engDist=_engDistInf; if(("LandVehicle" countType [_vL])==1)then{ _engDist=_engDistLand } else { if(("air" countType [_vL])==1)then{ _engDist=_engDistAir } else { if(("SmallShip" countType [_vL])==1)then{ _engDist=_engDistWater } } }; { _v = vehicle _x; if (((_v) distance _vL) <= _engDist) then { _l reveal (_v) } } forEach _det } forEach _closeGrps; #wait1 _c1 = _c1 + 1; ~0.05 ?(_c1 < count _sideGrps): goto "check"; #wait _c = _c + 1; ~0.1 ?(_c < count _sideArr): goto "checkAll"; ; Undefine vars _sideArr = nil; _sideGrps = nil; _enmGrps = nil; _enmUnits = nil; _grpArr = nil; _uGrp = nil; _det = nil; _ldr = nil; _c = nil; _c1 = nil; _l = nil; _u = nil; _grpRad = nil; _closeGrps = nil; _v = nil; _vL = nil; _engDist = nil; ~_wait goto "loop"; exit; ; ----------------- ; kINFOSHARE ; ----------------- ; ADVANCED INSTRUCTIONS: ; ; Parameters: ; - Array listing all units. This can be either a trigger list or a hand made array of units. Note that only units in this array will be able to detect AND be detected ; Default value: list allUnits ; - Array of maximum communication distances. First element: distance for west side; Second elem: for east; Third: for resistance; Fourth: for civilians ; - Array of radio classes recognized by this script. It will be an empty array as default ; ; USE: [<array of units>,<array of max distances>,<array of recognized radios>] exec "kInfoshare.sqs"; ; EXAMPLE: ["list allUnits",[4000,50,50,50],["ww4_radio"]] exec "kInfoshare.sqs"; ; ; You can leave parameters empty when calling the script, so the default values are used. ; This comes handy when you want to, say, keep the defaults of the array of units and radios but want to change the comm distances. ; To skip values and set defaults use: ; _arrUnits = "" ; _maxDist = [] ; _radioCl = [] ; For the mentioned example, you could use: ; ["",[200,200,200],[]] exec "kInfoshare.sqs"; ; or just: ; ["",[200,200,200]] exec "kInfoshare.sqs"; ; ; NOTES ON COMM DISTANCES: ; ; US army squads in the 80s had a AN/PRC-68 radio (walkie-talkie) with a range of about 5km, ; while soviets had to rely on an RTO or platoon leader carrying a P-159 VHF on their back. ; So, by default, all western units will have a far greater communication range than any other side. ; This can be edited by the user. ; ; Groups with a tank, plane or helicopter vehicle will be able to use that vehicle's radio to broadcast virtually anywhere. ; ----------------- ; ; Extra info: ; ; RANGES ; ; US: ; AN/PRC-77: 8km/16km - 50km ; AN/PRC-68: 3km - 5km ; ; USSR: ; P-159 VHF: 10km - 50km ; ; SINCGARS: 300m -35km ; AN/PRC-148: 6km - 30km ; ; ----------------- ; CHANGELOG ; - v1.2 ; * NEW: Added distance limits at which enemy units won't be reported depending on the type of group of the receiving friendly group (infantry, air, land or water vehicles). Editable in the SETTINGS area. ; * CHANGE: Removed requeriment to set comm distance for renegade groups (as it was unused anyway) ; - v1.1 ; * CHANGE: in2Darray function is now embeded in this script ; * CHANGE: revised parameter parsing and assignment of defaults ; * CHANGE: Expanded comments and descriptions ; - v1.0 ; * Initial release ; ----------------- Share this post Link to post Share on other sites
barccy 53 Posted December 23, 2017 Could you make an example user mission for infoshare? I don't think I've set it up right so far. Share this post Link to post Share on other sites