Page 1 of 1

Spawning a Ship/Station in a Predefined System

Posted: Fri May 20, 2016 2:43 am
by RPC
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.

Re: Spawning a Ship/Station in a Predefined System

Posted: Sat May 21, 2016 3:15 pm
by TheLoneWolf
That was helpful!

Re: Spawning a Ship/Station in a Predefined System

Posted: Sat May 21, 2016 3:43 pm
by AssumedPseudonym
 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.

Re: Spawning a Ship/Station in a Predefined System

Posted: Sat May 21, 2016 6:22 pm
by Xephyr
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)

Re: Spawning a Ship/Station in a Predefined System

Posted: Sun May 22, 2016 1:39 am
by TheLoneWolf
@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?

Re: Spawning a Ship/Station in a Predefined System

Posted: Sun May 22, 2016 1:45 am
by Xephyr
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.

Re: Spawning a Ship/Station in a Predefined System

Posted: Sun May 22, 2016 1:50 am
by TheLoneWolf
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!

Re: Spawning a Ship/Station in a Predefined System

Posted: Sun May 22, 2016 7:26 am
by AssumedPseudonym
 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.

Re: Spawning a Ship/Station in a Predefined System

Posted: Mon May 23, 2016 7:41 am
by TheLoneWolf
One Xeph to rule them all ^.^