#include <define.h>

//#define NAME                    SCRIPT_

#include <command.h>
//#include <ModReact.h>



import variable Manhole_Pointer_Top;
import variable Use_Manhole_Top;
import variable Manhole_Pointer_Middle;
import variable Use_Manhole_Middle;
import variable Manhole_Pointer_Bottom;
import variable Use_Manhole_Bottom;

procedure start;
#include <push.h>
procedure use_top;
procedure use_middle;
procedure use_bottom;


procedure start
begin
	if (script_action == use_proc) then begin
		move_to(dude_obj, 27097, 0);
	end
end

procedure use_top
begin
	script_overrides;
	if (obj_pid(self_obj) == 33554576) then begin
		if (Use_Manhole_Top) then begin
			Use_Manhole_Top := 0;
			animate_stand_obj(self_obj);
		end
		else begin
			Use_Manhole_Top := 1;
			add_timer_event(self_obj, 7, 1);
			animate_stand_reverse_obj(self_obj);
		end
	end
	else begin
		if (Use_Manhole_Top) then begin
			add_timer_event(self_obj, 7, 1);
		end
		else begin
			Use_Manhole_Top := 1;
			animate_stand_reverse_obj(Manhole_Pointer_Top);
			add_timer_event(self_obj, 7, 1);
		end
	end
end

procedure use_middle
begin
	script_overrides;
	if (obj_pid(self_obj) == 33554576) then begin
		if (Use_Manhole_Middle) then begin
			Use_Manhole_Middle := 0;
			animate_stand_obj(self_obj);
		end
		else begin
			Use_Manhole_Middle := 1;
			add_timer_event(self_obj, 7, 1);
			animate_stand_reverse_obj(self_obj);
		end
	end
	else begin
		if (Use_Manhole_Middle) then begin
			add_timer_event(self_obj, 7, 1);
		end
		else begin
			Use_Manhole_Middle := 1;
			animate_stand_reverse_obj(Manhole_Pointer_Middle);
			add_timer_event(self_obj, 7, 1);
		end
	end
end

procedure use_bottom
begin
	script_overrides;
	if (obj_pid(self_obj) == 33554576) then begin
		if (Use_Manhole_Bottom) then begin
			Use_Manhole_Bottom := 0;
			animate_stand_obj(self_obj);
		end
		else begin
			Use_Manhole_Bottom := 1;
			add_timer_event(self_obj, 7, 1);
			animate_stand_reverse_obj(self_obj);
		end
	end
	else begin
		if (Use_Manhole_Bottom) then begin
			add_timer_event(self_obj, 7, 1);
		end
		else begin
			Use_Manhole_Bottom := 1;
			animate_stand_reverse_obj(Manhole_Pointer_Bottom);
			add_timer_event(self_obj, 7, 1);
		end
	end
end