#include <define.h>

//#define NAME                    SCRIPT_

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



procedure start;
#include <push.h>
procedure critter_p_proc;
procedure damage_p_proc;
procedure destroy_p_proc;
procedure look_at_p_proc;
procedure map_enter_p_proc;
procedure pickup_p_proc;
procedure talk_p_proc;
procedure timed_event_p_proc;
procedure Marcelles00;
procedure Marcelles01;
procedure Marcelles02;
procedure Marcelles02a;
procedure Marcelles03;
procedure Marcelles04;
procedure Marcelles05;
procedure Marcelles06;
procedure Marcelles07;
procedure Marcelles08;
procedure Marcelles08a;
procedure Marcelles08b;
procedure Marcelles09;
procedure Marcelles10;
procedure Marcelles11;
procedure Marcelles12;
procedure Marcelles13;
procedure Marcelles14;
procedure Marcelles14a;
procedure Marcelles15;
procedure Marcelles16;
procedure Marcelles17;
procedure Marcelles17a;
procedure Marcelles18;
procedure Marcelles18a;
procedure Marcelles19;
procedure Marcelles19a;
procedure Marcelles19b;
procedure Marcelles20;
procedure Marcelles21;
procedure Marcelles22;
procedure Marcelles23;
procedure Marcelles24;
procedure Marcelles24a;
procedure Marcelles25;
procedure Marcelles26;
procedure Marcelles26a;
procedure Marcelles27;
procedure Marcelles28;
procedure Marcelles29;
procedure Marcelles29a;
procedure Marcelles30;
procedure Marcelles31;
procedure Marcelles32;
procedure Marcelles33;
procedure go_to_room;
procedure MarcellesEnd;
procedure Marcelles_charge_raider;
procedure sleeping;

variable night_person;
variable wake_time;
variable sleep_time;
variable home_tile;
variable sleep_tile;
variable Bessy;
variable hostile1;
variable message;
variable moving_disabled;
variable showing_room;
variable sleeping_disabled;
variable desk_tile := 19901;
variable dest_tile1 := 19901;
variable room_tile := 19289;
variable waiting_tile := 19095;

import variable JTRaider_ptr;
import variable Sinthia_ptr;
import variable messing_with_fridge;

variable line00flag;
variable line04flag;
variable line06flag;
variable line29flag;
variable Shooting;
variable sfx_name;

procedure Get_Reaction;
procedure React_To_Level;
procedure Level_To_React;
procedure Up_React;
procedure Down_React;
procedure Bottom_React;
procedure Top_React;
procedure Big_Up_React;
procedure Big_Down_React;
procedure Up_React_Level;
procedure Down_React_Level;
procedure Goodbyes;

variable exit_line;

procedure map_update_p_proc;


procedure start
begin
	if (script_action == critter_proc) then begin
		call critter_p_proc;
	end
	else begin
		if (script_action == look_at_proc) then begin
			call look_at_p_proc;
		end
		else begin
			if (script_action == map_enter_proc) then begin
				call map_enter_p_proc;
			end
			else begin
				if (script_action == pickup_proc) then begin
					call pickup_p_proc;
				end
				else begin
					if (script_action == talk_proc) then begin
						call talk_p_proc;
					end
					else begin
						if (script_action == timed_event_proc) then begin
							call timed_event_p_proc;
						end
					end
				end
			end
		end
	end
end

procedure critter_p_proc
begin
	if (hostile1) then begin
		hostile1 := 0;
		attack_complex(dude_obj, 0, 1, 0, 0, 30000, 0, 0);
	end
	else begin
		if (Shooting == 0) then begin
			if ((moving_disabled == 0) and (local_var(5) == 0)) then begin
				if (tile_num(self_obj) != dest_tile1) then begin
					animate_move_obj_to_tile(self_obj, dest_tile1, ANIMATE_WALK);
				end
			end
			if (showing_room) then begin
				dest_tile1 := room_tile;
				if (tile_num(self_obj) != dest_tile1) then begin
					animate_move_obj_to_tile(self_obj, dest_tile1, ANIMATE_WALK);
				end
				else begin
					add_timer_event(self_obj, game_ticks(5), 1);
					showing_room := 0;
				end
			end
			else begin
				if (obj_can_see_obj(self_obj, dude_obj) and messing_with_fridge) then begin
					call Marcelles33;
				end
			end
			if ((global_var(GVAR_SAVE_SINTHIA) != 2) and (map_var(3) != 0)) then begin
				if (tile_num(self_obj) != waiting_tile) then begin
					if (local_var(5)) then begin
						set_local_var(5, 0);
						sleeping_disabled := 1;
					end
					else begin
						showing_room := 0;
						rm_timer_event(self_obj);
						dest_tile1 := waiting_tile;
					end
				end
				if (global_var(GVAR_SAVE_SINTHIA) == 0) then begin
					if (obj_can_see_obj(self_obj, dude_obj)) then begin
						if (tile_distance_objs(self_obj, dude_obj) < 12) then begin
							if (not(line00flag)) then begin
								if (tile_num(self_obj) == waiting_tile) then begin
									dialogue_system_enter;
								end
							end
						end
					end
				end
			end
			else begin
				if ((global_var(GVAR_SAVE_SINTHIA) == 2) or (map_var(0) == 2)) then begin
					if ((tile_num(self_obj) != sleep_tile) and sleeping_disabled) then begin
						dest_tile1 := sleep_tile;
					end
					else begin
						sleeping_disabled := 0;
					end
					moving_disabled := 0;
				end
			end
			if (tile_distance(tile_num(dude_obj), desk_tile) < 8) then begin
				if (local_var(5) == 1) then begin
					dest_tile1 := desk_tile;
					moving_disabled := 0;
					sleeping_disabled := 1;
				end
			end
			else begin
				sleeping_disabled := 0;
			end
			if (sleeping_disabled == 0) then begin
				call sleeping;
			end
		end
	end
end

procedure damage_p_proc
begin
	if (source_obj == dude_obj) then begin
		set_global_var(GVAR_ENEMY_JUNKTOWN, 1);
	end
end

procedure destroy_p_proc
begin
	if (source_obj == dude_obj) then begin
		set_global_var(GVAR_ENEMY_JUNKTOWN, 1);
		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_GOOD_MONSTER, global_var(GVAR_GOOD_MONSTER) + 1);
			if ((global_var(GVAR_GOOD_MONSTER) % 2) == 0) then begin
				set_global_var(GVAR_PLAYER_REPUTATION, global_var(GVAR_PLAYER_REPUTATION) - 1);
			end
		end
	end
end

procedure look_at_p_proc
begin
	script_overrides;
	if (local_var(4)) then begin
		display_msg(message_str(SCRIPT_MARCELLE, 100));
	end
	else begin
		display_msg(message_str(SCRIPT_MARCELLE, 101));
	end
end

procedure map_enter_p_proc
begin
	if (obj_carrying_pid_obj(self_obj, 94)) then begin
		Bessy := obj_carrying_pid_obj(self_obj, 94);
	end
	else begin
		Bessy := create_object_sid(94, 0, 0, -1);
		add_obj_to_inven(self_obj, Bessy);
	end
	critter_add_trait(self_obj, TRAIT_OBJECT, OBJECT_TEAM_NUM, 16);
	sleep_tile := 20509;
	home_tile := 19901;
	wake_time := 600;
	sleep_time := 1900;
end

procedure pickup_p_proc
begin
	hostile1 := 1;
end

procedure talk_p_proc
begin
	if (local_var(5) == 1) then begin
		float_msg(self_obj, message_str(SCRIPT_GENVAULT, 166), FLOAT_MSG_NORMAL);
	end
	else begin
		if ((tile_num(self_obj) != home_tile) and (tile_num(self_obj) != waiting_tile)) then begin
			script_overrides;
		end
		else begin
			call Get_Reaction;
			start_gdialog(SCRIPT_MARCELLE, self_obj, 4, -1, -1);
			gsay_start;
			if ((global_var(GVAR_SAVE_SINTHIA) == 0) and not(line00flag) and (map_var(3) != 0)) then begin
				call Marcelles00;
			end
			else begin
				if (global_var(GVAR_SAVE_SINTHIA) == 1) then begin
					call Marcelles03;
				end
				else begin
					if ((global_var(GVAR_SAVE_SINTHIA) == 2) and not(line04flag) and (map_var(0) != 2)) then begin
						call Marcelles04;
					end
					else begin
						if ((map_var(0) == 2) and not(line06flag)) then begin
							call Marcelles06;
						end
						else begin
							if ((global_var(GVAR_KILL_KILLIAN) == 2) and not(line29flag)) then begin
								call Marcelles29;
							end
							else begin
								if (not(local_var(4))) then begin
									call Marcelles07;
								end
								else begin
									if (local_var(1) < 2) then begin
										call Marcelles22;
									end
									else begin
										call Marcelles17;
									end
								end
							end
						end
					end
				end
			end
			gsay_end;
			end_dialogue;
		end
	end
	sleeping_disabled := 0;
	if (showing_room) then begin
		call go_to_room;
	end
end

procedure timed_event_p_proc
begin
	if (fixed_param == 1) then begin
		add_timer_event(self_obj, game_ticks(2), 2);
	end
	else begin
		if (fixed_param == 2) then begin
			dest_tile1 := home_tile;
			moving_disabled := 0;
		end
		else begin
			if (fixed_param == 3) then begin
				if (tile_distance(tile_num(self_obj), 18089) > 2) then begin
					animate_move_obj_to_tile(self_obj, 18089, ANIMATE_RUN);
					add_timer_event(self_obj, 5, 3);
				end
				else begin
					add_timer_event(self_obj, 5, 4);
				end
			end
			else begin
				if (fixed_param == 4) then begin
					reg_anim_func(2, JTRaider_ptr);
					reg_anim_func(1, 1);
					reg_anim_animate(JTRaider_ptr, 43, -1);
					reg_anim_animate(JTRaider_ptr, 45, -1);
					reg_anim_animate(JTRaider_ptr, 44, -1);
					reg_anim_func(3, 0);
					critter_dmg(Sinthia_ptr, random(75, 100), 0);
					add_timer_event(self_obj, 5, 5);
					if (obj_is_carrying_obj_pid(self_obj, 94) == 0) then begin
						Bessy := create_object_sid(94, 0, 0, -1);
						add_obj_to_inven(self_obj, Bessy);
					end
					wield_obj_critter(self_obj, obj_carrying_pid_obj(self_obj, 94));
				end
				else begin
					if (fixed_param == 5) then begin
						reg_anim_func(2, self_obj);
						reg_anim_func(1, 1);
						reg_anim_animate(self_obj, 43, -1);
						reg_anim_animate(self_obj, 45, -1);
						sfx_name := sfx_build_weapon_name(1, obj_carrying_pid_obj(self_obj, 94), 0, JTRaider_ptr);
						reg_anim_play_sfx(self_obj, sfx_name, 0);
						reg_anim_animate(self_obj, 44, -1);
						reg_anim_func(3, 0);
						critter_dmg(JTRaider_ptr, random(75, 100), 0);
						Shooting := 0;
						game_ui_enable;
					end
					else begin
						if (fixed_param == 6) then begin
							if (global_var(GVAR_SAVE_SINTHIA) != 2) then begin
								call Marcelles_charge_raider;
							end
						end
					end
				end
			end
		end
	end
end

procedure Marcelles00
begin
	line00flag := 1;
	set_global_var(GVAR_SAVE_SINTHIA, 1);
	gsay_reply(SCRIPT_MARCELLE, 102);
	giq_option(4, SCRIPT_MARCELLE, 103, Marcelles02, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_MARCELLE, 104, Up_React, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_MARCELLE, 105, Marcelles01, NEUTRAL_REACTION);
end

procedure Marcelles01
begin
	gsay_message(SCRIPT_MARCELLE, 106, NEUTRAL_REACTION);
end

procedure Marcelles02
begin
	call Down_React;
	gsay_reply(SCRIPT_MARCELLE, 107);
	giq_option(4, SCRIPT_MARCELLE, 108, Marcelles02a, BAD_REACTION);
	giq_option(4, SCRIPT_MARCELLE, 109, MarcellesEnd, NEUTRAL_REACTION);
end

procedure Marcelles02a
begin
	call Big_Down_React;
	call Marcelles_charge_raider;
end

procedure Marcelles03
begin
	gsay_message(SCRIPT_MARCELLE, 110, NEUTRAL_REACTION);
end

procedure Marcelles04
begin
	line04flag := 1;
	gsay_reply(SCRIPT_MARCELLE, 111);
	giq_option(-3, SCRIPT_MARCELLE, 112, Marcelles05, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_MARCELLE, 113, Marcelles05, NEUTRAL_REACTION);
end

procedure Marcelles05
begin
	gsay_message(SCRIPT_MARCELLE, 114, NEUTRAL_REACTION);
	if (global_var(GVAR_RENT_TIME) < (game_time / (10 * 60 * 60 * 24))) then begin
		set_global_var(GVAR_RENT_TIME, (game_time / (10 * 60 * 60 * 24)) + 1);
	end
	else begin
		set_global_var(GVAR_RENT_TIME, global_var(GVAR_RENT_TIME) + 1);
	end
	showing_room := 1;
	message := message_str(SCRIPT_MARCELLE, 115);
end

procedure Marcelles06
begin
	line06flag := 1;
	call Big_Down_React;
	gsay_reply(SCRIPT_MARCELLE, 116);
	giq_option(4, SCRIPT_MARCELLE, 117, MarcellesEnd, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_MARCELLE, 118, MarcellesEnd, NEUTRAL_REACTION);
end

procedure Marcelles07
begin
	set_local_var(4, 1);
	gsay_reply(SCRIPT_MARCELLE, 119);
	giq_option(4, SCRIPT_MARCELLE, 120, Marcelles12, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_MARCELLE, 121, Marcelles13, NEUTRAL_REACTION);
	giq_option(7, SCRIPT_MARCELLE, 122, Marcelles14, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_MARCELLE, 123, Marcelles08, NEUTRAL_REACTION);
end

procedure Marcelles08
begin
	gsay_reply(SCRIPT_MARCELLE, 124);
	giq_option(-3, SCRIPT_MARCELLE, 125, Marcelles09, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_MARCELLE, 126, Marcelles08a, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_MARCELLE, 127, Marcelles08b, NEUTRAL_REACTION);
end

procedure Marcelles08a
begin
	if (item_caps_total(dude_obj) >= 25) then begin
		item_caps_adjust(dude_obj, -25);
		if (global_var(GVAR_RENT_TIME) < (game_time / (10 * 60 * 60 * 24))) then begin
			set_global_var(GVAR_RENT_TIME, (game_time / (10 * 60 * 60 * 24)) + 1);
		end
		else begin
			set_global_var(GVAR_RENT_TIME, global_var(GVAR_RENT_TIME) + 1);
		end
		call Marcelles10;
	end
	else begin
		call Marcelles11;
	end
end

procedure Marcelles08b
begin
	if (item_caps_total(dude_obj) >= 150) then begin
		item_caps_adjust(dude_obj, -150);
		if (global_var(GVAR_RENT_TIME) < (game_time / (10 * 60 * 60 * 24))) then begin
			set_global_var(GVAR_RENT_TIME, (game_time / (10 * 60 * 60 * 24)) + 7);
		end
		else begin
			set_global_var(GVAR_RENT_TIME, global_var(GVAR_RENT_TIME) + 7);
		end
		call Marcelles10;
	end
	else begin
		call Marcelles11;
	end
end

procedure Marcelles09
begin
	gsay_message(SCRIPT_MARCELLE, 128, NEUTRAL_REACTION);
end

procedure Marcelles10
begin
	gsay_message(SCRIPT_MARCELLE, 129, NEUTRAL_REACTION);
	showing_room := 1;
	message := message_str(SCRIPT_MARCELLE, 130);
end

procedure Marcelles11
begin
	gsay_message(SCRIPT_MARCELLE, 131, NEUTRAL_REACTION);
end

procedure Marcelles12
begin
	gsay_message(SCRIPT_MARCELLE, 132, NEUTRAL_REACTION);
end

procedure Marcelles13
begin
	gsay_reply(SCRIPT_MARCELLE, 133);
	giq_option(4, SCRIPT_MARCELLE, 134, Marcelles08b, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_MARCELLE, 135, Marcelles08a, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_MARCELLE, 136, MarcellesEnd, NEUTRAL_REACTION);
end

procedure Marcelles14
begin
	gsay_reply(SCRIPT_MARCELLE, 137);
	giq_option(5, SCRIPT_MARCELLE, 138, Marcelles14a, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_MARCELLE, 182, MarcellesEnd, NEUTRAL_REACTION);
end

procedure Marcelles14a
begin
	if (item_caps_total(dude_obj) >= 50) then begin
		call Marcelles15;
	end
	else begin
		call Marcelles16;
	end
end

procedure Marcelles15
begin
	item_caps_adjust(dude_obj, -50);
	gsay_message(SCRIPT_MARCELLE, 139, NEUTRAL_REACTION);
end

procedure Marcelles16
begin
	call Down_React;
	gsay_message(SCRIPT_MARCELLE, 140, NEUTRAL_REACTION);
end

procedure Marcelles17
begin
	gsay_reply(SCRIPT_MARCELLE, 141);
	giq_option(4, SCRIPT_MARCELLE, 142, Marcelles17a, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_MARCELLE, 184, MarcellesEnd, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_MARCELLE, 143, Marcelles17a, NEUTRAL_REACTION);
end

procedure Marcelles17a
begin
	if (global_var(GVAR_RENT_TIME) > (game_time / (10 * 60 * 60 * 24))) then begin
		call Marcelles18;
	end
	else begin
		call Marcelles20;
	end
end

procedure Marcelles18
begin
	gsay_reply(SCRIPT_MARCELLE, 144);
	giq_option(4, SCRIPT_MARCELLE, 145, Marcelles18a, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_MARCELLE, 146, MarcellesEnd, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_MARCELLE, 147, Marcelles18a, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_MARCELLE, 148, MarcellesEnd, NEUTRAL_REACTION);
end

procedure Marcelles18a
begin
	call Down_React;
	showing_room := 1;
	message := message_str(SCRIPT_MARCELLE, 149);
end

procedure Marcelles19
begin
	gsay_reply(SCRIPT_MARCELLE, 150);
	giq_option(-3, SCRIPT_MARCELLE, 151, Marcelles09, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_MARCELLE, 152, Marcelles19a, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_MARCELLE, 153, Marcelles19b, NEUTRAL_REACTION);
end

procedure Marcelles19a
begin
	if (item_caps_total(dude_obj) >= 25) then begin
		item_caps_adjust(dude_obj, -25);
		if (global_var(GVAR_RENT_TIME) < (game_time / (10 * 60 * 60 * 24))) then begin
			set_global_var(GVAR_RENT_TIME, (game_time / (10 * 60 * 60 * 24)) + 1);
		end
		else begin
			set_global_var(GVAR_RENT_TIME, global_var(GVAR_RENT_TIME) + 1);
		end
		call Marcelles21;
	end
	else begin
		call Marcelles11;
	end
end

procedure Marcelles19b
begin
	if (item_caps_total(dude_obj) >= 150) then begin
		item_caps_adjust(dude_obj, -150);
		if (global_var(GVAR_RENT_TIME) < (game_time / (10 * 60 * 60 * 24))) then begin
			set_global_var(GVAR_RENT_TIME, (game_time / (10 * 60 * 60 * 24)) + 7);
		end
		else begin
			set_global_var(GVAR_RENT_TIME, global_var(GVAR_RENT_TIME) + 7);
		end
		call Marcelles21;
	end
	else begin
		call Marcelles11;
	end
end

procedure Marcelles20
begin
	gsay_reply(SCRIPT_MARCELLE, 154);
	giq_option(4, SCRIPT_MARCELLE, 155, Marcelles19b, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_MARCELLE, 156, Marcelles19a, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_MARCELLE, 157, MarcellesEnd, NEUTRAL_REACTION);
end

procedure Marcelles21
begin
	call Up_React;
	gsay_message(SCRIPT_MARCELLE, 158, NEUTRAL_REACTION);
end

procedure Marcelles22
begin
	gsay_reply(SCRIPT_MARCELLE, 159);
	giq_option(4, SCRIPT_MARCELLE, 160, Marcelles24, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_MARCELLE, 184, MarcellesEnd, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_MARCELLE, 161, Marcelles23, NEUTRAL_REACTION);
end

procedure Marcelles23
begin
	gsay_message(SCRIPT_MARCELLE, 162, NEUTRAL_REACTION);
end

procedure Marcelles24
begin
	gsay_reply(SCRIPT_MARCELLE, 163);
	giq_option(4, SCRIPT_MARCELLE, 164, Marcelles24a, NEUTRAL_REACTION);
end

procedure Marcelles24a
begin
	if (is_success(roll_vs_skill(dude_obj, 14, 0))) then begin
		call Marcelles26;
	end
	else begin
		call Marcelles25;
	end
end

procedure Marcelles25
begin
	gsay_message(SCRIPT_MARCELLE, 165, NEUTRAL_REACTION);
end

procedure Marcelles26
begin
	gsay_reply(SCRIPT_MARCELLE, 166);
	giq_option(4, SCRIPT_MARCELLE, 167, Marcelles27, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_MARCELLE, 168, Marcelles26a, NEUTRAL_REACTION);
end

procedure Marcelles26a
begin
	if (item_caps_total(dude_obj) >= 100) then begin
		item_caps_adjust(dude_obj, -100);
		if (global_var(GVAR_RENT_TIME) < (game_time / (10 * 60 * 60 * 24))) then begin
			set_global_var(GVAR_RENT_TIME, (game_time / (10 * 60 * 60 * 24)) + 1);
		end
		else begin
			set_global_var(GVAR_RENT_TIME, global_var(GVAR_RENT_TIME) + 1);
		end
		call Marcelles28;
	end
	else begin
		call Marcelles11;
	end
end

procedure Marcelles27
begin
	gsay_reply(SCRIPT_MARCELLE, 169);
	giq_option(4, SCRIPT_MARCELLE, 170, MarcellesEnd, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_MARCELLE, 171, Marcelles26a, NEUTRAL_REACTION);
end

procedure Marcelles28
begin
	gsay_message(SCRIPT_MARCELLE, 172, NEUTRAL_REACTION);
end

procedure Marcelles29
begin
	line29flag := 1;
	gsay_reply(SCRIPT_MARCELLE, 173);
	giq_option(4, SCRIPT_MARCELLE, 174, Marcelles31, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_MARCELLE, 175, Marcelles29a, NEUTRAL_REACTION);
	giq_option(-3, SCRIPT_MARCELLE, 176, Marcelles30, NEUTRAL_REACTION);
end

procedure Marcelles29a
begin
	if (is_success(roll_vs_skill(dude_obj, 14, 0))) then begin
		call Marcelles32;
	end
	else begin
		call Marcelles31;
	end
end

procedure Marcelles30
begin
	call Bottom_React;
	gsay_message(SCRIPT_MARCELLE, 177, BAD_REACTION);
end

procedure Marcelles31
begin
	call Bottom_React;
	gsay_message(SCRIPT_MARCELLE, 178, BAD_REACTION);
end

procedure Marcelles32
begin
	call Big_Down_React;
	gsay_message(SCRIPT_MARCELLE, 179, BAD_REACTION);
end

procedure Marcelles33
begin
	messing_with_fridge := 0;
	if (global_var(GVAR_RENT_TIME) <= (game_time / (10 * 60 * 60 * 24))) then begin
		float_msg(self_obj, message_str(SCRIPT_MARCELLE, 181), FLOAT_MSG_RED);
		if (local_var(6) == 1) then begin
			hostile1 := 1;
		end
		else begin
			set_local_var(6, 1);
		end
	end
end

procedure go_to_room
begin
	showing_room := 1;
	sleeping_disabled := 1;
	moving_disabled := 1;
end

procedure MarcellesEnd
begin
end

procedure Marcelles_charge_raider
begin
	display_msg(message_str(SCRIPT_MARCELLE, 183));
	add_timer_event(self_obj, 5, 3);
	game_ui_disable;
	Shooting := 1;
end

procedure sleeping
begin
	if (local_var(5) == 1) then begin
		if (not(night_person) and (game_time_hour >= wake_time) and (game_time_hour < sleep_time) or (night_person and ((game_time_hour >= wake_time) or (game_time_hour < sleep_time)))) then begin
			if (((game_time_hour - wake_time) < 10) and ((game_time_hour - wake_time) > 0)) then begin
				if (tile_num(self_obj) != home_tile) then begin
					animate_move_obj_to_tile(self_obj, home_tile, ANIMATE_WALK);
				end
				else begin
					set_local_var(5, 0);
				end
			end
			else begin
				move_to(self_obj, home_tile, elevation(self_obj));
				if (tile_num(self_obj) == home_tile) then begin
					set_local_var(5, 0);
				end
			end
		end
	end
	else begin
		if (night_person and (game_time_hour >= sleep_time) and (game_time_hour < wake_time) or (not(night_person) and ((game_time_hour >= sleep_time) or (game_time_hour < wake_time)))) then begin
			if (((game_time_hour - sleep_time) < 10) and ((game_time_hour - sleep_time) > 0)) then begin
				if (tile_num(self_obj) != sleep_tile) then begin
					animate_move_obj_to_tile(self_obj, self_obj, ANIMATE_WALK);
				end
				else begin
					set_local_var(5, 1);
				end
			end
			else begin
				if (tile_num(self_obj) != sleep_tile) then begin
					move_to(self_obj, sleep_tile, elevation(self_obj));
				end
				else begin
					set_local_var(5, 1);
				end
			end
		end
	end
end

procedure Get_Reaction
begin
	if (local_var(2) == 0) then begin
		set_local_var(0, 50);
		set_local_var(1, 2);
		set_local_var(2, 1);
		set_local_var(0, local_var(0) + (5 * get_critter_stat(dude_obj, 3)) - 25);
		set_local_var(0, local_var(0) + (10 * has_trait(0, dude_obj, 10)));
		if (has_trait(0, dude_obj, 39)) then begin
			if (global_var(GVAR_PLAYER_REPUTATION) > 0) then begin
				set_local_var(0, local_var(0) + global_var(GVAR_PLAYER_REPUTATION));
			end
			else begin
				set_local_var(0, local_var(0) - global_var(GVAR_PLAYER_REPUTATION));
			end
		end
		else begin
			if (local_var(3) == 1) then begin
				set_local_var(0, local_var(0) - global_var(GVAR_PLAYER_REPUTATION));
			end
			else begin
				set_local_var(0, local_var(0) + global_var(GVAR_PLAYER_REPUTATION));
			end
		end
		if (global_var(GVAR_CHILDKILLER_REPUTATION) > 2) then begin
			set_local_var(0, local_var(0) - 30);
		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_local_var(0, local_var(0) + 20);
		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
			set_local_var(0, local_var(0) - 20);
		end
		call React_To_Level;
	end
end

procedure React_To_Level
begin
	if (local_var(0) <= 25) then begin
		set_local_var(1, 1);
	end
	else begin
		if (local_var(0) <= 75) then begin
			set_local_var(1, 2);
		end
		else begin
			set_local_var(1, 3);
		end
	end
end

procedure Level_To_React
begin
	if (local_var(1) == 1) then begin
		set_local_var(0, random(1, 25));
	end
	else begin
		if (local_var(1) == 2) then begin
			set_local_var(0, random(26, 75));
		end
		else begin
			set_local_var(0, random(76, 100));
		end
	end
end

procedure Up_React
begin
	set_local_var(0, local_var(0) + 10);
	call React_To_Level;
end

procedure Down_React
begin
	set_local_var(0, local_var(0) - 10);
	call React_To_Level;
end

procedure Bottom_React
begin
	set_local_var(1, 1);
	set_local_var(0, 1);
end

procedure Top_React
begin
	set_local_var(0, 100);
	set_local_var(1, 3);
end

procedure Big_Up_React
begin
	set_local_var(0, local_var(0) + 25);
	call React_To_Level;
end

procedure Big_Down_React
begin
	set_local_var(0, local_var(0) - 25);
	call React_To_Level;
end

procedure Up_React_Level
begin
	set_local_var(1, local_var(1) + 1);
	if (local_var(1) > 3) then begin
		set_local_var(1, 3);
	end
	call Level_To_React;
end

procedure Down_React_Level
begin
	set_local_var(1, local_var(1) - 1);
	if (local_var(1) < 1) then begin
		set_local_var(1, 1);
	end
	call Level_To_React;
end

procedure Goodbyes
begin
	exit_line := message_str(SCRIPT_MODREACT, random(100, 105));
end

procedure map_update_p_proc
begin
	if ((global_var(GVAR_SAVE_SINTHIA) == 0) and (line00flag == 0) and (map_var(3) != 0)) then begin
		move_to(self_obj, waiting_tile, 0);
		dest_tile1 := waiting_tile;
		showing_room := 0;
	end
end