-
-
Notifications
You must be signed in to change notification settings - Fork 382
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
CrewContracts - onUpdateBB #5596
base: master
Are you sure you want to change the base?
Conversation
I'm not suggesting any changes to the PR (haven't looked at the code, yet), but if you want to see how number of available ships in the market place was done, I wrote a post on that in #3243, assuming you're facing something similar here, with number of crew contracts, and how these are updated / churn |
Those plots are mesmerizing... |
@Gliese852 Thanks for the review! I'm currently looking into the algorithm @impaktor linked to above. May need to rewrite this. I like this one though. |
Number of applicants over about two and a half months game time. There is no affinity to any mean number but just a free running capitalistic hell. System Administration Resting has max applicants of 11 and Cydonia 39. In these scenarios I have modified the chance of reseeding after hitting zero from one in ten to one in a hundred. That's maybe a bit too long of a wait but I think it should be pretty high. Sometimes things just go bad. :) |
@impaktor OK, trying your way. I haven't tweaked the values to fit the human market yet. |
Graph redone for 2.5 months of human galactic migration. This is with the same variables as for the ship market. Please note that the population base is different between master and this PR. Crew Ad used Game.system.population and the one from the ship market uses station.path:GetSystemBody().parent.population. There is more drama in the earlier code. |
05dd512
to
29a9830
Compare
Rebased. When you have the 'Crew for hire" add open, the add isn't refreshed when the available crew changes. |
-- CrewContracts.lua local CrewContracts = {} -- We'll store the applicant data in a local table: -- Configuration -- Called once at game start or module init function CrewContracts.SeedApplicants() function CrewContracts.GenerateApplicant() -- This function runs periodically (e.g., every 60 in-game seconds). -- 1) Possibly remove or add an applicant based on some conditions: if #applicantPool > 0 then
else -- Additional logic to handle population-based speeds, if desired. end -- Called when the player initiates or ends a chat function CrewContracts.onChatEnd(candidateId, hired) -- Optional: a function to ensure we don't remove or re-roll an active candidate -- etc... return CrewContracts |
onUpdateBB() is a periodic update function (e.g., called from Pioneer’s UpdateBB() or your own tick/event hook) that manages the rotating pool of crew applicants: We’ll design the solution so that if a character is mid-interview (onChat with a player), the changes in the applicant list don’t invalidate that interview or accidentally remove the interviewee. The frequency at which new crew members appear or old ones leave can be tied to population or remain uniform if you want simpler balancing: If the applicant pool hits zero, we queue a re-seed timer so after X in-game hours or upon a certain event, a new batch of random applicants appears.
Notes on This Approach
Seeding Logic
CrewContracts.SeedApplicants() populates the list with a random number of new candidates between MIN_APPLICANTS and MAX_APPLICANTS. If the list ever drops to zero, we wait until the RESEED_DELAY passes and then repopulate.
Timing & Frequencies
You can tune the frequency of calling onUpdateBB and how quickly applicants come or go based on gameplay preference.
Non-Interference with Interviews
We mark any candidate in an active chat as busy. Your removal logic checks candidate.busy (or candidate.id ~= activeCandidateID) to avoid removing an active interviewee.
Population-Based Variation (Optional)
To mimic a big station vs. a tiny outpost, you could pass a “population factor” to onUpdateBB or store it in the station data. Then, when deciding whether to remove/add an applicant, you weigh the probability by that factor.
3. Addressing Your Specific Points
Character Deletion During Interview
|
29a9830
to
4765a07
Compare
Rebased on master |
This is the only issue I can find, otherwise the code adopted from @impaktor works well here. To test the issue:
It's not super clean and not all clear what's going on but maybe it's not a problem when the debug line is removed and we're not reminded of it. Essentially the character seem to be still applicable when the crew list goes to zero. The alternative would be to see the dialog window close on that event and this to me sounds possibly messy. Maybe this is ready for review? |
Introduce onUpdateBB to the CrewContracts module.
Some points:
Fixes #5510