Conditional Stuff

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

Post Reply
User avatar
Killer Wolf
---- E L I T E ----
---- E L I T E ----
Posts: 2268
Joined: Tue Jan 02, 2007 12:38 pm

Conditional Stuff

Post by Killer Wolf »

is it possible to use the "allowOfferShip" function to make a ship only available for purchase at one station/system?

Is it possible to control the appearance of subents? eg, if i had a station w/ a couple of sub ent ships docked outside, could a script/whatever randomly make one or more of them disappear so the station always looked different?

TIA
Alnivel
Dangerous
Dangerous
Posts: 100
Joined: Fri Jun 10, 2022 7:05 pm

Re: Conditional Stuff

Post by Alnivel »

Killer Wolf wrote: Thu Sep 21, 2023 7:58 am
is it possible to use the "allowOfferShip" function to make a ship only available for purchase at one station/system?
At one system - yes:

Code: Select all

this.allowOfferShip = function(shipkey) {
    if(galaxyNumber === 0 && system.ID === 7) // Lave
        return true;
    else
        return false;
}
But for a specific station, you probably need to manually add a ship to the shipyard via addShipToShipyard at station's shipSpawned event.

Killer Wolf wrote: Thu Sep 21, 2023 7:58 am
Is it possible to control the appearance of subents? eg, if i had a station w/ a couple of sub ent ships docked outside, could a script/whatever randomly make one or more of them disappear so the station always looked different?

TIA
You can let them all appear and then remove the ones you don't need. But adding back removed subentities is quite troublesome and in some cases it can be easier instead of removing to hide a subentity inside the main entity if it is big enough.
Here is how to remove some subentities on the station's spawn:

Code: Select all

this.shipSpawned = function() {
    var subEntities = this.ship.subEntities;
    var i = subEntities.length;
    while(i--) {
        if(Math.random() < 0.1) // 10% chance each subentity to be removed
            subEntities[i].remove();
    }
}
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4809
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Conditional Stuff

Post by phkb »

Alnivel wrote: Thu Sep 21, 2023 10:03 am
But adding back removed subentities is quite troublesome
You can do it, but you have to add all of them back at once, and then go through the list again and remove the ones you don't want.

To restore all subentities use:

Code: Select all

    mystation.restoreSubEntities();
User avatar
Killer Wolf
---- E L I T E ----
---- E L I T E ----
Posts: 2268
Joined: Tue Jan 02, 2007 12:38 pm

Re: Conditional Stuff

Post by Killer Wolf »

Much obliged, i'll check those out. i don't really need to add things back, i was thinking of having some subent ships/whatever hanging about in random order just to add colour - you might see one thing, or several, or none if a random scripty thing can zap them. i'll try a bit play wehn i've finished the models.
User avatar
cbr
---- E L I T E ----
---- E L I T E ----
Posts: 1401
Joined: Thu Aug 27, 2015 4:24 pm

Re: Conditional Stuff

Post by cbr »

Could/can you just 'add' ships with somekind of nullai?

Calculating the rotating position will be perhaps a bit difficult but Thargoid's yah-board position was calculated from the towing ship...
User avatar
Killer Wolf
---- E L I T E ----
---- E L I T E ----
Posts: 2268
Joined: Tue Jan 02, 2007 12:38 pm

Re: Conditional Stuff

Post by Killer Wolf »

Not sure i could do it accurately. The only spawn script i have is the one that sticks a station some specified distance along a line from witchpoint-sun etc etc. Rotation isn't a problem but accuracy is. Would be far easier to define the items as part of the model and either spawn or spawn-kill them.
Post Reply