<?xml version="1.0" ?>

<Scene name="MachineGraveyard04">

	<Audio source="chapter5"/>
	<Audio source="ambient_birds"/>

	<!-- Scene layers & anims -->
	<if t="$got_plane_plank == 0"> <Object type="ImageBox" image="scene_new_wooden_wing" x="0" y="328"/> </if>
	<if t="$got_plane_plank == -1">
		<Object type="ImageBox" image="scene_new_wooden_wing" x="0" y="328">
			<Animator type="AlphaChanger" amplitude="-255" speed="1"/>
		</Object>
		<Action type="SetVar" var="got_plane_plank" value="1" reset="0"/>
	</if>
	
	<if t="$mg4_sticks_placed and not $mg4_cleared"> <Object type="ImageBox" image="scene_explosive_sticks" x="494" y="268" /> </if>
    <if t="$detonator_wire_placed"> <Object type="ImageBox" image="scene_wire_placed" x="497" y="312" /> </if>

	<if t="$detonator_handle_placed">
		<if t="$mg4_explosion == 0">
			<Object type="ImageBox" image="scene_detonator_handle_up" x="620" y="513" />
		<else>
			<Object type="ImageBox" image="scene_detonator_handle_down" x="620" y="536" />
		</else>
		</if>
	</if>

    <if t="$mg4_cleared">
		<Object type="ImageBox" image="scene_exit_clear" alpha="255" x="431" y="178" />
	<else>
		<if t="$mg4_explosion">
			<Object type="ImageBox" image="scene_exit_clear" alpha="0" x="431" y="178">
				<Animator type="AlphaChanger" amplitude="255" speed="1"/>
			</Object>
		</if>
	</else>
	</if>

	<if t="$mg4_explosion">
		<Object type="ImageBox" image="add_glow_04" alpha="255" x="396" y="150">
			<Animator type="ResizerX" periods="-1" speed="6200"/>
			<Animator type="MoverY" periods="-1" speed="-3200"/>
			<Animator type="ResizerY" periods="-1" speed="6200"/>
			<Animator type="MoverX" periods="-1" speed="-3200"/>
			<Animator type="AlphaChanger" amplitude="-255" speed="0.3" delay="1"/>
		</Object>

		<Object type="ImageBox" image="add_explosion" alpha="63" x="520" y="260" w="211" h="109">
			<Animator type="ResizerX" periods="-1" speed="400"/>
			<Animator type="MoverX" periods="-1" speed="-200"/>
			<Animator type="ResizerY" periods="-1" speed="400"/>
			<Animator type="MoverY" periods="-1" speed="-200"/>
			<Animator type="AlphaChanger" amplitude="-255" speed="0.1"/>
		</Object>
		<Object type="ImageBox" image="add_explosion" alpha="63" x="404" y="179">
			<Animator type="ResizerX" periods="-1" speed="800"/>
			<Animator type="MoverY" periods="-1" speed="-400"/>
			<Animator type="ResizerY" periods="-1" speed="800"/>
			<Animator type="MoverX" periods="-1" speed="-400"/>
			<Animator type="AlphaChanger" amplitude="-255" speed="0.1"/>
			<Animator type="Rotator" periods="-1" speed="-10"/>
		</Object>
		<Object type="ImageBox" image="add_explosion" alpha="63" x="404" y="179">
			<Animator type="ResizerX" periods="-1" speed="1600"/>
			<Animator type="MoverY" periods="-1" speed="-800"/>
			<Animator type="ResizerY" periods="-1" speed="1600"/>
			<Animator type="MoverX" periods="-1" speed="-800"/>
			<Animator type="AlphaChanger" amplitude="-255" speed="0.05"/>
			<Animator type="Rotator" periods="-1" speed="10"/>
		</Object>

		<Animator type="DelayedAction" time="5">
			<Action type="UnlockScene"/>
			<Action type="SetVar" var="mg4_explosion" value="0" reset="0"/>
			<Action type="SetVar" var="mg4_cleared" value="1" reset="1"/>
		</Animator>

	</if>

	<!-- Actions -->
	<Action color="FFFF00" type="Reference" ref="M::exit_MG4"/>
	<Object type="ActionArrowMarker" x="500" y="630" color="FFFF00" image="ui.gui/ss_marker" angle="-90" clickthrough="1"/>
	
	<Action name="M::exit_MG4" type="SwitchScene" scene="MachineGraveyard01"/>

	<if t="$mg4_cleared">
		<Action color="FF0000" type="Composite">
			<Action type="PlaySound" sound="steps"/>
			<Action type="SwitchScene" scene="UnderworldEntrance01"/>
		</Action>		
		<Object type="ActionArrowMarker" x="500" y="490" color="FF0000" image="ui.gui/ss_marker" angle="60" clickthrough="1"/>
	</if>
	
	<Action condition="not $got_plane_plank" color="00FF00" type="ItemAction" cursor="question">
		<Action itemaction="noitem" type="Say" key="WOODEN_WING_LOOK"/>
		<Action itemaction="saw" type="Composite">
			<Action type="PlaySound" sound="sawed_off"/>
			<Action type="RemoveItem" item="saw" reset="0"/>			
			<Action type="AddItem" item="plank" reset="0"/>
			<Action type="SetVar" var="got_plane_plank" value="-1" reset="1"/>
		</Action>
	</Action>

	<!-- detonator actions -->
	
	<if t="not $mg4_cleared">
		<if t="not $detonator_handle_placed">
			<Action color="00FFFF" type="Reference" ref="M::detonator_no_handle" cursor="question"/>
			<Action color="0000FF" type="Reference" ref="M::detonator_no_handle" cursor="question"/>

			<Action name="M::detonator_no_handle" type="ItemAction">
				<Action itemaction="noitem" type="Say" key="DETONATOR_NO_HANDLE"/>
				<Action itemaction="detonator_handle" type="Composite">
					<Action type="PlaySound" sound="item_put_02"/>
					<Action type="RemoveItem" item="detonator_handle" reset="0"/>
					<Action type="SetVar" var="detonator_handle_placed" value="1" reset="1"/>
				</Action>
			</Action>
		</if>

		<if t="not $detonator_wire_placed">
			<Action color="00FFFF" type="ItemAction" cursor="question">
				<Action itemaction="noitem" condition="$mg4_sticks_placed" type="Say" key="DETONATOR_NO_WIRE"/>
				<Action itemaction="noitem" condition="not $mg4_sticks_placed" type="Say" key="DETONATOR_NO_WIRE_NO_STICKS"/>
				<Action itemaction="wire" type="Composite">
					<Action type="PlaySound" sound="item_put_01"/>
					<Action type="RemoveItem" item="wire" reset="0"/>
					<Action type="SetVar" var="detonator_wire_placed" value="1" reset="1"/>
				</Action>
			</Action>
			
			<Action color="0000FF" type="ItemAction" cursor="question">
				<Action itemaction="noitem" condition="$mg4_sticks_placed" type="Say" key="DETONATOR_NO_WIRE"/>
				<Action itemaction="noitem" condition="not $mg4_sticks_placed" type="Say" key="DETONATOR_NO_WIRE_NO_STICKS"/>
				<Action itemaction="wire" type="Composite">
					<Action type="PlaySound" sound="item_put_01"/>
					<Action type="RemoveItem" item="wire" reset="0"/>
					<Action type="SetVar" var="detonator_wire_placed" value="1" reset="1"/>
				</Action>
			</Action>
		</if>

		<if t="$detonator_handle_placed and $detonator_wire_placed and $mg4_sticks_placed">
			<Action color="00FFFF" type="Reference" ref="M::use_detonator" cursor="use"/>
			<Action color="0000FF" type="Reference" ref="M::use_detonator" cursor="use"/>

			<Action name="M::use_detonator" type="Composite">
				<Action type="LockScene"/>
				<Action type="PlaySound" sound="detonator_handle_push"/>
				<Action type="PlaySound" sound="explosion"/>
				<Action type="SetVar" var="mg4_explosion" value="-1" reset="1"/>
			</Action>
		<else>
			<if t="$detonator_handle_placed and $detonator_wire_placed and not $mg4_sticks_placed">
				<Action color="00FFFF" type="Reference" ref="M::use_detonator_no_sticks" cursor="use"/>
				<Action color="0000FF" type="Reference" ref="M::use_detonator_no_sticks" cursor="use"/>

				<Action name="M::use_detonator_no_sticks" type="Say" key="DETONATOR_NO_WIRE_NO_STICKS"/>
			</if>
		</else>
		</if>

		<if t="not $mg4_sticks_placed or not $detonator_wire_placed">
			<Action color="FF0000" type="ItemAction" cursor="question">
				<Action itemaction="noitem" type="Say" key="BLOCKED_CAVE_LOOK"/>
				<Action itemaction="explosive_stick" condition="not (not $ho_explosive_stick_1_visible and not $ho_explosive_stick_2_visible and not $ho_explosive_stick_3_visible and not $ho_explosive_stick_4_visible and not $ho_explosive_stick_5_visible and not $ho_explosive_stick_6_visible and not $ho_explosive_stick_7_visible and not $ho_explosive_stick_8_visible and not $ho_explosive_stick_9_visible and not $ho_explosive_stick_10_visible)" type="Say" key="INSUFF_EXPLOSIVE_STICKS"/>
				<Action itemaction="explosive_stick" condition="not $ho_explosive_stick_1_visible and not $ho_explosive_stick_2_visible and not $ho_explosive_stick_3_visible and not $ho_explosive_stick_4_visible and not $ho_explosive_stick_5_visible and not $ho_explosive_stick_6_visible and not $ho_explosive_stick_7_visible and not $ho_explosive_stick_8_visible and not $ho_explosive_stick_9_visible and not $ho_explosive_stick_10_visible" type="Composite">
					<Action type="PlaySound" sound="generic_item_use_put_taken"/>
					<Action type="RemoveItem" item="explosive_stick" reset="0"/> <!-- 1 -->
					<Action type="RemoveItem" item="explosive_stick" reset="0"/> <!-- 2 -->
					<Action type="RemoveItem" item="explosive_stick" reset="0"/> <!-- 3 -->
					<Action type="RemoveItem" item="explosive_stick" reset="0"/> <!-- 4 -->
					<Action type="RemoveItem" item="explosive_stick" reset="0"/> <!-- 5 -->
					<Action type="RemoveItem" item="explosive_stick" reset="0"/> <!-- 6 -->
					<Action type="RemoveItem" item="explosive_stick" reset="0"/> <!-- 7 -->
					<Action type="RemoveItem" item="explosive_stick" reset="0"/> <!-- 8 -->
					<Action type="RemoveItem" item="explosive_stick" reset="0"/> <!-- 9 -->
					<Action type="RemoveItem" item="explosive_stick" reset="0"/> <!-- 10 -->
					<Action type="SetVar" var="mg4_sticks_placed" value="1" reset="1"/>
				</Action>
				<Action itemaction="wire" type="Composite">
					<Action type="PlaySound" sound="item_put_01"/>
					<Action type="RemoveItem" item="wire" reset="0"/>
					<Action type="SetVar" var="detonator_wire_placed" value="1" reset="1"/>
				</Action>
			</Action>
		</if>
	<else>
		<Action color="0000FF" type="Reference" ref="M::exit_MG4" nosparkle="1"/>
		<Object type="ActionArrowMarker" x="500" y="630" color="0000FF" image="ui.gui/ss_marker" angle="-90" clickthrough="1"/>
	</else>
	</if>


</Scene>