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

Expansion Death Comms

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 Gives pilots that get killed in battle a final comms message. Gives pilots that get killed in battle a final comms message.
Identifier oolite.oxp.phkb.DeathComms oolite.oxp.phkb.DeathComms
Title Death Comms Death Comms
Category Ambience Ambience
Author phkb phkb
Version 1.7 1.7
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/7/74/DeathComms.oxz n/a
License CC BY-NC-SA 4.0 CC BY-NC-SA 4.0
File Size n/a
Upload date 1610873337

Documentation

Also read http://wiki.alioth.net/index.php/Death%20Comms

readme.txt

Death Comms
By Nick Rogers

With thanks to ShipBuilder, Smivs, Disembodied, Diziet Sma, Wildeblood, maaarcooose, Gimbal Locke, Knotty, and Tricky who contributed ideas to the thread mentioned below.

Overview
========
This OXP attempts to add a bit of flavour to battles by sometimes having ships give a final comms message when they die. The message should only occur if the ship still has a pilot in it (ie. the pilot didn't eject in an escape pod), and should only apply to normal ships (not police or Thargoids). Comments (and suggestions for additional comms examples) welcome!

Notes for OXP Developers
========================
This OXP uses a coding methodology described as "Monkey Patching". A Monkey Patch allows for existing code to be amended or modified without the foreknowledge of the original author. There is a body of evidence that suggests that Monkey Patching should only be used when there is no other option.

In this case, in order to keep the logic of this OXP as simple as possible, it is necessary. This OXP uses the "shipDied" event of NPC ships to determine when to send a comms message. But other OXP's may already be using this event for their own purposes. So to keep those OXP's functioning, and to add my code to the same event, I am using a Money Patch to rename the pre-existing script, and calling the renamed script from my own "shipDied" event.

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

Version History
===============
1.7
- Spelling corrections.

1.6
- Increased the frequency of comms messages appearing, just slightly.
- Updated exclusion list to make sure subentities, wreckage and nav buoys don't get included.
- Added a lot more comms variations, based on info in this forum link: http://aegidian.org/bb/viewtopic.php?f=4&t=13046

1.5
- Reduced the frequency of comms messages appearing.
- Added some more comms variations.

1.4
- Added some more comms variations.

1.3
- Added check for autoWeapons to determine whether the death comms script can be attached.

1.2
- Further tweaks to the script logic to make it fully compatible with other OXP's.

1.1
- Tweaks to the script logic to make it play better with other OXP's.
- Changed the manifest file to allow use with Oolite 1.80.

1.0
- Initial release.

Equipment

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

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
Scripts/deathcomms.js
"use strict";
this.name        = "DeathComms";
this.author      = "phkb";
this.copyright   = "2015 phkb";
this.description = "Adds the possibility of a comms message when ships die in battle";
this.licence     = "CC BY-NC-SA 4.0";

this._excludeRoles = ["police"];

//-------------------------------------------------------------------------------------------------------------
this.shipSpawned = function(ship) {
	if (ship.isStation == false &&
		ship.isThargoid == false &&
		ship.isPiloted == true &&
		ship.isSubEntity == false &&
		ship.isWeapon == false &&
		ship.isCargo == false &&
		ship.isRock == false &&
		ship.primaryRole != "wreckage" &&
		ship.scanClass != "CLASS_BUOY" &&
		this._excludeRoles.indexOf(ship.primaryRole) == -1) {
		// are autoWeapons on? if so, we can assume this is a standard ship, not a special OXP ship
		if (ship.autoWeapons == true) {
			// is there an existing script in shipDied?
			// move it to a new spot
			ship.script.$dc_old_shipDied = ship.script.shipDied;
			ship.script.shipDied = this.$dc_shipDied;
		}
	}
}

//-------------------------------------------------------------------------------------------------------------
this.$dc_shipDied = function(whom, why) {
	if (this.ship.script.$dc_old_shipDied) this.ship.script.$dc_old_shipDied(whom, why);
	
	if (this.ship.isDerelict == false && why != "removed" && Math.random() > 0.75) {
		//log(this.name, "Death Comms - sending comms");
		this.ship.commsMessage(expandDescription("[deathcomms_message]"), player.ship);
	}
}