Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.95.1a is out! (12/10/21); Blog post: The Pilgrim's Path (07/19/22)

Pages: [1] 2

Author Topic: [0.95.1a] Crew Replacer  (Read 20657 times)

alaricdragon

  • Ensign
  • *
  • Posts: 41
    • View Profile
    • Email
[0.95.1a] Crew Replacer
« 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.
  -Nexerelin's MarketCMD effects raiding. everything else works fine.
[close]
[close]
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
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]
« Last Edit: March 12, 2022, 12:14:42 PM by alaricdragon »
Logged

Omnicast

  • Ensign
  • *
  • Posts: 20
    • View Profile
Re: [0.95.1a] Crew Replacer
« Reply #1 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.
« Last Edit: March 10, 2022, 02:41:55 PM by Omnicast »
Logged

alaricdragon

  • Ensign
  • *
  • Posts: 41
    • View Profile
    • Email
Re: [0.95.1a] Crew Replacer
« Reply #2 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 =)
Logged

Omnicast

  • Ensign
  • *
  • Posts: 20
    • View Profile
Re: [0.95.1a] Crew Replacer
« Reply #3 on: March 10, 2022, 02:51:06 PM »

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

Kakroom

  • Commander
  • ***
  • Posts: 170
    • View Profile
Re: [0.95.1a] Crew Replacer
« Reply #4 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
Logged

briansd9

  • Ensign
  • *
  • Posts: 45
    • View Profile
Re: [0.95.1a] Crew Replacer
« Reply #5 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 */
}

Logged

AppleMarineXX

  • Lieutenant
  • **
  • Posts: 54
    • View Profile
Re: [0.95.1a] Crew Replacer
« Reply #6 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?

alaricdragon

  • Ensign
  • *
  • Posts: 41
    • View Profile
    • Email
Re: [0.95.1a] Crew Replacer
« Reply #7 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.
Logged

alaricdragon

  • Ensign
  • *
  • Posts: 41
    • View Profile
    • Email
Re: [0.95.1a] Crew Replacer
« Reply #8 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.
Logged

Liral

  • Commander
  • ***
  • Posts: 181
    • View Profile
Re: [0.95.1a] Crew Replacer
« Reply #9 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?
Logged

alaricdragon

  • Ensign
  • *
  • Posts: 41
    • View Profile
    • Email
Re: [0.95.1a] Crew Replacer
« Reply #10 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.
Logged

SonnaBanana

  • Admiral
  • *****
  • Posts: 761
    • View Profile
Re: [0.95.1a] Crew Replacer
« Reply #11 on: March 11, 2022, 09:40:30 PM »

You are a genius, I salute you.
Logged
I'm not going to check but you should feel bad :( - Alex

alaricdragon

  • Ensign
  • *
  • Posts: 41
    • View Profile
    • Email
Re: [0.95.1a] Crew Replacer
« Reply #12 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 :))
Logged

Thaago

  • Global Moderator
  • Admiral
  • *****
  • Posts: 6498
  • Harpoon Affectionado
    • View Profile
    • Email
Re: [0.95.1a] Crew Replacer
« Reply #13 on: March 12, 2022, 03:46:50 PM »

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

Kat Tsun

  • Ensign
  • *
  • Posts: 2
    • View Profile
Re: [0.95.1a] Crew Replacer
« Reply #14 on: March 19, 2022, 04:44:15 AM »

based

finally i have a use for this
Logged
Pages: [1] 2