X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_player.pas;h=38bb86a299228cfdd06c61bf01973c1aad915da4;hb=711b70131199a68f0dfd966bce5f66fb9caf149a;hp=f1a38c900d2049d411e2483069992abf104baf50;hpb=1faa4ed48a2107743f3f77c9ee966eb4c29c18e0;p=d2df-sdl.git diff --git a/src/game/g_player.pas b/src/game/g_player.pas index f1a38c9..38bb86a 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -634,6 +634,7 @@ procedure g_Bot_Add(Team, Difficult: Byte; Handicap: Integer = 100); procedure g_Bot_AddList(Team: Byte; lname: ShortString; num: Integer = -1; Handicap: Integer = 100); procedure g_Bot_MixNames(); procedure g_Bot_RemoveAll(); +function g_Bot_GetCount(): Integer; implementation @@ -944,6 +945,9 @@ var begin if not g_Game_IsServer then Exit; +// Íå äîáàâëÿåì áîòîâ åñëè ëèìèò óæå äîñòèãíóò + if (g_Bot_GetCount() >= gMaxBots) then Exit; + // Ñïèñîê íàçâàíèé ìîäåëåé: m := g_PlayerModel_GetNames(); if m = nil then @@ -1041,6 +1045,9 @@ var begin if not g_Game_IsServer then Exit; +// Íå äîáàâëÿåì áîòîâ åñëè ëèìèò óæå äîñòèãíóò + if (g_Bot_GetCount() >= gMaxBots) then Exit; + // Ñïèñîê íàçâàíèé ìîäåëåé: m := g_PlayerModel_GetNames(); if m = nil then @@ -1408,6 +1415,20 @@ begin Result := Result + 1; end; +function g_Bot_GetCount(): Integer; +var + a: Integer; +begin + Result := 0; + + if gPlayers = nil then + Exit; + + for a := 0 to High(gPlayers) do + if (gPlayers[a] <> nil) and (gPlayers[a] is TBot) then + Result := Result + 1; +end; + function g_Player_GetStats(): TPlayerStatArray; var a: Integer; @@ -1998,42 +2019,45 @@ begin end; procedure TPlayer.SetWeaponPrefs(Prefs: Array of Byte); -var i: Integer; +var + i: Integer; begin for i := WP_FIRST to WP_LAST + 1 do begin - if (Prefs[i] < 0) or (Prefs[i] > WP_LAST + 1) then + if (Prefs[i] > WP_LAST + 1) then FWeapPreferences[i] := 0 - else FWeapPreferences[i] := Prefs[i]; + else + FWeapPreferences[i] := Prefs[i]; end; end; procedure TPlayer.SetWeaponPref(Weapon, Pref: Byte); begin - if (Weapon < 0) or (Weapon > WP_LAST + 1) then + if (Weapon > WP_LAST + 1) then exit - else if (Pref >= 0) and (Pref <= WP_LAST + 1) and (Weapon >= 0) and (Weapon <= WP_LAST + 1) then + else if (Pref <= WP_LAST + 1) and (Weapon <= WP_LAST + 1) then FWeapPreferences[Weapon] := Pref - else if (Weapon >= 0) and (Weapon <= WP_LAST + 1) and ((Pref < 0) or (Pref > WP_LAST + 1)) then + else if (Weapon <= WP_LAST + 1) and (Pref > WP_LAST + 1) then FWeapPreferences[Weapon] := 0; end; function TPlayer.GetWeaponPref(Weapon: Byte) : Byte; begin - if (Weapon < 0) or (Weapon > WP_LAST + 1) then + if (Weapon > WP_LAST + 1) then result := 0 - else if (FWeapPreferences[Weapon] < 0) or (FWeapPreferences[Weapon] > WP_LAST + 1) then + else if (FWeapPreferences[Weapon] > WP_LAST + 1) then result := 0 else result := FWeapPreferences[Weapon]; end; function TPlayer.GetMorePrefered() : Byte; -var testedWeap, i: Byte; +var + testedWeap, i: Byte; begin testedWeap := FCurrWeap; for i := WP_FIRST to WP_LAST do - if FWeapon[i] and (FWeapPreferences[i] > FWeapPreferences[testedWeap]) then + if FWeapon[i] and maySwitch(i) and (FWeapPreferences[i] > FWeapPreferences[testedWeap]) then testedWeap := i; if (R_BERSERK in FRulez) and (FWeapPreferences[WP_LAST + 1] > FWeapPreferences[testedWeap]) then testedWeap := WEAPON_KASTET; @@ -2049,7 +2073,7 @@ begin result := false; end else if (FSwitchToEmpty = 0) and (not hasAmmoForShooting(Weapon)) then - result := false + result := false; end; procedure TPlayer.SwitchTeam; @@ -3800,7 +3824,7 @@ end; function TPlayer.shouldSwitch (weapon: Byte; hadWeapon: Boolean): Boolean; begin result := false; - if (weapon < 0) or (weapon > WP_LAST + 1) then + if (weapon > WP_LAST + 1) then begin result := false; exit; @@ -3975,19 +3999,9 @@ begin end; function TPlayer.PickItem(ItemType: Byte; arespawn: Boolean; var remove: Boolean): Boolean; - - function allowBerserkSwitching (): Boolean; - begin - if (FBFGFireCounter <> -1) then begin result := false; exit; end; - result := true; - if gBerserkAutoswitch then exit; - if not conIsCheatsEnabled then exit; - result := false; - end; - var a: Boolean; - switchWeapon: Byte = -1; + switchWeapon: Byte = 255; hadWeapon: Boolean = False; begin Result := False; @@ -4340,8 +4354,12 @@ begin if not (R_BERSERK in FRulez) then begin Include(FRulez, R_BERSERK); - if (shouldSwitch(WP_LAST + 1, false)) then - QueueWeaponSwitch(WEAPON_KASTET); + if (FBFGFireCounter = -1) then + begin + FCurrWeap := WEAPON_KASTET; + resetWeaponQueue(); + FModel.SetWeapon(WEAPON_KASTET); + end; if gFlash <> 0 then begin Inc(FPain, 100); @@ -5566,10 +5584,9 @@ end; procedure TPlayer.NetFire(Wpn: Byte; X, Y, AX, AY: Integer; WID: Integer = -1); var locObj: TObj; - F: Boolean; + visible: Boolean = True; WX, WY, XD, YD: Integer; begin - F := False; WX := X; WY := Y; XD := AX; @@ -5578,6 +5595,7 @@ begin case FCurrWeap of WEAPON_KASTET: begin + visible := False; DoPunch(); if R_BERSERK in FRulez then begin @@ -5619,14 +5637,12 @@ begin FSawSoundSelect.Stop(); FSawSound.PlayAt(FObj.X, FObj.Y); end; - f := True; end; WEAPON_PISTOL: begin g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', GameX, Gamey); FFireAngle := FAngle; - f := True; g_Player_CreateShell(GameX+PLAYER_RECT_CX, GameY+PLAYER_RECT_CX, GameVelX, GameVelY-2, SHELL_BULLET); end; @@ -5635,7 +5651,6 @@ begin begin g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex, Gamey); FFireAngle := FAngle; - f := True; FShellTimer := 10; FShellType := SHELL_SHELL; end; @@ -5644,7 +5659,6 @@ begin begin g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', Gamex, Gamey); FFireAngle := FAngle; - f := True; FShellTimer := 13; FShellType := SHELL_DBLSHELL; end; @@ -5653,7 +5667,6 @@ begin begin g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', Gamex, Gamey); FFireAngle := FAngle; - f := True; g_Player_CreateShell(GameX+PLAYER_RECT_CX, GameY+PLAYER_RECT_CX, GameVelX, GameVelY-2, SHELL_BULLET); end; @@ -5662,28 +5675,24 @@ begin begin g_Weapon_Rocket(wx, wy, xd, yd, FUID, WID); FFireAngle := FAngle; - f := True; end; WEAPON_PLASMA: begin g_Weapon_Plasma(wx, wy, xd, yd, FUID, WID); FFireAngle := FAngle; - f := True; end; WEAPON_BFG: begin g_Weapon_BFGShot(wx, wy, xd, yd, FUID, WID); FFireAngle := FAngle; - f := True; end; WEAPON_SUPERPULEMET: begin g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex, Gamey); FFireAngle := FAngle; - f := True; g_Player_CreateShell(GameX+PLAYER_RECT_CX, GameY+PLAYER_RECT_CX, GameVelX, GameVelY-2, SHELL_SHELL); end; @@ -5693,11 +5702,10 @@ begin g_Weapon_flame(wx, wy, xd, yd, FUID, WID); FlamerOn; FFireAngle := FAngle; - f := True; end; end; - if not f then Exit; + if not visible then Exit; if (FAngle = 0) or (FAngle = 180) then SetAction(A_ATTACK) else if (FAngle = ANGLE_LEFTDOWN) or (FAngle = ANGLE_RIGHTDOWN) then SetAction(A_ATTACKDOWN) @@ -8037,7 +8045,6 @@ end; begin - conRegVar('cheat_berserk_autoswitch', @gBerserkAutoswitch, 'autoswitch to fist when berserk pack taken', '', true, true); conRegVar('player_indicator', @gPlayerIndicator, 'Draw indicator only for current player, also for teammates, or not at all', 'Draw indicator only for current player, also for teammates, or not at all'); conRegVar('player_indicator_style', @gPlayerIndicatorStyle, 'Visual appearance of indicator', 'Visual appearance of indicator'); end.