Jump to content
  • 0

Animated Heli Crashes Not Spawning Loot


Tricks

Question

14 answers to this question

Recommended Posts

  • 0

Here is an error I am retting in my RPT:

 1:00:00 File z\addons\dayz_server\DZMS\Scripts\DZMSAISpawn.sqf, line 101
 1:00:00 [DZMS]: (DZMSUnitsMinor) 6 AI Spawned, 12 units in mission.
 1:00:01 "RUNNING EVENT: crash_spawner on [2014,7,6,1,0]"
 1:00:01 "CRASHSPAWNER: 83.3382% chance to start a crashing A-10 with loot table 'HeliCrash'"
 1:00:01 "CRASHSPAWNER: A-10 started flying from [6986,-630,1000] to [5009.23,10494.4] NOW!(TIME:582||LT:HeliCrash)"
 1:00:03 [DZMS]: (DZMSUnitsMinor) Waiting for 12/12 Units or Less to be Alive and a Player to be Near the Objective.
 1:02:54 "CRASHSPAWNER: A-10 just exploded at [4797.84,10327.2,4.3898]!, "
 1:02:54 "_iClass isNil, exiting loot spawn!"
 1:02:54 Error in expression <s select _index;
_itemType = _itemTypes select _index;
[_itemType select 0, _ite>
 1:02:54   Error position: <select _index;
[_itemType select 0, _ite>
 1:02:54   Error Zero divisor
 1:02:54 File z\addons\dayz_server\modules\crash_spawner.sqf, line 162
Link to comment
Share on other sites

  • 0

loottable structure has changed ... you need to replace some lines in crashspawner module

    _config =        configFile >> "CfgBuildingLoot" >> _lootTable;
    _itemTypes =    [] + getArray (_config >> "itemType");
    _index =        dayz_CBLBase find toLower(_lootTable);
    _weights =        dayz_CBLChances select _index;
    _cntWeights = count _weights;

with this

    if (DZE_MissionLootTable) then {
        _itemTypes = [] + getArray (missionConfigFile >> "CfgBuildingLoot" >> _lootTable >> "lootType");
    } else {
        _itemTypes = [] + getArray (configFile >> "CfgBuildingLoot" >> _lootTable >> "lootType");
    };
    _CBLBase = dayz_CBLBase find (toLower(_lootTable));
    _weights = dayz_CBLChances select _CBLBase;
    _cntWeights = count _weights;

and replace this

        _index = floor(random _cntWeights);
        _index = _weights select _index;
        _itemType = _itemTypes select _index;
        [_itemType select 0, _itemType select 1, _lootPos, 5] call spawn_loot;

with this

        _index1 = floor(random _cntWeights);
        _index2 = _weights select _index1;
        _itemType = _itemTypes select _index2;
        [_itemType select 0, _itemType select 1, _lootPos, 5] call spawn_loot;

last step, make sure that following vars are registered as private _index1, _index2 and _itemTypes - look ontop of file and add them or replace the line with this one ...

private["_index1","_index2","_itemTypes","_timeAdjust","_timeToSpawn","_spawnRoll","_crash","_hasAdjustment","_newHeight","_adjustedPos","_useStatic","_crashDamage","_lootRadius","_preWaypoints","_preWaypointPos","_endTime","_startTime","_safetyPoint","_heliStart","_deadBody","_exploRange","_heliModel","_lootPos","_list","_craters","_dummy","_wp2","_wp3","_landingzone","_aigroup","_wp","_helipilot","_crash","_crashwreck","_smokerand","_staticcoords","_pos","_dir","_position","_num","_config","_itemType","_itemChance","_weights","_index","_iArray","_crashModel","_lootTable","_guaranteedLoot","_randomizedLoot","_frequency","_variance","_spawnChance","_spawnMarker","_spawnRadius","_spawnFire","_permanentFire","_crashName"];

hope that helps... cheers

Link to comment
Share on other sites

  • 0

/*
Script Name: crash_spawner.sqf
Original Author: Grafzahl / Finest
Modified by BushWookie for Epoch
Script Version: 1.1a
*/
 
private["_index1","_index2","_itemTypes","_timeAdjust","_timeToSpawn","_spawnRoll","_crash","_hasAdjustment","_newHeight","_adjustedPos","_useStatic","_crashDamage","_lootRadius","_preWaypoints","_preWaypointPos","_endTime","_startTime","_safetyPoint","_heliStart","_deadBody","_exploRange","_heliModel","_lootPos","_list","_craters","_dummy","_wp2","_wp3","_landingzone","_aigroup","_wp","_helipilot","_crash","_crashwreck","_smokerand","_staticcoords","_pos","_dir","_position","_num","_config","_itemType","_itemChance","_weights","_index","_iArray","_crashModel","_lootTable","_guaranteedLoot","_randomizedLoot","_frequency","_variance","_spawnChance","_spawnMarker","_spawnRadius","_spawnFire","_permanentFire","_crashName"];
//############### //Config Start\\ ###############\\
_SpawnMax        = 100;                //Maximum percent chance of spawning a crash number between 0 - 100
_SpawnMin        = 50;                //Minimum percent chance of spawning a crash number between 0 - 100
_guaranteedLoot = 3;                //Guaranteed Loot Spawns
_randomizedLoot = 4;                //Random number of loot piles aswell as the guaranteed ones
_spawnFire      = true;                //Spawn Smoke/Fire at the helicrash
_fadeFire      = false;            //Fade the Smoke/Fire overtime
_preWaypoints    = 2;                //Amount of waypoints the heli flys to before crashing
_crashDamage    = 1;                //Amount of dammage the heli can take before crashing (between 0.1 and 1) Lower the number and the heli can take less damage before crashing 1 dammage is fully destroyed and 0.1 something like a DMR could one shot the heli
_exploRange    = 250;                //How far away from the predefined crash point should the heli start crashing
_minLootRadius    = 4;                //Minimum distance for loot to spawn from the crash site in meters
_maxLootRadius    = 10;                //Maximum distance for loot to spawn from the crash site in meters
//_lootTable        = "HeliCrash";        //Name of the loot table the heli gets loot from (DO NOT edit unless you know what your doing)
_lootTable = ["HeliCrash","HeliCrash_No50s"] call BIS_fnc_selectRandom;
//############### \\Config End// ###############\\
//DO NOT edit below this unless you know what your doing
 
_heliModel        = ["UH1Y_DZE","UH1H_DZE","MV22","A10","Mi17_DZ"] call BIS_fnc_selectRandom;        //The type of heli used
_crashModel    = "UH1Wreck_DZ";    //The type of Crash model used after the heli crashes
_plane            = false;
 
if(_heliModel == "Mi17_DZ") then {
    _crashModel    = "Mi8Wreck";
};
 
if(_heliModel == "MV22") then {
    _crashModel    = "MV22Wreck";
    _plane            = true;
};
 
if(_heliModel == "A10") then {
    _crashModel    = "A10Wreck";
    _plane            = true;
};
 
_maxLootRadius = _maxLootRadius - _minLootRadius;
_spawnRadius = HeliCrashArea;
/*
//Utes-Test
_heliStart = [[4986,-630,1000],[4450,-630,1000]] call BIS_fnc_selectRandom;
_safetyPoint = [0,5100,0];
*/
//Cherno
_heliStart = [[3461.92,5021.77,0],[8582.35,14077.7,0]] call BIS_fnc_selectRandom;
_safetyPoint = [8450.08,20240,0];

_crashName= getText (configFile >> "CfgVehicles" >> _heliModel >> "displayName");
_spawnMarker    = 'center';
_spawnChance = _SpawnMax - _SpawnMin;
_spawnChance = (random _spawnChance) + _SpawnMin;
_spawnRoll = round(random 100);
diag_log(format["CRASHSPAWNER: %1%2 chance to start a crashing %3 with loot table '%4'", _spawnChance, '%', _crashName, _lootTable]);
if (_spawnRoll <= _spawnChance) then
{
    _position = [getMarkerPos _spawnMarker,0,_spawnRadius,10,0,2000,0] call BIS_fnc_findSafePos;
    diag_log(format["CRASHSPAWNER: %1 started flying from %2 to %3 NOW!(TIME:%4||LT:%5)", _crashName,  str(_heliStart), str(_position), round(time), _lootTable]);
    _startTime = time;
    _crashwreck = createVehicle [_heliModel,_heliStart, [], 0, "FLY"];
    _crashwreck setCombatMode "BLUE";
    _crashwreck engineOn true;
    if (_plane) then
    {
        _crashwreck flyInHeight 300;
        _crashwreck forceSpeed 250;
        _crashwreck setspeedmode "NORMAL";
    }
    else
    {
        _crashwreck flyInHeight 150;
        _crashwreck forceSpeed 150;
        _crashwreck setspeedmode "NORMAL";
    };
    _landingzone = createVehicle ["HeliHEmpty", [_position select 0, _position select 1,0], [], 0, "CAN_COLLIDE"];
    _aigroup = creategroup civilian;
    _helipilot = _aigroup createUnit ["SurvivorW2_DZ",getPos _crashwreck,[],0,"FORM"];
    _helipilot setCombatMode "BLUE";
    _helipilot moveindriver _crashwreck;
    _helipilot assignAsDriver _crashwreck;
    sleep 0.5;
    if(_preWaypoints > 0) then
    {
        for "_x" from 1 to _preWaypoints do
        {
            _preWaypointPos = [getMarkerPos _spawnMarker,0,_spawnRadius,10,0,2000,0] call BIS_fnc_findSafePos;
            _wp = _aigroup addWaypoint [_preWaypointPos, 0];
            _wp setWaypointType "MOVE";
            _wp setWaypointBehaviour "CARELESS";
        };
    };
 
    _wp2 = _aigroup addWaypoint [position _landingzone, 0];
    _wp2 setWaypointType "MOVE";
    _wp2 setWaypointBehaviour "CARELESS";
    _wp2 setWaypointStatements ["true", "_crashwreck setdamage 1;"];
    _wp3 = _aigroup addWaypoint [_safetyPoint, 0];
    _wp3 setWaypointType "CYCLE";
    _wp3 setWaypointBehaviour "CARELESS";
    waituntil {(_crashwreck distance _position) <= 1000 || not alive _crashwreck || (getPosATL _crashwreck select 2) < 5 || (damage _crashwreck) >= _crashDamage};
    if (_plane) then
    {
        _crashwreck flyInHeight 100;
        _crashwreck forceSpeed 150;
        _crashwreck setspeedmode "NORMAL";
        _exploRange = 360;
    }
    else
    {
        _crashwreck flyInHeight 100;
        _crashwreck forceSpeed 100;
        _crashwreck setspeedmode "NORMAL";
    };
    waituntil {(_crashwreck distance _position) <= _exploRange || not alive _crashwreck || (getPosATL _crashwreck select 2) < 5 || (damage _crashwreck) >= _crashDamage};
    if (_plane) then
    {
        _crashwreck setdamage 1;
        _vel = velocity _crashwreck;
        _dir = direction _crashwreck;
        _speed = 100;
        _crashwreck setVelocity [(_vel select 0)-(sin _dir*_speed),(_vel select 1)-(cos _dir*_speed),(_vel select 2) - 30];
    }
    else
    {
        _crashwreck setHit ["mala vrtule", 1];
        _ran15 = random 15;
        _crashwreck setVelocity [_ran15,_ran15,-25];
        _crashwreck setdamage .9;
        waitUntil{sleep 1; getpos _crashwreck select 2 <= 30};
        _helipilot setdamage 1;
        _crashwreck setVelocity [_ran15,_ran15,-20];
        waitUntil{sleep 1; getpos _crashwreck select 2 <= 10};
        _crashwreck setdamage 1;
    };
    waitUntil{sleep 1; getpos _crashwreck select 2 <= 5};
    diag_log(format["CRASHSPAWNER: %1 just exploded at %2!, ", _crashName, str(getPosATL _crashwreck)]);
    _pos = [getpos _crashwreck select 0, getpos _crashwreck select 1,0];
    _dir = getdir _crashwreck;
	/*
	//removed coz useless
    heliCrash = _pos;
    publicVariable "heliCrash";
	*/
    deletevehicle _crashwreck;
    deletevehicle _helipilot;
    deletevehicle _landingzone;
    _crash = createVehicle [_crashModel, _pos, [], 0, "CAN_COLLIDE"];
    PVDZE_serverObjectMonitor set [count PVDZE_serverObjectMonitor,_crash];
    if (_spawnFire) then
    {
        PVDZE_obj_Fire = [_crash,2,time,false,_fadeFire];
        publicVariable "PVDZE_obj_Fire";
        _crash setVariable ["fadeFire",_fadeFire,true];
    };
    _num = round(random _randomizedLoot) + _guaranteedLoot;
  	if (DZE_MissionLootTable) then {
		_itemTypes = [] + getArray (missionConfigFile >> "CfgBuildingLoot" >> _lootTable >> "lootType");
	} else {
		_itemTypes = [] + getArray (configFile >> "CfgBuildingLoot" >> _lootTable >> "lootType");
	};
	_CBLBase = dayz_CBLBase find (toLower(_lootTable));
	_weights = dayz_CBLChances select _CBLBase;
	_cntWeights = count _weights;
	
    for "_x" from 1 to _num do
    {
        _maxLootRadius = (random _maxLootRadius) + _minLootRadius;
        _lootPos = [_pos, _maxLootRadius, random 360] call BIS_fnc_relPos;
		//create loot
		_index1 = floor(random _cntWeights);
		_index2 = _weights select _index1;
		_itemType = _itemTypes select _index2;
		[_itemType select 0, _itemType select 1, _lootPos, 5] call spawn_loot;
        diag_log(format["CRASHSPAWNER: Loot spawn at '%1' with loot table '%2'", _pos, _lootTable]);
        _nearby = _pos nearObjects ["ReammoBox", sizeOf(_crashModel)];
        {
            _x setVariable ["permaLoot",true];
        } forEach _nearBy;
    };
    _endTime = time - _startTime;
    diag_log(format["CRASHSPAWNER: Crash completed! Wreck at: %2 - Runtime: %1 Seconds || Distance from calculated POC: %3 meters", round(_endTime), str(getPos _crash), round(_position distance _crash)]);
};

 

^^ okay, here is the complete module... tested 12h on map Utes - some changes made - read comments.

 

cheers

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
  • Advertisement
  • Discord

×
×
  • Create New...