Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: Editing the amount of days for a mission  (Read 4943 times)

stross

  • Ensign
  • *
  • Posts: 10
    • View Profile
Editing the amount of days for a mission
« on: March 06, 2016, 02:12:36 PM »

Im trying to find the file in the core folder to increase the amount of days that I have to fulfill for a mission. Like those freight missions that only give 10 days to complete.
Logged

stross

  • Ensign
  • *
  • Posts: 10
    • View Profile
Re: Editing the amount of days for a mission
« Reply #1 on: March 07, 2016, 04:03:37 PM »

bump
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4688
    • View Profile
    • GitHub profile
Re: Editing the amount of days for a mission
« Reply #2 on: March 08, 2016, 03:53:59 AM »

Best method I can think of:
  • Make a copy of com.fs.starfarer.api.impl.campaign.missions.MarketProcurementMissionCreator (look in starsector-core/starfarer_api.zip)
  • Alter the duration settings (default at lines 114-117)
  • At start of the game (onNewGame() in mod plugin), remove the vanilla MarketProcurementMissionCreator (Global.getSector().removeScriptsOfClass(MarketProcurementMissionCreator.class)) and add the custom one (Global.getSector().addScript(new MyMarketProcurementMissionCreator()))

    (No, I'm not explaining the nuts and bolts of implementing beyond what's there. I'm too tired and you can an explanation of how to make mod elsewhere).
Logged

stross

  • Ensign
  • *
  • Posts: 10
    • View Profile
Re: Editing the amount of days for a mission
« Reply #3 on: March 09, 2016, 04:24:00 PM »

I cant seem to figure out which line of math causes missions to only be 10 days long. Any suggestions?
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4688
    • View Profile
    • GitHub profile
Re: Editing the amount of days for a mission
« Reply #4 on: March 10, 2016, 03:40:40 AM »

Code: java
		WeightedRandomPicker<Float> durationPicker = new WeightedRandomPicker<Float>();
durationPicker.add(10f); // try this one
durationPicker.add(20f);
durationPicker.add(30f);
durationPicker.add(60f);
Logged

stross

  • Ensign
  • *
  • Posts: 10
    • View Profile
Re: Editing the amount of days for a mission
« Reply #5 on: March 10, 2016, 02:47:41 PM »



Yeah I edited those lines to 60days each but I still get these short mission bonuses.
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4688
    • View Profile
    • GitHub profile
Re: Editing the amount of days for a mission
« Reply #6 on: March 11, 2016, 07:22:41 AM »

Bonus duration is half base duration (with minimum of 10 days). Lines 175-185:
Code: java
		float bonusDuration = 0f;
float bonusAmount = 0f;
if (withBonus) {
// you could do things with bonusDuration here
bonusDuration = duration * 0.5f;
if (bonusDuration < 10f) bonusDuration = 10f;

bonusAmount = (int) (price * (0.5f + 1f * (float) Math.random()));
bonusAmount *= Math.max(maxDuration - bonusDuration, 0) / maxDuration;
bonusAmount = (int) (bonusAmount / 1000) * 1000;
if (bonusAmount < 1000) bonusAmount = 1000;
}

If that screenshot has base duration forced to 60 days but missions are still sometimes offering less time, I can't say I know why unfortunately.
Logged

stross

  • Ensign
  • *
  • Posts: 10
    • View Profile
Re: Editing the amount of days for a mission
« Reply #7 on: March 12, 2016, 07:49:01 AM »

yeah editing the file in the zip still hasn't yielded any results. Should I try the jar I only edit the files with Notepad++
« Last Edit: March 12, 2016, 10:36:40 AM by stross »
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4688
    • View Profile
    • GitHub profile
Re: Editing the amount of days for a mission
« Reply #8 on: March 12, 2016, 07:11:27 PM »

Yeah, the .zip just contains code samples.

Recompiling starfarer_api.jar with the modified file might work, though I'd personally do a proper separate mod.
(It should only need the modified script in MyMod/data/scripts[/someSubdirectory], a mod plugin in the same place, and a mod_info.json in in the mod's base folder; look at other mods for an example of the structure)
Logged

stross

  • Ensign
  • *
  • Posts: 10
    • View Profile
Re: Editing the amount of days for a mission
« Reply #9 on: March 13, 2016, 10:12:05 AM »

So should I compile the Java then drop the Class file into the .Jar? I never figured out how to get Janino to work
Logged

stross

  • Ensign
  • *
  • Posts: 10
    • View Profile
Re: Editing the amount of days for a mission
« Reply #10 on: March 19, 2016, 12:33:52 PM »

bump
Logged