From: TerminalHash Date: Sun, 27 Aug 2023 23:14:42 +0000 (+0300) Subject: game: prototype for assists X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=46340979eb07041ef9b30fc62e84cabce72d4901;p=d2df-sdl.git game: prototype for assists There is only a value in the table. How to handle certain types of deaths and events (like <50 HP and kill by third player) needs to be thought about. --- diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 0cca553..6a8d63c 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -641,12 +641,14 @@ function Compare(a, b: TPlayerStat): Integer; begin if a.Spectator then Result := 1 else if b.Spectator then Result := -1 - else if a.Frags < b.Frags then Result := 1 - else if a.Frags > b.Frags then Result := -1 - else if a.Deaths < b.Deaths then Result := -1 - else if a.Deaths > b.Deaths then Result := 1 - else if a.Kills < b.Kills then Result := -1 - else Result := 1; + else if a.Assists < b.Assists then Result := 1 + else if a.Assists > b.Assists then Result := -1 + else if a.Frags < b.Frags then Result := 1 + else if a.Frags > b.Frags then Result := -1 + else if a.Deaths < b.Deaths then Result := -1 + else if a.Deaths > b.Deaths then Result := 1 + else if a.Kills < b.Kills then Result := -1 + else Result := 1; end; procedure SortGameStat(var stat: TPlayerStatArray); @@ -716,10 +718,10 @@ begin WriteLn(s, Format('mon_killed,mon_total,secrets_found,secrets_total' + LineEnding + '%d,%d,%d,%d',[gCoopMonstersKilled, gTotalMonsters, gCoopSecretsFound, gSecretsCount])); // lines 3-...: team, player name, frags, deaths - WriteLn(s, 'team,name,frags,deaths'); + WriteLn(s, 'team,name,frags,assists,deaths'); for I := Low(Stat.PlayerStat) to High(Stat.PlayerStat) do with Stat.PlayerStat[I] do - WriteLn(s, Format('%d,%s,%d,%d', [Team, dquoteStr(Name), Frags, Deaths])); + WriteLn(s, Format('%d,%s,%d,%d', [Team, dquoteStr(Name), Frags, Assists, Deaths])); except g_Console_Add(Format(_lc[I_CONSOLE_ERROR_WRITE], [fname])); end; @@ -1086,6 +1088,7 @@ begin Num := a; Name := gPlayers[a].Name; Frags := gPlayers[a].Frags; + Assists := gPlayers[a].Assists; Deaths := gPlayers[a].Death; Kills := gPlayers[a].Kills; Team := gPlayers[a].Team; @@ -1340,6 +1343,8 @@ begin e_TextureFontPrintEx(x+w1+16, _y, Format(_lc[I_GAME_PING_MS], [Ping, Loss]), gStdFont, rr, gg, bb, 1); // Ôðàãè e_TextureFontPrintEx(x+w1+w2+16, _y, IntToStr(Frags), gStdFont, rr, gg, bb, 1); + // Àññèñòû + e_TextureFontPrintEx(x+w1+w2+48, _y, IntToStr(Assists), gStdFont, rr, gg, bb, 1); // Ñìåðòè e_TextureFontPrintEx(x+w1+w2+w3+16, _y, IntToStr(Deaths), gStdFont, rr, gg, bb, 1); _y := _y+ch; @@ -2914,7 +2919,8 @@ begin else e_TextureFontPrintEx(x+16, _y, Name, gStdFont, rr, gg, bb, 1); e_TextureFontPrintEx(x+w1+16, _y, IntToStr(Frags), gStdFont, rr, gg, bb, 1); - e_TextureFontPrintEx(x+w1+w2+16, _y, IntToStr(Deaths), gStdFont, rr, gg, bb, 1); + e_TextureFontPrintEx(x+w1+w2+16, _y, IntToStr(Assists), gStdFont, rr, gg, bb, 1); + e_TextureFontPrintEx(x+w1+w2+w3+16, _y, IntToStr(Deaths), gStdFont, rr, gg, bb, 1); _y := _y+24; end; @@ -5382,6 +5388,7 @@ begin if gGameSettings.GameMode = GM_COOP then begin gPlayers[i].Frags := 0; + gPlayers[i].Assists := 0; gPlayers[i].RecallState; end; if (gPlayer1 = nil) and (gSpectLatchPID1 > 0) then diff --git a/src/game/g_language.pas b/src/game/g_language.pas index 975360b..b3262a8 100644 --- a/src/game/g_language.pas +++ b/src/game/g_language.pas @@ -58,6 +58,7 @@ type I_GAME_PING_MS, I_GAME_PING_HUD, I_GAME_FRAGS, + I_GAME_ASSISTS, I_GAME_DEATHS, I_GAME_DM, I_GAME_CTF, @@ -754,6 +755,8 @@ const 'Ïèíã: '), ('GAME FRAGS', 'Frags', 'Ôðàãîâ'), + ('GAME ASSISTS', 'Assists', + 'Àññèñòîâ'), ('GAME DEATHS', 'Deaths', 'Ñìåðòåé'), ('GAME DM', 'Deathmatch', diff --git a/src/game/g_netmsg.pas b/src/game/g_netmsg.pas index b090aa3..9b8214c 100644 --- a/src/game/g_netmsg.pas +++ b/src/game/g_netmsg.pas @@ -1332,6 +1332,7 @@ begin NetOut.Write(Byte(R_BERSERK in FRulez)); NetOut.Write(Frags); + NetOut.Write(Assists); NetOut.Write(Death); NetOut.Write(CurrWeap); @@ -2542,6 +2543,7 @@ begin FRulez := FRulez + [R_BERSERK]; Frags := M.ReadLongInt(); + Assists := M.ReadLongInt(); Death := M.ReadLongInt(); SetWeapon(M.ReadByte()); diff --git a/src/game/g_player.pas b/src/game/g_player.pas index d0275d0..c903d13 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -112,6 +112,7 @@ type Name: String; Team: Byte; Frags: SmallInt; + Assists: SmallInt; Deaths: SmallInt; Lives: Byte; Kills: Word; @@ -160,6 +161,7 @@ type FKills: Integer; FMonsterKills: Integer; FFrags: Integer; + FAssists: Integer; FFragCombo: Byte; FLastFrag: LongWord; FComboEvnt: Integer; @@ -383,6 +385,7 @@ type property Air: Integer read FAir write FAir; property JetFuel: Integer read FJetFuel write FJetFuel; property Frags: Integer read FFrags write FFrags; + property Assists: Integer read FAssists write FAssists; property Death: Integer read FDeath write FDeath; property Kills: Integer read FKills write FKills; property CurrWeap: Byte read FCurrWeap write FCurrWeap; @@ -419,6 +422,7 @@ type property eAir: Integer read FAir write FAir; property eJetFuel: Integer read FJetFuel write FJetFuel; property eFrags: Integer read FFrags write FFrags; + property eAssists: Integer read FAssists write FAssists; property eDeath: Integer read FDeath write FDeath; property eKills: Integer read FKills write FKills; property eCurrWeap: Byte read FCurrWeap write FCurrWeap; @@ -1497,6 +1501,7 @@ begin Name := gPlayers[a].FName; Team := gPlayers[a].FTeam; Frags := gPlayers[a].FFrags; + Assists := gPlayers[a].FAssists; Deaths := gPlayers[a].FDeath; Kills := gPlayers[a].FKills; Color := gPlayers[a].FModel.Color; @@ -2779,7 +2784,7 @@ var X, Y, SY, a, p, m: Integer; tw, th: Word; cw, ch: Byte; - s: string; + s, t: string; stat: TPlayerStatArray; begin X := gPlayerScreenSize.X; @@ -2835,10 +2840,12 @@ begin if gShowStat then begin s := IntToStr(Frags); + t := IntToStr(Assists); e_CharFont_GetSize(gMenuFont, s, tw, th); e_CharFont_PrintEx(gMenuFont, X-16-tw, Y, s, _RGB(255, 0, 0)); s := ''; + t := ''; p := 1; m := 0; stat := g_Player_GetStats(); @@ -2858,6 +2865,10 @@ begin if Frags >= m then s := s+'+' else s := s+'-'; s := s+IntToStr(Abs(Frags-m)); + t := IntToStr(p)+' / '+IntToStr(Length(stat))+' '; + if Assists >= m then t := t+'+' else t := t+'-'; + t := t+IntToStr(Abs(Assists-m)); + e_CharFont_GetSize(gMenuSmallFont, s, tw, th); e_CharFont_PrintEx(gMenuSmallFont, X-16-tw, Y+32, s, _RGB(255, 0, 0)); end; @@ -3428,6 +3439,7 @@ var plr: TPlayer; srv, netsrv: Boolean; DoFrags: Boolean; + DoAssists: Boolean; OldLR: Byte; KP: TPlayer; it: PItem; @@ -3465,6 +3477,7 @@ var begin DoFrags := (gGameSettings.MaxLives = 0) or (gGameSettings.GameMode = GM_COOP); + DoAssists := (gGameSettings.GameMode = GM_TDM) or (gGameSettings.GameMode = GM_CTF); Srv := g_Game_IsServer; Netsrv := g_Game_IsServer and g_Game_IsNet; if Srv then FDeath := FDeath + 1; @@ -3553,6 +3566,15 @@ begin KP.FragCombo(); end; + // Assists block + if (DoAssists or (gGameSettings.GameMode = GM_TDM)) then + begin + if a = 4 then + begin + Inc(KP.FAssists); + end; + end; + if (gGameSettings.GameMode = GM_TDM) and DoFrags then Inc(gTeamStat[KP.Team].Score, IfThen(SameTeam(FUID, SpawnerUID), -1, 1)); @@ -4515,6 +4537,7 @@ begin FNoTarget := False; FNoReload := False; FFrags := 0; + FAssists := 0; FLastFrag := 0; FComboEvnt := -1; FKills := 0; @@ -6155,6 +6178,8 @@ begin utils.writeInt(st, LongInt(FMonsterKills)); // Ôðàãîâ utils.writeInt(st, LongInt(FFrags)); + // Àññèñòîâ + utils.writeInt(st, LongInt(FAssists)); // Ôðàãîâ ïîäðÿä utils.writeInt(st, Byte(FFragCombo)); // Âðåìÿ ïîñëåäíåãî ôðàãà @@ -6259,6 +6284,8 @@ begin FMonsterKills := utils.readLongInt(st); // Ôðàãîâ FFrags := utils.readLongInt(st); + // Àññèñòîâ + FAssists := utils.readLongInt(st); // Ôðàãîâ ïîäðÿä FFragCombo := utils.readByte(st); // Âðåìÿ ïîñëåäíåãî ôðàãà