Back to Index Page generated: May 8, 2024, 6:16:03 AM

Expansion Trophy Collector

Content

Warnings

  1. Information URL mismatch between OXP Manifest and Expansion Manager string length at character position 0

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Keep track of your kills. When in-flight, view your 10 last kills (Bounty Log) in an MFD. When docked, view your all-time kills (Trophy Collection) along with a kill log (Trophy Log) of 38 events in the interfaces screen. Keep track of your kills. When in-flight, view your 10 last kills (Bounty Log) in an MFD. When docked, view your all-time kills (Trophy Collection) along with a kill log (Trophy Log) of 38 events in the interfaces screen.
Identifier oolite.oxp.spara.trophy_collector oolite.oxp.spara.trophy_collector
Title Trophy Collector Trophy Collector
Category Equipment Equipment
Author spara spara
Version 2.3.1 2.3.1
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL n/a
Download URL https://wiki.alioth.net/img_auth.php/9/9e/TrophyCollector.oxz n/a
License CC-BY-NC-SA 3.0 CC-BY-NC-SA 3.0
File Size n/a
Upload date 1610873393

Documentation

Also read http://wiki.alioth.net/index.php/Trophy%20Collector

TrophyCollector_readme_&_license.txt

Trophy Collector OXP ver 2.3.1 (27.06.2020)

Author: spara (Mika SpÄra)

_The_Story_

A usual situation at a GalCop station. After a hard days work, pilots are sitting in a bar and having a drink or two. After a while the talk goes to their Elite rankings. And it all ends up in a fight over whose ranking is better than others. The main argument being something like: "I have killed at least 500 Kraits..."

GalCop authorities recognized the problem and ordered a solution from Spara, PrOog & Ming Agency.

The solution is a list of killed shiptypes and quantities. The list is called the Trophy Collection. You kill someone and you get a trophy, simple as that. 

When you are in flight, your ship starts collecting trophies. You can view your 10 latest trophies from a MFD screen as a Bounty Log. 

You can view a log of trophies collected including their bounties and systems in a chronological list (MANIFEST - F7). This list is called Trophy Log. Log holds 38 entries.

When you are docked, you can view your Trophy Log of 38 entries and full Trophy Collection from the interfaces screen (F4). Collection shows ship types and quantity of trophies collected. Log shows ship type, bounty received and system the trophy was achieved in.

_Requirements_

Oolite version 1.79.

_Installing_

Install the OXP by copying TrophyCollector.oxp to your AddOns-folder.

------

This work is licensed under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/

Equipment

Name Visible Cost [deci-credits] Tech-Level
Trophy Log MFD yes 3000 5+
Remove Trophy Log MFD yes 100 5+

Ships

This expansion declares no ships. This may be related to warnings.

Models

This expansion declares no models. This may be related to warnings.

Scripts

Path
Config/script.js
"use strict";
this.name        = "trophy_col";
this.author      = "spara";
this.copyright   = "2012-2014 Mika Spara";
this.licence     = "CC BY-NC-SA 3.0";
this.description = "Manage Trophy Collection";
this.version     = "2.3.0";

this.startUp = function() {
	this.$lines = 19; 	//Number of rows printed to screen. Number of entries shown is 2*rows.
	if (!missionVariables.trophyArray) {
		this.$trophyArray = new Array();
	}
	else {
		this.$trophyArray = JSON.parse(missionVariables.trophyArray);
	}
	if (!missionVariables.trophyLog) {
		this.$trophyLog = new Array();
	}
	else {
		this.$trophyLog = JSON.parse(missionVariables.trophyLog);
	}
	this.$nextPage = false;
	this.$printInd = 0;
	this.$showLog = false;
	this.$cleanTrophyCollection();
	this.$trophyArrayFull = this.$trophyArray;
}

this.startUpComplete = function() {
	this.$addTrophyInterface();
	if (this.$isBigGuiActive() == true) this.$lines = 25;
}

//Clean bogus entries from the array.
this.$cleanTrophyCollection = function() {
	var bogusEntries = ["?"];
	for (var j = this.$trophyArray.length - 1; j >= 0; j--) {
		if (bogusEntries.indexOf(this.$trophyArray[j][0])!== -1)
			this.$trophyArray.splice(j,1);
	}
}

this.playerWillSaveGame = function () {
	missionVariables.trophyArray = JSON.stringify(this.$trophyArray);
	missionVariables.trophyLog = JSON.stringify(this.$trophyLog);
}

//Add new trophy to the collection.
this.shipKilledOther = function(whom, damageType) {
	if (!whom.hasRole("escape-capsule") && (whom.isPiloted || whom.isDerelict || whom.hasRole("tharglet") || whom.hasRole("thargon"))) {
		var name = expandMissionText("trophy_"+whom.dataKey);
		if (!name) name = whom.name;
		if (whom.primaryRole == "pirate-cove") //distinguish pirate coves from rock hermits
			name = "Pirate Cove";
		this.$trophyArray.unshift([name, formatCredits(whom.bounty, true, true) +", "+system.name]);
		if (this.$trophyArray.length == 2 * this.$lines + 1)
			this.$trophyArray.pop();
		this.$addTrophyToCollection(name);
		this.$setMFD();
	}
}

//Go to next page, if more than one screen of trophies.
this.missionScreenEnded = function() {
	if (this.$nextPage) {
		this.$showTrophyScreen("trophy_collection");
	}
	//show log after kill pages
	else if (this.$showLog) {
		this.shipWillLaunchFromStation();
		this.$showTrophyScreen("log");
		this.shipDockedWithStation();
		this.$nextPage = false;
		this.$printInd = 0;
	}
}

//Show mission screen of trophies
this.$showTrophyScreen = function(mode) {
	var largeGUI = this.$isBigGuiActive();
	this.$lines = 19;
	if (largeGUI == true) this.$lines = 25;
	//show log after kill pages
	this.$showLog = true;
	this.$nextpage = false;
	var titleText = "Trophy Collection";
	var bgImage = "trophy_bg.png";
	if (largeGUI == true) bgImage = "trophy_bg_lg.png";
	if (mode === "log") {
		titleText = "Trophy Log";
		bgImage = "trophy_inflight.png";
		if (largeGUI == true) bgImage = "trophy_inflight_lg.png";
	}
	var messageText = this.$createColumns();
	mission.runScreen({
		title: titleText,
		screenID:"trophy-collector",
		message: messageText,
		background: bgImage,
		allowInterrupt: true,
		exitScreen:"GUI_SCREEN_INTERFACES"
	});
}

//Swap collection to log on launch. Reset page count.
this.shipWillLaunchFromStation = function(station) {
	this.$trophyArray = this.$trophyLog;
	this.$printInd = 0;
	this.$nextPage = false;
	this.$setMFD();
}

this.$setMFD = function() {
	// no need to set the MFD if we're docked
	if (player.ship.isInSpace == false) return;
	if (player.ship.equipmentStatus("EQ_TROPHY_MFD") === "EQUIPMENT_OK") {
		var message = ""
		var line = 0
		if (this.$trophyArray.length > 0) {
			while (line < 10 && line < this.$trophyArray.length) {
				var details = this.$trophyArray[line][1].split(", ")
				message = message + this.$truncate(this.$trophyArray[line][0], details[0], details[1]) + "\n";
				line++;
			}
		}
		else message = "No trophies logged yet.\n\nGo hunt some trophies, Commander.";
		player.ship.setMultiFunctionText("trophy_mfd", message);
	}
	else player.ship.setMultiFunctionText("trophy_mfd", null);
}

this.equipmentDamaged = this.equipmentDestroyed = function(equipment) {
	if (equipment === "EQ_TROPHY_MFD") {
		player.ship.setMultiFunctionText("trophy_mfd", null);
	}
}

this.equipmentRepaired = function(equipment) {
	if (equipment === "EQ_TROPHY_MFD") {
		this.$setMFD();
	}
}

this.playerBoughtEquipment = function(equipment) {
	if (equipment === "EQ_TROPHY_MFD_REMOVE") {
		player.ship.removeEquipment("EQ_TROPHY_MFD");
		player.ship.removeEquipment("EQ_TROPHY_MFD_REMOVE");
	}
}

//squeezing looks ugly, so I'll truncate instead.
this.$truncate = function(tShip, tBounty, tSystem) {
	var line = tBounty + ", " + tShip + " (" + tSystem + ")";
	//first we chop the system down to 4 chars max
	while (global.defaultFont.measureString(line) > 14 && tSystem.length > 4) {
		tSystem = tSystem.slice(0, -1);
		line = tBounty + ", " + tShip + " (" + tSystem + ".)";
	}
	//if that's not enough, then we chop the shipname
	while (global.defaultFont.measureString(line) > 14) {
		var lastChar = tShip.charAt(tShip.length - 1);
		tShip = tShip.slice(0, -1);
		if (lastChar !== " " && tShip.charAt(tShip.length - 1) !== " ")
			line = tBounty + ", " + tShip + ". (" + tSystem + ".)";
		else
			line = tBounty + ", " + tShip + " (" + tSystem + ".)";
	}
	return line;
}

//Swap log to collection on docking.
this.shipDockedWithStation = function(station) {
	this.$trophyLog = this.$trophyArray;
	this.$trophyArrayFull.sort();
	this.$trophyArray = this.$trophyArrayFull;
	this.$addTrophyInterface();
	this.$showLog = false;
}

//Merge new trophy into the collection.
this.$addTrophyToCollection = function(name) {
	for (var j = 0; j < this.$trophyArrayFull.length; j++) {
		if (this.$trophyArrayFull[j][0] == name) {
			this.$trophyArrayFull[j][1] = this.$trophyArrayFull[j][1] + 1;
			return;
		}
	}
	this.$trophyArrayFull.push([name, 1]);
}

this.$addTrophyInterface = function() {
	player.ship.dockedStation.setInterface("trophy_collection",{
		title: "Trophy collection",
		category: "Statistical",
		summary: "Your collection of Trophies. You get trophies by killing piloted or derelict ships including thargoid drones and excluding escape pods.",
		callback: this.$showTrophyScreen.bind(this)
	});
}

//Format data into two columns.
this.$createColumns = function() {
	var columnized = "";
	var nameWidth = 0;
	var countWidth = 0;
	var spaceWidth = defaultFont.measureString(" ");
	var tabChar = String.fromCharCode(31);//hair-space
	var tabCharWidth = defaultFont.measureString(String.fromCharCode(31));//hair-space
	var entryWidth = 0;
	var start = this.$printInd;
	var lines = this.$lines; //maximum number of rows
	//less entries than rows?
	if (this.$trophyArray.length - start < lines)
		lines = this.$trophyArray.length - start;
	//last page?
	if (this.$trophyArray.length - (start+1) < 2*lines) {
		this.$printInd = 0;
		this.$nextPage = false;
	}
	else {
		this.$printInd = this.$printInd + 2 * lines;
		this.$nextPage = true;
	}
	var trunkName = "";
	for (var i = 0; i < lines ; i++) {
		nameWidth = defaultFont.measureString(this.$trophyArray[start+i][0]);
		countWidth = defaultFont.measureString("("+this.$trophyArray[start+i][1]+")");
		entryWidth = nameWidth + spaceWidth + countWidth;
		//Two column layout
		if (start+i+lines < this.$trophyArray.length) {

			//Left column
			if (entryWidth <= 15) {
				columnized = columnized + this.$trophyArray[start+i][0]+" ("+this.$trophyArray[start+i][1]+")";
				for (var j = 0; j < (17 - entryWidth) / tabCharWidth; j++)//spaceWidth
					columnized = columnized + tabChar;
			}
			else {
			//Entry too wide, truncate
				trunkName = this.$trophyArray[start+i][0];
				while (defaultFont.measureString(trunkName)+countWidth > 15) {
					trunkName = trunkName.substring(0,trunkName.length-1);
				}
				columnized = columnized + trunkName + "("+this.$trophyArray[start+i][1]+")";
				entryWidth = defaultFont.measureString(trunkName + "("+this.$trophyArray[start+i][1]+")");
				for (var j = 0; j < (17 - entryWidth) / tabCharWidth; j++)
					columnized = columnized + tabChar;
			}
			nameWidth = defaultFont.measureString(this.$trophyArray[start+i+lines][0]);
			countWidth = defaultFont.measureString("("+this.$trophyArray[start+i+lines][1]+")");
			entryWidth = nameWidth + spaceWidth + countWidth;
			//Right column
			if (entryWidth <= 15)
				columnized = columnized + this.$trophyArray[start+i+lines][0]+" ("+this.$trophyArray[start+i+lines][1]+")\n";
			else {
			//Entry too wide, truncate
				trunkName = this.$trophyArray[start+i+lines][0];
				while (defaultFont.measureString(trunkName)+countWidth > 15)
					trunkName = trunkName.substring(0,trunkName.length-1);
				columnized = columnized + trunkName + "("+this.$trophyArray[start+i+lines][1]+")\n";
			}
		}
		//One column layout
		else {
			if (entryWidth <= 32)
				columnized = columnized + this.$trophyArray[start+i][0]+" ("+this.$trophyArray[start+i][1]+")\n";
			else {
			//Entry too wide, truncate
				trunkName = this.$trophyArray[start+i][0];
				while (defaultFont.measureString(trunkName)+countWidth > 32)
					trunkName = trunkName.substring(0,trunkName.length-1);
				columnized = columnized + trunkName + "("+this.$trophyArray[start+i][1]+")\n"
			}
		}
	}
	//No trophies?
	if (this.$trophyArray.length == 0) {
		columnized = "No trophies collected yet.\n\nGo hunt some trophies Commander.";
		this.$showLog = false;
	}
	return columnized;
}

//-------------------------------------------------------------------------------------------------------------
// returns true if a HUD with allowBigGUI is enabled, otherwise false
this.$isBigGuiActive = function() {
	if (oolite.compareVersion("1.83") <= 0) {
		return player.ship.hudAllowsBigGui;
	} else {
		var bigGuiHUD = ["XenonHUD.plist", "coluber_hud_ch01-dock.plist"]; 	// until there is a property we can check, I'll be listing HUD's that have the allow_big_gui property set here
		if (bigGuiHUD.indexOf(player.ship.hud) >= 0) {
			return true;
		} else {
			return false;
		}
	}
}