Jump to content
killermanny9

How to make random loot .sqf?

Recommended Posts

Hello, Ive been working on a MP mission but I want random loot to spawn in buildings like how you would see on dayz or epoch. Ive already tried some scripts out but none had what I needed, or I couldnt wrap my head around the workings to make it what I need. Sadly I am having some troubles trying to change things up a bit, I just do not know how to make it spawn anything other than just weapons and Ive tried a lot of different ways but I'm pretty much a noob to arma scripting. Thanks for any help. I'm very grateful. I'm sorry if it is a lot or to demanding. I will appreciate what I can get.

 

List of what I'm trying to get out of it

  • Random loot spawns on floor in buildings (I tried creating an itemBox and setPos (0,0,0) method. worked exactly how I wanted.)
  • Ability to select which weapons are spawning in an Array and have a random count of the mags spawn with it (I managed to get this at one point but didnt know how to randomize mag spawn count.)
  • Having clothing/accessory and item spawns the same way as weapons but not seperately. (I could never figure out how to mix these arrays in along with the weapons array spawn, so that it is not just a million spawns of ONLY weapons.  Also trying to make a mission on tanoa so I'm trying to mostly use only apex clothing if possible)
  • Configurable loot spawn chance for a select of weapons in the weapons array. (Im actually trying to get this for both clothing and items too, but im sure I can most likely convert it over to them myself. I just cant figure out a script for it.)

 

 

  • Like 1

Share this post


Link to post
Share on other sites
6 hours ago, killermanny9 said:

(I managed to get this at one point but didnt know how to randomize mag spawn count.)

_box addMagazineCargo ["MagName", 1 + random(20)];

 

Show us the code you already have, that's easier for us. 

Share this post


Link to post
Share on other sites

You can join me on discord and i can show you how to either use my mods loot spawner (it does all that you describe) or help you create your own script. 

 

https://discord.gg/SAFysz8

 

(i think/hope i am not breaching forum guidelines with posting a link) 

 

Cheers

Vd

  • Like 1

Share this post


Link to post
Share on other sites

Maybe something like that (made it on my mobile, sry 🙂 ):

 

if (isserver) then
{

_buildings = nearestTerrainObjects [player, ["House"], 10000];

{
_chance = floor (random 100);

if (_chance <= 50) then
{
_pos = [_x] call BIS_fnc_buildingPositions;

if (count _pos > 0) then
{
_box = createVehicle ["<YOURLOOT>",selectrandom _pos , [], 0, "NONE"];
};

};

} foreach _buildings;

};

Share this post


Link to post
Share on other sites

I think first you would need to create a "groundweaponholder" and then additemcargoglobal into that gwh. 

 

So YOURLOOT must be "groundweaponholder". 

 

Then you can do

 

_box additemcargoglobal ["classname", 1] ; (doublecheck that code pls) 

 

Or the adequate commands for weapons gear and magazines. 

 

Cheers

Vd

Share this post


Link to post
Share on other sites
On 10/11/2019 at 6:05 AM, killermanny9 said:

List of what I'm trying to get out of it

 

Hello there killermanny9 !

 

Do you want to take a look here :

 

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×