#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_p_proc;
procedure use_skill_on_p_proc;

import variable AdyStor1_ptr;
import variable AdyStor2_ptr;
import variable Tine_barter;


procedure start
begin
	if (script_action == map_update_proc) then begin
		call map_update_p_proc;
	end
	else begin
		if (script_action == map_enter_proc) then begin
			call map_enter_p_proc;
		end
		else begin
			if (script_action == use_proc) then begin
				call use_p_proc;
			end
			else begin
				if (script_action == use_skill_on_proc) then begin
					call use_skill_on_p_proc;
				end
			end
		end
	end
end

procedure map_update_p_proc
begin
	if (tile_num(self_obj) == 12315) then begin
		AdyStor1_ptr := self_obj;
	end
	else begin
		if (tile_num(self_obj) == 13115) then begin
			AdyStor2_ptr := self_obj;
		end
	end
end

procedure map_enter_p_proc
begin
	if (tile_num(self_obj) == 12315) then begin
		AdyStor1_ptr := self_obj;
	end
	else begin
		if (tile_num(self_obj) == 13115) then begin
			AdyStor2_ptr := self_obj;
		end
	end
end

procedure use_p_proc
begin
	script_overrides;
	if (tile_num(self_obj) == 12315) then begin
		Tine_barter := 1;
	end
	else begin
		if (tile_num(self_obj) == 13115) then begin
			Tine_barter := 2;
		end
	end
end

procedure use_skill_on_p_proc
begin
	if (action_being_used == 10) then begin
		if (not(is_success(roll_vs_skill(source_obj, action_being_used, 0)))) then begin
			script_overrides;
			Tine_barter := -1;
		end
	end
end