1 (* Copyright (C) DooM 2D:Forever Developers
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *)
16 {$INCLUDE ../shared/a_modes.inc}
19 interface
21 uses
24 const
34 type
92 var
95 implementation
97 uses
102 begin
107 begin
108 result := g_Map_CollidePanel(X, Y, Width, Height, (PANEL_WALL or PANEL_CLOSEDOOR or PANEL_OPENDOOR), false);
110 (*
111 var
112 a: Integer;
113 begin
114 Result := False;
116 if gWalls = nil then
117 Exit;
119 for a := 0 to High(gWalls) do
120 if gWalls[a].Enabled and
121 not ( ((Y + Height <= gWalls[a].Y) or
122 (Y >= gWalls[a].Y + gWalls[a].Height)) or
123 ((X + Width <= gWalls[a].X) or
124 (X >= gWalls[a].X + gWalls[a].Width)) ) then
125 begin
126 Result := True;
127 Exit;
128 end;
129 end;
130 *)
133 var
135 begin
143 begin
145 Exit;
151 var
154 (*
155 i: Integer;
156 dx, dy: Integer;
157 Xerr, Yerr, d: LongWord;
158 incX, incY: Integer;
159 x, y: Integer;
160 *)
161 begin
162 (*
163 result := False;
165 Assert(gCollideMap <> nil, 'g_TraceVector: gCollideMap = nil');
167 Xerr := 0;
168 Yerr := 0;
169 dx := X2-X1;
170 dy := Y2-Y1;
172 if dx > 0 then incX := 1 else if dx < 0 then incX := -1 else incX := 0;
173 if dy > 0 then incY := 1 else if dy < 0 then incY := -1 else incY := 0;
175 dx := abs(dx);
176 dy := abs(dy);
178 if dx > dy then d := dx else d := dy;
180 x := X1;
181 y := Y1;
183 for i := 1 to d do
184 begin
185 Inc(Xerr, dx);
186 Inc(Yerr, dy);
187 if Xerr>d then
188 begin
189 Dec(Xerr, d);
190 Inc(x, incX);
191 end;
192 if Yerr > d then
193 begin
194 Dec(Yerr, d);
195 Inc(y, incY);
196 end;
198 if (y > gMapInfo.Height-1) or
199 (y < 0) or (x > gMapInfo.Width-1) or (x < 0) then
200 Exit;
201 if ByteBool(gCollideMap[y, x] and MARK_BLOCKED) then
202 Exit;
203 end;
205 Result := True;
206 *)
210 begin
211 // check distance
212 //result := ((wallHitX-x1)*(wallHitX-x1)+(wallHitY-y1)*(wallHitY-y1) > (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
214 end
215 else
216 begin
223 var
226 begin
230 UID_PLAYER:
231 begin
232 repeat
240 begin
242 Break;
247 UID_MONSTER:
248 begin
249 //FIXME!!!
251 begin
260 begin
262 Result := UID_GAME
263 else
265 Result := UID_PLAYER
266 else
272 begin
281 begin
290 begin
298 begin
299 //Result := not (((Y2 <= Y3) or (Y1 >= Y4)) or ((X2 <= X3) or (X1 >= X4)));
304 begin
312 begin
317 begin
322 begin
327 begin
332 begin
337 begin
342 begin
347 begin
352 begin
357 begin
362 begin
367 begin
372 begin
377 begin
382 begin
387 begin
392 begin
399 const
401 begin
408 begin
411 // D(0;H) --- C(W;H)
416 else
421 end
422 else
428 else
433 end
435 begin
437 Result := -Y
438 else
447 const
449 var
451 begin
461 begin
466 begin
468 Exit;
478 var
481 begin
495 var
498 begin
504 else
517 {function g_CollideLine(x1, y1, x2, y2, rX, rY: Integer; rWidth, rHeight: Word): Boolean;
518 const
519 table: array[0..8, 0..8] of Byte =
520 ((0, 0, 3, 3, 1, 2, 2, 0, 1),
521 (0, 0, 0, 0, 4, 7, 2, 0, 1),
522 (3, 0, 0, 0, 4, 4, 1, 3, 1),
523 (3, 0, 0, 0, 0, 0, 5, 6, 1),
524 (1, 4, 4, 0, 0, 0, 5, 5, 1),
525 (2, 7, 4, 0, 0, 0, 0, 0, 1),
526 (2, 2, 1, 5, 5, 0, 0, 0, 1),
527 (0, 0, 3, 6, 5, 0, 0, 0, 1),
528 (1, 1, 1, 1, 1, 1, 1, 1, 1));
530 function GetClass(x, y: Integer): Byte;
531 begin
532 if y < rY then
533 begin
534 if x < rX then Result := 7
535 else if x < rX+rWidth then Result := 0
536 else Result := 1;
537 end
538 else if y < rY+rHeight then
539 begin
540 if x < rX then Result := 6
541 else if x < rX+rWidth then Result := 8
542 else Result := 2;
543 end
544 else
545 begin
546 if x < rX then Result := 5
547 else if x < rX+rWidth then Result := 4
548 else Result := 3;
549 end;
550 end;
552 begin
553 case table[GetClass(x1, y1), GetClass(x2, y2)] of
554 0: Result := False;
555 1: Result := True;
556 2: Result := Abs((rY-y1))/Abs((rX-x1)) <= Abs((y2-y1))/Abs((x2-x1));
557 3: Result := Abs((rY-y1))/Abs((rX+rWidth-x1)) <= Abs((y2-y1))/Abs((x2-x1));
558 4: Result := Abs((rY+rHeight-y1))/Abs((rX+rWidth-x1)) >= Abs((y2-y1))/Abs((x2-x1));
559 5: Result := Abs((rY+rHeight-y1))/Abs((rX-x1)) >= Abs((y2-y1))/Abs((x2-x1));
560 6: Result := (Abs((rY-y1))/Abs((rX+rWidth-x1)) <= Abs((y2-y1))/Abs((x2-x1))) and
561 (Abs((rY+rHeight-y1))/Abs((rX-x1)) >= Abs((y2-y1))/Abs((x2-x1)));
562 7: Result := (Abs((rY+rHeight-y1))/Abs((rX+rWidth-x1)) >= Abs((y2-y1))/Abs((x2-x1))) and
563 (Abs((rY-y1))/Abs((rX-x1)) <= Abs((y2-y1))/Abs((x2-x1)));
564 else Result := False;
565 end;
566 end;}
569 var
575 begin
595 begin
599 begin
604 begin
617 var
619 begin
623 begin
627 Exit;
631 {function GetLines(Text: string; MaxChars: Word): SArray;
632 var
633 a: Integer;
634 b: array of string;
635 str: string;
636 begin
637 Text := Trim(Text);
639 while Pos(' ', Text) <> 0 do Text := AnsiReplaceStr(Text, ' ', ' ');
641 while Text <> '' do
642 begin
643 SetLength(b, Length(b)+1);
644 b[High(b)] := GetStr(Text);
645 end;
647 a := 0;
648 while True do
649 begin
650 if a > High(b) then Break;
652 str := b[a];
653 a := a+1;
655 if Length(str) >= MaxChars then
656 begin
657 while str <> '' do
658 begin
659 SetLength(Result, Length(Result)+1);
660 Result[High(Result)] := Copy(str, 1, MaxChars);
661 Delete(str, 1, MaxChars);
662 end;
664 Continue;
665 end;
667 while (a <= High(b)) and (Length(str+' '+b[a]) <= MaxChars) do
668 begin
669 str := str+' '+b[a];
670 a := a+1;
671 end;
673 SetLength(Result, Length(Result)+1);
674 Result[High(Result)] := str;
675 end;
676 end;}
681 var
683 begin
687 var
691 begin
697 // Óäàëÿåì ìíîæåñòâåííûå ïðîáåëû:
702 begin
709 begin
711 Break;
719 begin
730 end
732 begin
735 begin
747 var
750 begin
756 begin
765 var
772 begin
778 begin
787 begin
794 begin
803 begin
809 begin
818 begin
827 begin
831 begin
835 Break;
838 begin
846 Break;
850 Break;
855 begin
862 begin
866 vtInteger :
867 begin
869 begin
873 end
874 else
875 Break;
878 vtExtended :
879 begin
881 begin
885 end
886 else
887 Break;
890 vtString :
891 begin
893 begin
896 end
897 else
898 Break;
902 Break;
908 var
910 begin
917 begin
919 Exit;
924 var
926 begin
933 begin
935 Exit;
940 var
942 begin
951 begin
953 Exit;
958 var
961 begin
965 UID_PLAYER:
966 begin
974 UID_MONSTER:
975 begin
989 var
991 begin
994 Exit;
997 begin
1000 begin
1009 Break;
1015 var
1017 begin
1022 begin
1025 begin
1032 Break;
1038 var
1040 begin
1042 begin
1044 Exit;
1054 var
1056 begin
1058 begin
1060 Exit;
1070 var
1074 begin
1075 repeat
1088 var
1091 begin
1096 begin
1098 begin
1101 continue;
1104 begin
1126 else
1130 end else
1133 // reset to white at end
1138 var
1141 begin
1145 begin
1147 begin
1149 continue;
1152 begin
1154 continue;
1157 begin
1169 else
1173 end else