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
RPC
Fleet Admiral
Fleet Admiral
Posts: 2876
Joined: Thu Feb 03, 2011 5:21 am
Location: Hmm... I'm confused. Anybody have a starmap to the Core?

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
Get on Discord for mod help and general chat
Image
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: 802
Joined: Thu Nov 28, 2013 5:03 pm
Location: Aboard the CSS Radiant

That was helpful!
User avatar
AssumedPseudonym
Fleet Officer
Fleet Officer
Posts: 1190
Joined: Thu Aug 29, 2013 5:18 am
Location: On the other side of the screen.

 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

Mod prefixes: 0xA010 (registered) and 0xDCC8 (miscellaneous)

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: 857
Joined: Fri Dec 14, 2007 1:52 am
Location: Orion Arm, Milky Way
Contact:

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!"
Real programmers count from 0. And sometimes I do, too.
User avatar
TheLoneWolf
Militia Captain
Militia Captain
Posts: 802
Joined: Thu Nov 28, 2013 5:03 pm
Location: Aboard the CSS Radiant

@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: 857
Joined: Fri Dec 14, 2007 1:52 am
Location: Orion Arm, Milky Way
Contact:

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!"
Real programmers count from 0. And sometimes I do, too.
User avatar
TheLoneWolf
Militia Captain
Militia Captain
Posts: 802
Joined: Thu Nov 28, 2013 5:03 pm
Location: Aboard the CSS Radiant

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
Fleet Officer
Fleet Officer
Posts: 1190
Joined: Thu Aug 29, 2013 5:18 am
Location: On the other side of the screen.

 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

Mod prefixes: 0xA010 (registered) and 0xDCC8 (miscellaneous)

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: 802
Joined: Thu Nov 28, 2013 5:03 pm
Location: Aboard the CSS Radiant

One Xeph to rule them all ^.^
Post Reply