alanford 27 Posted December 20, 2014 How can I make the enemy Ai use a particular weapon set? (to be exact, the AK pack from toadie) I don't really want to edit each unit, I just want a blanket change to all the units. So all enemy units use AK's? (and their variants, so what was an autorifleman instead of using mk200 now uses rpk and so on...) The mission I want to edit is somewhere in siberia. It's a complex mission, so I don't really dare make any big changes. I just want a simple way that does not fuck with the scripting. http://forums.bistudio.com/showthread.php?179876-CP4-Somewhere-In-Siberia-Stalkers-Testers-wanted Can this be done? Cheers! Share this post Link to post Share on other sites
dreadedentity 278 Posted December 20, 2014 no, you need to script Share this post Link to post Share on other sites
IndeedPete 1038 Posted December 20, 2014 SiS co-dev here. Not sure if it's implemented in the latest SiS version but I wrote this piece of code a while ago to replace enemy weapons if Toadie's AKs are activated. if (isClass(configFile >> "CfgWeapons" >> "hlc_rifle_ak74")) then { // Check if one example AK from HLC Weapon pack exists. { if ((_x getVariable ["SURF_WeaponSwitch", false]) OR ((primaryWeapon _x) in ["SMG_02_F", "SMG_02_ACO_F", "SMG_02_ARCO_pointg_F"])) then { // Check if unit is assigned for weapon switch. _unit = _x; _primWeapon = primaryWeapon _unit; // Get old primary weapon. _possibleMagazines = getArray(configFile >> "CfgWeapons" >> _primWeapon >> "magazines"); // Get compatible magazine classes for old weapon. _count = {_x in _possibleMagazines} count (magazines _unit); // Count how many magazines the unit carries for its old weapon. _count = _count + 1; // Plus one for the currently loaded magazine. _newWeapon = ["hlc_rifle_ak74", "hlc_rifle_aks74", "hlc_rifle_aks74u", "hlc_rifle_ak47", "hlc_rifle_akm", "hlc_rifle_rpk", "hlc_rifle_ak12", "hlc_rifle_akmgl", "hlc_rifle_aks74_GL"] call BIS_fnc_selectRandom; // Pick new weapon from HLC package randomly. TODO: Adjust array of possible waepons. _newMagazine = (getArray(configFile >> "CfgWeapons" >> _newWeapon >> "magazines")) select 0; // Select compatible magazine class. _newMuzzles = getArray(configFile >> "CfgWeapons" >> _newWeapon >> "muzzles"); // Get all muzzles (to check if new weapon has grenade launcher). _unit removeWeapon _primWeapon; // Remove old weapon. {_unit removeMagazines _x} forEach _possibleMagazines; // Remove old magazines. (Only the ones that are related to the old weapon.) _unit addMagazines [_newMagazine, _count]; // Add new magazines. if (({_x in _newMuzzles} count ["hlc_GP30_AKS74", "hlc_GP25_AKM"]) > 0) then {_unit addMagazines ["hlc_VOG25_AK", (1 + (round(random 2)))]}; // If new weapon has grenade launcher add 1-3 grenades. TODO: Adjust amount. _unit addWeapon _newWeapon; // Add new weapon. _unit selectWeapon _newWeapon; // Select new weapon. }; } forEach allUnits; // Run for all units. }; DePBOing and adding this to the init.sqf should do the trick. Could swear we've published a version already supporting this feature... ---------- Post added at 03:46 PM ---------- Previous post was at 03:45 PM ---------- Oh, and you might want to run it server-side only if you intend to play it in COOP. Share this post Link to post Share on other sites
alanford 27 Posted December 20, 2014 Whoah! Massive thanks! Yeah, it might just already be implemented. I dont know, since i have not yet played it with hlc. Ill depbo and check either way. Running the mission on a dedicated server did not work for me. It just looped on "mission read from bank" message. Share this post Link to post Share on other sites
IndeedPete 1038 Posted December 20, 2014 It's not made for dedicated anyway. MP editing is hard as it is, dedis don't make it easier. Good luck! Share this post Link to post Share on other sites
alanford 27 Posted December 20, 2014 Right, but you still suggest I run it on a dedicated? Or what did you mean by "Oh, and you might want to run it server-side only if you intend to play it in COOP." Share this post Link to post Share on other sites
IndeedPete 1038 Posted December 20, 2014 No, I'd advise against dedi. I just meant to enclose the code between an if (isServer) then {CODE}; Share this post Link to post Share on other sites
dreadedentity 278 Posted December 20, 2014 @IndeedPete I like this line from your code: isClass(configFile >> "CfgWeapons" >> "hlc_rifle_ak74") For some reason activatedAddons doesn't work, at least when I tried last night (only listed dev-created pbo's), but I saw that you can use the same method with CfgPatches to check if an addon is activated: isClass(configFile >> "CfgPatches" >> "YOUR_MOD_NAME_AS_IT'S_LISTED_IN_CFGPATCHES") An extremely minor change, it really doesn't do anything extra from what you've already got, I just think it's a little cleaner Share this post Link to post Share on other sites
IndeedPete 1038 Posted December 20, 2014 Yes, that's true. This piece of code was a quick copypaste from my missions folder. It's a few months old. In more recent checks (e.g. for TPW scripts) I use CfgPatches. But my shop system supports multiple third party packs, hence I perform checks for every single item before it's listed. It avoids errors when mod creators remove or change stuff and I miss something. ---------- Post added at 08:19 PM ---------- Previous post was at 08:16 PM ---------- Checks like these are a nice way to allow third party content without forcing it. Something that should be expanded by someone (BIS?) in my opinion. Share this post Link to post Share on other sites
dreadedentity 278 Posted December 20, 2014 Checks like these are a nice way to allow third party content without forcing it. I agree, I'll be using a similar snippet for my next release, whenever I finish the new feature, and finish debugging (everything works, but there's one really nasty bug I can't figure out how to fix. It doesn't even break anything, just makes a "config not found" popup) Something that should be expanded by someone (BIS?) in my opinion. Probably BIS, I mean we're not really obligated to do anything lol, but they've got so much on their plate already Share this post Link to post Share on other sites
IndeedPete 1038 Posted December 20, 2014 isClass checks usually prevent the config not found errors, maybe you still have some left over piece of code causing that stuff. Well, many of the basic features of the engine seem to date back to OFP days and it's about damn time to bring them to the next decade. The outdated and non-flexible side/faction system for example. But also the hardcoded addon dependencies. Maybe some kind of a modular approach or a decent framework could allow mission creators to make mod content optional. I.e. like with DLCs in other games where the extra missions only show up when the DLC is running but don't cause troubles for people who haven't bought it. So players with different mod configurations can play the same mission. Of course, some addons like maps can't be made optional for a scenario that takes place on this particular map. Anyway, I fear we don't have enough standards in the community or at least common interfaces to do so but it's a nice idea for the future.^^ Share this post Link to post Share on other sites