#include <define.h>

//#define NAME                    SCRIPT_

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



procedure start;
#include <push.h>
procedure Francis04;
procedure Francis05;
procedure Francis06;
procedure Francis07_1;
procedure Francis07_2;
procedure Francis08_1;
procedure Francis08_2;
procedure Francis09_1;
procedure Francis09_2;
procedure Francis10_1;
procedure Francis10_2;
procedure Francis11_1;
procedure Francis11_2;
procedure Francis12_1;
procedure Francis12_2;
procedure Francis13;
procedure Francis14;
procedure Francis15_1;
procedure Francis15_2;
procedure Francis15_3;
procedure Francis16;
procedure Francis17_1;
procedure Francis17_2;
procedure Francis18;
procedure Francis19;
procedure Francis20;
procedure Francis21_1;
procedure Francis21_2;
procedure Francis22;
procedure FrancisEnd;
procedure Combat;

variable Hostile;
variable Only_Once := 1;


procedure start
begin
	if (Only_Once) then begin
		critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_TEAM_NUM, 20);
		critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_AI_PACKET, AI_BRAINWASHED_CHILDREN);
		Only_Once := 0;
	end
	if ((script_action == look_at_proc) or (script_action == description_proc)) then begin
		script_overrides;
		display_msg(message_str(SCRIPT_FRANCIS, 100));
	end
	else begin
		if (script_action == pickup_proc) then begin
			Hostile := 1;
		end
		else begin
			if (script_action == critter_proc) then begin
				if (Hostile) then begin
					Hostile := 0;
					attack_complex(dude_obj, 0, 1, 0, 0, 30000, 0, 0);
				end
			end
			else begin
				if (script_action == destroy_proc) then 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
				else begin
					if (script_action == talk_proc) then begin
						script_overrides;
						if (global_var(GVAR_CATHEDRAL_ENEMY) == 1) then begin
							float_msg(self_obj, message_str(SCRIPT_FRANCIS, 101), FLOAT_MSG_NORMAL);
						end
						else begin
							if (local_var(0) == 1) then begin
								float_msg(self_obj, message_str(SCRIPT_FRANCIS, 102), FLOAT_MSG_NORMAL);
							end
							else begin
								if ((obj_item_subtype(critter_inven_obj(dude_obj, 1)) == 3) or (obj_item_subtype(critter_inven_obj(dude_obj, 2)) == 3)) then begin
									float_msg(self_obj, message_str(SCRIPT_FRANCIS, 103), FLOAT_MSG_NORMAL);
								end
								else begin
									if (not(obj_pid(critter_inven_obj(dude_obj, 0)) == 113) and (((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)) or (global_var(GVAR_CHILDKILLER_REPUTATION) > 2))) then begin
										float_msg(self_obj, message_str(SCRIPT_FRANCIS, 104), FLOAT_MSG_NORMAL);
									end
									else begin
										start_gdialog(SCRIPT_FRANCIS, self_obj, 4, -1, -1);
										gsay_start;
										if (not(obj_pid(critter_inven_obj(dude_obj, 0)) == 113)) then begin
											call Francis04;
										end
										else begin
											if (obj_pid(critter_inven_obj(dude_obj, 0)) == 113) then begin
												call Francis05;
											end
											else begin
												call Francis06;
											end
										end
										gsay_end;
										end_dialogue;
										set_local_var(0, 1);
									end
								end
							end
						end
					end
				end
			end
		end
	end
end

procedure Francis04
begin
	gsay_reply(SCRIPT_FRANCIS, 105);
	giq_option(7, SCRIPT_FRANCIS, 106, Francis07_1, NEUTRAL_REACTION);
	giq_option(7, SCRIPT_FRANCIS, 107, Francis08_1, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_FRANCIS, 108, Francis09_1, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_FRANCIS, 109, Francis10_1, NEUTRAL_REACTION);
	if (global_var(GVAR_ALOCHOL_ADDICT) == 1) then begin
		giq_option(4, SCRIPT_FRANCIS, 110, Francis11_1, NEUTRAL_REACTION);
	end
	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
		giq_option(4, SCRIPT_FRANCIS, 111, Francis12_1, NEUTRAL_REACTION);
	end
	giq_option(-3, SCRIPT_FRANCIS, 112, Francis13, NEUTRAL_REACTION);
end

procedure Francis05
begin
	if (dude_is_male) then begin
		gsay_reply(SCRIPT_FRANCIS, 113);
	end
	else begin
		gsay_reply(SCRIPT_FRANCIS, 114);
	end
	giq_option(7, SCRIPT_FRANCIS, 115, Francis14, NEUTRAL_REACTION);
	giq_option(7, SCRIPT_FRANCIS, 116, Francis15_1, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_FRANCIS, 117, Francis16, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_FRANCIS, 118, Francis17_1, NEUTRAL_REACTION);
	if (global_var(GVAR_ALOCHOL_ADDICT) == 1) then begin
		giq_option(4, SCRIPT_FRANCIS, 119, Francis18, NEUTRAL_REACTION);
	end
	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
		giq_option(4, SCRIPT_FRANCIS, 120, Francis19, NEUTRAL_REACTION);
	end
	giq_option(-3, SCRIPT_FRANCIS, 121, Francis20, NEUTRAL_REACTION);
end

procedure Francis06
begin
	if (dude_is_male) then begin
		gsay_reply(SCRIPT_FRANCIS, 160);
	end
	else begin
		gsay_reply(SCRIPT_FRANCIS, 161);
	end
	giq_option(7, SCRIPT_FRANCIS, 122, Francis21_1, NEUTRAL_REACTION);
	giq_option(7, SCRIPT_FRANCIS, 123, Francis15_1, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_FRANCIS, 124, Francis09_1, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_FRANCIS, 125, Francis22, NEUTRAL_REACTION);
	if (global_var(GVAR_ALOCHOL_ADDICT) == 1) then begin
		giq_option(4, SCRIPT_FRANCIS, 126, Francis11_1, NEUTRAL_REACTION);
	end
	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
		giq_option(4, SCRIPT_FRANCIS, 127, Francis12_1, NEUTRAL_REACTION);
	end
	giq_option(-3, SCRIPT_FRANCIS, 128, Francis13, NEUTRAL_REACTION);
end

procedure Francis07_1
begin
	gsay_message(SCRIPT_FRANCIS, message_str(SCRIPT_FRANCIS, 129) + message_str(SCRIPT_FRANCIS, 130), NEUTRAL_REACTION);
end

procedure Francis07_2
begin
end

procedure Francis08_1
begin
	gsay_message(SCRIPT_FRANCIS, message_str(SCRIPT_FRANCIS, 131) + message_str(SCRIPT_FRANCIS, 132), NEUTRAL_REACTION);
end

procedure Francis08_2
begin
end

procedure Francis09_1
begin
	gsay_message(SCRIPT_FRANCIS, message_str(SCRIPT_FRANCIS, 133) + message_str(SCRIPT_FRANCIS, 134), NEUTRAL_REACTION);
end

procedure Francis09_2
begin
	gsay_message(SCRIPT_FRANCIS, message_str(SCRIPT_FRANCIS, 134), NEUTRAL_REACTION);
end

procedure Francis10_1
begin
	gsay_message(SCRIPT_FRANCIS, message_str(SCRIPT_FRANCIS, 135) + message_str(SCRIPT_FRANCIS, 136), NEUTRAL_REACTION);
end

procedure Francis10_2
begin
end

procedure Francis11_1
begin
	gsay_message(SCRIPT_FRANCIS, message_str(SCRIPT_FRANCIS, 137) + message_str(SCRIPT_FRANCIS, 138), NEUTRAL_REACTION);
end

procedure Francis11_2
begin
end

procedure Francis12_1
begin
	gsay_message(SCRIPT_FRANCIS, message_str(SCRIPT_FRANCIS, 139) + message_str(SCRIPT_FRANCIS, 140), NEUTRAL_REACTION);
end

procedure Francis12_2
begin
end

procedure Francis13
begin
	gsay_message(SCRIPT_FRANCIS, message_str(SCRIPT_FRANCIS, 141), NEUTRAL_REACTION);
end

procedure Francis14
begin
	if (dude_is_male) then begin
		gsay_message(SCRIPT_FRANCIS, 142, NEUTRAL_REACTION);
	end
	else begin
		gsay_message(SCRIPT_FRANCIS, 143, NEUTRAL_REACTION);
	end
end

procedure Francis15_1
begin
	gsay_message(SCRIPT_FRANCIS, message_str(SCRIPT_FRANCIS, 144) + message_str(SCRIPT_FRANCIS, 145) + message_str(SCRIPT_FRANCIS, 146), NEUTRAL_REACTION);
end

procedure Francis15_2
begin
end

procedure Francis15_3
begin
end

procedure Francis16
begin
	gsay_message(SCRIPT_FRANCIS, 147, NEUTRAL_REACTION);
end

procedure Francis17_1
begin
	gsay_message(SCRIPT_FRANCIS, message_str(SCRIPT_FRANCIS, 148) + message_str(SCRIPT_FRANCIS, 149), NEUTRAL_REACTION);
end

procedure Francis17_2
begin
end

procedure Francis18
begin
	if (dude_is_male) then begin
		gsay_message(SCRIPT_FRANCIS, 150, NEUTRAL_REACTION);
	end
	else begin
		gsay_message(SCRIPT_FRANCIS, 151, NEUTRAL_REACTION);
	end
end

procedure Francis19
begin
	gsay_message(SCRIPT_FRANCIS, 152, NEUTRAL_REACTION);
end

procedure Francis20
begin
	if (dude_is_male) then begin
		gsay_message(SCRIPT_FRANCIS, 153, NEUTRAL_REACTION);
	end
	else begin
		gsay_message(SCRIPT_FRANCIS, 154, NEUTRAL_REACTION);
	end
end

procedure Francis21_1
begin
	gsay_message(SCRIPT_FRANCIS, message_str(SCRIPT_FRANCIS, 155) + message_str(SCRIPT_FRANCIS, 156), NEUTRAL_REACTION);
end

procedure Francis21_2
begin
end

procedure Francis22
begin
	gsay_message(SCRIPT_FRANCIS, 157, NEUTRAL_REACTION);
end

procedure FrancisEnd
begin
end

procedure Combat
begin
	Hostile := 1;
end