diff --git a/src/game/g_holmes.pas b/src/game/g_holmes.pas
index 1f548e4c2058b560b06054513333e175df7ee7bc..165b8480f804c131577f6d0f3c3d52bd1f93d32a 100644 (file)
--- a/src/game/g_holmes.pas
+++ b/src/game/g_holmes.pas
interface
uses
+ mempool,
e_log, e_input,
g_textures, g_basic, e_graphics, g_phys, g_grid, g_player, g_monsters,
g_window, g_map, g_triggers, g_items, g_game, g_panel, g_console, g_gfx,
function g_Holmes_KeyEvent (var ev: THKeyEvent): Boolean; // returns `true` if event was eaten
// hooks for player
-procedure g_Holmes_plrView (viewPortX, viewPortY, viewPortW, viewPortH: Integer);
+procedure g_Holmes_plrViewPos (viewPortX, viewPortY: Integer);
+procedure g_Holmes_plrViewSize (viewPortW, viewPortH: Integer);
procedure g_Holmes_plrLaser (ax0, ay0, ax1, ay1: Integer);
implementation
uses
- {rttiobj,} typinfo,
+ {rttiobj,} typinfo, e_texture,
SysUtils, Classes, GL, SDL2,
MAPDEF, g_main, g_options,
utils, hashtable, xparser;
showLayersWindow: Boolean = false;
showOutlineWindow: Boolean = false;
showTriggers: Boolean = {$IF DEFINED(D2F_DEBUG)}false{$ELSE}false{$ENDIF};
+ showTraceBox: Boolean = {$IF DEFINED(D2F_DEBUG)}false{$ELSE}false{$ENDIF};
// ////////////////////////////////////////////////////////////////////////// //
// ////////////////////////////////////////////////////////////////////////// //
procedure g_Holmes_VidModeChanged ();
begin
- e_WriteLog(Format('Holmes: videomode changed: %dx%d', [gScreenWidth, gScreenHeight]), MSG_NOTIFY);
+ e_WriteLog(Format('Holmes: videomode changed: %dx%d', [gScreenWidth, gScreenHeight]), TMsgType.Notify);
// texture space is possibly lost here, idc
curtexid := 0;
font6texid := 0;
platMarkedGUID: Integer = -1;
-procedure g_Holmes_plrView (viewPortX, viewPortY, viewPortW, viewPortH: Integer);
+procedure g_Holmes_plrViewPos (viewPortX, viewPortY: Integer);
begin
vpSet := true;
vpx := viewPortX;
vpy := viewPortY;
+end;
+
+procedure g_Holmes_plrViewSize (viewPortW, viewPortH: Integer);
+begin
+ vpSet := true;
vpw := viewPortW;
vph := viewPortH;
end;
end;
end;
+ procedure drawTraceBox ();
+ var
+ plr: TPlayer;
+ px, py, pw, ph: Integer;
+ pdx, pdy: Integer;
+ ex, ey: Integer;
+ pan: TPanel;
+ begin
+ if (Length(gPlayers) < 1) then exit;
+ plr := gPlayers[0];
+ if (plr = nil) then exit;
+ plr.getMapBox(px, py, pw, ph);
+ drawRect(px, py, pw, ph, 255, 0, 255, 200);
+ pdx := pmsCurMapX-(px+pw div 2);
+ pdy := pmsCurMapY-(py+ph div 2);
+ drawLine(px+pw div 2, py+ph div 2, px+pw div 2+pdx, py+ph div 2+pdy, 255, 0, 255, 200);
+ pan := mapGrid.traceBox(ex, ey, px, py, pw, ph, pdx, pdy, nil, GridTagObstacle);
+ if (pan = nil) then
+ begin
+ drawRect(px+pdx, py+pdy, pw, ph, 255, 255, 255, 180);
+ end
+ else
+ begin
+ drawRect(px+pdx, py+pdy, pw, ph, 255, 255, 0, 180);
+ end;
+ drawRect(ex, ey, pw, ph, 255, 127, 0, 180);
+ end;
+
procedure hilightCell (cx, cy: Integer);
begin
fillRect(cx, cy, monsGrid.tileSize, monsGrid.tileSize, 0, 128, 0, 64);
procedure hilightCell1 (cx, cy: Integer);
begin
//e_WriteLog(Format('h1: (%d,%d)', [cx, cy]), MSG_NOTIFY);
+ cx := cx and (not (monsGrid.tileSize-1));
+ cy := cy and (not (monsGrid.tileSize-1));
fillRect(cx, cy, monsGrid.tileSize, monsGrid.tileSize, 255, 255, 0, 92);
end;
mon.getMapBox(mx, my, mw, mh);
drawLine(mx+mw div 2, my+mh div 2, emx+emw div 2, emy+emh div 2, 255, 0, 0, 255);
{$IF DEFINED(D2F_DEBUG)}
- //mapGrid.dbgRayTraceTileHitCB := hilightCell1;
+ mapGrid.dbgRayTraceTileHitCB := hilightCell1;
{$ENDIF}
if (g_Map_traceToNearestWall(mx+mw div 2, my+mh div 2, emx+emw div 2, emy+emh div 2, @ex, @ey) <> nil) then
//if (mapGrid.traceRay(ex, ey, mx+mw div 2, my+mh div 2, emx+emw div 2, emy+emh div 2, hilightWallTrc, (GridTagWall or GridTagDoor)) <> nil) then
drawLine(mx+mw div 2, my+mh div 2, ex, ey, 0, 255, 0, 255);
end;
{$IF DEFINED(D2F_DEBUG)}
- //mapGrid.dbgRayTraceTileHitCB := nil;
+ mapGrid.dbgRayTraceTileHitCB := nil;
{$ENDIF}
end;
TRIGGER_TEXTURE: begin end;
TRIGGER_ON, TRIGGER_OFF, TRIGGER_ONOFF, TRIGGER_PRESS:
begin
- if (trig.trigData.trigTWidth > 0) and (trig.trigData.trigTHeight > 0) then
+ if (trig.trigDataRec.trigTWidth > 0) and (trig.trigDataRec.trigTHeight > 0) then
begin
fillRect(
- trig.trigData.trigTX, trig.trigData.trigTY,
- trig.trigData.trigTWidth, trig.trigData.trigTHeight,
+ trig.trigDataRec.trigTX, trig.trigDataRec.trigTY,
+ trig.trigDataRec.trigTWidth, trig.trigDataRec.trigTHeight,
0, 255, 255, 42);
drawLine(
trig.trigCenter.x, trig.trigCenter.y,
- trig.trigData.trigTX+trig.trigData.trigTWidth div 2,
- trig.trigData.trigTY+trig.trigData.trigTHeight div 2,
+ trig.trigDataRec.trigTX+trig.trigDataRec.trigTWidth div 2,
+ trig.trigDataRec.trigTY+trig.trigDataRec.trigTHeight div 2,
255, 0, 255, 220);
end;
end;
var
mon: TMonster;
mx, my, mw, mh: Integer;
+ //pan: TPanel;
+ //ex, ey: Integer;
begin
if (gPlayer1 = nil) then exit;
if showTriggers then drawTriggers();
if showGrid then drawSelectedPlatformCells();
- drawAwakeCells();
+ //drawAwakeCells();
+
+ if showTraceBox then drawTraceBox();
//drawGibsBoxes();
+
+ //pan := g_Map_traceToNearest(16, 608, 16, 8, (GridTagObstacle or GridTagLiquid), @ex, @ey);
+ (*
+ {$IF DEFINED(D2F_DEBUG)}
+ mapGrid.dbgRayTraceTileHitCB := hilightCell1;
+ {$ENDIF}
+ pan := mapGrid.traceRay(ex, ey, 16, 608, 16, 8, nil, (GridTagObstacle or GridTagLiquid));
+ if (pan <> nil) then writeln('end=(', ex, ',', ey, ')');
+ {$IF DEFINED(D2F_DEBUG)}
+ mapGrid.dbgRayTraceTileHitCB := nil;
+ {$ENDIF}
+
+ pan := g_Map_PanelAtPoint(16, 608, (GridTagObstacle or GridTagLiquid));
+ if (pan <> nil) then writeln('hit!');
+ *)
+
glPopMatrix();
glDisable(GL_SCISSOR_TEST);
var
he: THMouseEvent;
begin
+ if g_Game_IsNet then begin result := false; exit; end;
holmesInitCommands();
holmesInitBinds();
result := true;
end;
begin
+ if g_Game_IsNet then begin result := false; exit; end;
holmesInitCommands();
holmesInitBinds();
result := false;
// ////////////////////////////////////////////////////////////////////////// //
procedure g_Holmes_Draw ();
begin
+ if g_Game_IsNet then exit;
{$IF not DEFINED(HEADLESS)}
holmesInitCommands();
holmesInitBinds();
glDisable(GL_SCISSOR_TEST);
glDisable(GL_TEXTURE_2D);
- if gGameOn then
- begin
- plrDebugDraw();
- end;
+ if gGameOn then plrDebugDraw();
{$ENDIF}
laserSet := false;
procedure g_Holmes_DrawUI ();
begin
+ if g_Game_IsNet then exit;
{$IF not DEFINED(HEADLESS)}
glPushMatrix();
glScalef(g_holmes_ui_scale, g_holmes_ui_scale, 1.0);
end;
end;
+procedure dbgToggleTraceBox (arg: Integer=-1); begin if (arg < 0) then showTraceBox := not showTraceBox else showTraceBox := (arg > 0); end;
+
+procedure dbgToggleHolmesPause (arg: Integer=-1); begin if (arg < 0) then g_Game_HolmesPause(not gPauseHolmes) else g_Game_HolmesPause(arg > 0); end;
+
procedure cbAtcurSelectMonster ();
function monsAtDump (mon: TMonster; tag: Integer): Boolean;
begin
result := true; // stop
- e_WriteLog(Format('monster #%d (UID:%u) (proxyid:%d)', [mon.arrIdx, mon.UID, mon.proxyId]), MSG_NOTIFY);
+ e_WriteLog(Format('monster #%d (UID:%u) (proxyid:%d)', [mon.arrIdx, mon.UID, mon.proxyId]), TMsgType.Notify);
monMarkedUID := mon.UID;
dumpPublishedProperties(mon);
end;
function monsAtDump (mon: TMonster; tag: Integer): Boolean;
begin
result := false; // don't stop
- e_WriteLog(Format('monster #%d (UID:%u) (proxyid:%d)', [mon.arrIdx, mon.UID, mon.proxyId]), MSG_NOTIFY);
+ e_WriteLog(Format('monster #%d (UID:%u) (proxyid:%d)', [mon.arrIdx, mon.UID, mon.proxyId]), TMsgType.Notify);
end;
begin
- e_WriteLog('===========================', MSG_NOTIFY);
+ e_WriteLog('===========================', TMsgType.Notify);
monsGrid.forEachAtPoint(pmsCurMapX, pmsCurMapY, monsAtDump);
- e_WriteLog('---------------------------', MSG_NOTIFY);
+ e_WriteLog('---------------------------', TMsgType.Notify);
end;
procedure cbAtcurDumpWalls ();
begin
result := false; // don't stop
if (platMarkedGUID = -1) then platMarkedGUID := pan.guid;
- e_LogWritefln('wall #%d(%d); enabled=%d (%d); (%d,%d)-(%d,%d)', [pan.arrIdx, pan.proxyId, Integer(pan.Enabled), Integer(mapGrid.proxyEnabled[pan.proxyId]), pan.X, pan.Y, pan.Width, pan.Height]);
+ e_LogWritefln('wall ''%s'' #%d(%d); enabled=%d (%d); (%d,%d)-(%d,%d)', [pan.mapId, pan.arrIdx, pan.proxyId, Integer(pan.Enabled), Integer(mapGrid.proxyEnabled[pan.proxyId]), pan.X, pan.Y, pan.Width, pan.Height]);
dumpPublishedProperties(pan);
end;
var
trig: PTrigger;
begin
platMarkedGUID := -1;
- e_WriteLog('=== TOGGLE WALL ===', MSG_NOTIFY);
+ e_WriteLog('=== TOGGLE WALL ===', TMsgType.Notify);
mapGrid.forEachAtPoint(pmsCurMapX, pmsCurMapY, wallToggle, (GridTagWall or GridTagDoor));
- e_WriteLog('--- toggle wall ---', MSG_NOTIFY);
+ e_WriteLog('--- toggle wall ---', TMsgType.Notify);
if showTriggers then
begin
for f := 0 to High(gTriggers) do
cmdAdd('mon_info', bcToggleMonsterInfo, 'toggle monster info', 'monster control');
cmdAdd('mon_los_plr', bcToggleMonsterLOSPlr, 'toggle monster LOS to player', 'monster control');
cmdAdd('mon_cells', bcToggleMonsterCells, 'toggle "show all cells occupied by monsters" (SLOW!)', 'monster control');
- cmdAdd('mon_wakeup', bcMonsterWakeup, 'toggle "show all cells occupied by monsters" (SLOW!)', 'monster control');
+ cmdAdd('mon_wakeup', bcMonsterWakeup, 'wake up selected monster', 'monster control');
cmdAdd('mon_spawn', bcMonsterSpawn, 'spawn monster', 'monster control');
cmdAdd('atcur_dump_monsters', cbAtcurDumpMonsters, 'dump monsters in cell', 'monster control');
cmdAdd('atcur_dump_walls', cbAtcurDumpWalls, 'dump walls in cell', 'wall control');
cmdAdd('atcur_disable_walls', cbAtcurToggleWalls, 'disable walls', 'wall control');
+
+ cmdAdd('dbg_tracebox', dbgToggleTraceBox, 'test traceBox()', 'player control');
+
+ cmdAdd('hlm_pause', dbgToggleHolmesPause, '"Holmes" pause mode', 'game control');
end;
keybindAdd('M-O', 'mplat_toggle');
keybindAdd('C-T', 'plr_teleport');
+ keybindAdd('M-T', 'dbg_tracebox');
keybindAdd('C-P', 'dbg_curpos');
keybindAdd('C-G', 'dbg_grid');
keybindAdd('C-1', 'mon_spawn zombie');
+ keybindAdd('C-S-P', 'hlm_pause');
+
// mouse
msbindAdd('LMB', 'atcur_select_monster');
msbindAdd('M-LMB', 'atcur_dump_monsters');