#include <define.h>

//#define NAME                    SCRIPT_

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



procedure start;
#include <push.h>
procedure use_obj_on_p_proc;
procedure use_skill_on_p_proc;
procedure turn_field_off;

import variable field_change;


procedure start
begin
	if (script_action == use_obj_on_proc) then begin
		call use_obj_on_p_proc;
	end
	else begin
		if (script_action == use_skill_on_proc) then begin
			call use_skill_on_p_proc;
		end
	end
end

procedure use_obj_on_p_proc
begin
	if (obj_pid(obj_being_used_with) == 75) then begin
		script_overrides;
		if (is_success(roll_vs_skill(dude_obj, 13, 0))) then begin
			call turn_field_off;
		end
		else begin
			display_msg(message_str(SCRIPT_FIELDGEN, 100));
		end
	end
end

procedure use_skill_on_p_proc
begin
	if (action_being_used == 13) then begin
		script_overrides;
		if (is_success(roll_vs_skill(dude_obj, 13, -20))) then begin
			call turn_field_off;
		end
		else begin
			display_msg(message_str(SCRIPT_FIELDGEN, 100));
		end
	end
end

procedure turn_field_off
begin
	field_change := "off";
	display_msg(message_str(SCRIPT_FIELDGEN, 101));
	if (cur_map_index == MAP_MBSTRG12) then begin
		if (elevation(self_obj) == 0) then begin
			if (tile_num(self_obj) == 15581) then begin
				use_obj(map_var(4));
			end
			else begin
				if (tile_num(self_obj) == 19124) then begin
					use_obj(map_var(5));
				end
				else begin
					if (tile_num(self_obj) == 25098) then begin
						use_obj(map_var(6));
					end
				end
			end
		end
	end
	else begin
		if (cur_map_index == MAP_MBVATS12) then begin
		end
	end
end