DangerRuss
OpenDayZ Rockstar!
So again I run a battle royale event server from time to time. One of the features is that carepackages are frequently dropped. I was able to go in and edit the file to add a marker on the map for the carepackage when it's dropped, and it is removed when a player gets close to the carepackage.
The problem is as follows. The first carepackage is dropped and a marker is placed on the map. A second carepackage is dropped and no new marker is added to the map. If a player captures the first carepackage, the marker is removed from the map. The very next carepackage that drops, following the capture of the first carepackage, updates the map marker to it's location. Therefore, any carepackages dropped after the first, and before it's captured, will not have a map marker.
spawn_carepackages.sqf
The problem is as follows. The first carepackage is dropped and a marker is placed on the map. A second carepackage is dropped and no new marker is added to the map. If a player captures the first carepackage, the marker is removed from the map. The very next carepackage that drops, following the capture of the first carepackage, updates the map marker to it's location. Therefore, any carepackages dropped after the first, and before it's captured, will not have a map marker.
spawn_carepackages.sqf
Code:
//_chutetype, _boxtype, _helistart, _crashwreck
private ["_chutetype","_boxtype","_helistart","_crashwreck","_randomizedLoot","_guaranteedLoot","_chute","_box","_num","_weights","_index","_itemType","_lootRadius","_lootPos","_pos","_bam","_i","_nearby","_smoke","_itemTypes","_cntWeights","_lootTable","_playerName","_null","_message2"];
_chutetype = _this select 0;
_boxtype = _this select 1;
_helistart = _this select 2;
_crashwreck = _this select 3;
_randomizedLoot = _this select 4;
_guaranteedLoot = _this select 5;
_lootRadius = 1;
_lootTable = ["HeliCrash","MilitarySpecial","Military"] call BIS_fnc_selectRandom;
_chute = createVehicle [_chutetype,_helistart,[],0,"CAN_COLLIDE"];
_chute setVariable["Sarge",1];
_chute setPos [(getpos _crashwreck select 0), (getPos _crashwreck select 1), (getPos _crashwreck select 2)-10];
_box = createVehicle [_boxtype,_helistart,[],0,"CAN_COLLIDE"];
_box setVariable["Sarge",1];
_box setPos [(getpos _crashwreck select 0), (getPos _crashwreck select 1), (getPos _crashwreck select 2)-10];
_box attachto [_chute, [0, 0, 0]];
_i = 0;
while {_i < 45} do {
scopeName "loop1";
if (((getPos _box) select 2) < 1) then {breakOut "loop1"};
sleep 1;
_i=_i+1;
};
switch (true) do {
case not (alive _box): {detach _box;_box setpos [(getpos _box select 0), (getpos _box select 1), 0];};
case alive _box: {detach _box;_box setpos [(getpos _box select 0), (getpos _box select 1), 0];_bam = _boxtype createVehicle [(getpos _box select 0),(getpos _box select 1),(getpos _box select 2)+0];deletevehicle _box;};
};
_bam setVariable["Sarge",1];
deletevehicle _chute;
sleep 2;
_pos = [getpos _bam select 0, getpos _bam select 1,0];
//Map Marker
_null = createMarker ["MarkerDrop",_pos];
"MarkerDrop" setMarkerText "Air Drop";
"MarkerDrop" setMarkerType "mil_dot";
"MarkerDrop" setMarkerColor "ColorRed";
//Map Marker
_smoke = createVehicle ["SmokeShellred",_pos,[],0,"CAN_COLLIDE"];
_smoke setVariable["Sarge",1];
//Wait until player is near, wait 90 seconds and delete marker/box.
waitUntil{
sleep 1;
(({isPlayer _x && _x distance _pos <= 5} count playableUnits > 0));
};
//_message2 = format[" %1 is at the carepackage!",_playerName];
_message2 = format[" A player is looting the carepackage!",_playerName];
[nil,nil,rTitleText,_message2, "PLAIN",6] call RE;
sleep 5;
deleteMarker "MarkerDrop";
_num = (round(random _randomizedLoot)) + _guaranteedLoot;
_itemTypes = [] + getArray (configFile >> "CfgBuildingLoot" >> _lootTable >> "lootType");
_index = dayz_CBLBase find _lootTable;
_weights = dayz_CBLChances select _index;
_cntWeights = count _weights;
//Creating the Lootpiles outside of the _crashModel
for "_x" from 1 to _num do {
//Create loot
_index = floor(random _cntWeights);
_index = _weights select _index;
_itemType = _itemTypes select _index;
//Let the Loot spawn in a non-perfect circle around _crashModel
_lootPos = [_pos, ((random 2) + (sizeOf(_boxtype) * _lootRadius)), random 360] call BIS_fnc_relPos;
[_itemType select 0, _itemType select 1, _lootPos, 0] call spawn_loot;
diag_log(format["CAREPACKAGE: Loot spawn at '%1' with loot %2", _lootPos, _itemType]);
// ReammoBox is preferred parent class here, as WeaponHolder wouldn't match MedBox0 and other such items.
_nearby = _pos nearObjects ["ReammoBox", (sizeOf(_boxtype)+3)];
{
_x setVariable ["permaLoot",true];
} forEach _nearBy;
};