[code]
//allows MPB to deploy closer to objects and on top of interiors
function MobileBaseVehicle::checkDeploy(%data, %obj)
{
%mask = $TypeMasks::VehicleObjectType | $TypeMasks::MoveableObjectType |
$TypeMasks::StaticShapeObjectType | $TypeMasks::ForceFieldObjectType |
$TypeMasks::ItemObjectType | $TypeMasks::PlayerObjectType |
$TypeMasks::TurretObjectType | //$TypeMasks::StaticTSObjectType |
//$TypeMasks::InteriorObjectType;
//%slot 1 = turret %slot 2 = station
%height[1] = 0;
%height[2] = 0;
%radius[1] = 2.4;
%radius[2] = 2.4;
%stationFailed = false;
%turretFailed = false;
for(%x = 1; %x < 3; %x++)
{
%posXY = getWords(%obj.getSlotTransform(%x), 0, 1);
%posZ = (getWord(%obj.getSlotTransform(%x), 2) + %height[%x]);
InitContainerRadiusSearch(%posXY @ " " @ %posZ, %radius[%x], %mask);
while ((%objFound = ContainerSearchNext()) != 0)
{
if(%objFound != %obj)
{
if(%x == 1)
%turretFailed = true;
else
%stationFailed = true;
break;
}
}
}
//If turret, station or both fail the send back the error message...
if(%turretFailed && %stationFailed)
return "Both Turret and Station are blocked and unable to deploy.";
if(%turretFailed)
return "Turret is blocked and unable to deploy.";
if(%stationFailed)
return "Station is blocked and unable to deploy.";
//Check the station for collision with the Terrain
%mat = %obj.getTransform();
for(%x = 1; %x < 7; %x+=2)
{
%startPos = MatrixMulPoint(%mat, %data.stationPoints[%x]);
%endPos = MatrixMulPoint(%mat, %data.stationPoints[%x+1]);
%rayCastObj = containerRayCast(%startPos, %endPos, $TypeMasks::TerrainObjectType, 0);
if(%rayCastObj)
return "Station is blocked by terrain and unable to deploy.";
}
return "";
}
// -----------------------------------------------------------------------------
//lets the MPB deploy anywhere you want
function MobileBaseVehicle::checkTurretDistance(%data, %obj)
{
%distance = 0;// - set whatever distance to check you want * HERE *
%pos = getWords(%obj.getTransform(), 0, 2);
InitContainerRadiusSearch(%pos, %distance, $TypeMasks::TurretObjectType | $TypeMasks::InteriorObjectType);
while ((%objFound = ContainerSearchNext()) != 0)
{
if(%objFound.getType() & $TypeMasks::TurretObjectType)
{
if(%objFound.getDataBlock().ClassName $= "TurretBase")
return "Turret Base is in the area. Unable to deploy.";
}
else
{
%subStr = getSubStr(%objFound.interiorFile, 1, 4);
if(%subStr !$= "rock" && %subStr !$= "spir" && %subStr !$= "misc")
return "Building is in the area. Unable to deploy.";
}
}
return "";
}