1c48de5f5e
Problems with versions after this which caused out of memory errors
85 lines
2.8 KiB
Plaintext
85 lines
2.8 KiB
Plaintext
// Unstuck based on a function written by Chris (infiSTAR)
|
|
// http://pastebin.com/73pjvXPw
|
|
|
|
|
|
private["_vehicle","_curPos","_oldvehPos","_engineTime","_newPos"];
|
|
_vehicle = _this select 0;
|
|
|
|
if(isNil "_vehicle") exitWith{};
|
|
|
|
if(count(crew _vehicle) > 0)then
|
|
{
|
|
_curPos = position _vehicle;
|
|
_newPos = _curPos;
|
|
_oldvehPos = _vehicle getVariable["vehPos",[0,0,0]];
|
|
if(isNil "_oldvehPos") then { _oldvehPos = [0,0,0]; };
|
|
if(str _oldvehPos != "[0,0,0]")then
|
|
{
|
|
if(_curPos distance _oldvehPos < 2)then
|
|
{
|
|
_engineTime = _vehicle getVariable["engineTime",-1];
|
|
if(_engineTime < 0)then
|
|
{
|
|
_vehicle setVariable["engineTime",time];
|
|
};
|
|
if(time - _engineTime > 10)then
|
|
{
|
|
|
|
_logDetail = format ["[OCCUPATION:Unstuck]:: %1 is stuck,attempting to unstick from %2 @ %3",_vehicle,_curPos,time];
|
|
[_logDetail] call SC_fnc_log;
|
|
|
|
_vehicle setVariable["engineTime",-1];
|
|
|
|
_vehicle setVectorUp [0,0,1];
|
|
|
|
_originalSpawnLocation = _vehicle getVariable "SC_vehicleSpawnLocation";
|
|
_group = group _vehicle;
|
|
_vehClass = typeOf _vehicle;
|
|
|
|
if(_vehicle isKindOf "LandVehicle") then
|
|
{
|
|
_tempPos = _curPos findEmptyPosition [0,150,_vehClass];
|
|
_newPos = [_tempPos select 0, _tempPos select 1, 0];
|
|
};
|
|
|
|
if(_vehicle isKindOf "Ship") then
|
|
{
|
|
_newPos = [_curPos, 5, 100, 3, 2, 20, 0] call BIS_fnc_findSafePos;
|
|
_newPos = _curPos;
|
|
_vehicle setDamage 0.2;
|
|
};
|
|
|
|
if(_vehicle isKindOf "Air") then
|
|
{
|
|
_newPos = _curPos;
|
|
};
|
|
_GroupLeader = leader (group _vehicle);
|
|
_GroupLeader doMove _originalSpawnLocation;
|
|
[_group, _originalSpawnLocation, 2000] call bis_fnc_taskPatrol;
|
|
_group setBehaviour "AWARE";
|
|
_group setCombatMode "RED";
|
|
|
|
_logDetail = format ["[OCCUPATION:Unstuck]:: %1 was stuck and was moved from %2 to %3 @ %4",_vehicle,_curPos,_newPos, time];
|
|
[_logDetail] call SC_fnc_log;
|
|
|
|
};
|
|
};
|
|
};
|
|
_vehicle setVariable["vehPos",_newPos];
|
|
};
|
|
|
|
_group = group _vehicle;
|
|
|
|
// Remove dead units from the group
|
|
{
|
|
if(!alive _x) then { [_x] join grpNull; };
|
|
}forEach units _group;
|
|
|
|
if(count units _group > 0) then
|
|
{
|
|
_vehicle lock 0;
|
|
_vehicle setVehicleLock "UNLOCKED";
|
|
_vehicle setVariable ["ExileIsLocked", 0, true];
|
|
};
|
|
|