#include <define.h>

//#define NAME                    SCRIPT_

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



procedure start;
#include <push.h>
procedure look_at_p_proc;
procedure description_p_proc;
procedure damage_p_proc;


procedure start
begin
	if ((script_action == look_at_proc) or (script_action == description_proc)) then begin
		call look_at_p_proc;
	end
	else begin
		if (script_action == damage_proc) then begin
			call damage_p_proc;
		end
	end
end

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

procedure description_p_proc
begin
	script_overrides;
	if (is_success(do_check(dude_obj, 1, 0)) or is_success(do_check(dude_obj, 6, -1))) then begin
		display_msg(message_str(SCRIPT_CAVEWALL, 101));
	end
	else begin
		display_msg(message_str(SCRIPT_CAVEWALL, 100));
	end
end

procedure damage_p_proc
begin
	variable LVar0 := 0;
	variable LVar1 := 0;
	if (map_var(0) == 0) then begin
		set_map_var(0, 1);
		gfade_out(600);
		LVar0 := create_object_sid(33554839, 0, 0, -1);
		move_to(LVar0, 21744, 0);
		create_object_sid(33554499, 22349, 0, -1);
		create_object_sid(33554499, 21544, 0, -1);
		create_object_sid(33554499, 21744, 0, -1);
		create_object_sid(33554499, 21944, 0, -1);
		create_object_sid(33554499, 22144, 0, -1);
		create_object_sid(33554499, 22344, 0, -1);
		create_object_sid(33554499, 22544, 0, -1);
		create_object_sid(33554499, 22744, 0, -1);
		create_object_sid(33554499, 22944, 0, -1);
		create_object_sid(33554499, 21139, 0, -1);
		create_object_sid(33554499, 21339, 0, -1);
		create_object_sid(33554499, 21539, 0, -1);
		create_object_sid(33554499, 21739, 0, -1);
		create_object_sid(33554499, 21939, 0, -1);
		create_object_sid(33554499, 22139, 0, -1);
		create_object_sid(33554499, 22339, 0, -1);
		create_object_sid(33554499, 22539, 0, -1);
		create_object_sid(33554499, 22739, 0, -1);
		create_object_sid(33554499, 22939, 0, -1);
		create_object_sid(33554499, 22940, 0, -1);
		create_object_sid(33554499, 22941, 0, -1);
		create_object_sid(33554499, 22942, 0, -1);
		create_object_sid(33554499, 22943, 0, -1);
		set_global_var(GVAR_PLAYER_REPUTATION, global_var(GVAR_PLAYER_REPUTATION) + 3);
		LVar1 := (global_var(GVAR_NUM_RADSCORPIONS) * 75) + 75;
		if (LVar1 < 300) then begin
			LVar1 := 300;
		end
		if (global_var(GVAR_NUM_RADSCORPIONS) > 0) then begin
			LVar1 := LVar1 + 500;
		end
		set_global_var(GVAR_RADSCORPIONS_KILLED, 2);
		set_global_var(GVAR_RADSCORPION_SEED, 2);
		display_msg(message_str(SCRIPT_GENCHAT, 188) + " " + message_str(SCRIPT_GENCHAT, 103) + " " + LVar1 + " " + message_str(SCRIPT_GENCHAT, 104));
		give_exp_points(LVar1);
		gfade_in(600);
		if (not(tile_distance(tile_num(dude_obj), 21155) < 15)) then begin
			metarule(13, 0);
		end
	end
end