Jump to content

[Help] change/add crate loot


Tom

Recommended Posts

Hello :)

 

i use a lootspawner script so spawn some crates in different buildings..

 

So.. i open the crates but they contains no loot...

My mate added the LS script.. so i don´t know which script he used..

But i think it was the LS script which spawns more weapons too (@MAS)

 

I want to add new items to this crates but i cant find the file where the loot is defined...

 

Crates:

Box_East_Wps_F
Box_East_Ammo_F
Box_NATO_Wps_F
Box_NATO_Ammo_F
Box_IND_Grenades_F
 
 
How can i spawn random Weapons, Ammo, Items, and so on... in this crates?
 
Please excuse my bad english..
Hope you understand my problem :)
 
Best regards
 
Tom :)

 

Link to comment
Share on other sites

It will. and they will be random, with or without markers etc.. Everything is configurabe, just give it a shot !

 

You can easily copy/paste the loop, to spawn different crates with different content also !!

 

Just do 3 times a loop of 2, spawning 6 random crates over the island etc.

Link to comment
Share on other sites

hmm actually i want to add stuff in the existing crates... the lootspawner script alreadys spawns crates in the locations i want..
But the crates are empty..
i dont need even more crates^^
 
I like your pbo.. but i dont need it in this case..
 
 
i think i have to add few new lines in my existing script...
in one of this scripts:

 

 

// Lootspawner spawn script
// Author: Na_Palm (BIS forums)
//-------------------------------------------------------------------------------------
//local to Server Var. "BuildingLoot" array of [state, time], placed on buildings that can spawn loot
// state: 0-not assigned, 1-has loot, 2-currently in use/blockaded
// time : timestamp of last spawn
//
//local to Server Var. "Lootready" time, placed on generated lootobject, needed for removing old loot
// time: timestamp of spawn, object is ready for use by player and loot deleter
//-------------------------------------------------------------------------------------
private["_begintime","_BaP_list","_spInterval","_chfullfuel","_chpSpot","_genZadjust","_BaPname","_lootClass","_buildPosViable_list","_buildPosZadj_list","_lBuildVar","_posviablecount","_spwnPos","_lootspawned","_randChance","_lootholder","_selecteditem","_loot","_chfullf","_idx_sBlist","_chperSpot","_tmpPos"];
 
//BaP - Buildings around Player
_BaP_list = _this select 0;
_spInterval = _this select 1;
_chfullfuel = _this select 2;
_genZadjust = _this select 3;
_chpSpot = _this select 4;
 
_begintime = time;
{
_BaPname = "";
_lootClass = 0;
_buildPosViable_list = [];
_buildPosZadj_list = [];
_lBuildVar = (_x getVariable ["BuildingLoot", [0, 0]]);
//diag_log format["-- LOOTSPAWNER DEBUG BaP _lBuildVar: v%1v v%2v --", _lBuildVar ,_x];
if ((_lBuildVar select 0) < 2) then {
//flag immediately as in use
_x setVariable ["BuildingLoot", [2, (_lBuildVar select 1)]];
if (((_lBuildVar select 1) == 0) || ((time - (_lBuildVar select 1)) > _spInterval)) then {
//get building class
_BaPname = typeOf _x;
//here an other _x
{
//if junction found, get lists and -> exit forEach
if (_BaPname == (_x select 0)) exitWith {
_lootClass = (_x select 1);
//get viable positions Idx
_buildPosViable_list set [count _buildPosViable_list, ((Buildingpositions_list select _forEachIndex) select 1)];
if (swSpZadjust) then {
//get position adjustments
_buildPosZadj_list set [count _buildPosZadj_list, ((Buildingpositions_list select _forEachIndex) select 2)];
};
};
sleep 0.001;
}forEach Buildingstoloot_list;
//diag_log format["-- LOOTSPAWNER DEBUG BaP: v%1v%2v :: v%3v :: v%4v --", _BaPname, _lootClass, _buildPosViable_list, _buildPosZadj_list];
//get spawn position, here the former _x
_posviablecount = 0;
for "_poscount" from 0 to 100 do {
//check if position is viable
if (_poscount == ((_buildPosViable_list select 0) select _posviablecount)) then {
_posviablecount = _posviablecount +1;
//consider chance per Slot
if ((floor random 100) < _chpSpot) then {
_spwnPos = (_x buildingPos _poscount);
_tmpPos = [(_spwnPos select 0), (_spwnPos select 1), 60000];
if ((_spwnPos select 0) == 0 && (_spwnPos select 1) == 0) then {
_spwnPos = getPosATL _x;
_tmpPos = [(_spwnPos select 0), (_spwnPos select 1), 60000];
};
if (swSpZadjust) then {
_spwnPos = [_spwnPos select 0, _spwnPos select 1, (_spwnPos select 2) + ((_buildPosZadj_list select 0) select _poscount)];
};
//generally add 0.1 on z
_spwnPos = [_spwnPos select 0, _spwnPos select 1, (_spwnPos select 2) + _genZadjust];
//check if position has old loot
if ((count (nearestObjects [_spwnPos, LSusedclass_list, 0.5])) == 0) then {
sleep 0.001;
//check what type of loot to spawn
_lootspawned = false;
for "_lootType" from 1 to 5 do {
//get chance for loot every time, so all combos in spawnClassChance_list are viable
_randChance = floor(random(100));
if (((spawnClassChance_list select _lootClass) select _lootType) > _randChance) then {
_lootspawned = true;
//special for weapons
if(_lootType == 1) exitWith {
_lootholder = createVehicle ["GroundWeaponHolder", _tmpPos, [], 0, "CAN_COLLIDE"];
_selecteditem = (floor(random(count((lootWeapon_list select _lootClass) select 1))));
_loot = (((lootWeapon_list select _lootClass) select 1) select _selecteditem);
_lootholder addWeaponCargoGlobal [_loot, 1];
_lootholder setdir (random 360);
_lootholder setPosATL _spwnPos;
};
//special for magazines: spawn 1-6
if(_lootType == 2) exitWith {
_lootholder = createVehicle ["GroundWeaponHolder", _tmpPos, [], 0, "CAN_COLLIDE"];
_randChance = 1 + floor(random(5));
for "_rm" from 0 to _randChance do {
_selecteditem = (floor(random(count((lootMagazine_list select _lootClass) select 1))));
_loot = (((lootMagazine_list select _lootClass) select 1) select _selecteditem);
_lootholder addMagazineCargoGlobal [_loot, 1];
};
_lootholder setdir (random 360);
_lootholder setPosATL _spwnPos;
};
//special for item/cloth/vests
if(_lootType == 3) exitWith {
_lootholder = createVehicle ["GroundWeaponHolder", _tmpPos, [], 0, "CAN_COLLIDE"];
_selecteditem = (floor(random(count((lootItem_list select _lootClass) select 1))));
_loot = (((lootItem_list select _lootClass) select 1) select _selecteditem);
_lootholder addItemCargoGlobal [_loot, 1];
_lootholder setdir (random 360);
_lootholder setPosATL _spwnPos;
};
//special for backpacks
if(_lootType == 4) exitWith {
_lootholder = createVehicle ["GroundWeaponHolder", _tmpPos, [], 0, "CAN_COLLIDE"];
_selecteditem = (floor(random(count((lootBackpack_list select _lootClass) select 1))));
_loot = (((lootBackpack_list select _lootClass) select 1) select _selecteditem);
_lootholder addBackpackCargoGlobal [_loot, 1];
_lootholder setdir (random 360);
_lootholder setPosATL _spwnPos;
};
//special for world objects: account for Wasteland and other items
if(_lootType == 5) exitWith {
_selecteditem = (floor(random(count((lootworldObject_list select _lootClass) select 1))));
_loot = (((lootworldObject_list select _lootClass) select 1) select _selecteditem);
_lootholder = createVehicle [_loot, _tmpPos, [], 0, "CAN_COLLIDE"];
if(_loot == "Land_CanisterFuel_F") then {
_chfullf = (random 100);
if (_chfullfuel > _chfullf) then {
_lootholder setVariable["mf_item_id", "jerrycanfull", true];
} else {
_lootholder setVariable["mf_item_id", "jerrycanempty", true];
};
};
if(_loot == "Land_CanisterOil_F") then {
_lootholder setVariable["mf_item_id", "syphonhose", true];
};
if(_loot == "Land_Can_V3_F") then {
_lootholder setVariable["mf_item_id", "energydrink", true];
};
if(_loot == "Land_Basket_F") then {
_lootholder setVariable["mf_item_id", "cannedfood", true];
};
if(_loot == "Land_CanisterPlastic_F") then {
_lootholder setVariable["mf_item_id", "water", true];
};
if(_loot == "Land_Suitcase_F") then {
_lootholder setVariable["mf_item_id", "repairkit", true];
};
//if container clear its cargo
if (({_x == _loot} count exclcontainer_list) > 0) then {
clearWeaponCargoGlobal _lootholder;
clearMagazineCargoGlobal _lootholder;
clearBackpackCargoGlobal _lootholder;
clearItemCargoGlobal _lootholder;
};
_lootholder setdir (random 360);
_lootholder setPosATL _spwnPos;
};
};
//1 category loot only per place so -> exit For
//no lootpiling
if (_lootspawned) exitWith {
_lootholder setVariable ["Lootready", time];
};
};
};
};
};
//if all viable positions run through -> exit For
if (_posviablecount == (count (_buildPosViable_list select 0))) exitWith {};
};
//release building with new timestamp
_x setVariable ["BuildingLoot", [1, time]];
} else {
//release building with old timestamp
_x setVariable ["BuildingLoot", [1, (_lBuildVar select 1)]];
};
};
sleep 0.001;
}forEach _BaP_list;
//diag_log format["-- LOOTSPAWNER DEBUG BaP: %1 buildings ready, needed %2s, EXIT now --", (count _BaP_list), (time - _begintime)];

 

 

// Lootspawner setup and control script
// Author: Na_Palm (BIS forums)
// credit to: Ed! (404Forums) and [GoT] JoSchaap (GoT2DayZ.nl) for initial script
//-------------------------------------------------------------------------------------
if (!isServer) exitwith {};
private["_buildingname","_chfullfuel","_chperSpot","_class","_dbgloopTime","_dbgloopTimeplU","_dbgTime","_dbgTurns","_dbgTurnsplU","_endloop","_genZadjust","_hndl","_item","_nearLootdist","_pos","_posAdjustZ","_posAdjustZlist","_poscount","_posIdxlist","_posnew","_posOrg","_posViable","_randomweapontestint","_spawnradius","_spInterval","_testpos","_tmpBuild","_tmpPoslist","_tmpTstPlace","_z"];
//-------------------------------------------------------------------------------------
//Switch
swDebugLS = false; //Debug messages on/off
swSpZadjust = false; //needed for ArmA 2 and older Maps/Buildings -> true
 
//-------------------------------------------------------------------------------------
//Variables
//local
_spawnradius = 80; //Radius (in meter) around players to spawn loot
_spInterval = 900; //Time (in sec.) to pass before an building spawns new loot
_chfullfuel = 35; //Chance (in %) of a spawned fuelcan to be full instead of empty
_genZadjust = -0.1; //High adjustment (in engine units) thats generally added to every spawnpoint
_tmpTstPlace = [14730, 16276, 0]; //Coord's, in [x,y,z] of a preferably flat and unocupied piece of land
_chperSpot = 75; //Chance (in %) if a spot gets loot. Will be considered before 'spawnClassChance_list'
 
//"spawnClassChance_list" array of [class, %weapon, %magazine, %ICV, %backpack, %object]
// class   : same classname as used in "Buildingstoloot_list"
// %weapon : % chance to spawn a weapon on spot
// %magazine : % chance to spawn magazines on spot
// %ICV   : % chance to spawn item/cloth/vests on spot
// %backpack : % chance to spawn a backpack on spot
// %object : % chance to spawn an world object on spot
//-------------- A VALUE OF '-1' RESULTS IN NO LOOT FOR THIS CLASS AND TYPE ----------------
spawnClassChance_list = [
[0, 13, 16, 20, 16, 22], // civil
[1, 22, 36, 28, 26, 18], // military
[2, 10, 21, 28, 26, 36], // industrial
[3, 12, 36, 36, -1, -1] // research
];
 
//"exclcontainer_list" single array of container classnames to NOT to delete if filled
exclcontainer_list = [
"Box_East_Ammo_F", "Box_East_AmmoOrd_F", "Box_East_AmmoVeh_F", "Box_East_Grenades_F", "Box_East_Support_F",
"Box_East_Wps_F", "Box_East_WpsLaunch_F", "Box_East_WpsSpecial_F",
"Box_IND_Ammo_F", "Box_IND_AmmoOrd_F", "Box_IND_AmmoVeh_F", "Box_IND_Grenades_F", "Box_IND_Support_F",
"Box_IND_Wps_F", "Box_IND_WpsLaunch_F", "Box_IND_WpsSpecial_F",
"Box_NATO_Ammo_F", "Box_NATO_AmmoOrd_F", "Box_NATO_AmmoVeh_F", "Box_NATO_Grenades_F", "Box_NATO_Support_F",
"Box_NATO_Wps_F", "Box_NATO_WpsLaunch_F", "Box_NATO_WpsSpecial_F"
];
 
//-------------------------------------------------------------------------------------
//DONT change these, will be filled in MAIN -------------------------------------------
spawnBuilding_list = [];
Buildingpositions_list = [];
LSusedclass_list = ["GroundWeaponHolder"];
//DONT change these, will be filled in MAIN -------------------------------------------
//-------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------
//Buildings that can spawn loot go in this list
#include "LSlootBuildings.sqf"
//Loot goes in these lists
#include "LSlootLists.sqf"
 
//-------------------------------------------------------------------------------------
//function only runs once on beginning of mission, not really needs a compile 
//fill spawnBuilding_list with buildingnames only
getListBuildingnames = {
{
spawnBuilding_list set [count spawnBuilding_list, (_x select 0)];
//diag_log format["-- LOOTSPAWNER DEBUG add to spawnBuilding_list: %1 ", (_x select 0)];
}forEach Buildingstoloot_list;
};
 
//-------------------------------------------------------------------------------------
//function only runs once on beginning of mission, not really needs a compile 
//get list of all Lootspawner generatable 'Worldobjects'
getUsedclasses = {
for "_class" from 0 to ((count lootworldObject_list) - 1) do {
for "_item" from 0 to ((count ((lootworldObject_list select _class) select 1)) - 1) do {
if !((((lootworldObject_list select _class) select 1) select _item) in LSusedclass_list) then {
LSusedclass_list set [count LSusedclass_list, (((lootworldObject_list select _class) select 1) select _item)];
};
sleep 0.001;
};
sleep 0.001;
};
};
 
//-------------------------------------------------------------------------------------
//function only runs once on beginning of mission, not really needs a compile 
//fill Buildingpositions_list with [_buildingname, [_posIdxlist], [_posAdjustZlist]] 
getListBuildingPositionjunction = {
_tmpTstPlace = _this select 0;
_randomweapontestint = 0.01; //Sets the highintervals in which weaponpositions are tested. (Lower = slower, but more accurate. Higher = faster, but less accurate.)
_nearLootdist = 0.5;
{
_buildingname = _x;
_tmpBuild = _buildingname createVehicleLocal _tmpTstPlace;
//check if the creation was successful
if (isNil {_tmpBuild}) then {
diag_log format["--!!ERROR!! LOOTSPAWNER in Buildingstoloot_list: %1 no viable object !!ERROR!!--", _buildingname];
} else {
//get spawnpositions from building
_poscount = 0;
_posAdjustZlist = [];
_posIdxlist = [];
_tmpPoslist = [];
_endloop = false;
while {!_endloop} do {
if((((_tmpBuild buildingPos _poscount) select 0) != 0) && (((_tmpBuild buildingPos _poscount) select 1) != 0)) then {
//counter loot piling
_pos = _tmpBuild buildingPos _poscount;
_posOrg = _pos;
_posViable = false;
if (_poscount != 0) then {
{
if ((_pos distance _x) > _nearLootdist) exitWith {
_posViable = true;
};
}forEach _tmpPoslist;
} else {
_posViable = true;
};
_tmpPoslist set [count _tmpPoslist, _pos];
//get Z adjustment for position
if (_posViable) then {
_posIdxlist set [count _posIdxlist, _poscount];
_posAdjustZ = 0;
if (swSpZadjust) then {
if(_pos select 2 < 0) then {
_pos = [_pos select 0, _pos select 1, 1];
};
_z = 0;
_posnew = _pos;
_testpos = true;
while {_testpos} do 
{
if((!lineIntersects[ATLtoASL(_pos), ATLtoASL([_pos select 0, _pos select 1, (_pos select 2) - (_randomweapontestint * _z)])]) && (!terrainIntersect[(_pos), ([_pos select 0, _pos select 1, (_pos select 2) - (_randomweapontestint * _z)])]) && (_pos select 2 > 0)) then {
_posnew = [_pos select 0, _pos select 1, (_pos select 2) - (_randomweapontestint * _z)];
_z = _z + 1;
} else {
_testpos = false;
};
};
_posnew = [_posnew select 0, _posnew select 1, (_posnew select 2) + 0.05];
_posAdjustZ = (_posOrg select 2) - (_posnew select 2);
// diag_log format["-- LOOTSPAWNER DEBUG adjusted %1 times", _z];
_posAdjustZlist set [count _posAdjustZlist, _posAdjustZ];
} else {
_posAdjustZlist set [count _posAdjustZlist, _posAdjustZ];
};
};
_poscount = _poscount + 1;
} else {
_endloop = true;
};
};
//save final position Index & adjustments to list
if (_poscount != 0) then {
//diag_log format["-- LOOTSPAWNER DEBUG add to Buildingpositions_list: v%1v v%2v v%3v added", _buildingname, _posIdxlist, _posAdjustZlist];
Buildingpositions_list set [count Buildingpositions_list, [_buildingname, _posIdxlist, _posAdjustZlist]];
} else {
diag_log format["-- !!LOOTSPAWNER WARNING!! in Buildingstoloot_list: %1 has no building positions --", _buildingname];
Buildingpositions_list set [count Buildingpositions_list, [_buildingname, [0], [0]]];
};
};
deleteVehicle _tmpBuild;
}forEach spawnBuilding_list;
};
 
//-------------------------------------------------------------------------------------
// MAIN
//-------------------------------------------------------------------------------------
diag_log format["-- LOOTSPAWNER initialise ------------------------"];
if ((count Buildingstoloot_list) == 0) then {
diag_log format["--!!ERROR!! LOOTSPAWNER Buildingstoloot_list in lootBuildings.sqf MUST have one entry at least !!ERROR!!--"];
diag_log format["-- LOOTSPAWNER disabled --"];
} else {
_dbgTime = time;
_hndl = [] spawn getListBuildingnames;
waitUntil{scriptDone _hndl};
diag_log format["-- LOOTSPAWNER spawnBuilding_list ready, d: %1s", (time - _dbgTime)];
_dbgTime = time;
_hndl = [_tmpTstPlace] spawn getListBuildingPositionjunction;
waitUntil{scriptDone _hndl};
diag_log format["-- LOOTSPAWNER Buildingpositions_list ready, d: %1s", (time - _dbgTime)];
_dbgTime = time;
_hndl = [] spawn getUsedclasses;
waitUntil{scriptDone _hndl};
diag_log format["-- LOOTSPAWNER LSusedclass_list ready, d: %1s", (time - _dbgTime)];
//run loot deleter continously
null = _spInterval spawn LSdeleter;
diag_log format["-- LOOTSPAWNER LSDer started..."];
if (swDebugLS) then {
dbgTime = time;
dbgTurns = 0;
dbgTurnsplU = 0;
dbgloopTime = 0;
dbgloopTimeplU = 0;
};
diag_log format["-- LOOTSPAWNER ready and waiting for players -----"];
//go into mainloop till mission ends
while {true} do {
_playersalive = false;
{
if (swDebugLS) then {
dbgTimeplU = time;
};
//is Player online and alive?
if ((isPlayer _x) && (alive _x)) then {
_playersalive = true;
//jogging has 4.16..., sprinting has 5.5... so if player velocity is < 6 spawn loot
//works for players in vehicles too
if (((velocity _x) distance [0,0,0]) < 6) then {
//if ((vehicle _x isKindOf "Land") || (vehicle _x isKindOf "Ship")) then {
_posPlayer = getPos _x;
//get list of viable buildings around player
_BaP_list = nearestObjects [_posPlayer, spawnBuilding_list, _spawnradius];
if ((count _BaP_list) > 0) then {
//give to spawn function
_hndl = [_BaP_list, _spInterval, _chfullfuel, _genZadjust, _chperSpot] spawn fn_getBuildingstospawnLoot;
waitUntil{scriptDone _hndl};
};
};
};
sleep 0.001;
if (swDebugLS) then {
dbgloopTimeplU = dbgloopTimeplU + (time - dbgTimeplU);
dbgTurnsplU = dbgTurnsplU + 1;
};
}forEach playableUnits;
if (swDebugLS) then {
dbgloopTime = dbgloopTime + dbgloopTimeplU;
dbgloopTimeplU = 0;
dbgTurns = dbgTurns + 1;
//every 30 sec. give stats out
if ((time - dbgTime) > 30) then {
if (dbgTurnsplU > 0) then {
diag_log format["-- DEBUG LOOTSPAWNER MAIN turns (spawned): %1(%2), duration: %3sec, average: %4sec.",dbgTurns ,dbgTurnsplU , dbgloopTime, (dbgloopTime / dbgTurnsplU)];
} else {
diag_log format["-- DEBUG LOOTSPAWNER MAIN waiting for players"];
};
dbgTime = time;
dbgTurns = 0;
dbgTurnsplU = 0;
dbgloopTime = 0;
};
};
//if no players online wait a bit
if (!_playersalive) then {
sleep 2;
};
};
};

 
Link to comment
Share on other sites

I don't see any scripts filling the boxes, so they SHOULD have their default loadout.. I don't know if any other Epoch side scripts however do an "empty" fucntion when spawning items..

 

I assume this is the lootspawner script that was posted on this forum? Ask in that thread!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Discord

×
×
  • Create New...