summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9ff94be)
raw | patch | inline | side by side (parent: 9ff94be)
author | Dmitry D. Chernov <blackdoomer@yandex.ru> | |
Sat, 15 Jul 2023 05:35:05 +0000 (15:35 +1000) | ||
committer | Dmitry D. Chernov <blackdoomer@yandex.ru> | |
Sat, 15 Jul 2023 05:35:05 +0000 (15:35 +1000) |
src/game/g_player.pas | patch | blob | history |
diff --git a/src/game/g_player.pas b/src/game/g_player.pas
index a7afb5c9d17116a2ed8a5624ec881c62124056c7..06176d94272587199f1e6c7f910cb046fc5565f4 100644 (file)
--- a/src/game/g_player.pas
+++ b/src/game/g_player.pas
path: AnsiString;
begin
BotNames := nil;
+ BotList := nil;
path := BOTNAMES_FILENAME;
- if e_FindResource(DataDirs, path) = false then
- Exit;
-
-// ×èòàåì âîçìîæíûå èìåíà áîòîâ èç ôàéëà:
- AssignFile(F, path);
- Reset(F);
-
- while not EOF(F) do
+ if e_FindResource(DataDirs, path) then
begin
- ReadLn(F, s);
+ // ×èòàåì âîçìîæíûå èìåíà áîòîâ èç ôàéëà:
+ AssignFile(F, path);
+ Reset(F);
- s := Trim(s);
- if s = '' then
- Continue;
+ while not EOF(F) do
+ begin
+ ReadLn(F, s);
- SetLength(BotNames, Length(BotNames)+1);
- BotNames[High(BotNames)] := s;
- end;
+ s := Trim(s);
+ if s = '' then
+ Continue;
- CloseFile(F);
+ SetLength(BotNames, Length(BotNames)+1);
+ BotNames[High(BotNames)] := s;
+ end;
-// Ïåðåìåøèâàåì èõ:
- g_Bot_MixNames();
+ CloseFile(F);
-// ×èòàåì ôàéë ñ ïàðàìåòðàìè áîòîâ:
- config := TConfig.CreateFile(path);
- BotList := nil;
- a := 0;
+ // Ïåðåìåøèâàåì èõ:
+ g_Bot_MixNames();
+ end;
- while config.SectionExists(IntToStr(a)) do
+ path := BOTLIST_FILENAME;
+ if e_FindResource(DataDirs, path) then
begin
- SetLength(BotList, Length(BotList)+1);
+ // ×èòàåì ôàéë ñ ïàðàìåòðàìè áîòîâ:
+ config := TConfig.CreateFile(path);
+ a := 0;
- with BotList[High(BotList)] do
+ while config.SectionExists(IntToStr(a)) do
begin
- // Èìÿ áîòà:
- name := config.ReadStr(IntToStr(a), 'name', '');
- // Ìîäåëü:
- model := config.ReadStr(IntToStr(a), 'model', '');
- // Êîìàíäà:
- if config.ReadStr(IntToStr(a), 'team', 'red') = 'red' then
- team := TEAM_RED
- else
- team := TEAM_BLUE;
- // Öâåò ìîäåëè:
- sa := parse(config.ReadStr(IntToStr(a), 'color', ''));
- color.R := StrToIntDef(sa[0], 0);
- color.G := StrToIntDef(sa[1], 0);
- color.B := StrToIntDef(sa[2], 0);
- // Âåðîÿòíîñòü ñòðåëüáû ïîä óãëîì:
- diag_fire := config.ReadInt(IntToStr(a), 'diag_fire', 0);
- // Âåðîÿòíîñòü îòâåòíîãî îãíÿ ïî íåâèäèìîìó ñîïåðíèêó:
- invis_fire := config.ReadInt(IntToStr(a), 'invis_fire', 0);
- // Òî÷íîñòü ñòðåëüáû ïîä óãëîì:
- diag_precision := config.ReadInt(IntToStr(a), 'diag_precision', 0);
- // Òî÷íîñòü ñòðåëüáû â ïîëåòå:
- fly_precision := config.ReadInt(IntToStr(a), 'fly_precision', 0);
- // Òî÷íîñòü óêëîíåíèÿ îò ñíàðÿäîâ:
- cover := config.ReadInt(IntToStr(a), 'cover', 0);
- // Âåðîÿòíîñòü ïðûæêà ïðè ïðèáëèæåíèè ñîïåðíèêà:
- close_jump := config.ReadInt(IntToStr(a), 'close_jump', 0);
- // Ïðèîðèòåòû îðóæèÿ äëÿ äàëüíåãî áîÿ:
- sa := parse(config.ReadStr(IntToStr(a), 'w_prior1', ''));
- if Length(sa) = 10 then
- for b := 0 to 9 do
- w_prior1[b] := EnsureRange(StrToInt(sa[b]), 0, 9);
- // Ïðèîðèòåòû îðóæèÿ äëÿ áëèæíåãî áîÿ:
- sa := parse(config.ReadStr(IntToStr(a), 'w_prior2', ''));
- if Length(sa) = 10 then
- for b := 0 to 9 do
- w_prior2[b] := EnsureRange(StrToInt(sa[b]), 0, 9);
-
- {sa := parse(config.ReadStr(IntToStr(a), 'w_prior3', ''));
- if Length(sa) = 10 then
- for b := 0 to 9 do
- w_prior3[b] := EnsureRange(StrToInt(sa[b]), 0, 9);}
+ SetLength(BotList, Length(BotList)+1);
+
+ with BotList[High(BotList)] do
+ begin
+ name := config.ReadStr(IntToStr(a), 'name', ''); // Èìÿ áîòà
+ model := config.ReadStr(IntToStr(a), 'model', ''); // Ìîäåëü
+
+ // Êîìàíäà
+ if config.ReadStr(IntToStr(a), 'team', 'red') = 'red'
+ then team := TEAM_RED
+ else team := TEAM_BLUE;
+
+ // Öâåò ìîäåëè
+ sa := parse(config.ReadStr(IntToStr(a), 'color', ''));
+ color.R := StrToIntDef(sa[0], 0);
+ color.G := StrToIntDef(sa[1], 0);
+ color.B := StrToIntDef(sa[2], 0);
+
+ diag_fire := config.ReadInt(IntToStr(a), 'diag_fire', 0); // Âåðîÿòíîñòü ñòðåëüáû ïîä óãëîì
+ invis_fire := config.ReadInt(IntToStr(a), 'invis_fire', 0); // Âåðîÿòíîñòü îòâåòíîãî îãíÿ ïî íåâèäèìîìó ñîïåðíèêó
+ diag_precision := config.ReadInt(IntToStr(a), 'diag_precision', 0); // Òî÷íîñòü ñòðåëüáû ïîä óãëîì
+ fly_precision := config.ReadInt(IntToStr(a), 'fly_precision', 0); // Òî÷íîñòü ñòðåëüáû â ïîëåòå
+ cover := config.ReadInt(IntToStr(a), 'cover', 0); // Òî÷íîñòü óêëîíåíèÿ îò ñíàðÿäîâ
+ close_jump := config.ReadInt(IntToStr(a), 'close_jump', 0); // Âåðîÿòíîñòü ïðûæêà ïðè ïðèáëèæåíèè ñîïåðíèêà
+
+ // Ïðèîðèòåòû îðóæèÿ äëÿ äàëüíåãî áîÿ
+ sa := parse(config.ReadStr(IntToStr(a), 'w_prior1', ''));
+ if Length(sa) = 10 then
+ for b := 0 to 9 do
+ w_prior1[b] := EnsureRange(StrToInt(sa[b]), 0, 9);
+
+ // Ïðèîðèòåòû îðóæèÿ äëÿ áëèæíåãî áîÿ
+ sa := parse(config.ReadStr(IntToStr(a), 'w_prior2', ''));
+ if Length(sa) = 10 then
+ for b := 0 to 9 do
+ w_prior2[b] := EnsureRange(StrToInt(sa[b]), 0, 9);
+
+ {sa := parse(config.ReadStr(IntToStr(a), 'w_prior3', ''));
+ if Length(sa) = 10 then
+ for b := 0 to 9 do
+ w_prior3[b] := EnsureRange(StrToInt(sa[b]), 0, 9);}
+ end;
+
+ a += 1;
end;
- a := a + 1;
+ config.Free();
end;
- config.Free();
SetLength(SavedStates, 0);
end;