Page 1 of 1

Destroying the main station via script

Posted: Sat Sep 28, 2013 8:14 pm
by UK_Eliter
Dear all

I would like to destroy the main station in a system (if only until the player leaves the system and then returns - and such a temporary destruction is all that is possible without repeatedly removing the station, apparently, and that's fine for my purposes). But how to do this? Apologies if this has been treated elsewhere. What I do get from elsewhere, is that I need (via script or AI) to hit the station, along the following lines (from https://bb.oolite.space/viewtopic.php?p=37676):
LittleBear wrote:
Even the main station can be destroyed if you hit it with an object that deals a stupidly high (999999999999999) weapon_energy. This is how the Doomsday Asteroid destroys the main station in AsteroidStorm and the Gravition Missile destroys the Balrog in Assassins. But nothing that normally appears in the game has enough weapons_energy. As CM says though the station will be back next time, unless the OXP script is set to remove it.
So is that the only way, please?

PS: This is for the 'thargoid invasion' bit of my ExtraThargoids OXP.

Re: Destroying the main station via script

Posted: Sat Sep 28, 2013 8:32 pm
by Commander McLane
You only need to put

Code: Select all

system.mainStation.remove();
into your world script at a convenient place. If you want it to go out with a bang, you need

Code: Select all

system.mainStation.explode();
See here for the documentation: Image http://wiki.alioth.net/index.php/Oolite ... ence:_Ship

Re: Destroying the main station via script

Posted: Sat Sep 28, 2013 9:54 pm
by UK_Eliter
Thanks, McLane. I did that (namely, 'system.mainStation.explode()') and . . had interesting results. To wit: when I used the Long Range Scanner equipment to transport myself to the system station (from the witchpoint), it put me by a pirate cove - which proved indestructable (even by q-mine and crashing my ship into it on injectors) and which started launching police. The cove had become the main station.

I'd like to avoid these consequences!

PS: I issued the command 'system.mainStation.explode()') within a 'this.shipExitedWitchspace'. I've Oolite version 1.77.

Re: Destroying the main station via script

Posted: Sat Sep 28, 2013 10:05 pm
by cim
UK_Eliter wrote:
I'd like to avoid these consequences!
Make sure you remove all the other stations first. (Carriers - i.e. stations with a max speed greater than zero - can be left in)

Re: Destroying the main station via script

Posted: Sat Sep 28, 2013 10:45 pm
by Commander McLane
cim wrote:
UK_Eliter wrote:
I'd like to avoid these consequences!
Make sure you remove all the other stations first. (Carriers - i.e. stations with a max speed greater than zero - can be left in)
To elaborate a little on this:

The game engine wants a main station to exist in every system. That's important for game play, because it's the only place where you can save and load. Therefore, it makes the main station indestructible by ordinary weapons.

If you circumvent this security measure by removing the main station via script, the game engine counters that manoeuvre by immediately promoting another station in the system to main station status. To be precise: the closest other dockable entity becomes the main station, where you can save and load. In your case, this was a rock hermit.

Thus, if you want to make sure that no other station gets promoted and becomes the main station, you have to remove each and every dockable entity from the system before removing the main station. There is no other way.

Re: Destroying the main station via script

Posted: Sun Sep 29, 2013 7:51 am
by JensAyton
Commander McLane wrote:
If you circumvent this security measure by removing the main station via script, the game engine counters that manoeuvre by immediately promoting another station in the system to main station status. To be precise: the closest other immobile dockable entity becomes the main station, where you can save and load. In your case, this was a rock hermit.

Thus, if you want to make sure that no other station gets promoted and becomes the main station, you have to remove each and every stationary ha ha dockable entity from the system before removing the main station. There is no other way.
FTFY.

We should probably expose isExplicitlyNotMainStation through shipdata… The game will get cranky if you have an inhabited system with no main station, though. For instance, the main station defines they system’s default market.

Re: Destroying the main station via script

Posted: Sun Sep 29, 2013 8:14 am
by DaddyHoggy
Thought: (May have been answered elsewhere) If Oolite engine makes a dockable station a main station if the native main station is removed then would it be possible to make an OXP that keeps track of all dockable entities in a particular system, then, when a player approaches any in-system station to dock, the OXP removes all the other stations (possibly including the main station), thus promoting the station that is about to be docked with to the role of main station and therefore it can be saved at. (Once docked, OXP could regenerate other stations, just in case player is planning going elsewhere in the system and/or NPC ships don't all start making their way to the only dockable entity in the system)

(I do vaguely recall that Cim mentioned that future versions of Oolite will allow saving at any station - so this may now be a moot point).

Re: Destroying the main station via script

Posted: Sun Sep 29, 2013 8:16 am
by Rorschachhamster
Maybe a workaround could be to create a destroyed main station to fool the system, a model that is not dockable. I don't know if this is doable, though... :wink:
Looked at the script on the wiki, if you place a dock somewhere where it's not visible inside the wreck and diable autodocking and fastdocking this could work... maybe? :D
Of course, this bogus station would probably still register as main station, so that NPCs would try to dock with it... I don't know if

Code: Select all

hasNPCTraffic = false;
could change that if it's the main station...
Just some rambling thoughts... :lol:

Re: Destroying the main station via script

Posted: Sun Sep 29, 2013 10:15 am
by cim
DaddyHoggy wrote:
would it be possible
You could certainly let them save there. Of course, they'd be back at the normal main station when they loaded the game again. There are other pitfalls too: I think for the most part they're possible to work around with the features available in 1.77, but I hope all the people with the programming skill and creativity to actually do so also have the restraint not to try...

1.79 will let you save at any stationary dockable where the author has given Oolite a reasonable expectation that a station of that location and type will still exist after a save/load cycle. (Giving that expectation will involve a small rewrite to the station OXPs)
Rorschachhamster wrote:
Of course, this bogus station would probably still register as main station, so that NPCs would try to dock with it... I don't know if

Code: Select all

hasNPCTraffic = false;
could change that if it's the main station...
Just some rambling thoughts... :lol:
hasNPCTraffic just stops the station launching ships except when explicitly instructed to - it doesn't affect docking. If you make the fake dock about a metre wide, nothing will actually try to dock with it, though they probably will still hang around outside waiting. The new 1.79 AIs could be told it was a restricted station and then would avoid it.

You would then have the slight oddity of an indestructible wreckage cloud, of course.
JensAyton wrote:
For instance, the main station defines they system’s default market.
Though, oddly, there is a separate system market defined independent of that, which is used to determine what counts as 'scarce' and 'plentiful' for filling trade holds.

Long-term I'd like to break the concept of "main station" up into its various bits - can be saved at, applies export offences, uses system market, etc. - so that the slight oddities around them aren't necessary any more (and you can have an inhabited system without one that still works)

Re: Destroying the main station via script

Posted: Sun Sep 29, 2013 9:28 pm
by Duggan
Mechanics aside (too complicated for my aged and addled brain) Those Thargoids could sure be getting whole lot more of a threat if they took out your only safe haven. I accept though that Thargoids were meant to be the main adversary right from the get go back in the day, so it might be quiet a good thing that they could properly throw said stick in your spokes.

AKA The Worserer and the Baderer the bugs could be would be sauce for the goose IMO. :)

Re: Destroying the main station via script

Posted: Mon Sep 30, 2013 1:54 pm
by JazHaz
Question, if all dockable stations and carriers been removed, could a Planetfall OXP location become a main station?

Re: Destroying the main station via script

Posted: Mon Sep 30, 2013 2:29 pm
by spara
JazHaz wrote:
Question, if all dockable stations and carriers been removed, could a Planetfall OXP location become a main station?
Probably not, as the ground station is not really there until you land.

Re: Destroying the main station via script

Posted: Mon Sep 30, 2013 8:40 pm
by Thargoid
Correct, the station is spawned at the moment of docking/landing and destroyed on launch. So it could only become the main station under very specific circumstances.