Vandeanson 1677 Posted August 22, 2018 (WIP) Weapon Attachment Trader Script for Ravage Fellow Ravagers, in case you want to be able to buy weapon attachments such as scopes, silencers, flashlight or laser pointers in your Ravage mission, in addition to the original Ravage traders, look no further;) Functions of the script - Spawns a trader at a marker position (multiple markers are possible if you want the trader to move around) - Matching attachments for weapons as defined per array - the first item the trader sells matches the players current weapon (if carrying any) - uses rvg_money as currency - checks if you have enough money and enough space in your inventory before you are able to buy an item - the base price per item is set at 90 with some randomization (per item sold) each time the script is triggered - currently the items sold refresh after you select "Back" in the scroll menu. Each time you press back you get to call for new items to be offered. - after successfully buying an item, the position will be removed from the scroll menue How to create, use and Install the script: Step 1 - init.sqf 1. Open notepad. 2. Copy this code -------> [] execVM "TraderspawnAtt.sqf"; 3. Paste the code into your notepad doc. 4. Save the notepad document with this name -----> init.sqf 5. Move the init.sqf to your mission folder. =================================== Note - if you already have an init.sqf then just add the code from 2 to it. init.sqf: Spoiler while {true} do { _traderspawn = selectRandom ["mrkrTR_1"]; // add more markers here, if you want your trader to "move arround". traders = createGroup west; trader1 = traders createUnit ["B_G_Survivor_F", getMarkerPos _traderspawn, [], 0, "NONE"]; [trader1] call rvg_fnc_equip; trader1 allowDamage false; trader1 disableAI "MOVE"; traderID0 = trader1 addAction ["Buy Attachements","AttachementsStore.sqf"]; sleep 3600; /// change timer in seconds before the trader respawns (may change position in case you added additional markers above. removeAllActions trader1; deleteVehicle trader1; sleep 5; }; Step 2 - Back.sqf 1. Open notepad. 2. Copy this code ------> from the spoiler below 3. Paste the code into your notepad doc. 4. Save the notepad document with this name ------> Back.sqf 5. Move the Back.sqf to your mission folder. ========================================= Back.sqf : Spoiler removeAllActions trader1; traderID0 = trader1 addAction ["Buy Attachements","AttachementsStore.sqf"]; Step 3 - TraderspawnAtt.sqf 1. Open notepad. 2. Copy this code ------> from the spoiler below 3. Paste the code into your notepad doc. 4. Save the notepad document with this name ------> TraderspawnAtt.sqf 5. Move the TraderspawnAtt.sqf to your mission folder. ========================================= TraderspawnAtt.sqf Spoiler WeaponArray = [ "Rusty_srifle_DMR_04_F", "Rusty_DMR_05_base_F", "Rusty_srifle_DMR_02_F", "Rusty_srifle_DMR_03_F", "Rusty_srifle_EBR_F", "Rusty_MMG_01_tan_F", "Rusty_MMG_02_black_F", "Rusty_LMG_Zafir_F" ]; // the Vendor will only sell Attachements that match at least one of the above weapons. To avoid errors, do not enter weapons that can not have attachements (e.g. WW2 weapons..) AttachementCosts = 90 +(selectrandom [0,1,2,3,4,5,6,7,8,9,10]); AttachementCosts1 = 90 +(selectrandom [0,1,2,3,4,5,6,7,8,9,10]); AttachementCosts2 = 90 +(selectrandom [0,1,2,3,4,5,6,7,8,9,10]); AttachementCosts3 = 90 +(selectrandom [0,1,2,3,4,5,6,7,8,9,10]); AttachementCosts4 = 90 +(selectrandom [0,1,2,3,4,5,6,7,8,9,10]); EquippedWeapons = weapons player; RndEquippedWeapon = selectRandom EquippedWeapons; RndWeapon = selectRandom WeaponArray;; //AttachementArray = RndWeapon call BIS_fnc_compatibleItems; AttachementArray = {_x call BIS_fnc_compatibleItems;} foreach WeaponArray; if ( weapons player isEqualTo [] ) then { Attachement = selectRandom AttachementArray; } else { persAttachementArray = RndEquippedWeapon call BIS_fnc_compatibleItems; Attachement = selectRandom persAttachementArray; }; Attachement1 = selectRandom AttachementArray; Attachement2 = selectRandom AttachementArray; Attachement3 = selectRandom AttachementArray; Attachement4 = selectRandom AttachementArray; traderID1 = trader1 addAction [format ["Buy %1 for %2",Attachement,AttachementCosts],"call BuyItem"]; traderID2 = trader1 addAction [format ["Buy %1 for %2",Attachement1,AttachementCosts1],"call BuyItem1"]; traderID3 = trader1 addAction [format ["Buy %1 for %2",Attachement2,AttachementCosts2],"call BuyItem2"]; traderID4 = trader1 addAction [format ["Buy %1 for %2",Attachement3,AttachementCosts3],"call BuyItem3"]; traderID5 = trader1 addAction [format ["Buy %1 for %2",Attachement4,AttachementCosts4],"call BuyItem4"]; traderID6 = trader1 addAction ["Back","Back.sqf"]; trader1 removeaction traderID0; BuyItem = { CurrentCash = {"rvg_money" == _x} count magazines player; if (CurrentCash >= AttachementCosts && player canAdd Attachement && player canAdd Attachement) then { for "_i" from 1 to (AttachementCosts) do { player removemagazine "rvg_money";}; player additem Attachement; hint format ["Bought %1", Attachement]; trader1 removeaction traderID1; } else { hint "Not enough money or not enough space in your inventory!"; }; }; BuyItem1 = { CurrentCash = {"rvg_money" == _x} count magazines player; if (CurrentCash >= AttachementCosts && player canAdd Attachement) then { for "_i" from 1 to (AttachementCosts) do { player removemagazine "rvg_money";}; player additem Attachement1; hint format ["Bought %1", Attachement1]; trader1 removeaction traderID2; } else { hint "Not enough money or not enough space in your inventory!"; }; }; BuyItem2 = { CurrentCash = {"rvg_money" == _x} count magazines player; if (CurrentCash >= AttachementCosts && player canAdd Attachement) then { for "_i" from 1 to (AttachementCosts) do { player removemagazine "rvg_money";}; player additem Attachement2; hint format ["Bought %1", Attachement2]; trader1 removeaction traderID3; } else { hint "Not enough money or not enough space in your inventory!"; }; }; BuyItem3 = { CurrentCash = {"rvg_money" == _x} count magazines player; if (CurrentCash >= AttachementCosts && player canAdd Attachement) then { for "_i" from 1 to (AttachementCosts) do { player removemagazine "rvg_money";}; player additem Attachement3; hint format ["Bought %1", Attachement3]; trader1 removeaction traderID4; } else { hint "Not enough money or not enough space in your inventory!"; }; }; BuyItem4 = { CurrentCash = {"rvg_money" == _x} count magazines player; if (CurrentCash >= AttachementCosts && player canAdd Attachement) then { for "_i" from 1 to (AttachementCosts) do { player removemagazine "rvg_money";}; player additem Attachement3; hint format ["Bought %1", Attachement4]; trader1 removeaction traderID5; } else { hint "Not enough money or not enough space in your inventory!"; }; }; OR: add custom items: If you want to define the attachments that may be sold by yourself, copy the below code into TraderspawnAtt.sqf instead of the above and add your attachment classnames in the array AttachementArray =["classname1","classname2"]; Spoiler AttachementCosts = 90 +(selectrandom [0,1,2,3,4,5,6,7,8,9,10]); AttachementCosts1 = 90 +(selectrandom [0,1,2,3,4,5,6,7,8,9,10]); AttachementCosts2 = 90 +(selectrandom [0,1,2,3,4,5,6,7,8,9,10]); AttachementCosts3 = 90 +(selectrandom [0,1,2,3,4,5,6,7,8,9,10]); AttachementCosts4 = 90 +(selectrandom [0,1,2,3,4,5,6,7,8,9,10]); AttachementArray = ["classname1","classname2"]; Attachement1 = selectRandom AttachementArray; Attachement2 = selectRandom AttachementArray; Attachement3 = selectRandom AttachementArray; Attachement4 = selectRandom AttachementArray; traderID1 = trader1 addAction [format ["Buy %1 for %2",Attachement,AttachementCosts],"call BuyItem"]; traderID2 = trader1 addAction [format ["Buy %1 for %2",Attachement1,AttachementCosts1],"call BuyItem1"]; traderID3 = trader1 addAction [format ["Buy %1 for %2",Attachement2,AttachementCosts2],"call BuyItem2"]; traderID4 = trader1 addAction [format ["Buy %1 for %2",Attachement3,AttachementCosts3],"call BuyItem3"]; traderID5 = trader1 addAction [format ["Buy %1 for %2",Attachement4,AttachementCosts4],"call BuyItem4"]; traderID6 = trader1 addAction ["Back","Back.sqf"]; trader1 removeaction traderID0; BuyItem = { CurrentCash = {"rvg_money" == _x} count magazines player; if (CurrentCash >= AttachementCosts && player canAdd Attachement && player canAdd Attachement) then { for "_i" from 1 to (AttachementCosts) do { player removemagazine "rvg_money";}; player additem Attachement; hint format ["Bought %1", Attachement]; trader1 removeaction traderID1; } else { hint "Not enough money or not enough space in your inventory!"; }; }; BuyItem1 = { CurrentCash = {"rvg_money" == _x} count magazines player; if (CurrentCash >= AttachementCosts && player canAdd Attachement) then { for "_i" from 1 to (AttachementCosts) do { player removemagazine "rvg_money";}; player additem Attachement1; hint format ["Bought %1", Attachement1]; trader1 removeaction traderID2; } else { hint "Not enough money or not enough space in your inventory!"; }; }; BuyItem2 = { CurrentCash = {"rvg_money" == _x} count magazines player; if (CurrentCash >= AttachementCosts && player canAdd Attachement) then { for "_i" from 1 to (AttachementCosts) do { player removemagazine "rvg_money";}; player additem Attachement2; hint format ["Bought %1", Attachement2]; trader1 removeaction traderID3; } else { hint "Not enough money or not enough space in your inventory!"; }; }; BuyItem3 = { CurrentCash = {"rvg_money" == _x} count magazines player; if (CurrentCash >= AttachementCosts && player canAdd Attachement) then { for "_i" from 1 to (AttachementCosts) do { player removemagazine "rvg_money";}; player additem Attachement3; hint format ["Bought %1", Attachement3]; trader1 removeaction traderID4; } else { hint "Not enough money or not enough space in your inventory!"; }; }; BuyItem4 = { CurrentCash = {"rvg_money" == _x} count magazines player; if (CurrentCash >= AttachementCosts && player canAdd Attachement) then { for "_i" from 1 to (AttachementCosts) do { player removemagazine "rvg_money";}; player additem Attachement3; hint format ["Bought %1", Attachement4]; trader1 removeaction traderID5; } else { hint "Not enough money or not enough space in your inventory!"; }; }; Script Dependencies: - Ravage mod is required to run this script - CBA (required by Ravage) Using the script without Ravage mod: If you want to use this without the Ravage and CBA mod, you would replace the currency ("rvg_money") with whatever classname of an item that you use as currency. Setting up the Script in the editor: 1. Start your mission via editor and place markers named: mrkrTR_1 2. To name a marker, add the above name into the Variable Names field like this: mrkrTR_1 Place your player and start your mission. Personalize the script - (additional markers) The trader will keep respawning at one location, if only one marker is placed. 1. To place more markers and achieve that the trader is "moving around", just add additional marker names under _traderspawn = [.....]. in the script. 2. The last marker needs to end without comma "mrkrTR_5"];. Leaving a comma at the end of the array "mrkrTR_5,"]; would not work. 3. Place the new markers on the map. Adding items The script selects Weapon Attachments based on randomly selected weapons from WeaponArray =[...]; Add remove weapons there to ensure attachments that match your weapons will spawn. To Dos: - find a way to sell back Weapon Attachments (to a lower price) - general code/script optimization and simplification - i might add some delay before the item list can be refreshed with "Back". - gather your input and change stuffs to make it better;) - MP not tested, happy to receive input on how to make this MP friendly Other stuff that is in the pipeline @ Vandeansons script factory: - Different Tier of traders connected to a reputation system (would be a separate script) - Vehicle trader (Planes, Helis, Cars,...) - currency exchange to allow for two different money systems (e.g. trader ravage currency versus the currency from HG Simple Shops) - Adaptation of the EDN_Fortification Base building mod to include it into your Ravage mission (spawn in collectible Blueprints, spawn in building materials, customize and add own blueprints) - Dynamic and infinite ongoing task generator connected to reward system (e.g. Money, equipment...) - tasks are either automatically assigned one after the other upon completion or document folders are spawned into in buildings around the player that, after collecting it, will assign a new task =================================== Changelog v.0.1 2018.08.22 - release of working version 2 1 Share this post Link to post Share on other sites
EO 11275 Posted August 22, 2018 Nice work Van, like the sound of that dynamic task generator. Good luck mate. 1 Share this post Link to post Share on other sites
Zakuaz 195 Posted August 22, 2018 Cool expansion on the traders goods. That dynamic task generator... I'm excited for that! IIRC, I dumped a long winded post on TPW and Haleks Ravage threads about some sort of task gen system. I'd hate to come off as desperate and pitch my idea to anyone who'd listen but I really would love to have that task gen system, a simple overlay you could apply to darn near any sandbox/survival scenario. So I hope I'm not stepping on any toes but here is a slightly modified copy paste from my post in TPW's thread about the idea: ""Something when toggled on, installed, loaded would set down an intel folder at a -marked- random location from the maps index of towns/poi's. Once the player picks up the intel folder it could auto set up a task objective of some sort based on a configurable set of criteria. Doing it this way would allow a player to run around with out a task being already generated, so the script is there when I first load in the game world BUT it doesn't create the task/tasks until I go to and retrieve the initial intel folder, that is when the task is generated. Configurable if possible? Two options for intel gathering type, 1= single document recovery, 2 = chain of intel recovery positions. Then you could also configure the style of intel, 1= classified document, 2= laptop, 3= device of some sort etc, 4= HVT, 5=Cache... Followed by the Intel briefing narrative, 1= Military "Command wants this intel recovered", 2= Survival "Possible stash location", 3= Zombie Survival "Information on the outbreak", 4= Kill HVT, 5= Clear town of bondits/zombies etc... and so on with what ever the imagination dreams up. These intel locations wouldn't be tied to any NPC spawns or conflicts...it is just an objective that overlays a players current scenario ( or lack there of like in Survivals). The beauty of it is that it spawns the intel obj over the top of lets say a RAVAGE mission, now I'm compelled to go see what this intel is in Elektro and just so happens I'll run into zombies ( Ravages ambient spawns) while I'm there. The idea came to mind while running around playing solo survival, shooting NPCs, looting and eating beans I thought "what if there was a little more substance as to why I'm going to travel across the map" A simple objective not placed by me could go a long way in the immersion IMO."" Man that is a lot sorry...maybe you should make its own thread for the dynamic task gen LOL. I'd be more then happy to delete this if you so desire, just let me know 1 1 Share this post Link to post Share on other sites
Vandeanson 1677 Posted August 23, 2018 Hola! indeed a separate thread will be comming;) but well, what you elaborated is pretty much what i am currently working on: 1. define a at least 3 sets of tasks, each set has a different activation logic behind it (WIP) 2. write tasks and the required scripts behind it (WIP for the first set) 3. connect to reward system (More or less done) Type of task sets: 1. sort of RPG game repetitive quests. (find this, search that, kill that guy, findout what happened to a missing friend, follow leads to a hidden stash) Activation: files or notes will spawn in player proximity (in houses), pick up the file and one random task from the first set of tasks is assigned and the script spawns in the probs for the quest in the region arround the player. this loops endlessly, a new file spawns once the previous task is completed. (WIP, just adding in tasks now) 2nd: i thought about having a guy sitting in his bunker giving you tasks to do from time to time over radio. so after you located him and maybe after completing an initial task for him, and while having a radio equipped, he will keep sending you things to do against a reward. these tasks will be a randomly selected task from the second set of tasks. (e.g. patrol area, mark crashed planes for scavenging, kill religious cult leader, sabotague power supplies of enemy survivors, find missing patrol) this loops endlessly.(not started) 3. set of tasks i was thinking about adding more of a story chain, sort of building up a main story, or atleast a template for for mission makers. this will either serve to build up background story and/or lead the player arround on the map, eg make him travel around (Not started) Reward system: (WIP more or less done) upon completing a task, one out of a set of rewards will be awarded (money, mags, items, weapons, weapon attachments, gear, maybe vehicles) either right into player inventory or a box will be spawned next to the player. I think such rewards should be exclusive things that do not spawn from the ravage equipment module settings, so you can set arrays of e.g. fancy protective gear you wish to spawn. Alternatively, i plan to connect this reward system to a basebuilding feature i am currently looking into. Basebuilding: (WIP, just adding in blueprints and a system to find blueprints on the map, also finalising the material spawner for building structures). I want to create an insentive for the player to find a hiding spot/base where he can return to or respawn from. there, he will have a specific lootbox where all task rewards will be spawned into and he can hord all his fancy loots;) Also, this would add the aspect , that you need to scavenge for building materials, collect such and move the vast amounts of bricks, wooden boards and steel back to your "construction site" with a vehicle as well as the need to cycle back to your base from time to time. I am working on an adaptation of the edn fortification mod that would allow the player to build a fancy base for himself. guards could be hired for money that guard the base while the player is on the road and i think it would be fun if sometimes bandits would attempt to raid the base and "steal " the players loot (so the player has to rush back and defend its base) but thats a side project and will be subject of a separate thread:) Note: - most of these features i have already working solution for (SP) - i learn scripting by trial and error and my scripts might be rather simple or clunky, and topics such as MP and JIP compabibility are not big on the agenda at the moment (although i am currently learning about MP Scripting) anyway, will kee you posted:) 3 Share this post Link to post Share on other sites
EO 11275 Posted August 23, 2018 2 hours ago, Vandeanson said: 2nd: i thought about having a guy sitting in his bunker giving you tasks to do from time to time over radio. so after you located him and maybe after completing an initial task for him, and while having a radio equipped, he will keep sending you things to do against a reward. these tasks will be a randomly selected task from the second set of tasks. (e.g. patrol area, mark crashed planes for scavenging, kill religious cult leader, sabotague power supplies of enemy survivors, find missing patrol) this loops endlessly.(not started) To me, this sounds like a great idea, Stalker vibe most definitely. Let's bring Sidorovich out of retirement... 1 1 Share this post Link to post Share on other sites
Vandeanson 1677 Posted August 23, 2018 Just now, EO said: To me, this sounds like a great idea, Stalker vibe most definitely. Let's bring Sidorovich out of retirement... haha i was looking for that name:)) exactly what i had in mind;) 1 Share this post Link to post Share on other sites
Zakuaz 195 Posted August 23, 2018 This sounds amazing and I love the task options. It feels like it would seamlessly integrate with or layer over the top of any survival or sandbox scenario. The ability for it to be flexible and non intrusive while you are wig splitting zombies is key IMO. while at the same time adding in that much welcomed / needed objective based motivation / gameplay. Ok I am probably getting too excited for this heh =) 1 1 Share this post Link to post Share on other sites
Vandeanson 1677 Posted August 23, 2018 35 minutes ago, Zakuaz said: This sounds amazing and I love the task options. It feels like it would seamlessly integrate with or layer over the top of any survival or sandbox scenario. The ability for it to be flexible and non intrusive while you are wig splitting zombies is key IMO. while at the same time adding in that much welcomed / needed objective based motivation / gameplay. Ok I am probably getting too excited for this heh =) Yep in the end it should be a few files that you move over into your mission folder and the script will do its magic. maybe with one or the other marker that needs to be placed + the ravage modules. I will stick to the vanilla arma assets + ravage as well to avoid dependencies. I will also try to make it as easy as possible for the user to add own tasks so this can be further extended, the more tasks exist in a task set, the less repetitive this gets=) Will see how well this project turns out=) 1 Share this post Link to post Share on other sites
johnnyboy 3789 Posted August 23, 2018 Sounds super cool VD (can I call you VD? haha). Keep up the great work man. I look forward to to seeing your end product. 2 Share this post Link to post Share on other sites
MuRaZorWitchKING 725 Posted August 25, 2018 @Vandeanson just wanna say I really enjoy your work and I use all your scripts offered in all my scenarios. You are the KING of scripts my friend, thanks for helping keep this Community amazing! Share this post Link to post Share on other sites
Vandeanson 1677 Posted August 27, 2018 On 26.8.2018 at 1:49 AM, MuRaZorWitchKING said: @Vandeanson just wanna say I really enjoy your work and I use all your scripts offered in all my scenarios. You are the KING of scripts my friend, thanks for helping keep this Community amazing! thanks man:) good to hear that the scripts do their job... more to come;) 1 Share this post Link to post Share on other sites
HereIsJones 20 Posted February 6, 2021 This looks like fun, but your code references "AttachementsStore.sqf" twice, and I can't find it anywhere. Can you point me to it? Sorry if it's obvious, I'm new to this game. Thanks! Share this post Link to post Share on other sites