Random Helicrashs in Namalsk 0.73

Grafzahl

Valued Member!
Hi Guys,

with the help of this thread i managed to bring back the old random helicrashs to namalsk 0.73, i had to change the vehicle-type to Land_mi8_crashed, because the old model seems to be banned since 0.72... which i dont like, because Land_mi8_crashed is a little bit buggy when placed on hills, and sometimes you cant go inside the wreck or break your bones/die... but ok.

This is the code actually is at the end of my 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 crashed helicopter at " + str(_position));
        _veh = createVehicle ["Land_mi8_crashed",_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 4) + 3;
    _config =        configFile >> dayzNam_buildingLoot >> "HeliCrashNamalsk";
    _itemType =        [["PK_DZN", "weapon"], ["Pecheneg_DZN", "weapon"], ["AKS_GOLD", "weapon"]];
    //diag_log ("DW_DEBUG: _itemType: " + str(_itemType));
    _itemChance =    [0.02, 0.01, 0.02];
    //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;
            };
        };
    };
};
While this is in my server_monitor.sqf
Code:
for "_x" from 1 to 30 do {
    _id = [] spawn spawn_heliCrash;
// Script done WaitUntil {_id};
};
So, this spawns 30 (just for testing ;) Land_mi8_crashed, they do have the same loot as the perma-crashsites on my server, and the loot spawns randomly around the crashsite... sometimes there are 2 weapons, sometimes 4.

Now, what i wanted to do is, that there are only 2 possible lootspawns in each heli, and like in the fixed crashsites on namalsk, it should spawn inside the wreck on fixed positions. What do i have to change to get that working? server_heliCrash_dzn.sqf does this:
Code:
    _weights = [];
    _weights =        [_itemType,_itemChance] call fnc_buildWeightedArray;
    _lootpos = [] + getArray (configFile >> dayzNam_buildingLoot >> (typeOf _helicrash) >> "lootPos");
 
    if (_helicrash != objNull) then {
        for "_x" from 1 to (count _lootpos) do {
            //create lootpos
            _wpos = _helicrash modelToWorld (_lootpos select (_x - 1));
            //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,_wpos];
                _iArray set [3,5];
                _iArray call spawn_loot;
                _nearby = _wpos nearObjects ["WeaponHolder",20];
                {
                    _x setVariable ["permaLoot",true];
                } forEach _nearBy;
            };
        };
But this used _helicrash, which is the switch that includes only the static crashsites...

The second thing is, i found the function deleteVehicle, because i wanted delete the static helicrashs from namalsk, so only the random ones are there, but i dont think i can delete vehicles which are fixed placed als "buildings" in the mission file, or is this possible?

Does anyone have an idea how to fix that? Thank you so much :)
 
could you possibly do it for me and upload the file somewhere please would greatly appreciate it
 
Hi Guys,

with the help of this thread i managed to bring back the old random helicrashs to namalsk 0.73, i had to change the vehicle-type to Land_mi8_crashed, because the old model seems to be banned since 0.72... which i dont like, because Land_mi8_crashed is a little bit buggy when placed on hills, and sometimes you cant go inside the wreck or break your bones/die... but ok.

This is the code actually is at the end of my 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 crashed helicopter at " + str(_position));
        _veh = createVehicle ["Land_mi8_crashed",_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 4) + 3;
    _config =        configFile >> dayzNam_buildingLoot >> "HeliCrashNamalsk";
    _itemType =        [["PK_DZN", "weapon"], ["Pecheneg_DZN", "weapon"], ["AKS_GOLD", "weapon"]];
    //diag_log ("DW_DEBUG: _itemType: " + str(_itemType));
    _itemChance =    [0.02, 0.01, 0.02];
    //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;
            };
        };
    };
};
While this is in my server_monitor.sqf
Code:
for "_x" from 1 to 30 do {
    _id = [] spawn spawn_heliCrash;
// Script done WaitUntil {_id};
};
So, this spawns 30 (just for testing ;) Land_mi8_crashed, they do have the same loot as the perma-crashsites on my server, and the loot spawns randomly around the crashsite... sometimes there are 2 weapons, sometimes 4.

Now, what i wanted to do is, that there are only 2 possible lootspawns in each heli, and like in the fixed crashsites on namalsk, it should spawn inside the wreck on fixed positions. What do i have to change to get that working? server_heliCrash_dzn.sqf does this:
Code:
    _weights = [];
    _weights =        [_itemType,_itemChance] call fnc_buildWeightedArray;
    _lootpos = [] + getArray (configFile >> dayzNam_buildingLoot >> (typeOf _helicrash) >> "lootPos");
 
    if (_helicrash != objNull) then {
        for "_x" from 1 to (count _lootpos) do {
            //create lootpos
            _wpos = _helicrash modelToWorld (_lootpos select (_x - 1));
            //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,_wpos];
                _iArray set [3,5];
                _iArray call spawn_loot;
                _nearby = _wpos nearObjects ["WeaponHolder",20];
                {
                    _x setVariable ["permaLoot",true];
                } forEach _nearBy;
            };
        };
But this used _helicrash, which is the switch that includes only the static crashsites...

The second thing is, i found the function deleteVehicle, because i wanted delete the static helicrashs from namalsk, so only the random ones are there, but i dont think i can delete vehicles which are fixed placed als "buildings" in the mission file, or is this possible?

Does anyone have an idea how to fix that? Thank you so much :)

Please upload a finished copy here for me to use for my server
 
Back
Top