#include "C:\Program Files\Black Isle\Fallout 2 Mapper\scripts\headers\define.h"
//#include "C:\Program Files\Black Isle\Fallout 2 Mapper\scripts\headers\<TownMapName.h>"
#define NAME SCRIPT_UNN //Script name from scripts.h
#include "C:\Program Files\Black Isle\Fallout 2 Mapper\scripts\headers\command.h"
#include "C:\Program Files\Black Isle\Fallout 2 Mapper\scripts\headers\ModReact.h"
#include "C:\Program Files\Black Isle\Fallout 2 Mapper\scripts\headers\partybkg.h"
procedure start;
procedure use_p_proc;
procedure Start_Dlg;
procedure Set_Coordinates;
procedure set_dest_x;
procedure DX0100A;
procedure DX0100B;
procedure DX0010A;
procedure DX0010B;
procedure DX0001A;
procedure DX0001B;
procedure set_dest_y;
procedure DY0100A;
procedure DY0100B;
procedure DY0010A;
procedure DY0010B;
procedure DY0001A;
procedure DY0001B;
procedure calc_dis_x;
procedure calc_dis_y;
procedure set_hor_dir;
procedure set_ver_dir;
procedure pre_check;
procedure dis_str;
procedure Triangulate;
procedure Approximate_Value_G;
procedure calc_00;
procedure calc_01;
procedure Recalculate;
procedure Display_distance;
procedure Plot_Coord;
procedure Nx_co_str;
procedure generate_linear_equation;
procedure calc_nxy00;
procedure calc_nxy01;
procedure disp_xy_coord;
procedure disp_coord;
procedure Node_X;
variable home_x := 0;
variable home_y := 0;
variable dest_x := 0;
variable dest_y := 0;
variable hor_dis := 0;
variable ver_dis := 0;
variable hor_dir := 0;
variable ver_dir := 0;
variable msg_dirh := 0;
variable msg_dirv := 0;
variable b_ratio := 0.000;
variable angle_x := 0.000;
variable bearing := 0.000;
variable dis2 := 0.000;
variable val_g := 0.000;
variable calc_root := 0.000;
variable diff := 0.000;
variable distance := 0.000;
variable dist_miles := 0.000;
variable gen_next_X := 0;
variable gen_next_Y := 0;
variable X := 0;
variable Y := 0;
variable TX := 0;
variable TY := 0;
variable rise := 0.000;
variable run := 0.000;
variable slope := 0.000;
variable slx_var := 0.000;
variable Z := 0;
variable Msg_Str := 0;
procedure start
begin
if (script_action == 6) then
call use_p_proc;
end
procedure use_p_proc
begin
script_overrides;
if (not combat_is_initialized) then
call Start_Dlg;
end
procedure Start_Dlg
begin
start_gdialog(66, target_obj, 4, -1, -1);
gsay_start;
call Set_Coordinates;
gsay_end;
end_dialogue;
end
procedure Set_Coordinates
begin
home_x := metarule(44, 0);
home_y := metarule(45, 0);
dest_x := 0;
dest_y := 0;
call set_dest_x;
end
procedure set_dest_x
begin
gsay_reply(961, "Destination X: " + dest_x + " Current World Map Position : X" + home_x + " , Y" + home_y + " Set Destination X position.");
giq_option(1, 961, "100+", DX0100A, 50);
giq_option(1, 961, "100-", DX0100B, 50);
giq_option(1, 961, "10+", DX0010A, 50);
giq_option(1, 961, "10-", DX0010B, 50);
giq_option(1, 961, "1+", DX0001A, 50);
giq_option(1, 961, "1-", DX0001B, 50);
giq_option(1, 961, "[DONE]", set_dest_y, 50);
end
procedure DX0100A
begin
dest_x := dest_x + 100;
call set_dest_x;
end
procedure DX0100B
begin
if (dest_x >= 100) then
dest_x := dest_x - 100;
else
dest_x := 0;
call set_dest_x;
end
procedure DX0010A
begin
dest_x := dest_x + 10;
call set_dest_x;
end
procedure DX0010B
begin
if (dest_x >= 10) then
dest_x := dest_x - 10;
else
dest_x := 0;
call set_dest_x;
end
procedure DX0001A
begin
dest_x := dest_x + 1;
call set_dest_x;
end
procedure DX0001B
begin
if (dest_x >= 1) then
dest_x := dest_x - 1;
else
dest_x := 0;
call set_dest_x;
end
procedure set_dest_y
begin
gsay_reply(961, "Destination Y: " + dest_y + " Current World Map Position : X" + home_x + " , Y" + home_y + " Destination Co-ordinates : X" + dest_x + " , Y" + dest_y + " Set Destination Y position.");
giq_option(1, 961, "100+", DY0100A, 50);
giq_option(1, 961, "100-", DY0100B, 50);
giq_option(1, 961, "10+", DY0010A, 50);
giq_option(1, 961, "10-", DY0010B, 50);
giq_option(1, 961, "1+", DY0001A, 50);
giq_option(1, 961, "1-", DY0001B, 50);
giq_option(1, 961, "[DONE]", calc_dis_x, 50);
end
procedure DY0100A
begin
dest_y := dest_y + 100;
call set_dest_y;
end
procedure DY0100B
begin
if (dest_y >= 100) then
dest_y := dest_y - 100;
else
dest_y := 0;
call set_dest_y;
end
procedure DY0010A
begin
dest_y := dest_y + 10;
call set_dest_y;
end
procedure DY0010B
begin
if (dest_y >= 10) then
dest_y := dest_y - 10;
else
dest_y := 0;
call set_dest_y;
end
procedure DY0001A
begin
dest_y := dest_y + 1;
call set_dest_y;
end
procedure DY0001B
begin
if (dest_y >= 1) then
dest_y := dest_y - 1;
else
dest_y := 0;
call set_dest_y;
end
procedure calc_dis_x
begin
if (home_x == dest_x) then
begin
hor_dis := 0;
hor_dir := 0;
end
else if (home_x < dest_x) then
begin
hor_dis := dest_x - home_x;
hor_dir := 1;
end
else if (home_x > dest_x) then
begin
hor_dis := home_x - dest_x;
hor_dir := 2;
end
call calc_dis_y;
end
procedure calc_dis_y
begin
if (home_y == dest_y) then
begin
ver_dis := 0;
ver_dir := 0;
end
else if (home_y < dest_y) then
begin
ver_dis := dest_y - home_y;
ver_dir := 1;
end
else if (home_y > dest_y) then
begin
ver_dis := home_y - dest_y;
ver_dir := 2;
end
call set_hor_dir;
end
procedure set_hor_dir
begin
if (hor_dir == 0) then
msg_dirh := "";
else if (hor_dir == 1) then
msg_dirh := "east";
else if (hor_dir == 2) then
msg_dirh := "west";
call set_ver_dir;
end
procedure set_ver_dir
begin
if (ver_dir == 0) then
msg_dirv := "";
else if (ver_dir == 1) then
msg_dirv := "south";
else if (ver_dir == 2) then
msg_dirv := "north";
call pre_check;
end
procedure pre_check
begin
speed := random(115, 149);
if ((hor_dis == 0) or (ver_dis == 0)) then
call dis_str;
else
call Triangulate;
end
procedure dis_str
begin
distance := hor_dis + ver_dis;
dist_miles := distance * 0.222;
gsay_reply(961, "Distance from current position: " + dist_miles + " miles " + msg_dirv + msg_dirh);
giq_option(1, 961, "Plot Trajectory", Plot_Coord, 50);
giq_option(1, 961, "[DONE]", Node_X, 50);
end
procedure Triangulate
begin
dis2 := 0.00 + (hor_dis * hor_dis) + (ver_dis * ver_dis);
b_ratio := 90.00 / (hor_dis + ver_dis);
if (ver_dis <= hor_dis) then
angle_x := 0.00 + b_ratio * ver_dis;
else
angle_x := 0.00 + b_ratio * hor_dis;
if ((hor_dir == 1) and (ver_dir == 2)) then
begin
if (ver_dis <= hor_dis) then
bearing := 90.00 - angle_x;
else
bearing := angle_x;
end
else if ((hor_dir == 1) and (ver_dir == 1)) then
begin
if (ver_dis <= hor_dis) then
bearing := 90.00 + angle_x;
else
bearing := 180.00 - angle_x;
end
else if ((hor_dir == 2) and (ver_dir == 1)) then
begin
if (ver_dis <= hor_dis) then
bearing := 270.00 - angle_x;
else
bearing := 180.00 + angle_x;
end
else if ((hor_dir == 2) and (ver_dir == 2)) then
begin
if (ver_dis <= hor_dis) then
bearing := 270.00 + angle_x;
else
bearing := 360.00 - angle_x;
end
call Approximate_Value_G;
end
procedure Approximate_Value_G
begin
if (dis2 < 4) then
val_g := 1.0;
else if ((dis2 >= 4) and (dis2 < 9)) then
val_g := 2.0;
else if ((dis2 >= 9) and (dis2 < 16)) then
val_g := 3.0;
else if ((dis2 >= 16) and (dis2 < 25)) then
val_g := 4.0;
else if ((dis2 >= 25) and (dis2 < 36)) then
val_g := 5.0;
else if ((dis2 >= 36) and (dis2 < 49)) then
val_g := 6.0;
else if ((dis2 >= 49) and (dis2 < 64)) then
val_g := 7.0;
else if ((dis2 >= 64) and (dis2 < 81)) then
val_g := 8.0;
else if ((dis2 >= 81) and (dis2 < 100)) then
val_g := 9.0;
else if ((dis2 >= 100) and (dis2 < 121)) then
val_g := 10.0;
else if ((dis2 >= 121) and (dis2 < 144)) then
val_g := 11.0;
else if ((dis2 >= 144) and (dis2 < 169)) then
val_g := 12.0;
else if ((dis2 >= 169) and (dis2 < 196)) then
val_g := 13.0;
else if ((dis2 >= 196) and (dis2 < 225)) then
val_g := 14.0;
else if ((dis2 >= 225) and (dis2 < 256)) then
val_g := 15.0;
else if ((dis2 >= 256) and (dis2 < 289)) then
val_g := 16.0;
else if ((dis2 >= 289) and (dis2 < 324)) then
val_g := 17.0;
else if ((dis2 >= 324) and (dis2 < 361)) then
val_g := 18.0;
else if ((dis2 >= 361) and (dis2 < 400)) then
val_g := 19.0;
else if (dis2 >= 400) then
val_g := 20.0;
call calc_00;
end
procedure calc_00
begin
calc_root := 0.000 + dis2 / val_g;
if (calc_root >= (val_g)) then
diff := calc_root - val_g;
if (calc_root < (val_g)) then
diff := val_g - calc_root;
call calc_01;
end
procedure calc_01
begin
if ((calc_root == val_g) or (diff <= 0.0001)) then
call Display_distance;
else
call Recalculate;
end
procedure Recalculate
begin
diff := diff / 2.000;
if (calc_root < val_g) then
val_g := val_g - diff;
else if (calc_root > val_g) then
val_g := val_g + diff;
call calc_00;
end
procedure Display_distance
begin
distance := 0.000 + calc_root;
dist_miles := distance * 0.222;
if (diff == 1) then
Msg_Str := "Distance from current position: " + dist_miles + " miles " + msg_dirv + msg_dirh + "(Hexes : " + distance + "/" + val_g + ") -- Bearing : " + bearing + " degrees";
else
Msg_Str := "Distance from current position: " + dist_miles + " miles, " + msg_dirv + msg_dirh + " -- (Hexes : " + distance + ") -- Bearing : " + bearing + " degrees";
gsay_reply(961, Msg_Str);
giq_option(1, 961, "Plot Trajectory", Plot_Coord, 50);
giq_option(1, 961, "[DONE]", Node_X, 50);
end
procedure Plot_Coord
begin
if ((home_x == dest_x) or (home_y == dest_y)) then
call Nx_co_str;
else
call generate_linear_equation;
end
procedure Nx_co_str
begin
if (home_x == dest_x) then
begin
gen_next_Y := random(0, ver_dis);
if (home_y < dest_y) then
Y := home_y + gen_next_Y;
else
Y := home_y - gen_next_Y;
display_msg("Next Co-ordinates : X" + home_x + ", Y" + Y);
end
else if (home_y == dest_y) then
begin
gen_next_X := random(0, hor_dis);
if (home_x < dest_x) then
X := home_x + gen_next_X;
else
X := home_x - gen_next_X;
display_msg("Next Co-ordinates : X" + X + ", Y" + home_y);
end
end
procedure generate_linear_equation
begin
gen_next_X := hor_dis;
rise := home_y - dest_y;
run := home_x - dest_x;
slope := (ver_dis * 10.00) / (hor_dis * 10.00);
X := home_x;
if (home_x > dest_x) then
slope := slope - (slope * 2);
slx_var := slope * X;
if (home_y < dest_y) then
Z := home_y - slx_var;
else if (home_y > dest_y) then
Z := home_y + slx_var;
gsay_reply(961, " Rise : " + rise + " Run : " + run + " Slope : " + slope + " Equation : Y = " + slope + "X (" + slx_var + ") + " + Z);
giq_option(1, 961, "Continue", calc_nxy00, 50);
giq_option(1, 961, "[DONE]", Node_X, 50);
end
procedure calc_nxy00
begin
if (gen_next_X > 0) then
call calc_nxy01;
else
call disp_coord;
end
procedure calc_nxy01
begin
if (home_x < dest_x) then
X := X + 1;
else if (home_x > dest_x) then
X := X - 1;
if (home_y < dest_y) then
begin
TY := slope * X;
Y := TY + Z;
end
else if (home_y > dest_y) then
begin
TX := slope * X;
TY := TX - Z;
Y := TY - (TY * 2);
end
call disp_xy_coord;
end
procedure disp_xy_coord
begin
gen_next_X := gen_next_X - 1;
gsay_reply(961, "X" + X + ", Y" + Y);
giq_option(1, 961, "Next co-ordinate", calc_nxy00, 50);
giq_option(1, 961, "[DONE]", Node_X, 50);
end
procedure disp_coord
begin
gsay_reply(961, "X" + X + ", Y" + Y);
giq_option(1, 961, "[DONE]", Node_X, 50);
end
procedure Node_X
begin
end