Fractal Softworks Forum

Starsector => Mods => Topic started by: alaricdragon on March 10, 2022, 02:23:00 PM

Title: [0.95.1a] Crew Replacer
Post by: alaricdragon on March 10, 2022, 02:23:00 PM
Crew Replacer v0.2
an modders utility library thing.
have you ever wanted to create a mod, were you had 'mega salvage rigs' to perform salvage jobs instead of 'crew'? have you every wanted to stop using 'marine's' and start using 'heavy titan walkers' when raiding a world? have you ever wanted to do away with 'heavy machinery' when salvaging, and instead use your newly modded in 'salvage equipment'? maybe you wanted to create a task in one for your mods, were other modders could set things to be consumed in said task but thought 'why bother'? maybe you wanted to have an diverse ground army when attacking an world? but could never find a way to mod that into the game easily and quickly?
well now you can. with CREW REPLACER!

what is Crew Replacer?
Crew Replacer is a mod library built with one goal in mind: to make it easy and quick to mod in new items to be used in jobs. crew replacer lets multiple modders modify the same tasks, by adding a system that lets a modder add an 'crew'(really any type of commodity) to an 'job'. were said 'job's replace all the instances of crew i could find in code.

but what dose that mean? it means that modders now have a system to to change what is used/required when the one tries to 'salvage' or 'survey' or 'raid'. it also means that modders have a system to add new jobs into the game, then let other modders change what is used/required in said task.

still dont understand? feel free to ask me questions. and i will do my best to explain.

Compatibility:
Spoiler
not compatible with anything that changes:
Spoiler
plugins:
   SurveyPluginImpl
rules.csv:
   sal_showRatingAndCost
   sal_optionCheckAccidents
   sal_salvageOptionSelected
   sal_scavengeDebris
   sal_forceRecoveryOptSel
   sal_demolishOptionConfirmed

   marketHostileRaidSel
   marketHostileRaidNonMarket
   marketHostileRaidValuableSel
   marketHostileRaidDisruptSel
   marketHostileRaidConfirmSel
[close]
known incompatible mods and there patches (if they have one)
Spoiler
Nexerelin: patch: https://github.com/Alaricdragon/CrewReplacer-Nexerelin-combatability (https://github.com/Alaricdragon/CrewReplacer-Nexerelin-combatability).
  -Nexerelin's MarketCMD effects raiding. everything else works fine.
[close]
[close]
Download:
https://github.com/Alaricdragon/Crew_Replacer (https://github.com/Alaricdragon/Crew_Replacer)

how to use the mod (for modders.)
for full API, there is an readme in the mod file that i will keep updated.

available 'basic' Jobs in the this mod:
(note: an Task is not a Job. only an Job is an Jobs)
Job ID's are in quotes. example: Job:"this is an job ID"
Spoiler
Note: quests have not had there requirements modified because I don't want spoilers when I do them. feel free to make your own add-ons that change quest items.

Task:survey(done)
Spoiler
-currently implemented in the survey plugin. this is bad, because the survey plugin only effects the cost of the survey, not what i have. so instead of having extra crew
i reduce the cost of the survey. same effect, but kinda confusing and disorientating. also cant remove crews like i would like.
-admins say that the survey plugin is the only place this can work, as were the crew available is calculated is part of the 'core' of the game, and cannot be changed.
Job:"survey_crew"(done)
Job:"survey_supply"(done)
 -crew added to the supply_job are not consumed when they should be.
 -the only way i can make then consumed, is if i make it happen every time someone mouses over a planet. and thats a no go for me thanks
 -this dose not effect normal supply.
Job:"survey_heavy_machinery"(done)
[close]
Task:salvage(done/tested)
Spoiler
-DONE in theory. might have a bug or 50, but i simply don't know for sure. i think its working though
Job:"salvage_crew"(done)
Job:"salvage_heavyMachinery"(done)
[close]
Task:raiding(done/tested)
Spoiler
-DONE in theory.
Job:"raiding_marines"(done)
[close]
[close]
for adding crew (basic):
Spoiler
how to get crewReplacer_Job:
Spoiler
crewReplacer_Main.getJob(String job)
   returns: an crewReplacer_Job with the same name. or creates one if none exists.
   job: is an ID that you wish for this job to have. most be no other jobs with this ID.
[close]
how to add a 'crew' to a 'job':
Spoiler
crewReplacer_Job.addNewCrew(String crew,float crewPower,float crewPriority);
crew:
   is the ID of the commodity that you want to add to this job.
   there can only be one instance of an name in each job. make sure its something distentct.
crewPower:
  is the multiplier to the number of 'crew' already in the fleet. so if you have 10 of this item with a crew power of 2, the game will treat it as though there are 20 of this 'crew' in this fleet.
  default value is 1.
crewPriority:
  is the order in wish the 'crew' will be used in a job. smaller numbers go first in a job.
  default value is 10.

you can also run:
crewReplacer_Job.addCrew(crewReplacer_Crew crew);
however, you must set crew.name first.
this method is only recommended if you plan on creating your own crewReplacer_Crew class.

crewReplacer_Job.organizePriority();
you MUST run this code after doing adding/changing any crew in a crewReplacer_Job. things WILL GO BAD otherwize.

[close]
[close]
for adding/running jobs:
Spoiler
how to create a new job:
Spoiler
crewReplacer_Main.getJob(String job)
   returns: an crewReplacer_Job with the same name. or creates one if none exists.
   job: is an ID that you wish for this job to have. most be no other jobs with this ID.

crewReplacer_Main.addOrMergeJob(crewReplacer_Job job);
   you can also run this command. however, this is for people who want to create there own crewReplacer_Job class.
   make sure to set your job.name first.
[close]
when running job data there is 3 commands you need to know:
to get available crew power:
Spoiler
crewReplacer_Job.getAvailableCrewPower(CampaignFleetAPI fleet)
   returns: (float) the availableCrew * crewPower in this fleet
   fleet: is the fleet that you want to get crew from.
[close]
to display available crew for this job:
   
Spoiler
crewReplacer_Job.displayCrewAvailable(CampaignFleetAPI fleet,TextPanelAPI text)
   displays all the crew in the fleet to the inputted TextPanelAPI
   fleet: is the fleet that you want to get crew from.
   text: is the TextPanelAPI you want to display to
[close]
to apply and display crew losses for this job:
   
Spoiler
crewReplacer_Job.automaticlyGetDisplayAndApplyCrewLost(CampaignFleetAPI fleet,int crewPowerRequired, float crew_power_to_lose,TextPanelAPI text)
   removes crew from the fleet, and displays how mush crew was lost to the inputed TextPanelAPI
   fleet: is the fleet that you want to get crew from.
   crewPowerRequired: an float that should be equal to the required amount of crew to complete this job.
   crew_power_to_lose: the number of crew you want to remove from this fleet. should never be more then crewPowerRequired.
   text: is the TextPanelAPI you want to display to
[close]
[close]
Changelog
Spoiler
v0.2
 updates crewReplacer_Crew.DisplayedCrewNumbers
  -added the starsector function "getAOrAnFor()" to the default display (thanks anonymous user.)
  -made the code properly display commodity name, as apposed to its ID.
v0.1:
 release
[close]
Title: Re: [0.95.1a] Crew Replacer
Post by: Omnicast on March 10, 2022, 02:40:13 PM
Wait wait wait... so are you telling me we can Titanfall some poor hapless farming colony now? Drop pod deadly Elvish Blade Singers upon the annoying pain in the ass Hegemony? Flood a Luddic world with Rabid Furries? Unleash a tide of mechanical horrors that is the Necrons? Deploy an army of clones?! Horatio clones... or maybe Clone Troopers. I am right to assume this mod enables all this and MORE?!

Wait... couldn't the mods that introduce these units also have buildings that manufacture/grow/breed them?!

ZERGS! Xenomorphs! Sentinels! Power Armor! Terminators!

I can't wait for modders to go crazy with this library.
Title: Re: [0.95.1a] Crew Replacer
Post by: alaricdragon on March 10, 2022, 02:44:10 PM
Wait wait wait... so are you telling me we can Titanfall some poor hapless farming colony now? Drop pod deadly Elvish Blade Singers upon the annoying pain in the ass Hegemony? Flood a Luddic world with Rabid Furries? Unleash a tide of mechanical horrors that is the Necrons? Deploy an army of clones?! Horatio clones... or maybe Republic clones. I am right to assume this mod enables all this and MORE?!

Wait... couldn't the mods that introduce these units also have buildings that manufacture/grow/breed them?!

ZERGS! Xenomorphs! Sentinels! Power Armor! Terminators!

I can't wait for modders to go crazy with this library.
now you understand. the universe is at our fingertips and we (the modders) shall be the gods of this new world. I hope the modding community enjoy this as well =)
Title: Re: [0.95.1a] Crew Replacer
Post by: Omnicast on March 10, 2022, 02:51:06 PM
I forgot dragons... someone mod in dragons. It's Necessary!
Title: Re: [0.95.1a] Crew Replacer
Post by: Kakroom on March 10, 2022, 04:59:08 PM
Wait wait wait... so are you telling me we can Titanfall some poor hapless farming colony now? Drop pod deadly Elvish Blade Singers upon the annoying pain in the ass Hegemony? Flood a Luddic world with Rabid Furries? Unleash a tide of mechanical horrors that is the Necrons? Deploy an army of clones?! Horatio clones... or maybe Clone Troopers. I am right to assume this mod enables all this and MORE?!

Wait... couldn't the mods that introduce these units also have buildings that manufacture/grow/breed them?!

Dad i need it
Title: Re: [0.95.1a] Crew Replacer
Post by: briansd9 on March 10, 2022, 05:33:53 PM
Not compatible with Nexerelin? But almost everyone will have it...

Would it be possible to include the compatibility patch in the main mod, instead of requiring a separate download? Many mods do stuff like this:
Code
if (Global.getSettings().getModManager().isModEnabled("nexerelin")) {
  /* your code here */
}

Title: Re: [0.95.1a] Crew Replacer
Post by: AppleMarineXX on March 10, 2022, 06:56:32 PM
Does this mod allow the replacement objects to be "better" than the default objects?

For example, could I make a custom Super-Soldier commodity that acts as 10 marines at once?
Title: Re: [0.95.1a] Crew Replacer
Post by: alaricdragon on March 10, 2022, 08:07:20 PM
Does this mod allow the replacement objects to be "better" than the default objects?

For example, could I make a custom Super-Soldier commodity that acts as 10 marines at once?
yes. that is what 'crew power' dose. the default crew power is 1, so if you set your Super-Soldier to have 10 crew power when you make it, it will be worth 10 marines.
Title: Re: [0.95.1a] Crew Replacer
Post by: alaricdragon on March 10, 2022, 08:22:43 PM
Not compatible with Nexerelin? But almost everyone will have it...

Would it be possible to include the compatibility patch in the main mod, instead of requiring a separate download? Many mods do stuff like this:
Code
if (Global.getSettings().getModManager().isModEnabled("nexerelin")) {
  /* your code here */
}

I have no idea at all if this will work in this case, as my compatibility patch functions by extending Nexerelin's custom marketCMD that it has, well my mod works by extending the default marketCMD. and I am unsure how to merge the two classes, without having to update every time Nexerline dose. regardless, ill give it a try sometime. but probably not right now.
Title: Re: [0.95.1a] Crew Replacer
Post by: Liral on March 11, 2022, 01:05:59 PM
Does Crew Replacer extend to ships?  For example, could the Salvage Rig replace (or be required alongside) Heavy Equipment when salvaging derelict stuff, and can this mod add new requirements to actions that previously did not require them; e.g., requiring Heavy Equipment or Salvage Rigs to recover derelict ships?
Title: Re: [0.95.1a] Crew Replacer
Post by: alaricdragon on March 11, 2022, 07:43:18 PM
Does Crew Replacer extend to ships?  For example, could the Salvage Rig replace (or be required alongside) Heavy Equipment when salvaging derelict stuff, and can this mod add new requirements to actions that previously did not require them; e.g., requiring Heavy Equipment or Salvage Rigs to recover derelict ships?
yes to your first question. you can make an class that extends crewReplacer_Crew and overwrite the removeCrew, getCrewInFleet, and DisplayedCrewNumbers function. then add that to a crewReplacer_Job. you can then put your custom code into said functions, to make it so a ship can be used. or do anything truely. 'extends' and 'overwrite' is kinda like magic. (just started to learn about them a week ago sorry for nerding out about them)

regarding your second question, no. crew replacer cannot add new requirements. it was never built with such an idea in mind.
it is built with the idea that someone would want to replace its scripts in mind though. so if you are feeling crazy you can always try to make your own mod that changes salvage to have new requirements.
Title: Re: [0.95.1a] Crew Replacer
Post by: SonnaBanana on March 11, 2022, 09:40:30 PM
You are a genius, I salute you.
Title: Re: [0.95.1a] Crew Replacer
Post by: alaricdragon on March 11, 2022, 10:04:53 PM
You are a genius, I salute you.
*Salutes you back* just doing my duty for the modding community
(Thanks for the complement though. Complements on my things make me happy :))
Title: Re: [0.95.1a] Crew Replacer
Post by: Thaago on March 12, 2022, 03:46:50 PM
Huh, cool extension of capabilities! Nice idea to make this a library for the community.
Title: Re: [0.95.1a] Crew Replacer
Post by: Kat Tsun on March 19, 2022, 04:44:15 AM
based

finally i have a use for this (https://www.dropbox.com/s/60j6o31stg3oixs/CELE_crewcl.png?raw=1)
Title: Re: [0.95.1a] Crew Replacer
Post by: XeroNecross on March 19, 2022, 10:25:19 AM
I can't wait to learn to mod like ya'll can. I am still learning basics before I get into Java or Python... but one of these days. Skyrim had peaked my interest in modding, but StarSector has actually made me go out of my way to start learning this stuff and the more you guys make the more excited I get to learn! I'm literally only learning coding because of this game and the mods ya'll make -_-
Title: Re: [0.95.1a] Crew Replacer
Post by: alaricdragon on March 22, 2022, 02:53:09 PM
based

finally i have a use for this (https://www.dropbox.com/s/60j6o31stg3oixs/CELE_crewcl.png?raw=1)

cant wait to see what 'this' is used for =)
Title: Re: [0.95.1a] Crew Replacer
Post by: alaricdragon on March 22, 2022, 02:56:02 PM
I can't wait to learn to mod like ya'll can. I am still learning basics before I get into Java or Python... but one of these days. Skyrim had peaked my interest in modding, but StarSector has actually made me go out of my way to start learning this stuff and the more you guys make the more excited I get to learn! I'm literally only learning coding because of this game and the mods ya'll make -_-

Well im glad your enjoying the mods the community makes and that it inspired you, and i do wish you luck on your future coding/moding projects =)
Title: Re: [0.95.1a] Crew Replacer
Post by: alaricdragon on March 22, 2022, 02:56:30 PM
Huh, cool extension of capabilities! Nice idea to make this a library for the community.

thanks =)
Title: Re: [0.95.1a] Crew Replacer
Post by: Sunnyko on April 02, 2022, 06:29:57 PM
Is it possible to make like a generic crew replacement, that can.... say crew ships without being "crew" for if you wanted to give a faction its own unique crew?

If not can this be a possible option?
Title: Re: [0.95.1a] Crew Replacer
Post by: alaricdragon on April 02, 2022, 10:08:35 PM
Is it possible to make like a generic crew replacement, that can.... say crew ships without being "crew" for if you wanted to give a faction its own unique crew?

If not can this be a possible option?

unfortunately that's not possible right now, as i have not found were in the code the 'crew for ships' is calculated. same for things acting as ship supply.
if you, or anyone else knows were this code is located so I can get at it with crew replacer, I will add this future immediately, as I also want to be able to do this as well
Title: Re: [0.95.1a] Crew Replacer
Post by: Sunnyko on April 03, 2022, 03:29:24 AM
Is it possible to make like a generic crew replacement, that can.... say crew ships without being "crew" for if you wanted to give a faction its own unique crew?

If not can this be a possible option?

unfortunately that's not possible right now, as i have not found were in the code the 'crew for ships' is calculated. same for things acting as ship supply.
if you, or anyone else knows were this code is located so I can get at it with crew replacer, I will add this future immediately, as I also want to be able to do this as well

Sadly I do not.... but also as a note, you cant launch invasions in Nex with the marine replacments, even with the Nex patch... don't know if the same applies to vanilla, or even if vanilla has invasions if I am being honest, its been literal years since I have played without Nex.
Title: Re: [0.95.1a] Crew Replacer
Post by: alaricdragon on April 04, 2022, 04:02:04 PM
Sadly I do not.... but also as a note, you cant launch invasions in Nex with the marine replacments, even with the Nex patch... don't know if the same applies to vanilla, or even if vanilla has invasions if I am being honest, its been literal years since I have played without Nex.

I probably should have said somewhere, that the nex patch was only for raiding (nex overwrites the marketCMD, and that's something crew replacer has to overwrite to work with that job). I have yet to add all the other crazy jobs that nex adds into the game. mostly because I'm kind of sorta scared to try to do so. I also cant right now, but I should probably at least get the invasion job into the nex patch sometime. no idea when that will be though. life can be mean sometimes.

the base game dose not have invasions. that's something nex added itself.
Title: Re: [0.95.1a] Crew Replacer
Post by: Sunnyko on April 04, 2022, 05:14:33 PM
Sadly I do not.... but also as a note, you cant launch invasions in Nex with the marine replacments, even with the Nex patch... don't know if the same applies to vanilla, or even if vanilla has invasions if I am being honest, its been literal years since I have played without Nex.

I probably should have said somewhere, that the nex patch was only for raiding (nex overwrites the marketCMD, and that's something crew replacer has to overwrite to work with that job). I have yet to add all the other crazy jobs that nex adds into the game. mostly because I'm kind of sorta scared to try to do so. I also cant right now, but I should probably at least get the invasion job into the nex patch sometime. no idea when that will be though. life can be mean sometimes.

the base game dose not have invasions. that's something nex added itself.

Thats totaly understandable, and no rush at all, take care of yourself first after all.

Invasions are TBH probaly the only real big thing that would be needed for nex with any priority, like I know there are other uses for marines in it.... but like invasions are the one where most of them are spent you know?
Title: Re: [0.95.1a] Crew Replacer
Post by: alaricdragon on April 04, 2022, 05:49:19 PM
Sadly I do not.... but also as a note, you cant launch invasions in Nex with the marine replacments, even with the Nex patch... don't know if the same applies to vanilla, or even if vanilla has invasions if I am being honest, its been literal years since I have played without Nex.

I probably should have said somewhere, that the nex patch was only for raiding (nex overwrites the marketCMD, and that's something crew replacer has to overwrite to work with that job). I have yet to add all the other crazy jobs that nex adds into the game. mostly because I'm kind of sorta scared to try to do so. I also cant right now, but I should probably at least get the invasion job into the nex patch sometime. no idea when that will be though. life can be mean sometimes.

the base game dose not have invasions. that's something nex added itself.

Thats totaly understandable, and no rush at all, take care of yourself first after all.

Invasions are TBH probaly the only real big thing that would be needed for nex with any priority, like I know there are other uses for marines in it.... but like invasions are the one where most of them are spent you know?
it should be noted that most jobs in nex have nothing to do with crew. of course a 'job' as defined by crewReplacer is any time someone uses an item for something. so invasion is two jobs, marines and heavy armaments. the other things i think nex has is an 'outpost' build system, that would have 3 'jobs' in it i think, an 'boost stability' thing, that i think is 3 jobs, and probably more that I'm missing.
uh what im trying to say is that crew replacer is more like item replacer. it replaces more then crew, as crew are functionally the same as supplies or food as far as crew replacer is concerned. just a slightly rambling correction of assumptions.

i do agree that invasions is the top priority on that patch. its by far the most game changing thing crew replacer would edit in nex
Title: Re: [0.95.1a] Crew Replacer
Post by: Kobold on May 04, 2022, 07:12:54 PM
I forgot dragons... someone mod in dragons. It's Necessary!
yea, the dragons from rick and morty, cause once their done soul bonding, we can go and massacre them all because of how inept they would be