Jump to content

Keeping teams balanced


s1a

Recommended Posts

This could either be done in LUA or in the mod itself (it would be a great addition).

 

The shuffle is already configurable where you can shuffle by K/D, XP or PWR. We could do the same for changing team "prevention".

There is already some code to prevent people from joining a team that has more players. Just add a new cvar to allow the "change team" to be configurable: by amount of players, by K/D, XP or PWR.

 

This way you don't have to lock the teams in a certain way and prevent the players from joining another team as well as not preventing the specs from joining. This would keep the teams balanced by a configurable ratio.

 

In this case, the only way to make the teams unbalanced would be having a lot of players leave one team. Then it's up to the admins to putteam some key people in the other team or in spec. This would also help admins to not always have to putteam people that try to stack.

 

 

To do it in LUA, I would have to check how to catch and prevent a change team. This would be complicated since it has to be stopped before the class of the player change.

 

 

I've dig a bit in LUA and there is a way to just break the "/team" command. I could use that to prevent the team changing. I would have to make sure that I'm catching everything command. The limbo menu is using the team command as well as the popup menu. I'm not sure what are the other commands that can be used to switch team (except putteam). I would also have to match for the different teams to join: 1/r/R/a/A/b/B/2/3/s/S, etc. There has to be some logic in the blocking since /team is the way to change class also.

Another way that would be much simpler is to lock the team. The check could be done every 100ms and would lock/unlock teams appropriately. I see 2 issues with that way:

- there has to be a 100% thrust in the script that it will never forget to unlock a team (it can be achieved by issuing an unlock at each 100ms and locking right after)

- the players doesn't get a feedback of why they can't join the team

 

 

However, I have an issue to finish the 2nd most important part: I couldn't find any gclient fields that are available in LUA that gives the PWR and K/D. This means that until those are available for LUA, this mod can't be done.

 

I think it would be a very good idea to provide the PWR and K/D gclient fields to LUA as RO since that could be useful for other LUA mods. But at this moment, it's not available and LUA can't be used for this purpose until those gclient fields are available.

 

According to gaoesa, the code is the same for the g_lua.c as etpub. By taking a look at the array:

 

static const gentity_field_t gclient_fields[]

 

You can see that it's not available (I've look into ps.stats, sess.game_points and sess.skillpoints since they looked like "ratings").

 

The g_lua.c file is important for LUA coders and it would be great if all of it could be release to public or just added to the LUA documentation since the ETPro one is becoming more and more obsolete. This file tells what is available for LUA coders. In etpro, the source wasn't available, but they made sure that all the information from the g_lua.c was available at http://wolfwiki.anim...php/Lua_Mod_API. For etpub, they updated the LUA documentation from time to time, but they didn't really care since the source code was available. For Silent, you either have to document every functions that are in that file (you are missing about 10-15) + the gclient fields (you have about 5 more than etpro so their page is obsolete http://wolfwiki.anim...x.php/Fieldname).

 

 

 

Even if I gave a good example on how it can be done in LUA, I think it would be a great addition in the mod itself.

Link to comment
Share on other sites

  • Management
There is already some code to prevent people from joining a team that has more players. Just add a new cvar to allow the "change team" to be configurable: by amount of players, by K/D, XP or PWR.

 

This is a good idea. Though it might some in cases make higher ratio team have too few players, so it should probably effect only when the player numbers are close to even.

 

I'm also interested of the possibility of making some sort of Lua plugin possibility to team sorting.

Link to comment
Share on other sites

If you balance the teams using K/D, it might do that. However, the PWR would be a good way to achieve a balanced team.

 

I saw the other thread about team sorting and it can be done in LUA, the only problem is the availability of the gclient entities for the players.

 

Since you said that the g_lua.c is very similar to etpub, I'll give you some diff on how to make those available in etpub and you can see if it fits for Silent.

Link to comment
Share on other sites

  • Management

The problem with PWR is that it only counts wins and it adjusts very slowly. Therefore, I have seen players with very low usefullness for team having very high PRW and messing the balance that way. In theory, it does sound valid though. Probably part of the issue is in the slowness as it requires the known players playing all the time and it can also give low PRW to better players who intentionally choose the losing team in an attempt to balance. Same applies to KR too, but it adjusts little faster to a reasonable value. Best in my own opinion would be to combine both in a faster adjusting rate that would give value to players who put themselves into the game and also make results. Sorry I'm drifting again. We appreciate even a rough diff how you think the issue is best handled in the Lua.

 

PS. The Active Team Balance that was in the mod earlier used the PRW to make the teams and it actually resulted very unbalanced teams. This has been reported from several servers.

Link to comment
Share on other sites

I'm up for suggestion on the matter. On the FA Silent server, most of the time the "strong" players already played a couple hours. So ratio is normally already well adjusted. There is some new players joining from time to time, but it's still not happening very often. That's why I was originally suggesting the KR since for a new player that is very good, it will go up very fast. However, it's not always true that a good fragger will change the game.

 

Just to make it clearer, the diff I'll provide is how to make the PWR and KR available to the gentity fields.

Link to comment
Share on other sites

I've poke a bit in the etpub code and realistically it would take more time for me to do the diff than to you to do the addition.

The elements we need are in "g_player_rating.c" and are defined as:

 

float overall_killrating;

float overall_killvariance;

float rating;

float rating_variance;

 

Those are part of the "session" (clientSession_t) of a player which is defined in "g_local.h". Which is also part of the following struct (if you look at the 4-5 first variables of that struct in the "g_local.h" file):

struct gclient_s

Which is what we use to "allow" those variables in g_lua.c (define found in g_lua.h):

#define _et_gclient_addfield(n, t, f) {#n, t, offsetof(struct gclient_s, n), FIELD_FLAG_GCLIENT + f}

 

So to sum up, would it be possible to add the following in "static const gentity_field_t gclient_fields[]" in the g_lua.c file:

_et_gclient_addfield(sess.overall_killrating, FIELD_FLOAT, FIELD_FLAG_READONLY),

_et_gclient_addfield(sess.overall_killvariance, FIELD_FLOAT, FIELD_FLAG_READONLY),

_et_gclient_addfield(sess.rating, FIELD_FLOAT, FIELD_FLAG_READONLY),

_et_gclient_addfield(sess.rating_variance, FIELD_FLOAT, FIELD_FLAG_READONLY),

 

It would be much faster if you could do it directly since it's a very light change and I'll put it on a temp linux server to see if it works as I expect it.

 

Let me know if you would prefer me to do the changes in etpub to test it. That might take a couple days since I don't have anything to compile etpub at this moment.

Edited by s1a
Link to comment
Share on other sites

  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...