/*SecForceEX JS*/
window.SFC = function() {
	const V = State.variables;
	if (V.SFTradeShow.CanAttend === -1) {
		return `The Colonel`;
	} else {
		if (V.LieutenantColonel > 0) {
			return `Lieutenant Colonel <<= SlaveFullName($LieutenantColonel)>>`;
		} else {
			return `a designated soldier`;
		}
	}
};

window.SFCR = function() {
	const V = State.variables,
		C = V.SFColonel;
	if (C.Status < 1) {
		return `boss`;
	} else if (C.Status >= 10) {
		return `friend`;
	} else if (C.Status >= 25) {
		return `close friend`;
	} else if (C.Status >= 45) {
		if (V.PC.title > 0) {
			return `boyfriend`;
		} else {
			return `girlfriend`;
		}
	} else if (C.Status >= 65) {
		return `lover`;
	}
};

window.TroopDec = function() {
	const V = State.variables,
		commom = "the <<print commaNum($SFUnit.Troops)>> members of $SF.Lower",
		S = V.SFUnit;
	if (S.Troops < 100) {
		return `sparsely occupied, ${commom} residing within them concentrating together in a corner. The hundreds of empty beds and lockers visibly herald the future`;
	} else if (S.Troops < 400) {
		return `lightly occupied, with ${commom} starting to spread out across them`;
	} else if (S.Troops < 800) {
		return `moderately occupied, though ${commom} residing within have a considerable amount of extra room`;
	} else if (S.Troops < 1500) {
		return `well-occupied, and ${commom} residing within have started to form small cliques based on section and row`;
	} else if (S.Troops < 2000) {
		return `near capacity, and ${commom} often barter their personal loot, whether it be monetary or human, for the choicest bunks`;
	}
};

window.HSM = function() {
	const V = State.variables;
	if (V.PC.hacking <= -100) {
		return 1.5;
	} else if (V.PC.hacking <= -75) {
		return 1.35;
	} else if (V.PC.hacking <= -50) {
		return 1.25;
	} else if (V.PC.hacking <= -25) {
		return 1.15;
	} else if (V.PC.hacking < 0) {
		return 1.10;
	} else if (V.PC.hacking === 0) {
		return 1;
	} else if (V.PC.hacking <= 10) {
		return 0.97;
	} else if (V.PC.hacking <= 25) {
		return 0.95;
	} else if (V.PC.hacking <= 50) {
		return 0.90;
	} else if (V.PC.hacking <= 75) {
		return 0.85;
	} else if (V.PC.hacking <= 100) {
		return 0.80;
	} else if (V.PC.hacking > 100) {
		return 0.75;
	}
};

window.Count = function() {
	const V = State.variables,
		T = State.temporary,
		C = Math.clamp,
		S = V.SFUnit,
		E = V.economy;
	T.FU = 10,S.Firebase = C(S.Firebase, 0, T.FU);
	T.AU = 10,S.Armoury = C(S.Armoury, 0, T.AU);
	T.DrugsU = 10,S.Drugs = C(S.Drugs, 0, T.DrugsU);
	T.DU = 10,S.Drones = C(S.Drones, 0, T.DU);
	T.AVU = 10,S.AV = C(S.AV, 0, T.AVU);
	T.TVU = 10,S.TV = C(S.TV, 0, T.TVU);
	T.PGTU = 10,S.PGT = C(S.PGT, 0, T.PGTU);
	T.GU = T.AVU+T.TVU+T.PGTU, T.G = S.AV+S.TV+S.PGT;
	if (V.PC.hacking >= 75) {
		T.AAU = 10,T.TAU = 10;
	} else {
		T.AAU = 9,T.TAU = 9;
	}
	S.AA = C(S.AA, 0, T.AAU),S.TA = C(S.TA, 0, T.TAU);
	if (V.PC.hacking >= 75) {
		T.SPU = 10;
	} else {
		T.SPU = 9;
	}
	T.GunSU = 10;
	S.SpacePlane = C(S.SpacePlane, 0, T.SPU), S.GunS = C(S.GunS, 0, T.GunSU);
	T.H = S.AA+S.TA+S.SpacePlane+S.GunS, T.HU = T.AAU+T.TAU+T.SPU+T.GunSU;
	if (V.PC.hacking >= 75) {
		T.SatU = 10, T.GRU = 10;
	} else {
		T.SatU = 9, T.GRU = 9;
	}
	S.Satellite = C(S.Satellite, 0, T.SatU);
	S.GiantRobot = C(S.GiantRobot, 0, T.GRU);
	T.MSU = 10;
	S.MissileSilo = C(S.MissileSilo, 0, T.MSU);
	if (V.PC.hacking >= 75) {
		T.SubU = 10;
	} else {
		T.SubU = 9;
	}
	S.Sub = C(S.Sub, 0, T.SubU);
	T.HATU = 10;
	S.HAT = C(S.HAT, 0, T.HATU);
	T.ACU = 10;
	S.AircraftCarrier = C(S.AircraftCarrier, 0, T.ACU);
	T.Base = S.Firebase + S.Armoury + S.Drugs + S.Drones + T.G + T.H;
	T.BaseU = T.FU + T.AU + T.DrugsU + T.DU + T.GU + T.HU;
	T.LBU = T.SatU + T.GRU + T.MSU, T.LB = S.Satellite + S.GiantRobot + S.MissileSilo;
	T.max = T.BaseU + T.LBU;
	V.SF.Units = T.Base + T.LB;
	T.Land = 1;
	if (V.terrain === "oceanic" || V.terrain === "marine") {
		T.NY = S.AircraftCarrier + S.Sub + S.HAT;
		T.NYU = T.ACU + T.SubU + T.HATU;
		T.max += T.NYU;
		V.SF.Units += T.NY;
		T.Land = 0;
	}
	V.SF.Units = C(V.SF.Units, 0, T.max);
	if (E < 1) {
		T.Env = 4;
	} else if (E < 1.5) {
		T.Env = 3;
	} else if (E > 1.5) {
		T.Env = 2;
	}
};

window.Firebase = function() {
	const V = State.variables,
		S = V.SFUnit;
	var quanitiy = "",
		casemates = "",
		pads = "",
		sizeI = "",
		barrel = "",
		t = `Has (mostly) taken on the appearance of a professional military installation, with clearly delineated soldier and logistical areas, dedicated support and recreation facilities, in addition to advanced command and control apparatus. As a final measure,`;
	if (S.Firebase === 0)
		return `Is currently quite basic, consisting of little more than a dormitory, armoury, a processing facility for human spoils, and a common area, sectioned off by stacks of empty supply crates. The cavernous space, however, is ripe for expansion.`;
	if (S.Firebase === 1)
		return `Has become more permanent, expanding into free space, erecting permanent dividers, and sectioning off an area for use as a garage and vehicle maintenance bay.`;
	if (S.Firebase === 2)
		return `Has added a facility for the storage, maintenance, and deployment of armed combat drones, and added storage facilities for the soldiers to store their personal spoils in.`;
	if (S.Firebase === 3)
		return `Has added additional support personnel and equipment, allowing the potential procurement of heavier infantry armour, fighting vehicles, and combat drones.`;
	if (S.Firebase === 4)
		return `Has expanded tremendously, adding an aerial control facility and express elevator connecting to a ring of launch pads and hangars built around the arcology's upper levels. Additional facilities have been added for soldier recreation, and Spartan quarters for live-in slaves, both menial and service, have been installed.`;
	if (S.Firebase === 5) sizeI = `356 cm wide`;
	if (S.Firebase >= 6) quanitiy = `quad`, sizeI = `406 cm wide`;
	if (S.Firebase >= 7) casemates = `fortified EMP/jammer resistant`, barrel =  `double-barreled`;
	if (S.Firebase >= 8) pads = `and a powerful arcology wide electromagnetic force field has been installed`;
	if (S.Firebase === 9) barrel = `tripple-barreled`, sizeI = `415 cm wide`;
	if (S.Firebase === 10) barrel = `quad-barreled`, sizeI = `420 cm wide`;
	return ` ${t} ${quanitiy} heavy, long range, ${barrel} electromagnetic railgun ${sizeI} artillery pieces have been installed in ${casemates} casemates along the aerial launch pads ${pads}, giving $SF.Lower an immense superiority in local firepower.`;
};

window.Armoury = function() {
	const V = State.variables,
		S = V.SFUnit;
	var size = ``,
		kit = ``,
		t = `Acquired heavy weapon attachments for its combat armour suits`,
		y = `for the soldiers, ensuring that the infantry of $SF.Lower is perhaps the most well-equipped in the world.`;
	if (S.Armoury === 0)
		return `Is well-stocked with high-quality personal weapons and light armour, but contains little in the way of exceptional armament.`;
	if (S.Armoury === 1)
		return `Has large stocks of the absolute latest personal weapons and light armour, It has also added first-generation exo-suits to improve soldier lethality.`;
	if (S.Armoury === 2)
		return `Has acquired advanced tactical helmets and second-generation exo-suits to further improve soldier lethality.`;
	if (S.Armoury === 3)
		return `Has replaced deployed exo-suits with basic enclosed combat armour suits, and has further begun to deploy early electromagnetic (coilgun) weaponry.`;
	if (S.Armoury === 4)
		return `Has begun to equip the soldiers with more advanced combat armour suits, and has expanded its inventory of electromagnetic weaponry.`;
	if (S.Armoury === 5) size = `small`;
	if (S.Armoury === 6) size = `both small and medium`;
	if (S.Armoury >= 7) size = `small/medium and large`;
	if (S.Armoury === 8) kit = `with basic thrusters`;
	if (S.Armoury === 9) kit = `with advanced thrusters`;
	if (S.Armoury === 10) kit = `with advanced thrusters and optical illusion kits`;
	return `${t} ${kit},and has further sourced ${size} advanced electromagnetic weaponry (miniaturized railguns) ${y}`;
};

window.Drugs = function() {
	const V = State.variables,
		S = V.SFUnit;
	var improvement = ``,
		tryptamine = ``,
		tryptamine1 = ``,
		Dose = ``,
		LSD = ``,
		purity = ``,
		doc = ``,
		Effects = ``,
		Effect0 = ``,
		x = 'the formulas of the methamphetamine-based stimulants and phencyclidine-based dissociatives,';
	if (S.Drugs === 0)
		return `Is providing the soldiers with standard ephedrine-based stimulants.`;
	if (S.Drugs === 1)
		return `Improved the formula of the ephedrine-based stimulants, concentrating them and increasing both their potency, and the effectiveness of the soldiers under their influence.`;
	if (S.Drugs === 2)
		return `Replaced the soldiers' stimulants with methamphetamine-based variants, greatly increasing their alertness and aggressiveness when under their influence.`;
	if (S.Drugs === 3)
		return `Improved and concentrated the methamphetamine-based stimulants, and has also begun providing soldiers with phencyclidine-based dissociatives, allowing the soldiers to excuse their actions in the field and reducing any reluctance to follow severe orders.`;
	if (S.Drugs === 4) improvement = `further`;
		tryptamine = `has also begun providing tryptamine-based psychedelics to the soldiers, allowing them to avoid traumatic stress in the field.`;
	if (S.Drugs >= 5) improvement = `maximally`;
		tryptamine = `tryptamine-based psychedelics`;
		tryptamine1 = `Greatly increasing their effectiveness in all aspects thus ensuring that the soldiers of $SF.Lower go into combat wired, aggressive, and euphoric (if needed).`;
	if (S.Drugs >= 6) purity = `with much higher purity compontent`;
	if (S.Drugs >= 7) LSD = `and a slight trace of LSD`;
	if (S.Drugs >= 8) Dose = `into a single dose`;
		doc = `<div style='font-size: 75%;'>*Only the doctors of $SF.Lower were consulted to ensure a completely unbiased result.</div>`;
		Effects = `However side effects may include (no particular order): Dissociative Identity Disorder, severe clinical depression, unstoppable vomiting, extreme paranoia, PTSD, finally total organ failure. Recommended by 9/10 doctors*.`;
	if (S.Drugs >= 9) Effects = `Potential side effects have been reduced slightly to “only mildly” severe ones: Dissociative Identity Disorder, severe clinical depression, unstoppable vomiting, extreme paranoia and PTSD. Now recommended by 15/10 doctors*.`;
	if (S.Drugs === 10) Dose = `into a single higher strength dose`, Effect0 = `at the cost of lengthening the effects`;
	return `Has ${improvement} refined ${x} and ${tryptamine} ${purity} ${LSD} ${Dose}. ${tryptamine1} ${Effect0}.${Effects} ${doc}`;
};

window.LUAV = function() {
	const V = State.variables,
		S = V.SFUnit;
	var a = `have been recommissioned for use by $SF.Lower`,
		b = `.`,
		c = ``,
		d = ``,
		e = ``,
		f = ``,
		g = ``,
		h = ``,
		i = ``,
		j = ``,
		k = ``;

	if (S.Drones >= 2) a = `equipped with missiles are resting on one side of the drone bay`, b = `, as well as destroying the occasional target.`;
	if (S.Drones >= 3) c = `A fleet of`, d = `large delivery quadcopters have been converted for military service to support ground forces as combat drones.`;
	if (S.Drones >= 4) d = `combat drones take up the rest of the space in the drone bay. They have a`, e = `small automatic rifle`, f = `mounted to the underside.`;
	if (S.Drones >= 5) g = `Armor has been added to protect vulnerable components from small arms fire.`;
	if (S.Drones >= 6) h = `The fleet's batteries have been replaced with higher capacity models, increasing the functional time spent in combat.`;
	if (S.Drones >= 7) i = `The propellers and motors have been upgraded, increasing maneuverability and speed.`;
	if (S.Drones >= 8) j = `The drone control signal has been boosted and encrypted, giving the drones a greater range and protecting against electronic warfare.`;
	if (S.Drones >= 9) e = `light machine gun`;
	if (S.Drones >= 10)	k = `A drone-to-drone network has been installed, allowing drones to swarm, maneuver, and attack targets autonomously.`;

	return `Surveillance drones ${a}. During combat, they supply aerial intel to commanders and act as the communications network for ground forces${b} ${c} ${d} ${e} ${f} ${g} ${h} ${i} ${j} ${k}`;
};

window.AV = function() {
	const V = State.variables,
		S = V.SFUnit;
	var b = `has been recommissioned for use by $SF.Lower. They`,
		c = `; mechanics are methodically checking the recent purchases for battle-readiness`,
		MG = `120 mm main gun is enough to handle the majority of opponents around the Free Cities.`,
		engine = ``,
		armor = ``,
		armor2 = ``,
		ammo = ``,
		mg = ``,
		fireC0 = ``,
		fireC1 = ``,
		fireC2 = ``,
		fireC3 = ``,
		turret = ``;

	if (S.AV >= 2) engine = `The engine has been overhauled, allowing much faster maneuvering around the battlefield.`, b = ``, c = ``;
	if (S.AV >= 3) armor = `A composite ceramic armor has replaced the original, offering much greater protection from attacks.`;
	if (S.AV >= 4) ammo = `The tanks have been outfitted with additional types of ammo for situational use.`;
	if (S.AV >= 5) mg = `A remote-controlled .50 cal machine gun has been mounted on the turret to handle infantry and low-flying aircraft.`;
	if (S.AV >= 6) fireC0 = `A fire-control system`, fireC3 = `been installed, guaranteeing`, fireC2 = `has`, fireC1 = `accurate fire.`;
	if (S.AV >= 7) fireC2 = `and an autoloader have`, fireC1 = `rapid, accurate fire while separating the crew from the stored ammunition in the event the ammo cooks off.`;
	if (S.AV >= 8) armor2 = `A reactive armor system has been added, giving the tank an additional, if temporary, layer of protection.`;
	if (S.AV >= 9) turret = `The turret has been massively redesigned, lowering the tank profile and increasing the efficiency of the mechanisms within.`;
	if (S.AV >= 10) MG = `140 mm main gun can quash anything even the greatest Old World nations could muster.`;

	return `A fleet of main battle tanks ${b} are parked in the garage${c}. ${turret} The ${MG} ${ammo} ${mg} ${fireC0} ${fireC2} ${fireC3} ${fireC1} ${engine} ${armor} ${armor2}`;
};

window.TV = function() {
	const V = State.variables,
		S = V.SFUnit;
	var B = `has been recommissioned for use by $SF.Lower. They`,
		C = `; mechanics are giving the new purchases a final tuneup`,
		squad = `a squad`,
		G1 = `20`,
		G2 = `in a firefight`,
		e0 = `The engine has been`,
		engine = ``,
		armor = ``,
		tires = ``,
		m1 = ``,
		m2 = ``,
		pod1 = ``,
		pod2 = ``;

	if (S.TV >= 2) engine = `${e0} overhauled, allowing for higher mobility.`, C = ``, B = ``;
	if (S.TV >= 3) armor = `Composite armor has been bolted to the exterior, increasing the survivability of an explosive attack for the crew and passengers.`;
	if (S.TV >= 4) tires = `The tires have been replaced with a much more durable version that can support a heavier vehicle.`;
	if (S.TV >= 5) m1 = `An automatic missile defense system has been installed,`, m2 = `targeting any guided missiles with laser dazzlers and deploying a smokescreen.`;
	if (S.TV >= 6) pod1 = `An anti-tank missle pod`, pod2 = `has been installed on the side of the turret.`;
	if (S.TV >= 7) G1 = `25`, G2 = `by attacking enemies through cover and destroying light armor`;
	if (S.TV >= 8) pod2 = `and an anti-aircraft missile pod have been installed on either side of the turret.`;
	if (S.TV >= 9) squad = `two squads`, armor = ``, m2 = `destroying any incoming missiles with a high-powered laser. Some of the now redundant composite armor has been removed, and the reclaimed space allows for more passengers.`;
	if (S.TV >= 10) engine = `${e0} replaced with the newest model, allowing the vehicle to get in and out of the conflict extremely quickly.`;

	return `A fleet of infantry fighting vehicles ${B} are parked in the garage${C}. The IFVs can carry ${squad} of 6 to a firezone. The ${G1} mm autocannon supports infantry ${G2}. ${pod1} ${pod2} ${engine} ${armor} ${tires} ${m1} ${m2}`;
};

window.PGT = function() {
	const V = State.variables,
		S = V.SFUnit;
	var b = `has been sold to $SF.Lower through back channels to support a failing Old World nation. The tank is so large it cannot fit inside the garage, and has`,
		c = ``,
		engines = `. Two engines power the left and right sides of the tank separately, leaving it underpowered and slow`,
		gun0 = ``,
		gun1 = ``,
  		gun2 = `an undersized main gun and makeshift firing system from a standard battle tank`,
		armor1 = ``,
		armor0 = ``,
		cannon = ``,
		laser = ``,
		PGTframe = ``;

	if (S.PGT >= 2) c = `rests in`, b = ``, engines = ` and powered by their own engine, allowing the tank to travel with an unsettling speed for its massive bulk`;
	if (S.PGT >= 3) gun0 = `a railgun capable of`, gun1 = `firing steel slugs`, gun2 = `through one tank and into another`;
	if (S.PGT >= 4) armor0 = `reinforced, increasing survivability for the crew inside.`, armor1 = `The armor has been`;
	if (S.PGT >= 5) cannon = `A coaxial 30mm autocannon has been installed in the turret, along with automated .50 cal machine guns mounted over the front treads.`;
	if (S.PGT >= 6) laser = `Laser anti-missile countermeasures have been installed, destroying any subsonic ordinance fired at the Goliath.`;
	if (S.PGT >= 7) PGTframe = `The frame has been reinforced, allowing the Goliath to carry more armor and gun.`;
	if (S.PGT >= 8) armor0 = `redesigned with sloping and state-of-the-art materials, allowing the Goliath to shrug off even the most advanced armor-piercing tank rounds.`;
	if (S.PGT >= 9) gun1 = `firing guided projectiles`;
	if (S.PGT >= 10) gun0 = `a twin-barreled railgun capable of rapidly`;

	return `A prototype Goliath tank ${b}${c} its own garage housing built outside the arcology. The massive bulk is spread out over 8 tracks, two for each corner of the tank${engines}. The turret is equipped with ${gun0} ${gun1} ${gun2}. ${cannon} ${armor1} ${armor0} ${laser} ${PGTframe}`;
};

window.AA = function() {
	const V = State.variables,
		S = V.SFUnit;
	var W1 = `only armed`,
		W2 = `,`,
		W3 = `a poor weapon against flying targets, but enough to handle ground forces`,
		group = `A small group of attack VTOL have been recommissioned for use by $SF.Lower, enough to make up a squadron`,
		engines = ``,
		TAI = ``,
		lock = ``,
		support = ``,
		stealth = ``,
		scramble = ``,
		PAI = ``;

	if (S.AA >= 2) W1 = `armed`, W2 = ` and air-to-air missiles,`, W3 = `a combination that can defend the arcology from enemy aircraft, as well as`, support = ` support ground troops`;
	if (S.AA >= 3) engines = `The engines have been tuned, allowing faster flight with greater acceleration.`;
	if (S.AA >= 4) TAI = `An advanced targeting AI has been installed to handle all control of weapons, allowing much more efficent use of ammunition and anti-countermeasure targeting.`;
	if (S.AA >= 5) lock = `Installed multispectrum countermeasures protect against all types of missile locks.`;
	if (S.AA >= 6) group = `A respectable number of attack VTOL protect your arcology, split into a few squadrons`;
	if (S.AA >= 7) support = ` attack ground targets`, W2 = `, rocket pods, and air-to-air missiles,`;
	if (S.AA >= 8) stealth = `The old skin has been replaced with a radar-absorbent material, making the aircraft difficult to pick up on radar.`;
	if (S.AA >= 9)  scramble = `The VTOLs can scramble to react to any threat in under three minutes.`;
	if (S.AA >= 10)	PAI = `A piloting AI has been installed, allowing the VTOLs to perform impossible maneuvers that cannot be done by a human pilot. This removes the need for a human in the aircraft altogether.`;

	return `${group}. Several of the landing pads around $arcologies[0].name host groups of four fighters, ready to defend the arcology. ${scramble} The attack VTOL are currently ${W1} with a Gatling cannon${W2} ${W3}${support}. ${TAI} ${PAI} ${engines} ${lock} ${stealth}`;
};

window.TA = function() {
	const V = State.variables,
		S = V.SFUnit;
	var Num = `number`,
		type = `tiltrotor`,
		capacity = `small platoon or 15`,
		engines = ``,
		engines2 = ``,
		Radar = ``,
		Armor = ``,
		landing = ``,
		miniguns = ``,
		counter = ``;

	if (S.TA >= 2) engines = `The tiltrotor engines have been replaced with a more powerful engine, allowing faster travel times.`;
	if (S.TA >= 3) counter = `Multispectrum countermeasures have been added to protect against guided missiles.`;
	if (S.TA >= 4) miniguns = `Mounted miniguns have been installed to cover soldiers disembarking in dangerous areas.`;
	if (S.TA >= 5) Num = `large number`;
	if (S.TA >= 6) landing = `The landing equipment has been overhauled, protecting personel and cargo in the event of a hard landing or crash.`;
	if (S.TA >= 7) Armor = `Armor has been added to protect passengers from small arms fire from below.`;
	if (S.TA >= 8) capacity = `large platoon or 20`, engines2 = `Further tweaks to the engine allow for greater lifting capacity.`;
	if (S.TA >= 9) Radar = `Radar-absorbent materials have replaced the old skin, making it difficult to pick up the VTOL on radar.`;
	if (S.TA >= 10) type = `tiltjet`, engines2 = ``, engines = `The tiltrotors have been replaced with tiltjets, allowing for much greater airspeed and acceleration.`;

	return `A ${Num} of transport ${type} VTOL have been recommissioned for use by $SF.Lower. The VTOLs are resting on large pads near the base to load either a ${capacity} tons of materiel. ${engines} ${engines2} ${Armor} ${landing} ${counter} ${Radar} ${miniguns}`;
};

window.SP = function() {
	const V = State.variables,
		S = V.SFUnit;
	var engine = `ramjet engines in the atmosphere that can reach Mach 10`,
		b = `has been purchased from an insolvent Old World nation. It `,
		shield = ``,
		camera = ``,
		efficiency = ``,
		camera2 = ``,
		drag = ``,
		crew = ``,
		engine2 = ``,
		skin = ``;

	if (S.SpacePlane >= 2) b = ``, shield = `The current heat shielding has been upgraded, reducing the likelihood of heat damage during reentry.`;
	if (S.SpacePlane >= 3) engine2 = ` and liquid rocket engines in orbit that can reach an equivalent Mach 18`;
	if (S.SpacePlane >= 4) camera = `A state-of-the-art camera has been installed in the underbelly that takes incredibly high resolution photos, but requires the frictionless environment of space to focus.`;
	if (S.SpacePlane >= 5) efficiency = `Tweaks to the engines have increased fuel efficency to the point where midflight refueling is no longer necessary.`;
	if (S.SpacePlane >= 6) camera2 = `The camera sensor is capable of taking IR shots.`;
	if (S.SpacePlane >= 7) drag = `Miraculous advances in aerodynamics and materials allow frictionless flight, even while in the atmosphere.`;
	if (S.SpacePlane >= 8) crew = `Increased the crew comfort and life support systems to increase operational time.`;
	if (S.SpacePlane >= 9) skin = `Replaced the underbelly skin with an chameleon kit, matching the color to the sky above it.`;
	if (S.SpacePlane >= 10) engine = `experimental scramjet engines in the atmosphere that can reach Mach 15`, engine2 = ` and liquid rocket engines in orbit that can reach an equivalent Mach 25`;

	return `A prototype spaceplane ${b} rests in the hangar, its black fuselage gleaming. The craft is powered by ${engine}${engine2}. ${efficiency} ${shield} ${camera} ${camera2} ${drag} ${crew} ${skin}`;
};

window.GunS = function() {
	const V = State.variables,
		S = V.SFUnit;
	var a = `has been recommissioned for use by $SF.Lower. Currently, it `,
		b = ``,
		c = ``,
		d = ``,
		e = `Miniguns and Gatling cannons line`,
		f = `, though the distance to ground targets renders the smaller calibers somewhat less useful`,
		g = ``,
		h = ``,
		i = ``,
		j = ``,
		k = ``;

	if (S.GunS >= 2) b = `Infrared sensors have been added for the gunners to better pick targets.`, a = ``;
	if (S.GunS >= 3) c = `The underside of the aircraft has been better armored against small-arms fire`, h = `.`;
	if (S.GunS >= 4) d = `Larger fuel tanks have been installed in the wings and fuselage, allowing the gunship to provide aerial support for longer periods before refueling.`;
	if (S.GunS >= 5) e = `25 mm Gatling cannons`, f = `, allowing the gunship to eliminate infantry`, j = ` and light vehicles from above`, k = ` and a 40 mm autocannon are mounted on`;
	if (S.GunS >= 6) g = `The engines have been replaced, allowing both faster travel to a target, and slower travel around a target.`;
	if (S.GunS >= 7) h = `, and multi-spectrum countermeasures have been installed to protect against guided missiles.`;
	if (S.GunS >= 8) b = `Upgraded multi-spectrum sensors can clearly depict targets even with IR shielding.`;
	if (S.GunS >= 9) i = `The ammunition storage has been increased, only slightly depriving loaders of a place to sit.`;
	if (S.GunS >= 10) j = `, both light and heavy vehicles, and most enemy cover from above`, k = `, a 40 mm autocannon, and a 105 mm howitzer are mounted on`;

	return `A large gunship ${a} is being refueled in the hangar. ${e}${k} the port side of the fuselage${f}${j}. ${b} ${i} ${g} ${c}${h} ${d}`;
};

window.Sat = function() {
	const V = State.variables,
		S = V.SFUnit;
	var loc = `An unused science satellite has been purchased from an Old World nation. While currently useless, it holds potential to be a powerful tool.`,
		gyro = ``,
		telemetry = ``,
		thrusters = ``,
		solar = ``,
		surviv = ``,
		laser = ``,
		heat = ``,
		reactor = ``,
		lens = ``,
		kin = ``;

	if (S.Satellite >= 2) {
		if (V.SatLaunched < 1) {loc = `The satellite is being worked on in the Launch Bay.`;} else {loc = `The satellite is in geosynchronous orbit, far above the arcology.`;}
		gyro = `A suite of sensors have been installed to ensure the satellite can detect attitude and orbital altitude.`;
		}
	if (S.Satellite >= 3) telemetry = `Telemetry systems have been installed to communicate with the satellite in orbit, with strong encryption measures.`;
	if (S.Satellite >= 4) thrusters = `Thrusters have been installed to control satellite attitude and orbit.`;
	if (S.Satellite >= 5) solar = `A massive folding solar panel array, combined with the latest in battery technology allow the satellite to store an enormous amount of energy relatively quickly.`, surviv = `Enough of the satellite has been finished that it can expect to survive for a significant period of time in space.`;
	if (S.Satellite >= 6) laser = `A laser cannon has been mounted facing the earth, capable of cutting through steel in seconds`, heat = ` while generating a large amount of heat.`;
	if (S.Satellite >= 7) heat = `. The installed heatsink allows the laser cannon to fire more frequently without damaging the satellite.`;
	if (S.Satellite >= 8) reactor = `A small, efficient nuclear reactor has been installed to continue generating energy while in the Earth's shadow.`;
	if (S.Satellite >= 9) lens = `A higher quality and adjustable lens has been installed on the laser, allowing scalpel precision on armor or wide-area blasts on unarmored targets.`;
	if (S.Satellite >= 10) kin = `A magazine of directable tungsten rods have been mounted to the exterior of the satellite, allowing for kinetic bombardment roughly equal to a series of nuclear blasts.`;

	return `${loc} ${gyro} ${thrusters} ${telemetry} ${solar} ${reactor} ${surviv} ${laser}${heat} ${lens} ${kin}`;
};

window.GR = function() {
	const V = State.variables,
		S = V.SFUnit;
	var loc = `has been purchased from a crumbling Old World nation. It`,
		power = `Large batteries mounted in oversized shoulders power the robot for up to ten minutes of use, though they make for large targets.`,
  		knife = `simply a 8.5 meter long knife, though additional weapons are under development.`,
		armor = ``,
		actuator = ``,
		cannon = ``,
		heatsink = ``,
		ammo = ``,
		missile = ``;

	if (S.GiantRobot >= 2) loc = ``, armor = `Armor plating has been mounted over the majority of the robot.`;
	if (S.GiantRobot >= 3) power = `The robot is now powered by an umbilical cable system instead of bulky and short-lived batteries.`;
	if (S.GiantRobot >= 4) knife = `a 25 meter plasma sword. The cutting edge uses plasma to melt and cut through targets, reducing the strain on the sword.`;
	if (S.GiantRobot >= 5) actuator = `The limb actuators have been replaced with a faster and more powerful variant, granting the robot the same.`;
	if (S.GiantRobot >= 6) cannon = `A custom 45 mm Gatling cannon rifle has been developed for ranged use`, ammo = `, though it lacks enough ammo storage for a main weapon.`;
	if (S.GiantRobot >= 7) heatsink = `Large heatsinks have been installed out of the back to solve a massive overheating problem. These heatsinks resemble wings, and tend to glow red with heat when in heavy use.`;
	if (S.GiantRobot >= 8) armor = ``, actuator = `Final actuator tweaks have allowed for the addition of exceptionally thick armor without any loss in speed or power.`;
	if (S.GiantRobot >= 9) ammo = `, with spare ammunition drums kept along the robot's waist.`;
	if (S.GiantRobot >= 10) missile = `Missile pods have been mounted on the shoulders.`;

	return `A prototype giant robot ${loc} rests in a gantry along the side of the arcology. The robot is as tall as a medium-sized office building, focusing on speed over other factors. ${power} ${armor} ${actuator} ${heatsink} The main armament is ${knife} ${cannon}${ammo} ${missile}`;
};

window.ms = function() {
	const V = State.variables,
		S = V.SFUnit;
	var a = `A cruise missile launch site has been constructed near the base of`,
		b = `outdated, something quickly rigged together to give the launch site something to fire in the case of an attack`,
		c = ``,
		d = ``,
		e = ``,
		f = ``,
		g = ``,
		h = ``;

	if (S.MissileSilo >= 2) b = `a modern missile`, c = `, tipped with a conventional warhead`;
	if (S.MissileSilo >= 3) d = `The launch systems have been overhauled, allowing a launch within seconds of an attack order being given.`;
	if (S.MissileSilo >= 4) e = `The missile engines have been tweaked, giving them a greater range.`;
	if (S.MissileSilo >= 5) f = `A passive radar has been installed, allowing the missile to follow moving targets.`;
	if (S.MissileSilo >= 6) a = `Several cruise missile launch sites have been constructed around`;
	if (S.MissileSilo >= 7) e = `The engine has been replaced, giving the missiles greater range and supersonic speeds.`;
	if (S.MissileSilo >= 8) g = `The ability to pick new targets should the original be lost has been added.`;
	if (S.MissileSilo >= 9) h = `The missile now uses its remaining fuel to create a thermobaric explosion, massively increasing explosive power.`;
	if (S.MissileSilo >= 10) c = ` that can be tipped with either a conventional or nuclear warhead`;

	return `${a} the arcology. The current missile armament is ${b}${c}. ${d} ${e} ${f} ${g} ${h}`;
};

window.AC = function() {
	const V = State.variables,
		S = V.SFUnit;
	var recom = `has been recommisioned from the Old World for $SF.Lower. It`,
		jets = `Formerly mothballed strike jets`,
		loc = ``,
		radar = ``,
		AA = ``,
		prop = ``,
		torp = ``,
		armor = ``,
		power = ``,
		scramble = ``;

	if (V.week % 6 === 0) { loc = `moored to the pier in the Naval Yard`; } else { loc = `patrolling the waters near $arcologies[0].name`; }
	if (S.AircraftCarrier >= 2) radar = `The island's radar and comms have been improved.`, recom = ``;
	if (S.AircraftCarrier >= 3) AA = `The antiair guns have been updated to automatically track and predict enemy aircraft movement.`;
	if (S.AircraftCarrier >= 4) jets = `Modern strike jets with state-of-the-art armaments`;
	if (S.AircraftCarrier >= 5) prop = `The propellers have been redesigned, granting greater speed with less noise.`;
	if (S.AircraftCarrier >= 6) torp = `An anti-torpedo system detects and destroys incoming torpedoes.`;
	if (S.AircraftCarrier >= 7) armor = `Additional armor has been added to the hull and deck.`;
	if (S.AircraftCarrier >= 8) power = `The power plant has been converted to provide nuclear power.`;
	if (S.AircraftCarrier >= 9) scramble = `The catapult has been converted to an electromagnetic launch system, halving the time it takes to scramble jets.`;
	if (S.AircraftCarrier >= 10) jets = `Attack VTOL from the converted for carrier capability`;

	return `An aircraft carrier ${recom} is ${loc}. ${jets} serve as its airpower. ${scramble} ${power} ${radar} ${AA} ${torp} ${prop} ${armor}`;
};

window.Sub = function() {
	const V = State.variables,
		S = V.SFUnit;
	var recom = `has been recommissioned from the old world, and`,
		reactor = `Because diesel engines provide power and breathing oxygen is kept in pressurized canisters, the sub must frequently surface.`,
		reactor1 = ``,
		cal = ``,
		hull = ``,
		tubes = ``,
		torpedoes = ``,
		sonar = ``,
		control = ``,
		missiles = ``;

	if (S.Sub >= 2) recom = ``, reactor = `A nuclear reactor provides power`, reactor1 = `, but because oxygen is still kept in pressurized canisters the sub must frequently surface to replenish its oxygen stocks.`;
	if (S.Sub >= 3) reactor1 = ` and an oxygen generator pulls O₂ from the surrounding seawater, allowing the submarine to remain underwater for months if necessary.`;
	if (S.Sub >= 4) cal = `Calibration of the propulsion systems has reduced the telltale hum of a moving sub to a whisper.`;
	if (S.Sub >= 5) hull = `The outer hull has been redesigned for hydrodynamics and sonar absorption.`;
	if (S.Sub >= 6) tubes = `The torpedo tubes have been redesigned for faster loading speeds`, torpedoes = `.`;
	if (S.Sub >= 7) sonar = `The passive sonar has been finely tuned to detect mechanical noises miles away.`;
	if (S.Sub >= 8) control = `The control room computers have been upgraded to automate many conn duties.`;
	if (S.Sub >= 9) torpedoes = `and launch more agile torpedoes.`;
	if (S.Sub >= 10) missiles = `The submarine has been outfitted with several cruise missiles to attack land or sea-based targets.`;

	return `An attack submarine ${recom} is moored to the pier of the Naval Yard. ${reactor}${reactor1} ${cal} ${hull} ${tubes}${torpedoes} ${sonar} ${control} ${missiles}`;
};

window.HAT = function() {
	const V = State.variables,
		S = V.SFUnit;
	var recom = `, has been recommissioned for use by $SF.Lower. It`,
		tons = `200`,
		skirt = ``,
		guns = ``,
		guns2 = ``,
		fans = ``,
  		speed = ``,
		turbines = ``,
		armor = ``,
		ramps = ``,
		HATframe = ``,
		loadout = ``;

	if (S.HAT >= 2) skirt = `The skirt has been upgraded to increase durabilty and improve cushion when travelling over uneven terrain and waves.`, recom = `,`;
	if (S.HAT >= 3) guns = `A minigun`, guns2 = `has been mounted on the front corners of the craft to defend against attackers.`;
	if (S.HAT >= 4) fans = `The turbines powering the rear fans`, speed = `acceleration and speed.`, turbines = `have been replaced with a more powerful version, allowing greater`;
	if (S.HAT >= 5) armor = `The armor protecting its cargo has been increased.`;
	if (S.HAT >= 6) tons = `300`, fans = `The turbines powering the rear fans and impeller`, speed = `acceleration, speed, and carrying capacity.`;
	if (S.HAT >= 7) guns = `A minigun and grenade launcher`;
	if (S.HAT >= 8) ramps = `The loading ramps have been improved, allowing for faster unloading.`;
	if (S.HAT >= 9) HATframe = `The frame has been widened and reinforced, allowing for more space on the deck.`;
	if (S.HAT >= 10) loadout = `An experimental loadout sacrifices all carrying capacity to instead act as a floating gun platform by mounting several rotary autocannons the deck, should the need arise.`;

	return `An air cushion transport vehicle, or hovercraft${recom} is parked on the pier of the Naval Yard, ready to ferry ${tons} tons of soldiers and vehicles. ${guns} ${guns2} ${fans} ${turbines} ${speed} ${skirt} ${armor} ${ramps} ${HATframe} ${loadout}`;
};

window.Interactions = function() {
	const V = State.variables,
		T = State.temporary, C = V.SFColonel;
	var choice = ``,
		gift = ``,
		giftdec = ``,
		giftdec2 = ``,
		Colonel = ``,
		join = ``,
		status = ``,
		status2 = ``,
		t = ``;
	if (V.SF.Units !== T.max) { status2 = `improved this week`
		if (V.SF.U > 0) {
			status = `being`;
		} else {
			status = `able to be`;
		}
	} else {
		status = `fully equipped and upgraded - nothing else can be done`;
	}
	if (V.SF.WG > 0 || (C.Talk > 0 || C.Fun > 0)) choice = `and you have already`;
	if (V.SF.WG > 0) gift = `been provided with`;
	if (V.choice < 2) {
		giftdec = `an extra @@.yellowgreen;<<print cashFormat(Math.ceil($CashGift))>>@@ in tribute`;
	} else {
		giftdec = ` a message of support, @@.green;improving@@`;
		if (V.choice < 3) {
		giftdec2 = `your reputation`;
		} else {
			giftdec2 = `the prosperity of $arcologies[0].name`;
		}
	}
	if (C.Talk > 0 || C.Fun > 0) Colonel = `time with The Colonel`, t = `spent`;
	if (V.SF.WG > 0) join = `in addition to `, t = `spening`;
	return `${status} ${status2} ${choice} ${gift} ${giftdec} ${giftdec2} ${join} ${t} ${Colonel}.`;
};