Destroying the main station via script

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

Moderators: winston, another_commander

Post Reply
UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1246
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Destroying the main station via script

Post 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.
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Destroying the main station via script

Post 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
UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1246
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Re: Destroying the main station via script

Post 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.
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Destroying the main station via script

Post 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)
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Destroying the main station via script

Post 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.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: Destroying the main station via script

Post 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.
User avatar
DaddyHoggy
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 8515
Joined: Tue Dec 05, 2006 9:43 pm
Location: Newbury, UK
Contact:

Re: Destroying the main station via script

Post 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).
Selezen wrote:
Apparently I was having a DaddyHoggy moment.
Oolite Life is now revealed here
User avatar
Rorschachhamster
---- E L I T E ----
---- E L I T E ----
Posts: 274
Joined: Sun Aug 05, 2012 11:46 pm
Contact:

Re: Destroying the main station via script

Post 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:
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Destroying the main station via script

Post 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)
Duggan
---- E L I T E ----
---- E L I T E ----
Posts: 496
Joined: Sat Dec 31, 2011 2:58 pm

Re: Destroying the main station via script

Post 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. :)
Flying Python Class Cruiser, Chapter & Verse IV
User avatar
JazHaz
---- E L I T E ----
---- E L I T E ----
Posts: 2991
Joined: Tue Sep 22, 2009 11:07 am
Location: Enfield, Middlesex
Contact:

Re: Destroying the main station via script

Post by JazHaz »

Question, if all dockable stations and carriers been removed, could a Planetfall OXP location become a main station?
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2691
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Destroying the main station via script

Post 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.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: Destroying the main station via script

Post 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.
Post Reply