I'd like to see the more experienced scripters take apart the spawn_Helicrash, if anyone has the time or inclination. I've read the FAQ Scripting Guide, and been at this stuff for the last six months, but it's all trial and error for me, mostly error.
I'm mostly looking for what specific numbers actually mean, and what we can change them to.
Here's the code inside dayz_server>init>server_functions.sqf
I'll throw in my two cents about what I know.
First, I know that:
Defines the entire code afterwards, and is referenced in other dayz files, mainly in server_monitor.sqf. You can change it to reference new spawn types that you specify in the code.
Anything with diag_log will write the information following it into your arma2oaserver.RPT so you can reference it.
Example:
Using that line will give you a reference with a position for all of your chopper crashes.
The line below gives you a random amount plus another numeric for loot at the spawnsite.
This line below sets the type of loot table the spawn site will use.
HeliCrash can be changed to "Military", "Residential", "Industrial", "MilitarySpecial", or any other type you specify or create inside the config.cpp inside dayz_code.
Below is another diag_log you can use to see what items spawn at a particular spawn site.
Here's an example of using different items other than wrecks, and with different loot tables.
And that's about all I know. I want to be clear, I've used many examples from other people to set up my crashes and loot spawns, and I don't know all of who I used. I do know I followed Stapo's diag_log examples to add those so I could see where my sites were spawning.
I have some specific questions about code, and if anyone knows what any of the rest of the code is referencing or telling the server to do, I know I, personally, would love directions and examples about how to further edit.
My specific questions are as follows:
In this line, I am assuming it is telling it a center reference from where to randomly find a spot for the site. I have successfully changed the 2000 number to 4000 to cause further afield spawns than are normal, but any above 4k in both fields causes sites to spawn off the map. I'm interested to know exactly what the numbers are for.
I'm also looking for some way to force loot to spawn further away from the center of the loot site, so that it won't spawn underneath any models I use.
I thought maybe the following code had something to do with it:
But after repeatedly changing it and checking sites, I've found no discernible change in the loot spawning.
Anywho, I figured this would be an interesting study in examples and expert scripter input.
Thanks for any replies!
I'm mostly looking for what specific numbers actually mean, and what we can change them to.
Here's the code inside dayz_server>init>server_functions.sqf
Code:
spawn_heliCrash = {
private["_position","_veh","_num","_config","_itemType","_itemChance","_weights","_index","_iArray"];
waitUntil{!isNil "BIS_fnc_selectRandom"};
if (isDedicated) then {
_position = [getMarkerPos "center",0,4000,10,0,2000,0] call BIS_fnc_findSafePos;
diag_log("DEBUG: Spawning a HeliCrash At " + str(_position));
_veh = createVehicle ["UH1Wreck_DZ",_position, [], 0, "CAN_COLLIDE"];
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_veh];
_veh setVariable ["ObjectID",1,true];
dayzFire = [_veh,2,time,false,false];
publicVariable "dayzFire";
if (isServer) then {
nul=dayzFire spawn BIS_Effects_Burn;
};
_num = round(random 2) + 3;
_config = configFile >> "CfgBuildingLoot" >> "HeliCrash";
_itemType = [] + getArray (_config >> "itemType");
//diag_log ("DW_DEBUG: _itemType: " + str(_itemType));
_itemChance = [] + getArray (_config >> "itemChance");
//diag_log ("DW_DEBUG: _itemChance: " + str(_itemChance));
//diag_log ("DW_DEBUG: (isnil fnc_buildWeightedArray): " + str(isnil "fnc_buildWeightedArray"));
waituntil {!isnil "fnc_buildWeightedArray"};
_weights = [];
_weights = [_itemType,_itemChance] call fnc_buildWeightedArray;
//diag_log ("DW_DEBUG: _weights: " + str(_weights));
for "_x" from 1 to _num do {
//create loot
_index = _weights call BIS_fnc_selectRandom;
sleep 1;
if (count _itemType > _index) then {
//diag_log ("DW_DEBUG: " + str(count (_itemType)) + " select " + str(_index));
_iArray = _itemType select _index;
_iArray set [2,_position];
_iArray set [3,5];
_iArray call spawn_loot;
diag_log("LOOTSPAWN: " + str(_iArray) + " Spawned At A UH-1Y CrashSite");
_nearby = _position nearObjects ["WeaponHolder",20];
{
_x setVariable ["permaLoot",true];
} forEach _nearBy;
};
};
};
};
I'll throw in my two cents about what I know.
First, I know that:
Code:
spawn_heliCrash
Defines the entire code afterwards, and is referenced in other dayz files, mainly in server_monitor.sqf. You can change it to reference new spawn types that you specify in the code.
Code:
//Spawn crashed helos
for "_x" from 1 to 4 do {
_id = [] spawn spawn_heliCrash;
//waitUntil{scriptDone _id};
};
//Spawn crashed Ural
for "_x" from 1 to 4 do {
_id = [] spawn spawn_UralCrash;
//waitUntil{scriptDone _id};
};
Anything with diag_log will write the information following it into your arma2oaserver.RPT so you can reference it.
Example:
Code:
diag_log("DEBUG: Spawning a HeliCrash At " + str(_position));
Using that line will give you a reference with a position for all of your chopper crashes.
The line below gives you a random amount plus another numeric for loot at the spawnsite.
Code:
_num = round(random 2) + 3;
This line below sets the type of loot table the spawn site will use.
Code:
_config = configFile >> "CfgBuildingLoot" >> "HeliCrash";
HeliCrash can be changed to "Military", "Residential", "Industrial", "MilitarySpecial", or any other type you specify or create inside the config.cpp inside dayz_code.
Below is another diag_log you can use to see what items spawn at a particular spawn site.
Code:
diag_log("LOOTSPAWN: " + str(_iArray) + " Spawned At A UH-1Y CrashSite");
Here's an example of using different items other than wrecks, and with different loot tables.
Code:
spawn_Outpost3 = {
private["_position","_veh","_num","_config","_itemType","_itemChance","_weights","_index","_iArray"];
waitUntil{!isNil "BIS_fnc_selectRandom"};
if (isDedicated) then {
_position = [getMarkerPos "center",0,4000,10,0,4000,0] call BIS_fnc_findSafePos;
diag_log("DEBUG: Spawning a Outpost3 at " + str(_position));
_veh = createVehicle ["Land_fortified_nest_small",_position, [], 0, "CAN_COLLIDE"];
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_veh];
_veh setVariable ["ObjectID",1,true];
_num = round(random 5) + 3;
_config = configFile >> "CfgBuildingLoot" >> "Military";
_itemType = [] + getArray (_config >> "itemType");
//diag_log ("DW_DEBUG: _itemType: " + str(_itemType));
_itemChance = [] + getArray (_config >> "itemChance");//diag_log ("DW_DEBUG: _itemType: " + str(_itemType));
//_itemChance = [] + getArray (_config >> "itemChance");
//diag_log ("DW_DEBUG: _itemChance: " + str(_itemChance));
//diag_log ("DW_DEBUG: (isnil fnc_buildWeightedArray): " + str(isnil "fnc_buildWeightedArray"));
waituntil {!isnil "fnc_buildWeightedArray"};
_weights = [];
_weights = [_itemType,_itemChance] call fnc_buildWeightedArray;
//diag_log ("DW_DEBUG: _weights: " + str(_weights));
for "_x" from 1 to _num do {
//create loot
_index = _weights call BIS_fnc_selectRandom;
sleep 1;
if (count _itemType > _index) then {
//diag_log ("DW_DEBUG: " + str(count (_itemType)) + " select " + str(_index));
_iArray = _itemType select _index;
_iArray set [2,_position];
_iArray set [3,5];
_iArray call spawn_loot;
_nearby = _position nearObjects ["WeaponHolder",20];
{
_x setVariable ["permaLoot",true];
} forEach _nearBy;
};
};
};
};
And that's about all I know. I want to be clear, I've used many examples from other people to set up my crashes and loot spawns, and I don't know all of who I used. I do know I followed Stapo's diag_log examples to add those so I could see where my sites were spawning.
I have some specific questions about code, and if anyone knows what any of the rest of the code is referencing or telling the server to do, I know I, personally, would love directions and examples about how to further edit.
My specific questions are as follows:
Code:
_position = [getMarkerPos "center",0,4000,10,0,2000,0] call BIS_fnc_findSafePos;
In this line, I am assuming it is telling it a center reference from where to randomly find a spot for the site. I have successfully changed the 2000 number to 4000 to cause further afield spawns than are normal, but any above 4k in both fields causes sites to spawn off the map. I'm interested to know exactly what the numbers are for.
I'm also looking for some way to force loot to spawn further away from the center of the loot site, so that it won't spawn underneath any models I use.
I thought maybe the following code had something to do with it:
Code:
_nearby = _position nearObjects ["WeaponHolder",20];
But after repeatedly changing it and checking sites, I've found no discernible change in the loot spawning.
Anywho, I figured this would be an interesting study in examples and expert scripter input.
Thanks for any replies!