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

Expansion Extra Rock Hermits

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Adds some extra Rock Hermit styles, based on Griff's Space Bar model. Adds some extra Rock Hermit styles, based on Griff's Space Bar model.
Identifier oolite.oxp.phkb.ExtraRockHermits oolite.oxp.phkb.ExtraRockHermits
Title Extra Rock Hermits Extra Rock Hermits
Category Dockables Dockables
Author phkb, Griff phkb, Griff
Version 1.5 1.5
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL https://wiki.alioth.net/index.php/Extra_Rock_Hermits n/a
Download URL https://wiki.alioth.net/img_auth.php/1/15/ExtraRockHermits_1.5.oxz n/a
License CC-BY-SA-NC 4.0 CC-BY-SA-NC 4.0
File Size n/a
Upload date 1712669834

Documentation

Also read http://wiki.alioth.net/index.php/Extra%20Rock%20Hermits

readme.txt

Extra Rock Hermits
by phkb

Overview
========
This mod is intended to add more variety to the types of Rock Hermits in various systems. Rock Hermits from this pack can have extra facilities built on the surface of the rock, and can even have an external landing pad in the more technologically advanced systems. If the External Docking System is installed, the player will be able to dock at the station at the external pad.

Default Rock Hermits will be replaced with ones from this pack in about 35% of cases. 

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/

Station models and textures courtesy of Griff, from his Space Bar station.

Asteroid textures from:
<a href="https://www.freepik.com/free-photo/empty-cement-background-decoration_1240107.htm#query=asteroid%20texture&position=19&from_view=keyword&track=ais&uuid=1581e164-4b2b-4688-adf3-8c12f2b51dd3">Image by topntp26</a> on Freepik
<a href="https://www.freepik.com/free-photo/concrete-wall-texture_1119956.htm#page=2&query=asteroid%20texture&position=46&from_view=keyword&track=ais&uuid=863c61d5-a1d1-4a10-94b2-388d011af0d1">Image by kues1</a> on Freepik
<a href="https://www.freepik.com/free-photo/stone-texture-background_1120405.htm#query=asteroid%20textures&position=3&from_view=search&track=ais&uuid=bd750ff9-d5d2-4b07-af4b-82f464e62351">Image by kues1</a> on Freepik
<a href="https://www.freepik.com/free-photo/stone-texture_1033837.htm#page=3&query=asteroid%20textures&position=41&from_view=search&track=ais&uuid=f4c560e8-4a67-4ab9-88da-91995df7284e">Image by kues1</a> on Freepik

Version History
===============
1.5
- Addressed issue where some extra rock hermits are becoming pirate coves, and missing the extra property Vimana-X HUD needs to distinguish between them.

1.4
- Fixed issue that would prevent Astromines from replacing Rock Hermits in Communist systems if the Commies OXP is installed.
- Recreated normal maps for rock types 2, 3 and 4, as the originals had some issues.

1.3
- Fixed incorrectly named descriptions.plist file.

1.2
- Updated to latest EDS interface specification.

1.1
- Fixed issue where the external dock flashers were not being removed in all cases if the External Dock System is not installed.
- Expanded number of subentity configurations to 6, for more variety.

1.0
- Initial release

Equipment

This expansion declares no equipment.

Ships

Name
ERH Back section
erh_chaotic
erh_entrydock
ERH Entry section
ERH Main section
ERH Pipe
erh_pirate
ERH Platform
ERH Solar panel
erh_standard

Models

This expansion declares no models.

Scripts

Path
Config/script.js
"use strict";
this.name = "ERH_Corrections";
this.author = "phkb";
this.copyright = "2024 phkb";
this.license = "CC BY-NC-SA 4.0";

// in some circumstances, when using the old version of Pirate Coves, an extra rock hermit
// can become a pirate cove. To me this doesn't make sense, as the roles would seem to make this
// impossible. But it appears to be happening to others, if not me.
// These routines will apply a small correction to those ERH stations that end up being pirate coves.
// Because they will have all subentities defined, we just add the missing property to the ship
// which VimanaX HUD can pick up and so display the correct ship image.

this.systemWillPopulate = function() {
    this._onceOnly = true;
}

this.systemWillRepopulate = function() {
    if (this._onceOnly == true) {
        this._onceOnly = false;
        var rhn = system.shipsWithRole("extrarockhermit")
        for (var i = 0; i < rhn.length; i++) {
            if (rhn[i].script.name != "ExtraRockHermit_Spawn") {
                // found one
                rhn[i]._rhStyle = 5; // default - has everything
            }
        }
    }
}
Scripts/erh_conditions.js
"use strict";
this.name = "ERH_Condition_Script";
this.author = "phkb";
this.copyright = "2024 phkb";
this.license = "CC BY-NC-SA 4.0";

//----------------------------------------------------------------------------------------
this.allowSpawnShip = function(shipKey) {
    // don't get in the way of Commies spawning routines
    if (system.government == 4 && worldScripts["communist_population"]) return false;
    var seed = 230; // default for erh_standard
    switch (shipKey) {
        case "erh_chaotic": seed = 240; break;
        case "erh_pirate": seed = 250; break;
    }
    var check = system.scrambledPseudoRandomNumber(seed + this.$totalRockHermits(shipKey));
    return (check < 0.35);
}

//----------------------------------------------------------------------------------------
this.$totalRockHermits = function(shipKey) {
    switch (shipKey) {
        case "erh_standard": return system.countShipsWithRole("rockhermit");
        case "erh_chaotic": return system.countShipsWithRole("rockhermit-chaotic");
        case "erh_pirate": return system.countShipsWithRole("rockhermit-pirate");
    }
    return 0;
}
Scripts/erh_spawn.js
"use strict";
this.name = "ExtraRockHermit_Spawn";
this.author = "phkb";
this.description = "Looks after setup of extra rock hermits";
this.copyright = "2024 phkb";
this.license = "CC BY-NC-SA 4.0";

this._debug = true;

//----------------------------------------------------------------------------------------
this.shipSpawned = function() {
    if (this._debug) log(this.name, "extra rock hermit spawning in " + system.name + " for role " + this.ship.primaryRole);

    var num = system.sun["_erh_" + this.ship.primaryRole]; //system.countShipsWithRole(this.ship.primaryRole);
    if (!num) num = 0;

    // pick from our available rock textures
    var textures = ["griff_erh_rock1", "griff_erh_rock2", "griff_erh_rock3", "griff_erh_rock4"];
    var seed = (system.ID + this.ship.primaryRole.length) * 2;
    var rocktype = (parseInt(system.scrambledPseudoRandomNumber(seed) * 4) + num) % 4;
    var diff = textures[rocktype] + ".png";
    var norm = textures[rocktype] + "_normal.png";
    var spec = textures[rocktype] + "_specular.png";

    if (this._debug) log(this.name, "using " + diff + " for rock texture (" + num + " rh's in system)");
    // set the materials for the rh
    this.ship.setMaterials({"griff_spacebar_rock.png":{
        diffuse_map:diff,
        normal_map:norm,
        specular_map:spec,
        gloss:0.4,
        specular_color:[0.1, 0.1, 0.1, 1.0]}
    });

    var subents = this.ship.subEntities;
    var tl = system.techLevel;
    // make it possible for other rock hermits to have other styles by having a completely random roll for chaotic and pirate roles
    if (this.ship.primaryRole == "rockhermit-chaotic") tl = (tl + parseInt(system.scrambledPseudoRandomNumber(77) * 15)) % 15;
    if (this.ship.primaryRole == "rockhermit-pirate") tl = (tl + parseInt(system.scrambledPseudoRandomNumber(88) * 15)) % 15;
    var style = (parseInt((tl + 1) / 6) + num) % 6;
    this.ship._rhStyle = style;
    if (this._debug) log(this.name, "setting style to " + style);

    var eds = worldScripts.ExternalDockSystem;
    var rem = [];
    switch (style) {
        // style 0 - no extras
        case 0: rem = [2,3,4,5,6]; break;
        // style 1 - main building only
        case 1: rem = [5,6]; break;
        // style 2 - external dock only
        case 2: rem = [2,3,4,5]; break;
        // style 3 - main building and external dock
        case 3: rem = [5]; break;
        // style 4 - main building plus back section
        case 4: rem = [6]; break;
        // style 5 - main building plus back section plus external dock - don't remove anything
        case 5: rem = []; break;
    }
    var i = rem.length;
    while (i--) {
        subents[rem[i]].remove();
    }
    
    // if we've got a landing pad and eds is installed, set up the external dock
    if (eds && rem.indexOf(6) == -1) {
        this.$registerExternalDocks(this.ship);
    } else {
        this.$removeExternalDockFlashers();
    }
    num += 1;
    system.sun["_erh_" + this.ship.primaryRole] = num;
}

//----------------------------------------------------------------------------------------
// get rid of the flashers on the external dock
this.$removeExternalDockFlashers = function() {
    var fa = this.ship.flashers;
    var last = fa.length;
    while (last--) {
        fa[last].remove();
        if (last == 10) break;
    }
}

//----------------------------------------------------------------------------------------
// registers our external docks with the eds
this.$registerExternalDocks = function () {
    // set up the timer to let the player know about the docks
    this._timer = new Timer(this, this.$externalDockNotification, 2, 2);

    var eds = worldScripts.ExternalDockSystem;
    eds.$addExternalDock({station:this.ship, position:[-550, 0, 22], scale:0.5, preDockCallback:this.$preDockSetup.bind(this)});
}

//----------------------------------------------------------------------------------------
this.$preDockSetup = function(station) {
    // docking at the external port will still get you transferred inside
    player.addMessageToArrivalReport(expandDescription("[erh_redocked]"));
}

//----------------------------------------------------------------------------------------
this.$externalDockNotification = function $externalDockNotification() {
	if (this._externalDockNotification == false) {
		if (this.ship.position.distanceTo(player.ship) < player.ship.scannerRange * 0.85) {
			this.ship.commsMessage(expandDescription("[erh_external_dock]"), player.ship);
			this._externalDockNotification = true;
		}
	} else {
		this._timer.stop();
	}
}