# Copyright (c) 2017 by Michael Zahniser
# Copyright (c) 2018 by Zitchas
# Copyright (c) 2022 by williaji
#
# Endless Sky is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later version.
#
# Endless Sky is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <https://www.gnu.org/licenses/>.

mission "Remnant: Bounty"
	job
	repeat
	name "Crippled <npc model> Bounty"
	description "A crippled Korath ship is lurking in Remnant territory. Hunt it down, and then return to <planet> to receive your payment of <payment>."
	source
		government "Remnant"
	to offer
		has "Remnant: Defense 2: done"
		or
			not "remnant: ssil vida active"
			not "flagship planet: Ssil Vida"
		random < 60
	npc kill
		government "Korath"
		personality coward target uninterested marked waiting
		system
			distance 1 2
		fleet
			names "korath"
			cargo 3
			commodities "Food" "Clothing" "Metal" "Plastic" "Medical" "Heavy Metals"
			variant
				"Palavret (Crippled)"
		dialog "You have destroyed the Korath ship. You can now return to <planet> to collect your payment."
	on visit
		dialog phrase "generic bounty hunting on visit"
	on complete
		payment 300000
		dialog "A Remnant military leader thanks you for hunting down the <npc>, and gives you the agreed-upon payment of <payment>."



mission "Remnant: Bounty 2"
	job
	repeat
	name "Troublesome <npc model> Bounty"
	description "A Korath ship is proving troublesome in Remnant territory. Hunt it down, and then return to <planet> to receive your payment of <payment>."
	source
		government "Remnant"
	to offer
		has "Remnant: Salvage 4: offered"
		or
			not "remnant: ssil vida active"
			not "flagship planet: Ssil Vida"
		random < 50
	npc kill
		government "Korath"
		personality heroic vindictive target uninterested waiting marked
		system
			distance 1 2
		fleet
			names "korath"
			cargo 3
			commodities "Food" "Clothing" "Metal" "Plastic" "Medical" "Heavy Metals"
			variant
				"Palavret (Hyperdrive)"
		dialog "You have destroyed the Korath ship. You can now return to <planet> to collect your payment."
	on visit
		dialog phrase "generic bounty hunting on visit"
	on complete
		payment 400000
		dialog "A Remnant military leader thanks you for hunting down the Korath ship <npc>, and gives you the agreed-upon payment of <payment>."



mission "Remnant: Broken Jump Drive job"
	name "Broken Jump Drive Delivery"
	description "The researchers on <planet> need another broken jump drive to continue their project."
	job
	repeat 4
	to offer
		has "Remnant: Broken Jump Drive 5: done"
		or
			not "remnant: ssil vida active"
			not "flagship planet: Ssil Vida"
			
	source
		government "Remnant"
	destination
		government "Remnant"
		attributes outfitter
		not attributes "remnant station"
		not distance 0
	on visit
		dialog phrase "broken jump drive on visit"
	on complete
		outfit "Jump Drive (Broken)" -1
		"remnant: broken jump drive count" ++
		payment 300000
		"reputation: Remnant" ++
		"Remnant: Broken Jump Drive job: offered" --
		dialog "The research team quickly offloads the broken jump drive and pays you <payment> before hurrying back to their lab."



mission "Remnant: Expanded Horizons Astral job"
	job
	repeat
	name "Research Expedition to <waypoints>"
	description "Travel to <waypoints> with a Research Laboratory to collect data, then return to <destination>."
	source
		government "Remnant"
	waypoint
		not attributes "pleiades"
		not attributes "inaccessible"
	to offer
		has "Remnant: Expanded Horizons Astral 2: done"
		random < 50
	on offer
		require "Research Laboratory"
	on waypoint
		dialog "Your scientist unpacks the laboratory and takes the requested observations. A short while later, they have the data compiled on a set of data crystals and inform you that everything is ready for departure."
	on complete
		payment 500000
		"reputation: Remnant" ++
		dialog "When you land, a researcher quickly retrieves the data crystals with the information about the surveyed system and hands you the logistics allotment of <payment>."



mission "Remnant: Bounty 3"
	job
	repeat
	name "Damaged Rano'erek Bounty"
	description "A damaged Korath ship is lurking in Remnant territory. Hunt it down, and then return to <planet> to receive your payment of <payment>."
	source
		government "Remnant"
	to offer
		# 0.9.13 Compatibility patch
		or
			has "Remnant: Cognizance 4: done"
			has "Remnant: Cognizance 4: failed"
		not "Remnant: Cognizance 4: aborted"
		random < 40
	npc kill
		government "Korath"
		personality heroic vindictive target uninterested waiting marked
		system
			distance 1 2
		fleet
			names "korath"
			cargo 3
			commodities "Food" "Clothing" "Metal" "Plastic" "Medical" "Heavy Metals"
			variant
				"Rano'erek (Crippled)"
		dialog "You have destroyed the Korath ship. You can now return to <planet> to collect your payment."
	on visit
		dialog phrase "generic bounty hunting on visit"
	on complete
		payment 400000
		dialog "A Remnant military leader thanks you for hunting down the Korath ship <npc>, and gives you the agreed-upon payment of <payment>."



mission "Remnant: Bounty 4"
	job
	repeat
	name "Marauding Rano'erek Bounty"
	description "A Korath ship is marauding through Remnant territory. Hunt it down, and then return to <planet> to receive your payment of <payment>."
	source
		government "Remnant"
	to offer
		has "Remnant: Cognizance 14: done"
		random < 30
	npc kill
		government "Korath"
		personality heroic vindictive target uninterested waiting marked
		system
			distance 1 2
		fleet
			names "korath"
			cargo 3
			commodities "Food" "Clothing" "Metal" "Plastic" "Medical" "Heavy Metals"
			variant
				"Rano'erek (Crippled)"
		dialog "You have destroyed the Korath ship. You can now return to <planet> to collect your payment."
	on visit
		dialog phrase "generic bounty hunting on visit"
	on complete
		payment 500000
		dialog "A Remnant military leader thanks you for hunting down the Korath ship <npc>, and gives you the agreed-upon payment of <payment>."



mission "Remnant: Bounty 5"
	job
	repeat
	name "Destroy Ground Assault Bounty"
	description "A Korath ship is hunting for our outposts in the Ember Wastes. Track it down, eliminate it and any fighters it is carrying, and then return to <planet> to receive your payment of <payment>."
	source
		government "Remnant"
	to offer
		has "Remnant: Cognizance 29: done"
		or
			not "remnant: ssil vida active"
			not "flagship planet: Ssil Vida"
		random < 5
	npc kill
		government "Korath"
		personality heroic vindictive target marked staying
		system
			attributes "ember waste"
			not attributes "graveyard"
			not attributes "inaccessible"
		fleet
			names "korath"
			cargo 3
			commodities "Food" "Clothing" "Metal" "Plastic" "Medical" "Heavy Metals"
			variant
				"Rano'erek (Ground Assault)"
				"'olofez" 4
		dialog "You have destroyed the Korath ship and its fighters. You can now return to <planet> to collect your payment."
	on visit
		dialog "You've landed on <planet>, but the Korath ship and its fighters have not all been eliminated. Hunt them down and destroy them before returning."
	on complete
		payment 400000
		dialog "A Remnant military leader thanks you for hunting down the Korath ship <npc> and its fighters, and gives you the agreed-upon payment of <payment>."



mission "Remnant: Logistics Civil Engineering"
	name "Civil delivery to <planet>"
	description `Engineers on <planet> need <cargo> delivered. Logistics adjustment is <payment>.`
	cargo "remnant civil" 20 4 .1
	job
	repeat
	to offer
		not "remnant: ssil vida active"
		has "Remnant: Logistics 1: done"
		random < 51
	source
		government "Remnant"
		not planet "Ssil Vida"
	destination
		government "Remnant"
		not distance 0
		not planet "Ssil Vida"
		not planet "Esquiline"
	on visit
		dialog phrase "generic cargo on visit"
	on complete
		dialog `A project engineer inspects the <cargo> and signs off on your payment of <payment>.`
		payment
		payment 10000



mission "Remnant: Logistics Industrial Delivery"
	name "Industrial delivery to <planet>"
	description `Project teams on <planet> need <cargo> delivered. Logistics adjustment is <payment>.`
	cargo "remnant industrial" 20 4 .03
	job
	repeat
	to offer
		not "remnant: ssil vida active"
		has "Remnant: Logistics 1: done"
		has "Remnant: Logistics Civil Engineering: done" >= 9
		random < 76
	source
		government "Remnant"
	destination
		government "Remnant"
		not distance 0
		not planet "Ssil Vida"
		not planet "Esquiline"
	on visit
		dialog phrase "generic cargo on visit"
	on complete
		dialog `A project technician inspects the <cargo> and approves your payment of <payment>.`
		payment
		payment 15000



mission "Remnant: Logistics Outfitter Delivery"
	name "Component delivery to <planet>"
	description `Outfitter repair crews on <planet> need <cargo> parts delivered. Logistics adjustment is <payment>.`
	cargo "remnant outfitter repair" 20 3 .04
	job
	repeat
	to offer
		not "remnant: ssil vida active"
		has "Remnant: Logistics 1: done"
		has "license: Remnant"
		has "Remnant: Logistics Industrial Delivery: done" >= 9
		random < 30
	source
		government "Remnant"
	destination
		government "Remnant"
		not distance 0
		not planet "Ssil Vida"
		not planet "Esquiline"
	on visit
		dialog phrase "generic cargo on visit"
	on complete
		dialog `A repair technician inspects the <cargo> parts and authorizes your payment of <payment>.`
		payment
		payment 30000



mission "Remnant: Logistics Salvage Delivery"
	name "Salvage delivery to <planet>"
	description `Deliver <cargo> components from recent salvage operations to the outfitters on <planet> for research, refurbishment, or recycling. Logistics adjustment is <payment>.`
	cargo "remnant salvage" 5 4 .06
	job
	repeat
	to offer
		not "remnant: ssil vida active"
		has "Remnant: Logistics 1: done"
		has "license: Remnant Capital"
		has "Remnant: Logistics Outfitter Delivery: done" >= 9
		random < 11
	source
		government "Remnant"
	destination
		government "Remnant"
		not distance 0
		not planet "Ssil Vida"
		not planet "Esquiline"
	on visit
		dialog phrase "generic cargo on visit"
	on complete
		dialog `Two armed repair technicians inspects the <cargo> and authorize your payment of <payment>.`
		payment 25000 300



mission "Remnant: Rescue"
	job
	repeat
	name "Search and Rescue: Scout"
	description "The <npc> has gone missing during a scouting mission in the Ember Wastes. Find them and help them return to <destination>."
	source
		government "Remnant"
	to offer
		has "Remnant: Learn Sign Follow Up: offered"
		random < 10
	npc accompany save
		system
			attributes "ember waste"
			not attributes "ka'het"
			not attributes "inaccessible"
			not attributes "graveyard"
			not government "Remnant"
			not near "Arculus" 3
		personality derelict timid plunders
		government "Remnant"
		fleet
			names "remnant"
			variant
				Starling
			variant
				Gull
	on complete
		"remnant: rescue missions" ++
		payment 200000
		dialog
			`Your communicator notifies you of a resource allocation of <payment>.`
	on visit
		dialog
			`You have returned, yet the <npc> is still missing.`



# The Rescue Dummy is meant to commit suicide as soon as possible on entering the randomized system.
ship "Rescue Dummy"
	# sprite "ship/behemoth"
	attributes
		"heat dissipation" 1
		"hull" 1
		"mass" 10
		"drag" 1
		"automaton" 1
		"energy generation" 1
		"thrust" 30
		"turn" 30
	outfits
		"Suicide Gun"
	gun 0 0

outfit "Suicide Gun"
	"category" guns
	thumbnail "outfit/unknown"
	"gun ports" -1
	weapon
		velocity 100
		lifetime 10
		reload 1
		"blast radius" 900
		"shield damage" 0.01
		"hull damage" 1



mission "Remnant: Rescue 1B"
	job
	repeat
	name "Search and Rescue: Scout"
	description "The <npc> has gone missing during a scouting mission in the Ember Wastes. Find them and help them return to <destination>."
	source
		government "Remnant"
	to offer
		has "Remnant: Learn Sign Follow Up: offered"
		random < 1
	npc kill
		system
			attributes "ember waste"
			not attributes "ka'het"
			not attributes "inaccessible"
			not attributes "graveyard"
			not government "Remnant"
			not near "Arculus" 3
		personality staying heroic nemesis unconstrained
		government "Test Dummy"
		fleet
			names "remnant"
			variant
				"Rescue Dummy"
		dialog
			`As you enter the system, your sensors pick up a lot of debris. Further analysis confirms your worst fears. The <npc> has been destroyed. You frantically spend the next few hours searching for survivors, your hope sinking with every passing minute.`
	on complete
		"remnant: rescue missions" ++
		payment 200000
		dialog
			`You land, and with a heavy heart, report that the <npc> was lost with all hands. The Remnant are saddened at the news, but thank you regardless and hand off your resource allocation of <payment>.`
	on visit
		dialog
			`You have returned, yet the <npc> is still missing.`



mission "Remnant: Rescue 2"
	job
	repeat
	name "Search and Rescue: Retrieval"
	description "The <npc> has gone missing during a tech retrieval mission in the Ember Wastes. Find them and help them return to <destination>."
	source
		government "Remnant"
	to offer
		has "Remnant: Learn Sign Follow Up: offered"
		random < 10
	npc accompany save
		system
			attributes "ember waste"
			not attributes "ka'het"
			not attributes "inaccessible"
			not attributes "graveyard"
			not government "Remnant"
			not near "Arculus" 3
		personality derelict timid plunders
		government "Remnant"
		fleet
			names "remnant"
			variant 7
				Gull
			variant 3
				Starling
			variant 3
				Pelican
	on complete
		"remnant: rescue missions" ++
		payment 300000
		dialog
			`Your communicator notifies you of a resource allocation of <payment>, along with a brief note of thanks.`
	on visit
		dialog
			`You have returned, yet the <npc> is still missing.`



mission "Remnant: Rescue 2B"
	job
	repeat
	name "Search and Rescue: Retrieval"
	description "The <npc> has gone missing during a tech retrieval mission in the Ember Wastes. Find them and help them return to <destination>."
	source
		government "Remnant"
	to offer
		has "Remnant: Learn Sign Follow Up: offered"
		random < 3
	npc kill
		system
			attributes "ember waste"
			not attributes "ka'het"
			not attributes "inaccessible"
			not attributes "graveyard"
			not government "Remnant"
			not near "Arculus" 3
		personality staying heroic nemesis unconstrained
		government "Test Dummy"
		fleet
			names "remnant"
			variant
				"Rescue Dummy"
		dialog
			`As you enter the system, your sensors pick up a lot of debris. Further analysis confirms your worst fears. The <npc> has been destroyed. You frantically spend the next few hours searching for survivors, your hope sinking with every passing minute.`
	on complete
		"remnant: rescue missions" ++
		payment 300000
		dialog
			`You land, and with a heavy heart, report that the <npc> was lost with all hands. The Remnant are saddened at the news, but thank you regardless and hand off your resource allocation of <payment>.`
	on visit
		dialog
			`You have returned, yet the <npc> is still missing.`



mission "Remnant: Rescue 3"
	job
	repeat
	name "Search and Rescue: Supply Ship"
	description "The <npc> has gone missing during a supply run in the Ember Wastes. Find them and help them return to <destination>."
	source
		government "Remnant"
	to offer
		has "Remnant: Learn Sign Follow Up: offered"
		random < 10
	npc accompany save
		system
			attributes "ember waste"
			not attributes "ka'het"
			not attributes "inaccessible"
			not attributes "graveyard"
			not government "Remnant"
			not near "Arculus" 3
		personality derelict timid plunders
		government "Remnant"
		fleet
			names "remnant"
			variant 7
				Pelican
			variant 2
				Gull
	on complete
		"remnant: rescue missions" ++
		payment 300000
		dialog
			`Your communicator notifies you of a resource allocation of <payment>, and also a thank you from the captain of the <npc>.`
	on visit
		dialog
			`You have returned, yet the <npc> is still missing.`



mission "Remnant: Rescue 3B"
	job
	repeat
	name "Search and Rescue: Supply Ship"
	description "The <npc> has gone missing during a supply run in the Ember Wastes. Find them and help them return to <destination>."
	source
		government "Remnant"
	to offer
		has "Remnant: Learn Sign Follow Up: offered"
		random < 3
	npc kill
		system
			attributes "ember waste"
			not attributes "ka'het"
			not attributes "inaccessible"
			not attributes "graveyard"
			not government "Remnant"
			not near "Arculus" 3
		personality staying heroic nemesis unconstrained
		government "Test Dummy"
		fleet
			names "remnant"
			variant
				"Rescue Dummy"
		dialog
			`As you enter the system, your sensors pick up a lot of debris. Further analysis confirms your worst fears. The <npc> has been destroyed. You frantically spend the next few hours searching for survivors, your hope sinking with every passing minute.`
	on complete
		"remnant: rescue missions" ++
		payment 300000
		dialog
			`You land, and with a heavy heart, report that the <npc> was lost with all hands. The Remnant are saddened at the news, but thank you regardless and hand off your resource allocation of <payment>.`
	on visit
		dialog
			`You have returned, yet the <npc> is still missing.`



mission "Remnant: Rescue 4"
	job
	repeat
	name "Distress Signal: Graveyard"
	description "A distress signal has been received from the <npc> in the Graveyard. Follow the telemetry data to find them, and help return them safely to <destination>."
	source
		government "Remnant"
	to offer
		has "Remnant: Learn Sign Follow Up: offered"
		has "First Contact: Ka'het: Remnant 1B: offered"
		random < 10
	npc accompany save
		system
			attributes "graveyard"
			not government "Remnant"
			near "Nona" 20
				"only unrestricted wormholes"
		personality escort derelict heroic plunders
		government "Remnant"
		fleet
			names "remnant"
			variant 8
				Albatross
			variant 2
				Ibis
	on complete
		"remnant: rescue missions" ++
		payment 500000
		dialog
			`Upon landing, the captain of the <npc> meets you at your ship to thank you personally for rescuing them from the Graveyard, leaving you with a heartfelt sentence: "May the Embers burn bright for you."`
			`	Soon after, your communicator notifies you of a resource allocation of <payment>.`
	on visit
		dialog
			`You have returned, yet the <npc> has not.`



mission "Remnant: Rescue 5"
	job
	repeat
	name "Search and Rescue: Terminus"
	description "While scouting around Terminus, the <npc> has stopped reporting in. Find out what happened and return to <destination>."
	source
		government "Remnant"
	to offer
		has "Remnant: Learn Sign Follow Up: offered"
		random < 10
	npc accompany save
		system
			near "Terminus" 2
		personality derelict timid plunders
		government "Remnant"
		fleet
			names "remnant"
			variant 6
				Gull
			variant 3
				Starling
	on complete
		"remnant: rescue missions" ++
		payment 500000
		dialog
			`Worried that they would never see the Embers again, the captain of the <npc> personally thanks you for bringing them home, even before your communicator notifies you of a resource allocation of <payment>.`
	on visit
		dialog
			`You have returned, but there is still no word from the missing ship.`


mission "Remnant: Disable 1"
	job
	repeat
	name "Disable Damaged Kas'lor Ik 582"
	description "A damaged Kas'lor Ik 582 is stuck in a newly accessible system, near Postverta. It has a large civilian population so we ask you to only disable it to avoid an atrocity. Once you return to <planet> you will receive a logistics adjustment of <payment>."
	source
		government "Remnant"
	to offer
		has "Remnant: Will Not Someone Please Think Of The Children: done"
		not "Remnant: Disable 1: aborted"
		not "Remnant: Disable 1: failed"
		random < 5
	npc disable save
		government "Korath"
		personality heroic target marked staying disables plunders
		system
			near "Vaticanus" 1
		fleet
			names "korath"
			variant
				"Kas'lor Ik 582 (Stranded)"
		dialog `You have disabled the Kas'lor Ik 582. Time to report back to <planet>.`
	on visit
		dialog `You've landed on <planet>, but the stuck Kas'lor Ik 582 has not been disabled yet. Hunt it down and disable it before returning.`
	on abort
		dialog `The Remnant are puzzled at your aborting of this mission, but they tell you they will send someone else to do this work. They advise you they will prioritize other teams for these missions in the future.`
	on fail
		"reputation: Remnant" -= 250
		dialog `You where unable to disable the Kas'lor Ik 582 without destroying it... The Remnant will not be pleased...`
	on complete
		"remnant: disable and save count" ++
		payment 2000000
		dialog "A Remnant military prefect thanks you for disabling down the Kas'lor Ik 582 <npc>, and gives you the agreed-upon logistics adjustment of <payment>."
