Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/role preference options #1142

Closed

Conversation

EntranceJew
Copy link
Contributor

made dead code not dead

Copy link
Member

@TimGoll TimGoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice contribution thank you. I also like the way you named your variables. I'm hesitating a bit because of the convars though

gamemodes/terrortown/gamemode/server/sv_roleselection.lua Outdated Show resolved Hide resolved

---
-- @realm server
ttt2_roles_trickle_down_odds = CreateConVar("ttt2_roles_trickle_down_odds", "3", {FCVAR_NOTIFY, FCVAR_ARCHIVE}, "The 1/N odds of a player receiving a role and not being passed up."),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also not 100% sure we need this. If you add this, you have to explain in detail in the UI how changing this convar affects the selection. Because I think it is hard to understand.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I don't even like having the math.random call in there -- I think the shuffle is doing all the work the RNG really needs to do to consider things.

Should we just only focus on conditions that prevent the role from being selected and pass true by default?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's hard to make a call on as I never worked on the roleselection. Maybe @saibotk has more insight into this. Or @ZenBre4ker?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The system is broken in a way anyway. As @saibotk mentioned in another PR, I wouldnt give so many options. I would either always allow or forbid avoiding roles alltogether. I dont like that system anyway, so I would suggest to remove role avoiding alltogether.

About the random call, I believe they tried to make it more random as in the past often the same players in a row got the same role over and over again.

And the trickle system I need to take a look again.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel the same way, all this role avoidance stuff is rarely used by players and should rather be something a server owner decides upon. This just adds unnecessary complexity and confusion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah checked again, I would just set the tricklerate as before to 3 and check if it is 2, so 1/3 chance, that role gets assigned without the other conditions.

@TimGoll
Copy link
Member

TimGoll commented Nov 22, 2023

I also have to run the TTT2LanguageParser on this one

Copy link
Contributor

@ZenBre4ker ZenBre4ker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You definitely revived the dead code 😄

But I believe, that you implemented SelectBaseRolePlayers wrongly. Removing the random aspect and the while loop means, that this pass could be false for many players.
I am unsure about the consequences, but it does not have the same behaviour as before, if I am not wrong.

Also in my opinion please dont insert two more convars. The trickle rate is just there to randomize the other states.

Comment on lines 887 to 886
for j = 1, #plysSecondPass do
local ply = plysSecondPass[j]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should stay as "i". I dont see where this would be a problem.

gamemodes/terrortown/gamemode/server/sv_roleselection.lua Outdated Show resolved Hide resolved

---
-- @realm server
ttt2_roles_trickle_down_odds = CreateConVar("ttt2_roles_trickle_down_odds", "3", {FCVAR_NOTIFY, FCVAR_ARCHIVE}, "The 1/N odds of a player receiving a role and not being passed up."),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah checked again, I would just set the tricklerate as before to 3 and check if it is 2, so 1/3 chance, that role gets assigned without the other conditions.

local minKarmaCVar = GetConVar("ttt_" .. roles.GetByIndex(subrole).name .. "_karma_min")
local min_karmas = minKarmaCVar and minKarmaCVar:GetInt() or 0

while curRoles < roleAmount and #plys > 0 do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesnt removing this while loop here means, that players might not get a role in this pass?

As far as I can see, the "CanSelectRole" method can most often just return false.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also unsure about what this change implies for the selection process further down.

We need to think of the assumptions, that were made for what this function does codewise.
It always tries to assign players to the given subrole until roleAmount of players received the role.
This is now not the case anymore and we need to check if that is assumed to happen here and if other functionality relies on that to happen etc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(After requested Review)
Isnt this still having the same problem here?
Exchanging the while loop with a for loop seems like different behaviour?

@EntranceJew EntranceJew force-pushed the feature/role-preference-options branch from 965dd50 to 5ca661c Compare December 6, 2023 14:10
@TimGoll
Copy link
Member

TimGoll commented Dec 6, 2023

I see you worked again on this PR. We discussed this one as well las sunday and we had the uniform opinion, that the trickle down convar should be removed. It might be a good idea to move it to a library variagble though. Something like roleselection.trickleDownRate. That way addons can easily interact with it, if they so desire.

@ZenBre4ker Wasn't sure if you broke any of the roleselection logic, so he has to confirm your changes.

Last but not least we'd like to let you know that we tend to remove the role avoidance completely as it doesn't work that well anyway. Most players seem really confused by it.

@EntranceJew
Copy link
Contributor Author

is the intention to have this commit remove the role avoidance settings instead? or will that be later?

@TimGoll
Copy link
Member

TimGoll commented Dec 7, 2023

is the intention to have this commit remove the role avoidance settings instead? or will that be later?

Later. If you want to add to the role avoidance that is fine. Just be aware that it will probably be removed at some point

@EntranceJew EntranceJew force-pushed the feature/role-preference-options branch 2 times, most recently from eefe340 to f5d7a83 Compare December 7, 2023 10:11
@@ -16,6 +16,7 @@ roleselection.finalRoles = {}
roleselection.selectableRoles = nil
roleselection.baseroleLayers = {}
roleselection.subroleLayers = {}
roleselection.trickleDownRate = 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still can have a sane default, as it was there before too with the random(3) == 2

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still 0, should be at least 3.

local minKarmaCVar = GetConVar("ttt_" .. roles.GetByIndex(subrole).name .. "_karma_min")
local min_karmas = minKarmaCVar and minKarmaCVar:GetInt() or 0

while curRoles < roleAmount and #plys > 0 do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also unsure about what this change implies for the selection process further down.

We need to think of the assumptions, that were made for what this function does codewise.
It always tries to assign players to the given subrole until roleAmount of players received the role.
This is now not the case anymore and we need to check if that is assumed to happen here and if other functionality relies on that to happen etc.

@EntranceJew EntranceJew force-pushed the feature/role-preference-options branch from f5d7a83 to a9ac53f Compare December 7, 2023 21:51
@Histalek Histalek added type/enhancement Enhancement or simple change to existing functionality accepted labels Dec 8, 2023
@EntranceJew EntranceJew force-pushed the feature/role-preference-options branch 5 times, most recently from 5c71b7b to aa6e29a Compare December 15, 2023 00:02
@EntranceJew EntranceJew force-pushed the feature/role-preference-options branch from aa6e29a to c0a4b86 Compare December 18, 2023 10:32
@EntranceJew EntranceJew force-pushed the feature/role-preference-options branch from c0a4b86 to 5e549e3 Compare December 18, 2023 11:17
local minKarmaCVar = GetConVar("ttt_" .. roles.GetByIndex(subrole).name .. "_karma_min")
local min_karmas = minKarmaCVar and minKarmaCVar:GetInt() or 0

while curRoles < roleAmount and #plys > 0 do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(After requested Review)
Isnt this still having the same problem here?
Exchanging the while loop with a for loop seems like different behaviour?

@@ -16,6 +16,7 @@ roleselection.finalRoles = {}
roleselection.selectableRoles = nil
roleselection.baseroleLayers = {}
roleselection.subroleLayers = {}
roleselection.trickleDownRate = 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still 0, should be at least 3.

Comment on lines -576 to +579
while plysAmount > 0 and availableRolesAmount > 0 do
local pick = math.random(plysAmount)
local ply = plys[pick]
for i = #newPlys, 1, -1 do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The for loop here also has the wrong behaviour. It only goes through every player once. But it could be that some players are not assigned.

CHANGELOG.md Outdated
@@ -108,6 +108,10 @@ All notable changes to TTT2 will be documented here. Inspired by [keep a changel
- Moved reset buttons onto the left (by @a7f3)
- Added ammo icons to the weapon switch HUD and player status HUD elements (by @EntranceJew)
- Changed the disguiser icon to be more fitting (by @TimGoll)
- Role selection RNG improvements (by @EntranceJew):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also in my opinion there are no RNG improvements, as you said in this PR, it generally only "made dead code not dead"

@Histalek Histalek added this to the v0.13.0b milestone Dec 20, 2023
NovaDiablox added a commit to NovaDiablox/TTT2 that referenced this pull request Dec 29, 2023
@EntranceJew EntranceJew deleted the feature/role-preference-options branch January 11, 2024 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement Enhancement or simple change to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants