Jump to content
Sign in to follow this  
thefinn

Considering making a weapons locker, but unsure how to start.

Recommended Posts

I'm pretty sure I can write what's needed to add weapons to it from another container, however, I'm not sure how to only allow this within a certain area around it.

For instance, player drives up and unloads a box of ammo from a truck next to the locker, how do I make the "gather" (or whatever) command know the box is within say 10 metres and therefore give the option on scroll wheel.

I'm just after an idea of how to do the area around the container itself.

Edited by thefinn

Share this post


Link to post
Share on other sites

That highly depends, if the box you want to transfer the weapons from is always the same, you could simply do it like this:

(_locker distance _box) <= 10

Or you could try something like this:

((position nearestObject [_locker, B_CargoNet_01_ammo_F"]) distance _locker) <= 10

Edited by R3vo

Share this post


Link to post
Share on other sites

It'd be more like finding a crate and then throwing it into a truck (via ALiVE logistics) and then bringing it back to base, unload it and "store weapons" (or whatever's in it) into an inventory that is then accessible (I'm considering using VAS) to equip yourself/teammates. (I'd use the BIS Arsenal, but I don't think you can limit the amount of a particular gun by however many are found and stored).

You can in fact already do this exact thing in Whole Lotta Altis, however, I cannot read his code for love nor money ;)

I already have a working loot system and can spawn AI with the best of them, I'm really just looking for a good way to do this for a more survivaly feeling.

Edited by thefinn

Share this post


Link to post
Share on other sites

Considering something along these lines.

Going to add the contents of the box to VAS (not transfer from one box to the other).

Any input helpful.

/* Array sent from addaction */
_supplies = _this select 0;
_caller = _this select 1;

/* Position of the main supply cache */
_pos = position _supplies;

/* Stuff is now an array of ammoboxes in 10 metres from the main supply cache */
_stuff = _pos nearSupplies 10;

/* Array of ammoboxes we accept */
_boxesworking = ["B_CargoNet_01_ammo_F"];

/* Step through all the ammoboxes in 10 metres and remove their contents, add contents to the supply cache */
for "_i" from 0 to {(count _stuff) -1) do {

};

Pretty sure I can do "remove object" from the crate ;)

However, I'm less sure how to -

1. start with an empty VAS but still accept gear.

2. add things to VAS "on the fly" so to speak, but also just add 1 gun/item at a time, without just unlocking unlimited amounts.

Any help appreciated by any VAS experts. :)

Edited by thefinn

Share this post


Link to post
Share on other sites

You can get ammo and weapons with these commands magazineCargo, weaponCargo. First clean the crate where you want to put stuff if wanted.

Clearmagazinecargo box1;

ClearWeaponcargo box1;

_w = weaponCargo box2;

_n = magazineCargo box2;

{_y = _x; box1 addweaponcargo [_x,1];} foreach _w;

{_y = _x; box1 addmagazinecargo [_x,1];} foreach _n;

Clearmagazinecargo box2;

ClearWeaponcargo box2;

You can find similar command for other items and backpacks here.

https://community.bistudio.com/wiki/Category:Scripting_Commands_Arma_3

If wanting to store stuff virtually, you would need arrays e.g. set in object or missionnamespace. E.g. make array myWeapons = []; in init.sqf, then during mission you can add weapons to it like:

{

_y = _x;

_n = 0;

{if (_x select 0 == _y) exitWith {myWeapons set [_foreachIndex, [_x select 0, (_x select 1) + 1]];_n = 1;};} foreach myWeapons;

if (_n == 0) then {myWeapons pushback [_x,1];};

} foreach _w;

myWeapons will then look like [["weaponclass1",amount],["weaponclass2",amount],...]

You can later e.g. move the content to crate with

{crate1 addweaponcargo _x;} foreach myWeapons;

myWeapons = [];

Or first weapon would be picked with;

_n = (myWeapons select 0);

_wClass = _n select 0;

if (_n select 1 > 1) the {myWeapons set [0, [_n select 0, (_n select 1) - 1]];} else {myWeapons deleteAt 0;};

Foreach, count, append and - are needed too when playing with arrays. It gets quite complex quick, but learned tricks are always usefull. ;) Let me know if something not working. Wrote the code without testing, but using similar methods myself. Only now spotted the weaponcargo command, have used getweaponcargo command myself which gives data more annoying way.

Edited by SaOk

Share this post


Link to post
Share on other sites

How would the player access them from the virtual array ?

This was the part I was kind of stuck on.

Tried getting VAS working, but it seems kinda broken at the moment and I couldn't see any way to limit the numbers of weapons available.

I don't think BIS Arsenal supports it at all either.

Edit: I suppose items with an amount >0 could be whitelisted?

But then I'm unsure how I'd take a weapon out of the list once someone uses it.

Like if there's 1 katiba in the VA, then someone uses a katiba, how do you know that to subtract one?

Edited by thefinn

Share this post


Link to post
Share on other sites

Understood bit wrong, you can find arsenal functions here:

https://community.bistudio.com/wiki/Arsenal

So weapon removing happens with:

[myBox,["arifle_MXC_F"],true] call BIS_fnc_removeVirtualWeaponCargo;

There is also functions to add gear to the virtual box. So e.g. change

{_y = _x; box1 addweaponcargo [_x,1];} foreach _w;

to

{[box1,_x] call BIS_fnc_addVirtualWeaponCargo;} foreach _w;

Share this post


Link to post
Share on other sites

Right sorry, I thought add virtual cargo was going to add an unlimited supply of the item when they added 1 item. ;)

You know all that _x _y variable stuff is why I cannot read your code right?

dw I'm not knocking it, I'm sure it's a lot faster than _this_gun or something ;)

Edited by thefinn

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
Sign in to follow this  

×