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

Expansion AsteroidRemover

Content

Warnings

  1. http://wiki.alioth.net/index.php/AsteroidRemover -> 404 Not Found
  2. 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 Moves static asteroids on a really random position Moves static asteroids on a really random position
Identifier oolite.oxp.SMax.AsteroidRandomizer oolite.oxp.SMax.AsteroidRandomizer
Title AsteroidRemover AsteroidRemover
Category Ambience Ambience
Author SMax SMax
Version 0.1 0.1
Tags Asteroid Asteroid
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/b/b1/AsteroidRandomizer_0.1.oxz n/a
License CC-BY-NC-SA 4.0 CC-BY-NC-SA 4.0
File Size n/a
Upload date 1610873443

Documentation

README.md

AsteroidRandomizer

By S Max

Moves static asteroids on a really random position

# 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
##[0.1] - 2016-09-10

* 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
Config/script.js
/* global system log*/

this.name = "AsteroidRandomizer";
this.author = "SMax";
this.copyright = "2016 SMax";
this.licence = "CC-BY-NC-SA 4.0";
this.description = "Moves static asteroids on a really random position";
this.version = "0.1";

"use strict";

this._DEBUG = false;

this._DIFF_RADIUS = 5000;

this.startUpComplete = function() {
	this._RandomAsteroids();
};

this.shipWillExitWitchspace = function() {
	this._RandomAsteroids();
};

this._logger = function(msg) {
	if (this._DEBUG) {
		log(this.name, msg);
	}
};

this._RandomAsteroids = function() {
	var t = system.shipsWithPrimaryRole("asteroid");

	if (t) {
		this._logger("Asteroids in system: " + t.length);
		for (var i = 0; i < t.length; i++) {
			if (this._testShip(t[i])) {
				var v = [];
				for (var j = 0; j < 3; j++) {
					v[j] = Math.random(); // Random number [ 0, 1 )
					v[j] -= 0.5; // Normalize to 0 - [ -0.5, 0.5 )
					v[j] *= this._DIFF_RADIUS * 2; // Set length as _DIFF_RADIUS - [ -_DIFF_RADIUS, _DIFF_RADIUS )
				}
				var pos = t[i].position.add(v); // Adding a random vector to the position
				this._logger("Move: " + t[i].position + " -> " + pos + " diff: " + v);
				t[i].position = pos;
			}
		}
	}
};

this._testShip = function(ship) {
	return ship.isShip && ship.AI == "dumbAI.plist";
};