-
Notifications
You must be signed in to change notification settings - Fork 2
/
looker.pp
129 lines (109 loc) · 3.42 KB
/
looker.pp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
unit looker;
{What is this? It's the unit which supports the 'Look'}
{command. Basically, it provides a UI for the user to select}
{a map tile which is currently on-screen.}
interface
uses crt,rpgtext,texmodel,texmaps,texfx,critters,gamebook;
Function SelectPoint(SC: ScenarioPtr; Render, SeekModel: Boolean; M: ModelPtr): Point;
implementation
Procedure MoveMapCursor(gb: GameBoardPtr; D: Integer; var P: Point);
{Move the map cursor point. This can be used for the Select}
{Target routine, or for the PCLook routine. In any case,}
{the big point is to make sure that the point doesn't go off}
{the screen.}
begin
if OnTheScreen(gb,p.x + VecDir[D,1],p.y + VecDir[D,2]) then begin
p.x := p.x + VecDir[D,1];
p.y := p.y + VecDir[D,2];
end;
end;
Function NextVisibleModel(gb: GameBoardPtr; M: ModelPtr): ModelPtr;
{Locate the next visible model in the models list. If}
{the end of the list is encountered, start looking again}
{at the beginning. If no visible models are found,}
{return Nil.}
var
M1,M2: ModelPtr;
GetOutOfLoopFree: Boolean;
begin
{ERROR CHECK- exit immediately if there are no models present.}
if gb^.MList = Nil then Exit(Nil);
M2 := Nil;
M1 := M;
if M = Nil then M := gb^.MList;
GetOutOfLoopFree := False;
repeat
if M1 <> Nil then begin
{Move to the next model in the list.}
M := M^.Next;
if M = Nil then M := gb^.MList;
end;
if TileLOS(gb^.POV,M^.X,M^.Y) and (M <> gb^.POV.M) and OnTheScreen(gb,M^.X,M^.Y) and (M^.Kind = MKIND_Critter) then M2 := M;
if M1 = Nil then begin
M := M^.Next;
if M = Nil then GetOutOfLoopFree := True;
end else begin
if M = M1 then GetOutOfLoopFree := True;
end;
until (M2 <> Nil) or GetOutOfLoopFree;
NextVisibleModel := M2;
end;
Function SelectPoint(SC: ScenarioPtr; Render,SeekModel: Boolean; M: ModelPtr): Point;
{This function is a UI utility. It allows a target}
{square to be chosen, centered on the POV model.}
{If CANCEL is chosen instead of a target, the X value}
{of the returned point will be set to -1.}
var
p: Point;
a: Char;
begin
if SeekModel then begin
if M = Nil then M := NextVisibleModel(SC^.gb,M)
else if not TileLOS(SC^.gb^.POV,M^.X,M^.Y) or not OnTheScreen(SC^.gb,M^.X,M^.Y) then M := NextVisibleModel(SC^.gb,M);
end;
if M <> Nil then begin
{Start the point selector centered on the selected model.}
p.x := M^.X;
p.y := M^.Y;
end else begin
{Start the point centered on the POV origin.}
p.x := SC^.gb^.POV.M^.X;
p.y := SC^.gb^.POV.M^.Y;
end;
{Start the loop.}
repeat
{Indicate the point.}
if Render then
IndicatePath(SC^.gb,SC^.gb^.pov.m^.x,SC^.gb^.pov.m^.y,p.x,p.y,true)
else
HighlightTile(SC^.gb,p.x,p.y);
DCPointMessage(TileName(SC,p.x,p.y));
{Get player input and act upon it.}
a := RPGKey;
{Deindicate the point.}
if Render then
DeIndicatePath(SC^.gb,SC^.gb^.pov.m^.x,SC^.gb^.pov.m^.y,p.x,p.y)
else
DisplayTile(SC^.gb,p.x,p.y);
case A of
'1': MoveMapCursor(SC^.gb,1,p);
'2': MoveMapCursor(SC^.gb,2,p);
'3': MoveMapCursor(SC^.gb,3,p);
'4': MoveMapCursor(SC^.gb,4,p);
'6': MoveMapCursor(SC^.gb,6,p);
'7': MoveMapCursor(SC^.gb,7,p);
'8': MoveMapCursor(SC^.gb,8,p);
'9': MoveMapCursor(SC^.gb,9,p);
#9: begin
M := NextVisibleModel(SC^.gb,M);
if M <> Nil then begin
p.x := M^.X;
p.y := M^.Y;
end;
end;
end;
until (a = ' ') or (a = #27) or (a = KMap[13].Key) or (a = KMap[14].Key);
if a = #27 then p.x := -1;
SelectPoint := P;
end;
end.