X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_player.pas;h=ebbd2043e5fc69d7784346b031c5b51d804f637c;hb=cb39caa8b879b70aa096476a2e919d4a298f1fa5;hp=75366d34590e693d5c82b50f235ee20adcc27f04;hpb=e0ef894b62b50d6a7bd7e1dfa42ee3f1a839403a;p=d2df-sdl.git diff --git a/src/game/g_player.pas b/src/game/g_player.pas index 75366d3..ebbd204 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -249,6 +249,11 @@ type FDummy: Boolean; FFireTime: Integer; + // debug: viewport offset + viewPortX, viewPortY, viewPortW, viewPortH: Integer; + + function isValidViewPort (): Boolean; inline; + constructor Create(); virtual; destructor Destroy(); override; procedure Respawn(Silent: Boolean; Force: Boolean = False); virtual; @@ -314,6 +319,8 @@ type //WARNING! this does nothing for now, but still call it! procedure positionChanged (); //WARNING! call this after monster position was changed, or coldet will not work right! + procedure getMapBox (out x, y, w, h: Integer); inline; + property Name: String read FName write FName; property Model: TPlayerModel read FModel; property Health: Integer read FHealth write FHealth; @@ -517,8 +524,9 @@ implementation uses e_log, g_map, g_items, g_console, SysUtils, g_gfx, Math, - g_options, g_triggers, g_menu, MAPDEF, g_game, - wadreader, g_main, g_monsters, CONFIG, g_language, g_net, g_netmsg; + g_options, g_triggers, g_menu, MAPDEF, g_game, g_grid, + wadreader, g_main, g_monsters, CONFIG, g_language, + g_net, g_netmsg, g_window, GL, g_holmes; type TBotProfile = record @@ -1842,6 +1850,8 @@ end; { T P l a y e r : } +function TPlayer.isValidViewPort (): Boolean; inline; begin result := (viewPortW > 0) and (viewPortH > 0); end; + procedure TPlayer.BFGHit(); begin g_Weapon_BFGHit(FObj.X+FObj.Rect.X+(FObj.Rect.Width div 2), @@ -1985,6 +1995,11 @@ end; constructor TPlayer.Create(); begin + viewPortX := 0; + viewPortY := 0; + viewPortW := 0; + viewPortH := 0; + FIamBot := False; FDummy := False; FSpawned := False; @@ -2300,7 +2315,28 @@ begin DrawAim(); end; + procedure TPlayer.DrawAim(); + procedure drawCast (sz: Integer; ax0, ay0, ax1, ay1: Integer); + var + ex, ey: Integer; + begin + if isValidViewPort and (self = gPlayer1) then + begin + g_Holmes_plrLaser(ax0, ay0, ax1, ay1); + end; + + e_DrawLine(sz, ax0, ay0, ax1, ay1, 255, 0, 0, 96); + if (g_Map_traceToNearestWall(ax0, ay0, ax1, ay1, @ex, @ey) <> nil) then + begin + e_DrawLine(sz, ax0, ay0, ex, ey, 0, 255, 0, 96); + end + else + begin + e_DrawLine(sz, ax0, ay0, ex, ey, 0, 0, 255, 96); + end; + end; + var wx, wy, xx, yy: Integer; angle: SmallInt; @@ -2387,7 +2423,11 @@ begin end; xx := Trunc(Cos(-DegToRad(angle)) * len) + wx; yy := Trunc(Sin(-DegToRad(angle)) * len) + wy; + {$IF DEFINED(D2F_DEBUG)} + drawCast(sz, wx, wy, xx, yy); + {$ELSE} e_DrawLine(sz, wx, wy, xx, yy, 255, 0, 0, 96); + {$ENDIF} end; procedure TPlayer.DrawGUI(); @@ -2980,7 +3020,7 @@ var id: DWORD; begin id := g_Items_Create(FObj.X, FObj.Y, t, True, False); - it := g_ItemByIdx(id); + it := g_Items_ByIdx(id); if KillType = K_EXTRAHARDKILL then // -7..+7; -8..0 begin g_Obj_Push(@it.Obj, (FObj.Vel.X div 2)-7+Random(15), @@ -3121,7 +3161,7 @@ begin end else if g_GetUIDType(SpawnerUID) = UID_MONSTER then begin // Óáèò ìîíñòðîì - mon := g_Monsters_Get(SpawnerUID); + mon := g_Monsters_ByUID(SpawnerUID); if mon = nil then s := '?' else @@ -4813,7 +4853,7 @@ begin DecMin(FPain, 5, 0); DecMin(FPickup, 1, 0); - if FLive and (FObj.Y > gMapInfo.Height+128) and AnyServer then + if FLive and (FObj.Y > Integer(gMapInfo.Height)+128) and AnyServer then begin // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë FMegaRulez[MR_SUIT] := 0; @@ -4998,6 +5038,14 @@ begin if FKeys[b].Time = 0 then FKeys[b].Pressed := False else Dec(FKeys[b].Time); end; +procedure TPlayer.getMapBox (out x, y, w, h: Integer); inline; +begin + x := FObj.X+PLAYER_RECT.X; + y := FObj.Y+PLAYER_RECT.Y; + w := PLAYER_RECT.Width; + h := PLAYER_RECT.Height; +end; + function TPlayer.Collide(X, Y: Integer; Width, Height: Word): Boolean; begin Result := g_Collide(FObj.X+PLAYER_RECT.X, @@ -6304,10 +6352,10 @@ var vsPlayer, vsMonster, ok: Boolean; - function monsUpdate (monidx: Integer; mon: TMonster): Boolean; + function monsUpdate (mon: TMonster): Boolean; begin result := false; // don't stop - if (mon <> nil) and (mon.Live) and (mon.MonsterType <> MONSTER_BARREL) then + if mon.Live and (mon.MonsterType <> MONSTER_BARREL) then begin if not TargetOnScreen(mon.Obj.X+mon.Obj.Rect.X, mon.Obj.Y+mon.Obj.Rect.Y) then exit; @@ -6393,7 +6441,7 @@ begin if (g_GetUIDType(Target.UID) = UID_MONSTER) and vsMonster then begin // Ìîíñòð - mon := g_Monsters_Get(Target.UID); + mon := g_Monsters_ByUID(Target.UID); if mon <> nil then begin Target.X := mon.Obj.X; @@ -6626,7 +6674,7 @@ begin end else begin // Öåëü - ìîíñòð - mon := g_Monsters_Get(Target.UID); + mon := g_Monsters_ByUID(Target.UID); if (mon = nil) or (not mon.Live) then Target.UID := 0; // òî çàáûòü öåëü end; @@ -7378,7 +7426,7 @@ begin if (g_GetUIDType(FLastSpawnerUID) = UID_MONSTER) and LongBool(gGameSettings.Options and GAME_OPTION_BOTVSMONSTER) then begin // Ìîíñòð - mon := g_Monsters_Get(FLastSpawnerUID); + mon := g_Monsters_ByUID(FLastSpawnerUID); ok := not TargetOnScreen(mon.Obj.X + mon.Obj.Rect.X, mon.Obj.Y + mon.Obj.Rect.Y); end;