Skip to content

Commit

Permalink
Fix static gun unflip code
Browse files Browse the repository at this point in the history
  • Loading branch information
Sparker95 committed Nov 6, 2020
1 parent b6ba241 commit 90350d0
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/AI/Unit/ActionUnitGetInVehicle.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -162,20 +162,31 @@ CLASS("ActionUnitGetInVehicle", "ActionUnit")
T_SETV("state", ACTION_STATE_FAILED);
ACTION_STATE_FAILED
};

// Set the vehicle upright if its a static
pr _unitVeh = T_GETV("unitVeh");
if (CALLM0(_unitVeh, "isStatic")) then {
if ((vectorUp _hO) select 2 < 0.5) then { //0.5 roughly 45 degrees of tilt
_hO setVectorUp surfaceNormal position _hO;
_terrainHeight = getTerrainHeightASL position _hO;
_position = [(getPosASL _hO) select 0,(getPosASL _hO) select 1, _terrainHeight];
_hO setPosASL _position;
if ((vectorUp _hVeh) select 2 < 0.5) then { //0.5 roughly 45 degrees of tilt
private _posASL = getPosASL _hVeh;
private _heightAboveGround = (_posASL#2) - (getTerrainHeightASL _posASL);

if (_heightAboveGround > 1.5) then {
// If static gun is on a building
_hVeh setVectorUp [0, 0, 1];
_hVeh setPosASL [_posASL#0, _posASL#1, (_posASL#2) + 0.3];
} else {
// If static gun is on the ground
_hVeh setVectorUp surfaceNormal position _hVeh;
_terrainHeight = getTerrainHeightASL position _hVeh;
_position = [(getPosASL _hVeh) select 0,(getPosASL _hVeh) select 1, _terrainHeight];
_hVeh setPosASL _position;
};
};
};

// Assign vehicle
pr _vehRole = T_GETV("vehRole");
pr _turretPath = T_GETV("turretPath");
pr _unitVeh = T_GETV("unitVeh");
pr _success = CALLM3(_ai, "_assignVehicle", _vehRole, _turretPath, _unitVeh);
if (_success) then {
OOP_INFO_0("ACTIVATEd successfully");
Expand Down

0 comments on commit 90350d0

Please sign in to comment.