Back to Index | Page generated: Nov 12, 2024, 11:02:04 PM |
from Expansion Manager's OXP list | from Expansion Manifest | |
---|---|---|
Description | A scripted tweak which causes randomly some equipment to be totally destroyed when it gets damaged. | A scripted tweak which causes randomly some equipment to be totally destroyed when it gets damaged. |
Identifier | oolite.oxp.Thargoid.RealisticDamage | oolite.oxp.Thargoid.RealisticDamage |
Title | Realistic Damage | Realistic Damage |
Category | Mechanics | Mechanics |
Author | Thargoid | Thargoid |
Version | 1.00 | 1.00 |
Tags | mechanics | mechanics |
Required Oolite Version | ||
Maximum Oolite Version | ||
Required Expansions | ||
Optional Expansions | ||
Conflict Expansions | ||
Information URL | http://wiki.alioth.net/index.php/RealisticDamage_OXP | n/a |
Download URL | https://wiki.alioth.net/img_auth.php/5/55/Realistic_Damage_1.00.oxz | n/a |
License | Creative Commons Attribution - Non-Commercial - Share Alike 3.0 license with clauses - see readme file | Creative Commons Attribution - Non-Commercial - Share Alike 3.0 license with clauses - see readme file |
File Size | n/a | |
Upload date | 1610873301 |
Also read http://wiki.alioth.net/index.php/Realistic%20Damage
Realistic Damage OXP by Thargoid. A small and simple script OXP, which makes equipment damage a little more realistic. In the vanilla game, most equipment can become damaged but it will never be fully destroyed. This script modifies that, and gives a chance whenever an item is damaged that it will be broken beyond repair and completely destroyed. In such cases repair will not be possible and the item will need to be purchased again from scratch. The base chance of a damaged piece of equipment being totally destroyed is between 5-10%, and is also weighted by the items complexity (it's tech level). For OXP makers, if an item is destroyed the event this.equipmentDestroyed is sent to all other loaded world scripts, with the equipment entity as the parameter (in the same way as this.equipmentDamaged). The script also has a 0.25s delay after the equipmentDamaged trigger, so immediately self-repairing OXP equipment will be immune to destruction. Requires v1.76 or later of Oolite. -------------------------------------------------------------- License: This OXP is released under the Creative Commons Attribution - Non-Commercial - Share Alike 3.0 license with the following clauses: * Whilst you are free (and encouraged) to re-use any of the scripting, models or texturing in this OXP, the usage must be distinct from that within this OXP. Unique identifiers such as (but not limited to) unique shipdata.plist entity keys, mission variables, script names (this.name), equipment identity strings (EQ_), description list arrays and entity roles must not be re-used without prior agreement. Basically if it's unique or would identify or overwrite anything in the original OXP, then you may not re-use it (for obvious compatibility reasons). * rebundling of this OXP within another distribution is permitted as long as it is unchanged. The following derivates however are permitted and except from the above: * the conversion of files between XML and openStep. * the merging of files with other files of the same type from other OXPs. * The license information (either as this file or merged into a larger one) must be included in the OXP. * Even though it is not compulsory, if you are re-using any sizable or recognisable piece of this OXP, please let me know :) -------------------------------------------------------------- Instructions: Unzip the file, and then move the folder "Realistic Damage 1.00.oxp" to the AddOns directory of your Oolite installation. -------------------------------------------------------------- Version history: 16/08/2012 - Version 1.00, initial release. -------------------------------------------------------------- Acknowledgements: With thanks to Eric Walch for the discussion on setting up unique timer IDs for multiple concurrent function triggering, and to IronFist for beta-testing and bug reports.
Path | |
---|---|
Config/script.js | this.name = "realisticDamage.js"; this.author = "Thargoid"; this.copyright = "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt"; this.description = "Chance for damaged equipment to be totally destroyed"; this.version = "1.00"; this.startUp = function() { this.scriptDelay = new Timer(this, this.$scanScripts, 0.25); } this.$scanScripts = function() { // delay of 0.25s to ensure all worldscripts are loaded before scanning this.scriptArray = []; // array of loaded worldscripts which contain equipmentDestroyed function this.damagedArray = []; // array of damaged equipment to be checked for destruction if(worldScriptNames.length > 0) { var scriptCounter = 0 ; // reset the counter for(scriptCounter = 0;scriptCounter<worldScriptNames.length;scriptCounter++) { if(worldScriptNames[scriptCounter] && worldScripts[worldScriptNames[scriptCounter]] && worldScripts[worldScriptNames[scriptCounter]].equipmentDestroyed) { this.scriptArray.push(worldScriptNames[scriptCounter]); } } } } this.shipWillLaunchFromStation = function(station) { this.itemCounter = 0; } this.equipmentDamaged = function(equipment) { this.damagedArray.push(equipment); this["checkDelay"+(this.itemCounter++)] = new Timer(this, this.$checkEquipment, 0.25); // unique timer ID for each item, in case of multiple concurrent damages } this.$checkEquipment = function() { if(!this.damagedArray || this.damagedArray.length === 0) { return; } this.damagedEquipment = this.damagedArray.pop(); if(player.ship.equipmentStatus(this.damagedEquipment) !== "EQUIPMENT_DAMAGED") { return; } this.equipmentItem = EquipmentInfo.infoForKey(this.damagedEquipment); this.equipLevel = this.equipmentItem.effectiveTechLevel; this.chance = 0.05 + (0.05 * Math.random()) + ((this.equipLevel - 7) * 0.01); if(Math.random() < this.chance) { this.link = (this.equipmentItem.name.length > 1 && this.equipmentItem.name.charAt(this.equipmentItem.name.length-1) === "s" && this.equipmentItem.name.charAt(this.equipmentItem.name.length-2) !== "s") ? " have " : " has "; player.consoleMessage(this.equipmentItem.name + this.link + "been destroyed!"); player.ship.removeEquipment(this.equipmentItem); if(this.scriptArray && this.scriptArray.length > 0) { var scriptCounter = 0 ; // reset the counter for(scriptCounter = 0;scriptCounter<this.scriptArray.length;scriptCounter++) { worldScripts[this.scriptArray[scriptCounter]].equipmentDestroyed(this.damagedEquipment); } } } } |