<_templates Include="trucks">
	<Body>
		<Grappler
			Collisions="Internal"
			ForceBodyParams="true"
			Friction="2.0"
			Mass="200"
			NoClientCollisions="true"
		>
			<Constraint AxisLocal="(0;0;1)" Type="Hinge">
				<Motor
					Damping="1.0"
					Force="100500"
					Tau="0.04"
					Type="Position"
				/>
			</Constraint>
		</Grappler>
		<Anchor Mass="400" >
			<Constraint
				AxisLocal="(0;1;0)"
				MinLimit="0"
				MaxLimit="0.6"
				Name="AnchorExt"
				Type="Prismatic"
			>
				<Motor Force="40000" Tau="0.2" Type="Position" />
			</Constraint>
			<Body Collisions="None" Mass="300">
				<Constraint AxisLocal="(1;0;0)" Type="Hinge">
					<Motor Force="40000" Tau="0.2" Type="Position" />
				</Constraint>
				<Body
					ForceBodyParams="true"
					Mass="200"
					NoFoliageCollisions="true"
				>
					<Constraint
						AxisLocal="(0;1;0)"
						MinLimit="0"
						MaxLimit="1.4"
						Name="Anchor"
						Type="Prismatic"
					>
						<Motor Damping="1.0" Force="120000" Tau="0.3" Type="Position" />
					</Constraint>
				</Body>
			</Body>
		</Anchor>
	</Body>
</_templates>
<TruckAddon IsChassisFullOcclusion="true">
	<PoweredConstraints>
		<Group Id="crane_grab" IsGamepadHotkey="true">
			<Constraint Name="RightGrappler" Position="110" SpeedMult="2" />
			<Constraint Name="LeftGrappler" Position="-110" SpeedMult="2" />
		</Group>
		<Group Id="anchors_position">
			<Constraint Name="RightAnchorBase" Position="-178" TerminalFix="true" />
			<Constraint Name="LeftAnchorBase" Position="178" TerminalFix="true" />
			<Constraint
				InitialFix="true"
				Name="AnchorExt"
				Position="0.6"
				TerminalFix="true"
			/>
		</Group>
		<Group Id="anchors_push">
			<Constraint Name="Anchor" Position="0.83" TerminalFix="true" />
		</Group>
	</PoweredConstraints>
	<PhysicsModel Mesh="trucks/maz538_crane">
		<Body ImpactType="Truck" Mass="2000" CenterOfMassOffset="(1.6; 0; 0)">
		    <Constraint Type="Fixed" />
			<Body Mass="1800" ModelFrame="BoneRotationBase_cdt">
			    <Constraint
					AxisLocal="(0;1;0)"
					MinLimit="-350"
					MaxLimit="350"
					Name="Crane"
					Type="Hinge"
				>
					<Motor Force="800000" Tau="0.2" Type="Position" />
				</Constraint>
				<Body Collisions="Internal" Mass="900" ModelFrame="BoneArm1_cdt">
					<Constraint
						AxisLocal="(1;0;0)"
						MinLimit="-92"
						MaxLimit="20"
						Name="Crane"
						Type="Hinge"
					>
						<Motor Force="4500000" Tau="0.4" Type="Position" />
					</Constraint>
					<Body Collisions="Internal" Mass="700" ModelFrame="BoneArm2_cdt">
						<Constraint
							AxisLocal="(1;0;0)"
							MinLimit="-151"
							MaxLimit="20"
							Name="Crane"
							Type="Hinge"
						>
							<Motor Force="3000000" Tau="0.35" Type="Position" />
						</Constraint>
						<Body Collisions="Internal" Mass="600" ModelFrame="BoneArm3_cdt"> 
						    <Constraint
								AxisLocal="(0;1;0)"
								MinLimit="0"
								MaxLimit="1"
								Name="Crane"
								Type="Prismatic"
							>
								<Motor Force="3000000" Tau="0.3" Type="Position" />
							</Constraint>
							<Body Collisions="None" Mass="200" ModelFrame="BoneGrapplerRoot_cdt" >
								<Constraint
									AxisLocal="(1;0;0)"
									MinLimit="-50"
									MaxLimit="150"
									Type="Hinge"
								>
									<Motor Damping="1200" Spring="0" Type="Spring" />
								</Constraint>
								<Body Collisions="None" Mass="200" ModelFrame="BoneGrapplerBase_cdt">
								    <Constraint
										AxisLocal="(0;0;1)"
										MinLimit="-70"
										MaxLimit="70"
										Type="Hinge"
									>
										<Motor Damping="1200" Spring="0" Type="Spring" />
									</Constraint>
									<Body
										Collisions="Internal"
										ForceBodyParams="true"
										Mass="200"
										ModelFrame="BoneGrappler_cdt"
									>
									    <Constraint
											AxisLocal="(0;1;0)"
											MinLimit="-180"
											MaxLimit="180"
											Name="GrapplerBase"
											Type="Hinge"
										>
											<Motor Force="80000" Tau="0.2" Type="Position" />
										</Constraint>										
										<Body _template="Grappler" ModelFrame="BoneGrapplerLeft_cdt">
											<Constraint MinLimit="-110" MaxLimit="0" Name="LeftGrappler" />
										</Body>
										<Body _template="Grappler" ModelFrame="BoneGrapplerRight_cdt">
											<Constraint MinLimit="0" MaxLimit="110" Name="RightGrappler" />
										</Body>										
									</Body>
								</Body>
							</Body>
						</Body>
					</Body>
				</Body>
			</Body>
			<Body _template="Anchor" ModelFrame="BoneLeftAnchorExt_cdt">
				<Body ModelFrame="BoneLeftAnchorBase_cdt">
					<Constraint MinLimit="0" MaxLimit="178" Name="LeftAnchorBase" />
					<Body ModelFrame="BoneLeftAnchor_cdt" />
				</Body>
			</Body>
			<Body _template="Anchor" ModelFrame="BoneRightAnchorExt_cdt">
				<Body ModelFrame="BoneRightAnchorBase_cdt">
					<Constraint MinLimit="-178" MaxLimit="0" Name="RightAnchorBase" />
					<Body ModelFrame="BoneRightAnchor_cdt" />
				</Body>
			</Body>
		</Body>
	</PhysicsModel>
	<ModelAttachments>
		<HeadLight>
			<Model
				_template="HeadLightRay"
				Dir="(-0.719; -0.695; 0)"
				Pos="(-0.288; 3.508; 0.22)"
				ParentFrame="BoneArm1_cdt"
			/>
			<Model
				_template="HeadLightRay"
				Dir="(-0.719; -0.695; 0)"
				Pos="(-0.288; 3.508; -0.22)"
				ParentFrame="BoneArm1_cdt"
			/>
			<Flare
				_template="HeadLight"
				Dir="(-0.719; -0.695; 0)"
				Pos="(-0.288; 3.508; 0.22)"
				ParentFrame="BoneArm1_cdt"
			/>
			<Flare
				_template="HeadLight"
				Dir="(-0.719; -0.695; 0)"
				Pos="(-0.288; 3.508; -0.22)"
				ParentFrame="BoneArm1_cdt"
			/>
			<Flare
				_template="BlueStreak"
				Dir="(-0.719; -0.695; 0)"
				Pos="(-0.288; 3.508; 0.22)"
				ParentFrame="BoneArm1_cdt"
			/>
			<Flare
				_template="BlueStreak"
				Dir="(-0.719; -0.695; 0)"
				Pos="(-0.288; 3.508; -0.22)"
				ParentFrame="BoneArm1_cdt"
			/>
		</HeadLight>				
	</ModelAttachments>	
	<HeadLight
		_template="Default"
		AttenEnd="32"
		Color="g(255; 212; 154) x 3.2"
		Dir="(-0.719; -0.695; 0)"
		Pos="(-0.288; 3.508; 0)"
		ParentFrame="BoneArm1_cdt"
	/>	
	<GameData _noinherit="true">
	    <WinchSocket Pos="(-0.43; 2.14; 0.0)" ParentFrame="BoneGrappler_cdt"/>
		<InstallSocket Type="Maz538Cart" />
	</GameData>
	<ControlledIK>
		<Chain
			CenterXZ="(0.7; 0)"
			EndOffset="(0; 2.2; 0)"
			Id="crane"
           	MinRadius="1.0"		
			ModelFrames="BoneCart_cdt,BoneRotationBase_cdt,BoneArm1_cdt,BoneArm2_cdt,BoneArm3_cdt"
			VerticalLineFrame="BoneGrappler_cdt"
		/>
	</ControlledIK>
	<ControlledConstraints>
		<Constraint Id="crane_grappler" LinkToControlledIK="crane" Name="GrapplerBase" />
	</ControlledConstraints>
	<AutomaticIK>
		<IKBone ModelFrame="BoneConnector1" ParentFrame="BoneArm1_cdt">
			<IKJoint AxisLocal="(1;0;0)" Type="Hinge" />
			<IKBone
				AttachOffset="(0; 0.65; 0)"
				AttachToFrame="BoneArm2_cdt"
				ModelFrame="BoneConnector2"
			>
				<IKJoint AxisLocal="(1;0;0)" Type="Hinge" />
			</IKBone>
		</IKBone>
		<IKBone ModelFrame="BoneArmPistonBase" ParentFrame="BoneArm1_cdt">
			<IKJoint AxisLocal="(1;0;0)" Type="Hinge" />
			<IKBone
				AttachOffset="(0; 1.333; 0)"
				AttachToFrame="BoneConnector1"
				ModelFrame="BoneArmPiston"
			>
				<IKJoint AxisLocal="(0;1;0)" Type="Slider" />
			</IKBone>
		</IKBone>
		<IKBone ModelFrame="BoneBasePistonBase" ParentFrame="BoneArm1_cdt">
			<IKJoint AxisLocal="(1;0;0)" Type="Hinge" />
			<IKBone
				AttachOffset="(0; 0.713; 0)"
				AttachToFrame="BoneRotationBase_cdt"
				ModelFrame="BoneBasePiston"
			>
				<IKJoint AxisLocal="(0;1;0)" Type="Slider" />
			</IKBone>
		</IKBone>
	</AutomaticIK>
	<AddonCamera 
		FirstPersonDir="(-1.0; -0.32; 0.0)"
		FirstPersonPos="(1.4; 4.7; -1.3)"
		ParentFrame="BoneRotationBase_cdt"
    />	
</TruckAddon>	
<!--  8800 kg/> -->