#include <define.h>

//#define NAME                    SCRIPT_

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



procedure start;
#include <push.h>
procedure damage_p_proc;
procedure description_p_proc;
procedure look_at_p_proc;
procedure talk_p_proc;
procedure use_p_proc;
procedure use_obj_on_p_proc;
procedure use_skill_on_p_proc;
procedure VConComp00;
procedure VConComp01;
procedure VConComp01a;
procedure VConComp02;
procedure VConComp02a;
procedure VConComp03;
procedure VConComp04;
procedure VConComp05;
procedure VConComp06;
procedure VConComp07;
procedure VConComp08;
procedure VConComp09;
procedure VConComp10;
procedure VConComp11;
procedure VConComp12;
procedure VConComp12a;
procedure VConComp13;
procedure VConComp13a;
procedure VConComp14;
procedure VConComp15;
procedure VConComp16;
procedure VConComp17;
procedure VConComp17a;
procedure VConComp17b;
procedure VConComp18;
procedure VConComp18a;
procedure VConComp19;
procedure VConComp19a;
procedure VConComp20;
procedure VConComp21;
procedure VConComp22;
procedure VConComp23;
procedure VConComp24;
procedure VConComp25;
procedure VConComp26;
procedure VConComp27;
procedure VConComp28;
procedure VConComp29;
procedure VConComp30;
procedure VConComp31;
procedure VConComp32;
procedure VConCompEnd;
procedure Update_Invasion;


procedure start
begin
	if (script_action == damage_proc) then begin
		call damage_p_proc;
	end
	else begin
		if (script_action == look_at_proc) then begin
			call look_at_p_proc;
		end
		else 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
	end
end

procedure damage_p_proc
begin
	if (global_var(GVAR_VATS_BLOWN) == 0) then begin
		set_global_var(GVAR_VATS_COUNTDOWN, game_time / 10);
		set_global_var(GVAR_PLAYER_REPUTATION, global_var(GVAR_PLAYER_REPUTATION) + 5);
		set_global_var(GVAR_VATS_BLOWN, 1);
		set_global_var(GVAR_DESTROY_MASTER_4, 2);
		call Update_Invasion;
		display_msg(message_str(SCRIPT_VCONCOMP, 179));
	end
end

procedure description_p_proc
begin
	script_overrides;
	display_msg(message_str(SCRIPT_VCONCOMP, 200));
end

procedure look_at_p_proc
begin
	script_overrides;
	display_msg(message_str(SCRIPT_VCONCOMP, 100));
end

procedure talk_p_proc
begin
	if (global_var(GVAR_VATS_COUNTDOWN) == 0) then begin
		if (local_var(0) == 1) then begin
			start_gdialog(SCRIPT_VCONCOMP, self_obj, 4, -1, -1);
			gsay_start;
			call VConComp01;
			gsay_end;
			end_dialogue;
		end
		else begin
			start_gdialog(SCRIPT_VCONCOMP, self_obj, 4, -1, -1);
			gsay_start;
			call VConComp00;
			gsay_end;
			end_dialogue;
		end
	end
end

procedure use_p_proc
begin
	script_overrides;
	if (local_var(0) == 0) then begin
		display_msg(message_str(SCRIPT_VCONCOMP, 177));
	end
	else begin
		dialogue_system_enter;
	end
end

procedure use_obj_on_p_proc
begin
	if (obj_pid(obj_being_used_with) == 221) then begin
		if (local_var(0) == 0) then begin
			script_overrides;
			display_msg(message_str(SCRIPT_VCONCOMP, 180));
			set_local_var(0, 1);
			dialogue_system_enter;
		end
	end
end

procedure use_skill_on_p_proc
begin
	if (action_being_used == 12) then begin
		script_overrides;
		if (is_success(roll_vs_skill(dude_obj, 12, 0))) then begin
			set_local_var(0, 1);
			display_msg(message_str(SCRIPT_VCONCOMP, 176));
		end
		else begin
			display_msg(message_str(SCRIPT_VCONCOMP, 178));
		end
		game_time_advance(game_ticks(300));
	end
end

procedure VConComp00
begin
	gsay_message(SCRIPT_VCONCOMP, 101, BAD_REACTION);
end

procedure VConComp01
begin
	gsay_reply(SCRIPT_VCONCOMP, 102);
	call VConComp01a;
end

procedure VConComp01a
begin
	giq_option(4, SCRIPT_VCONCOMP, 103, VConComp02, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 104, VConComp11, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 106, VConComp05, NEUTRAL_REACTION);
	giq_option(0, SCRIPT_VCONCOMP, 181, VConCompEnd, NEUTRAL_REACTION);
end

procedure VConComp02
begin
	gsay_reply(SCRIPT_VCONCOMP, 140);
	giq_option(4, SCRIPT_VCONCOMP, 107, VConComp03, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 108, VConComp04, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 109, VConComp05, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 110, VConComp06, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 111, VConComp07, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 112, VConComp08, NEUTRAL_REACTION);
	giq_option(5, SCRIPT_VCONCOMP, 113, VConComp02a, NEUTRAL_REACTION);
	giq_option(0, SCRIPT_VCONCOMP, 181, VConCompEnd, NEUTRAL_REACTION);
end

procedure VConComp02a
begin
	if (is_success(roll_vs_skill(dude_obj, 12, -10)) or (global_var(GVAR_CALM_REBELS_1) == 1)) then begin
		call VConComp09;
	end
	else begin
		call VConComp10;
	end
end

procedure VConComp03
begin
	gsay_message(SCRIPT_VCONCOMP, 114, NEUTRAL_REACTION);
	set_global_var(GVAR_VATS_COUNTDOWN, (game_time / 10) - 240);
	set_global_var(GVAR_PLAYER_REPUTATION, global_var(GVAR_PLAYER_REPUTATION) + 5);
	set_global_var(GVAR_VATS_BLOWN, 1);
	set_global_var(GVAR_DESTROY_MASTER_4, 2);
end

procedure VConComp04
begin
	gsay_message(SCRIPT_VCONCOMP, 115, NEUTRAL_REACTION);
	set_global_var(GVAR_PLAYER_REPUTATION, global_var(GVAR_PLAYER_REPUTATION) + 5);
	set_global_var(GVAR_VATS_COUNTDOWN, (game_time / 10) - 30);
	set_global_var(GVAR_VATS_BLOWN, 1);
	set_global_var(GVAR_DESTROY_MASTER_4, 2);
end

procedure VConComp05
begin
	gsay_message(SCRIPT_VCONCOMP, 116, NEUTRAL_REACTION);
	set_global_var(GVAR_VATS_ALERT, 1);
end

procedure VConComp06
begin
	gsay_message(SCRIPT_VCONCOMP, 117, NEUTRAL_REACTION);
	set_global_var(GVAR_VATS_COUNTDOWN, game_time / 10);
	set_global_var(GVAR_PLAYER_REPUTATION, global_var(GVAR_PLAYER_REPUTATION) + 5);
	set_global_var(GVAR_VATS_BLOWN, 1);
	set_global_var(GVAR_DESTROY_MASTER_4, 2);
end

procedure VConComp07
begin
	gsay_message(SCRIPT_VCONCOMP, 118, NEUTRAL_REACTION);
	set_global_var(GVAR_VATS_COUNTDOWN, game_time / 10);
	set_global_var(GVAR_PLAYER_REPUTATION, global_var(GVAR_PLAYER_REPUTATION) + 5);
	set_global_var(GVAR_VATS_BLOWN, 1);
	set_global_var(GVAR_DESTROY_MASTER_4, 2);
end

procedure VConComp08
begin
	gsay_message(SCRIPT_VCONCOMP, 119, NEUTRAL_REACTION);
	set_global_var(GVAR_VATS_COUNTDOWN, (game_time / 10) - 299);
	set_global_var(GVAR_PLAYER_REPUTATION, global_var(GVAR_PLAYER_REPUTATION) + 5);
	set_global_var(GVAR_VATS_BLOWN, 1);
	set_global_var(GVAR_DESTROY_MASTER_4, 2);
end

procedure VConComp09
begin
	gsay_reply(SCRIPT_VCONCOMP, 120);
	giq_option(4, SCRIPT_VCONCOMP, 121, VConComp03, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 122, VConComp04, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 123, VConComp05, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 124, VConComp06, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 125, VConComp07, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 126, VConComp08, NEUTRAL_REACTION);
end

procedure VConComp10
begin
	if (local_var(1) == 1) then begin
		set_global_var(GVAR_VATS_ALERT, 1);
	end
	else begin
		set_local_var(1, 1);
	end
	gsay_message(SCRIPT_VCONCOMP, 127, BAD_REACTION);
end

procedure VConComp11
begin
	gsay_reply(SCRIPT_VCONCOMP, 127);
	giq_option(4, SCRIPT_VCONCOMP, 129, VConComp12, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 130, VConComp14, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 131, VConComp13, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 132, VConComp14, NEUTRAL_REACTION);
end

procedure VConComp12
begin
	gsay_reply(SCRIPT_VCONCOMP, 133);
	giq_option(4, SCRIPT_VCONCOMP, 134, VConComp12a, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 135, VConComp15, NEUTRAL_REACTION);
end

procedure VConComp12a
begin
	set_global_var(GVAR_MASTER_FILLER_7, 1);
	call VConComp15;
end

procedure VConComp13
begin
	gsay_reply(SCRIPT_VCONCOMP, 136);
	giq_option(4, SCRIPT_VCONCOMP, 134, VConComp13a, NEUTRAL_REACTION);
end

procedure VConComp13a
begin
	set_global_var(GVAR_MASTER_FILLER_8, 1);
	call VConComp15;
end

procedure VConComp14
begin
	gsay_reply(SCRIPT_VCONCOMP, 139);
	call VConComp01a;
end

procedure VConComp15
begin
	gsay_reply(SCRIPT_VCONCOMP, 140);
	call VConComp01a;
end

procedure VConComp16
begin
	gsay_reply(SCRIPT_VCONCOMP, 141);
	giq_option(6, SCRIPT_VCONCOMP, 142, VConComp17, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 138, VConComp15, NEUTRAL_REACTION);
end

procedure VConComp17
begin
	gsay_reply(SCRIPT_VCONCOMP, 143);
	giq_option(4, SCRIPT_MODREACT, 104, VConCompEnd, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_VCONCOMP, 144, VConComp17a, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_VCONCOMP, 145, VConComp17b, NEUTRAL_REACTION);
end

procedure VConComp17a
begin
	if (is_success(roll_vs_skill(dude_obj, 12, 0))) then begin
		call VConComp18;
	end
	else begin
		call VConComp20;
	end
end

procedure VConComp17b
begin
	if (is_success(roll_vs_skill(dude_obj, 7, 0))) then begin
		call VConComp18;
	end
	else begin
		call VConComp20;
	end
end

procedure VConComp18
begin
	gsay_reply(SCRIPT_VCONCOMP, 146);
	call VConComp18a;
end

procedure VConComp18a
begin
	giq_option(6, SCRIPT_VCONCOMP, 147, VConComp19, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_VCONCOMP, 148, VConComp19, NEUTRAL_REACTION);
	giq_option(7, SCRIPT_VCONCOMP, 149, VConComp19, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 150, VConCompEnd, NEUTRAL_REACTION);
end

procedure VConComp19
begin
	gsay_reply(SCRIPT_VCONCOMP, 151);
	giq_option(6, SCRIPT_VCONCOMP, 152, VConComp20, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_VCONCOMP, 153, VConComp21, NEUTRAL_REACTION);
	giq_option(6, SCRIPT_VCONCOMP, 154, VConComp20, NEUTRAL_REACTION);
	giq_option(7, SCRIPT_VCONCOMP, 155, VConComp19a, NEUTRAL_REACTION);
end

procedure VConComp19a
begin
	if (is_success(roll_vs_skill(dude_obj, 12, -10))) then begin
		call VConComp21;
	end
	else begin
		call VConComp20;
	end
end

procedure VConComp20
begin
	gsay_reply(SCRIPT_VCONCOMP, 156);
	call VConComp18a;
end

procedure VConComp21
begin
	gsay_reply(SCRIPT_VCONCOMP, 157);
	giq_option(6, SCRIPT_VCONCOMP, 158, VConComp27, NEUTRAL_REACTION);
	giq_option(7, SCRIPT_VCONCOMP, 159, VConComp30, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 150, VConCompEnd, NEUTRAL_REACTION);
end

procedure VConComp22
begin
	gsay_reply(SCRIPT_VCONCOMP, 160);
	giq_option(4, SCRIPT_VCONCOMP, 161, VConComp23, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 162, VConComp24, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 163, VConComp25, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 164, VConComp26, NEUTRAL_REACTION);
end

procedure VConComp23
begin
	gsay_reply(SCRIPT_VCONCOMP, 165);
	giq_option(4, SCRIPT_VCONCOMP, 166, VConComp22, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 138, VConComp18, NEUTRAL_REACTION);
end

procedure VConComp24
begin
	gsay_reply(SCRIPT_VCONCOMP, 167);
	giq_option(4, SCRIPT_VCONCOMP, 166, VConComp22, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 138, VConComp18, NEUTRAL_REACTION);
end

procedure VConComp25
begin
	gsay_reply(SCRIPT_VCONCOMP, 168);
	giq_option(4, SCRIPT_VCONCOMP, 166, VConComp22, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 138, VConComp18, NEUTRAL_REACTION);
end

procedure VConComp26
begin
	gsay_reply(SCRIPT_VCONCOMP, 169);
	giq_option(4, SCRIPT_VCONCOMP, 166, VConComp22, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 138, VConComp18, NEUTRAL_REACTION);
end

procedure VConComp27
begin
	gsay_reply(SCRIPT_VCONCOMP, 170);
	giq_option(4, SCRIPT_VCONCOMP, 172, VConComp28, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 173, VConComp29, NEUTRAL_REACTION);
end

procedure VConComp28
begin
	gsay_reply(SCRIPT_VCONCOMP, 171);
	giq_option(4, SCRIPT_VCONCOMP, 138, VConComp32, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 150, VConCompEnd, NEUTRAL_REACTION);
end

procedure VConComp29
begin
	gsay_reply(SCRIPT_VCONCOMP, 146);
	call VConComp18a;
end

procedure VConComp30
begin
	gsay_reply(SCRIPT_VCONCOMP, 174);
	giq_option(4, SCRIPT_VCONCOMP, 172, VConComp31, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 173, VConComp29, NEUTRAL_REACTION);
end

procedure VConComp31
begin
	gsay_reply(SCRIPT_VCONCOMP, 175);
	giq_option(4, SCRIPT_VCONCOMP, 138, VConComp32, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 150, VConCompEnd, NEUTRAL_REACTION);
end

procedure VConComp32
begin
	gsay_reply(SCRIPT_VCONCOMP, 176);
	giq_option(4, SCRIPT_VCONCOMP, 103, VConComp02, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 104, VConComp11, NEUTRAL_REACTION);
	giq_option(4, SCRIPT_VCONCOMP, 105, VConComp05, NEUTRAL_REACTION);
end

procedure VConCompEnd
begin
end

procedure Update_Invasion
begin
	variable LVar0 := 0;
	variable LVar1 := 0;
	variable LVar2 := 0;
	variable LVar3 := 0;
	variable LVar4 := 0;
	LVar0 := global_var(GVAR_THE_HUB_INVADED_DATE) - ((global_var(GVAR_THE_HUB_INVADED_DATE) - (game_time / (10 * 60 * 60 * 24))) / 2);
	LVar1 := global_var(GVAR_BROTHERHOOD_INVADED_DATE) - ((global_var(GVAR_BROTHERHOOD_INVADED_DATE) - (game_time / (10 * 60 * 60 * 24))) / 2);
	LVar2 := global_var(GVAR_JUNKTOWN_INVADED_DATE) - ((global_var(GVAR_JUNKTOWN_INVADED_DATE) - (game_time / (10 * 60 * 60 * 24))) / 2);
	LVar3 := global_var(GVAR_SHADY_SANDS_INVADED_DATE) - ((global_var(GVAR_SHADY_SANDS_INVADED_DATE) - (game_time / (10 * 60 * 60 * 24))) / 2);
	LVar4 := global_var(GVAR_VAULT_13_INVADED_DATE) - ((global_var(GVAR_VAULT_13_INVADED_DATE) - (game_time / (10 * 60 * 60 * 24))) / 2);
	set_global_var(GVAR_THE_HUB_INVADED_DATE, LVar0);
	set_global_var(GVAR_BROTHERHOOD_INVADED_DATE, LVar1);
	set_global_var(GVAR_JUNKTOWN_INVADED_DATE, LVar2);
	set_global_var(GVAR_SHADY_SANDS_INVADED_DATE, LVar3);
	set_global_var(GVAR_VAULT_13_INVADED_DATE, LVar4);
end