#include <define.h>

//#define NAME                    SCRIPT_

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



procedure start;
#include <push.h>
procedure map_update_p_proc;
procedure map_enter_p_proc;
procedure use_term;
procedure look_at_p_proc;

import variable term1_ptr;
import variable Vree_ptr;


procedure start
begin
	if (script_action == map_enter_proc) then begin
		call map_enter_p_proc;
	end
	else begin
		if (script_action == map_update_proc) then begin
			call map_update_p_proc;
		end
		else begin
			if (script_action == look_at_proc) then begin
				call look_at_p_proc;
			end
			else begin
				if (script_action == use_proc) then begin
					call use_term;
				end
			end
		end
	end
end

procedure map_update_p_proc
begin
	term1_ptr := self_obj;
end

procedure map_enter_p_proc
begin
	term1_ptr := self_obj;
end

procedure use_term
begin
	if (source_obj == Vree_ptr) then begin
		set_local_var(0, 1);
		float_msg(self_obj, message_str(SCRIPT_VREE, 133), FLOAT_MSG_YELLOW);
	end
	else begin
		if (local_var(0) == 0) then begin
			display_msg(message_str(SCRIPT_TERM, 101));
		end
		else begin
			if (local_var(0) == 1) then begin
				gfade_out(600);
				critter_mod_skill(dude_obj, 12, 15);
				set_local_var(0, 2);
				gfade_in(600);
				display_msg(message_str(SCRIPT_TERM, 102));
			end
			else begin
				if (local_var(0) == 2) then begin
					display_msg(message_str(SCRIPT_TERM, 103));
				end
			end
		end
	end
end

procedure look_at_p_proc
begin
	script_overrides;
	display_msg(message_str(SCRIPT_TERM, 100));
end