[Starsector Mods][0.95.1a] Crew Replacer

  • Post category:Mods
  • Post comments:0 Comments

Crew Replacer v0.4
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: click to expand
Spoiler
not compatible with anything that changes:

Spoiler: click to expand
Spoiler
plugins:
   SurveyPluginImpl
rules.csv:
   sal_showRatingAndCost
   sal_optionCheckAccidents
   sal_salvageOptionSelected
   sal_scavengeDebris
   sal_forceRecoveryOptSel
   sal_demolishOptionConfirmed

   marketHostileRaidSel
   marketHostileRaidNonMarket
   marketHostileRaidValuableSel
   marketHostileRaidDisruptSel
   marketHostileRaidConfirmSel

known incompatible mods and there patches (if they have one)

Spoiler: click to expand
Spoiler
(no longer required as of Nexerelin v0.10.5b or higher)
Nexerelin: patch: https://github.com/Alaricdragon/CrewReplacer-Nexerelin-combatability.
  -Nexerelin’s MarketCMD effects raiding. everything else works fine.

Download:
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: click to expand
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: click to expand
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)

Task:salvage(done/tested)

Spoiler: click to expand
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)

Task:raiding(done/tested)

Spoiler: click to expand
Spoiler
-DONE in theory.
Job:”raiding_marines”(done)

task: steal a starship mission (done/tested)

Spoiler: click to expand
Spoiler
functional
job:”Mission_hijack_marines”(done)

task: repair Coronal HyperShunt (functional/display not yet working)

Spoiler: click to expand
Spoiler
Almost done, it works, but the display is not respecting me
job:”CoronalHyperShunt_repair_Metals”(done)
job:”CoronalHyperShunt_repair_RareMetals”(done)
job:”CoronalHyperShunt_repair_Crew”(done)

for adding crew (basic):

Spoiler: click to expand
Spoiler
how to get crewReplacer_Job:

Spoiler: click to expand
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.

how to add a 'crew' to a 'job':

Spoiler: click to expand
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.

for adding/running jobs:

Spoiler: click to expand
Spoiler
how to create a new job:

Spoiler: click to expand
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.

when running job data there is 3 commands you need to know:
to get available crew power:

Spoiler: click to expand
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.

to display available crew for this job:
   

Spoiler: click to expand
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

to apply and display crew losses for this job:
   

Spoiler: click to expand
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

Changelog

Spoiler: click to expand
Spoiler
V0.4
    -new jobs:
        task: steal a starship mission
            job name:                               replaces
            Mission_hijack_marines:                 marines
        task: repair Coronal HyperShunt
            job name:                               replaces
            CoronalHyperShunt_repair_Metals:        metals
            CoronalHyperShunt_repair_RareMetals:    rare_metals
            CoronalHyperShunt_repair_Crew:          crew
    -issues:
        steal a starship mission has no feedback on what crews can do a mission. will be fixed later
        repair Coronal HyperShunt’s fancy looking display that shows what is available/required dose not respect crew replacer yet. will be fixed in a week or so
V0.3.4
    -fixes:
        fixed supplyDemandChange crashing the game because of bad code when supply change was ran.
         -this is no longer functional. my update broke everything about this. expect this to be moved into an diffrent project when it is fixed.
v0.3.3
made crewReplace_Job.organizePrioirty(); public (thanks for the bug reports)
made marines in the job “raiding_marines” correctly have the right crew priority.
V0.3.2
(thanks Histidine, the person who added this change) improved display of crew lost with little pictures of items and colored numbers. it looks like the rest of the game now =)
v0.3.1
fixed an indexing bug that caused issues that i missed
v0.3
 updated crewReplacer_Job
  -fixed an bug were crewReplacer_Job could not select crew randomly when they were the same priority.
  -optimized some random things.
  -made it so when displaying crew, it displays an integer, and not an float.
 crewReplacer_Crew
  -i forgot to keep track of what i did, but i think i added an function or three to this. or maybe not. please don’t judge me.
 added an new thing called supply demand class
  -this is nothing specials, that’s to say, you could do this on your own without crew replacer, but it fits here well, and its not big enough for its own project.
  -supply demand class is an collection of functions and data that makes it a little easier to edit an industry’s supply and demand without having to override said industry. it might be moved to its own project someday, but for now its going to sit here, as something useful, but not really needed that mush.
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

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.


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 =)


I forgot dragons... someone mod in dragons. It's Necessary!

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


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 */
}


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?


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.


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.


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?

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.


You are a genius, I salute you.

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 :))


Huh, cool extension of capabilities! Nice idea to make this a library for the community.

based

finally i have a use for this

Leave a Reply