#include <define.h>

//#define NAME                    SCRIPT_

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



procedure start;
#include <push.h>
procedure use_stuff;
procedure pick_lock;

variable unlocked;

import variable MVAirlock_ptr;


procedure start
begin
	if (script_action == map_enter_proc) then begin
		MVAirlock_ptr := self_obj;
	end
	else begin
		if ((script_action == look_at_proc) or (script_action == description_proc)) then begin
			script_overrides;
			display_msg(message_str(SCRIPT_MVAIRLOC, 100));
		end
		else begin
			if (script_action == use_proc) then begin
				call use_stuff;
			end
			else begin
				if (script_action == use_skill_on_proc) then begin
					if (obj_pid(obj_being_used_with) == 77) then begin
						call pick_lock;
					end
				end
			end
		end
	end
end

procedure use_stuff
begin
	if (not(unlocked)) then begin
		script_overrides;
		display_msg(message_str(SCRIPT_MVAIRLOC, 101));
	end
end

procedure pick_lock
begin
	script_overrides;
	if (unlocked) then begin
		display_msg(message_str(SCRIPT_MVAIRLOC, 102));
	end
	else begin
		if (is_success(roll_vs_skill(dude_obj, 9, -30))) then begin
			display_msg(message_str(SCRIPT_MVAIRLOC, 103));
			unlocked := 1;
		end
		else begin
			display_msg(message_str(SCRIPT_MVAIRLOC, 104));
		end
	end
end