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

Add more variety to traitor objectives #37395

Open
wants to merge 4 commits into
base: Bleeding-Edge
Choose a base branch
from

Conversation

BoraHive
Copy link
Contributor

Increases the number and variety of traitor objectives, rather than always assigning a single assassinate and steal objective. Death/exit objectives (stay alive, die a glorious death, etc.) untouched.
Fixes #37392.

What this does

Adds a new method for generating objectives for a traitor, trying between 2 and 5 with an attempt to limit duplicates to an extent.

Why it's good

For those who want inspiration or greentext it's a big improvement.

How it was tested

Locally.

Changelog

🆑

  • rscadd: Traitors generate more and varied objectives.

Increases the number and variety of traitor objectives, rather than always assigning a single assassinate and steal objective.
Death/exit objectives (stay alive, die a glorious death, etc.) untouched.
@Eneocho Eneocho added the Content Adds something. Neat! label Jan 27, 2025
for(i=0; i<=rand(2,5); i++)//generates 2 to 5 objectives, limiting duplicates
roll = rand(1,13)
if(roll in dupecheck)
i = i-1
Copy link
Contributor

@hacker-on-steroids hacker-on-steroids Jan 30, 2025

Choose a reason for hiding this comment

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

possible infinite loop
i would make a list [1,2,3,4,5,6,7,8,9,10,11,12,13] , shuffle it and pick the first 2-5 elements

you can find some list helper functions in this file

/proc/shuffle(var/list/L)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Where's the possibility for an infinite loop?
I don't see it.

Copy link
Contributor

@SonixApache SonixApache Jan 31, 2025

Choose a reason for hiding this comment

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

Since you're iterating backwards for some reason, there's a infinitesimally small chance that this code rolls the same number every time and thus gets stuck in an infinite loop. Non-issue, but it's there.
might be better to run the loop till the len of dupecheck is equal to your rolled jectiecount,
And also what he said or something similar; you're wasting CPU cycles on re-rolls. Bad code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Entropy deniers aside, there's no infinite loop.
It probably is super inefficient though, since I don't know shit about optimization. I'd guess it's slower on average to shuffle the entire list but there's a hard cap on how long it can take as opposed to my method where you could get really unlucky and roll a lot. Pure conjecture though.

Regardless, this change should cap the length it takes without a functional change in the result.

Copy link
Collaborator

@west3436 west3436 left a comment

Choose a reason for hiding this comment

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

Fix the possible infinite loop per @hacker-on-steroids please

@hacker-on-steroids
Copy link
Contributor

is there a reason you're doing these branch merges/updates west?
there aren't any conflicts so it should merge without problem even without em

@west3436
Copy link
Collaborator

is there a reason you're doing these branch merges/updates west? there aren't any conflicts so it should merge without problem even without em

Linters were broken; I fixed them in #37399 so open PRs with failing checks had to merge the latest branch to pick up the fixes

Prerolled objective indices via a shuffled list to increase efficiency.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content Adds something. Neat!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Traitors only ever get Steal objective and nothing else
5 participants