Jump to content
Sign in to follow this  
phant

Best method for saving what equipment is in a supply crate, to carry across missions

Recommended Posts

Hi there,

So for some context, I am making a campaign where the players are insurgents retaking an already fully occupied island. They are not given ANY supplies except for what they spawn in with on the first mission, and a few supply crates to store supplies that they raid. They must raid enemy supplies to build up their own supplies. This campaign will involve a fair bit of manual work on my behalf, as it won't be a single mission, it will be spread over several missions, but I want to keep what is in the ammo crates persistent, without writing down what's in it and then manually putting that in.

So, what is the best method for me to carry across/save equipment that is dumped in a supply crate and load that into any supply crate in a proceeding mission? Keeping in mind I would have to 'export' what is in the crate at the end of a mission, before finalising it.

Cheers,

Phant

Share this post


Link to post
Share on other sites

Hi,

Just to clear up on things, next time please mention what you have said above in your previous post. Its best to have everything your going to say in one thread rather multiple threads. :)

Share this post


Link to post
Share on other sites
Hi,

Just to clear up on things, next time please mention what you have said above in your previous post. Its best to have everything your going to say in one thread rather multiple threads. :)

The two threads are in no way related (each question is pertaining to a completely different mission (thus the context in this thread is not relevant to my other thread)) and would likely be too convoluted to include questions for 2 completely different scenarios in one thread, but I'll keep that in mind.

Share this post


Link to post
Share on other sites

Have a look at the Pool commands, I believe that is what they are for although i have never used them myself. Maybe one of the other members here like IndeedPete or Kydoimos who do campaign missions will know if/how they work.

Share this post


Link to post
Share on other sites

Saving and altering an individual unit's gear already answered here: http://forums.bistudio.com/showthread.php?192275-make-player-have-his-weapons-in-the-next-mission-%28CAMPAIGN%29&p=2945204#post2945204

Saving boxes can be done by two simple scripts. (Cutouts from existing scripts, might not work right away.)

On mission end:

#define ADD(X) _toSave pushBack X;
#define BOX(X) [CLUSTER(weaponCargo X), CLUSTER(magazineCargo X), CLUSTER(itemCargo X), CLUSTER(backpackCargo X)]
#define CLUSTER(X) (X call _clusterArray)

private ["_clusterArray", "_toSave"];
_clusterArray = {
private ["_array", "_list", "_clusteredArray"];
_array = _this;
_list = [];
_clusteredArray = [];

{
	_entry = _x;
	if (!(_entry in _list)) then {
		_list = _list + [_entry];
		_count = {_x == _entry} count _array;
		_clusteredArray = _clusteredArray + [[_entry, _count]];
	};
} forEach _array;

_clusteredArray
};

_toSave = [];

if (!(isNil "TAG_WeaponBox")) then {
TAG_CMP_WeaponBox = BOX(TAG_WeaponBox);
ADD("TAG_CMP_WeaponBox")
};

if (!(isNil "TAG_AmmoBox")) then {
TAG_CMP_AmmoBox = BOX(TAG_AmmoBox);
ADD("TAG_CMP_AmmoBox")
};

if (!(isNil "TAG_MiscBox")) then {
TAG_CMP_MiscBox = BOX(TAG_MiscBox);
ADD("TAG_CMP_MiscBox")
};

{saveVar _x} forEach _toSave;

On next mission start:

if (!(isNil "TAG_WeaponBox") && !(isNil "TAG_CMP_WeaponBox")) then {
{TAG_WeaponBox addWeaponCargo _x} forEach (TAG_CMP_WeaponBox select 0);
{TAG_WeaponBox addMagazineCargo _x} forEach (TAG_CMP_WeaponBox select 1);
{TAG_WeaponBox addItemCargo _x} forEach (TAG_CMP_WeaponBox select 2);
{TAG_WeaponBox addBackpackCargo _x} forEach (TAG_CMP_WeaponBox select 3);
};

if (!(isNil "TAG_AmmoBox") && !(isNil "TAG_CMP_AmmoBox")) then {
{TAG_AmmoBox addWeaponCargo _x} forEach (TAG_CMP_AmmoBox select 0);
{TAG_AmmoBox addMagazineCargo _x} forEach (TAG_CMP_AmmoBox select 1);
{TAG_AmmoBox addItemCargo _x} forEach (TAG_CMP_AmmoBox select 2);
{TAG_AmmoBox addBackpackCargo _x} forEach (TAG_CMP_AmmoBox select 3);
};

if (!(isNil "TAG_MiscBox") && !(isNil "TAG_CMP_MiscBox")) then {
{TAG_MiscBox addWeaponCargo _x} forEach (TAG_CMP_MiscBox select 0);
{TAG_MiscBox addMagazineCargo _x} forEach (TAG_CMP_MiscBox select 1);
{TAG_MiscBox addItemCargo _x} forEach (TAG_CMP_MiscBox select 2);
{TAG_MiscBox addBackpackCargo _x} forEach (TAG_CMP_MiscBox select 3);
};

Make sure your boxes exist, are named correctly and are empty on mission start.

Share this post


Link to post
Share on other sites

Thanks for the info Pete. Am I to run these scripts as a .sqf in the mission (if this is the case I'm assuming I'd have to call the script via debug menu?). And perusing the mission end script, I don't understand where the loadouts are actually being saved to?

I'm a newbie at this, so go easy on me.

Share this post


Link to post
Share on other sites

Yes, you can run them as any other script in .SQF format. But not via debug menu. You could call the one on mission start from your init.sqf(s). I assume you have already heard about these eventscripts (init.sqf, serverInit.sqf, missionFlow.fsm etc.). If not, a list is available here. As for the stuff that should happen on mission end: It's up to you how to implement that but I'd suggest to make it your very last script before BIS_fnc_endMission. You could call it from a trigger for example.

Edited by IndeedPete

Share this post


Link to post
Share on other sites

Thanks for the help, I'll do some reading.

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  

×