Author Topic: Dynamic Wave Grouping  (Read 762 times)

0 Members and 1 Guest are viewing this topic.

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Dynamic Wave Grouping
« on: December 12, 2009, 09:40:25 pm »
Hello everyone, I am trying to come up with a new way to calculate what zombies should be in-game at any particular time. Currently I have a long list of predefined (badly) groups that is loaded at compile and referenced every 10 seconds. I want a system that will dynamicly create the bot group using only the average level of all my players and predefined 'cost' of each bot. I have the bots enumerated and the costs loaded into an array. I am terrible with anything that requires sorting of any kind. Thank you to anyone that will help me.

Here is the structure of the arrays/constants:

Code: [Select]
const
botidend = 16;

maxbots = 16;
sbcopycat = 0;
sbdemon = 1;
sbdoppleganger = 2;
sbeliteslicerzombie = 3;
sbelitezombie = 4;
sbghoul = 5;
sbgrimreaper = 6;
sbkamakazi = 7;
sbmirror = 8;
sbmummy = 9;
sbnitrokamakazi = 10;
sbrocketzombie = 11;
sbslicerzombie = 12;
sbturncoat = 13;
sbvortex = 14;
sbzombie = 15;

var
bots,botcost: array[1..botidend] of byte;

There is currently a max of 16 bots, but with this system it would be totally dynamic. After the list (bots[]) is calculated then bots would be kicked/added to make the current in-server bots match.


Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Dynamic Wave Grouping
« Reply #1 on: December 13, 2009, 07:29:31 am »
Heres something I wrote with Neosano, maybe it helps you
Why using arrays when you can also just check how much are need and add/kick them instead of
calculating arrays, checking if enough bots are here or not and add/kick them.

Code: (pascal) [Select]
procedure BalanceBots(Add, Remove: String; Need, Players: integer);
var Current, Mustbe: integer; i, j: byte;
begin
  Current := 0;

  for i := 1 to 32 do
    if GetPlayerStat(i, 'Active') = True then
      if GetPlayerStat(i, 'Human') = False then
        if IDToName(i) = Add then
          Current := Current + 1;

  Mustbe  := Players DIV Need;

  if Mustbe < Current then
    while Mustbe < Current do begin
      Mustbe := Mustbe + 1;
      KickPlayer(NameToID(Add));
      Command('/addbot2 ' + Remove);
    end;

  if Mustbe > Current then
    while Mustbe > Current do begin
      Mustbe := Mustbe - 1;
      KickPlayer(NameToID(Remove));
      Command('/addbot2 ' + Add);
    end;

end;

You could set Players to the sum of the players levels and use Need for the level amount needed for the zombie.
« Last Edit: December 13, 2009, 07:33:07 am by y0uRd34th »