0 Members and 1 Guest are viewing this topic.
const // zombie related stuff min_ghouls = 4; GhoulsPerPlayer = 2; BotSpecies = 2; // teams GhoulTeam = 1; HumanTeam = 2; type TBot = Record species, armor, chest: integer; // Species; 1: Ghoul; 2: Imploding Ghoul; kick: boolean; end; TSpecies = Record armor, chest, need: integer; name: string; end;var Bot: Array [1..30] of TBot; species: array [1..BotSpecies] of TSpecies;function HighestID(): byte;var i: byte;begin for i := 1 to 30 do if GetPlayerStat(i,'Active') = true then Result := i;end; procedure SetSpecies();begin species[1].name := 'Ghoul'; species[1].armor := 8000; species[1].chest := 10; species[1].need := 1; species[2].name := 'Imploding Ghoul'; species[2].armor := 12000; species[2].chest := 30 species[2].need := 3;end;function GetBotSpecies(ID: byte): integer;var i: byte;begin for i := 1 to BotSpecies do begin if IDToName(ID) = species[i].name then Result := i; end;end;function GetBotCount(Specie: integer): byte;var i: byte;begin Result := 0; for i := 1 to HighestID do begin if GetPlayerStat(i,'Active') = true then if GetPlayerStat(i,'Human') = false then if IDToName(i) = species[Specie].name then Result := Result + 1; end;end;function GetBot(Specie: integer): integer;var i: byte;begin for i := 1 to HighestID do begin if GetPlayerStat(i,'Active') = true then if GetPlayerStat(i,'Human') = false then if IDToName(i) = species[specie].name then begin Result := i; break; end; end; end;procedure CalculateGhouls();var botcount, num: array [1..BotSpecies] of integer; humans, i, j, present, ghouls : integer;begin humans := 0; present := 0; for i := 1 to BotSpecies do botcount[i] := GetBotCount(i); for i := 1 to HighestID do begin if GetPlayerStat(i,'Active') = true then if GetPlayerStat(i,'Human') = true then humans := humans + 1; end; ghouls := GhoulsPerPlayer * humans + min_Ghouls; for i := 1 to BotSpecies do present := present + botcount[i]; // less bots then minimal number of them? set it to the minimum number if present < min_ghouls then present := min_ghouls; // not enough bots on server for humans? add them if present < ghouls then for i := 1 to ghouls - present do begin Command('/addbot' + IntToStr(GhoulTeam) + ' ' + species[1].name); botcount[1] := botcount[1] + 1; // too much bots per player there? kick them to balance if present > ghouls then for i := 1 to present - ghouls do begin j := GetBot(1); KickPlayer(j); botcount[1] := botcount[1] - 1; end; end; if humans > 0 then begin // setting up the number of bots required to add for i := 1 to BotSpecies do begin if humans > species[i].need then num[i] := humans div species[i].need; end; // now add or kick them for i := 1 to BotSpecies do begin // not enough bots there? add them if botcount[i] < num[i] then while botcount[i] < num[i] do begin Command('/addbot' + IntToStr(GhoulTeam) + ' ' + species[i].name); j := GetBot(1); KickPlayer(j); botcount[i] := botcount[i] + 1; botcount[1] := botcount[1] - 1; end; // too much on the server? kick them if botcount[i] > num[i] then while botcount[i] > num[i] do begin j := GetBot(i); KickPlayer(j); botcount[i] := botcount[i] - 1; if i > 1 then begin Command('/addbot' + IntToStr(GhoulTeam) + ' ' + species[1].name); botcount[1] := botcount[1] + 1; end; end; end; end;end;procedure ActivateServer();begin SetSpecies;end;procedure OnJoinTeam(ID, team: byte);begin calculateghouls;end;procedure OnLeaveGame(ID, team: byte; kicked: boolean);begin calculateghouls;end;
num[i] := humans div species[i].need;