multiple destID station dockscreens in deliveryMissions query

Freeform discussion about anything related to modding Transcendence.
Post Reply
relanat
Militia Captain
Militia Captain
Posts: 941
Joined: Tue Nov 05, 2013 9:56 am

The next version of the Loyal Fleet Settlements will include a 'deliveryMission' mission running from the "Barracks" action.

It all works very well thanks to the help of community members.
The player accepts the mission to go to a station, accept supplies from that station and deliver them to the owner station (Fleet settlement).

There is, however, no check against available cargo space in the playership hold. This could lead to the playership being overfilled.

I currently have the 'destID' station showing a different dockscreen if the player cannot fit all of the supplies. This dockscreen tells the player "you don't have enough room, come back later". Unfortunately pressing the "Continue" action in this screen does nothing, the same screen still shows. Another second press of "Continue" will undock the playership.

Ideally the "Continue" action would show the station's normal main dockscreen. This is what happens when the player does have enough room and collects the supplies. This would allow the player the option to sell some cargo to that station to make more room.
If the player did sell some items to the station it would require an undock and redock to get the supplies but this is acceptable IMO.

Is there a way to show another dockscreen in the destID station and then access the standard station's dockscreens using <OnDeliveryMissionCompleted>?

A search of other missions shows the <OnPaneInit> event in 'paneInitMissions. There is also the <OnGetNextScreen> event. Possibly one of these could be used instead?

Relevant code:

Code: Select all

<OnDeliveryMissionCompleted>
		;This code runs when the mission has been accepted and the playership
		;	docks with the 'destID' station.
		;If the player cannot fit all the supplies we tell them - show
		;	'descFitNone' - to have more cargo space available.
		;Once they have enough room, we add the supplies to the playership.
		;We set 'msnData 'destID' to Nil to stop a special dockscreen from
		;	showing again.
		;And we change 'msnData 'status' to 'gotSupplies' to reset the player
		;	target and allow us to check for mission completion when the
		;	playership docks with the owner station.
		;The screen description 'descGotSupplies' shows on docking with the
		;	destination station, then the standard station dockscreen.
	(block (
		(fitCount (objGetFitCount gPlayerShip (msnGetData gSource 'supplies)))
		)
		(switch
			(eq (msnGetData gSource 'status) 'needSupplies)
				(switch
					(geq fitCount 4)
						(block Nil
							(objAddItem gPlayerShip (msnGetData gSource 'supplies))
							(msnSetData gSource 'destID Nil)
							(msnSetData gSource 'status 'gotSupplies)
							(msnSetPlayerTarget gSource)
							(msnTranslate gSource 'descGotSupplies)
						)

					{
					desc: (msnTranslate gSource 'descFitNone)
					forceUndock: Nil
					}
				)
		)
	)
</OnDeliveryMissionCompleted>
Mission UNID in the attached xml file. Entire mod in the zip.
Attachments
FleetSettlementsUpdate.zip
(16.25 KiB) Downloaded 251 times
FleetSettlementMission01.xml
(21.77 KiB) Downloaded 242 times
Stupid code. Do what I want, not what I typed in!
giantcabbage
Militia Lieutenant
Militia Lieutenant
Posts: 104
Joined: Thu Apr 07, 2011 9:05 pm

deliveryMission missions work using the <GetGlobalDockScreen> event - see here - which will attempt to show the dockscreen when the player is docked at a station matching destID AND the mission is active. This means that the OnDeliveryMissionCompleted event must do one of the following:
  • complete the mission
  • clear (or change) the destID
  • return forceUndock
If you don't do one of these, then the GetGlobalDockScreen event will just show the same screen again after you select Continune.

To get your "not enough room - come back later" screen to work you could try one of the following:
  1. In <OnDeliveryMissionCompleted> clear destID so the screen only shows once.
    In another event (e.g. OnUpdate) you can reset destID so the screen will be shown next time the player docks (you'll need to be careful to add appropriate checks that this reset does not occur while the player is docked)
  2. Change it so deliveryMission is only used for the first time the player visits, and add an extra action e.g. "Transfer Cargo" using paneInitMission for when the player returns. You can have a mission with both deliveryMission and paneInitMission attributes. In this case you should have your <OnDeliveryMissionCompleted> event clear destID and set paneID instead
relanat
Militia Captain
Militia Captain
Posts: 941
Joined: Tue Nov 05, 2013 9:56 am

Thanks. Excellent post.

An explanation of what is happening and a couple of ways to get the desired result.

You rock! :D
Stupid code. Do what I want, not what I typed in!
relanat
Militia Captain
Militia Captain
Posts: 941
Joined: Tue Nov 05, 2013 9:56 am

Got it working! Yippee. Thanks everyone. That finishes the mod except for a few minor changes.

I couldn't make the 'paneInit' code work successfully so used the 'deliveryMission' event.

The 'destID' value is set to Nil if the player can't fit all the supplies on docking. A recurring event, "CheckScreen" from the Commander's Log mod, is fired which checks for 'scrGetScreen' being Nil. This happens when the player undocks and the 'destID' value is then reset to allow the special screen to show again.

A couple of the mission failure modes show a small delay in resetting or clearing the target. This is (probably) because they are detected in 'OnUpdate' and there is a delay between that event's firings.

One query. If the mission is declined at one station it isn't offered at any of the others but will be reoffered at the first station. EDIT: This happens in 1.8 but in 1.9a1 the mission is offered at any station. If the <CanCreate> event is used to determine if the mission can run will this allow any station to reoffer the mission? 2nd EDIT: OK. 'destroyOnDecline' doesn't seem to work in 1.8.3. Works fine in 1.9a1. Not sure what is happening. Changed the mod so the <OnDeclined> event will destroy the mission instead. Although it doesn't destroy the missions until the player gates, this works because we only have one Fleet settlement per system. So at the next settlement there isn't an existing mission and the mission is offered again. At least I think that is how it works. END EDITS.

Other than that the target setting code is a wall of text but that is deliberate so an explanation can be added for each target reset. And I think there are more comments than code too!

Whole mod attached. Anyone can feel free to pick holes in it or suggest other ways of doing things. I really haven't got a clue why some of it is working!
The only thing left is to do is vary the reward. If this is kept smaller than the supplies then there is no need to check cargo hold space at the end of the mission.

Thanks again, everyone. This wouldn't have happened without your help.

Code:

Code: Select all

<OnDeliveryMissionCompleted>
	(switch
			;Supplies fit in the cargo hold.
		(geq (objGetFitCount gPlayerShip (msnGetData gSource 'supplies)) 4)
			(block Nil
				(objAddItem gPlayerShip (msnGetData gSource 'supplies))
				(msnSetData gSource 'destID Nil)
				(msnSetData gSource 'status 'gotSupplies)
				(msnSetPlayerTarget gSource)
				(msnTranslate gSource 'descGotSupplies)
			)

			;Or clear 'destID' and reset it on undocking in the next event.
		(block Nil
			(msnSetData gSource 'destID Nil)
			(msnSetData gSource 'resetDestID True)
			(msnAddRecurringTimerEvent gSource 1 "CheckScreen")
			(msnTranslate gSource 'descFitNone)
		)
	)
</OnDeliveryMissionCompleted>

<CheckScreen>
		;If we are no longer in a dockscreen and we have just come from the dest
		;	station we cancel the recurring event, reset 'msnData 'destID' so we
		;	can get the supplies when we have more room and set 'msnData
		;	'resetDestID' to Nil.
	(if (and (or (isError (scrGetScreen gScreen)) ;TY, NMS.
				(eq (scrGetScreen gScreen) Nil)
			)
			(msnGetData gSource 'resetDestID)
		)
		(block Nil
			(msnCancelTimerEvent gSource "CheckScreen")
			(msnSetData gSource 'destID (msnGetData gSource 'savedDestID))
			(msnSetData gSource 'resetDestID Nil)
		)
	)
</CheckScreen>
Attachments
FleetSettlementsUpdate.zip
(14.39 KiB) Downloaded 223 times
Stupid code. Do what I want, not what I typed in!
Post Reply