Back to Index Page generated: Dec 20, 2024, 7:22:09 AM

Expansion QTHI AntiZap

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description QTHI AntiZap devices are powerful anti-weapons which install in your shield generators. They come with a certain risk, though. QTHI AntiZap devices are powerful anti-weapons which install in your shield generators. They come with a certain risk, though.
Identifier oolite.oxp.QCS.QTHI_AntiZap oolite.oxp.QCS.QTHI_AntiZap
Title QTHI AntiZap QTHI AntiZap
Category Equipment Equipment
Author QCS QCS
Version 0.1 0.1
Tags equipment equipment
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL http://wiki.alioth.net/index.php/QTHI_AntiZap n/a
Download URL https://wiki.alioth.net/img_auth.php/5/57/QTHI_AntiZap_0.1.oxz n/a
License Creative Commons Attribution - Non-Commercial - Share Alike 4.0 license Creative Commons Attribution - Non-Commercial - Share Alike 4.0 license
File Size n/a
Upload date 1610873302

Documentation

Also read http://wiki.alioth.net/index.php/QTHI%20AntiZap

Equipment

Name Visible Cost [deci-credits] Tech-Level
QTHI AntiZap yes 10 2+
Sell QTHI AntiZap yes 0 2+

Ships

This expansion declares no ships.

Models

This expansion declares no models.

Scripts

Path
Config/script.js
this.name = "QTHI AntiZap";
this.author = "QCS";
this.copyright = "(C) 2017 QCS.";
this.licence = "CC-NC-by-SA 4.0";
this.description = "Worldscript for QTHI AntiZap by QCS.";
this.version = "0.1";

"use strict";

this.mode = 2;
this.activated = false;
this.armed = true;
this.ships = [];

this.shipLaunchedFromStation = function (station) {
	this.shipExitedWormhole();
};

this.shipExitedWormhole = function () {
	if (player.ship.equipmentStatus("EQ_QTHI_AntiZap") === "EQUIPMENT_OK") {
		this.activated = true;
		this.console();
		if (!this.shipsTimer) {
			this.shipsTimer = new Timer(this, this.evaluateShips, 0.25, 0.25);
		}
		this.shipsTimer.start();

	}
};

this.shipWillDockWithStation = function (station) {
	this.shipsTimer.stop();
};

this.toggleActive = function () {
	this.activated = !this.activated;
	this.console();
};

this.console = function () {
	if (this.activated) {
		player.consoleMessage("QTHI AntiZap active");
	} else {
		player.consoleMessage("QTHI AntiZap inactive.");
	}

	return;

	/*	if (this.activated) {
		switch (this.mode) {
		case 1:
			player.consoleMessage("QTHI AntiZap active, mode: light zap.");
			break;
		case 2:
			player.consoleMessage("QTHI AntiZap active, mode: medium zap.");
			break;
		case 3:
			player.consoleMessage("QTHI AntiZap active, mode: strong zap.");
			break;
		}
	} else {
		player.consoleMessage("QTHI AntiZap inactive.");
	}
*/
};

this.playerBoughtEquipment = function (equipmentKey) {
	if (equipmentKey === "EQ_QTHI_AntiZap_Sell") {
		player.ship.removeEquipment("EQ_QTHI_AntiZap");
		player.ship.removeEquipment("EQ_QTHI_AntiZap_Sell");
		player.credits += 100;
	}
};

this.shipTakingDamage = function (amount, whom, type) {
	if (player.ship.equipmentStatus("EQ_QTHI_AntiZap") !== "EQUIPMENT_OK") {
		return;
	}

	if (this.mode === 0) {
		return;
	}
	if (!this.armed) {
		return;
	}
	if (whom.currentWeapon.equipmentKey === "EQ_WEAPON_NONE") {
		this.slog("skipped attack from " + whom + " due to NONE weapon");
		return;
	}
	if (player.ship.energy < 32) {
		this.slog("skipped attack from " + whom + " due to LOW energy");
		return;
	}
	if (player.ship.temperature > 0.85) {
		this.slog("skipped attack from " + whom + " due to HIGH temperature");
		return;
	}
	if (amount > 0) {
		this.slog("skipped attack from " + whom + " due to shield down");
		return;
	}
	//TODO check which shield, return if shield is 0;
	// - shield must be operating 
	// - maybe only check if damage is 0 - if not, shield is down

	switch (this.mode) {
	case 1:
		whom.energy -= 10;
		whom.temperature += 0.1;
		player.ship.energy -= 3;
		break;
	case 2:
		whom.energy -= 15;
		whom.temperature += 0.3;
		player.ship.energy -= 5;
		if (Math.random() < 0.2) {
			whom.commsMessage("Help! My systems went totally haywire!");
		}
		whom.performStop();
//		whom.performTumble();
		this.ships[clock.absoluteSeconds + 5] = whom;
		break;
	case 3:
		whom.energy -= 20;
		whom.temperature += 0.25;
		whom.performTumble();
		player.ship.energy -= 10;
		break;
	}
	player.consoleMessage("QTHI AntiZap zapped enemy!", 6);
};

this.slog = function (s) {
	log(this.name, s);
};

this.evaluateShips = function () {
//	slog("evaluateShips");
	for (var s in this.ships) {
//		slog("Ship: " + s + ": " + this.ships[s]);
		if (clock.absoluteSeconds >= s) {
			this.ships[s].broadcastDistressMessage();
			delete this.ships[s];
		} else {
//			this.ships[s].performTumble();
			this.ships[s].performStop();
		}		
	}
};
Scripts/EQ_QTHI_AntiZap.js
this.author      = "QCS"; 
this.copyright   = "� 2017 QCS."; 
this.licence = "CC-BY-SA 4.0";
this.version     = "0.1"; 
this.name = "QTHI AntiZap EQ";
this.author = "QCS";
this.copyright = "(C) 2017 QCS.";
this.licence = "CC-NC-by-SA 4.0";
this.description = "Equipment script for AntiZap";
this.version = "0.1";

this.activated = function () {
	worldScripts["QTHI AntiZap"].toggleActive();
}

this.mode = function () {
	//for now, do nothing
	return;
	
	var mode = worldScripts["QTHI AntiZap"]._mode;
	mode++;
	if (mode > 3) {
		mode = 1;
	}
	ws._mode = mode;
	ws.console();
}