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

Expansion Carriers with turrets

Content

Warnings

  1. Syntax Error Config/shipdata-overrides.plist[219:58] extraneous input '.0' expecting {')', ','}
  2. Found 1 issues in Config/shipdata-overrides.plist
  3. Required Expansions mismatch between OXP Manifest and Expansion Manager at character position 0059 (DIGIT ZERO vs LATIN SMALL LETTER N)
  4. No version in dependency reference to oolite.oxp.Norby.Carriers:null

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Short range turrets applied on Carriers as a big help in close defese. Requires Carriers OXP. Short range turrets applied on Carriers as a big help in close defese. Requires Carriers OXP.
Identifier oolite.oxp.Norby.Carriers_with_turrets oolite.oxp.Norby.Carriers_with_turrets
Title Carriers with turrets Carriers with turrets
Category Ships Ships
Author Norby Norby
Version 1.0 1.0
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
  • oolite.oxp.Norby.Carriers:0
  • oolite.oxp.Norby.Carriers:
  • Optional Expansions
    Conflict Expansions
    Information URL http://wiki.alioth.net/index.php/Carriers n/a
    Download URL https://wiki.alioth.net/img_auth.php/7/7c/Carriers_with_turrets_1.0.oxz n/a
    License CC BY-NC-SA 4.0 CC BY-NC-SA 4.0
    File Size n/a
    Upload date 1610873343

    Documentation

    Also read http://wiki.alioth.net/index.php/Carriers%20with%20turrets

    Equipment

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

    Ships

    Name
    Main Turret
    Carrier Turret

    Models

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

    Scripts

    Path
    Scripts/carriers-turret.js
    "use strict";
    this.name        = "carriers-turret";
    this.author      = "Norby";
    this.copyright   = "2015 Norbert Nagy";
    this.description = "Place turret inside of the shields and send message if a turret gone.";
    this.licence     = "CC BY-NC-SA 4.0";
    
    this.$Carriersturret_HitTimer = null;
    
    //this.shipBeingAttacked = function(whom) {
    this.shipTakingDamage = function(amount, whom, type) {
    	if(amount<=0) return;//player shield can take the whole damage
    //if(this.ship.isPlayer) {var a=Math.round(amount); var e=Math.round(this.ship.energy);}//debug
    	if(this.ship.scriptInfo.hardarmour > 0) { //Hard Armour support
    		var d = Math.min(this.ship.scriptInfo.hardarmour, amount);
    		if( this.ship.energy > 5 ) this.ship.energy += d; //hardly explode without if
    		amount -= d;
    	}
    //if(this.ship.isPlayer) player.commsMessage(a+" "+Math.round(amount)+" "+e+" "+Math.round(this.ship.energy));//debug
    	if(amount<=0) return;//extra check after armor
    	var energydamage = amount;
    	var owner = this.ship.owner;
    	if(owner.isValid && !this.ship.scriptInfo.noturretshield
    		&& !owner.scriptInfo.noturretshield) {//can disable turret shield in shipdata.plist
    		var angle = 3.14;//unknown attacker assumed in front
    		if(whom && whom.isValid)
    			angle = owner.vectorForward.angleTo(owner.position.subtract(whom.position));
    		if(owner.isPlayer) {
    			if(angle > 1.57) {//forward
    				if(energydamage > owner.forwardShield) { //hit the shield first
    					this.ship.energy += owner.forwardShield;
    					energydamage -= owner.forwardShield;
    					owner.forwardShield = 0;
    				} else {
    					if(owner.isPlayer) var d = Math.round(this.ship.energy);//debug
    					this.ship.energy += energydamage;
    					if(this.ship.isPlayer) player.console(this.ship.name+" "+d+" "+Math.round(this.ship.energy)
    						+" "+Math.round(amount));//debug					
    					owner.forwardShield -= energydamage;
    					energydamage = 0;
    				}
    			} else { //aft
    				if(energydamage > owner.aftShield) {
    					this.ship.energy += owner.aftShield;
    					energydamage -= owner.aftShield;
    					owner.aftShield = 0;
    				} else {
    					this.ship.energy += energydamage;
    					owner.aftShield -= energydamage;
    					energydamage = 0;
    				}
    			}
    		} else if(worldScripts["customshields"]) { //NPC, check if CustomShields installed
    			if(angle < 1.57) {
    				if(energydamage > owner.script.customshieldsaftshieldlevel) {
    					this.ship.energy += owner.script.customshieldsaftshieldlevel;
    					energydamage -= owner.script.customshieldsaftshieldlevel;
    					owner.script.customshieldsaftshieldlevel = 0;
    				} else {
    					this.ship.energy += energydamage;
    					owner.script.customshieldsaftshieldlevel -= energydamage;
    					energydamage = 0;
    				}
    			} else {
    				if(energydamage > owner.script.customshieldsforwardshieldlevel) {
    					this.ship.energy += owner.script.customshieldsforwardshieldlevel;
    					energydamage -= owner.script.customshieldsforwardshieldlevel;
    					owner.script.customshieldsforwardshieldlevel = 0;
    				} else {
    					this.ship.energy += energydamage;
    					owner.script.customshieldsforwardshieldlevel -= energydamage;
    					energydamage = 0;
    				}
    			}			
    		}
    	}
    	if(energydamage > 0 && owner.isPlayer) {
    		if(!this.$Carriersturret_HitTimer)  { 
    			//delayed show the energy of the turret after hit to avoid too many messages
    			this.$Carriersturret_HitTimer = new Timer(this, this.$Carriersturret_Hit, 1);
    		}
    	}
    }
    
    this.$Carriersturret_Pos = function() {
    	var pos = "";
    	if(this.ship.name === "Main Turret") pos+="Main ";//Main Turret always placed in Front
    	else if(this.ship.position.z > 2)  pos+="Fore ";
    	if(this.ship.position.z < -105)  pos+="Aft "; //side and top turrets are 104.85m behind the center
    	if(this.ship.position.x > 2)  pos+="Port ";
    	if(this.ship.position.x < -2)  pos+="Starboard ";
    	if(this.ship.position.y > 2)  pos+="Up ";
    	if(this.ship.position.y < -2)  pos+="Down ";
    	return(pos);
    }
    
    this.$Carriersturret_Hit = function() {
    	player.consoleMessage(this.$Carriersturret_Pos()+"Turret "+Math.ceil(this.ship.energy)+" armor left.");
    	if(this.$Carriersturret_HitTimer) {
    		this.$Carriersturret_HitTimer.stop();
    		delete this.$Carriersturret_HitTimer;
    	}
    }
    
    this.shipDied = function () {
    	if(this.ship.owner === player.ship) {
    		player.commsMessage(this.$Carriersturret_Pos()+"Turret gone.");
    	}
    };
    
    Scripts/carriers_with_turrets.js
    "use strict";
    this.name        = "carriers_with_turrets";
    this.author      = "Norby";
    this.copyright   = "2015 Norbert Nagy";
    this.licence     = "CC BY-NC-SA 4.0";
    this.description = "Carriers with turrets";
    
    //The simple existence of this script make detectable in any js that Carriers has turrets:
    //
    // if( worldScripts.carriers_with_turrets ) {
    //	/* do something with turreted Carriers */
    // }