Spawning a Ship/Station in a Predefined System

This is a moderated forum that collects tutorials, guides, and references for creating Transcendence extensions and scripts.
Post Reply
User avatar
RPC
Fleet Admiral
Fleet Admiral
Posts: 2834
Joined: Thu Feb 03, 2011 5:21 am
Location: Hmm... I'm confused. Anybody have a starmap to the Core?

Spawning a Ship/Station in a Predefined System

Post by RPC » Fri May 20, 2016 2:43 am

The one way I like to do it is to create a virtual station, then use an event to spawn that station.

The idea is that OnGlobalSystemCreated creates a station for each system, then when that station is created it checks if the name of the system is right, then you get to spawn whatever you want using sysCreateShip or sysCreateStation.

Code: Select all

	<StationType UNID="&stVirtualStation;"
    name=               "Virtual Station"
    virtual=            "True"
    >
	<Events>
		<OnGlobalSystemCreated>
			(block Nil
				(sysCreateStation &stVirtualStation; nil)
				(if
					;(eq (sysGetName) "name of the system you want")
					(eq (sysGetName) "Eridani")
						(block Nil
							;here is where you spawn either a ship or a station
							;(sysCreateShip unid pos sovereignID [eventHandler]) 
							;(sysCreateStation unid pos [eventHandler])
							(sysCreateStation &stAresShipyard; (sysVectorPolarOffset Nil 0 0))
							)
					)
				)
		</OnGlobalSystemCreated>
	<Events>
</StationType>
The above sample code should produce an Ares Shipyard at Eridani.
Tutorial List on the Wiki and Installing Mods
Image<----- click to get to #Transcendence IRC on Freenode
Image
Der Tod ist der zeitlose Frieden und das leben ist der Krieg
Wir müssen wissen — wir werden wissen!
I don't want any sort of copyright on my Transcendence mods. Feel free to take/modify whatever you want.

User avatar
TheLoneWolf
Militia Captain
Militia Captain
Posts: 798
Joined: Thu Nov 28, 2013 5:03 pm
Location: Aboard the CSS Radiant

Re: Spawning a Ship/Station in a Predefined System

Post by TheLoneWolf » Sat May 21, 2016 3:15 pm

That was helpful!

User avatar
AssumedPseudonym
Militia Captain
Militia Captain
Posts: 915
Joined: Thu Aug 29, 2013 5:18 am
Location: On the other side of the screen.

Re: Spawning a Ship/Station in a Predefined System

Post by AssumedPseudonym » Sat May 21, 2016 3:43 pm

 If you’re wanting to put a unique station of your own design into a predefined system, you can even forgo the virtual station and just drop that whole <Events> section into the your station’s code.
Image

My mods on Xelerus: Click here!

Of all the things I’ve lost in life, I miss my mind the least. (I’m having a lot more fun without it!)

User avatar
Xephyr
Militia Captain
Militia Captain
Posts: 796
Joined: Fri Dec 14, 2007 1:52 am
Location: Orion Arm, Milky Way

Re: Spawning a Ship/Station in a Predefined System

Post by Xephyr » Sat May 21, 2016 6:22 pm

What I've been doing more recently is putting that kind of thing in the <Encounter> info, which is pretty versatile

Code: Select all

<Encounter
	numberAppearing=	"1"
	systemCriteria=		"+nodeID:YourNodeHere;"
	locationCriteria=	"*outerSystem"
	enemyExclusionRadius="150"
	/>
This will place exactly one station in the given node, UNLESS the system has "NoExtraEncounters" set to "true", in which case you'll have to use code.

For extensions that expand on vanilla but take place in their own area of space, using systemCriteria to filter out systems by attribute is immensely helpful in keeping your stations out of the mainline.

Other accepted fields are levelFrequency, minAppearing, and maxAppearing (and probably a few others)
Project Renegade (Beta) : "The Poor Man's Corporate Command!"
"Cowards die many times before their deaths; The valiant never taste of death but once. " -Julius Caesar as written by William Shakespeare, a notorious permadeath player.

User avatar
TheLoneWolf
Militia Captain
Militia Captain
Posts: 798
Joined: Thu Nov 28, 2013 5:03 pm
Location: Aboard the CSS Radiant

Re: Spawning a Ship/Station in a Predefined System

Post by TheLoneWolf » Sun May 22, 2016 1:39 am

@RPC
Yeah I wanted to do that! And I just did! Thank you :D

@Xephyr
You're using numberAppearing, and that ain't device code :/
Mind taking a look at my thread (Usage of numberAppearing) in Shipyards?

User avatar
Xephyr
Militia Captain
Militia Captain
Posts: 796
Joined: Fri Dec 14, 2007 1:52 am
Location: Orion Arm, Milky Way

Re: Spawning a Ship/Station in a Predefined System

Post by Xephyr » Sun May 22, 2016 1:45 am

TheLoneWolf wrote: @Xephyr
You're using numberAppearing, and that ain't device code :/
Mind taking a look at my thread (Usage of numberAppearing) in Shipyards?
numberAppearing in this case, on stations, means that one station will appear in the given node. Since there's more than one spot that can fulfill the location criteria, it prevents it from spawning more than once. If you wanted to limit the station to appearing only a maximum of times, then you would use maxAppearing.

However, for items, AssumedPseudonym's post in your thread is spot on. It just determines how big a stack will generate. If you want to create only a given number of a certain item, you should put the notRandom attribute on it and generate it in via code or an item table.
Project Renegade (Beta) : "The Poor Man's Corporate Command!"
"Cowards die many times before their deaths; The valiant never taste of death but once. " -Julius Caesar as written by William Shakespeare, a notorious permadeath player.

User avatar
TheLoneWolf
Militia Captain
Militia Captain
Posts: 798
Joined: Thu Nov 28, 2013 5:03 pm
Location: Aboard the CSS Radiant

Re: Spawning a Ship/Station in a Predefined System

Post by TheLoneWolf » Sun May 22, 2016 1:50 am

I trust AP :D

Can't we use minAppearing and maxAppearing at the same time?

Code: Select all

minAppearing= "1"
+

Code: Select all

maxAppearing= "1"
=
A unique encounter!

User avatar
AssumedPseudonym
Militia Captain
Militia Captain
Posts: 915
Joined: Thu Aug 29, 2013 5:18 am
Location: On the other side of the screen.

Re: Spawning a Ship/Station in a Predefined System

Post by AssumedPseudonym » Sun May 22, 2016 7:26 am

 That would probably also work.
TheLoneWolf wrote:I trust AP :D
 And I trust Xephyr. If Xeph says that numberAppearing works in <Encounter> stuff, it probably does.
Image

My mods on Xelerus: Click here!

Of all the things I’ve lost in life, I miss my mind the least. (I’m having a lot more fun without it!)

User avatar
TheLoneWolf
Militia Captain
Militia Captain
Posts: 798
Joined: Thu Nov 28, 2013 5:03 pm
Location: Aboard the CSS Radiant

Re: Spawning a Ship/Station in a Predefined System

Post by TheLoneWolf » Mon May 23, 2016 7:41 am

One Xeph to rule them all ^.^

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests