#include <define.h>

//#define NAME                    SCRIPT_

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



procedure start;
#include <push.h>
procedure use_p_proc;
procedure talk_p_proc;
procedure use_skill_on_p_proc;
procedure Term01;
procedure Term02;
procedure Term03;
procedure Term03a;
procedure Term04;
procedure Term05;
procedure Term06;
procedure Term06a;
procedure Term07;
procedure Term08;
procedure Term09;
procedure Term09a;
procedure Term10;
procedure Term11;
procedure Term11a;
procedure Term12;
procedure Term13;
procedure Term14;
procedure Term14a;
procedure Term15;
procedure TermEnd;


procedure start
begin
	if (script_action == use_proc) then begin
		call use_p_proc;
	end
	else begin
		if (script_action == talk_proc) then begin
			call talk_p_proc;
		end
		else begin
			if (script_action == use_skill_on_proc) then begin
				call use_skill_on_p_proc;
			end
		end
	end
end

procedure use_p_proc
begin
	script_overrides;
	dialogue_system_enter;
end

procedure talk_p_proc
begin
	start_gdialog(SCRIPT_GPWRTERM, self_obj, 4, -1, -1);
	gsay_start;
	if (global_var(GVAR_GLOW_POWER) == 0) then begin
		call Term14;
	end
	else begin
		if (global_var(GVAR_GLOW_POWER) == 1) then begin
			call Term01;
		end
		else begin
			call Term09;
		end
	end
	gsay_end;
	end_dialogue;
end

procedure use_skill_on_p_proc
begin
	if (action_being_used == 12) then begin
		script_overrides;
		dialogue_system_enter;
	end
end

procedure Term01
begin
	gsay_reply(SCRIPT_GPWRTERM, 100);
	giq_option(4, SCRIPT_GPWRTERM, 101, Term02, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_GPWRTERM, 102, Term10, NEUTRAL_REACTION);
	giq_option(0, SCRIPT_GPWRTERM, 103, TermEnd, NEUTRAL_REACTION);
end

procedure Term02
begin
	gsay_reply(SCRIPT_GPWRTERM, 104);
	giq_option(4, SCRIPT_GPWRTERM, 105, Term03, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_GPWRTERM, 106, Term06, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_GPWRTERM, 107, Term01, NEUTRAL_REACTION);
end

procedure Term03
begin
	gsay_reply(SCRIPT_GPWRTERM, 108);
	giq_option(4, SCRIPT_GPWRTERM, 109, Term03a, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_GPWRTERM, 110, Term02, NEUTRAL_REACTION);
end

procedure Term03a
begin
	if (global_var(GVAR_START_POWER) != 2) then begin
		call Term04;
	end
	else begin
		set_global_var(GVAR_GLOW_POWER, 2);
	end
end

procedure Term04
begin
	gsay_reply(SCRIPT_GPWRTERM, 111);
	giq_option(8, SCRIPT_GPWRTERM, 112, Term05, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_GPWRTERM, 113, Term02, NEUTRAL_REACTION);
end

procedure Term05
begin
	gsay_reply(SCRIPT_GPWRTERM, 114);
	giq_option(4, SCRIPT_GPWRTERM, 115, Term02, NEUTRAL_REACTION);
end

procedure Term06
begin
	gsay_reply(SCRIPT_GPWRTERM, 116);
	giq_option(4, SCRIPT_GPWRTERM, 117, Term06a, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_GPWRTERM, 118, Term02, NEUTRAL_REACTION);
end

procedure Term06a
begin
	set_global_var(GVAR_GLOW_POWER, 0);
end

procedure Term07
begin
	gsay_reply(SCRIPT_GPWRTERM, 119);
	giq_option(4, SCRIPT_GPWRTERM, 120, Term08, NEUTRAL_REACTION);
	giq_option(0, SCRIPT_GPWRTERM, 121, TermEnd, NEUTRAL_REACTION);
end

procedure Term08
begin
	gsay_reply(SCRIPT_GPWRTERM, 122);
	giq_option(4, SCRIPT_GPWRTERM, 123, Term09a, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_GPWRTERM, 124, Term07, NEUTRAL_REACTION);
end

procedure Term09
begin
	gsay_reply(SCRIPT_GPWRTERM, 125);
	giq_option(-3, SCRIPT_GPWRTERM, 126, Term09a, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_GPWRTERM, 127, Term09a, NEUTRAL_REACTION);
	giq_option(0, SCRIPT_GPWRTERM, 128, TermEnd, NEUTRAL_REACTION);
end

procedure Term09a
begin
	set_global_var(GVAR_GLOW_POWER, 1);
end

procedure Term10
begin
	gsay_reply(SCRIPT_GPWRTERM, 129);
	giq_option(-3, SCRIPT_GPWRTERM, 130, Term11, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_GPWRTERM, 131, Term13, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_GPWRTERM, 132, Term01, NEUTRAL_REACTION);
end

procedure Term11
begin
	gsay_reply(SCRIPT_GPWRTERM, 133);
	giq_option(-3, SCRIPT_GPWRTERM, 134, Term11a, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_GPWRTERM, 135, Term10, NEUTRAL_REACTION);
end

procedure Term11a
begin
	if (global_var(GVAR_START_POWER) != 2) then begin
		call Term12;
	end
	else begin
		set_global_var(GVAR_GLOW_POWER, 2);
	end
end

procedure Term12
begin
	gsay_reply(SCRIPT_GPWRTERM, 136);
	giq_option(-3, SCRIPT_GPWRTERM, 137, Term10, NEUTRAL_REACTION);
end

procedure Term13
begin
	gsay_reply(SCRIPT_GPWRTERM, 138);
	giq_option(-3, SCRIPT_GPWRTERM, 148, Term06a, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_GPWRTERM, 137, Term10, NEUTRAL_REACTION);
end

procedure Term14
begin
	gsay_reply(SCRIPT_GPWRTERM, 139);
	giq_option(4, SCRIPT_GPWRTERM, 140, Term14a, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_GPWRTERM, 141, Term15, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_GPWRTERM, 142, Term15, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_GPWRTERM, 143, Term14a, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_GPWRTERM, 144, Term15, NEUTRAL_REACTION);
	giq_option(0, SCRIPT_GPWRTERM, 145, TermEnd, NEUTRAL_REACTION);
end

procedure Term14a
begin
	set_global_var(GVAR_GLOW_POWER, 1);
	if (global_var(GVAR_START_POWER) == 2) then begin
		call Term01;
	end
end

procedure Term15
begin
	gsay_reply(SCRIPT_GPWRTERM, 146);
	giq_option(0, SCRIPT_GPWRTERM, 147, TermEnd, NEUTRAL_REACTION);
end

procedure TermEnd
begin
end