#include <define.h>

//#define NAME                    SCRIPT_

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



procedure start;
#include <push.h>
procedure see_stuff;
procedure do_dialogue;
procedure destroy_p_proc;
procedure Hernandez01;
procedure Hernandez02;
procedure Hernandez03;
procedure Hernandez04;
procedure Hernandez05;
procedure Hernandez06;
procedure Hernandez07;
procedure Hernandez08;
procedure Hernandez09;
procedure Hernandez10;
procedure Hernandez11;
procedure Hernandez12;
procedure Hernandez13;
procedure Hernandez14;
procedure Hernandezend;

variable known;


procedure start
begin
	if (script_action == talk_proc) then begin
		call do_dialogue;
	end
	else begin
		if (script_action == destroy_proc) then begin
			call destroy_p_proc;
		end
		else begin
			if ((script_action == look_at_proc) or (script_action == description_proc)) then begin
				call see_stuff;
			end
			else begin
				if (script_action == timed_event_proc) then begin
					attack_complex(dude_obj, 0, 1, 0, 0, 30000, 0, 0);
				end
			end
		end
	end
end

procedure see_stuff
begin
	script_overrides;
	if (known) then begin
		display_msg(message_str(SCRIPT_GAMBLER, 100));
	end
	else begin
		display_msg(message_str(SCRIPT_GAMBLER, 101));
	end
end

procedure do_dialogue
begin
	start_gdialog(SCRIPT_GAMBLER, self_obj, 4, -1, -1);
	gsay_start;
	if (known) then begin
		call Hernandez01;
	end
	else begin
		call Hernandez12;
	end
	gsay_end;
	end_dialogue;
end

procedure destroy_p_proc
begin
	if (source_obj == dude_obj) then begin
		if (((global_var(GVAR_BAD_MONSTER) + global_var(GVAR_GOOD_MONSTER)) >= 25) and ((global_var(GVAR_GOOD_MONSTER) > (2 * global_var(GVAR_BAD_MONSTER))) or (global_var(GVAR_BERSERKER_REPUTATION) == 1))) then begin
			set_global_var(GVAR_BERSERKER_REPUTATION, 1);
			set_global_var(GVAR_CHAMPION_REPUTATION, 0);
		end
		if (((global_var(GVAR_BAD_MONSTER) + global_var(GVAR_GOOD_MONSTER)) >= 25) and ((global_var(GVAR_BAD_MONSTER) > (3 * global_var(GVAR_GOOD_MONSTER))) or (global_var(GVAR_CHAMPION_REPUTATION) == 1))) then begin
			set_global_var(GVAR_CHAMPION_REPUTATION, 1);
			set_global_var(GVAR_BERSERKER_REPUTATION, 0);
		end
		set_global_var(GVAR_BAD_MONSTER, global_var(GVAR_BAD_MONSTER) + 1);
		if ((global_var(GVAR_BAD_MONSTER) % 6) == 0) then begin
			set_global_var(GVAR_PLAYER_REPUTATION, global_var(GVAR_PLAYER_REPUTATION) + 1);
		end
	end
end

procedure Hernandez01
begin
	gsay_reply(SCRIPT_GAMBLER, 102);
	known := 1;
	giq_option(4, SCRIPT_GAMBLER, 103, Hernandez02, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_GAMBLER, 104, Hernandez03, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_GAMBLER, 105, Hernandez04, NEUTRAL_REACTION);
end

procedure Hernandez02
begin
	gsay_message(SCRIPT_GAMBLER, 106, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_GAMBLER, 107, Hernandez03, NEUTRAL_REACTION);
	giq_option(5, SCRIPT_GAMBLER, 108, Hernandez09, NEUTRAL_REACTION);
	giq_option(5, SCRIPT_GAMBLER, 109, Hernandez11, NEUTRAL_REACTION);
end

procedure Hernandez03
begin
	variable LVar0 := 0;
	variable LVar1 := 0;
	LVar0 := do_check(dude_obj, 1, 0);
	LVar1 := message_str(SCRIPT_GAMBLER, 110);
	if (is_success(LVar0)) then begin
		LVar1 := LVar1 + message_str(SCRIPT_GAMBLER, 111);
	end
	gsay_message(SCRIPT_GAMBLER, LVar1, NEUTRAL_REACTION);
	gsay_reply(SCRIPT_GAMBLER, 112);
	giq_option(4, SCRIPT_GAMBLER, 113, Hernandez05, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_GAMBLER, 114, Hernandez06, NEUTRAL_REACTION);
	if (is_success(LVar0)) then begin
		giq_option(4, SCRIPT_GAMBLER, 115, Hernandez14, NEUTRAL_REACTION);
	end
end

procedure Hernandez04
begin
	gsay_message(SCRIPT_GAMBLER, 116, NEUTRAL_REACTION);
end

procedure Hernandez05
begin
	gsay_message(SCRIPT_GAMBLER, 117, NEUTRAL_REACTION);
end

procedure Hernandez06
begin
	gsay_message(SCRIPT_GAMBLER, 118, NEUTRAL_REACTION);
end

procedure Hernandez07
begin
	gsay_reply(SCRIPT_GAMBLER, 119);
	giq_option(4, SCRIPT_GAMBLER, 120, Hernandez08, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_GAMBLER, 121, Hernandez03, NEUTRAL_REACTION);
end

procedure Hernandez08
begin
end

procedure Hernandez09
begin
	gsay_message(SCRIPT_GAMBLER, 122, NEUTRAL_REACTION);
	gsay_reply(SCRIPT_GAMBLER, 123);
	giq_option(4, SCRIPT_GAMBLER, 124, Hernandez07, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_GAMBLER, 125, Hernandez10, NEUTRAL_REACTION);
end

procedure Hernandez10
begin
	gsay_message(SCRIPT_GAMBLER, 126, NEUTRAL_REACTION);
end

procedure Hernandez11
begin
	gsay_reply(SCRIPT_GAMBLER, 127);
	giq_option(4, SCRIPT_GAMBLER, 128, Hernandez03, NEUTRAL_REACTION);
end

procedure Hernandez12
begin
	if (dude_is_male) then begin
		gsay_reply(SCRIPT_GAMBLER, 136);
	end
	else begin
		gsay_reply(SCRIPT_GAMBLER, 137);
	end
	giq_option(4, SCRIPT_GAMBLER, 130, Hernandez13, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_GAMBLER, 131, Hernandezend, NEUTRAL_REACTION);
end

procedure Hernandez13
begin
	gsay_message(SCRIPT_GAMBLER, 132, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_GAMBLER, 133, Hernandezend, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_GAMBLER, 134, Hernandez14, NEUTRAL_REACTION);
end

procedure Hernandez14
begin
	gsay_message(SCRIPT_GAMBLER, 135, NEUTRAL_REACTION);
	add_timer_event(self_obj, 5, 1);
end

procedure Hernandezend
begin
end