This describes the changes in the missionrefactor branch. The primary aim is to update legacy missions (Militia, Korolov, Fleet etc.) to use MissionType and Language elements in order to better support modding and future enhancements to the missions.
Also see pull requests: 30 32 33

Code

  • rpgMissionAssignment: added option for a delay between missions as used for Commonwealth mining and slums missions
  • RPGWingmen: Added a dsRPGWingmanEncounter dockscreen to handle initial encounter and accept/decline of wingmen.

CommonwealthMining

Addresses issues:
https://ministry.kronosaur.com/record.hexm?id=471
https://ministry.kronosaur.com/record.hexm?id=25596
https://ministry.kronosaur.com/record.hexm?id=54075
https://ministry.kronosaur.com/record.hexm?id=69464

  • scBorerCaptured and mneAllTargetsDestroyed are no longer used

CommonwealthAgricultural

Addresses issues:
https://ministry.kronosaur.com/record.hexm?id=55982

KorolovShipping

Addresses issues:
https://ministry.kronosaur.com/record.hexm?id=471
https://ministry.kronosaur.com/record.hexm?id=70263 (I think it will still glitch if the player completes both the escort and kronosaurus mission at the same time)
https://ministry.kronosaur.com/record.hexm?id=6185
https://ministry.kronosaur.com/record.hexm?id=5033 (player can escort new freighters from gate)

  • Moves traffic control code from StationType to korTrafficControl function and behavior evKorolovFreighterBehavior
  • Global data and language elements moved to unidKorolovShipping
  • CharonBuster shipclasses moved to KSMission03 (attack on stronghold)
  • Use RPGCharacter to track Kronosaurus state

CommonwealthMilitia

  • Global data and language elements moved to unidCommonwealthMilitia
  • Added mission limit and intervals

Commonwealth Fleet

Addresses issues:
https://ministry.kronosaur.com/record.hexm?id=67091
https://ministry.kronosaur.com/record.hexm?id=54410
Should fix https://ministry.kronosaur.com/record.hexm?id=53848

  • All CSC task force missions converted (not Point Juno or CSCTerra)
  • Fleet Delivery implemented using deliveryMission attribute. dsFleetDelivery dockscreen no longer used
  • Added RPGCharacter for Juan Carlos
giantcabbage 31 Mar 2017:

Ideas for future improvements

Intercept Ares patrol

  • In my testing the CSC usually destroyed the entire patrol. Consider adjusting ships / approach distance

Escort missions should have more variability in enemies

  • waiting at gate, follow through gate, enroute
  • different types of enemies
  • improved encounter tables

Rogue minelayer needs improvements

  • mine field is too small and freighter usually misses it
  • try ~linear mine field from one side of path to other
  • check that player is not in the area (so ship does not appear on screen), switch to alternate variant if player is waiting half way
  • see ministry tickets

More freighter variability

  • ship table / random list / typFind +commonwealth +freighter

Suicide freighter

  • Message from CSC is too easy to miss
  • Needs encounters enroute so experiences players don't know to start attacking it half way

Refugee Convoy

  • Change E100's to follow so they don't chase the Ares

msCSCInterceptAresAttack

  • Mixed attack demios + sandstorm should give more weight to demios for determining XP

Attack Station

  • remove the Ares station spawn (there should be enough missions especially if we let them work at multiple ranks)

General

  • Missions should be available at multiple ranks (similar to CC)
  • Add a low level strike mission (against outputs)
  • Add missions against other enemies (rogue fleet etc)
  • Add CSCHospital missions
johnbwatson 31 Mar 2017:

I like it. Many of these CSC suggestions were also made by me a while back, so naturally I approve of them.

I'd add that the interceptAresAttack mission is in need of a full rework or replacement. The lack of any threat to the CSC from many of the attacks isn't good for immersion, nor is turning off the CSC's defensive measures. I feel like there has to be a better way to run such a mission.

It could be made more interesting as the result of a previous mission. Having a chance of an attack force showing up partway into the Sandstorm swarm unknown hostile mission and recalling you to defend the CSC would make both missions much more exciting, and the presence of a huge group of Sandstorms makes more sense as a distraction.

nms 1 Apr 2017:

Great work so far! But I feel like it's bad practice to have code that does anything other than assemble a string inside a <Text> element. And ideally even that should be avoided by putting the code in an event and using subst and wildcards if necessary to assemble the string out of constant text elements. That way, the (currently hypothetical) translators don't need to understand any code; they can just put the wildcards in the right place for their language.

Deploying the Kronosaurus is way out of line. If there isn't a mission event that can run at the right time, that's a problem with the engine that should be corrected, but in the mean time it should be in an <OnPaneInit> or something.

giantcabbage 2 Apr 2017:

I agree the Kronosaurus deployment is a rather ugly hack. But I couldn’t see a clean way to do it without changing the original behaviour (plus those missions were copied from my two-year old Korolov mod and I didn’t want to make any changes which would require re-testing them). However, there are plenty of other places where I have broken my “conversion-only” rule and introduced various “enhancements”

  • Leave the code in the <Text> element

Generally a bad idea to have side-effects in <Text> elements, but this should be safe (it only triggers after the player has destroyed 3 frigates, only activates once, and should have been tested a fair bit)

  • Deploy the Kronosaurus as part of the mission reward

This would avoid having side-effects in the <Text> element, but make the code uglier as it would still need detect the special “reward” and display alternative text

  • Use OnGetNextScreen to display an additional screen

This would be a change to original behaviour, plus would break if the player was promoted at the same time as the Kronosaurus was deployed. But it would allow OnPaneInit to be used.

  • Don’t deploy the Kronosaurus during mission debrief

The Kronosaurus could be offered as a mission (without the decline option) once the player has destroyed three frigates. This would prevent the player taking escort missions while being pursued by the Kronosaurus (Hey player, the deadliest frigate in the Charon fleet is chasing you - why not escort this freighter so it can be destroyed in the crossfire).

Currently I prefer the last option, but it would need thinking through in terms of interaction with the promotion to legend, the backup deployment at 4 frigates destroyed, and Kronosaurus as an RPGCharacter (so it can be used in mods etc.). So in the short term deploying it in the reward may be the best option.

nms 2 Apr 2017:

OK, I've studied how missions work a bit more and you're right. The rpgPagePaneInit function and the way it's used in the <OnPaneInit> events of dsRPGMission still confuse me, but it seems they force the description to be set via msnTranslate, which means that if you want it to be variable, you have to put code in the corresponding <Text> element. Functionally, this is similar to calling an event, but it violates the segregation of of text and code that <Text> elements are intended to maintain. In this case, you could move (chrDeployKronosaurus) to the <OnReward> or <OnDebriefed> events, but you'd still have to check if the conditions were met in the SuccessDebrief text to display the correct description, so there's not much point.

The game fix would be for dsRPGMission to call events of the mission type to get the desc and data about other panes, and fall back on the text if they don't exist. But then again, there are 1239 <Text> elements with code in them in my Collection folder, according to my regex search for <Text [^/]+>s*( , so fixing this kind of issue may be a low priority.

nms 2 Apr 2017:

The Rescue Scientists mission has the wrong summary - copied from an escort freighter mission.

johnbwatson 2 Apr 2017:

The Kronosaurus spawns after you kill 3 frigates, regardless of whether you're involved with Korolov at all at the time. I've had it come after me in Charon. Offering it as a mission wouldn't work.

nms 3 Apr 2017:

Not quite. It spawns when you kill 4 frigates, or if you complete an escort mission after killing 3.

giantcabbage 3 Apr 2017:

The Rescue Scientists mission has the wrong summary - copied from an escort freighter mission.

Thanks - I've added a summary now!

giantcabbage 3 Apr 2017:

@johnbwatson it is possible to start missions without going through the offer accept/decline screens. In the current version I have kept the original behavior and start the mission in the escort mission success debrief screen (via ugly hack) at 3 frigates, or immediately after the player has destroyed 4 frigates.

Thinking about ways to improve the mission and make it better fit the new system it may be better to split Kronosaurus into two missions:

1) After destroying 3 frigates player is given mission at Korolov

  • Mission is given through the normal “Escort Freighter” action. It cannot be declined. It is not started in the debrief screen of a previous mission. It has high priority so player will not be offered normal escort missions
  • Once player has “accepted” mission, the Kronosaurus enters the system
  • Kronosaurus hunts player using a “reverse NAUhunt” i.e. wanders system, any pirate ship that sees player will summon Kronosaurus, if Kronosaurus can detect player it starts attacking
  • If player destroys Kronosaurus they get Volkov and legend rank
  • If player dies or leaves system for a long time (~15 minutes?) they will fail the mission

2) After destroying 4 frigates the Kronosaurus hunts more aggressively

  • Mission starts immediately (no dockscreen required)
  • Kronosaurus will follow player between systems (up level 4)
  • Korolov should not offer any missions while Kronosaurus is hunting
  • If the player kills Kronosaurus in a system with a Korolov station, has completed at least one Korolov mission, and has not failed (1), then they get Volkov and legend rank
george moromisato 4 Apr 2017:

@nms @giantcabbage: On the code inside <Text> issue, I agree with the ideal (no code) but also know that sometimes we can't avoid it. Globalization is still a long way away, so this is not a high priority. But I've got a few guidelines that I'm trying to follow:

  1. Avoid side-effects in <Text> code. For the case of the Kronosaurus, maybe there is a way to add a new event somewhere.
  2. I'd love to move to a system of replaceable parameters, with gData having the values. We'd do something like: <Text id="xxx">"Please pay %cost%."</Text>, where we replace %cost% with (@ gData 'cost). I can add this to the engine, but it will be a while before we can edit all the Text elements.
  3. For more complex if-then statements in <Text>, I think it is OK to have some code that refers to other (clean) Text elements. Something like:
  4. <Text id="xxx">
       (if something (scrTranslate gScreen 'Text1) (scrTranslate gScreen 'Text2))
    </Text>
    
giantcabbage 5 Apr 2017:

I've moved the side effect to <OnReward> event and set a flag so the <Text> code can select the appropriate text to display. The Success case was actually quite simple in the end. However, there is no equivalent for Failure as the <OnDebriefed> events are called after the debrief screens are displayed.

I'd love to move to a system of replaceable parameters, with gData having the values.

This would be really useful. But we'd probably need another mission event to create the gData structure for dsRPGMission etc. or otherwise extract the required data from the mission object.

nms 6 Apr 2017:

How about having the <OnPaneInit> events in dsRPGMission call events of the mission like <GetBriefingDesc>, <GetProgressDesc>, etc. that are expected to return data in the same format as the current <Text>s? If they don't exist, fall back on the current method, and if that doesn't exist, use a generic <Text> like "Someone offers you a mission."

That's a pretty minimal change that doesn't break any existing code, but allows people to move the code to generate these screens into events, which can then call msnTranslate to get strings.

There might be a less confusing way to organize the data used to create these screens, but I'm not really sure. It would help if the explanation of the current structure were clearer about which variables go where.

george moromisato 7 Apr 2017:

@giantcabbage: The latest pull request seems to be missing some definitions. I get an error about "msKronosaurus" not defined. That entity is not defined anywhere (but is used in CharonPirates.xml). KronosaurMissions01.xml is not included anywhere.

Did you forget to submit HumanSpaceVol01.xml?

giantcabbage 7 Apr 2017:

Did you forget to submit HumanSpaceVol01.xml?

Yes - new PR sent.

BTW, I gave the commonwealth (mining, agricultral) missions commonwealth UNIDs 0010xxxx following on from msDestroyThreatToSlums. Everything else has temporary UNIDs DDDEFxxx

george moromisato 24 Apr 2017:

I've incorporated in 1.8 Alpha 1 and I've assigned appropriate UNIDs. Thank you, I really appreciate your hard work!