2016-04-06 10:29:59 +00:00
|
|
|
// Unstuck based on a function written by Chris (infiSTAR)
|
|
|
|
// http://pastebin.com/73pjvXPw
|
|
|
|
|
|
|
|
|
|
|
|
private["_vehicle","_curPos","_oldvehPos","_engineTime","_newPos"];
|
|
|
|
_vehicle = _this select 0;
|
|
|
|
|
2016-04-10 14:42:45 +00:00
|
|
|
if(isNil "_vehicle") exitWith{};
|
|
|
|
|
2016-04-06 10:29:59 +00:00
|
|
|
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 = _vehicle getVariable "vehClass";
|
|
|
|
_vehClass = typeOf _vehicle;
|
|
|
|
|
|
|
|
if(_vehicle isKindOf "LandVehicle") then
|
|
|
|
{
|
2016-04-06 14:52:53 +00:00
|
|
|
//_newPos = [ _curPos, 1, 50, [ 0, 0, 1, 0, 0, 0, 0, 0, true] ] call DMS_fnc_FindSafePos_InRange;
|
|
|
|
//_newPos = [_curPos, 5, 100, 3, 0, 20, 0] call BIS_fnc_findSafePos;
|
|
|
|
_tempPos = _curPos findEmptyPosition [0,100,_vehClass];
|
2016-04-06 10:29:59 +00:00
|
|
|
_newPos = [_tempPos select 0, _tempPos select 1, 0];
|
2016-04-06 14:52:53 +00:00
|
|
|
//_newPos = _curPos;
|
|
|
|
//_vehicle setDamage 0.2;
|
2016-04-06 10:29:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if(_vehicle isKindOf "Ship") then
|
|
|
|
{
|
2016-04-06 14:52:53 +00:00
|
|
|
//_newPos = [ _curPos, 1,50, [ 0, 0, 1, 0, 0, 0, 0, 0, true, true ] ] call DMS_fnc_FindSafePos_InRange;
|
|
|
|
_newPos = [_curPos, 5, 100, 3, 2, 20, 0] call BIS_fnc_findSafePos;
|
|
|
|
//_tempPos = _curPos findEmptyPosition [0,100,_vehClass];
|
|
|
|
//_newPos = [_tempPos select 0, _tempPos select 1, 0];
|
|
|
|
_newPos = _curPos;
|
|
|
|
_vehicle setDamage 0.2;
|
2016-04-06 10:29:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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];
|
|
|
|
};
|
|
|
|
|