#include <define.h>

//#define NAME                    SCRIPT_

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



procedure start;
#include <push.h>
procedure map_enter_p_proc;
procedure map_update_p_proc;
procedure use_p_proc;
procedure pickup_p_proc;
procedure use_skill_on_p_proc;

variable Free_To_Steal;

import variable Shop_Ptr;
import variable Shopkepper_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 == use_proc) then begin
				call use_p_proc;
			end
			else begin
				if (script_action == pickup_proc) then begin
					call pickup_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
end

procedure map_enter_p_proc
begin
	Shop_Ptr := self_obj;
end

procedure map_update_p_proc
begin
	Shop_Ptr := self_obj;
end

procedure use_p_proc
begin
	if (Shopkepper_Ptr != 0) then begin
		script_overrides;
		add_timer_event(Shopkepper_Ptr, 1, 1);
	end
end

procedure pickup_p_proc
begin
	if ((Shopkepper_Ptr != 0) and (Free_To_Steal == 0)) then begin
		script_overrides;
		add_timer_event(Shopkepper_Ptr, 1, 1);
	end
end

procedure use_skill_on_p_proc
begin
	if ((action_being_used == 10) and (Shopkepper_Ptr != 0)) then begin
		if (is_success(roll_vs_skill(dude_obj, 10, -10))) then begin
			Free_To_Steal := 1;
		end
		else begin
			script_overrides;
			add_timer_event(Shopkepper_Ptr, 1, 2);
		end
	end
end