Changing Ships Sample

Freeform discussion about anything related to modding Transcendence.
Post Reply
george moromisato
Developer
Developer
Posts: 2997
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Here is the code that I used to test changing ships:

Code: Select all

<?xml version="1.0" ?>

<!DOCTYPE TranscendenceAdventure
	[
	<!ENTITY unidAdventure		"0xA1000100">
	<!ENTITY ssTestSystem1		"0xA1000101">
	<!ENTITY stShipDealer		"0xA1000102">
	]>

<TranscendenceAdventure 
		UNID=				"&unidAdventure;"
		version=			"1.1"
		name=				"Changing Ships (Sample)"
		>

	<AdventureDesc
		    UNID=				"&unidAdventure;"
			name=				"Changing Ships (Sample)"
			backgroundID=		""
			>
	</AdventureDesc>

	<!-- Ship Dealer -->

	<StationType UNID="&stShipDealer;"
			name=				"Corporate ship dealer"
			sovereign=			"&svCorporate;"
			dockScreen=			"Main"
			abandonedScreen=	"&dsAbandonedStation;"
			dockingPorts=		"8"
			canAttack=			"true"

			multiHull=			"true"
			armorID=			"&itAdvancedPlasteelPlate;"
			maxHitPoints=		"350"
			hitPoints=			"350"
			repairRate=			"5"
			explosionType=		"&vtThermoExplosion1;"
			ejectaType=			"&vtWreckEjecta;"

			attributes=			"corporate,independent,friendly,envAir,envEarth,envFire,envWater,populated"
			levelFrequency=		"--rcu ur--- ----- ----- -----"
			locationCriteria=	"+planetary,-asteroids"
			enemyExclusionRadius="50"
			>

		<Image			imageID="&rsStations4;" imageX="128" imageY="192" imageWidth="128" imageHeight="256"/>

		<Ships>
			<Lookup count="2" table="&tbCorpDefenders;"/>
			<Lookup count="1" table="&tbCommPrivateCrafts;"/>
		</Ships>

		<Events>
			<OnCreate>
				(block (theShip)
					; Create a player ship and dock it to the station
					(setq theShip (sysCreateShip &scEI100XPlayer; (objGetPos gSource) &svCorporate;))
					(shpOrder theShip 'dock gSource)
					)
			</OnCreate>

			<OnDestroy>
				(intCorporateOnDestroy)
			</OnDestroy>
		</Events>

		<DockScreens>
			<Main
				name=			"=(objGetName gSource)"
				>

				<OnInit>
					(intCorporateOnInit "Main")
				</OnInit>

				<Panes>
					<Default
							desc=	"You are docked at ship dealer.">

						<Actions>
							<Action name="Switch" default="1" key="S">
								(block (theShip)
									; Find a player ship
									(setq theShip (random (sysFindObject gSource "sZ O:docked; +playerClass;")))
									
									; Do it
									(if theShip
										(block Nil
											(plyChangeShip gPlayer theShip)
											(scrExitDock gScreen)
											)
										)
									)
							</Action>

							<Action name="Undock" cancel="1" key="U">
								<Exit/>
							</Action>

						</Actions>

					</Default>

				</Panes>
			</Main>

		</DockScreens>

		<DockingPorts>
			<Port x="0"		y="90" />
			<Port x="0"		y="-90" />
			<Port x="60"	y="60" />
			<Port x="60"	y="-60" />
			<Port x="90"	y="0" />
			<Port x="-90"	y="0" />
			<Port x="-60"	y="60" />
			<Port x="-60"	y="-60" />
		</DockingPorts>

	</StationType>
	
	<!-- Topology -->

	<SystemTopology>

		<!-- NOTE: ID must be SE because that's where player ships start -->
		
		<Node ID="SE" rootNode="true">
			<System name="Test"				level="1">
				<System UNID="&ssTestSystem1;"/>
			</System>

			<StarGates>
				<StarGate Name="Outbound" DestID="EndGame"/>
			</StarGates>
		</Node>

		<Node ID="EndGame"
				endGame="true"
				endGameReason="escaped"
				epitaph="escaped the Sample Adventure"
				>
		</Node>

	</SystemTopology>

	<!-- Test System -->

	<SystemType UNID="&ssTestSystem1;">
		<SystemGroup>
			<Station type="&stG-TypeStar;" name="TestStar"/>

			<Orbitals distance="120">
				<Group>
					<Marker objName="Start"/>
					
					<Siblings arcInc="16">
						<Lookup table="StargateOutbound"/>
					</Siblings>

					<Siblings arcInc="-16">
						<Station type="&stShipDealer;"/>
					</Siblings>
				</Group>
			</Orbitals>
		</SystemGroup>
	</SystemType>

</TranscendenceAdventure>
NOTE: By convention I'm using the attribute 'playerClass' to mark a class that has the <PlayerSettings> attribute.
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

George, it looks great. Can't wait to dig into it. But I would like to echo Prophets request for a function that does the check internally, instead of depending on the modder adding an attribute. (shpIsPlayerShip shp) -> true/nil would be really handy. Thing is, we have tons of ships on xelerus that don't have this attribute. Additionally it protects agains misspellings, omissions and misuse (modders labeling ships as playership, that aren't).

As usual, thx for the hard work :)
george moromisato
Developer
Developer
Posts: 2997
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

alterecco wrote:George, it looks great. Can't wait to dig into it. But I would like to echo Prophets request for a function that does the check internally, instead of depending on the modder adding an attribute. (shpIsPlayerShip shp) -> true/nil would be really handy. Thing is, we have tons of ships on xelerus that don't have this attribute. Additionally it protects agains misspellings, omissions and misuse (modders labeling ships as playership, that aren't).

As usual, thx for the hard work :)
Good point. I can do that for the next version.

I want to implement that as a "special attribute". As you probably know, there is a syntax for selecting special attributes.

For example:

Code: Select all

(sysFindObject Nil "s +unid:0x3001;")
This will return all ships in the system with unid=0x3001. [The colon in the attribute means that it is special; i.e., we don't look for it in the attribute list but instead interpret it natively.]

I will probably introduce a new syntax like:

Code: Select all

(sysFindObject Nil "s +[isPlayerShip]")
Where the brackets indicate that this is a special boolean attribute that we have to compute.
User avatar
Aury
Fleet Admiral
Fleet Admiral
Posts: 5421
Joined: Tue Feb 05, 2008 1:10 am
Location: Somewhere in the Frontier on a Hycrotan station, working on new ships.

:D
Thanks for the example george!
So we're getting the special attribute in 1.03?
(alterecco and I were talkinga bout this last night)
(shpOrder gPlayership 'barrelRoll)
(plySetGenome gPlayer (list 'Varalyn 'nonBinary))
Homelab Servers: Xeon Silver 4110, 16GB | Via Quadcore C4650, 16GB | Athlon 200GE, 8GB | i7 7800X, 32GB | Threadripper 1950X, 32GB | Atom x5 8350, 4GB | Opteron 8174, 16GB | Xeon E5 2620 v3, 8GB | 2x Xeon Silver 4116, 96GB, 2x 1080ti | i7 8700, 32GB, 6500XT
Workstations & Render machines: Threadripper 3990X, 128GB, 6900XT | Threadripper 2990WX, 32GB, 1080ti | Xeon Platinum 8173M, 48GB, 1070ti | R9 3900X, 16GB, Vega64 | 2x E5 2430L v2, 24GB, 970 | R7 3700X, 32GB, A6000
Gaming Systems: R9 5950X, 32GB, 6700XT
Office Systems: Xeon 5318Y, 256GB, A4000
Misc Systems: R5 3500U, 20GB | R5 2400G, 16GB | i5 7640X, 16GB, Vega56 | E5 2620, 8GB, R5 260 | P4 1.8ghz, 0.75GB, Voodoo 5 5500 | Athlon 64 x2 4400+, 1.5GB, FX 5800 Ultra | Pentium D 3.2ghz, 4GB, 7600gt | Celeron g460, 8GB, 730gt | 2x Athlon FX 74, 8GB, 8800gts 512 | FX 9590, 16GB, R9 295x2 | E350, 8GB | Phenom X4 2.6ghz, 16GB, 8800gt | random core2 duo/atom/i5/i7 laptops
george moromisato
Developer
Developer
Posts: 2997
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Wolfy wrote::D
Thanks for the example george!
So we're getting the special attribute in 1.03?
(alterecco and I were talkinga bout this last night)
Yea, It's on my list for 1.03.
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

george moromisato wrote:As you probably know, there is a syntax for selecting special attributes.

For example:

Code: Select all

(sysFindObject Nil "s +unid:0x3001;")
:shock: - No, I did not know that! Very interesting. Are there any other existing special attribute selectors? I will add them to the wiki.
george moromisato wrote: I will probably introduce a new syntax like:

Code: Select all

(sysFindObject Nil "s +[isPlayerShip]")
OK, that is nice. For me the most important is that it works for typFind and objMatches, since I can mostly see myself using it in that context.
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

is there a way of disabling other resurrection systems? For example I don't want to waste my insurance on a robotic scout ship.

Also is resurrection only tied to the player? For example you have a group of ships that follow you around and protect you when not in direct control but can be directly controlled. I would like them to be individually insured and replaced if I am or not in control of that ship.
Crying is not a proper retort!
User avatar
Aury
Fleet Admiral
Fleet Admiral
Posts: 5421
Joined: Tue Feb 05, 2008 1:10 am
Location: Somewhere in the Frontier on a Hycrotan station, working on new ships.

If I use an <onDestroy> to swap playerships, will the player death events kick into action? Will it even work? XD
(shpOrder gPlayership 'barrelRoll)
(plySetGenome gPlayer (list 'Varalyn 'nonBinary))
Homelab Servers: Xeon Silver 4110, 16GB | Via Quadcore C4650, 16GB | Athlon 200GE, 8GB | i7 7800X, 32GB | Threadripper 1950X, 32GB | Atom x5 8350, 4GB | Opteron 8174, 16GB | Xeon E5 2620 v3, 8GB | 2x Xeon Silver 4116, 96GB, 2x 1080ti | i7 8700, 32GB, 6500XT
Workstations & Render machines: Threadripper 3990X, 128GB, 6900XT | Threadripper 2990WX, 32GB, 1080ti | Xeon Platinum 8173M, 48GB, 1070ti | R9 3900X, 16GB, Vega64 | 2x E5 2430L v2, 24GB, 970 | R7 3700X, 32GB, A6000
Gaming Systems: R9 5950X, 32GB, 6700XT
Office Systems: Xeon 5318Y, 256GB, A4000
Misc Systems: R5 3500U, 20GB | R5 2400G, 16GB | i5 7640X, 16GB, Vega56 | E5 2620, 8GB, R5 260 | P4 1.8ghz, 0.75GB, Voodoo 5 5500 | Athlon 64 x2 4400+, 1.5GB, FX 5800 Ultra | Pentium D 3.2ghz, 4GB, 7600gt | Celeron g460, 8GB, 730gt | 2x Athlon FX 74, 8GB, 8800gts 512 | FX 9590, 16GB, R9 295x2 | E350, 8GB | Phenom X4 2.6ghz, 16GB, 8800gt | random core2 duo/atom/i5/i7 laptops
george moromisato
Developer
Developer
Posts: 2997
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Betelgeuse wrote:is there a way of disabling other resurrection systems? For example I don't want to waste my insurance on a robotic scout ship.

Also is resurrection only tied to the player? For example you have a group of ships that follow you around and protect you when not in direct control but can be directly controlled. I would like them to be individually insured and replaced if I am or not in control of that ship.
BTW: For 1.03 I'm planning (but no promises) to add a function to switch the current POVs. This is different from switching player ships in that gPlayerShip remains the same (you continue to "be" the same ship). But you see and can manipulate a different ship (e.g., by remote control).

I think this is a better function for what you want, since resurrection won't kick-in for a robotic ship.
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

george moromisato wrote:
Betelgeuse wrote:is there a way of disabling other resurrection systems? For example I don't want to waste my insurance on a robotic scout ship.

Also is resurrection only tied to the player? For example you have a group of ships that follow you around and protect you when not in direct control but can be directly controlled. I would like them to be individually insured and replaced if I am or not in control of that ship.
BTW: For 1.03 I'm planning (but no promises) to add a function to switch the current POVs. This is different from switching player ships in that gPlayerShip remains the same (you continue to "be" the same ship). But you see and can manipulate a different ship (e.g., by remote control).

I think this is a better function for what you want, since resurrection won't kick-in for a robotic ship.
sounds good. That way you can have a event on your main ship to resurrect the companion ships in the event of destruction. What will happen when what you are in control of gets destroyed?

This could also be used for things like showing space that isn't near the player. (put them in a "star") Then returning to the main ship.

This could also be used for controlling player bases. They could have their own internal dockscreens allowing you to set them up the way you want and still act differently when normal docking.

eta:
Will we have a way of telling where the player is looking or has control of?
What will happen if the ship goes through a gate or starts in a different system?

eta2:
Will stations be valid pov? Will you be able to have a separate internal dockscreen for them?
Crying is not a proper retort!
User avatar
Prophet
Militia Captain
Militia Captain
Posts: 826
Joined: Tue Nov 18, 2008 6:09 pm

Can I request some new events?

<OnGlobalPlayerShipDestroyed>
Allows custom definition of what ship to switch to, resurrection prefs, and what to do with other player owned ships (move to sys X, destroy, order to wait)
This would be the one-stop place for solving most of the new problems without going back and either adding events to existing ships (causing conflicts) or every modder overwriting the initial ships with their own versions of <OnDestroy> events.

<OnGlobalPlayerOwnedDestroyed>
Fires when a ship owned by the player (but doesn't hold the playership data), similar to the above event.
Coming soon: The Syrtian War adventure mod!
A Turret defense genre mod exploring the worst era in Earth's history.
Can you defend the Earth from the Syrtian invaders?
Stay tuned for updates!
User avatar
Aury
Fleet Admiral
Fleet Admiral
Posts: 5421
Joined: Tue Feb 05, 2008 1:10 am
Location: Somewhere in the Frontier on a Hycrotan station, working on new ships.

:o
POV switching! this will be so awesome! I can do virtual camera ships and all sorts of awesome stuff! :D
Cutscenes, here we come! :D (I wonder if it's possible to make an entire scripted movie; no to "playthroughs" are ever the same!)
(shpOrder gPlayership 'barrelRoll)
(plySetGenome gPlayer (list 'Varalyn 'nonBinary))
Homelab Servers: Xeon Silver 4110, 16GB | Via Quadcore C4650, 16GB | Athlon 200GE, 8GB | i7 7800X, 32GB | Threadripper 1950X, 32GB | Atom x5 8350, 4GB | Opteron 8174, 16GB | Xeon E5 2620 v3, 8GB | 2x Xeon Silver 4116, 96GB, 2x 1080ti | i7 8700, 32GB, 6500XT
Workstations & Render machines: Threadripper 3990X, 128GB, 6900XT | Threadripper 2990WX, 32GB, 1080ti | Xeon Platinum 8173M, 48GB, 1070ti | R9 3900X, 16GB, Vega64 | 2x E5 2430L v2, 24GB, 970 | R7 3700X, 32GB, A6000
Gaming Systems: R9 5950X, 32GB, 6700XT
Office Systems: Xeon 5318Y, 256GB, A4000
Misc Systems: R5 3500U, 20GB | R5 2400G, 16GB | i5 7640X, 16GB, Vega56 | E5 2620, 8GB, R5 260 | P4 1.8ghz, 0.75GB, Voodoo 5 5500 | Athlon 64 x2 4400+, 1.5GB, FX 5800 Ultra | Pentium D 3.2ghz, 4GB, 7600gt | Celeron g460, 8GB, 730gt | 2x Athlon FX 74, 8GB, 8800gts 512 | FX 9590, 16GB, R9 295x2 | E350, 8GB | Phenom X4 2.6ghz, 16GB, 8800gt | random core2 duo/atom/i5/i7 laptops
Post Reply