summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f0d4e19)
raw | patch | inline | side by side (parent: f0d4e19)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Tue, 22 Aug 2017 19:15:15 +0000 (22:15 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Wed, 23 Aug 2017 18:23:55 +0000 (21:23 +0300) |
src/game/g_player.pas | patch | blob | history | |
src/game/g_weapons.pas | patch | blob | history |
diff --git a/src/game/g_player.pas b/src/game/g_player.pas
index 1c9996dc526f307bfadbf96abf618f1108bdf441..8720e077261d47014e69aaeacca1b95157f3b570 100644 (file)
--- a/src/game/g_player.pas
+++ b/src/game/g_player.pas
procedure TPlayer.DrawAim();
procedure drawCast (sz: Integer; ax0, ay0, ax1, ay1: Integer);
+
+ function monsCollector (mon: TMonster; tag: Integer): Boolean;
+ var
+ ex, ey: Integer;
+ mx, my, mw, mh: Integer;
+ begin
+ result := false;
+ mon.getMapBox(mx, my, mw, mh);
+ e_DrawQuad(mx, my, mx+mw-1, my+mh-1, 255, 255, 0, 96);
+ if lineAABBIntersects(ax0, ay0, ax1, ay1, mx, my, mw, mh, ex, ey) then
+ begin
+ e_DrawPoint(8, ex, ey, 0, 255, 0);
+ end;
+ end;
+
var
ex, ey: Integer;
- mon: TMonster;
- mx, my, mw, mh: Integer;
+ //mon: TMonster;
+ //mx, my, mw, mh: Integer;
begin
e_DrawLine(sz, ax0, ay0, ax1, ay1, 255, 0, 0, 96);
if g_Map_traceToNearestWall(ax0, ay0, ax1, ay1, @ex, @ey) then
e_DrawLine(sz, ax0, ay0, ex, ey, 0, 0, 255, 96);
end;
+ {
mon := g_Mons_ByIdx(0);
mon.getMapBox(mx, my, mw, mh);
ax1 := mx+mw div 2;
ay1 := my+mh div 2;
e_DrawLine(2, ax0, ay0, ax1, ay1, 0, 96, 96, 96);
- if lineAABBIntersects(ax0, ay0, ax1, ay1, mx, my, mw, mh, ex, ey) then
+ if lineAABBIntersects(ax0, ay0, ax1, ay1, mx, my, mw, mh, ex, ey) then
begin
e_DrawLine(2, ax0, ay0, ex, ey, 255, 255, 0, 96);
end
begin
e_DrawLine(2, ax0, ay0, ex, ey, 255, 127, 0, 96);
end;
+ }
+
+ g_Mons_alongLine(ax0, ay0, ax1, ay1, monsCollector);
end;
var
diff --git a/src/game/g_weapons.pas b/src/game/g_weapons.pas
index fc9db75ca5576da7fd02a0acec6b20a7c7cab88b..88670fdb5a59ccf102cfa252b8ff235e816020d3 100644 (file)
--- a/src/game/g_weapons.pas
+++ b/src/game/g_weapons.pas
wgunHitTimeUsed: Integer = 0;
-function hitTimeCompare (a, b: Integer): Boolean;
+function hitTimeLess (a, b: Integer): Boolean;
+var
+ hta, htb: PHitTime;
begin
- if (wgunHitTime[a].distSq < wgunHitTime[b].distSq) then begin result := true; exit; end;
- if (wgunHitTime[a].distSq > wgunHitTime[b].distSq) then begin result := false; exit; end;
- if (wgunHitTime[a].mon <> nil) then
+ hta := @wgunHitTime[a];
+ htb := @wgunHitTime[b];
+ if (hta.distSq <> htb.distSq) then begin result := (hta.distSq < htb.distSq); exit; end;
+ if (hta.mon <> nil) then
begin
// a is monster
- if (wgunHitTime[b].mon = nil) then begin result := false; exit; end; // players first
- result := (wgunHitTime[a].mon.UID < wgunHitTime[b].mon.UID); // why not?
+ if (htb.mon = nil) then begin result := false; exit; end; // players first
+ result := (hta.mon.UID < htb.mon.UID); // why not?
end
else
begin
// a is player
- if (wgunHitTime[b].mon <> nil) then begin result := true; exit; end; // players first
- result := (wgunHitTime[a].plridx < wgunHitTime[b].plridx); // why not?
+ if (htb.mon <> nil) then begin result := true; exit; end; // players first
+ result := (hta.plridx < htb.plridx); // why not?
end;
end;
g_Texture_CreateWADEx('TEXTURE_SHELL_SHELL', GameWAD+':TEXTURES\ESHELL');
//wgunMonHash := hashNewIntInt();
- wgunHitHeap := TBinaryHeapHitTimes.Create(hitTimeCompare);
+ wgunHitHeap := TBinaryHeapHitTimes.Create(hitTimeLess);
end;
procedure g_Weapon_FreeData();
//!!!FIXME!!!
procedure g_Weapon_gun (const x, y, xd, yd, v, dmg: Integer; SpawnerUID: Word; CheckTrigger: Boolean);
var
+ x0, y0: Integer;
x2, y2: Integer;
xi, yi: Integer;
wallDistSq: Integer = $3fffffff;
begin
result := false; // don't stop
mon.getMapBox(mx, my, mw, mh);
- if lineAABBIntersects(x, y, x2, y2, mx, my, mw, mh, inx, iny) then
+ if lineAABBIntersects(x0, y0, x2, y2, mx, my, mw, mh, inx, iny) then
begin
- distSq := distanceSq(x, y, inx, iny);
- if (distSq < wallDistSq) then appendHitTimeMon(distanceSq(x, y, inx, iny), mon, inx, iny);
+ distSq := distanceSq(x0, y0, inx, iny);
+ if (distSq < wallDistSq) then appendHitTimeMon(distSq, mon, inx, iny);
end;
end;
end;
*)
+ if (xd = 0) and (yd = 0) then exit;
+
//wgunMonHash.reset(); //FIXME: clear hash on level change
wgunHitHeap.clear();
wgunHitTimeUsed := 0;
if Abs(s) < 0.01 then s := 0;
if Abs(c) < 0.01 then c := 0;
+ x0 := x;
+ y0 := y;
x2 := x+Round(c*gMapInfo.Width);
y2 := y+Round(s*gMapInfo.Width);
dx := x2-x;
dy := y2-y;
- if (xd = 0) and (yd = 0) then exit;
-
- if dx > 0 then xi := 1 else if dx < 0 then xi := -1 else xi := 0;
- if dy > 0 then yi := 1 else if dy < 0 then yi := -1 else yi := 0;
+ if (dx > 0) then xi := 1 else if (dx < 0) then xi := -1 else xi := 0;
+ if (dy > 0) then yi := 1 else if (dy < 0) then yi := -1 else yi := 0;
{$IF DEFINED(D2F_DEBUG)}
e_WriteLog(Format('GUN TRACE: (%d,%d) to (%d,%d)', [x, y, x2, y2]), MSG_NOTIFY);
g_Mons_alongLine(x, y, x2, y2, sqchecker);
// here, we collected all monsters and players in `wgunHitHeap` and `wgunHitTime`
- // also, if `wallWasHit` >= 0, then `wallHitX` and `wallHitY` contains spark coords
+ // also, if `wallWasHit` is `true`, then `wallHitX` and `wallHitY` contains spark coords
while (wgunHitHeap.count > 0) do
begin
// has some entities to check, do it
i := wgunHitHeap.front;
wgunHitHeap.popFront();
+ // hitpoint
xe := wgunHitTime[i].x;
ye := wgunHitTime[i].y;
// check if it is not behind the wall