#include <define.h>

//#define NAME                    SCRIPT_

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



procedure start;
#include <push.h>
procedure description_p_proc;
procedure talk_p_proc;
procedure use_p_proc;
procedure use_obj_on_p_proc;
procedure use_skill_on_p_proc;
procedure Control00;
procedure Control01;
procedure Control02;
procedure Control03;
procedure Control04;
procedure Control05;
procedure Control06;
procedure Control07;
procedure Control08;
procedure Control08a;
procedure Control08b;
procedure Control08c;
procedure Control09;
procedure Control09a;
procedure Control09b;
procedure Control10;
procedure Control10a;
procedure Control10b;
procedure Control10c;
procedure Control10d;
procedure Control10e;
procedure Control11;
procedure Control12;
procedure Control13;
procedure Control14;
procedure Control15;
procedure Control16;
procedure Control16a;
procedure Control17;
procedure Control18;
procedure Control19;
procedure Control20;
procedure Control21;
procedure Control22;
procedure Control23;
procedure Control24;
procedure Control25;
procedure Controlend;

variable rndx;
variable chance;


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

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

procedure talk_p_proc
begin
	start_gdialog(SCRIPT_ROBCTRL, self_obj, 4, -1, -1);
	gsay_start;
	if (local_var(0) == 1) then begin
		gsay_message(SCRIPT_ROBCTRL, 101, NEUTRAL_REACTION);
	end
	else begin
		if (local_var(1) == 1) then begin
			call Control14;
		end
		else begin
			call Control00;
		end
	end
	gsay_end;
	end_dialogue;
end

procedure use_p_proc
begin
	script_overrides;
	display_msg(message_str(SCRIPT_ROBCTRL, 196));
end

procedure use_obj_on_p_proc
begin
	if (obj_pid(obj_being_used_with) == 100) then begin
		display_msg(message_str(SCRIPT_ROBCTRL, 195));
	end
end

procedure use_skill_on_p_proc
begin
	if (action_being_used == 13) then begin
		script_overrides;
		display_msg(message_str(SCRIPT_ROBCTRL, 197));
	end
	else begin
		if (action_being_used == 12) then begin
			script_overrides;
			dialogue_system_enter;
		end
	end
end

procedure Control00
begin
	set_local_var(1, 1);
	gsay_reply(SCRIPT_ROBCTRL, 102);
	giq_option(-3, SCRIPT_ROBCTRL, 103, Control01, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_ROBCTRL, 104, Control03, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 105, Control03, NEUTRAL_REACTION);
	giq_option(8, SCRIPT_ROBCTRL, 106, Control06, NEUTRAL_REACTION);
end

procedure Control01
begin
	gsay_reply(SCRIPT_ROBCTRL, 107);
	giq_option(-3, SCRIPT_ROBCTRL, 108, Control01, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_ROBCTRL, 109, Control01, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_ROBCTRL, 110, Control02, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_ROBCTRL, 111, Control01, NEUTRAL_REACTION);
end

procedure Control02
begin
	gsay_message(SCRIPT_ROBCTRL, 112, NEUTRAL_REACTION);
end

procedure Control03
begin
	gsay_reply(SCRIPT_ROBCTRL, 113);
	giq_option(6, SCRIPT_ROBCTRL, 114, Controlend, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 115, Control04, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 116, Control06, NEUTRAL_REACTION);
end

procedure Control04
begin
	gsay_reply(SCRIPT_ROBCTRL, 117);
	giq_option(6, SCRIPT_ROBCTRL, 118, Control05, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 119, Control06, NEUTRAL_REACTION);
end

procedure Control05
begin
	gsay_reply(SCRIPT_ROBCTRL, 120);
	giq_option(6, SCRIPT_ROBCTRL, 121, Control06, NEUTRAL_REACTION);
end

procedure Control06
begin
	gsay_reply(SCRIPT_ROBCTRL, 122);
	giq_option(6, SCRIPT_ROBCTRL, 123, Control07, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 124, Control07, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 125, Control07, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 126, Control07, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 127, Controlend, NEUTRAL_REACTION);
end

procedure Control07
begin
	gsay_reply(SCRIPT_ROBCTRL, 128);
	giq_option(6, SCRIPT_ROBCTRL, 129, Control08, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 130, Control09, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 131, Control10, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 132, Control11, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 133, Controlend, NEUTRAL_REACTION);
end

procedure Control08
begin
	gsay_reply(SCRIPT_ROBCTRL, 134);
	giq_option(6, SCRIPT_ROBCTRL, 135, Control08a, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 136, Control08b, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 137, Control08c, NEUTRAL_REACTION);
end

procedure Control08a
begin
	set_global_var(GVAR_DESTROY_VATS_2, 0);
	call Control12;
end

procedure Control08b
begin
	set_global_var(GVAR_DESTROY_VATS_2, 1);
	call Control12;
end

procedure Control08c
begin
	set_global_var(GVAR_DESTROY_VATS_2, 2);
	call Control12;
end

procedure Control09
begin
	gsay_reply(SCRIPT_ROBCTRL, 138);
	giq_option(6, SCRIPT_ROBCTRL, 139, Control09a, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 140, Control09b, NEUTRAL_REACTION);
end

procedure Control09a
begin
	set_global_var(GVAR_DESTROY_VATS_3, 0);
	call Control12;
end

procedure Control09b
begin
	set_global_var(GVAR_DESTROY_VATS_3, 1);
	call Control12;
end

procedure Control10
begin
	gsay_reply(SCRIPT_ROBCTRL, 141);
	giq_option(6, SCRIPT_ROBCTRL, 142, Control10a, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 143, Control10b, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 144, Control10c, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 145, Control10d, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 146, Control10e, NEUTRAL_REACTION);
end

procedure Control10a
begin
	set_global_var(GVAR_DESTROY_VATS_1, 1);
	call Control12;
end

procedure Control10b
begin
	set_global_var(GVAR_DESTROY_VATS_1, 4);
	call Control12;
end

procedure Control10c
begin
	set_global_var(GVAR_DESTROY_VATS_1, 3);
	call Control12;
end

procedure Control10d
begin
	set_global_var(GVAR_DESTROY_VATS_1, 2);
	call Control12;
end

procedure Control10e
begin
	set_global_var(GVAR_DESTROY_VATS_1, 0);
	call Control12;
end

procedure Control11
begin
	chance := 4 * 10;
	if (chance < 5) then begin
		chance := 5;
	end
	if (chance > 95) then begin
		chance := 95;
	end
	rndx := random(1, 100);
	if (rndx < chance) then begin
		gsay_message(SCRIPT_ROBCTRL, 147, NEUTRAL_REACTION);
	end
	else begin
		gsay_message(SCRIPT_ROBCTRL, 148, NEUTRAL_REACTION);
	end
end

procedure Control12
begin
	gsay_reply(SCRIPT_ROBCTRL, 149);
	giq_option(6, SCRIPT_ROBCTRL, 150, Control08, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 151, Control09, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 152, Control10, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 153, Control11, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 154, Controlend, NEUTRAL_REACTION);
end

procedure Control13
begin
	gsay_reply(SCRIPT_ROBCTRL, 155);
	giq_option(6, SCRIPT_ROBCTRL, 156, Control08, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 157, Control09, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 158, Control10, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 159, Control11, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 160, Controlend, NEUTRAL_REACTION);
end

procedure Control14
begin
	gsay_reply(SCRIPT_ROBCTRL, 161);
	giq_option(-3, SCRIPT_ROBCTRL, 103, Control01, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_ROBCTRL, 162, Control03, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 163, Control13, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 164, Control15, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 165, Control16, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 166, Control23, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 167, Controlend, NEUTRAL_REACTION);
end

procedure Control15
begin
	gsay_reply(SCRIPT_ROBCTRL, 168);
	giq_option(6, SCRIPT_ROBCTRL, 169, Control13, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 170, Control16, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 171, Control23, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 172, Controlend, NEUTRAL_REACTION);
end

procedure Control16
begin
	gsay_reply(SCRIPT_ROBCTRL, 173);
	giq_option(6, SCRIPT_ROBCTRL, 174, Control13, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 175, Control16a, NEUTRAL_REACTION);
end

procedure Control16a
begin
	if (is_success(roll_vs_skill(dude_obj, 12, 0))) then begin
		call Control17;
	end
	else begin
		call Control22;
	end
end

procedure Control17
begin
	gsay_reply(SCRIPT_ROBCTRL, 176);
	giq_option(6, SCRIPT_ROBCTRL, 177, Control18, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 178, Control19, NEUTRAL_REACTION);
end

procedure Control18
begin
	gsay_reply(SCRIPT_ROBCTRL, 179);
	giq_option(6, SCRIPT_ROBCTRL, 180, Control13, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 181, Controlend, NEUTRAL_REACTION);
end

procedure Control19
begin
	gsay_reply(SCRIPT_ROBCTRL, 182);
	giq_option(6, SCRIPT_ROBCTRL, 183, Control13, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 184, Controlend, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 185, Control20, NEUTRAL_REACTION);
end

procedure Control20
begin
	gsay_reply(SCRIPT_ROBCTRL, 186);
	giq_option(6, SCRIPT_ROBCTRL, 187, Control21, NEUTRAL_REACTION);
end

procedure Control21
begin
	set_local_var(0, 1);
	gsay_message(SCRIPT_ROBCTRL, 188, NEUTRAL_REACTION);
end

procedure Control22
begin
	gsay_message(SCRIPT_ROBCTRL, 189, NEUTRAL_REACTION);
end

procedure Control23
begin
	gsay_reply(SCRIPT_ROBCTRL, 190);
	giq_option(6, SCRIPT_ROBCTRL, 191, Control24, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_ROBCTRL, 192, Control25, NEUTRAL_REACTION);
end

procedure Control24
begin
	set_local_var(0, 1);
	gsay_message(SCRIPT_ROBCTRL, 193, NEUTRAL_REACTION);
end

procedure Control25
begin
	gsay_message(SCRIPT_ROBCTRL, 194, NEUTRAL_REACTION);
end

procedure Controlend
begin
end