#include <define.h>

//#define NAME                    SCRIPT_

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



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

variable item;


procedure start
begin
	if (script_action == description_proc) then begin
		call description_p_proc;
	end
	else begin
		if (script_action == pickup_proc) then begin
			call use_p_proc;
		end
		else 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
	end
end

procedure description_p_proc
begin
	script_overrides;
	display_msg(message_str(SCRIPT_TROPHY, 100));
end

procedure use_p_proc
begin
	script_overrides;
	if (global_var(GVAR_DESTROY_VATS_14) == 0) then begin
		if ((game_time_hour >= 410) and (game_time_hour <= 1200)) then begin
			script_overrides;
			set_global_var(GVAR_DESTROY_VATS_14, 1);
			item := create_object_sid(112, 0, 0, -1);
			add_obj_to_inven(source_obj, item);
			display_msg(message_str(SCRIPT_TROPHY, 101));
			animate_stand_obj(self_obj);
		end
		else begin
			display_msg(message_str(SCRIPT_TROPHY, 103));
		end
	end
end

procedure use_obj_on_p_proc
begin
	if (obj_pid(obj_being_used_with) == 112) then begin
		script_overrides;
		set_global_var(GVAR_DESTROY_VATS_14, 0);
		set_map_var(4, 0);
		animate_stand_obj(self_obj);
		rm_obj_from_inven(source_obj, obj_being_used_with);
		destroy_object(obj_being_used_with);
	end
end

procedure use_skill_on_p_proc
begin
	if (action_being_used == 10) then begin
		if (global_var(GVAR_DESTROY_VATS_14) == 0) then begin
			script_overrides;
			set_global_var(GVAR_DESTROY_VATS_14, 1);
			item := create_object_sid(112, 0, 0, -1);
			add_obj_to_inven(source_obj, item);
			if (is_success(roll_vs_skill(source_obj, 10, 0))) then begin
				display_msg(message_str(SCRIPT_TROPHY, 101));
			end
			else begin
				display_msg(message_str(SCRIPT_TROPHY, 102));
				set_map_var(4, 1);
			end
			reg_anim_func(2, self_obj);
			animate_stand_obj(self_obj);
		end
	end
end