-
Notifications
You must be signed in to change notification settings - Fork 541
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
base: Bleeding-Edge
Are you sure you want to change the base?
Add more variety to traitor objectives #37395
Conversation
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.
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 |
There was a problem hiding this comment.
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
vgstation13/code/__HELPERS/lists.dm
Line 333 in ceb170c
/proc/shuffle(var/list/L) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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
is there a reason you're doing these branch merges/updates west? |
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.
…ion13 into Tator-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.
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
🆑