*label presence

*rand pirate_quadrant 1 111

*temp mark 1
*temp bearing 1

*rand mark 1 24
*rand bearing 1 365
*rand dieroll 5001 8961
	
*if starbase1_quadrant = quadrant
	*set pirate_present false
	*return
	
*if starbase2_quadrant = quadrant
	*set pirate_present false
	*return
	
*if starbase3_quadrant = quadrant
	*set pirate_present false
	*return
	
*if starbase4_quadrant = quadrant
	*set pirate_present false
	*return
	
*if starbase5_quadrant = quadrant
	*set pirate_present false
	*return
	
*if starbase6_quadrant = quadrant
	*set pirate_present false
	*return
	
*if starbase7_quadrant = quadrant
	*set pirate_present false
	*return
	
*if starbase8_quadrant = quadrant
	*set pirate_present false
	*return
	
*if starbase9_quadrant = quadrant
	*set pirate_present false
	*return
	
*if starbase10_quadrant = quadrant
	*set pirate_present false
	*return
	
*if starbase11_quadrant = quadrant
	*set pirate_present false
	*return

	
*set pirate_present false

*if move_counter < 50
	*return

*gosub pirate_names
	
*if quadrant = pirate_quadrant
	🧭 Navigation has identified a ship, 🏴‍☠️  [i]${pirate_ship}[/i], bearing ${bearing}, mark ${mark}, range ${dieroll} kilometers.
	
	*set pirate_present true
	
	You currently have ${credits} credits on board your ship.
	
*return

*label encounter

*temp pirate_battery 0
*set pirate_battery (battery_max + 50)
*temp pirate_torpedoes 0
*rand pirate_torpedoes 2 5

*if sound
	*sound pirates.wav

🛰️ Tactical reports that we are being scanned by the ship!

📶🏴‍☠️ [i]Ahoy, ${ship_name}! Do not even think about trying to run from us.  Shut down your engines immediately and prepare to be boarded.[/i]

*if rp
	${rp_emoji} "Run, ${name}!"

[b]:::[/b] What do you want to do, Captain ${name}?

*fake_choice
	#📶  Give permission to board
		*goto pirate_boarded
	*selectable_if (story_mode = false) #🛰️ Scan [i]${pirate_ship}[/i]
		*goto scan_pirate
	*selectable_if (story_mode = false) #⚔️ Attack [i]${pirate_ship}[/i]
		*goto attack_pirate
	*selectable_if (fuel > 20) #💫 Make an emergency warp jump
		*goto warp
	
*label scan_pirate

*if sound
	*sound scan.wav

🌌  [b]Current Location[/b]: Quadrant ${quadrant}, Sector ${sector}

Your scan reveals tactical information about  🏴‍☠️  ${pirate_ship}:

🔋 Battery: ${pirate_battery}
*line_break
🚇 Torpedoes: ${pirate_torpedoes}
*line_break

📶 [i]"Captain, if you do not shut down your engines at once, we will open fire."[/i]

[b]:::[/b] What do you want to do, Captain ${name}?

*fake_choice
	#📶  Give permission to board
		*goto pirate_boarded
	#⚔️ Attack [i]${pirate_ship}[/i]
		*goto attack_pirate
	*selectable_if (fuel > 20) #💫 Make an emergency warp jump
		*goto warp
	
*label pirate_boarded

🌌  [b]Current Location[/b]: Quadrant ${quadrant}, Sector ${sector}

*rand dieroll 1 3
*temp bribe 0
*set bribe (credits / dieroll)
*set bribe round(bribe)

*if sound
	*sound stcommunicator.wav

📶 "I have shut down my engines and am standing by for your arrival," you broadcast to the unidentified ship.

*if rp
	${rp_emoji} "Those animals are gonna tear apart your ship, ${name}."

A few minutes later, a contingent of motley scalawags arrives on board your vessel and begins a hard target search.

After the privateers turn over every square inch of your ship, the ugliest one turns to you:

*temp pretext ""

*rand dieroll 1 7

*if dieroll = 1
	*set pretext "being a total dumbass who thought they could enter this sector without paying protection tax"
	
*if dieroll = 2
	*set pretext "sneaking up on us in this sector when we were just trying to relax and unwind"
	
*if dieroll = 3
	*set pretext "failing to respond fast enough when we told you to cut off your damn engines"
	
*if dieroll = 4
	*set pretext "looking shifty and bug-eyed and just all around giving me the creeps"
	
*if dieroll = 5
	*set pretext "stinking up our space lanes with this garbage ship"
	
*if dieroll = 6
	*set pretext "trying to get rich just by shuttling stuff around from planet to planet"
	
*if dieroll = 7
	*set pretext "playing lame music too loud when we were trying to conduct a health and safety inspection"
	
*temp polemoji ""

*rand dieroll 1 2

*if dieroll = 1
	*set polemoji "🙋‍♀️"
	
*if dieroll = 2
	*set polemoji "🙋‍♂️"
	
*if bribe < 350
	*goto warning

*set credits (credits - bribe)

🦜 [i]"We hereby find you guilty of ${pretext}.  For this heinous offense to our delicate sensibilities, we are fining you ¢${bribe}.  If you continue to annoy us in the future, we will take your ship, Captain.  Have a good day now."[/i]

*page_break ${polemoji} Salute the pirates

*goto_scene startrip_main

*label warning

*temp load 0
*set load (cargo_holds - cargo_space_free)

*if load > 1
	*goto steal_cargo

🦜 [i]"We hereby find you guilty of ${pretext}.  For this heinous offense to our delicate sensibilities, we should be taking every last credit you got, but it turns out that you are unbelievably poor.  Therefore, we're just going to give you a warning, for now.  But next time, we're taking your ship!"[/i]

*page_break 🙋 Salute the pirates

*goto_scene startrip_main

*label attack_pirate

*set oppo_battery pirate_battery
*comment *set oppo_torpedoes pirate_torpedoes
*set oppo_torpedoes 0
*set oppo_name pirate_ship
*set oppo_emoji "🏴‍☠️ "

*goto_scene ship_fight

*label steal_cargo

*set resource1_carrying 0
*set resource2_carrying 0
*set resource3_carrying 0
*set resource4_carrying 0
*set resource5_carrying 0
*set resource6_carrying 0
*set resource7_carrying 0
*set resource8_carrying 0
*set resource9_carrying 0
*set resource10_carrying 0
*set resource11_carrying 0
*set cargo_space_free cargo_holds

🦜 [i]"We hereby find you guilty of ${pretext}.  For this heinous offense to our delicate sensibilities, we should be taking every last credit you got, but it turns out that you are unbelievably poor.  Because you wasted our time, we're going to take your cargo."[/i]

*page_break 🙋 Salute the pirates

*goto_scene startrip_main

	
*label warp

*if sound
	*sound emergency.wav

Without hesitating, you punch in the codes to execute an emergency warp jump in order to flee the pirate ship.

*if rp
	${rp_emoji} "Go, go, go!"

*page_break 💫 Engage!

*if sound
	*sound fuelburn.mp3

*if story_mode = false
	*rand quadrant 1 111
	*rand sector 1 4
	
*if story_mode = true
	*rand dieroll 1 11
	*temp gringo ""
	*set gringo "starbase${dieroll}_quadrant"
	*set quadrant {gringo}
	*set gringo "starbase${dieroll}_sector"
	*set sector {gringo}

*temp fuel_burn 0
*set fuel_burn fuel

*set fuel (fuel / 3)
*set fuel round(fuel)
*set fuel_burn (fuel_burn - fuel)

🔥 Fuel burned: ${fuel_burn}
*line_break
Fuel remaining: ${fuel}
*line_break

*label fish

*set pirate_quadrant 0

*goto_scene startrip_main

*label pirate_names

*rand dieroll 1 21

*rand dieroll 1 21

*if dieroll = 1
	*set pirate_ship "The Dishonorable Dagger"
	
*if dieroll = 2
	*set pirate_ship "Curse of Atlantis"
	
*if dieroll = 3
	*set pirate_ship "Angel of Doom"
	
*if dieroll = 4
	*set pirate_ship "Blood Lightning"
	
*if dieroll = 5
	*set pirate_ship "The Bloody Hangman"
	
*if dieroll = 6
	*set pirate_ship "Bone Rattler"
	
*if dieroll = 7
	*set pirate_ship "Broken Slave"
	
*if dieroll = 8
	*set pirate_ship "Fearful Diamond"
	
*if dieroll = 9
	*set pirate_ship "Hellhound"
	
*if dieroll = 10
	*set pirate_ship "The Lost Soul"
	
*if dieroll = 11
	*set pirate_ship "Moon Raider"
	
*if dieroll = 12
	*set pirate_ship "Night Blood"
	
*if dieroll = 13
	*set pirate_ship "Night Wind"
	
*if dieroll = 14
	*set pirate_ship "Drunken Squid"
	
*if dieroll = 15
	*set pirate_ship "Plague Bringer"
	
*if dieroll = 16
	*set pirate_ship "Storm of Plagues"
	
*if dieroll = 17
	*set pirate_ship "The Poisoned Arrow"
	
*if dieroll = 18
	*set pirate_ship "Red Hurricane"
	
*if dieroll = 19
	*set pirate_ship "Revenge Queen"
	
*if dieroll = 20
	*set pirate_ship "Galactic Ghost"
	
*if dieroll = 21
	*set pirate_ship "Shark Rider"

*return