#include <define.h>

//#define NAME                    SCRIPT_

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



procedure start;
#include <push.h>
procedure use_p_proc;
procedure timer_p_proc;

variable OnlyOnce := 1;

import variable Front_Door_Ptr;


procedure start
begin
	if (OnlyOnce) then begin
		OnlyOnce := 0;
		Front_Door_Ptr := self_obj;
		obj_close(self_obj);
	end
	if (script_action == use_proc) then begin
		call use_p_proc;
	end
	if (script_action == timed_event_proc) then begin
		call timer_p_proc;
	end
end

procedure use_p_proc
begin
	if ((source_obj == dude_obj) and (tile_num(dude_obj) == 21927)) then begin
		obj_open(self_obj);
	end
	else begin
		if ((map_var(3) == 0) and (source_obj == dude_obj) and (map_var(4) == 0)) then begin
			script_overrides;
			set_map_var(2, 1);
		end
		else begin
			obj_open(self_obj);
			if ((source_obj != dude_obj) and (map_var(4) == 0)) then begin
				add_timer_event(self_obj, game_ticks(1), 0);
			end
		end
	end
end

procedure timer_p_proc
begin
	use_obj(self_obj);
	rm_timer_event(self_obj);
end